mirror of https://gitee.com/stylefeng/roses
【7.6.0】【sys】【user】用户列表增加对机构信息的返回
parent
710e03f3f7
commit
c811de7ace
|
@ -25,6 +25,9 @@
|
||||||
package cn.stylefeng.roses.kernel.sys.api;
|
package cn.stylefeng.roses.kernel.sys.api;
|
||||||
|
|
||||||
import cn.stylefeng.roses.kernel.sys.api.pojo.SimpleUserDTO;
|
import cn.stylefeng.roses.kernel.sys.api.pojo.SimpleUserDTO;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.api.pojo.UserOrgDTO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基础核心业务Api
|
* 基础核心业务Api
|
||||||
|
@ -35,12 +38,29 @@ import cn.stylefeng.roses.kernel.sys.api.pojo.SimpleUserDTO;
|
||||||
public interface SysUserServiceApi {
|
public interface SysUserServiceApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户ID获取用户信息
|
* 获取用户的基本信息
|
||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @author fengshuonan
|
||||||
* @author majianguo
|
* @since 2023/6/11 21:07
|
||||||
* @since 2021/1/9 19:00
|
|
||||||
*/
|
*/
|
||||||
SimpleUserDTO getUserInfoByUserId(Long userId);
|
SimpleUserDTO getUserInfoByUserId(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户的主要任职信息
|
||||||
|
* <p>
|
||||||
|
* 返回一条结果,只返回主部门的信息
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2023/6/11 21:07
|
||||||
|
*/
|
||||||
|
UserOrgDTO getUserMainOrgInfo(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户绑定的组织机构列表,主要任职部门和次要任职部门都返回
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2023/6/11 21:08
|
||||||
|
*/
|
||||||
|
List<UserOrgDTO> getUserOrgList(Long userId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户所属组织机构的信息包装
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2023/6/11 21:11
|
||||||
|
*/
|
||||||
|
public class UserOrgFormatProcess extends BaseSimpleFieldFormatProcess {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getItemClass() {
|
||||||
|
return Long.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object simpleItemFormat(Object businessId) {
|
||||||
|
|
||||||
|
if (businessId == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Long userId = Convert.toLong(businessId);
|
||||||
|
|
||||||
|
SysUserServiceApi sysUserServiceApi = SpringUtil.getBean(SysUserServiceApi.class);
|
||||||
|
|
||||||
|
return sysUserServiceApi.getUserMainOrgInfo(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||||
|
*
|
||||||
|
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||||
|
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||||
|
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||||
|
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||||
|
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||||
|
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||||
|
*/
|
||||||
|
package cn.stylefeng.roses.kernel.sys.api.pojo;
|
||||||
|
|
||||||
|
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户信息的简单包装
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2023/6/11 17:05
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UserOrgDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
@ChineseDescription("用户id")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户所属公司id
|
||||||
|
*/
|
||||||
|
@ChineseDescription("用户所属公司id")
|
||||||
|
private Long companyId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户所属公司名称
|
||||||
|
*/
|
||||||
|
@ChineseDescription("用户所属公司名称")
|
||||||
|
private String companyName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户所属部门id
|
||||||
|
*/
|
||||||
|
@ChineseDescription("用户所属部门id")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户所属部门名称
|
||||||
|
*/
|
||||||
|
@ChineseDescription("用户所属部门名称")
|
||||||
|
private String deptName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所属部门的职位id
|
||||||
|
*/
|
||||||
|
@ChineseDescription("所属部门的职位id")
|
||||||
|
private Long positionId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户所属职位名称
|
||||||
|
*/
|
||||||
|
@ChineseDescription("用户所属职位名称")
|
||||||
|
private String positionName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否是主部门:Y-是主部门,N-不是主部门
|
||||||
|
*/
|
||||||
|
@ChineseDescription("是否是主部门:Y-是主部门,N-不是主部门")
|
||||||
|
private String mainFlag;
|
||||||
|
|
||||||
|
}
|
|
@ -2,6 +2,9 @@ package cn.stylefeng.roses.kernel.sys.modular.user.entity;
|
||||||
|
|
||||||
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseExpandFieldEntity;
|
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseExpandFieldEntity;
|
||||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||||
|
import cn.stylefeng.roses.kernel.rule.annotation.EnumFieldFormat;
|
||||||
|
import cn.stylefeng.roses.kernel.rule.enums.SexEnum;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.api.pojo.UserOrgDTO;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
@ -77,6 +80,7 @@ public class SysUser extends BaseExpandFieldEntity {
|
||||||
*/
|
*/
|
||||||
@TableField("sex")
|
@TableField("sex")
|
||||||
@ChineseDescription("性别:M-男,F-女")
|
@ChineseDescription("性别:M-男,F-女")
|
||||||
|
@EnumFieldFormat(processEnum = SexEnum.class)
|
||||||
private String sex;
|
private String sex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,4 +153,15 @@ public class SysUser extends BaseExpandFieldEntity {
|
||||||
@ChineseDescription("对接外部主数据的用户id")
|
@ChineseDescription("对接外部主数据的用户id")
|
||||||
private String masterUserId;
|
private String masterUserId;
|
||||||
|
|
||||||
|
//-------------------------------非实体字段-------------------------------
|
||||||
|
//-------------------------------非实体字段-------------------------------
|
||||||
|
//-------------------------------非实体字段-------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户组织机构详情
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
@ChineseDescription("用户组织机构详情")
|
||||||
|
private UserOrgDTO userOrgDTO;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,9 @@ import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||||
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
||||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.api.SysUserServiceApi;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.api.pojo.SimpleUserDTO;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.api.pojo.UserOrgDTO;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUser;
|
import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUser;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.user.enums.SysUserExceptionEnum;
|
import cn.stylefeng.roses.kernel.sys.modular.user.enums.SysUserExceptionEnum;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.user.mapper.SysUserMapper;
|
import cn.stylefeng.roses.kernel.sys.modular.user.mapper.SysUserMapper;
|
||||||
|
@ -26,7 +29,7 @@ import java.util.List;
|
||||||
* @date 2023/06/10 21:26
|
* @date 2023/06/10 21:26
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {
|
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService, SysUserServiceApi {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(SysUserRequest sysUserRequest) {
|
public void add(SysUserRequest sysUserRequest) {
|
||||||
|
@ -60,8 +63,14 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
// 只查询需要的字段
|
// 只查询需要的字段
|
||||||
wrapper.select(SysUser::getUserId, SysUser::getRealName, SysUser::getAccount, SysUser::getSex, SysUser::getStatusFlag, BaseEntity::getCreateTime);
|
wrapper.select(SysUser::getUserId, SysUser::getRealName, SysUser::getAccount, SysUser::getSex, SysUser::getStatusFlag, BaseEntity::getCreateTime);
|
||||||
|
|
||||||
Page<SysUser> sysRolePage = this.page(PageFactory.defaultPage(), wrapper);
|
Page<SysUser> sysUserPage = this.page(PageFactory.defaultPage(), wrapper);
|
||||||
return PageResultFactory.createPageResult(sysRolePage);
|
|
||||||
|
// 遍历查询结果,增加对用户部门信息的返回
|
||||||
|
for (SysUser record : sysUserPage.getRecords()) {
|
||||||
|
record.setUserOrgDTO(this.getUserMainOrgInfo(record.getUserId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return PageResultFactory.createPageResult(sysUserPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -70,6 +79,21 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
return this.list(wrapper);
|
return this.list(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SimpleUserDTO getUserInfoByUserId(Long userId) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserOrgDTO getUserMainOrgInfo(Long userId) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<UserOrgDTO> getUserOrgList(Long userId) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取信息
|
* 获取信息
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue