mirror of https://gitee.com/stylefeng/roses
【8.0】【group】更新group业务
parent
71a37d8df3
commit
7070b59a1c
|
@ -1,11 +1,7 @@
|
|||
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 com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 业务分组 Mapper 接口
|
||||
|
@ -15,12 +11,5 @@ import java.util.List;
|
|||
*/
|
||||
public interface SysGroupMapper extends BaseMapper<SysGroup> {
|
||||
|
||||
/**
|
||||
* 获取用户分组列表
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2022/5/11 16:49
|
||||
*/
|
||||
List<SysGroupDTO> getUserGroupList(@Param("groupBizCode") String groupBizCode, @Param("userId") Long userId, @Param("getTotal") boolean getTotal);
|
||||
|
||||
}
|
||||
|
|
|
@ -2,14 +2,4 @@
|
|||
<!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">
|
||||
|
||||
<select id="getUserGroupList" resultType="cn.stylefeng.roses.kernel.group.api.pojo.SysGroupDTO">
|
||||
select group_name, group_id, group_biz_code, business_id, user_id
|
||||
from sys_group
|
||||
where user_id = #{userId}
|
||||
and group_biz_code = #{groupBizCode}
|
||||
<if test="getTotal != null and getTotal == false">
|
||||
group by group_name
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cn.stylefeng.roses.kernel.group.modular.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
|
||||
|
@ -31,26 +32,44 @@ public class SysGroupServiceImpl extends ServiceImpl<SysGroupMapper, SysGroup> i
|
|||
|
||||
@Override
|
||||
public List<SysGroupDTO> findGroupList(SysGroupRequest sysGroupRequest, boolean getTotal) {
|
||||
|
||||
// 定义返回结果
|
||||
List<SysGroupDTO> sysGroupDTOS = new ArrayList<>();
|
||||
|
||||
String groupBizCode = sysGroupRequest.getGroupBizCode();
|
||||
Long userId = LoginContext.me().getLoginUser().getUserId();
|
||||
List<SysGroupDTO> userGroupList = this.baseMapper.getUserGroupList(groupBizCode, userId, getTotal);
|
||||
|
||||
LambdaQueryWrapper<SysGroup> wrapper = this.createWrapper(groupBizCode, userId, getTotal);
|
||||
List<SysGroup> list = this.list(wrapper);
|
||||
if (ObjectUtil.isNotEmpty(list)) {
|
||||
sysGroupDTOS = BeanUtil.copyToList(list, SysGroupDTO.class);
|
||||
}
|
||||
|
||||
// 增加两个固定的选中和取消选项
|
||||
addAllGroup(groupBizCode, userGroupList);
|
||||
addAllGroup(groupBizCode, sysGroupDTOS);
|
||||
|
||||
return userGroupList;
|
||||
return sysGroupDTOS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysGroupDTO> addSelect(SysGroupRequest sysGroupRequest) {
|
||||
|
||||
// 定义返回结果
|
||||
List<SysGroupDTO> sysGroupDTOS = new ArrayList<>();
|
||||
|
||||
String groupBizCode = sysGroupRequest.getGroupBizCode();
|
||||
Long userId = LoginContext.me().getLoginUser().getUserId();
|
||||
List<SysGroupDTO> userGroupList = this.baseMapper.getUserGroupList(groupBizCode, userId, false);
|
||||
|
||||
LambdaQueryWrapper<SysGroup> wrapper = this.createWrapper(groupBizCode, userId, false);
|
||||
List<SysGroup> list = this.list(wrapper);
|
||||
if (ObjectUtil.isNotEmpty(list)) {
|
||||
sysGroupDTOS = BeanUtil.copyToList(list, SysGroupDTO.class);
|
||||
}
|
||||
|
||||
// 增加两个固定的选中和取消选项
|
||||
addCommonGroup(groupBizCode, userGroupList);
|
||||
addCommonGroup(groupBizCode, sysGroupDTOS);
|
||||
|
||||
return userGroupList;
|
||||
return sysGroupDTOS;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -102,7 +121,8 @@ public class SysGroupServiceImpl extends ServiceImpl<SysGroupMapper, SysGroup> i
|
|||
LambdaQueryWrapper<SysGroup> sysGroupLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sysGroupLambdaQueryWrapper.eq(SysGroup::getUserId, userId);
|
||||
sysGroupLambdaQueryWrapper.eq(SysGroup::getGroupBizCode, sysGroupRequest.getGroupBizCode());
|
||||
sysGroupLambdaQueryWrapper.eq(StrUtil.isNotBlank(sysGroupRequest.getGroupName()), SysGroup::getGroupName, sysGroupRequest.getGroupName());
|
||||
sysGroupLambdaQueryWrapper.eq(StrUtil.isNotBlank(sysGroupRequest.getGroupName()), SysGroup::getGroupName,
|
||||
sysGroupRequest.getGroupName());
|
||||
|
||||
List<SysGroup> list = this.list(sysGroupLambdaQueryWrapper);
|
||||
if (list == null || list.size() == 0) {
|
||||
|
@ -221,4 +241,26 @@ public class SysGroupServiceImpl extends ServiceImpl<SysGroupMapper, SysGroup> i
|
|||
result.add(0, addGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建通用wrapper
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/7/11 16:23
|
||||
*/
|
||||
private LambdaQueryWrapper<SysGroup> createWrapper(String groupBizCode, Long userId, Boolean getTotal) {
|
||||
|
||||
LambdaQueryWrapper<SysGroup> sysGroupLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sysGroupLambdaQueryWrapper.eq(SysGroup::getGroupBizCode, groupBizCode);
|
||||
sysGroupLambdaQueryWrapper.eq(SysGroup::getUserId, userId);
|
||||
|
||||
if (getTotal != null && !getTotal) {
|
||||
sysGroupLambdaQueryWrapper.groupBy(SysGroup::getGroupName);
|
||||
}
|
||||
|
||||
sysGroupLambdaQueryWrapper.select(SysGroup::getGroupName, SysGroup::getGroupId, SysGroup::getGroupBizCode, SysGroup::getBusinessId,
|
||||
SysGroup::getUserId);
|
||||
|
||||
return sysGroupLambdaQueryWrapper;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue