【7.2.3】更新分组管理的业务

pull/30/head
fengshuonan 2022-06-29 17:00:34 +08:00
parent ae613ef0b0
commit bf109ea6d8
8 changed files with 97 additions and 40 deletions

View File

@ -24,6 +24,11 @@
*/ */
package cn.stylefeng.roses.kernel.group.api; package cn.stylefeng.roses.kernel.group.api;
import cn.stylefeng.roses.kernel.group.api.pojo.SysGroupDTO;
import cn.stylefeng.roses.kernel.group.api.pojo.SysGroupRequest;
import java.util.List;
/** /**
* Api * Api
* *
@ -32,5 +37,20 @@ package cn.stylefeng.roses.kernel.group.api;
*/ */
public interface GroupApi { public interface GroupApi {
/**
* id
*
* @author fengshuonan
* @date 2022/5/11 17:00
*/
List<Long> findUserGroupDataList(SysGroupRequest sysGroupRequest);
/**
*
*
* @author fengshuonan
* @date 2022/5/11 17:00
*/
List<SysGroupDTO> findGroupList(SysGroupRequest sysGroupRequest);
} }

View File

@ -0,0 +1,45 @@
package cn.stylefeng.roses.kernel.group.api.pojo;
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
import lombok.Data;
/**
*
*
* @author fengshuonan
* @date 2022/05/11 12:54
*/
@Data
public class SysGroupDTO {
/**
* id
*/
@ChineseDescription("分组id")
private Long groupId;
/**
*
*/
@ChineseDescription("所属业务编码")
private String groupBizCode;
/**
*
*/
@ChineseDescription("分组名称")
private String groupName;
/**
* id
*/
@ChineseDescription("业务主键id")
private Long businessId;
/**
* id
*/
@ChineseDescription("用户id")
private Long userId;
}

View File

@ -1,4 +1,4 @@
package cn.stylefeng.roses.kernel.group.modular.pojo; package cn.stylefeng.roses.kernel.group.api.pojo;
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription; import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest; import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;

View File

