mirror of https://gitee.com/stylefeng/roses
【7.6.0】【sys】整理,用户组织机构关系应单独存放api,并且由SysUserOrgService实现
parent
0d0954f75f
commit
f469529717
|
@ -0,0 +1,23 @@
|
|||
package cn.stylefeng.roses.kernel.sys.api;
|
||||
|
||||
import cn.stylefeng.roses.kernel.sys.api.pojo.user.UserOrgDTO;
|
||||
|
||||
/**
|
||||
* 单独编写用户和组织机构关系的Api
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/6/18 23:14
|
||||
*/
|
||||
public interface SysUserOrgServiceApi {
|
||||
|
||||
/**
|
||||
* 获取用户的主要任职信息
|
||||
* <p>
|
||||
* 返回一条结果,只返回主部门的信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/6/11 21:07
|
||||
*/
|
||||
UserOrgDTO getUserMainOrgInfo(Long userId);
|
||||
|
||||
}
|
|
@ -46,16 +46,6 @@ public interface SysUserServiceApi {
|
|||
*/
|
||||
SimpleUserDTO getUserInfoByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 获取用户的主要任职信息
|
||||
* <p>
|
||||
* 返回一条结果,只返回主部门的信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/6/11 21:07
|
||||
*/
|
||||
UserOrgDTO getUserMainOrgInfo(Long userId);
|
||||
|
||||
/**
|
||||
* 获取用户绑定的组织机构列表,主要任职部门和次要任职部门都返回
|
||||
*
|
||||
|
|
|
@ -3,7 +3,7 @@ package cn.stylefeng.roses.kernel.sys.api.format;
|
|||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.stylefeng.roses.kernel.rule.format.BaseSimpleFieldFormatProcess;
|
||||
import cn.stylefeng.roses.kernel.sys.api.SysUserServiceApi;
|
||||
import cn.stylefeng.roses.kernel.sys.api.SysUserOrgServiceApi;
|
||||
|
||||
/**
|
||||
* 用户所属组织机构的信息包装
|
||||
|
@ -27,9 +27,9 @@ public class UserOrgFormatProcess extends BaseSimpleFieldFormatProcess {
|
|||
|
||||
Long userId = Convert.toLong(businessId);
|
||||
|
||||
SysUserServiceApi sysUserServiceApi = SpringUtil.getBean(SysUserServiceApi.class);
|
||||
SysUserOrgServiceApi sysUserOrgServiceApi = SpringUtil.getBean(SysUserOrgServiceApi.class);
|
||||
|
||||
return sysUserServiceApi.getUserMainOrgInfo(userId);
|
||||
return sysUserOrgServiceApi.getUserMainOrgInfo(userId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import cn.stylefeng.roses.kernel.file.api.FileInfoApi;
|
|||
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import cn.stylefeng.roses.kernel.sys.api.SysUserServiceApi;
|
||||
import cn.stylefeng.roses.kernel.sys.api.exception.SysException;
|
||||
import cn.stylefeng.roses.kernel.sys.api.pojo.user.SimpleUserDTO;
|
||||
import cn.stylefeng.roses.kernel.sys.api.pojo.user.UserOrgDTO;
|
||||
import cn.stylefeng.roses.kernel.sys.api.pojo.user.UserValidateDTO;
|
||||
|
@ -29,8 +28,6 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.stylefeng.roses.kernel.sys.modular.user.enums.SysUserOrgExceptionEnum.MAIN_FLAG_COUNT_ERROR;
|
||||
|
||||
/**
|
||||
* 用户相关的综合业务
|
||||
*
|
||||
|
@ -87,26 +84,6 @@ public class UserIntegrationService implements SysUserServiceApi {
|
|||
return simpleUserDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserOrgDTO getUserMainOrgInfo(Long userId) {
|
||||
|
||||
if (userId == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<SysUserOrg> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysUserOrg::getUserId, userId);
|
||||
queryWrapper.eq(SysUserOrg::getMainFlag, YesOrNotEnum.Y.getCode());
|
||||
List<SysUserOrg> sysUserOrgList = sysUserOrgService.list(queryWrapper);
|
||||
if (sysUserOrgList.size() > 1) {
|
||||
throw new SysException(MAIN_FLAG_COUNT_ERROR, userId);
|
||||
}
|
||||
|
||||
// 获取到用户的主部门信息
|
||||
SysUserOrg sysUserOrg = sysUserOrgList.get(0);
|
||||
return UserOrgFactory.createUserOrgDetailInfo(sysUserOrg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserOrgDTO> getUserOrgList(Long userId) {
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.user.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.sys.api.SysUserOrgServiceApi;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUserOrg;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.pojo.request.SysUserOrgRequest;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
@ -13,7 +14,7 @@ import java.util.List;
|
|||
* @author fengshuonan
|
||||
* @date 2023/06/10 21:26
|
||||
*/
|
||||
public interface SysUserOrgService extends IService<SysUserOrg> {
|
||||
public interface SysUserOrgService extends IService<SysUserOrg>, SysUserOrgServiceApi {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
|
|
|
@ -9,9 +9,12 @@ import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
|||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import cn.stylefeng.roses.kernel.sys.api.callback.RemoveOrgCallbackApi;
|
||||
import cn.stylefeng.roses.kernel.sys.api.callback.RemoveUserCallbackApi;
|
||||
import cn.stylefeng.roses.kernel.sys.api.exception.SysException;
|
||||
import cn.stylefeng.roses.kernel.sys.api.exception.enums.OrgExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.sys.api.pojo.user.UserOrgDTO;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUserOrg;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.enums.SysUserOrgExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.factory.UserOrgFactory;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.mapper.SysUserOrgMapper;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.pojo.request.SysUserOrgRequest;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.service.SysUserOrgService;
|
||||
|
@ -24,6 +27,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.stylefeng.roses.kernel.sys.modular.user.enums.SysUserOrgExceptionEnum.MAIN_FLAG_COUNT_ERROR;
|
||||
|
||||
/**
|
||||
* 用户组织机构关联业务实现层
|
||||
*
|
||||
|
@ -116,6 +121,26 @@ public class SysUserOrgServiceImpl extends ServiceImpl<SysUserOrgMapper, SysUser
|
|||
this.remove(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserOrgDTO getUserMainOrgInfo(Long userId) {
|
||||
|
||||
if (userId == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<SysUserOrg> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysUserOrg::getUserId, userId);
|
||||
queryWrapper.eq(SysUserOrg::getMainFlag, YesOrNotEnum.Y.getCode());
|
||||
List<SysUserOrg> sysUserOrgList = this.list(queryWrapper);
|
||||
if (sysUserOrgList.size() > 1) {
|
||||
throw new SysException(MAIN_FLAG_COUNT_ERROR, userId);
|
||||
}
|
||||
|
||||
// 获取到用户的主部门信息
|
||||
SysUserOrg sysUserOrg = sysUserOrgList.get(0);
|
||||
return UserOrgFactory.createUserOrgDetailInfo(sysUserOrg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取信息
|
||||
*
|
||||
|
|
|
@ -152,7 +152,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
|
||||
// 遍历查询结果,增加对用户部门信息的返回
|
||||
for (SysUser record : sysUserPage.getRecords()) {
|
||||
record.setUserOrgDTO(sysUserServiceApi.getUserMainOrgInfo(record.getUserId()));
|
||||
record.setUserOrgDTO(sysUserOrgService.getUserMainOrgInfo(record.getUserId()));
|
||||
}
|
||||
|
||||
return PageResultFactory.createPageResult(sysUserPage);
|
||||
|
|
Loading…
Reference in New Issue