feat:部门负责人
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
CREATE TABLE `simulation_role_permission` (
|
CREATE TABLE `simulation_role_permission` (
|
||||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
`id` int NOT NULL AUTO_INCREMENT,
|
||||||
`roleId` bigint NOT NULL COMMENT '角色id(对应CID)',
|
`roleId` bigint NOT NULL COMMENT '角色id(对应CID)',
|
||||||
`permissionCode` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '菜单权限编码',
|
`permissionCode` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '菜单权限编码',
|
||||||
`tenantId` bigint NOT NULL DEFAULT '0' COMMENT '租户ID',
|
`tenantId` bigint NOT NULL DEFAULT '0' COMMENT '租户ID',
|
||||||
`creator` bigint NOT NULL DEFAULT '0' COMMENT '模版创建者ID',
|
`creator` bigint NOT NULL DEFAULT '0' COMMENT '创建者ID',
|
||||||
`createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '模版创建时间',
|
`createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='角色菜单权限表';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='角色菜单权限表';
|
||||||
11
1-sql/2026-01-08/sys_dept_user.sql
Normal file
11
1-sql/2026-01-08/sys_dept_user.sql
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
CREATE TABLE `sys_dept_user` (
|
||||||
|
`id` int NOT NULL AUTO_INCREMENT,
|
||||||
|
`deptId` bigint NOT NULL COMMENT '部门ID',
|
||||||
|
`deptName` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '部门名称',
|
||||||
|
`userId` bigint NOT NULL COMMENT '部门负责人用户ID',
|
||||||
|
`tenantId` bigint NOT NULL DEFAULT '0' COMMENT '租户ID',
|
||||||
|
`creator` bigint NOT NULL DEFAULT '0' COMMENT '创建者ID',
|
||||||
|
`createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='部门负责人表';
|
||||||
@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -99,6 +101,7 @@ public class SimulationPerformance implements Serializable {
|
|||||||
private String tenantId;
|
private String tenantId;
|
||||||
|
|
||||||
@TableField("createTime")
|
@TableField("createTime")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
@TableField("creator")
|
@TableField("creator")
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package com.sdm.system.controller;
|
||||||
|
|
||||||
|
import com.sdm.common.common.SdmResponse;
|
||||||
|
import com.sdm.common.entity.resp.PageDataResp;
|
||||||
|
import com.sdm.system.model.entity.SysDeptUser;
|
||||||
|
import com.sdm.system.model.req.dept.DeptOperateReq;
|
||||||
|
import com.sdm.system.model.req.dept.DeptQueryReq;
|
||||||
|
import com.sdm.system.service.ISysDeptUserService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springdoc.core.annotations.ParameterObject;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Tag(name = "部门管理", description = "部门相关接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/dept")
|
||||||
|
public class SysDeptController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysDeptUserService deptUserService;
|
||||||
|
|
||||||
|
@Operation(summary = "新增部门及负责人", description = "新增部门及负责人")
|
||||||
|
@PostMapping("/addDept")
|
||||||
|
public SdmResponse addDept(@RequestBody DeptOperateReq deptAddReq) {
|
||||||
|
return deptUserService.addDept(deptAddReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "新增部门及负责人", description = "新增部门及负责人")
|
||||||
|
@PostMapping("/editDept")
|
||||||
|
public SdmResponse editDept(@RequestBody DeptOperateReq deptAddReq) {
|
||||||
|
return deptUserService.editDept(deptAddReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "查询部门列表", description = "查询部门列表")
|
||||||
|
@GetMapping("/listDept")
|
||||||
|
public SdmResponse<PageDataResp<List<SysDeptUser>>> listDept(@ParameterObject DeptQueryReq req) {
|
||||||
|
return deptUserService.listDept(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.sdm.system.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.sdm.system.model.entity.SysDeptUser;
|
||||||
|
|
||||||
|
public interface SysDeptUserMapper extends BaseMapper<SysDeptUser> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -24,9 +24,9 @@ public class SimulationRolePermission implements Serializable {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Schema(description = "表单ID")
|
@Schema(description = "主键ID")
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
private Long id;
|
private Integer id;
|
||||||
|
|
||||||
@Schema(description = "角色id(对应CID")
|
@Schema(description = "角色id(对应CID")
|
||||||
@TableField("roleId")
|
@TableField("roleId")
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package com.sdm.system.model.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("sys_dept_user")
|
||||||
|
@ApiModel(value="SysDeptUser对象", description="部门负责人表")
|
||||||
|
public class SysDeptUser implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Schema(description = "主键ID")
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@Schema(description = "部门ID")
|
||||||
|
@TableField("deptId")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
@Schema(description = "部门名称")
|
||||||
|
@TableField("deptName")
|
||||||
|
private String deptName;
|
||||||
|
|
||||||
|
@Schema(description = "部门负责人用户ID")
|
||||||
|
@TableField("userId")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@Schema(description = "所属租户ID")
|
||||||
|
@TableField("tenantId")
|
||||||
|
private Long tenantId;
|
||||||
|
|
||||||
|
@Schema(description = "创建人")
|
||||||
|
@TableField("creator")
|
||||||
|
private Long creator;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@TableField("createTime")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.sdm.system.model.req.dept;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DeptOperateReq {
|
||||||
|
|
||||||
|
@Schema(description = "部门名称")
|
||||||
|
private String deptName;
|
||||||
|
|
||||||
|
@Schema(description = "部门负责人用户ID")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@Schema(description = "部门ID")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
@Schema(description = "主键")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.sdm.system.model.req.dept;
|
||||||
|
|
||||||
|
import com.sdm.system.model.req.BaseReq;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DeptQueryReq extends BaseReq {
|
||||||
|
|
||||||
|
@Schema(description = "部门名称")
|
||||||
|
private String deptName;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.sdm.system.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.sdm.common.common.SdmResponse;
|
||||||
|
import com.sdm.common.entity.resp.PageDataResp;
|
||||||
|
import com.sdm.system.model.entity.SysDeptUser;
|
||||||
|
import com.sdm.system.model.req.dept.DeptOperateReq;
|
||||||
|
import com.sdm.system.model.req.dept.DeptQueryReq;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ISysDeptUserService extends IService<SysDeptUser> {
|
||||||
|
|
||||||
|
SdmResponse addDept(DeptOperateReq deptAddReq);
|
||||||
|
|
||||||
|
SdmResponse editDept(DeptOperateReq deptAddReq);
|
||||||
|
|
||||||
|
SdmResponse<PageDataResp<List<SysDeptUser>>> listDept(DeptQueryReq req);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package com.sdm.system.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.sdm.common.common.SdmResponse;
|
||||||
|
import com.sdm.common.common.ThreadLocalContext;
|
||||||
|
import com.sdm.common.entity.resp.PageDataResp;
|
||||||
|
import com.sdm.common.utils.PageUtils;
|
||||||
|
import com.sdm.system.dao.SysDeptUserMapper;
|
||||||
|
import com.sdm.system.model.entity.SysDeptUser;
|
||||||
|
import com.sdm.system.model.req.dept.DeptOperateReq;
|
||||||
|
import com.sdm.system.model.req.dept.DeptQueryReq;
|
||||||
|
import com.sdm.system.service.ISysDeptUserService;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ISysDeptUserServiceImpl extends ServiceImpl<SysDeptUserMapper, SysDeptUser> implements ISysDeptUserService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SdmResponse addDept(DeptOperateReq deptAddReq) {
|
||||||
|
SysDeptUser deptUser = new SysDeptUser();
|
||||||
|
deptUser.setDeptName(deptAddReq.getDeptName());
|
||||||
|
deptUser.setUserId(deptAddReq.getUserId());
|
||||||
|
deptUser.setTenantId(ThreadLocalContext.getTenantId());
|
||||||
|
deptUser.setCreator(ThreadLocalContext.getUserId());
|
||||||
|
deptUser.setDeptId(IdWorker.getId(deptUser));
|
||||||
|
this.save(deptUser);
|
||||||
|
return SdmResponse.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SdmResponse editDept(DeptOperateReq deptEditReq) {
|
||||||
|
SysDeptUser deptUser = this.getById(deptEditReq.getId());
|
||||||
|
if (deptUser != null) {
|
||||||
|
if (StringUtils.isNotBlank(deptEditReq.getDeptName())) {
|
||||||
|
deptUser.setDeptName(deptEditReq.getDeptName());
|
||||||
|
}
|
||||||
|
if (deptEditReq.getUserId() != null) {
|
||||||
|
deptUser.setUserId(deptEditReq.getUserId());
|
||||||
|
}
|
||||||
|
this.updateById(deptUser);
|
||||||
|
}
|
||||||
|
return SdmResponse.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SdmResponse<PageDataResp<List<SysDeptUser>>> listDept(DeptQueryReq req) {
|
||||||
|
PageHelper.startPage(req.getCurrent(), req.getSize());
|
||||||
|
LambdaQueryWrapper<SysDeptUser> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (StringUtils.isNotEmpty(req.getDeptName())) {
|
||||||
|
queryWrapper.like(SysDeptUser::getDeptName, req.getDeptName());
|
||||||
|
}
|
||||||
|
List<SysDeptUser> sysDeptUsers = this.list(queryWrapper);
|
||||||
|
PageInfo<SysDeptUser> page = new PageInfo<>(sysDeptUsers);
|
||||||
|
return PageUtils.getJsonObjectSdmResponse(sysDeptUsers, page);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -42,7 +42,8 @@ public class SimulationRolePermissionServiceImpl extends ServiceImpl<SimulationR
|
|||||||
rolePermission.setCreator(userId);
|
rolePermission.setCreator(userId);
|
||||||
rolePermissionList.add(rolePermission);
|
rolePermissionList.add(rolePermission);
|
||||||
}
|
}
|
||||||
return SdmResponse.success(this.saveBatch(rolePermissionList));
|
this.saveBatch(rolePermissionList);
|
||||||
|
return SdmResponse.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -63,7 +64,7 @@ public class SimulationRolePermissionServiceImpl extends ServiceImpl<SimulationR
|
|||||||
List<String> userPermissionList = new ArrayList<>();
|
List<String> userPermissionList = new ArrayList<>();
|
||||||
for (CIDRoleResp cidRoleResp : cidRoleRespList) {
|
for (CIDRoleResp cidRoleResp : cidRoleRespList) {
|
||||||
List<String> rolePermissionList = getRolePermissions(cidRoleResp.getRoleId()).getData();
|
List<String> rolePermissionList = getRolePermissions(cidRoleResp.getRoleId()).getData();
|
||||||
if (!CollectionUtils.isNotEmpty(rolePermissionList)) {
|
if (CollectionUtils.isNotEmpty(rolePermissionList)) {
|
||||||
userPermissionList.addAll(rolePermissionList);
|
userPermissionList.addAll(rolePermissionList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -99,6 +101,7 @@ public class SimulationPerformance implements Serializable {
|
|||||||
private String tenantId;
|
private String tenantId;
|
||||||
|
|
||||||
@TableField("createTime")
|
@TableField("createTime")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
@TableField("creator")
|
@TableField("creator")
|
||||||
|
|||||||
Reference in New Issue
Block a user