feat:App端代理商和管理端活动信息收集管理和家长参与代理商活动管理
This commit is contained in:
parent
e2fdadae2f
commit
29da542823
@ -329,6 +329,7 @@ public enum ResultCodeEnum {
|
||||
INVALID_AGENT(13004, "代理商不存在或已失效"),
|
||||
AGENT_STATUS_INVALID(13005, "代理商状态无效"),
|
||||
AGENT_EMPLOYEE_ALREADY_EXISTS(130051, "代理商员工已存在"),
|
||||
AGENT_EMPLOYEE_NOT_FOUND(130052, "代理商员工不存在"),
|
||||
AGENT_CONTACT_INFO_INVALID(13006, "联系信息无效"),
|
||||
AGENT_NON_PARTICIPANT_ACTIVE(130061, "代理商没有参与该活动"),
|
||||
ACTIVITY_NOT_FOUND(13007, "活动不存在"),
|
||||
@ -338,6 +339,7 @@ public enum ResultCodeEnum {
|
||||
PARENT_NOT_FOUND(13011, "家长不存在"),
|
||||
INVALID_ACTIVITY_STATUS(13012, "无效的活动状态"),
|
||||
AGENT_NOT_FOUND(13013, "代理商不存在"),
|
||||
AGENT_IS_EXISTS(13014, "代理商已存在"),
|
||||
PARENT_ALREADY_SIGN_UP(130121, "已经报名参加该活动"),
|
||||
UNAUTHORIZED_UPDATE_EMPLOYEE(13013, "无权限更新员工信息"),
|
||||
DATA_REPEAT_ERROR(130014, "数据重复"),
|
||||
|
||||
@ -2,6 +2,7 @@ package com.seer.teach.mp.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import com.seer.teach.common.entity.BaseEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
@ -56,7 +57,7 @@ public class MpActivityInfoCollectionEntity extends BaseEntity {
|
||||
* 孩子性别(M-男,F-女)
|
||||
*/
|
||||
@TableField("child_gender")
|
||||
private String childGender;
|
||||
private Integer childGender;
|
||||
|
||||
/**
|
||||
* 出生年月
|
||||
@ -68,7 +69,7 @@ public class MpActivityInfoCollectionEntity extends BaseEntity {
|
||||
* 年级
|
||||
*/
|
||||
@TableField("grade")
|
||||
private String grade;
|
||||
private Integer grade;
|
||||
|
||||
/**
|
||||
* 学校
|
||||
@ -76,6 +77,12 @@ public class MpActivityInfoCollectionEntity extends BaseEntity {
|
||||
@TableField("school")
|
||||
private String school;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@TableField("mobile")
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 地区
|
||||
*/
|
||||
@ -103,13 +110,13 @@ public class MpActivityInfoCollectionEntity extends BaseEntity {
|
||||
/**
|
||||
* 薄弱科目
|
||||
*/
|
||||
@TableField("weak_subject_ids")
|
||||
@TableField(value = "weak_subject_ids",typeHandler = JacksonTypeHandler.class)
|
||||
private List<Integer> weakSubjectIds;
|
||||
|
||||
/**
|
||||
* 优势科目
|
||||
*/
|
||||
@TableField("strong_subject_ids")
|
||||
@TableField(value = "strong_subject_ids",typeHandler = JacksonTypeHandler.class)
|
||||
private List<Integer> strongSubjectIds;
|
||||
|
||||
/**
|
||||
|
||||
@ -6,20 +6,14 @@ import com.seer.teach.common.ResultBean;
|
||||
import com.seer.teach.common.annotation.LogPrint;
|
||||
import com.seer.teach.mp.admin.controller.req.AgentQueryReq;
|
||||
import com.seer.teach.mp.admin.controller.req.MpAgentReq;
|
||||
import com.seer.teach.mp.admin.controller.req.MpAgentSaveReq;
|
||||
import com.seer.teach.mp.admin.controller.resp.AgentResp;
|
||||
import com.seer.teach.mp.admin.service.AdminAgentService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -49,14 +43,14 @@ public class AdminAgentController {
|
||||
@Operation(summary = "新增")
|
||||
@PostMapping
|
||||
@SaCheckPermission("mp:admin:agent:save")
|
||||
public ResultBean<Boolean> save(@RequestBody MpAgentReq req) {
|
||||
public ResultBean<Boolean> save(@RequestBody @Validated MpAgentSaveReq req) {
|
||||
return ResultBean.success(adminAgentService.saveAgent(req));
|
||||
}
|
||||
|
||||
@Operation(summary = "更新")
|
||||
@PutMapping
|
||||
@SaCheckPermission("mp:admin:agent:update")
|
||||
public ResultBean<Boolean> update(@RequestBody MpAgentReq req) {
|
||||
public ResultBean<Boolean> update(@RequestBody @Validated MpAgentReq req) {
|
||||
return ResultBean.success(adminAgentService.updateAgent(req));
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ import com.seer.teach.common.PageListBean;
|
||||
import com.seer.teach.common.ResultBean;
|
||||
import com.seer.teach.common.annotation.LogPrint;
|
||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeRelationQueryReq;
|
||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeRelationReq;
|
||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeUpdateReq;
|
||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeSaveReq;
|
||||
import com.seer.teach.mp.admin.controller.resp.AgentEmployeeRelationResp;
|
||||
import com.seer.teach.mp.admin.service.IAdminAgentEmployeeRelationService;
|
||||
@ -41,8 +41,8 @@ public class AdminAgentEmployeeRelationController {
|
||||
@Operation(summary = "更新代理商员工关联")
|
||||
@PostMapping("/update")
|
||||
@SaCheckPermission("mp:admin:agent:employee:update")
|
||||
public ResultBean<Boolean> update(@RequestBody @Validated AgentEmployeeRelationReq request) {
|
||||
return ResultBean.success(agentEmployeeRelationService.saveOrUpdateRelation(request));
|
||||
public ResultBean<Boolean> update(@RequestBody @Validated AgentEmployeeUpdateReq request) {
|
||||
return ResultBean.success(agentEmployeeRelationService.update(request));
|
||||
}
|
||||
|
||||
@Operation(summary = "删除代理商员工关联")
|
||||
|
||||
@ -1,24 +0,0 @@
|
||||
package com.seer.teach.mp.admin.controller.req;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(name = "AgentEmployeeRelationReq", description = "代理商员工关联请求参数")
|
||||
@Data
|
||||
public class AgentEmployeeRelationReq {
|
||||
|
||||
@Schema(description = "关联ID")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "代理商ID")
|
||||
private Integer agentId;
|
||||
|
||||
@Schema(description = "员工用户ID")
|
||||
private Integer employeeUserId;
|
||||
|
||||
@Schema(description = "员工职位")
|
||||
private String position;
|
||||
|
||||
@Schema(description = "员工状态:0-禁用,1-启用")
|
||||
private Integer status = 1;
|
||||
}
|
||||
@ -1,7 +1,9 @@
|
||||
package com.seer.teach.mp.admin.controller.req;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@ -9,19 +11,27 @@ import lombok.Data;
|
||||
public class AgentEmployeeSaveReq {
|
||||
|
||||
|
||||
@Schema(description = "代理商名称")
|
||||
@NotNull(message = "代理商名称不能为空")
|
||||
private String agentName;
|
||||
@Schema(description = "代理商Id")
|
||||
@NotNull(message = "代理商Id不能为空")
|
||||
private Integer agentId;
|
||||
|
||||
@Schema(description = "员工名称")
|
||||
@NotNull(message = "员工名称不能为空")
|
||||
@NotBlank(message = "员工名称不能为空")
|
||||
private String employeeName;
|
||||
|
||||
@Schema(description = "员工密码")
|
||||
@NotBlank(message = "员工密码不能为空")
|
||||
private String password;
|
||||
|
||||
@Schema(description = "员工手机号")
|
||||
@NotBlank(message = "员工手机号不能为空")
|
||||
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "请输入正确的手机号")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "员工职位")
|
||||
private String position;
|
||||
|
||||
@Schema(description = "员工状态:0-禁用,1-启用")
|
||||
private Integer status = 1;
|
||||
|
||||
private String password;
|
||||
}
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
package com.seer.teach.mp.admin.controller.req;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(name = "AgentEmployeeRelationReq", description = "代理商员工关联请求参数")
|
||||
@Data
|
||||
public class AgentEmployeeUpdateReq {
|
||||
|
||||
@Schema(description = "关联ID")
|
||||
@NotNull(message = "关联ID不能为空")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "员工名称")
|
||||
private String employeeName;
|
||||
|
||||
@Schema(description = "员工职位")
|
||||
private String position;
|
||||
|
||||
@Schema(description = "员工密码")
|
||||
private String password;
|
||||
|
||||
@Schema(description = "员工手机号")
|
||||
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "请输入正确的手机号")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "员工状态:0-禁用,1-启用")
|
||||
private Integer status = 1;
|
||||
}
|
||||
@ -1,54 +1,62 @@
|
||||
package com.seer.teach.mp.admin.controller.req;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(name = "MpAgentReq", description = "代理商请求参数")
|
||||
@Data
|
||||
public class MpAgentReq {
|
||||
|
||||
@Schema(description = "代理商ID")
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 代理商名称
|
||||
*/
|
||||
@Schema(description = "代理商名称")
|
||||
private String agentName;
|
||||
|
||||
/**
|
||||
* 代理商编码
|
||||
*/
|
||||
@Schema(description = "代理商编码")
|
||||
private String agentCode;
|
||||
|
||||
/**
|
||||
* 代理商等级
|
||||
*/
|
||||
@Schema(description = "代理商等级")
|
||||
private String agentLevel;
|
||||
|
||||
/**
|
||||
* 联系人姓名
|
||||
*/
|
||||
@Schema(description = "联系人姓名")
|
||||
private String contactName;
|
||||
|
||||
/**
|
||||
* 联系人用户Id
|
||||
*/
|
||||
private Integer contactUserId;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
@Schema(description = "联系电话")
|
||||
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "请输入正确的手机号")
|
||||
private String contactPhone;
|
||||
|
||||
/**
|
||||
* 登录密码
|
||||
*/
|
||||
@Schema(description = "登录密码")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 代理商地址
|
||||
*/
|
||||
@Schema(description = "代理商地址")
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 代理商状态:0-禁用,1-启用
|
||||
*/
|
||||
@Schema(description = "代理商状态:0-禁用,1-启用")
|
||||
private Integer status;
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
package com.seer.teach.mp.admin.controller.req;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Schema(name = "MpAgentSaveReq", description = "新增代理商请求参数")
|
||||
public class MpAgentSaveReq {
|
||||
|
||||
/**
|
||||
* 代理商名称
|
||||
*/
|
||||
@Schema(description = "代理商名称")
|
||||
@NotBlank(message = "代理商名称不能为空")
|
||||
private String agentName;
|
||||
|
||||
/**
|
||||
* 代理商编码
|
||||
*/
|
||||
@Schema(description = "代理商编码")
|
||||
private String agentCode;
|
||||
|
||||
/**
|
||||
* 代理商等级
|
||||
*/
|
||||
@Schema(description = "代理商等级")
|
||||
private String agentLevel;
|
||||
|
||||
/**
|
||||
* 联系人姓名
|
||||
*/
|
||||
@Schema(description = "联系人姓名")
|
||||
@NotBlank(message = "联系人姓名不能为空")
|
||||
private String contactName;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
@Schema(description = "联系电话")
|
||||
@NotBlank(message = "联系电话不能为空")
|
||||
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "请输入正确的手机号")
|
||||
private String contactPhone;
|
||||
|
||||
/**
|
||||
* 登录密码
|
||||
*/
|
||||
@Schema(description = "登录密码")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 代理商地址
|
||||
*/
|
||||
@Schema(description = "代理商地址")
|
||||
@NotBlank(message = "代理商地址不能为空")
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 代理商状态:0-禁用,1-启用
|
||||
*/
|
||||
@Schema(description = "代理商状态:0-禁用,1-启用")
|
||||
private Integer status;
|
||||
}
|
||||
@ -23,6 +23,9 @@ public class AgentEmployeeRelationResp {
|
||||
@Schema(description = "员工名称")
|
||||
private String employeeName;
|
||||
|
||||
@Schema(description = "员工手机号")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "员工职位")
|
||||
private String position;
|
||||
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
package com.seer.teach.mp.admin.convert;
|
||||
|
||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeRelationQueryReq;
|
||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeRelationReq;
|
||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeSaveReq;
|
||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeUpdateReq;
|
||||
import com.seer.teach.mp.admin.controller.resp.AgentEmployeeRelationResp;
|
||||
import com.seer.teach.mp.entity.MpAgentEmployeeRelationEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
@ -15,10 +16,11 @@ public interface AdminAgentEmployeeRelationConvert {
|
||||
|
||||
AdminAgentEmployeeRelationConvert INSTANCE = Mappers.getMapper(AdminAgentEmployeeRelationConvert.class);
|
||||
|
||||
MpAgentEmployeeRelationEntity convert(AgentEmployeeRelationReq req);
|
||||
MpAgentEmployeeRelationEntity convert(AgentEmployeeUpdateReq req);
|
||||
|
||||
MpAgentEmployeeRelationEntity convert(AgentEmployeeRelationQueryReq req);
|
||||
|
||||
@Mapping(source = "contactPhone", target = "mobile")
|
||||
AgentEmployeeRelationResp convertToResp(MpAgentEmployeeRelationEntity entity);
|
||||
|
||||
List<AgentEmployeeRelationResp> convertToRespList(List<MpAgentEmployeeRelationEntity> mpAgentEmployeeRelationEntities);
|
||||
|
||||
@ -2,6 +2,7 @@ package com.seer.teach.mp.admin.convert;
|
||||
|
||||
import com.seer.teach.mp.admin.controller.req.AgentQueryReq;
|
||||
import com.seer.teach.mp.admin.controller.req.MpAgentReq;
|
||||
import com.seer.teach.mp.admin.controller.req.MpAgentSaveReq;
|
||||
import com.seer.teach.mp.admin.controller.resp.AgentResp;
|
||||
import com.seer.teach.mp.entity.MpAgentEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
@ -22,5 +23,7 @@ public interface AgentConvert {
|
||||
|
||||
MpAgentEntity convertOne2Entity(MpAgentReq req);
|
||||
|
||||
MpAgentEntity convertOneSave(MpAgentSaveReq req);
|
||||
|
||||
AgentQueryReq convertToReq(MpAgentEntity entity);
|
||||
}
|
||||
@ -4,13 +4,18 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.seer.teach.common.PageListBean;
|
||||
import com.seer.teach.common.enums.ResultCodeEnum;
|
||||
import com.seer.teach.common.utils.AssertUtils;
|
||||
import com.seer.teach.common.utils.PageConverterUtils;
|
||||
import com.seer.teach.mp.admin.controller.req.AgentQueryReq;
|
||||
import com.seer.teach.mp.admin.controller.req.MpAgentReq;
|
||||
import com.seer.teach.mp.admin.controller.req.MpAgentSaveReq;
|
||||
import com.seer.teach.mp.admin.controller.resp.AgentResp;
|
||||
import com.seer.teach.mp.admin.convert.AgentConvert;
|
||||
import com.seer.teach.mp.entity.MpAgentEntity;
|
||||
import com.seer.teach.mp.service.IMpAgentService;
|
||||
import com.seer.teach.user.api.UserInfoServiceApi;
|
||||
import com.seer.teach.user.api.dto.UserInfoDTO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -25,6 +30,8 @@ public class AdminAgentService {
|
||||
|
||||
private final IMpAgentService mpAgentService;
|
||||
|
||||
private final UserInfoServiceApi userInfoServiceApi;
|
||||
|
||||
/**
|
||||
* 获取代理商列表
|
||||
*
|
||||
@ -63,8 +70,10 @@ public class AdminAgentService {
|
||||
* @param req 代理商
|
||||
* @return 是否成功
|
||||
*/
|
||||
public Boolean saveAgent(MpAgentReq req) {
|
||||
MpAgentEntity agentEntity = AgentConvert.INSTANCE.convertOne2Entity(req);
|
||||
public Boolean saveAgent(MpAgentSaveReq req) {
|
||||
boolean userIdByMobile = userInfoServiceApi.getUserIdByMobile(req.getContactPhone());
|
||||
AssertUtils.isTrue(userIdByMobile, ResultCodeEnum.AGENT_IS_EXISTS);
|
||||
MpAgentEntity agentEntity = AgentConvert.INSTANCE.convertOneSave(req);
|
||||
boolean result = mpAgentService.saveAgent(agentEntity,req.getPassword());
|
||||
log.info("保存代理商结果: {}", result);
|
||||
return result;
|
||||
@ -77,10 +86,31 @@ public class AdminAgentService {
|
||||
* @return 是否成功
|
||||
*/
|
||||
public Boolean updateAgent(MpAgentReq req) {
|
||||
MpAgentEntity agentEntity = AgentConvert.INSTANCE.convertOne2Entity(req);
|
||||
boolean result = mpAgentService.updateAgent(agentEntity);
|
||||
MpAgentEntity agent = mpAgentService.getById(req.getId());
|
||||
AssertUtils.notNull(agent, ResultCodeEnum.AGENT_NOT_FOUND);
|
||||
UserInfoDTO userInfoDTO = new UserInfoDTO();
|
||||
userInfoDTO.setId(agent.getContactUserId());
|
||||
userInfoDTO.setUserName(req.getContactName());
|
||||
userInfoDTO.setMobile(req.getContactPhone());
|
||||
if (StringUtils.isNotBlank(req.getPassword())) {
|
||||
userInfoDTO.setPassword(req.getPassword());
|
||||
}
|
||||
boolean updateUserResult = userInfoServiceApi.updateUserInfo(userInfoDTO);
|
||||
log.info("更新用户结果: {}", updateUserResult);
|
||||
|
||||
agent.setId(req.getId());
|
||||
agent.setAgentName(req.getAgentName());
|
||||
agent.setAgentCode(req.getAgentCode());
|
||||
agent.setAgentLevel(req.getAgentLevel());
|
||||
agent.setContactName(req.getContactName());
|
||||
Integer contactUserId = userInfoServiceApi.getUserIdByUserName(agent.getContactName());
|
||||
agent.setContactUserId(contactUserId);
|
||||
agent.setContactPhone(req.getContactPhone());
|
||||
agent.setAddress(req.getAddress());
|
||||
agent.setStatus(req.getStatus());
|
||||
boolean result = mpAgentService.updateAgent(agent);
|
||||
log.info("更新代理商结果: {}", result);
|
||||
return result;
|
||||
return result && updateUserResult;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -2,9 +2,9 @@ package com.seer.teach.mp.admin.service;
|
||||
|
||||
import com.seer.teach.common.PageListBean;
|
||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeSaveReq;
|
||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeUpdateReq;
|
||||
import com.seer.teach.mp.admin.controller.resp.AgentEmployeeRelationResp;
|
||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeRelationQueryReq;
|
||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeRelationReq;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -32,7 +32,7 @@ public interface IAdminAgentEmployeeRelationService {
|
||||
* @param request 关联请求对象
|
||||
* @return 操作是否成功
|
||||
*/
|
||||
boolean saveOrUpdateRelation(AgentEmployeeRelationReq request);
|
||||
boolean update(AgentEmployeeUpdateReq request);
|
||||
|
||||
/**
|
||||
* 删除代理商员工关联(管理端)
|
||||
|
||||
@ -8,18 +8,18 @@ import com.seer.teach.common.enums.RoleEnum;
|
||||
import com.seer.teach.common.utils.AssertUtils;
|
||||
import com.seer.teach.common.utils.PageConverterUtils;
|
||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeRelationQueryReq;
|
||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeRelationReq;
|
||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeSaveReq;
|
||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeUpdateReq;
|
||||
import com.seer.teach.mp.admin.controller.resp.AgentEmployeeRelationResp;
|
||||
import com.seer.teach.mp.admin.convert.AdminAgentEmployeeRelationConvert;
|
||||
import com.seer.teach.mp.admin.service.IAdminAgentEmployeeRelationService;
|
||||
import com.seer.teach.mp.entity.MpAgentEmployeeRelationEntity;
|
||||
import com.seer.teach.mp.entity.MpAgentEntity;
|
||||
import com.seer.teach.mp.service.IMpAgentEmployeeRelationService;
|
||||
import com.seer.teach.mp.service.IMpAgentService;
|
||||
import com.seer.teach.user.api.UserInfoServiceApi;
|
||||
import com.seer.teach.user.api.dto.UserInfoDTO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@ -34,6 +34,7 @@ import java.util.Objects;
|
||||
* @since 2025-12-30
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class AdminAgentEmployeeRelationServiceImpl implements IAdminAgentEmployeeRelationService {
|
||||
|
||||
@ -55,9 +56,33 @@ public class AdminAgentEmployeeRelationServiceImpl implements IAdminAgentEmploye
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveOrUpdateRelation(AgentEmployeeRelationReq request) {
|
||||
MpAgentEmployeeRelationEntity entity = AdminAgentEmployeeRelationConvert.INSTANCE.convert(request);
|
||||
return agentEmployeeRelationService.saveOrUpdateRelation(entity);
|
||||
public boolean update(AgentEmployeeUpdateReq request) {
|
||||
log.info("更新代理商员工关系,参数: {}", request);
|
||||
MpAgentEmployeeRelationEntity existingRelation = agentEmployeeRelationService.getById(request.getId());
|
||||
AssertUtils.notNull(existingRelation, ResultCodeEnum.AGENT_EMPLOYEE_NOT_FOUND);
|
||||
UserInfoDTO userInfoDTO = new UserInfoDTO();
|
||||
userInfoDTO.setId(existingRelation.getEmployeeUserId());
|
||||
userInfoDTO.setUserName(request.getEmployeeName());
|
||||
userInfoDTO.setMobile(request.getMobile());
|
||||
if (request.getPassword() != null) {
|
||||
userInfoDTO.setPassword(request.getPassword());
|
||||
}
|
||||
userInfoServiceApi.updateUserInfo(userInfoDTO);
|
||||
// 更新关联表中的用户信息
|
||||
MpAgentEmployeeRelationEntity updateEntity = getUpdateEntity(request, existingRelation);
|
||||
return agentEmployeeRelationService.updateById(updateEntity);
|
||||
}
|
||||
|
||||
private static MpAgentEmployeeRelationEntity getUpdateEntity(AgentEmployeeUpdateReq request, MpAgentEmployeeRelationEntity existingRelation) {
|
||||
MpAgentEmployeeRelationEntity updateEntity = new MpAgentEmployeeRelationEntity();
|
||||
updateEntity.setId(request.getId());
|
||||
updateEntity.setAgentId(existingRelation.getAgentId());
|
||||
updateEntity.setEmployeeUserId(existingRelation.getEmployeeUserId());
|
||||
updateEntity.setStatus(request.getStatus());
|
||||
updateEntity.setPosition(request.getPosition());
|
||||
updateEntity.setEmployeeName(request.getEmployeeName());
|
||||
updateEntity.setContactPhone(request.getMobile());
|
||||
return updateEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -87,16 +112,17 @@ public class AdminAgentEmployeeRelationServiceImpl implements IAdminAgentEmploye
|
||||
UserInfoDTO userInfoDTO = new UserInfoDTO();
|
||||
userInfoDTO.setUserName(request.getEmployeeName());
|
||||
userInfoDTO.setPassword(request.getPassword());
|
||||
userInfoDTO.setMobile(request.getMobile());
|
||||
userInfoDTO.setRoleCode(RoleEnum.AGENT);
|
||||
Integer userId = userInfoServiceApi.addUserInfoAndAssignRole(userInfoDTO);
|
||||
Integer agentId = mpAgentService.lambdaQuery().eq(MpAgentEntity::getAgentName, request.getAgentName()).one().getId();
|
||||
MpAgentEmployeeRelationEntity entity = new MpAgentEmployeeRelationEntity();
|
||||
entity.setAgentId(agentId);
|
||||
entity.setAgentId(request.getAgentId());
|
||||
entity.setAgentName(mpAgentService.getById(request.getAgentId()).getAgentName());
|
||||
entity.setEmployeeUserId(userId);
|
||||
entity.setEmployeeName(request.getEmployeeName());
|
||||
entity.setAgentName(request.getAgentName());
|
||||
entity.setPosition(request.getPosition());
|
||||
entity.setStatus(request.getStatus());
|
||||
entity.setContactPhone(request.getMobile());
|
||||
agentEmployeeRelationService.save(entity);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -131,15 +131,16 @@ CREATE TABLE `mp_activity_info_collection` (
|
||||
`activity_id` int NOT NULL COMMENT '活动ID',
|
||||
`parent_id` int NOT NULL COMMENT '家长ID',
|
||||
`child_name` varchar(100) COMMENT '孩子姓名',
|
||||
`child_gender` varchar(10) COMMENT '孩子性别(M-男,F-女)',
|
||||
`child_gender` int COMMENT '孩子性别(1-男,0-女)',
|
||||
`child_birth_date` date COMMENT '出生年月',
|
||||
`grade` varchar(20) COMMENT '年级',
|
||||
`grade` int COMMENT '年级',
|
||||
`school` varchar(255) COMMENT '学校',
|
||||
`mobile` varchar(20) COMMENT '手机号',
|
||||
`region` varchar(255) COMMENT '地区',
|
||||
`parent_identity` varchar(20) COMMENT '家长身份(爸爸,妈妈)',
|
||||
`learning_situation` varchar(20) COMMENT '学习情况(优、良、中、差)',
|
||||
`weak_subject_ids` varchar(50) COMMENT '薄弱科目',
|
||||
`strong_subject_ids` varchar(50) COMMENT '优势科目',
|
||||
`weak_subject_ids` json COMMENT '薄弱科目',
|
||||
`strong_subject_ids` json COMMENT '优势科目',
|
||||
`weak_subject` varchar(50) COMMENT '偏科(数学、英语等)',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
|
||||
|
||||
@ -13,14 +13,13 @@ import com.seer.teach.mp.app.controller.resp.AgentActivityParentInfoResp;
|
||||
import com.seer.teach.mp.app.service.IAppAgentActivityParentInfoService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 代理商活动参与家长信息App控制器
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package com.seer.teach.mp.app.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.seer.teach.common.PageListBean;
|
||||
import com.seer.teach.common.ResultBean;
|
||||
import com.seer.teach.common.annotation.LogPrint;
|
||||
@ -31,8 +30,6 @@ public class AppAgentEmployeeRelationController {
|
||||
@PostMapping("/page-list")
|
||||
@SaCheckLogin
|
||||
public ResultBean<PageListBean<AppAgentEmployeeRelationResp>> pageList(@RequestBody @Validated AppAgentEmployeeRelationQueryReq query) {
|
||||
Integer agentId = StpUtil.getLoginIdAsInt();
|
||||
query.setAgentId(agentId);
|
||||
return ResultBean.success(agentEmployeeRelationService.pageList(query));
|
||||
}
|
||||
|
||||
@ -40,8 +37,6 @@ public class AppAgentEmployeeRelationController {
|
||||
@PostMapping("/add")
|
||||
@SaCheckLogin
|
||||
public ResultBean<Boolean> addEmployee(@RequestBody @Validated AppAgentEmployeeRelationReq request) {
|
||||
Integer agentId = StpUtil.getLoginIdAsInt();
|
||||
request.setAgentId(agentId);
|
||||
return ResultBean.success(agentEmployeeRelationService.addEmployee(request));
|
||||
}
|
||||
|
||||
@ -49,8 +44,7 @@ public class AppAgentEmployeeRelationController {
|
||||
@PostMapping("/update")
|
||||
@SaCheckLogin
|
||||
public ResultBean<Boolean> updateEmployee(@RequestBody @Validated AppAgentEmployeeRelationReq request) {
|
||||
Integer agentId = StpUtil.getLoginIdAsInt();
|
||||
boolean belongsToAgent = agentEmployeeRelationService.isEmployeeBelongsToAgent(request.getId(), agentId);
|
||||
boolean belongsToAgent = agentEmployeeRelationService.isEmployeeBelongsToAgent(request.getId(),request.getAgentId());
|
||||
if (!belongsToAgent) {
|
||||
return ResultBean.error(ResultCodeEnum.UNAUTHORIZED_UPDATE_EMPLOYEE);
|
||||
}
|
||||
@ -60,8 +54,7 @@ public class AppAgentEmployeeRelationController {
|
||||
@Operation(summary = "删除员工")
|
||||
@DeleteMapping("/{id}")
|
||||
@SaCheckLogin
|
||||
public ResultBean<Boolean> deleteEmployee(@PathVariable Integer id) {
|
||||
Integer agentId = StpUtil.getLoginIdAsInt();
|
||||
public ResultBean<Boolean> deleteEmployee(@PathVariable Integer id, @RequestParam Integer agentId) {
|
||||
boolean belongsToAgent = agentEmployeeRelationService.isEmployeeBelongsToAgent(id,agentId);
|
||||
if (!belongsToAgent) {
|
||||
return ResultBean.error(ResultCodeEnum.UNAUTHORIZED_UPDATE_EMPLOYEE);
|
||||
@ -72,8 +65,7 @@ public class AppAgentEmployeeRelationController {
|
||||
@Operation(summary = "员工详情")
|
||||
@GetMapping("/{id}")
|
||||
@SaCheckLogin
|
||||
public ResultBean<AppAgentEmployeeRelationResp> getEmployee(@PathVariable Integer id) {
|
||||
Integer agentId = StpUtil.getLoginIdAsInt();
|
||||
public ResultBean<AppAgentEmployeeRelationResp> getEmployee(@PathVariable Integer id,@RequestParam Integer agentId) {
|
||||
boolean belongsToAgent = agentEmployeeRelationService.isEmployeeBelongsToAgent(id,agentId);
|
||||
if (!belongsToAgent) {
|
||||
return ResultBean.error(ResultCodeEnum.UNAUTHORIZED_UPDATE_EMPLOYEE);
|
||||
@ -85,8 +77,7 @@ public class AppAgentEmployeeRelationController {
|
||||
@Operation(summary = "获取所有员工列表")
|
||||
@GetMapping("/all")
|
||||
@SaCheckLogin
|
||||
public ResultBean<List<AppAgentEmployeeRelationResp>> getAllEmployees() {
|
||||
Integer agentId = StpUtil.getLoginIdAsInt();
|
||||
public ResultBean<List<AppAgentEmployeeRelationResp>> getAllEmployees(@RequestParam Integer agentId) {
|
||||
return ResultBean.success(agentEmployeeRelationService.getAllEmployeesByAgentId(agentId));
|
||||
}
|
||||
}
|
||||
@ -12,6 +12,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@ -34,7 +35,7 @@ public class AppParentAgentActivityController {
|
||||
@PostMapping("/sign-up")
|
||||
@SaCheckLogin
|
||||
@Operation(summary = "家长报名参加代理商活动")
|
||||
public ResultBean<Boolean> signUpForActivity(@RequestBody AppMpSignUpActivityReq request) {
|
||||
public ResultBean<Boolean> signUpForActivity(@RequestBody @Validated AppMpSignUpActivityReq request) {
|
||||
Integer parentId = StpUtil.getLoginIdAsInt();
|
||||
return ResultBean.success(appParentAgentActivityService.signUpForActivityWithInfo(request, parentId));
|
||||
}
|
||||
@ -42,7 +43,7 @@ public class AppParentAgentActivityController {
|
||||
@PostMapping("/update-info")
|
||||
@SaCheckLogin
|
||||
@Operation(summary = "家长更新活动信息")
|
||||
public ResultBean<Boolean> updateActivityInfo(@RequestBody AppMpSignUpActivityReq request) {
|
||||
public ResultBean<Boolean> updateActivityInfo(@RequestBody @Validated AppMpSignUpActivityReq request) {
|
||||
Integer parentId = StpUtil.getLoginIdAsInt();
|
||||
return ResultBean.success(appParentAgentActivityService.updateActivityInfo(request, parentId));
|
||||
}
|
||||
|
||||
@ -4,16 +4,17 @@ import com.seer.teach.common.request.PageRequest;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(name = "AppAgentEmployeeRelationQueryReq", description = "代理商员工关联查询请求参数")
|
||||
@Data
|
||||
@Schema(name = "AppAgentEmployeeRelationQueryReq", description = "代理商员工关联查询请求参数")
|
||||
public class AppAgentEmployeeRelationQueryReq extends PageRequest {
|
||||
|
||||
@Schema(description = "代理商ID")
|
||||
private Integer agentId; // 用于限制只能查询当前代理商的员工
|
||||
|
||||
@Schema(description = "员工职位")
|
||||
private String position;
|
||||
|
||||
@Schema(description = "员工状态:0-禁用,1-启用")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "员工名称")
|
||||
private String employeeName;
|
||||
}
|
||||
@ -1,10 +1,9 @@
|
||||
package com.seer.teach.mp.app.controller.req;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
@Schema(name = "AppAgentEmployeeRelationReq", description = "App端代理商员工关联请求参数")
|
||||
@Data
|
||||
public class AppAgentEmployeeRelationReq {
|
||||
@ -21,8 +20,9 @@ public class AppAgentEmployeeRelationReq {
|
||||
@Schema(description = "员工密码")
|
||||
private String password;
|
||||
|
||||
@Schema(description = "联系电话")
|
||||
private String contactPhone;
|
||||
@Schema(description = "员工手机号")
|
||||
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "请输入正确的手机号")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "员工职位")
|
||||
private String position;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.seer.teach.mp.app.controller.req;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
@ -10,6 +11,9 @@ import java.util.List;
|
||||
@Data
|
||||
public class AppMpSignUpActivityReq {
|
||||
|
||||
@Schema (description = "ID")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "活动ID")
|
||||
private Integer activityId;
|
||||
|
||||
@ -17,6 +21,7 @@ public class AppMpSignUpActivityReq {
|
||||
private Integer agentId;
|
||||
|
||||
@Schema(description = "手机号码")
|
||||
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "请输入正确的手机号")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "孩子姓名")
|
||||
|
||||
@ -11,7 +11,7 @@ import java.time.LocalDate;
|
||||
public class TestChildCharacterReq {
|
||||
|
||||
@NotNull(message = "孩子性别不能为空")
|
||||
@Schema(description = "孩子性别(M-男,F-女)")
|
||||
@Schema(description = "孩子性别(男,女)")
|
||||
private String childGender;
|
||||
|
||||
@NotNull(message = "出生年月不能为空")
|
||||
|
||||
@ -28,18 +28,21 @@ public class AgentActivityParentInfoResp {
|
||||
@Schema(description = "孩子姓名")
|
||||
private String childName;
|
||||
|
||||
@Schema(description = "孩子性别(M-男,F-女)")
|
||||
private String childGender;
|
||||
@Schema(description = "孩子性别(1-男,0-女)")
|
||||
private Integer childGender;
|
||||
|
||||
@Schema(description = "出生年月")
|
||||
private LocalDate childBirthDate;
|
||||
|
||||
@Schema(description = "年级")
|
||||
private String grade;
|
||||
private Integer grade;
|
||||
|
||||
@Schema(description = "学校")
|
||||
private String school;
|
||||
|
||||
@Schema(description = "手机号")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "地区")
|
||||
private String region;
|
||||
|
||||
|
||||
@ -39,6 +39,9 @@ public class AppMpSignUpActivityResp {
|
||||
@Schema(description = "学校")
|
||||
private String school;
|
||||
|
||||
@Schema(description = "手机号码")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "地区")
|
||||
private String region;
|
||||
|
||||
@ -50,4 +53,7 @@ public class AppMpSignUpActivityResp {
|
||||
|
||||
@Schema(description = "薄弱科目")
|
||||
private String weakSubject;
|
||||
|
||||
@Schema(description = "代理商拨打电话联系家长的次数")
|
||||
private Integer contactCallCount;
|
||||
}
|
||||
@ -4,6 +4,7 @@ import com.seer.teach.mp.app.controller.req.AppMpSignUpActivityReq;
|
||||
import com.seer.teach.mp.app.controller.resp.AppMpSignUpActivityResp;
|
||||
import com.seer.teach.mp.entity.MpActivityInfoCollectionEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
@ -16,6 +17,8 @@ public interface AppMpActivityInfoCollectionConvert {
|
||||
* @param entity 实体
|
||||
* @return 响应参数
|
||||
*/
|
||||
@Mapping(source = "mobile", target = "mobile")
|
||||
@Mapping(source = "contactCallCount", target = "contactCallCount")
|
||||
AppMpSignUpActivityResp convert2Resp(MpActivityInfoCollectionEntity entity);
|
||||
|
||||
|
||||
|
||||
@ -35,10 +35,15 @@ import java.util.Objects;
|
||||
public class AppParentAgentActivityService implements IAppParentAgentActivityService {
|
||||
|
||||
private final IMpParentAgentActivityRelationService parentAgentActivityRelationService;
|
||||
|
||||
private final IMpActivityInfoCollectionService activityInfoCollectionService;
|
||||
|
||||
private final IMpActivityService activityService;
|
||||
|
||||
private final IMpAgentService agentService;
|
||||
|
||||
private final IMpAgentActivityParticipantService mpAgentActivityParticipantService;
|
||||
|
||||
private final AiModelCallService aiModelCallService;
|
||||
|
||||
/**
|
||||
@ -78,6 +83,7 @@ public class AppParentAgentActivityService implements IAppParentAgentActivitySer
|
||||
if (saved) {
|
||||
MpActivityInfoCollectionEntity mpActivityInfoCollectionEntity = AppMpActivityInfoCollectionConvert.INSTANCE.convertOne2Entity(request);
|
||||
mpActivityInfoCollectionEntity.setRelationId(relation.getId());
|
||||
mpActivityInfoCollectionEntity.setParentId(parentId);
|
||||
boolean activityInfoCollectionResult = activityInfoCollectionService.save(mpActivityInfoCollectionEntity);
|
||||
log.info("活动信息收集结果:{}", activityInfoCollectionResult);
|
||||
return activityInfoCollectionResult;
|
||||
@ -93,13 +99,28 @@ public class AppParentAgentActivityService implements IAppParentAgentActivitySer
|
||||
* @return true表示成功,false表示失败
|
||||
*/
|
||||
public boolean updateActivityInfo(AppMpSignUpActivityReq request, Integer parentId) {
|
||||
MpActivityInfoCollectionEntity entity = activityInfoCollectionService.getById(request.getId());
|
||||
if (entity == null) {
|
||||
return false;
|
||||
}
|
||||
Integer agentId = request.getAgentId();
|
||||
Integer activityId = request.getActivityId();
|
||||
MpParentAgentActivityRelationEntity relation = parentAgentActivityRelationService.getByAgentIdAndActivityIdAndParentId(agentId, activityId, parentId);
|
||||
AssertUtils.notNull(relation, ResultCodeEnum.PARENT_NOT_SIGNED_UP);
|
||||
MpActivityInfoCollectionEntity mpActivityInfoCollectionEntity = AppMpActivityInfoCollectionConvert.INSTANCE.convertOne2Entity(request);
|
||||
mpActivityInfoCollectionEntity.setRelationId(relation.getId());
|
||||
return activityInfoCollectionService.updateById(mpActivityInfoCollectionEntity);
|
||||
entity.setRelationId(relation.getId());
|
||||
entity.setParentId(parentId);
|
||||
entity.setMobile(request.getMobile());
|
||||
entity.setChildName(request.getChildName());
|
||||
entity.setChildGender(request.getChildGender());
|
||||
entity.setChildBirthDate(request.getChildBirthDate());
|
||||
entity.setGrade(request.getGrade());
|
||||
entity.setSchool(request.getSchool());
|
||||
entity.setRegion(request.getRegion());
|
||||
entity.setParentIdentity(request.getParentIdentity());
|
||||
entity.setLearningSituation(request.getLearningSituation());
|
||||
entity.setWeakSubjectIds(request.getWeakSubjectIds());
|
||||
entity.setStrongSubjectIds(request.getStrongSubjectIds());
|
||||
return activityInfoCollectionService.updateById(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -69,7 +69,7 @@ public interface IAppAgentEmployeeRelationService {
|
||||
* 验证员工是否属于指定代理商
|
||||
*
|
||||
* @param relationId 关联ID
|
||||
* @param agentId 代理商ID
|
||||
* @param employeeUserId 代理商ID
|
||||
* @return 是否属于
|
||||
*/
|
||||
boolean isEmployeeBelongsToAgent(Integer relationId, Integer agentId);
|
||||
|
||||
@ -113,6 +113,8 @@ public class AppAgentActivityParentInfoServiceImpl implements IAppAgentActivityP
|
||||
resp.setChildBirthDate(entity.getChildBirthDate());
|
||||
resp.setGrade(entity.getGrade());
|
||||
resp.setSchool(entity.getSchool());
|
||||
resp.setMobile(entity.getMobile());
|
||||
resp.setContactCallCount(entity.getContactCallCount());
|
||||
resp.setRegion(entity.getRegion());
|
||||
resp.setParentIdentity(entity.getParentIdentity());
|
||||
resp.setLearningSituation(entity.getLearningSituation());
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.seer.teach.mp.app.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@ -16,10 +17,9 @@ import com.seer.teach.mp.app.controller.resp.AppAgentEmployeeRelationResp;
|
||||
import com.seer.teach.mp.app.service.IAppAgentEmployeeRelationService;
|
||||
import com.seer.teach.mp.entity.MpAgentEmployeeRelationEntity;
|
||||
import com.seer.teach.mp.service.IMpAgentEmployeeRelationService;
|
||||
import com.seer.teach.mp.service.IMpAgentService;
|
||||
import com.seer.teach.user.api.UserInfoServiceApi;
|
||||
import com.seer.teach.user.api.UserRelationServiceApi;
|
||||
import com.seer.teach.user.api.dto.UserInfoDTO;
|
||||
import com.seer.teach.user.api.dto.UserRelationDTO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -42,16 +42,32 @@ import java.util.stream.Collectors;
|
||||
public class AppAgentEmployeeRelationServiceImpl implements IAppAgentEmployeeRelationService {
|
||||
|
||||
private final IMpAgentEmployeeRelationService mpAgentEmployeeRelationService;
|
||||
|
||||
private final IMpAgentService mpAgentService;
|
||||
|
||||
private final UserInfoServiceApi userInfoServiceApi;
|
||||
|
||||
@Override
|
||||
public PageListBean<AppAgentEmployeeRelationResp> pageList(AppAgentEmployeeRelationQueryReq query) {
|
||||
Integer employeeUserId = StpUtil.getLoginIdAsInt();
|
||||
Integer agentId = mpAgentEmployeeRelationService.lambdaQuery().eq(MpAgentEmployeeRelationEntity::getEmployeeUserId, employeeUserId).one().getAgentId();
|
||||
AssertUtils.notNull(agentId, ResultCodeEnum.AGENT_EMPLOYEE_NOT_FOUND);
|
||||
log.info("查询参数:{}", query);
|
||||
IPage<MpAgentEmployeeRelationEntity> page = new Page<>(query.getPageNo(), query.getPageSize());
|
||||
var pageResult = mpAgentEmployeeRelationService.page(page, new LambdaQueryWrapper<>(MpAgentEmployeeRelationEntity.class)
|
||||
.eq(MpAgentEmployeeRelationEntity::getAgentId, query.getAgentId())
|
||||
LambdaQueryWrapper<MpAgentEmployeeRelationEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(MpAgentEmployeeRelationEntity::getAgentId, agentId)
|
||||
.like(StringUtils.isNotBlank(query.getPosition()), MpAgentEmployeeRelationEntity::getPosition, query.getPosition())
|
||||
.eq(query.getStatus() != null, MpAgentEmployeeRelationEntity::getStatus, query.getStatus()));
|
||||
.eq(query.getStatus() != null, MpAgentEmployeeRelationEntity::getStatus, query.getStatus());
|
||||
|
||||
if (StringUtils.isNotBlank(query.getEmployeeName())) {
|
||||
List<Integer> matchUserIds = userInfoServiceApi.getUserIdsByUserNameLike(query.getEmployeeName());
|
||||
if (CollectionUtil.isEmpty(matchUserIds)) {
|
||||
log.info("无匹配员工");
|
||||
return PageConverterUtils.convertPageListBean(page, null);
|
||||
}
|
||||
wrapper.in(MpAgentEmployeeRelationEntity::getEmployeeUserId, matchUserIds);
|
||||
}
|
||||
IPage<MpAgentEmployeeRelationEntity> pageResult = mpAgentEmployeeRelationService.page(page, wrapper);
|
||||
|
||||
if (CollectionUtil.isEmpty(pageResult.getRecords())) {
|
||||
log.info("查询结果为空");
|
||||
@ -63,9 +79,10 @@ public class AppAgentEmployeeRelationServiceImpl implements IAppAgentEmployeeRel
|
||||
|
||||
@Override
|
||||
public boolean addEmployee(AppAgentEmployeeRelationReq request) {
|
||||
log.info("新增员工参数:{}", request);
|
||||
LambdaQueryWrapper<MpAgentEmployeeRelationEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(MpAgentEmployeeRelationEntity::getAgentId, request.getAgentId())
|
||||
.eq(MpAgentEmployeeRelationEntity::getContactPhone, request.getContactPhone());
|
||||
.eq(MpAgentEmployeeRelationEntity::getContactPhone, request.getMobile());
|
||||
|
||||
MpAgentEmployeeRelationEntity existing = mpAgentEmployeeRelationService.getOne(wrapper);
|
||||
if (existing != null) {
|
||||
@ -73,13 +90,16 @@ public class AppAgentEmployeeRelationServiceImpl implements IAppAgentEmployeeRel
|
||||
}
|
||||
UserInfoDTO userInfoDTO = new UserInfoDTO();
|
||||
userInfoDTO.setUserName(request.getEmployeeName());
|
||||
userInfoDTO.setMobile(request.getContactPhone());
|
||||
userInfoDTO.setMobile(request.getMobile());
|
||||
userInfoDTO.setPassword(request.getPassword());
|
||||
userInfoDTO.setRoleCode(RoleEnum.AGENT);
|
||||
Integer userId = userInfoServiceApi.addUserInfoAndAssignRole(userInfoDTO);
|
||||
|
||||
MpAgentEmployeeRelationEntity entity = new MpAgentEmployeeRelationEntity();
|
||||
entity.setAgentId(request.getAgentId());
|
||||
entity.setEmployeeName(request.getEmployeeName());
|
||||
entity.setContactPhone(request.getMobile());
|
||||
entity.setAgentName(mpAgentService.getById(request.getAgentId()).getAgentName());
|
||||
entity.setEmployeeUserId(userId);
|
||||
entity.setPosition(request.getPosition());
|
||||
entity.setStatus(request.getStatus());
|
||||
@ -101,8 +121,12 @@ public class AppAgentEmployeeRelationServiceImpl implements IAppAgentEmployeeRel
|
||||
|
||||
UserInfoDTO userInfoDTO = new UserInfoDTO();
|
||||
userInfoDTO.setUserName(request.getEmployeeName());
|
||||
userInfoDTO.setMobile(request.getContactPhone());
|
||||
userInfoDTO.setMobile(request.getMobile());
|
||||
userInfoDTO.setId(existing.getEmployeeUserId());
|
||||
if (StringUtils.isNotBlank(request.getPassword())) {
|
||||
userInfoDTO.setPassword(request.getPassword());
|
||||
log.info("更新员工密码");
|
||||
}
|
||||
boolean updateUserResult = userInfoServiceApi.updateUserInfo(userInfoDTO);
|
||||
log.info("更新员工结果:{}", updateUserResult);
|
||||
|
||||
@ -111,10 +135,13 @@ public class AppAgentEmployeeRelationServiceImpl implements IAppAgentEmployeeRel
|
||||
updateEntity.setPosition(request.getPosition());
|
||||
updateEntity.setStatus(request.getStatus());
|
||||
updateEntity.setEmployeeName(request.getEmployeeName());
|
||||
existing.setContactPhone(request.getContactPhone());
|
||||
boolean result = mpAgentEmployeeRelationService.updateById(existing);
|
||||
updateEntity.setContactPhone(request.getMobile());
|
||||
updateEntity.setAgentName(mpAgentService.getById(request.getAgentId()).getAgentName());
|
||||
updateEntity.setAgentId(request.getAgentId());
|
||||
updateEntity.setEmployeeUserId(existing.getEmployeeUserId());
|
||||
boolean result = mpAgentEmployeeRelationService.updateById(updateEntity);
|
||||
log.info("更新员工结果:{}", result);
|
||||
return result;
|
||||
return result && updateUserResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -152,11 +179,11 @@ public class AppAgentEmployeeRelationServiceImpl implements IAppAgentEmployeeRel
|
||||
|
||||
@Override
|
||||
public boolean isEmployeeBelongsToAgent(Integer relationId, Integer agentId) {
|
||||
MpAgentEmployeeRelationEntity entity = mpAgentEmployeeRelationService.getById(relationId);
|
||||
if (entity == null) {
|
||||
return false;
|
||||
}
|
||||
return entity.getAgentId().equals(agentId);
|
||||
MpAgentEmployeeRelationEntity entity = mpAgentEmployeeRelationService.lambdaQuery()
|
||||
.eq(MpAgentEmployeeRelationEntity::getId, relationId)
|
||||
.eq(MpAgentEmployeeRelationEntity::getAgentId, agentId)
|
||||
.one();
|
||||
return entity != null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -2,7 +2,6 @@ package com.seer.teach.mp.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.seer.teach.common.enums.RoleEnum;
|
||||
import com.seer.teach.common.utils.CommonUtils;
|
||||
import com.seer.teach.mp.entity.MpAgentEntity;
|
||||
import com.seer.teach.mp.mapper.MpAgentMapper;
|
||||
import com.seer.teach.mp.service.IMpAgentService;
|
||||
@ -32,7 +31,7 @@ public class MpAgentServiceImpl extends ServiceImpl<MpAgentMapper, MpAgentEntity
|
||||
@Override
|
||||
public Boolean saveAgent(MpAgentEntity agentEntity,String password) {
|
||||
UserInfoDTO userInfoDTO = new UserInfoDTO();
|
||||
userInfoDTO.setUserName(agentEntity.getAgentName());
|
||||
userInfoDTO.setUserName(agentEntity.getContactName());
|
||||
userInfoDTO.setPassword(password);
|
||||
userInfoDTO.setMobile(agentEntity.getContactPhone());
|
||||
userInfoDTO.setRoleCode(RoleEnum.AGENT);
|
||||
|
||||
@ -2,11 +2,7 @@ package com.seer.teach.user.api;
|
||||
|
||||
import com.seer.teach.user.api.dto.*;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -193,4 +189,10 @@ public interface UserInfoServiceApi {
|
||||
@GetMapping("/getUserIdByUserName")
|
||||
Integer getUserIdByUserName(@RequestParam("userName") String userName);
|
||||
|
||||
@GetMapping("/getUserIdsByUserNameLike")
|
||||
List< Integer> getUserIdsByUserNameLike(@RequestParam("userName") String userName);
|
||||
|
||||
@GetMapping("/getUserIdByMobile")
|
||||
boolean getUserIdByMobile(@RequestParam("mobile") String mobile);
|
||||
|
||||
}
|
||||
@ -45,6 +45,9 @@ public class OfficialOauthWithAccountLoginStrategy extends AbstractLoginStrategy
|
||||
UserEntity accountUser = null;
|
||||
if (request.getUserName() != null && !request.getUserName().isEmpty()) {
|
||||
accountUser = userService.getOneByUserName(request.getUserName());
|
||||
if (accountUser == null) {
|
||||
accountUser = userService.getOneByMobile(request.getUserName());
|
||||
}
|
||||
} else if (request.getPhoneNumber() != null && !request.getPhoneNumber().isEmpty()) {
|
||||
accountUser = userService.getOneByMobile(request.getPhoneNumber());
|
||||
}
|
||||
|
||||
@ -3,9 +3,9 @@ package com.seer.teach.user.admin.api;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.seer.teach.common.dto.mq.im.MqUserInfoDTO;
|
||||
import com.seer.teach.common.enums.im.ImMqTopicEnum;
|
||||
import com.seer.teach.common.enums.ResultCodeEnum;
|
||||
import com.seer.teach.common.enums.RoleEnum;
|
||||
import com.seer.teach.common.enums.im.ImMqTopicEnum;
|
||||
import com.seer.teach.common.enums.im.UserInfoTopiTagEnum;
|
||||
import com.seer.teach.common.enums.iot.IsInfoEnum;
|
||||
import com.seer.teach.common.exception.CommonException;
|
||||
@ -222,8 +222,16 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
|
||||
|
||||
@Override
|
||||
public boolean updateUserInfo(UserInfoDTO userInfoDTO) {
|
||||
UserEntity UserEntity = UserInfoConvert.INSTANCE.convertOne(userInfoDTO);
|
||||
return userService.updateById(UserEntity);
|
||||
UserEntity oldUser = userService.getById(userInfoDTO.getId());
|
||||
UserEntity userEntity = UserInfoConvert.INSTANCE.convertOne(userInfoDTO);
|
||||
// 密码加密(只有传入的密码不为空时,才加密并更新,否则保留原密码)
|
||||
if (StringUtils.hasText(userInfoDTO.getPassword())) {
|
||||
userEntity.setPassword(CommonUtils.encryptPassword(userInfoDTO.getPassword()));
|
||||
} else {
|
||||
// 保留原密码
|
||||
userEntity.setPassword(oldUser.getPassword());
|
||||
}
|
||||
return userService.updateById(userEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -290,7 +298,6 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
|
||||
log.info("注册默认Children User:{}", userEntity);
|
||||
return userEntity.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer checkUserInfo(Integer userId) {
|
||||
UserExtendEntity byUserId = userExtendService.getByUserId(userId);
|
||||
@ -308,6 +315,18 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
|
||||
return userEntity.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getUserIdsByUserNameLike(String userName) {
|
||||
return userService.lambdaQuery().select(UserEntity::getId).like(UserEntity::getUserName, userName)
|
||||
.list().stream().map(UserEntity::getId).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUserIdByMobile(String mobile) {
|
||||
UserEntity one = userService.lambdaQuery().eq(UserEntity::getMobile, mobile).one();
|
||||
return one == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送更新孩子信息的MQ消息
|
||||
*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user