【修改】修改部门负责人,从 String 字符串,调整成和后台用户的用户编号绑定

pull/2/head
YunaiV 2022-01-14 01:04:44 +08:00
parent 2809254a07
commit 33ab2e9633
12 changed files with 112 additions and 19 deletions

View File

@ -1,5 +1,7 @@
package cn.iocoder.yudao.adminserver.modules.system.controller.dept.vo.dept;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -28,8 +30,8 @@ public class SysDeptBaseVO {
@NotNull(message = "显示顺序不能为空")
private Integer sort;
@ApiModelProperty(value = "负责人", example = "芋道")
private String leader;
@ApiModelProperty(value = "负责人的用户编号", example = "2048")
private Long leaderUserId;
@ApiModelProperty(value = "联系电话", example = "15601691000")
@Size(max = 11, message = "联系电话长度不能超过11个字符")
@ -42,7 +44,7 @@ public class SysDeptBaseVO {
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 SysCommonStatusEnum 枚举")
@NotNull(message = "状态不能为空")
// @InEnum(value = SysCommonStatusEnum.class, message = "修改状态必须是 {value}")
// @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
private Integer status;
}

View File

@ -1,7 +1,10 @@
package cn.iocoder.yudao.adminserver.modules.system.controller.user;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.adminserver.modules.system.controller.dept.vo.dept.SysDeptListReqVO;
import cn.iocoder.yudao.adminserver.modules.system.controller.dept.vo.dept.SysDeptSimpleRespVO;
import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user.*;
import cn.iocoder.yudao.adminserver.modules.system.convert.dept.SysDeptConvert;
import cn.iocoder.yudao.adminserver.modules.system.convert.user.SysUserConvert;
import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO;
import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysDeptService;
@ -32,6 +35,8 @@ import java.io.IOException;
import java.util.*;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
@Api(tags = "用户")
@ -99,7 +104,7 @@ public class SysUserController {
}
// 获得拼接需要的数据
Collection<Long> deptIds = CollectionUtils.convertList(pageResult.getList(), SysUserDO::getDeptId);
Collection<Long> deptIds = convertList(pageResult.getList(), SysUserDO::getDeptId);
Map<Long, SysDeptDO> deptMap = deptService.getDeptMap(deptIds);
// 拼接结果返回
List<SysUserPageItemRespVO> userList = new ArrayList<>(pageResult.getList().size());
@ -111,6 +116,15 @@ public class SysUserController {
return success(new PageResult<>(userList, pageResult.getTotal()));
}
@GetMapping("/list-all-simple")
@ApiOperation(value = "获取用户精简信息列表", notes = "只包含被开启的用户,主要用于前端的下拉选项")
public CommonResult<List<SysUserSimpleRespVO>> getSimpleUsers() {
// 获用户门列表,只要开启状态的
List<SysUserDO> list = userService.getUsersByStatus(CommonStatusEnum.ENABLE.getStatus());
// 排序后,返回给前端
return success(SysUserConvert.INSTANCE.convertList04(list));
}
@GetMapping("/get")
@ApiOperation("获得用户详情")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@ -129,15 +143,19 @@ public class SysUserController {
List<SysUserDO> users = userService.getUsers(reqVO);
// 获得拼接需要的数据
Collection<Long> deptIds = CollectionUtils.convertList(users, SysUserDO::getDeptId);
Collection<Long> deptIds = convertList(users, SysUserDO::getDeptId);
Map<Long, SysDeptDO> deptMap = deptService.getDeptMap(deptIds);
Map<Long, SysUserDO> deptLeaderUserMap = userService.getUserMap(convertSet(deptMap.values(), SysDeptDO::getLeaderUserId));
// 拼接数据
List<SysUserExcelVO> excelUsers = new ArrayList<>(users.size());
users.forEach(user -> {
SysUserExcelVO excelVO = SysUserConvert.INSTANCE.convert02(user);
// 设置部门
MapUtils.findAndThen(deptMap, user.getDeptId(), dept -> {
excelVO.setDeptName(dept.getName());
excelVO.setDeptLeader(dept.getLeader());
// 设置部门负责人的名字
MapUtils.findAndThen(deptLeaderUserMap, dept.getLeaderUserId(),
deptLeaderUser -> excelVO.setDeptLeaderNickname(deptLeaderUser.getNickname()));
});
excelUsers.add(excelVO);
});

View File

@ -47,6 +47,6 @@ public class SysUserExcelVO {
private String deptName;
@ExcelProperty("部门负责人")
private String deptLeader;
private String deptLeaderNickname;
}

View File

@ -0,0 +1,21 @@
package cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@ApiModel("用户精简信息 Response VO")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SysUserSimpleRespVO {
@ApiModelProperty(value = "用户编号", required = true, example = "1024")
private Long id;
@ApiModelProperty(value = "用户昵称", required = true, example = "芋道")
private String nickname;
}

View File

@ -45,4 +45,5 @@ public interface SysUserConvert {
List<SysUserProfileRespVO.SocialUser> convertList03(List<SysSocialUserDO> list);
List<SysUserSimpleRespVO> convertList04(List<SysUserDO> list);
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept;
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import com.baomidou.mybatisplus.annotation.TableId;
@ -38,8 +39,10 @@ public class SysDeptDO extends TenantBaseDO {
private Integer sort;
/**
*
*
* {@link SysUserDO#getId()}
*/
private String leader;
private Long leaderUserId;
/**
*
*/

View File

@ -55,7 +55,7 @@ public interface SysUserMapper extends BaseMapperX<SysUserDO> {
return selectList(new QueryWrapperX<SysUserDO>().like("username", username));
}
// TODO 芋艿:可废弃该方法
default List<SysUserDO> selectListByDepartIdAndPostId(Long departId, Long postId) {
return selectList(new QueryWrapperX<SysUserDO>()
.eq("status", CommonStatusEnum.ENABLE.getStatus())
@ -64,5 +64,9 @@ public interface SysUserMapper extends BaseMapperX<SysUserDO> {
.likeIfPresent("post_ids", Optional.ofNullable(postId).map(t -> String.valueOf(postId)).orElse("")));
}
default List<SysUserDO> selectListByStatus(Integer status) {
return selectList("status", status);
}
}

View File

@ -169,4 +169,12 @@ public interface SysUserService {
*/
SysUserImportRespVO importUsers(List<SysUserImportExcelVO> importUsers, boolean isUpdateSupport);
/**
*
*
* @param status
* @return
*/
List<SysUserDO> getUsersByStatus(Integer status);
}

View File

@ -379,4 +379,9 @@ public class SysUserServiceImpl implements SysUserService {
return respVO;
}
@Override
public List<SysUserDO> getUsersByStatus(Integer status) {
return userMapper.selectListByStatus(status);
}
}

View File

@ -10,6 +10,14 @@ export function listUser(query) {
})
}
// 获取用户精简信息列表
export function listSimpleUsers() {
return request({
url: '/system/user/list-all-simple',
method: 'get'
})
}
// 查询用户详细
export function getUser(userId) {
return request({

View File

@ -25,8 +25,9 @@
<el-table v-loading="loading" :data="deptList" row-key="id" default-expand-all
:tree-props="{children: 'children', hasChildren: 'hasChildren'}">
<el-table-column prop="name" label="部门名称" width="260"></el-table-column>
<el-table-column prop="status" label="负责人" :formatter="userNicknameFormat" width="120"/>
<el-table-column prop="sort" label="排序" width="200"></el-table-column>
<el-table-column prop="status" label="状态" :formatter="statusFormat" width="100"></el-table-column>
<el-table-column prop="status" label="状态" :formatter="statusFormat" width="100"/>
<el-table-column label="创建时间" align="center" prop="createTime" width="200">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
@ -64,8 +65,10 @@
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="负责人" prop="leader">
<el-input v-model="form.leader" placeholder="请输入负责人" maxlength="20" />
<el-form-item label="负责人" prop="leaderUserId">
<el-select v-model="form.leaderUserId" placeholder="请输入负责人" clearable style="width: 100%">
<el-option v-for="item in users" :key="parseInt(item.id)" :label="item.nickname" :value="parseInt(item.id)" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
@ -103,6 +106,7 @@ import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import {SysCommonStatusEnum} from '@/utils/constants'
import { getDictDataLabel, getDictDatas, DICT_TYPE } from '@/utils/dict'
import {listSimpleUsers} from "@/api/system/user";
export default {
name: "Dept",
@ -117,6 +121,8 @@ export default {
deptList: [],
//
deptOptions: [],
//
users: [],
//
title: "",
//
@ -168,6 +174,10 @@ export default {
},
created() {
this.getList();
//
listSimpleUsers().then(response => {
this.users = response.data;
});
},
methods: {
/** 查询部门列表 */
@ -193,6 +203,18 @@ export default {
statusFormat(row, column) {
return getDictDataLabel(DICT_TYPE.SYS_COMMON_STATUS, row.status)
},
//
userNicknameFormat(row, column) {
if (!row.leaderUserId) {
return '未设置';
}
for (const user of this.users) {
if (row.leaderUserId === user.id) {
return user.nickname;
}
}
return '未知【' + row.leaderUserId + '】';
},
//
cancel() {
this.open = false;
@ -205,7 +227,7 @@ export default {
parentId: undefined,
name: undefined,
sort: undefined,
leader: undefined,
leaderUserId: undefined,
phone: undefined,
email: undefined,
status: SysCommonStatusEnum.ENABLE,

View File

@ -20,6 +20,12 @@
5. 流程结束
* 我的请假中,可以查询本人的请假申请, 和进度
### 📝 TODO
* 支付
* 用户前台的社交登陆
* 用户前台的修改手机、修改密码、忘记密码
## [v1.3.0] 进行中
### ⚠️ Warning
@ -33,6 +39,7 @@
* 【新增】待办任务的管理,支持任务的审批通过与不通过
* 【新增】已办任务的管理,支持详情的查看
* 【新增】引入 bpmn-process-designer 0.0.1 版本,提供流程设计器的能力
* 【修改】修改部门负责人,从 String 字符串,调整成和后台用户的用户编号绑定
### 🐞 Bug Fixes
@ -45,12 +52,6 @@
* 【升级】druid from 1.2.4 to 1.2.8,提升数据库连接池的稳定性
* 【升级】dynamic-datasource from 3.3.2 to 3.5.0,修复动态数据源切换的问题
### 📝 TODO
* 支付
* 用户前台的社交登陆
* 用户前台的修改手机、修改密码、忘记密码
## [v1.2.0]
### ⚠️ Warning