Compare commits
5 Commits
935c4cd828
...
543f972c5c
| Author | SHA1 | Date | |
|---|---|---|---|
| 543f972c5c | |||
| 9e733f71ff | |||
|
|
7792e17438 | ||
|
|
c596fb3db8 | ||
|
|
e44abef9dc |
@ -30,6 +30,7 @@ public enum ResultCodeEnum {
|
||||
USER_MOBILE_EXIST(1002, "该账号号已经被注册"),
|
||||
PHONE_IS_REPEAT(1009, "账号已被注册,请重新输入"),
|
||||
USER_NOT_FOUND(1003, "用户不存在"),
|
||||
USER_SAVE_ERROR(10031, "用户保存失败"),
|
||||
USER_PERMISSION_DENIED_ERROR(1004, "用户权限不足"),
|
||||
PLEASE_LOGIN(1005, "请先登录"),
|
||||
USERNAME_IS_REPEAT(1006, "用户名重复"),
|
||||
@ -337,7 +338,9 @@ public enum ResultCodeEnum {
|
||||
PARENT_NOT_FOUND(13011, "家长不存在"),
|
||||
INVALID_ACTIVITY_STATUS(13012, "无效的活动状态"),
|
||||
PARENT_ALREADY_SIGN_UP(130121, "已经报名参加该活动"),
|
||||
UNAUTHORIZED_UPDATE_EMPLOYEE(13013, "无权限更新员工信息");
|
||||
UNAUTHORIZED_UPDATE_EMPLOYEE(13013, "无权限更新员工信息"),
|
||||
DATA_REPEAT_ERROR(130014, "数据重复"),
|
||||
DATA_NOT_EXIST(130015, "数据不存在");
|
||||
|
||||
private int code;
|
||||
private String msg;
|
||||
|
||||
@ -45,7 +45,12 @@ public enum RoleEnum implements ArrayValuable<String> {
|
||||
/**
|
||||
* 访客
|
||||
*/
|
||||
GUEST("GUEST", "GUEST", "访客"),;
|
||||
GUEST("GUEST", "GUEST", "访客"),
|
||||
|
||||
/**
|
||||
* 代理商
|
||||
*/
|
||||
AGENT("AGENT", "代理商", "代理商角色");
|
||||
|
||||
public static final String[] ARRAYS = Arrays.stream(values()).map(RoleEnum::getCode).toArray(String[]::new);
|
||||
|
||||
|
||||
@ -2,7 +2,6 @@ package com.seer.teach.mp.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.seer.teach.common.config.mybatis.hanler.IntegerListTypeHandler;
|
||||
import com.seer.teach.common.entity.BaseEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
@ -29,18 +28,18 @@ public class MpActivityInfoCollectionEntity extends BaseEntity {
|
||||
@TableField("relation_id")
|
||||
private Integer relationId;
|
||||
|
||||
/**
|
||||
* 活动ID
|
||||
*/
|
||||
@TableField("activity_id")
|
||||
private Integer activityId;
|
||||
|
||||
/**
|
||||
* 代理商ID
|
||||
*/
|
||||
@TableField("agent_id")
|
||||
private Integer agentId;
|
||||
|
||||
/**
|
||||
* 活动ID
|
||||
*/
|
||||
@TableField("activity_id")
|
||||
private Integer activityId;
|
||||
|
||||
/**
|
||||
* 家长ID
|
||||
*/
|
||||
@ -96,14 +95,21 @@ public class MpActivityInfoCollectionEntity extends BaseEntity {
|
||||
private String learningSituation;
|
||||
|
||||
/**
|
||||
* 优势学科(数学、英语等)
|
||||
* 偏科(数学、英语等)
|
||||
*/
|
||||
@TableField(value = "strong_subject_ids",typeHandler = IntegerListTypeHandler.class)
|
||||
private List<Integer> strongSubjectIds;
|
||||
@TableField("weak_subject")
|
||||
private String weakSubject;
|
||||
|
||||
/**
|
||||
* 劣势学科(数学、英语等)
|
||||
* 薄弱科目
|
||||
*/
|
||||
@TableField(value = "weak_subject_ids",typeHandler = IntegerListTypeHandler.class)
|
||||
@TableField("weak_subject_ids")
|
||||
private List<Integer> weakSubjectIds;
|
||||
|
||||
/**
|
||||
* 优势科目
|
||||
*/
|
||||
@TableField("strong_subject_ids")
|
||||
private List<Integer> strongSubjectIds;
|
||||
|
||||
}
|
||||
@ -40,6 +40,9 @@ public class MpAgentEmployeeRelationEntity extends BaseEntity {
|
||||
@TableField("employee_name")
|
||||
private String employeeName;
|
||||
|
||||
@TableField("contact_phone")
|
||||
private String contactPhone;
|
||||
|
||||
/**
|
||||
* 员工职位
|
||||
*/
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.seer.teach.mp.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.seer.teach.common.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
@ -31,6 +32,9 @@ public class MpAgentEntity extends BaseEntity {
|
||||
*/
|
||||
private String contactName;
|
||||
|
||||
@TableField("contact_user_id")
|
||||
private Integer contactUserId;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
|
||||
@ -0,0 +1,50 @@
|
||||
package com.seer.teach.mp.admin.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
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.ActivityInfoCollectionQueryReq;
|
||||
import com.seer.teach.mp.admin.controller.resp.AdminActivityInfoCollectionResp;
|
||||
import com.seer.teach.mp.admin.service.AdminActivityInfoCollectionService;
|
||||
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.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "管理端 - 活动信息收集管理")
|
||||
@LogPrint
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/mp/activity/info/collection")
|
||||
public class AdminActivityInfoCollectionController {
|
||||
|
||||
private final AdminActivityInfoCollectionService adminActivityInfoCollectionService;
|
||||
|
||||
@PostMapping("/page")
|
||||
@SaCheckPermission("admin:activity:info:collection:page")
|
||||
@Operation(summary = "分页查询活动信息收集记录")
|
||||
public ResultBean<PageListBean<AdminActivityInfoCollectionResp>> pageList(
|
||||
@RequestBody @Validated ActivityInfoCollectionQueryReq req) {
|
||||
PageListBean<AdminActivityInfoCollectionResp> result = adminActivityInfoCollectionService.pageList(req);
|
||||
return ResultBean.success(result);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@SaCheckPermission("admin:activity:info:collection:detail")
|
||||
@Operation(summary = "获取活动信息收集记录详情")
|
||||
public ResultBean<AdminActivityInfoCollectionResp> detail(@PathVariable Integer id) {
|
||||
return ResultBean.success(adminActivityInfoCollectionService.getDetail(id));
|
||||
}
|
||||
|
||||
@PostMapping("delete")
|
||||
@SaCheckPermission("admin:activity:info:collection:delete")
|
||||
@Operation(summary = "删除活动信息收集记录")
|
||||
public ResultBean<Boolean> delete(@RequestBody List<Integer> ids) {
|
||||
return ResultBean.success(adminActivityInfoCollectionService.delete(ids));
|
||||
}
|
||||
}
|
||||
@ -5,14 +5,21 @@ 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.AgentQueryReq;
|
||||
import com.seer.teach.mp.admin.controller.req.MpAgentReq;
|
||||
import com.seer.teach.mp.admin.controller.resp.AgentResp;
|
||||
import com.seer.teach.mp.admin.service.AdminAgentService;
|
||||
import com.seer.teach.mp.entity.MpAgentEntity;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
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.*;
|
||||
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 java.util.List;
|
||||
|
||||
@ -42,15 +49,15 @@ public class AdminAgentController {
|
||||
@Operation(summary = "新增")
|
||||
@PostMapping
|
||||
@SaCheckPermission("mp:admin:agent:save")
|
||||
public ResultBean<Boolean> save(@RequestBody MpAgentEntity agentEntity) {
|
||||
return ResultBean.success(adminAgentService.saveAgent(agentEntity));
|
||||
public ResultBean<Boolean> save(@RequestBody MpAgentReq req) {
|
||||
return ResultBean.success(adminAgentService.saveAgent(req));
|
||||
}
|
||||
|
||||
@Operation(summary = "更新")
|
||||
@PutMapping
|
||||
@SaCheckPermission("mp:admin:agent:update")
|
||||
public ResultBean<Boolean> update(@RequestBody MpAgentEntity agentEntity) {
|
||||
return ResultBean.success(adminAgentService.updateAgent(agentEntity));
|
||||
public ResultBean<Boolean> update(@RequestBody MpAgentReq req) {
|
||||
return ResultBean.success(adminAgentService.updateAgent(req));
|
||||
}
|
||||
|
||||
@Operation(summary = "删除")
|
||||
|
||||
@ -1,30 +1,26 @@
|
||||
package com.seer.teach.mp.admin.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
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.ResultBean;
|
||||
import com.seer.teach.common.annotation.LogPrint;
|
||||
import com.seer.teach.common.utils.PageConverterUtils;
|
||||
import com.seer.teach.mp.admin.controller.req.ParentAgentActivityQueryReq;
|
||||
import com.seer.teach.mp.admin.controller.resp.AdminParentAgentActivityResp;
|
||||
import com.seer.teach.mp.admin.controller.resp.MpParentAgentActivityResp;
|
||||
import com.seer.teach.mp.admin.service.AdminParentAgentActivityService;
|
||||
import com.seer.teach.mp.entity.MpParentAgentActivityRelationEntity;
|
||||
import com.seer.teach.mp.service.IMpParentAgentActivityRelationService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 家长参与代理商活动控制器 - 管理端
|
||||
*/
|
||||
@Tag(name = "管理端 - 家长参与代理商活动管理")
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/mp/admin/parent/agent/activity")
|
||||
@RequestMapping("/mp/parent/agent/activity")
|
||||
public class AdminParentAgentActivityController {
|
||||
|
||||
private final AdminParentAgentActivityService adminParentAgentActivityService;
|
||||
@ -45,4 +41,12 @@ public class AdminParentAgentActivityController {
|
||||
public ResultBean<AdminParentAgentActivityResp> detail(@PathVariable Integer id) {
|
||||
return ResultBean.success(adminParentAgentActivityService.getDetail(id));
|
||||
}
|
||||
|
||||
@PostMapping("delete")
|
||||
@SaCheckPermission("admin:parent:agent:activity:delete")
|
||||
@Operation(summary = "删除家长参与代理商活动记录")
|
||||
@LogPrint
|
||||
public ResultBean<Boolean> delete(@RequestBody List<Integer> ids) {
|
||||
return ResultBean.success(adminParentAgentActivityService.delete(ids));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package com.seer.teach.mp.admin.controller.req;
|
||||
|
||||
import com.seer.teach.common.request.PageRequest;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "活动信息收集查询请求")
|
||||
public class ActivityInfoCollectionQueryReq extends PageRequest {
|
||||
|
||||
/**
|
||||
* 孩子姓名
|
||||
*/
|
||||
@Schema(description = "孩子姓名")
|
||||
private String childName;
|
||||
|
||||
/**
|
||||
* 孩子性别(M-男,F-女)
|
||||
*/
|
||||
@Schema(description = "孩子性别")
|
||||
private String childGender;
|
||||
|
||||
/**
|
||||
* 年级
|
||||
*/
|
||||
@Schema(description = "年级")
|
||||
private String grade;
|
||||
|
||||
/**
|
||||
* 学校
|
||||
*/
|
||||
@Schema(description = "学校")
|
||||
private String school;
|
||||
|
||||
}
|
||||
@ -17,6 +17,10 @@ public class AgentEmployeeSaveReq {
|
||||
@NotNull(message = "员工名称不能为空")
|
||||
private String employeeName;
|
||||
|
||||
@Schema(description = "员工密码")
|
||||
@NotNull(message = "员工密码不能为空")
|
||||
private String password;
|
||||
|
||||
@Schema(description = "员工职位")
|
||||
private String position;
|
||||
|
||||
|
||||
@ -0,0 +1,54 @@
|
||||
package com.seer.teach.mp.admin.controller.req;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(name = "MpAgentReq", description = "代理商请求参数")
|
||||
@Data
|
||||
public class MpAgentReq {
|
||||
|
||||
/**
|
||||
* 代理商名称
|
||||
*/
|
||||
private String agentName;
|
||||
|
||||
/**
|
||||
* 代理商编码
|
||||
*/
|
||||
private String agentCode;
|
||||
|
||||
/**
|
||||
* 代理商等级
|
||||
*/
|
||||
private String agentLevel;
|
||||
|
||||
/**
|
||||
* 联系人姓名
|
||||
*/
|
||||
private String contactName;
|
||||
|
||||
/**
|
||||
* 联系人用户Id
|
||||
*/
|
||||
private Integer contactUserId;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
private String contactPhone;
|
||||
|
||||
/**
|
||||
* 登录密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 代理商地址
|
||||
*/
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 代理商状态:0-禁用,1-启用
|
||||
*/
|
||||
private Integer status;
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
package com.seer.teach.mp.admin.controller.resp;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Schema(name = "AdminActivityInfoCollectionResp", description = "活动信息收集响应参数")
|
||||
public class AdminActivityInfoCollectionResp {
|
||||
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 关联的家长参与代理商活动关系ID
|
||||
*/
|
||||
@Schema(description = "关联的家长参与代理商活动关系ID")
|
||||
private Integer relationId;
|
||||
|
||||
@Schema(description = "代理商ID")
|
||||
private Integer agentId;
|
||||
|
||||
/**
|
||||
* 活动ID
|
||||
*/
|
||||
@Schema(description = "活动ID")
|
||||
private Integer activityId;
|
||||
|
||||
/**
|
||||
* 家长ID
|
||||
*/
|
||||
@Schema(description = "家长ID")
|
||||
private Integer parentId;
|
||||
|
||||
/**
|
||||
* 孩子姓名
|
||||
*/
|
||||
@Schema(description = "孩子姓名")
|
||||
private String childName;
|
||||
|
||||
/**
|
||||
* 孩子性别(M-男,F-女)
|
||||
*/
|
||||
@Schema(description = "孩子性别")
|
||||
private String childGender;
|
||||
|
||||
/**
|
||||
* 出生年月
|
||||
*/
|
||||
@Schema(description = "出生年月")
|
||||
private LocalDate childBirthDate;
|
||||
|
||||
/**
|
||||
* 年级
|
||||
*/
|
||||
@Schema(description = "年级")
|
||||
private String grade;
|
||||
|
||||
/**
|
||||
* 学校
|
||||
*/
|
||||
@Schema(description = "学校")
|
||||
private String school;
|
||||
|
||||
/**
|
||||
* 地区
|
||||
*/
|
||||
@Schema(description = "地区")
|
||||
private String region;
|
||||
|
||||
/**
|
||||
* 家长身份(爸爸,妈妈)
|
||||
*/
|
||||
@Schema(description = "家长身份(爸爸,妈妈)")
|
||||
private String parentIdentity;
|
||||
|
||||
/**
|
||||
* 学习情况(优、良、中、差)
|
||||
*/
|
||||
@Schema(description = "学习情况(优、良、中、差)")
|
||||
private String learningSituation;
|
||||
|
||||
/**
|
||||
* 优势学科(数学、英语等)
|
||||
*/
|
||||
@Schema(description = "偏科(数学、英语等)")
|
||||
private String weakSubject;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
@ -42,4 +42,8 @@ public class AdminParentAgentActivityResp {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.seer.teach.mp.admin.convert;
|
||||
|
||||
import com.seer.teach.mp.admin.controller.resp.AdminActivityInfoCollectionResp;
|
||||
import com.seer.teach.mp.entity.MpActivityInfoCollectionEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface AdminActivityInfoCollectionConvert {
|
||||
|
||||
AdminActivityInfoCollectionConvert INSTANCE = Mappers.getMapper(AdminActivityInfoCollectionConvert.class);
|
||||
|
||||
AdminActivityInfoCollectionResp convertToResp(MpActivityInfoCollectionEntity entity);
|
||||
|
||||
List<AdminActivityInfoCollectionResp> convertToRespList(List<MpActivityInfoCollectionEntity> entity);
|
||||
}
|
||||
@ -7,6 +7,7 @@ import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@org.mapstruct.Mapper
|
||||
@Mapper
|
||||
public interface AdminParentAgentActivityConvert {
|
||||
|
||||
|
||||
@ -1,6 +1,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.resp.AgentResp;
|
||||
import com.seer.teach.mp.entity.MpAgentEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
@ -19,5 +20,7 @@ public interface AgentConvert {
|
||||
|
||||
MpAgentEntity convertOne(AgentQueryReq req);
|
||||
|
||||
MpAgentEntity convertOne2Entity(MpAgentReq req);
|
||||
|
||||
AgentQueryReq convertToReq(MpAgentEntity entity);
|
||||
}
|
||||
@ -0,0 +1,62 @@
|
||||
package com.seer.teach.mp.admin.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.seer.teach.common.PageListBean;
|
||||
import com.seer.teach.common.utils.PageConverterUtils;
|
||||
import com.seer.teach.mp.admin.controller.req.ActivityInfoCollectionQueryReq;
|
||||
import com.seer.teach.mp.admin.controller.resp.AdminActivityInfoCollectionResp;
|
||||
import com.seer.teach.mp.admin.convert.AdminActivityInfoCollectionConvert;
|
||||
import com.seer.teach.mp.entity.MpActivityInfoCollectionEntity;
|
||||
import com.seer.teach.mp.service.IMpActivityInfoCollectionService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class AdminActivityInfoCollectionService {
|
||||
|
||||
private final IMpActivityInfoCollectionService mpActivityInfoCollectionService;
|
||||
|
||||
/**
|
||||
* 分页查询活动信息收集记录
|
||||
*
|
||||
* @param req 查询参数
|
||||
* @return 分页结果
|
||||
*/
|
||||
public PageListBean<AdminActivityInfoCollectionResp> pageList(ActivityInfoCollectionQueryReq req) {
|
||||
Page<MpActivityInfoCollectionEntity> page = new Page<>(req.getPageNo(), req.getPageSize());
|
||||
LambdaQueryWrapper<MpActivityInfoCollectionEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.like(Objects.nonNull(req.getChildName()) && !req.getChildName().isEmpty(), MpActivityInfoCollectionEntity::getChildName, req.getChildName())
|
||||
.like(Objects.nonNull(req.getGrade()) && !req.getGrade().isEmpty(), MpActivityInfoCollectionEntity::getGrade, req.getGrade())
|
||||
.like(Objects.nonNull(req.getSchool()) && !req.getSchool().isEmpty(), MpActivityInfoCollectionEntity::getSchool, req.getSchool())
|
||||
.like(Objects.nonNull(req.getChildGender()) && !req.getChildGender().isEmpty(), MpActivityInfoCollectionEntity::getChildGender, req.getChildGender())
|
||||
.orderByDesc(MpActivityInfoCollectionEntity::getCreateTime);
|
||||
Page<MpActivityInfoCollectionEntity> result = mpActivityInfoCollectionService.page(page, wrapper);
|
||||
return PageConverterUtils.convertPageListBean(result, AdminActivityInfoCollectionConvert.INSTANCE::convertToRespList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取活动信息收集记录详情
|
||||
* @param id 记录ID
|
||||
* @return 详情
|
||||
*/
|
||||
public AdminActivityInfoCollectionResp getDetail(Integer id) {
|
||||
MpActivityInfoCollectionEntity entity = mpActivityInfoCollectionService.getById(id);
|
||||
return AdminActivityInfoCollectionConvert.INSTANCE.convertToResp(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除活动信息收集记录
|
||||
* @param ids 删除的ID列表
|
||||
* @return 删除结果
|
||||
*/
|
||||
public boolean delete(List<Integer> ids) {
|
||||
return mpActivityInfoCollectionService.removeByIds(ids);
|
||||
}
|
||||
}
|
||||
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.seer.teach.common.PageListBean;
|
||||
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.resp.AgentResp;
|
||||
import com.seer.teach.mp.admin.convert.AgentConvert;
|
||||
import com.seer.teach.mp.entity.MpAgentEntity;
|
||||
@ -59,11 +60,12 @@ public class AdminAgentService {
|
||||
/**
|
||||
* 保存代理商
|
||||
*
|
||||
* @param agentEntity 代理商实体
|
||||
* @param req 代理商
|
||||
* @return 是否成功
|
||||
*/
|
||||
public Boolean saveAgent(MpAgentEntity agentEntity) {
|
||||
boolean result = mpAgentService.saveAgent(agentEntity);
|
||||
public Boolean saveAgent(MpAgentReq req) {
|
||||
MpAgentEntity agentEntity = AgentConvert.INSTANCE.convertOne2Entity(req);
|
||||
boolean result = mpAgentService.saveAgent(agentEntity,req.getPassword());
|
||||
log.info("保存代理商结果: {}", result);
|
||||
return result;
|
||||
}
|
||||
@ -71,10 +73,11 @@ public class AdminAgentService {
|
||||
/**
|
||||
* 更新代理商
|
||||
*
|
||||
* @param agentEntity 代理商实体
|
||||
* @param req 代理商
|
||||
* @return 是否成功
|
||||
*/
|
||||
public Boolean updateAgent(MpAgentEntity agentEntity) {
|
||||
public Boolean updateAgent(MpAgentReq req) {
|
||||
MpAgentEntity agentEntity = AgentConvert.INSTANCE.convertOne2Entity(req);
|
||||
boolean result = mpAgentService.updateAgent(agentEntity);
|
||||
log.info("更新代理商结果: {}", result);
|
||||
return result;
|
||||
|
||||
@ -76,7 +76,7 @@ public class AdminDealerApplicationsService {
|
||||
userInfoDTO.setRealName(application.getApplicantName());
|
||||
userInfoDTO.setMobile(application.getPhone());
|
||||
userInfoDTO.setIdCardNumber(application.getIdCardNumber());
|
||||
userInfoDTO.setRoleCode(RoleEnum.DISTRIBUTOR.getCode());
|
||||
userInfoDTO.setRoleCode(RoleEnum.DISTRIBUTOR);
|
||||
boolean updated = userInfoServiceApi.updateUserInfoAndAssignRole(userInfoDTO);
|
||||
log.info("更新用户[{}]信息结果: {}",application.getApplicantUserId(), updated);
|
||||
if(updated){
|
||||
|
||||
@ -4,11 +4,9 @@ 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.ResultBean;
|
||||
import com.seer.teach.common.utils.PageConverterUtils;
|
||||
import com.seer.teach.mp.admin.controller.req.ParentAgentActivityQueryReq;
|
||||
import com.seer.teach.mp.admin.controller.resp.AdminParentAgentActivityResp;
|
||||
import com.seer.teach.mp.admin.controller.resp.MpParentAgentActivityResp;
|
||||
import com.seer.teach.mp.admin.convert.AdminParentAgentActivityConvert;
|
||||
import com.seer.teach.mp.entity.MpParentAgentActivityRelationEntity;
|
||||
import com.seer.teach.mp.service.IMpParentAgentActivityRelationService;
|
||||
@ -16,6 +14,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@ -32,7 +31,7 @@ public class AdminParentAgentActivityService {
|
||||
LambdaQueryWrapper<MpParentAgentActivityRelationEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(Objects.nonNull(query.getActivityId()), MpParentAgentActivityRelationEntity::getActivityId, query.getActivityId())
|
||||
.eq(Objects.nonNull(query.getAgentId()), MpParentAgentActivityRelationEntity::getAgentId, query.getAgentId())
|
||||
.eq(Objects.nonNull(query.getAgentId()), MpParentAgentActivityRelationEntity::getParentId, query.getAgentId())
|
||||
.eq(Objects.nonNull(query.getParentId()), MpParentAgentActivityRelationEntity::getParentId, query.getParentId())
|
||||
.like(Objects.nonNull(query.getActivityName()) && !query.getActivityName().isEmpty(), MpParentAgentActivityRelationEntity::getActivityName, query.getActivityName())
|
||||
.like(Objects.nonNull(query.getAgentName()) && !query.getAgentName().isEmpty(), MpParentAgentActivityRelationEntity::getAgentName, query.getAgentName())
|
||||
.eq(Objects.nonNull(query.getStatus()), MpParentAgentActivityRelationEntity::getStatus, query.getStatus())
|
||||
@ -47,4 +46,8 @@ public class AdminParentAgentActivityService {
|
||||
MpParentAgentActivityRelationEntity entity = parentAgentActivityRelationService.getById(id);
|
||||
return AdminParentAgentActivityConvert.INSTANCE.convertToResp(entity);
|
||||
}
|
||||
|
||||
public boolean delete(List<Integer> ids) {
|
||||
return parentAgentActivityRelationService.removeByIds(ids);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,18 +4,21 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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.enums.RoleEnum;
|
||||
import com.seer.teach.common.utils.AssertUtils;
|
||||
import com.seer.teach.common.utils.PageConverterUtils;
|
||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeSaveReq;
|
||||
import com.seer.teach.mp.admin.service.IAdminAgentEmployeeRelationService;
|
||||
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.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 org.springframework.stereotype.Service;
|
||||
|
||||
@ -38,6 +41,8 @@ public class AdminAgentEmployeeRelationServiceImpl implements IAdminAgentEmploye
|
||||
|
||||
private final IMpAgentService mpAgentService;
|
||||
|
||||
private final UserInfoServiceApi userInfoServiceApi;
|
||||
|
||||
@Override
|
||||
public PageListBean<AgentEmployeeRelationResp> pageList(AgentEmployeeRelationQueryReq query) {
|
||||
Page<MpAgentEmployeeRelationEntity> pageParm = new Page<>(query.getPageNo(), query.getPageSize());
|
||||
@ -70,15 +75,29 @@ public class AdminAgentEmployeeRelationServiceImpl implements IAdminAgentEmploye
|
||||
public List<AgentEmployeeRelationResp> getEmployeeRelationsByAgentId(Integer agentId) {
|
||||
var relations = agentEmployeeRelationService.getEmployeeRelationsByAgentId(agentId);
|
||||
return relations.stream()
|
||||
.map(AdminAgentEmployeeRelationConvert.INSTANCE::convertToResp)
|
||||
.toList();
|
||||
.map(AdminAgentEmployeeRelationConvert.INSTANCE::convertToResp)
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean save(AgentEmployeeSaveReq request) {
|
||||
AssertUtils.isNull(request.getAgentName(), ResultCodeEnum.AGENT_EMPLOYEE_ALREADY_EXISTS);
|
||||
MpAgentEmployeeRelationEntity relation = AdminAgentEmployeeRelationConvert.INSTANCE.convert(request);
|
||||
MpAgentEmployeeRelationEntity one = agentEmployeeRelationService.lambdaQuery()
|
||||
.eq(MpAgentEmployeeRelationEntity::getEmployeeName, request.getEmployeeName()).one();
|
||||
AssertUtils.isNull(one, ResultCodeEnum.AGENT_EMPLOYEE_ALREADY_EXISTS);
|
||||
UserInfoDTO userInfoDTO = new UserInfoDTO();
|
||||
userInfoDTO.setUserName(request.getEmployeeName());
|
||||
userInfoDTO.setPassword(request.getPassword());
|
||||
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.setEmployeeUserId(userId);
|
||||
entity.setEmployeeName(request.getEmployeeName());
|
||||
entity.setAgentName(request.getAgentName());
|
||||
entity.setPosition(request.getPosition());
|
||||
entity.setStatus(request.getStatus());
|
||||
agentEmployeeRelationService.save(entity);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -127,6 +127,7 @@ DROP TABLE IF EXISTS `mp_activity_info_collection`;
|
||||
CREATE TABLE `mp_activity_info_collection` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '信息收集ID',
|
||||
`relation_id` int NOT NULL COMMENT '关联的家长参与代理商活动关系ID',
|
||||
`agent_id` int NOT NULL COMMENT '代理商ID',
|
||||
`activity_id` int NOT NULL COMMENT '活动ID',
|
||||
`parent_id` int NOT NULL COMMENT '家长ID',
|
||||
`child_name` varchar(100) COMMENT '孩子姓名',
|
||||
@ -137,6 +138,8 @@ CREATE TABLE `mp_activity_info_collection` (
|
||||
`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` 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 '创建人',
|
||||
|
||||
@ -25,6 +25,12 @@
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>seer-user-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||
|
||||
@ -50,7 +50,6 @@ public class AppAgentEmployeeRelationController {
|
||||
@SaCheckLogin
|
||||
public ResultBean<Boolean> updateEmployee(@RequestBody @Validated AppAgentEmployeeRelationReq request) {
|
||||
Integer agentId = StpUtil.getLoginIdAsInt();
|
||||
// 验证员工是否属于当前代理商
|
||||
boolean belongsToAgent = agentEmployeeRelationService.isEmployeeBelongsToAgent(request.getId(), agentId);
|
||||
if (!belongsToAgent) {
|
||||
return ResultBean.error(ResultCodeEnum.UNAUTHORIZED_UPDATE_EMPLOYEE);
|
||||
@ -74,8 +73,7 @@ public class AppAgentEmployeeRelationController {
|
||||
@GetMapping("/{id}")
|
||||
@SaCheckLogin
|
||||
public ResultBean<AppAgentEmployeeRelationResp> getEmployee(@PathVariable Integer id) {
|
||||
Integer agentId = StpUtil.getLoginIdAsInt(); // 假设代理商ID就是登录ID
|
||||
// 验证员工是否属于当前代理商
|
||||
Integer agentId = StpUtil.getLoginIdAsInt();
|
||||
boolean belongsToAgent = agentEmployeeRelationService.isEmployeeBelongsToAgent(id, agentId);
|
||||
if (!belongsToAgent) {
|
||||
return ResultBean.error(ResultCodeEnum.UNAUTHORIZED_UPDATE_EMPLOYEE);
|
||||
@ -88,7 +86,7 @@ public class AppAgentEmployeeRelationController {
|
||||
@GetMapping("/all")
|
||||
@SaCheckLogin
|
||||
public ResultBean<List<AppAgentEmployeeRelationResp>> getAllEmployees() {
|
||||
Integer agentId = StpUtil.getLoginIdAsInt(); // 假设代理商ID就是登录ID
|
||||
Integer agentId = StpUtil.getLoginIdAsInt();
|
||||
return ResultBean.success(agentEmployeeRelationService.getAllEmployeesByAgentId(agentId));
|
||||
}
|
||||
}
|
||||
@ -13,11 +13,16 @@ public class AppAgentEmployeeRelationReq {
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "代理商ID")
|
||||
private Integer agentId; // 用于内部验证,不强制要求前端传入
|
||||
private Integer agentId;
|
||||
|
||||
@NotNull(message = "员工用户ID不能为空")
|
||||
@Schema(description = "员工用户ID")
|
||||
private Integer employeeUserId;
|
||||
@Schema(description = "员工名称")
|
||||
private String employeeName;
|
||||
|
||||
@Schema(description = "员工密码")
|
||||
private String password;
|
||||
|
||||
@Schema(description = "联系电话")
|
||||
private String contactPhone;
|
||||
|
||||
@Schema(description = "员工职位")
|
||||
private String position;
|
||||
|
||||
@ -27,4 +27,7 @@ public class AppMpAgentResp {
|
||||
|
||||
@Schema(description = "代理商地址")
|
||||
private String address;
|
||||
|
||||
@Schema(description = "是否是代理商联系人")
|
||||
private Boolean isContactPerson;
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ 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.enums.RoleEnum;
|
||||
import com.seer.teach.common.exception.CommonException;
|
||||
import com.seer.teach.common.utils.AssertUtils;
|
||||
import com.seer.teach.common.utils.PageConverterUtils;
|
||||
@ -15,8 +16,10 @@ 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.user.api.UserService;
|
||||
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;
|
||||
@ -39,18 +42,18 @@ import java.util.stream.Collectors;
|
||||
public class AppAgentEmployeeRelationServiceImpl implements IAppAgentEmployeeRelationService {
|
||||
|
||||
private final IMpAgentEmployeeRelationService mpAgentEmployeeRelationService;
|
||||
private final UserService userService;
|
||||
private final UserInfoServiceApi userInfoServiceApi;
|
||||
|
||||
@Override
|
||||
public PageListBean<AppAgentEmployeeRelationResp> pageList(AppAgentEmployeeRelationQueryReq query) {
|
||||
log.info("查询参数:{}", query);
|
||||
IPage<MpAgentEmployeeRelationEntity> page = new Page<>(query.getPageNo(), query.getPageSize());
|
||||
var pageResult = mpAgentEmployeeRelationService.page(page, new LambdaQueryWrapper<>(MpAgentEmployeeRelationEntity.class)
|
||||
.eq(query.getAgentId() != null, MpAgentEmployeeRelationEntity::getAgentId, query.getAgentId()) // 只查询当前代理商的员工
|
||||
.eq(MpAgentEmployeeRelationEntity::getAgentId, query.getAgentId())
|
||||
.like(StringUtils.isNotBlank(query.getPosition()), MpAgentEmployeeRelationEntity::getPosition, query.getPosition())
|
||||
.eq(query.getStatus() != null, MpAgentEmployeeRelationEntity::getStatus, query.getStatus()));
|
||||
|
||||
if (pageResult.getRecords() == null || pageResult.getRecords().isEmpty()) {
|
||||
if (CollectionUtil.isEmpty(pageResult.getRecords())) {
|
||||
log.info("查询结果为空");
|
||||
}
|
||||
log.info("查询代理商员工数量:{}", pageResult.getTotal());
|
||||
@ -60,22 +63,27 @@ public class AppAgentEmployeeRelationServiceImpl implements IAppAgentEmployeeRel
|
||||
|
||||
@Override
|
||||
public boolean addEmployee(AppAgentEmployeeRelationReq request) {
|
||||
// 检查员工是否已经存在于当前代理商下
|
||||
LambdaQueryWrapper<MpAgentEmployeeRelationEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(MpAgentEmployeeRelationEntity::getAgentId, request.getAgentId())
|
||||
.eq(MpAgentEmployeeRelationEntity::getEmployeeUserId, request.getEmployeeUserId());
|
||||
.eq(MpAgentEmployeeRelationEntity::getContactPhone, request.getContactPhone());
|
||||
|
||||
MpAgentEmployeeRelationEntity existing = mpAgentEmployeeRelationService.getOne(wrapper);
|
||||
if (existing != null) {
|
||||
throw new CommonException(ResultCodeEnum.DATA_REPEAT_ERROR, "该员工已属于当前代理商");
|
||||
}
|
||||
UserInfoDTO userInfoDTO = new UserInfoDTO();
|
||||
userInfoDTO.setUserName(request.getEmployeeName());
|
||||
userInfoDTO.setMobile(request.getContactPhone());
|
||||
userInfoDTO.setPassword(request.getPassword());
|
||||
userInfoDTO.setRoleCode(RoleEnum.AGENT);
|
||||
Integer userId = userInfoServiceApi.addUserInfoAndAssignRole(userInfoDTO);
|
||||
|
||||
MpAgentEmployeeRelationEntity entity = new MpAgentEmployeeRelationEntity();
|
||||
entity.setAgentId(request.getAgentId());
|
||||
entity.setEmployeeUserId(request.getEmployeeUserId());
|
||||
entity.setEmployeeUserId(userId);
|
||||
entity.setPosition(request.getPosition());
|
||||
entity.setStatus(request.getStatus());
|
||||
|
||||
|
||||
boolean result = mpAgentEmployeeRelationService.save(entity);
|
||||
log.info("新增员工结果:{}", result);
|
||||
return result;
|
||||
@ -86,15 +94,24 @@ public class AppAgentEmployeeRelationServiceImpl implements IAppAgentEmployeeRel
|
||||
// 验证员工是否属于当前代理商(通过ID查询并验证)
|
||||
MpAgentEmployeeRelationEntity existing = mpAgentEmployeeRelationService.getById(request.getId());
|
||||
AssertUtils.notNull(existing, ResultCodeEnum.DATA_NOT_EXIST);
|
||||
|
||||
|
||||
if (!existing.getAgentId().equals(request.getAgentId())) {
|
||||
throw new CommonException(ResultCodeEnum.PERMISSION_DENIED, "无权限操作此员工");
|
||||
}
|
||||
|
||||
existing.setEmployeeUserId(request.getEmployeeUserId());
|
||||
existing.setPosition(request.getPosition());
|
||||
existing.setStatus(request.getStatus());
|
||||
UserInfoDTO userInfoDTO = new UserInfoDTO();
|
||||
userInfoDTO.setUserName(request.getEmployeeName());
|
||||
userInfoDTO.setMobile(request.getContactPhone());
|
||||
userInfoDTO.setPassword(request.getPassword());
|
||||
boolean updateUserResult = userInfoServiceApi.updateUserInfo(userInfoDTO);
|
||||
log.info("更新员工结果:{}", updateUserResult);
|
||||
|
||||
MpAgentEmployeeRelationEntity updateEntity = new MpAgentEmployeeRelationEntity();
|
||||
updateEntity.setId(request.getId());
|
||||
updateEntity.setPosition(request.getPosition());
|
||||
updateEntity.setStatus(request.getStatus());
|
||||
updateEntity.setEmployeeName(request.getEmployeeName());
|
||||
existing.setContactPhone(request.getContactPhone());
|
||||
boolean result = mpAgentEmployeeRelationService.updateById(existing);
|
||||
log.info("更新员工结果:{}", result);
|
||||
return result;
|
||||
@ -102,10 +119,8 @@ public class AppAgentEmployeeRelationServiceImpl implements IAppAgentEmployeeRel
|
||||
|
||||
@Override
|
||||
public boolean deleteEmployee(Integer id) {
|
||||
// 验证员工是否属于当前代理商
|
||||
MpAgentEmployeeRelationEntity existing = mpAgentEmployeeRelationService.getById(id);
|
||||
AssertUtils.notNull(existing, ResultCodeEnum.DATA_NOT_EXIST);
|
||||
|
||||
boolean result = mpAgentEmployeeRelationService.removeById(id);
|
||||
log.info("删除员工结果:{}", result);
|
||||
return result;
|
||||
@ -130,7 +145,6 @@ public class AppAgentEmployeeRelationServiceImpl implements IAppAgentEmployeeRel
|
||||
if (CollectionUtil.isEmpty(entities)) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
return entities.stream()
|
||||
.map(this::convertToResp)
|
||||
.collect(Collectors.toList());
|
||||
@ -159,7 +173,7 @@ public class AppAgentEmployeeRelationServiceImpl implements IAppAgentEmployeeRel
|
||||
|
||||
// 通过用户服务获取员工的详细信息
|
||||
if (entity.getEmployeeUserId() != null) {
|
||||
UserInfoDTO userInfo = userService.getUserInfoById(entity.getEmployeeUserId());
|
||||
UserInfoDTO userInfo = userInfoServiceApi.getByUserId(entity.getEmployeeUserId());
|
||||
resp.setEmployeeUserInfo(userInfo);
|
||||
}
|
||||
|
||||
|
||||
@ -30,7 +30,9 @@ public class AppAgentServiceImpl implements IAppAgentService {
|
||||
if (agentEntity == null) {
|
||||
return null;
|
||||
}
|
||||
return AppAgentConvert.INSTANCE.entityToResp(agentEntity);
|
||||
AppMpAgentResp appMpAgentResp = AppAgentConvert.INSTANCE.entityToResp(agentEntity);
|
||||
appMpAgentResp.setIsContactPerson(agentEntity.getContactUserId().equals(userId));
|
||||
return appMpAgentResp;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -22,9 +22,10 @@ public interface IMpAgentService extends IService<MpAgentEntity> {
|
||||
* 保存代理商
|
||||
*
|
||||
* @param agentEntity 代理商实体
|
||||
* @param password m密码
|
||||
* @return 是否成功
|
||||
*/
|
||||
Boolean saveAgent(MpAgentEntity agentEntity);
|
||||
Boolean saveAgent(MpAgentEntity agentEntity,String password);
|
||||
|
||||
/**
|
||||
* 更新代理商
|
||||
|
||||
@ -1,9 +1,15 @@
|
||||
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;
|
||||
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;
|
||||
@ -11,16 +17,28 @@ import java.util.List;
|
||||
/**
|
||||
* 代理商服务实现类
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
@Slf4j
|
||||
public class MpAgentServiceImpl extends ServiceImpl<MpAgentMapper, MpAgentEntity> implements IMpAgentService {
|
||||
|
||||
private final UserInfoServiceApi userInfoServiceApi;
|
||||
|
||||
@Override
|
||||
public MpAgentEntity getAgentById(Integer id) {
|
||||
return this.getById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean saveAgent(MpAgentEntity agentEntity) {
|
||||
public Boolean saveAgent(MpAgentEntity agentEntity,String password) {
|
||||
UserInfoDTO userInfoDTO = new UserInfoDTO();
|
||||
userInfoDTO.setUserName(agentEntity.getAgentName());
|
||||
userInfoDTO.setPassword(password);
|
||||
userInfoDTO.setMobile(agentEntity.getContactPhone());
|
||||
userInfoDTO.setRoleCode(RoleEnum.AGENT);
|
||||
Integer userId = userInfoServiceApi.addUserInfoAndAssignRole(userInfoDTO);
|
||||
log.info("用户id:{}", userId);
|
||||
agentEntity.setContactUserId(userId);
|
||||
return this.save(agentEntity);
|
||||
}
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ 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;
|
||||
|
||||
@ -124,6 +125,24 @@ public interface UserInfoServiceApi {
|
||||
@PostMapping("/update-user-assign-role")
|
||||
boolean updateUserInfoAndAssignRole(@RequestBody UserInfoDTO userInfoDTO);
|
||||
|
||||
/**
|
||||
* 跟新用户信息
|
||||
*
|
||||
* @param userInfoDTO 用户信息
|
||||
* @return 用户ID
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
boolean updateUserInfo(@RequestBody UserInfoDTO userInfoDTO);
|
||||
|
||||
/**
|
||||
* 新增用户信息并分配角色
|
||||
*
|
||||
* @param userInfoDTO 用户信息
|
||||
* @return 用户ID
|
||||
*/
|
||||
@PostMapping("/update-user-assign-role")
|
||||
Integer addUserInfoAndAssignRole(@RequestBody UserInfoDTO userInfoDTO);
|
||||
|
||||
/**
|
||||
* 根据孩子Id获取家长信息
|
||||
*
|
||||
@ -170,4 +189,8 @@ public interface UserInfoServiceApi {
|
||||
|
||||
@GetMapping("/checkUserInfo")
|
||||
Integer checkUserInfo(@RequestParam("userId") Integer userId);
|
||||
|
||||
@GetMapping("/getUserIdByUserName")
|
||||
Integer getUserIdByUserName(@RequestParam("userName") String userName);
|
||||
|
||||
}
|
||||
@ -2,12 +2,28 @@ package com.seer.teach.user.api;
|
||||
|
||||
import com.seer.teach.user.api.dto.UserRelationDTO;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
@FeignClient(name = ApiConstants.SERVER_NAME, contextId = "userRelationServiceApi", path = "/seer/user/internal")
|
||||
public interface UserRelationServiceApi {
|
||||
|
||||
/**
|
||||
* 保存用户关系
|
||||
*
|
||||
* @param userRelationDTO 用户关系信息
|
||||
* @return 保存结果
|
||||
*/
|
||||
@PostMapping("/save-relation")
|
||||
boolean saveUserRelation(@RequestBody UserRelationDTO userRelationDTO);
|
||||
|
||||
/**
|
||||
* 删除用户关系
|
||||
*
|
||||
* @param userRelationDTO 用户关系信息
|
||||
* @return 删除结果
|
||||
*/
|
||||
@DeleteMapping("/delete")
|
||||
boolean deleteUserRelation(@RequestBody UserRelationDTO userRelationDTO);
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
package com.seer.teach.user.api.dto;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.seer.teach.common.enums.RoleEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@ -62,5 +63,5 @@ public class UserInfoDTO {
|
||||
private Integer experience;
|
||||
|
||||
@Schema(description = "角色编码")
|
||||
private String roleCode;
|
||||
private RoleEnum roleCode;
|
||||
}
|
||||
@ -1,18 +1,23 @@
|
||||
package com.seer.teach.user.api.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "用户关系DTO")
|
||||
@Data
|
||||
public class UserRelationDTO {
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@NotNull(message = "用户ID不能为空")
|
||||
private Integer userId;
|
||||
|
||||
/**
|
||||
* 关联的用户ID
|
||||
*/
|
||||
@NotNull(message = "关联的用户ID不能为空")
|
||||
private Integer relationId;
|
||||
|
||||
/**
|
||||
|
||||
@ -8,6 +8,7 @@ import com.seer.teach.common.enums.ResultCodeEnum;
|
||||
import com.seer.teach.common.enums.RoleEnum;
|
||||
import com.seer.teach.common.enums.im.UserInfoTopiTagEnum;
|
||||
import com.seer.teach.common.enums.iot.IsInfoEnum;
|
||||
import com.seer.teach.common.exception.CommonException;
|
||||
import com.seer.teach.common.utils.AssertUtils;
|
||||
import com.seer.teach.common.utils.CommonUtils;
|
||||
import com.seer.teach.iot.api.UserDeviceServiceApi;
|
||||
@ -61,6 +62,7 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
|
||||
|
||||
/**
|
||||
* 根据用户ID获取用户信息
|
||||
*
|
||||
* @param id 用户ID
|
||||
* @return 用户信息DTO对象
|
||||
*/
|
||||
@ -72,7 +74,7 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
|
||||
log.info("userEntity:{}", userEntity);
|
||||
UserExtendEntity userExtendEntity = userExtendService.getUserExtendByUserId(id);
|
||||
log.info("userExtendEntity:{}", userExtendEntity);
|
||||
return UserInfoConvert.INSTANCE.convertOne(userEntity,userExtendEntity);
|
||||
return UserInfoConvert.INSTANCE.convertOne(userEntity, userExtendEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -93,20 +95,21 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserAuthDTO> getUserAuthListByUserIdsAndAppId(UserAuthQueryDTO userAuthQueryDTO){
|
||||
public List<UserAuthDTO> getUserAuthListByUserIdsAndAppId(UserAuthQueryDTO userAuthQueryDTO) {
|
||||
List<UserAuthEntity> userAuthList = userAuthService.getUserAuthListByUserIdsAndAppId(userAuthQueryDTO.getUserIds(), userAuthQueryDTO.getAppId());
|
||||
return UserInfoConvert.INSTANCE.convertUserAuthList(userAuthList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据OpenId获取用户信息
|
||||
*
|
||||
* @param openId 微信OpenId
|
||||
* @return 用户信息DTO对象
|
||||
*/
|
||||
@Override
|
||||
public UserInfoDTO getByOpenId(String openId) {
|
||||
UserAuthEntity userAuthEntity = userAuthService.getOneByOpenId(openId);
|
||||
if(Objects.isNull(userAuthEntity)){
|
||||
if (Objects.isNull(userAuthEntity)) {
|
||||
return null;
|
||||
}
|
||||
UserEntity userEntity = userService.getById(userAuthEntity.getUserId());
|
||||
@ -115,13 +118,14 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
|
||||
|
||||
/**
|
||||
* 获取用户权限信息
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 用户权限DTO对象
|
||||
*/
|
||||
@Override
|
||||
public UserPermissionDTO getUserPermission(Integer userId) {
|
||||
UserEntity userEntity = userService.getById(userId);
|
||||
if(Objects.isNull(userEntity)){
|
||||
if (Objects.isNull(userEntity)) {
|
||||
return new UserPermissionDTO();
|
||||
}
|
||||
List<AuthorityEntity> permissions = authorityService.getPermissionsByUserId(userId);
|
||||
@ -130,7 +134,8 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
|
||||
|
||||
/**
|
||||
* 为用户添加经验值
|
||||
* @param userId 用户ID
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param experienceValue 要添加的经验值
|
||||
*/
|
||||
@Override
|
||||
@ -140,11 +145,12 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
|
||||
UserExtendEntity userExtend = userExtendService.extraPoints(userId, experienceValue);
|
||||
Integer parentId = userInfoServiceApi.getParentIdByChildrenId(children.getId());
|
||||
UserCoinAccountRespDTO userCoinAccount = coinAccountServiceApi.getUserCoinAccount(parentId);
|
||||
pushUpdateChildrenInfoMessage(children,userExtend,device,userId,userCoinAccount);
|
||||
pushUpdateChildrenInfoMessage(children, userExtend, device, userId, userCoinAccount);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取孩子信息
|
||||
*
|
||||
* @param userId 孩子用户ID
|
||||
* @return 孩子信息DTO对象
|
||||
*/
|
||||
@ -168,6 +174,7 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
|
||||
|
||||
/**
|
||||
* 获取孩子年级ID
|
||||
*
|
||||
* @param userId 孩子用户ID
|
||||
* @return 年级ID
|
||||
*/
|
||||
@ -179,24 +186,25 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
|
||||
|
||||
/**
|
||||
* 保存用户信息
|
||||
*
|
||||
* @param userInfoDTO 用户信息DTO对象
|
||||
* @return 用户ID,如果用户已存在则返回已存在的用户ID
|
||||
*/
|
||||
@Override
|
||||
public Integer save(UserInfoDTO userInfoDTO) {
|
||||
// 根据UnionId判断用户是否已存在
|
||||
if(StringUtils.hasText(userInfoDTO.getUnionId())){
|
||||
if (StringUtils.hasText(userInfoDTO.getUnionId())) {
|
||||
UserAuthEntity userAuthEntity = userAuthService.getOneByUnionId(userInfoDTO.getUnionId());
|
||||
if(Objects.nonNull(userAuthEntity)){
|
||||
if (Objects.nonNull(userAuthEntity)) {
|
||||
log.info("用户已存在,请勿重复添加");
|
||||
return userAuthEntity.getId();
|
||||
}
|
||||
return save0(userInfoDTO);
|
||||
}
|
||||
// 根据OpenId判断用户是否已存在
|
||||
if(StringUtils.hasText(userInfoDTO.getOpenId())){
|
||||
if (StringUtils.hasText(userInfoDTO.getOpenId())) {
|
||||
UserAuthEntity one = userAuthService.getOneByOpenId(userInfoDTO.getOpenId());
|
||||
if(Objects.nonNull(one)){
|
||||
if (Objects.nonNull(one)) {
|
||||
log.info("用户已存在,请勿重复添加");
|
||||
return one.getId();
|
||||
}
|
||||
@ -208,10 +216,29 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
|
||||
@Override
|
||||
public boolean updateUserInfoAndAssignRole(UserInfoDTO userInfoDTO) {
|
||||
UserEntity UserEntity = UserInfoConvert.INSTANCE.convertOne(userInfoDTO);
|
||||
userRoleService.assignUserRoleByRoleCode(UserEntity.getId(), userInfoDTO.getRoleCode());
|
||||
userRoleService.assignUserRoleByRoleCode(UserEntity.getId(), userInfoDTO.getRoleCode().getCode());
|
||||
return userService.updateById(UserEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateUserInfo(UserInfoDTO userInfoDTO) {
|
||||
UserEntity UserEntity = UserInfoConvert.INSTANCE.convertOne(userInfoDTO);
|
||||
return userService.updateById(UserEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer addUserInfoAndAssignRole(UserInfoDTO userInfoDTO) {
|
||||
UserEntity userEntity = UserInfoConvert.INSTANCE.convertOne(userInfoDTO);
|
||||
userEntity.setPassword(CommonUtils.encryptPassword(userInfoDTO.getPassword()));
|
||||
boolean saved = userService.save(userEntity);
|
||||
log.info("保存用户信息:{}", saved);
|
||||
if(saved){
|
||||
userRoleService.assignUserRoleByRoleCode(userEntity.getId(), userInfoDTO.getRoleCode().getCode());
|
||||
return userEntity.getId();
|
||||
}
|
||||
throw new CommonException(ResultCodeEnum.USER_SAVE_ERROR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getParentIdByChildrenId(Integer childrenId) {
|
||||
return userRelationService.getParentIdByChildrenId(childrenId);
|
||||
@ -220,7 +247,7 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
|
||||
@Override
|
||||
public List<UserInfoDTO> listByMobile(String mobile) {
|
||||
List<UserEntity> userList = userService.list(new LambdaQueryWrapper<UserEntity>()
|
||||
.like(UserEntity::getMobile, mobile));
|
||||
.like(UserEntity::getMobile, mobile));
|
||||
return UserInfoConvert.INSTANCE.convertList(userList);
|
||||
}
|
||||
|
||||
@ -233,6 +260,7 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
|
||||
|
||||
/**
|
||||
* 根据用户ID列表获取用户信息
|
||||
*
|
||||
* @param userIds
|
||||
* @return
|
||||
*/
|
||||
@ -244,6 +272,7 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
|
||||
|
||||
/**
|
||||
* 根据用户ID获取用户信息
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@ -265,40 +294,52 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
|
||||
@Override
|
||||
public Integer checkUserInfo(Integer userId) {
|
||||
UserExtendEntity byUserId = userExtendService.getByUserId(userId);
|
||||
if (Objects.isNull(byUserId)){
|
||||
if (Objects.isNull(byUserId)) {
|
||||
return IsInfoEnum.NO_INFO.getCode();
|
||||
}
|
||||
return IsInfoEnum.HAS_INFO.getCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getUserIdByUserName(String userName) {
|
||||
UserEntity userEntity = userService.getOne(new LambdaQueryWrapper<UserEntity>()
|
||||
.eq(UserEntity::getUserName, userName));
|
||||
if (Objects.nonNull(userEntity)) {
|
||||
return userEntity.getId();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送更新孩子信息的MQ消息
|
||||
* @param children 孩子用户实体对象
|
||||
*
|
||||
* @param children 孩子用户实体对象
|
||||
* @param userExtendEntity 用户扩展信息实体对象
|
||||
* @param device 设备信息
|
||||
* @param userId 用户ID
|
||||
* @param device 设备信息
|
||||
* @param userId 用户ID
|
||||
*/
|
||||
public void pushUpdateChildrenInfoMessage(UserEntity children,UserExtendEntity userExtendEntity, String device, Integer userId,UserCoinAccountRespDTO userCoinAccount) {
|
||||
public void pushUpdateChildrenInfoMessage(UserEntity children, UserExtendEntity userExtendEntity, String device, Integer userId, UserCoinAccountRespDTO userCoinAccount) {
|
||||
// 获取年级和等级信息
|
||||
GradeEntity grade = gradeService.getById(userExtendEntity.getGradeId());
|
||||
LevelEntity level = levelService.getById(userExtendEntity.getLevelId());
|
||||
MqUserInfoDTO userInfoDTO = UserInfoConvert.INSTANCE.toMqUserInfoDTO(children, userExtendEntity,grade,level,device);
|
||||
MqUserInfoDTO userInfoDTO = UserInfoConvert.INSTANCE.toMqUserInfoDTO(children, userExtendEntity, grade, level, device);
|
||||
userInfoDTO.setExperience(CommonUtils.calculatePercentage(userExtendEntity.getExperience(), level.getPoint()));
|
||||
userInfoDTO.setCoinNumber(userCoinAccount.getAvailableBalance().intValue());
|
||||
String userJson = JSONUtil.toJsonStr(userInfoDTO);
|
||||
String topic = ImMqTopicEnum.USER_INFO.getTopic();
|
||||
String tag = UserInfoTopiTagEnum.UPDATE_CHILDREN_INFO.getTag();
|
||||
log.info("发送更新孩子[{}]MQ消息开始 Device: [{}],Topic:{}, Tag:{}",userId,device,topic,tag);
|
||||
mqProducer.sendMsg(topic, tag,device, userJson);
|
||||
log.info("发送更新孩子[{}]MQ消息成功 Device: [{}]",userId,device);
|
||||
log.info("发送更新孩子[{}]MQ消息开始 Device: [{}],Topic:{}, Tag:{}", userId, device, topic, tag);
|
||||
mqProducer.sendMsg(topic, tag, device, userJson);
|
||||
log.info("发送更新孩子[{}]MQ消息成功 Device: [{}]", userId, device);
|
||||
}
|
||||
|
||||
/**
|
||||
* 实际保存用户信息的私有方法
|
||||
*
|
||||
* @param userInfoDTO 用户信息DTO对象
|
||||
* @return 保存后的用户ID
|
||||
*/
|
||||
private int save0(UserInfoDTO userInfoDTO){
|
||||
private int save0(UserInfoDTO userInfoDTO) {
|
||||
UserEntity UserEntity = UserInfoConvert.INSTANCE.convertOne(userInfoDTO);
|
||||
boolean saveOrUpdate = userService.saveOrUpdate(UserEntity);
|
||||
log.info("保存用户信息:{}", saveOrUpdate);
|
||||
|
||||
@ -22,4 +22,11 @@ public class UserRelationServiceApiImpl implements UserRelationServiceApi {
|
||||
UserRelationEntity userRelation = UserRelationConvert.INSTANCE.convertOne(userRelationDTO);
|
||||
return userRelationService.save(userRelation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteUserRelation(UserRelationDTO userRelationDTO) {
|
||||
log.info("删除用户关系:{}", userRelationDTO);
|
||||
UserRelationEntity userRelation = UserRelationConvert.INSTANCE.convertOne(userRelationDTO);
|
||||
return userRelationService.deleteUserRelation(userRelation);
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,4 +117,12 @@ public interface IUserRelationService extends IService<UserRelationEntity> {
|
||||
* @return 用户关系列表
|
||||
*/
|
||||
List<UserRelationEntity> getUserRelationByUserIdAndFamilyId(Integer userId, Integer familyId);
|
||||
|
||||
/**
|
||||
* 删除用户关系
|
||||
*
|
||||
* @param userRelation 用户关系
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteUserRelation(UserRelationEntity userRelation);
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ public interface IUserRoleService extends IService<UserRoleEntity> {
|
||||
* @param userId 角色编号
|
||||
* @param roleIds 角色编号集合
|
||||
*/
|
||||
void assignUserRole(Integer userId, Set<Integer> roleIds);
|
||||
boolean assignUserRole(Integer userId, Set<Integer> roleIds);
|
||||
|
||||
/**
|
||||
* 为用户分配角色
|
||||
@ -48,7 +48,7 @@ public interface IUserRoleService extends IService<UserRoleEntity> {
|
||||
* @param userId 角色编号
|
||||
* @param roleId 角色编号集合
|
||||
*/
|
||||
void assignUserRole(Integer userId, Integer roleId);
|
||||
boolean assignUserRole(Integer userId, Integer roleId);
|
||||
|
||||
/**
|
||||
* 为用户分配角色
|
||||
|
||||
@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -105,4 +106,12 @@ public class UserRelationServiceImpl extends ServiceImpl<UserRelationMapper, Use
|
||||
.eq(UserRelationEntity::getFamilyId, familyId)
|
||||
.eq(UserRelationEntity::getUserId, userId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteUserRelation(UserRelationEntity userRelation) {
|
||||
return super.remove(new LambdaQueryWrapper<>(UserRelationEntity.class)
|
||||
.eq(UserRelationEntity::getUserId, userRelation.getUserId())
|
||||
.eq(UserRelationEntity::getRelationId, userRelation.getRelationId())
|
||||
.eq(Objects.nonNull(userRelation.getType()),UserRelationEntity::getType, userRelation.getType()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,42 +58,38 @@ public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRoleEnt
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assignUserRole(Integer userId, Set<Integer> roleIds) {
|
||||
public boolean assignUserRole(Integer userId, Set<Integer> roleIds) {
|
||||
List<UserRoleEntity> userRoleList = this.getListByUserId(userId);
|
||||
if(CollectionUtils.isEmpty(userRoleList)){
|
||||
List<UserRoleEntity> userRoles = roleIds.stream().map(roleId -> UserRoleEntity.builder().userId(userId).roleId(roleId.intValue()).build()).collect(Collectors.toList());
|
||||
boolean savedBatch = super.saveBatch(userRoles);
|
||||
log.info("分配角色[{}] result:{}", userRoles, savedBatch);
|
||||
return;
|
||||
return savedBatch;
|
||||
}
|
||||
Set<Integer> roleIdSet = userRoleList.stream().map(UserRoleEntity::getRoleId).collect(Collectors.toSet());
|
||||
Collection<Integer> createRoleIds = CollUtil.subtract(roleIds, roleIdSet);
|
||||
Collection<Integer> deleteRoleIds = CollUtil.subtract(roleIdSet, roleIds);
|
||||
if (CollUtil.isNotEmpty(createRoleIds)) {
|
||||
List<UserRoleEntity> userRoles = createRoleIds.stream().map(roleId -> UserRoleEntity.builder().userId(userId).roleId(roleId.intValue()).build()).collect(Collectors.toList());
|
||||
boolean savedBatch = super.saveBatch(userRoles);
|
||||
log.info("新增角色[{}] result:{}", userRoles, savedBatch);
|
||||
return savedBatch;
|
||||
}
|
||||
if (CollUtil.isNotEmpty(deleteRoleIds)) {
|
||||
super.remove(new LambdaQueryWrapper<>(UserRoleEntity.class).eq(UserRoleEntity::getUserId, userId).in(UserRoleEntity::getRoleId, deleteRoleIds));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assignUserRole(Integer userId, Integer roleId) {
|
||||
public boolean assignUserRole(Integer userId, Integer roleId) {
|
||||
Set<Integer> roleIds = new HashSet<>();
|
||||
roleIds.add(roleId);
|
||||
assignUserRole(userId, roleIds);
|
||||
return assignUserRole(userId, roleIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean assignUserRoleByRoleCode(Integer userId, String roleCode) {
|
||||
Optional<RoleEntity> role = roleService.getRoleByCode(roleCode);
|
||||
if(!role.isPresent()){
|
||||
return false;
|
||||
if(role.isPresent()){
|
||||
return assignUserRole(userId, role.get().getId());
|
||||
}
|
||||
assignUserRole(userId, role.get().getId());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user