@ -1,7 +1,8 @@
package cn.stylefeng.roses.kernel.group.modular.controller; package cn.stylefeng.roses.kernel.group.modular.controller;
import cn.stylefeng.roses.kernel.group.modular.entity.SysGroup; import cn.stylefeng.roses.kernel.group.api.GroupApi;
import cn.stylefeng.roses.kernel.group.modular.pojo.SysGroupRequest; import cn.stylefeng.roses.kernel.group.api.pojo.SysGroupDTO;
import cn.stylefeng.roses.kernel.group.api.pojo.SysGroupRequest;
import cn.stylefeng.roses.kernel.group.modular.service.SysGroupService; import cn.stylefeng.roses.kernel.group.modular.service.SysGroupService;
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest; import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData; import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
@ -29,6 +30,9 @@ public class SysGroupController {
@Resource @Resource
private SysGroupService sysGroupService; private SysGroupService sysGroupService;
@Resource
private GroupApi groupApi;
/** /**
* *
* *
@ -36,8 +40,8 @@ public class SysGroupController {
* @date 2022/05/11 12:54 * @date 2022/05/11 12:54
*/ */
@GetResource(name = "获取列表", path = "/sysGroup/list") @GetResource(name = "获取列表", path = "/sysGroup/list")
public ResponseData<List<SysGroup>> list(@Validated(BaseRequest.list.class) SysGroupRequest sysGroupRequest) { public ResponseData<List<SysGroupDTO>> list(@Validated(BaseRequest.list.class) SysGroupRequest sysGroupRequest) {
return new SuccessResponseData<>(sysGroupService.findGroupList(sysGroupRequest)); return new SuccessResponseData<>(groupApi.findGroupList(sysGroupRequest));
} }
/** /**
@ -47,7 +51,7 @@ public class SysGroupController {
* @date 2022/05/11 12:54 * @date 2022/05/11 12:54
*/ */
@GetResource(name = "添加分组时候的选择列表", path = "/sysGroup/addSelect") @GetResource(name = "添加分组时候的选择列表", path = "/sysGroup/addSelect")
public ResponseData<List<SysGroup>> addSelect(@Validated(BaseRequest.list.class) SysGroupRequest sysGroupRequest) { public ResponseData<List<SysGroupDTO>> addSelect(@Validated(BaseRequest.list.class) SysGroupRequest sysGroupRequest) {
return new SuccessResponseData<>(sysGroupService.addSelect(sysGroupRequest)); return new SuccessResponseData<>(sysGroupService.addSelect(sysGroupRequest));
} }
@ -58,7 +62,7 @@ public class SysGroupController {
* @date 2022/05/11 12:54 * @date 2022/05/11 12:54
*/ */
@PostResource(name = "添加", path = "/sysGroup/add") @PostResource(name = "添加", path = "/sysGroup/add")
public ResponseData<SysGroup> add(@RequestBody @Validated(SysGroupRequest.add.class) SysGroupRequest sysGroupRequest) { public ResponseData<?> add(@RequestBody @Validated(SysGroupRequest.add.class) SysGroupRequest sysGroupRequest) {
sysGroupService.add(sysGroupRequest); sysGroupService.add(sysGroupRequest);
return new SuccessResponseData<>(); return new SuccessResponseData<>();
} }

View File

@ -1,5 +1,6 @@
package cn.stylefeng.roses.kernel.group.modular.mapper; package cn.stylefeng.roses.kernel.group.modular.mapper;
import cn.stylefeng.roses.kernel.group.api.pojo.SysGroupDTO;
import cn.stylefeng.roses.kernel.group.modular.entity.SysGroup; import cn.stylefeng.roses.kernel.group.modular.entity.SysGroup;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -20,6 +21,6 @@ public interface SysGroupMapper extends BaseMapper<SysGroup> {
* @author fengshuonan * @author fengshuonan
* @date 2022/5/11 16:49 * @date 2022/5/11 16:49
*/ */
List<SysGroup> getUserGroupList(@Param("groupBizCode") String groupBizCode, @Param("userId") Long userId); List<SysGroupDTO> getUserGroupList(@Param("groupBizCode") String groupBizCode, @Param("userId") Long userId);
} }

View File

@ -2,8 +2,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.stylefeng.roses.kernel.group.modular.mapper.SysGroupMapper"> <mapper namespace="cn.stylefeng.roses.kernel.group.modular.mapper.SysGroupMapper">
<select id="getUserGroupList" resultType="cn.stylefeng.roses.kernel.group.modular.entity.SysGroup"> <select id="getUserGroupList" resultType="cn.stylefeng.roses.kernel.group.api.pojo.SysGroupDTO">
select group_name select group_name, group_id, group_biz_code, business_id, user_id
from sys_group from sys_group
where user_id = #{userId} where user_id = #{userId}
and group_biz_code = #{groupBizCode} and group_biz_code = #{groupBizCode}

View File

@ -1,7 +1,8 @@
package cn.stylefeng.roses.kernel.group.modular.service; package cn.stylefeng.roses.kernel.group.modular.service;
import cn.stylefeng.roses.kernel.group.api.pojo.SysGroupDTO;
import cn.stylefeng.roses.kernel.group.api.pojo.SysGroupRequest;
import cn.stylefeng.roses.kernel.group.modular.entity.SysGroup; import cn.stylefeng.roses.kernel.group.modular.entity.SysGroup;
import cn.stylefeng.roses.kernel.group.modular.pojo.SysGroupRequest;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List; import java.util.List;
@ -14,21 +15,13 @@ import java.util.List;
*/ */
public interface SysGroupService extends IService<SysGroup> { public interface SysGroupService extends IService<SysGroup> {
/**
*
*
* @author fengshuonan
* @date 2022/5/11 17:00
*/
List<SysGroup> findGroupList(SysGroupRequest sysGroupRequest);
/** /**
* *
* *
* @author fengshuonan * @author fengshuonan
* @date 2022/5/11 17:00 * @date 2022/5/11 17:00
*/ */
List<SysGroup> addSelect(SysGroupRequest sysGroupRequest); List<SysGroupDTO> addSelect(SysGroupRequest sysGroupRequest);
/** /**
* *
@ -48,12 +41,4 @@ public interface SysGroupService extends IService<SysGroup> {
*/ */
void del(SysGroupRequest sysGroupRequest); void del(SysGroupRequest sysGroupRequest);
/**
* id
*
* @author fengshuonan
* @date 2022/5/11 17:00
*/
List<Long> findUserGroupDataList(SysGroupRequest sysGroupRequest);
} }

View File

@ -2,10 +2,12 @@ package cn.stylefeng.roses.kernel.group.modular.service.impl;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext; import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
import cn.stylefeng.roses.kernel.group.api.GroupApi;
import cn.stylefeng.roses.kernel.group.api.constants.GroupConstants; import cn.stylefeng.roses.kernel.group.api.constants.GroupConstants;
import cn.stylefeng.roses.kernel.group.api.pojo.SysGroupDTO;
import cn.stylefeng.roses.kernel.group.api.pojo.SysGroupRequest;
import cn.stylefeng.roses.kernel.group.modular.entity.SysGroup; import cn.stylefeng.roses.kernel.group.modular.entity.SysGroup;
import cn.stylefeng.roses.kernel.group.modular.mapper.SysGroupMapper; import cn.stylefeng.roses.kernel.group.modular.mapper.SysGroupMapper;
import cn.stylefeng.roses.kernel.group.modular.pojo.SysGroupRequest;
import cn.stylefeng.roses.kernel.group.modular.service.SysGroupService; import cn.stylefeng.roses.kernel.group.modular.service.SysGroupService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@ -23,13 +25,13 @@ import java.util.stream.Collectors;
* @date 2022/05/11 12:54 * @date 2022/05/11 12:54
*/ */
@Service @Service
public class SysGroupServiceImpl extends ServiceImpl<SysGroupMapper, SysGroup> implements SysGroupService { public class SysGroupServiceImpl extends ServiceImpl<SysGroupMapper, SysGroup> implements SysGroupService, GroupApi {
@Override @Override
public List<SysGroup> findGroupList(SysGroupRequest sysGroupRequest) { public List<SysGroupDTO> findGroupList(SysGroupRequest sysGroupRequest) {
String groupBizCode = sysGroupRequest.getGroupBizCode(); String groupBizCode = sysGroupRequest.getGroupBizCode();
Long userId = LoginContext.me().getLoginUser().getUserId(); Long userId = LoginContext.me().getLoginUser().getUserId();
List<SysGroup> userGroupList = this.baseMapper.getUserGroupList(groupBizCode, userId); List<SysGroupDTO> userGroupList = this.baseMapper.getUserGroupList(groupBizCode, userId);
// 增加两个固定的选中和取消选项 // 增加两个固定的选中和取消选项
addAllGroup(groupBizCode, userGroupList); addAllGroup(groupBizCode, userGroupList);
@ -38,10 +40,10 @@ public class SysGroupServiceImpl extends ServiceImpl<SysGroupMapper, SysGroup> i
} }
@Override @Override
public List<SysGroup> addSelect(SysGroupRequest sysGroupRequest) { public List<SysGroupDTO> addSelect(SysGroupRequest sysGroupRequest) {
String groupBizCode = sysGroupRequest.getGroupBizCode(); String groupBizCode = sysGroupRequest.getGroupBizCode();
Long userId = LoginContext.me().getLoginUser().getUserId(); Long userId = LoginContext.me().getLoginUser().getUserId();
List<SysGroup> userGroupList = this.baseMapper.getUserGroupList(groupBizCode, userId); List<SysGroupDTO> userGroupList = this.baseMapper.getUserGroupList(groupBizCode, userId);
// 增加两个固定的选中和取消选项 // 增加两个固定的选中和取消选项
addCommonGroup(groupBizCode, userGroupList); addCommonGroup(groupBizCode, userGroupList);
@ -114,15 +116,15 @@ public class SysGroupServiceImpl extends ServiceImpl<SysGroupMapper, SysGroup> i
* @author fengshuonan * @author fengshuonan
* @date 2022/6/28 10:50 * @date 2022/6/28 10:50
*/ */
private void addCommonGroup(String groupBizCode, List<SysGroup> result) { private void addCommonGroup(String groupBizCode, List<SysGroupDTO> result) {
// 添加分组 // 添加分组
SysGroup addGroup = new SysGroup(); SysGroupDTO addGroup = new SysGroupDTO();
addGroup.setGroupBizCode(groupBizCode); addGroup.setGroupBizCode(groupBizCode);
addGroup.setGroupName(GroupConstants.GROUP_ADD_NAME); addGroup.setGroupName(GroupConstants.GROUP_ADD_NAME);
// 未分组 // 未分组
SysGroup noneGroup = new SysGroup(); SysGroupDTO noneGroup = new SysGroupDTO();
noneGroup.setGroupBizCode(groupBizCode); noneGroup.setGroupBizCode(groupBizCode);
noneGroup.setGroupName(GroupConstants.GROUP_DELETE_NAME); noneGroup.setGroupName(GroupConstants.GROUP_DELETE_NAME);
@ -136,15 +138,15 @@ public class SysGroupServiceImpl extends ServiceImpl<SysGroupMapper, SysGroup> i
* @author fengshuonan * @author fengshuonan
* @date 2022/6/28 10:50 * @date 2022/6/28 10:50
*/ */
private void addAllGroup(String groupBizCode, List<SysGroup> result) { private void addAllGroup(String groupBizCode, List<SysGroupDTO> result) {
// 添加分组 // 添加分组
SysGroup addGroup = new SysGroup(); SysGroupDTO addGroup = new SysGroupDTO();
addGroup.setGroupBizCode(groupBizCode); addGroup.setGroupBizCode(groupBizCode);
addGroup.setGroupName(GroupConstants.ALL_GROUP_NAME); addGroup.setGroupName(GroupConstants.ALL_GROUP_NAME);
// 未分组 // 未分组
SysGroup noneGroup = new SysGroup(); SysGroupDTO noneGroup = new SysGroupDTO();
noneGroup.setGroupBizCode(groupBizCode); noneGroup.setGroupBizCode(groupBizCode);
noneGroup.setGroupName(GroupConstants.GROUP_DELETE_NAME); noneGroup.setGroupName(GroupConstants.GROUP_DELETE_NAME);