feat(system): 新增系统组件服务重构部门和用户选择功能
- 新增 CuteDeptTreeVo 模型类用于部门树形结构 - 重命名并迁移 SystemProductLineTreeVo 到 CuteProductLineSelectProVo - 重命名并迁移 SystemProductLineVo 到 CuteProductLineSelectVo - 新增 CuteUserSelectVo 模型类用于用户选择组件 - 新增 CuteBaseService 提供基础部门查询服务 - 新增 CuteDeptTreeService 处理部门树形数据逻辑 - 新增 CuteFileUploadService 管理文件上传功能 - 新增 CuteProductLineSelectProService 和 CuteProductLineSelectService - 新增 CuteUserSelectService 提供用户选择数据源 - 新增多个 API 控制器包括 CuteDeptTreeApi、CuteFileUploadApi 等 - 更新缓存键常量 USER_INFO 替代 ONLINE_USER - 移除旧的 SystemComponentController 和相关方法 - 调整 SystemUserInfoDAO 使用新的缓存键名 - 修改 SystemUserVo 中的部门字段类型为 SystemDeptTb
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
|||||||
|
package cn.odboy.system.application;
|
||||||
|
|
||||||
|
import cn.odboy.system.application.model.CuteDeptTreeVo;
|
||||||
|
import cn.odboy.system.application.service.CuteDeptTreeService;
|
||||||
|
import cn.odboy.system.dal.model.request.SystemQueryDeptArgs;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "系统组件:CuteDeptTree")
|
||||||
|
@RequestMapping("/api/component/CuteDeptTree")
|
||||||
|
public class CuteDeptTreeApi {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CuteDeptTreeService cuteDeptTreeService;
|
||||||
|
|
||||||
|
@ApiOperation("查询部门")
|
||||||
|
@PostMapping(value = "/listMetadata")
|
||||||
|
public ResponseEntity<List<CuteDeptTreeVo>> listMetadata(@Validated @RequestBody SystemQueryDeptArgs args) throws Exception {
|
||||||
|
List<CuteDeptTreeVo> depts = cuteDeptTreeService.listMetadata(args);
|
||||||
|
return ResponseEntity.ok(depts);
|
||||||
|
}
|
||||||
|
}
|
||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
package cn.odboy.system.application;
|
||||||
|
|
||||||
|
import cn.odboy.system.application.service.CuteFileUploadService;
|
||||||
|
import cn.odboy.system.framework.operalog.OperationLog;
|
||||||
|
import cn.odboy.system.service.SystemOssStorageService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "系统组件:CuteFileUpload")
|
||||||
|
@RequestMapping("/api/component/CuteFileUpload")
|
||||||
|
public class CuteFileUploadApi {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CuteFileUploadService cuteFileUploadService;
|
||||||
|
@Autowired
|
||||||
|
private SystemOssStorageService systemOssStorageService;
|
||||||
|
|
||||||
|
@OperationLog
|
||||||
|
@ApiOperation("上传文件到服务器本地")
|
||||||
|
@PostMapping(value = "/uploadLocal")
|
||||||
|
@PreAuthorize("@el.check()")
|
||||||
|
public ResponseEntity<String> uploadLocal(@RequestParam("file") MultipartFile file) {
|
||||||
|
String fileUrl = cuteFileUploadService.uploadLocal(file);
|
||||||
|
return ResponseEntity.ok(fileUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperationLog
|
||||||
|
@ApiOperation("上传文件到OSS")
|
||||||
|
@PostMapping(value = "/uploadOSS")
|
||||||
|
@PreAuthorize("@el.check()")
|
||||||
|
public ResponseEntity<String> uploadOSS(@RequestParam("file") MultipartFile file) {
|
||||||
|
String fileUrl = systemOssStorageService.uploadFile(file);
|
||||||
|
return ResponseEntity.ok(fileUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
package cn.odboy.system.application;
|
||||||
|
|
||||||
|
import cn.odboy.system.application.service.CuteProductLineSelectService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "系统组件:CuteProductLineSelect")
|
||||||
|
@RequestMapping("/api/component/CuteProductLineSelect")
|
||||||
|
public class CuteProductLineSelectApi {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CuteProductLineSelectService cuteProductLineSelectService;
|
||||||
|
|
||||||
|
@ApiOperation("查询部门下拉选择数据源")
|
||||||
|
@PostMapping(value = "/listMetadata")
|
||||||
|
@PreAuthorize("@el.check()")
|
||||||
|
public ResponseEntity<?> listMetadata() {
|
||||||
|
return ResponseEntity.ok(cuteProductLineSelectService.listMetadata());
|
||||||
|
}
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
package cn.odboy.system.application;
|
||||||
|
|
||||||
|
import cn.odboy.system.application.service.CuteProductLineSelectProService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "系统组件:CuteProductLineSelectPro")
|
||||||
|
@RequestMapping("/api/component/CuteProductLineSelectPro")
|
||||||
|
public class CuteProductLineSelectProApi {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CuteProductLineSelectProService cuteProductLineSelectProService;
|
||||||
|
|
||||||
|
@ApiOperation("查询部门下拉选择Pro数据源")
|
||||||
|
@PostMapping(value = "/listMetadata")
|
||||||
|
@PreAuthorize("@el.check()")
|
||||||
|
public ResponseEntity<?> listMetadata() {
|
||||||
|
return ResponseEntity.ok(cuteProductLineSelectProService.listMetadata());
|
||||||
|
}
|
||||||
|
}
|
||||||
+41
@@ -0,0 +1,41 @@
|
|||||||
|
package cn.odboy.system.application;
|
||||||
|
|
||||||
|
import cn.odboy.system.application.model.CuteUserSelectVo;
|
||||||
|
import cn.odboy.system.application.service.CuteUserSelectService;
|
||||||
|
import cn.odboy.system.dal.model.request.SystemQueryUserArgs;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "系统组件:CuteUserSelect")
|
||||||
|
@RequestMapping("/api/component/CuteUserSelect")
|
||||||
|
public class CuteUserSelectApi {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CuteUserSelectService cuteUserSelectService;
|
||||||
|
|
||||||
|
@ApiOperation("查询用户基础数据")
|
||||||
|
@PostMapping(value = "/listMetadata")
|
||||||
|
@PreAuthorize("@el.check()")
|
||||||
|
public ResponseEntity<List<CuteUserSelectVo>> listMetadata(@Validated @RequestBody SystemQueryUserArgs args) {
|
||||||
|
List<CuteUserSelectVo> collect = cuteUserSelectService.listMetadata(args);
|
||||||
|
return ResponseEntity.ok(collect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("根据用户名称集合查询用户基础数据")
|
||||||
|
@PostMapping(value = "/listMetadataByUsernames")
|
||||||
|
@PreAuthorize("@el.check()")
|
||||||
|
public ResponseEntity<List<CuteUserSelectVo>> listMetadataByUsernames(@RequestBody List<String> usernameList) {
|
||||||
|
List<CuteUserSelectVo> collect = cuteUserSelectService.listMetadataByUsernames(usernameList);
|
||||||
|
return ResponseEntity.ok(collect);
|
||||||
|
}
|
||||||
|
}
|
||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
package cn.odboy.system.application.model;
|
||||||
|
|
||||||
|
import cn.odboy.base.KitObject;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class CuteDeptTreeVo extends KitObject {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门ID
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
/**
|
||||||
|
* 部门名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 上级部门ID
|
||||||
|
*/
|
||||||
|
private String pid;
|
||||||
|
/**
|
||||||
|
* 子节点数目
|
||||||
|
*/
|
||||||
|
private Integer subCount = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否有子节点
|
||||||
|
*/
|
||||||
|
public Boolean getHasChildren() {
|
||||||
|
return subCount > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为叶子
|
||||||
|
*/
|
||||||
|
public Boolean getLeaf() {
|
||||||
|
return subCount <= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标签名称
|
||||||
|
*/
|
||||||
|
public String getLabel() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
+9
-4
@@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package cn.odboy.system.dal.model.response;
|
package cn.odboy.system.application.model;
|
||||||
|
|
||||||
import cn.odboy.base.KitObject;
|
import cn.odboy.base.KitObject;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -22,9 +22,14 @@ import java.util.List;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class SystemProductLineTreeVo extends KitObject {
|
public class CuteProductLineSelectProVo extends KitObject {
|
||||||
|
/**
|
||||||
|
* 部门ID(select的value)
|
||||||
|
*/
|
||||||
private String value;
|
private String value;
|
||||||
|
/**
|
||||||
|
* 产品线,如"研发部/华南分部/devops组"
|
||||||
|
*/
|
||||||
private String label;
|
private String label;
|
||||||
private List<SystemProductLineTreeVo> children;
|
private List<CuteProductLineSelectProVo> children;
|
||||||
}
|
}
|
||||||
+3
-3
@@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package cn.odboy.system.dal.model.response;
|
package cn.odboy.system.application.model;
|
||||||
|
|
||||||
import cn.odboy.base.KitObject;
|
import cn.odboy.base.KitObject;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -21,12 +21,12 @@ import lombok.Setter;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class SystemProductLineVo extends KitObject {
|
public class CuteProductLineSelectVo extends KitObject {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门ID(select的value)
|
* 部门ID(select的value)
|
||||||
*/
|
*/
|
||||||
private Long value;
|
private String value;
|
||||||
/**
|
/**
|
||||||
* 产品线,如"研发部/华南分部/devops组"
|
* 产品线,如"研发部/华南分部/devops组"
|
||||||
*/
|
*/
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
package cn.odboy.system.application.model;
|
||||||
|
|
||||||
|
import cn.odboy.base.KitObject;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class CuteUserSelectVo extends KitObject {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* username
|
||||||
|
*/
|
||||||
|
private String value;
|
||||||
|
/**
|
||||||
|
* nickname
|
||||||
|
*/
|
||||||
|
private String label;
|
||||||
|
/**
|
||||||
|
* 部门ID
|
||||||
|
*/
|
||||||
|
private String deptId;
|
||||||
|
/**
|
||||||
|
* 邮箱
|
||||||
|
*/
|
||||||
|
private String email;
|
||||||
|
/**
|
||||||
|
* 手机号
|
||||||
|
*/
|
||||||
|
private String phone;
|
||||||
|
}
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||||
|
import cn.odboy.system.dal.mysql.SystemDeptMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CuteBaseService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SystemDeptMapper systemDeptMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询启用的所有部门集合
|
||||||
|
*
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
public List<SystemDeptTb> listEnabledDept() {
|
||||||
|
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemDeptTb::getEnabled, 1);
|
||||||
|
return systemDeptMapper.selectList(wrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
+65
@@ -0,0 +1,65 @@
|
|||||||
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.odboy.system.application.model.CuteDeptTreeVo;
|
||||||
|
import cn.odboy.system.constant.SystemDataScopeEnum;
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||||
|
import cn.odboy.system.dal.model.request.SystemQueryDeptArgs;
|
||||||
|
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
|
||||||
|
import cn.odboy.system.service.SystemDeptService;
|
||||||
|
import cn.odboy.util.KitClassUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CuteDeptTreeService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SystemDeptService systemDeptService;
|
||||||
|
|
||||||
|
public List<CuteDeptTreeVo> listMetadata(SystemQueryDeptArgs args) throws Exception {
|
||||||
|
String dataScopeType = KitSecurityHelper.getDataScopeType();
|
||||||
|
if (dataScopeType.equals(SystemDataScopeEnum.ALL.getValue())) {
|
||||||
|
args.setPidIsNull(true);
|
||||||
|
}
|
||||||
|
List<Field> fields = KitClassUtil.getAllFields(args.getClass(), new ArrayList<>());
|
||||||
|
List<String> fieldNames = new ArrayList<>() {{
|
||||||
|
add("pidIsNull");
|
||||||
|
add("enabled");
|
||||||
|
}};
|
||||||
|
for (Field field : fields) {
|
||||||
|
// 设置对象的访问权限, 保证对private的属性的访问
|
||||||
|
field.setAccessible(true);
|
||||||
|
Object val = field.get(args);
|
||||||
|
if (fieldNames.contains(field.getName())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotNull(val)) {
|
||||||
|
args.setPidIsNull(null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 数据权限
|
||||||
|
args.setIds(KitSecurityHelper.getCurrentUserDataScope());
|
||||||
|
List<SystemDeptTb> list = systemDeptService.queryDeptByArgs(args);
|
||||||
|
// 如果为空, 就代表为自定义权限或者本级权限, 就需要去重, 不理解可以注释掉,看查询结果
|
||||||
|
if (StrUtil.isBlank(dataScopeType)) {
|
||||||
|
return systemDeptService.filterRootDeptList(list).stream().map(this::convertToVo).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return list.stream().map(this::convertToVo).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private CuteDeptTreeVo convertToVo(SystemDeptTb record) {
|
||||||
|
CuteDeptTreeVo treeVo = new CuteDeptTreeVo();
|
||||||
|
treeVo.setId(Long.toString(record.getId()));
|
||||||
|
treeVo.setName(record.getName());
|
||||||
|
treeVo.setPid(record.getPid() == null ? null : Long.toString(record.getPid()));
|
||||||
|
treeVo.setSubCount(record.getSubCount());
|
||||||
|
return treeVo;
|
||||||
|
}
|
||||||
|
}
|
||||||
+67
@@ -0,0 +1,67 @@
|
|||||||
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.odboy.framework.context.KitRequestHolder;
|
||||||
|
import cn.odboy.framework.exception.BadRequestException;
|
||||||
|
import cn.odboy.framework.properties.AppProperties;
|
||||||
|
import cn.odboy.framework.server.core.KitFileLocalUploadHelper;
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemLocalStorageTb;
|
||||||
|
import cn.odboy.system.dal.mysql.SystemLocalStorageMapper;
|
||||||
|
import cn.odboy.util.KitFileUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class CuteFileUploadService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SystemLocalStorageMapper systemLocalStorageMapper;
|
||||||
|
@Autowired
|
||||||
|
private KitFileLocalUploadHelper fileUploadPathHelper;
|
||||||
|
@Autowired
|
||||||
|
private AppProperties properties;
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public String uploadLocal(MultipartFile multipartFile) {
|
||||||
|
long size = multipartFile.getSize();
|
||||||
|
KitFileUtil.checkSize(properties.getOss().getMaxSize(), size);
|
||||||
|
String suffix = KitFileUtil.getSuffix(multipartFile.getOriginalFilename());
|
||||||
|
String type = KitFileUtil.getFileType(suffix);
|
||||||
|
String uploadDateStr = DateUtil.format(new Date(), DatePattern.PURE_DATE_FORMAT);
|
||||||
|
File file = KitFileUtil.upload(multipartFile, fileUploadPathHelper.getPath() + uploadDateStr + File.separator);
|
||||||
|
if (file == null) {
|
||||||
|
throw new BadRequestException("上传失败");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
String formatSize = KitFileUtil.getSize(size);
|
||||||
|
String prefixName = KitFileUtil.getPrefix(multipartFile.getOriginalFilename(), null);
|
||||||
|
SystemLocalStorageTb localStorage = new SystemLocalStorageTb();
|
||||||
|
localStorage.setRealName(file.getName());
|
||||||
|
localStorage.setName(prefixName);
|
||||||
|
localStorage.setSuffix(suffix);
|
||||||
|
localStorage.setPath(file.getPath());
|
||||||
|
localStorage.setType(type);
|
||||||
|
localStorage.setSize(formatSize);
|
||||||
|
localStorage.setDateGroup(uploadDateStr);
|
||||||
|
systemLocalStorageMapper.insert(localStorage);
|
||||||
|
// 构建上传路径 /file/20260117/odboycn-20260117055246428.png
|
||||||
|
HttpServletRequest httpServletRequest = KitRequestHolder.getHttpServletRequest();
|
||||||
|
StringBuffer requestURL = httpServletRequest.getRequestURL();
|
||||||
|
String[] splits = requestURL.toString().split("/api/component/CuteFileUpload");
|
||||||
|
String requestAddress = splits[0];
|
||||||
|
return String.format("%s/file/%s/%s", requestAddress, uploadDateStr, localStorage.getRealName());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("上传文件失败", e);
|
||||||
|
KitFileUtil.del(file);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+69
@@ -0,0 +1,69 @@
|
|||||||
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
|
import cn.odboy.system.application.model.CuteProductLineSelectProVo;
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CuteProductLineSelectProService extends CuteBaseService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品线选择组件Pro版 数据源
|
||||||
|
*
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
public List<CuteProductLineSelectProVo> listMetadata() {
|
||||||
|
List<SystemDeptTb> depts = this.listEnabledDept();
|
||||||
|
// 查询所有部门并按父子关系组织
|
||||||
|
Map<Long, SystemDeptTb> deptMap =
|
||||||
|
depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity()));
|
||||||
|
List<CuteProductLineSelectProVo> options = new ArrayList<>();
|
||||||
|
// 构建树形结构
|
||||||
|
for (SystemDeptTb dept : depts) {
|
||||||
|
// 只处理顶级部门(pid为null或0的部门)
|
||||||
|
if (dept.getPid() == null || dept.getPid() == 0) {
|
||||||
|
CuteProductLineSelectProVo vo = this.buildDeptTreePro(dept, deptMap);
|
||||||
|
options.add(vo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 按排序字段排序
|
||||||
|
options.sort(Comparator.comparingInt(o -> {
|
||||||
|
Long id = Long.valueOf(o.getValue());
|
||||||
|
return deptMap.get(id) != null ? deptMap.get(id).getDeptSort() : 0;
|
||||||
|
}));
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归构建部门树
|
||||||
|
*
|
||||||
|
* @param dept 当前部门
|
||||||
|
* @param deptMap 部门映射
|
||||||
|
* @return CuteProductLineSelectProVo 树节点
|
||||||
|
*/
|
||||||
|
private CuteProductLineSelectProVo buildDeptTreePro(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap) {
|
||||||
|
CuteProductLineSelectProVo vo = new CuteProductLineSelectProVo();
|
||||||
|
vo.setValue(String.valueOf(dept.getId()));
|
||||||
|
vo.setLabel(dept.getName());
|
||||||
|
// 查找子部门
|
||||||
|
List<CuteProductLineSelectProVo> children = new ArrayList<>();
|
||||||
|
for (SystemDeptTb childDept : deptMap.values()) {
|
||||||
|
if (dept.getId().equals(childDept.getPid())) {
|
||||||
|
children.add(this.buildDeptTreePro(childDept, deptMap));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 子部门按排序字段排序
|
||||||
|
children.sort(Comparator.comparingInt(o -> {
|
||||||
|
Long id = Long.valueOf(o.getValue());
|
||||||
|
return deptMap.get(id) != null ? deptMap.get(id).getDeptSort() : 0;
|
||||||
|
}));
|
||||||
|
vo.setChildren(children);
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
}
|
||||||
+70
@@ -0,0 +1,70 @@
|
|||||||
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
|
import cn.odboy.system.application.model.CuteProductLineSelectVo;
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CuteProductLineSelectService extends CuteBaseService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品线选择组件 数据源
|
||||||
|
*
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
public List<CuteProductLineSelectVo> listMetadata() {
|
||||||
|
List<SystemDeptTb> depts = this.listEnabledDept();
|
||||||
|
return this.buildDeptMetadata(depts);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<CuteProductLineSelectVo> buildDeptMetadata(List<SystemDeptTb> depts) {
|
||||||
|
// 查询所有部门并按父子关系组织
|
||||||
|
Map<Long, SystemDeptTb> deptMap =
|
||||||
|
depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity()));
|
||||||
|
List<CuteProductLineSelectVo> options = new ArrayList<>();
|
||||||
|
for (SystemDeptTb dept : depts) {
|
||||||
|
// 构建部门ID路径
|
||||||
|
List<Long> pathIds = new ArrayList<>();
|
||||||
|
this.buildDeptIdPath(dept, deptMap, pathIds);
|
||||||
|
// 反转路径,从顶级部门到当前部门
|
||||||
|
Collections.reverse(pathIds);
|
||||||
|
CuteProductLineSelectVo dto = new CuteProductLineSelectVo();
|
||||||
|
dto.setValue(Long.toString(dept.getId()));
|
||||||
|
dto.setIdPath(pathIds.stream().map(String::valueOf).collect(Collectors.joining("-")));
|
||||||
|
// 保留名称路径用于显示
|
||||||
|
dto.setLabel(this.buildNamePath(dept, deptMap));
|
||||||
|
options.add(dto);
|
||||||
|
}
|
||||||
|
// 按部门名称路径排序
|
||||||
|
options.sort(Comparator.comparing(CuteProductLineSelectVo::getLabel));
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildDeptIdPath(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap, List<Long> pathIds) {
|
||||||
|
pathIds.add(dept.getId());
|
||||||
|
if (dept.getPid() != null && dept.getPid() != 0 && deptMap.containsKey(dept.getPid())) {
|
||||||
|
this.buildDeptIdPath(deptMap.get(dept.getPid()), deptMap, pathIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildNamePath(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap) {
|
||||||
|
List<String> pathNames = new ArrayList<>();
|
||||||
|
this.buildDeptNamePath(dept, deptMap, pathNames);
|
||||||
|
Collections.reverse(pathNames);
|
||||||
|
return String.join(" / ", pathNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildDeptNamePath(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap, List<String> pathNames) {
|
||||||
|
pathNames.add(dept.getName());
|
||||||
|
if (dept.getPid() != null && dept.getPid() != 0 && deptMap.containsKey(dept.getPid())) {
|
||||||
|
this.buildDeptNamePath(deptMap.get(dept.getPid()), deptMap, pathNames);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+68
@@ -0,0 +1,68 @@
|
|||||||
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.odboy.system.application.model.CuteUserSelectVo;
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemUserTb;
|
||||||
|
import cn.odboy.system.dal.model.request.SystemQueryUserArgs;
|
||||||
|
import cn.odboy.system.dal.mysql.SystemUserMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CuteUserSelectService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SystemUserMapper systemUserMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模糊查询用户基础信息,限制返回的条数
|
||||||
|
*
|
||||||
|
* @param args 查询参数
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
public List<CuteUserSelectVo> listMetadata(SystemQueryUserArgs args) {
|
||||||
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.select(SystemUserTb::getUsername, SystemUserTb::getNickName, SystemUserTb::getDeptId, SystemUserTb::getEmail, SystemUserTb::getPhone);
|
||||||
|
wrapper.and(c -> {
|
||||||
|
c.eq(SystemUserTb::getPhone, args.getBlurry());
|
||||||
|
c.or();
|
||||||
|
c.eq(SystemUserTb::getEmail, args.getBlurry());
|
||||||
|
c.or();
|
||||||
|
c.like(SystemUserTb::getUsername, args.getBlurry());
|
||||||
|
c.or();
|
||||||
|
c.like(SystemUserTb::getNickName, args.getBlurry());
|
||||||
|
});
|
||||||
|
return systemUserMapper.selectPage(new Page<>(1, 50), wrapper).convert(m -> {
|
||||||
|
CuteUserSelectVo selectVo = new CuteUserSelectVo();
|
||||||
|
selectVo.setValue(m.getUsername());
|
||||||
|
selectVo.setLabel(m.getNickName());
|
||||||
|
selectVo.setDeptId(Long.toString(m.getDeptId()));
|
||||||
|
selectVo.setEmail(m.getEmail());
|
||||||
|
selectVo.setPhone(m.getPhone());
|
||||||
|
return selectVo;
|
||||||
|
}).getRecords();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CuteUserSelectVo> listMetadataByUsernames(List<String> usernameList) {
|
||||||
|
if (CollUtil.isEmpty(usernameList)) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.select(SystemUserTb::getUsername, SystemUserTb::getNickName, SystemUserTb::getDeptId, SystemUserTb::getEmail, SystemUserTb::getPhone);
|
||||||
|
wrapper.in(SystemUserTb::getUsername, usernameList);
|
||||||
|
return systemUserMapper.selectList(wrapper).stream().map(m -> {
|
||||||
|
CuteUserSelectVo selectVo = new CuteUserSelectVo();
|
||||||
|
selectVo.setValue(m.getUsername());
|
||||||
|
selectVo.setLabel(m.getNickName());
|
||||||
|
selectVo.setDeptId(Long.toString(m.getDeptId()));
|
||||||
|
selectVo.setEmail(m.getEmail());
|
||||||
|
selectVo.setPhone(m.getPhone());
|
||||||
|
return selectVo;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
@@ -28,4 +28,8 @@ public interface SystemCacheKey {
|
|||||||
* 登录验证码
|
* 登录验证码
|
||||||
*/
|
*/
|
||||||
String CAPTCHA_LOGIN = "captcha::login:";
|
String CAPTCHA_LOGIN = "captcha::login:";
|
||||||
|
/**
|
||||||
|
* 用户信息
|
||||||
|
*/
|
||||||
|
String USER_INFO = "user::info:";
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,6 @@ import cn.odboy.system.dal.model.response.SystemAuthVo;
|
|||||||
import cn.odboy.system.service.SystemAuthService;
|
import cn.odboy.system.service.SystemAuthService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
@@ -29,6 +28,7 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 授权、根据token获取用户详细信息
|
* 授权、根据token获取用户详细信息
|
||||||
|
|||||||
-49
@@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021-2026 Odboy
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package cn.odboy.system.controller;
|
|
||||||
|
|
||||||
import cn.odboy.system.service.SystemDeptService;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@Api(tags = "系统:组件数据源")
|
|
||||||
@RequestMapping("/api/component")
|
|
||||||
public class SystemComponentController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SystemDeptService systemDeptService;
|
|
||||||
|
|
||||||
@ApiOperation("查询部门下拉选择数据源")
|
|
||||||
@PostMapping(value = "/listDeptSelectDataSource")
|
|
||||||
@PreAuthorize("@el.check()")
|
|
||||||
public ResponseEntity<?> listDeptSelectDataSource() {
|
|
||||||
return ResponseEntity.ok(systemDeptService.listDeptSelectDataSource());
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("查询部门下拉选择Pro数据源")
|
|
||||||
@PostMapping(value = "/listDeptSelectProDataSource")
|
|
||||||
@PreAuthorize("@el.check()")
|
|
||||||
public ResponseEntity<?> listDeptSelectProDataSource() {
|
|
||||||
return ResponseEntity.ok(systemDeptService.listDeptSelectProDataSource());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-9
@@ -17,7 +17,6 @@ package cn.odboy.system.controller;
|
|||||||
|
|
||||||
import cn.odboy.base.KitPageArgs;
|
import cn.odboy.base.KitPageArgs;
|
||||||
import cn.odboy.base.KitPageResult;
|
import cn.odboy.base.KitPageResult;
|
||||||
import cn.odboy.base.KitSelectOptionVo;
|
|
||||||
import cn.odboy.system.dal.dataobject.SystemUserTb;
|
import cn.odboy.system.dal.dataobject.SystemUserTb;
|
||||||
import cn.odboy.system.dal.model.request.SystemQueryUserArgs;
|
import cn.odboy.system.dal.model.request.SystemQueryUserArgs;
|
||||||
import cn.odboy.system.dal.model.request.SystemUpdateUserPasswordArgs;
|
import cn.odboy.system.dal.model.request.SystemUpdateUserPasswordArgs;
|
||||||
@@ -43,7 +42,6 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@Api(tags = "系统:用户管理")
|
@Api(tags = "系统:用户管理")
|
||||||
@@ -141,13 +139,6 @@ public class SystemUserController {
|
|||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("查询用户基础数据")
|
|
||||||
@PostMapping(value = "/queryUserMetadataOptions")
|
|
||||||
@PreAuthorize("@el.check('user:list')")
|
|
||||||
public ResponseEntity<List<KitSelectOptionVo>> queryUserMetadataOptions(@Validated @RequestBody KitPageArgs<SystemQueryUserArgs> args) {
|
|
||||||
List<KitSelectOptionVo> collect = systemUserService.queryUserMetadataOptions(args);
|
|
||||||
return ResponseEntity.ok(collect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("获取用户信息")
|
@ApiOperation("获取用户信息")
|
||||||
@PostMapping(value = "/getCurrentUserInfo")
|
@PostMapping(value = "/getCurrentUserInfo")
|
||||||
|
|||||||
+2
-2
@@ -20,10 +20,10 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
|||||||
+2
-1
@@ -16,6 +16,7 @@
|
|||||||
package cn.odboy.system.dal.model.response;
|
package cn.odboy.system.dal.model.response;
|
||||||
|
|
||||||
import cn.odboy.base.KitBaseUserTimeTb;
|
import cn.odboy.base.KitBaseUserTimeTb;
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||||
import cn.odboy.system.dal.dataobject.SystemJobTb;
|
import cn.odboy.system.dal.dataobject.SystemJobTb;
|
||||||
import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
@@ -60,7 +61,7 @@ public class SystemUserVo extends KitBaseUserTimeTb {
|
|||||||
* 扩展字段
|
* 扩展字段
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "用户部门")
|
@ApiModelProperty(value = "用户部门")
|
||||||
private SystemDeptVo dept;
|
private SystemDeptTb dept;
|
||||||
@ApiModelProperty(value = "用户角色")
|
@ApiModelProperty(value = "用户角色")
|
||||||
private Set<SystemRoleTb> roles;
|
private Set<SystemRoleTb> roles;
|
||||||
@ApiModelProperty(value = "用户岗位")
|
@ApiModelProperty(value = "用户岗位")
|
||||||
|
|||||||
+3
-3
@@ -43,7 +43,7 @@ public class SystemUserInfoDAO {
|
|||||||
if (StrUtil.isNotEmpty(userName)) {
|
if (StrUtil.isNotEmpty(userName)) {
|
||||||
// 添加数据, 避免数据同时过期(2小时左右)
|
// 添加数据, 避免数据同时过期(2小时左右)
|
||||||
long time = 7200 + RandomUtil.randomInt(900, 1800);
|
long time = 7200 + RandomUtil.randomInt(900, 1800);
|
||||||
redisHelper.set(SystemCacheKey.ONLINE_USER + userName, user, time);
|
redisHelper.set(SystemCacheKey.USER_INFO + userName, user, time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ public class SystemUserInfoDAO {
|
|||||||
public void deleteUserLoginInfoByUserName(String userName) {
|
public void deleteUserLoginInfoByUserName(String userName) {
|
||||||
if (StrUtil.isNotEmpty(userName)) {
|
if (StrUtil.isNotEmpty(userName)) {
|
||||||
// 清除数据
|
// 清除数据
|
||||||
redisHelper.del(SystemCacheKey.ONLINE_USER + userName);
|
redisHelper.del(SystemCacheKey.USER_INFO + userName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ public class SystemUserInfoDAO {
|
|||||||
public SystemUserJwtVo getUserLoginInfoByUserName(String username) {
|
public SystemUserJwtVo getUserLoginInfoByUserName(String username) {
|
||||||
if (StrUtil.isNotEmpty(username)) {
|
if (StrUtil.isNotEmpty(username)) {
|
||||||
// 获取数据
|
// 获取数据
|
||||||
return redisHelper.get(SystemCacheKey.ONLINE_USER + username, SystemUserJwtVo.class);
|
return redisHelper.get(SystemCacheKey.USER_INFO + username, SystemUserJwtVo.class);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
+39
-183
@@ -27,8 +27,6 @@ import cn.odboy.system.dal.model.export.SystemDeptExportRowVo;
|
|||||||
import cn.odboy.system.dal.model.request.SystemCreateDeptArgs;
|
import cn.odboy.system.dal.model.request.SystemCreateDeptArgs;
|
||||||
import cn.odboy.system.dal.model.request.SystemQueryDeptArgs;
|
import cn.odboy.system.dal.model.request.SystemQueryDeptArgs;
|
||||||
import cn.odboy.system.dal.model.response.SystemDeptVo;
|
import cn.odboy.system.dal.model.response.SystemDeptVo;
|
||||||
import cn.odboy.system.dal.model.response.SystemProductLineTreeVo;
|
|
||||||
import cn.odboy.system.dal.model.response.SystemProductLineVo;
|
|
||||||
import cn.odboy.system.dal.mysql.SystemDeptMapper;
|
import cn.odboy.system.dal.mysql.SystemDeptMapper;
|
||||||
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
|
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
|
||||||
import cn.odboy.util.KitBeanUtil;
|
import cn.odboy.util.KitBeanUtil;
|
||||||
@@ -42,14 +40,11 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@@ -107,10 +102,10 @@ public class SystemDeptService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteDeptByIds(Set<Long> ids) {
|
public void deleteDeptByIds(Set<Long> ids) {
|
||||||
// 查询部门, 和其所有子部门
|
// 查询部门, 和其所有子部门
|
||||||
Set<SystemDeptVo> depts = this.traverseDeptByIdWithPids(ids);
|
Set<SystemDeptTb> depts = this.traverseDeptByIdWithPids(ids);
|
||||||
// 验证是否被角色或用户关联
|
// 验证是否被角色或用户关联
|
||||||
this.verifyBindRelationByIds(depts);
|
this.verifyBindRelationByIds(depts);
|
||||||
for (SystemDeptVo dept : depts) {
|
for (SystemDeptTb dept : depts) {
|
||||||
systemDeptMapper.deleteById(dept.getId());
|
systemDeptMapper.deleteById(dept.getId());
|
||||||
this.updateDeptSubCnt(dept.getPid());
|
this.updateDeptSubCnt(dept.getPid());
|
||||||
}
|
}
|
||||||
@@ -171,16 +166,6 @@ public class SystemDeptService {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据ID查询
|
|
||||||
*
|
|
||||||
* @param id /
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
public SystemDeptVo getDeptVoById(Long id) {
|
|
||||||
return KitBeanUtil.copyToClass(systemDeptMapper.selectById(id), SystemDeptVo.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据部门id遍历所有部门和子部门id集合
|
* 根据部门id遍历所有部门和子部门id集合
|
||||||
*
|
*
|
||||||
@@ -207,14 +192,15 @@ public class SystemDeptService {
|
|||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public KitPageResult<SystemDeptVo> searchDeptTree(List<Long> ids, Boolean exclude) {
|
public KitPageResult<SystemDeptVo> searchDeptTree(List<Long> ids, Boolean exclude) {
|
||||||
Set<SystemDeptVo> deptSet1 = new LinkedHashSet<>();
|
Map<Long, SystemDeptTb> allDeptMap = this.getAllDeptMap();
|
||||||
|
Set<SystemDeptTb> deptSet1 = new LinkedHashSet<>();
|
||||||
for (Long id : ids) {
|
for (Long id : ids) {
|
||||||
// 同级数据
|
// 同级数据
|
||||||
SystemDeptVo dept = this.getDeptVoById(id);
|
SystemDeptTb dept = allDeptMap.get(id);
|
||||||
// 上级数据
|
// 上级数据
|
||||||
List<SystemDeptVo> depts = this.querySuperiorDeptByPid(dept, new ArrayList<>());
|
List<SystemDeptTb> depts = this.querySuperiorDeptByPid(dept, new ArrayList<>(), allDeptMap);
|
||||||
if (exclude) {
|
if (exclude) {
|
||||||
for (SystemDeptVo data : depts) {
|
for (SystemDeptTb data : depts) {
|
||||||
if (data.getId().equals(dept.getPid())) {
|
if (data.getId().equals(dept.getPid())) {
|
||||||
data.setSubCount(data.getSubCount() - 1);
|
data.setSubCount(data.getSubCount() - 1);
|
||||||
}
|
}
|
||||||
@@ -224,18 +210,20 @@ public class SystemDeptService {
|
|||||||
}
|
}
|
||||||
deptSet1.addAll(depts);
|
deptSet1.addAll(depts);
|
||||||
}
|
}
|
||||||
List<SystemDeptVo> deptList = new ArrayList<>(deptSet1);
|
List<SystemDeptTb> deptList = new ArrayList<>(deptSet1);
|
||||||
// 构建部门树
|
// 构建部门树
|
||||||
Set<SystemDeptVo> trees = new LinkedHashSet<>();
|
Set<SystemDeptVo> trees = new LinkedHashSet<>();
|
||||||
Set<SystemDeptVo> deptSet = new LinkedHashSet<>();
|
Set<SystemDeptVo> deptSet = new LinkedHashSet<>();
|
||||||
List<String> deptNames = deptList.stream().map(SystemDeptVo::getName).collect(Collectors.toList());
|
List<String> deptNames = deptList.stream().map(SystemDeptTb::getName).collect(Collectors.toList());
|
||||||
|
|
||||||
boolean isChild;
|
boolean isChild;
|
||||||
for (SystemDeptVo dept : deptList) {
|
List<SystemDeptVo> systemDeptVos = KitBeanUtil.copyToList(deptList, SystemDeptVo.class);
|
||||||
|
for (SystemDeptVo dept : systemDeptVos) {
|
||||||
isChild = false;
|
isChild = false;
|
||||||
if (dept.getPid() == null) {
|
if (dept.getPid() == null) {
|
||||||
trees.add(dept);
|
trees.add(dept);
|
||||||
}
|
}
|
||||||
for (SystemDeptVo it : deptList) {
|
for (SystemDeptVo it : systemDeptVos) {
|
||||||
if (it.getPid() != null && dept.getId().equals(it.getPid())) {
|
if (it.getPid() != null && dept.getId().equals(it.getPid())) {
|
||||||
isChild = true;
|
isChild = true;
|
||||||
if (dept.getChildren() == null) {
|
if (dept.getChildren() == null) {
|
||||||
@@ -246,7 +234,7 @@ public class SystemDeptService {
|
|||||||
}
|
}
|
||||||
if (isChild) {
|
if (isChild) {
|
||||||
deptSet.add(dept);
|
deptSet.add(dept);
|
||||||
} else if (dept.getPid() != null && !deptNames.contains(this.getDeptVoById(dept.getPid()).getName())) {
|
} else if (dept.getPid() != null && !deptNames.contains(allDeptMap.get(dept.getPid()).getName())) {
|
||||||
deptSet.add(dept);
|
deptSet.add(dept);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -259,13 +247,18 @@ public class SystemDeptService {
|
|||||||
return baseResult;
|
return baseResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<Long, SystemDeptTb> getAllDeptMap() {
|
||||||
|
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
return systemDeptMapper.selectList(wrapper).stream().collect(Collectors.toMap(SystemDeptTb::getId, i -> i, (m, n) -> m));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证是否被角色或用户关联
|
* 验证是否被角色或用户关联
|
||||||
*
|
*
|
||||||
* @param deptSet /
|
* @param deptSet /
|
||||||
*/
|
*/
|
||||||
public void verifyBindRelationByIds(Set<SystemDeptVo> deptSet) {
|
public void verifyBindRelationByIds(Set<SystemDeptTb> deptSet) {
|
||||||
Set<Long> deptIds = deptSet.stream().map(SystemDeptVo::getId).collect(Collectors.toSet());
|
Set<Long> deptIds = deptSet.stream().map(SystemDeptTb::getId).collect(Collectors.toSet());
|
||||||
if (systemUserDeptService.countUserByDeptIds(deptIds) > 0) {
|
if (systemUserDeptService.countUserByDeptIds(deptIds) > 0) {
|
||||||
throw new BadRequestException("所选部门存在用户关联,请解除后再试!");
|
throw new BadRequestException("所选部门存在用户关联,请解除后再试!");
|
||||||
}
|
}
|
||||||
@@ -279,13 +272,13 @@ public class SystemDeptService {
|
|||||||
*
|
*
|
||||||
* @param ids 部门id集合
|
* @param ids 部门id集合
|
||||||
*/
|
*/
|
||||||
public Set<SystemDeptVo> traverseDeptByIdWithPids(Set<Long> ids) {
|
public Set<SystemDeptTb> traverseDeptByIdWithPids(Set<Long> ids) {
|
||||||
Set<SystemDeptVo> depts = new HashSet<>();
|
Set<SystemDeptTb> depts = new HashSet<>();
|
||||||
for (Long id : ids) {
|
for (Long id : ids) {
|
||||||
// 根部门
|
// 根部门
|
||||||
depts.add(this.getDeptVoById(id));
|
depts.add(systemDeptMapper.selectById(id));
|
||||||
// 子部门
|
// 子部门
|
||||||
List<SystemDeptVo> deptList = this.listDeptVoByPid(id);
|
List<SystemDeptTb> deptList = this.listDeptByPid(id);
|
||||||
if (CollUtil.isNotEmpty(deptList)) {
|
if (CollUtil.isNotEmpty(deptList)) {
|
||||||
this.queryRelationDeptByArgs(deptList, depts);
|
this.queryRelationDeptByArgs(deptList, depts);
|
||||||
}
|
}
|
||||||
@@ -293,43 +286,6 @@ public class SystemDeptService {
|
|||||||
return depts;
|
return depts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 产品线选择组件 数据源
|
|
||||||
*
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
public List<SystemProductLineVo> listDeptSelectDataSource() {
|
|
||||||
List<SystemDeptTb> depts = this.listEnabledDepts();
|
|
||||||
return this.buildDeptSelectOptions(depts);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 产品线选择组件Pro版 数据源
|
|
||||||
*
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
public List<SystemProductLineTreeVo> listDeptSelectProDataSource() {
|
|
||||||
List<SystemDeptTb> depts = this.listEnabledDepts();
|
|
||||||
// 查询所有部门并按父子关系组织
|
|
||||||
Map<Long, SystemDeptTb> deptMap =
|
|
||||||
depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity()));
|
|
||||||
List<SystemProductLineTreeVo> options = new ArrayList<>();
|
|
||||||
// 构建树形结构
|
|
||||||
for (SystemDeptTb dept : depts) {
|
|
||||||
// 只处理顶级部门(pid为null或0的部门)
|
|
||||||
if (dept.getPid() == null || dept.getPid() == 0) {
|
|
||||||
SystemProductLineTreeVo vo = this.buildDeptTreePro(dept, deptMap);
|
|
||||||
options.add(vo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 按排序字段排序
|
|
||||||
options.sort(Comparator.comparingInt(o -> {
|
|
||||||
Long id = Long.valueOf(o.getValue());
|
|
||||||
return deptMap.get(id) != null ? deptMap.get(id).getDeptSort() : 0;
|
|
||||||
}));
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据父部门id查询部门集合
|
* 根据父部门id查询部门集合
|
||||||
*
|
*
|
||||||
@@ -373,137 +329,37 @@ public class SystemDeptService {
|
|||||||
return systemDeptMapper.selectList(wrapper);
|
return systemDeptMapper.selectList(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 递归构建部门树
|
|
||||||
*
|
|
||||||
* @param dept 当前部门
|
|
||||||
* @param deptMap 部门映射
|
|
||||||
* @return SystemProductLineTreeVo 树节点
|
|
||||||
*/
|
|
||||||
private SystemProductLineTreeVo buildDeptTreePro(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap) {
|
|
||||||
SystemProductLineTreeVo vo = new SystemProductLineTreeVo();
|
|
||||||
vo.setValue(String.valueOf(dept.getId()));
|
|
||||||
vo.setLabel(dept.getName());
|
|
||||||
// 查找子部门
|
|
||||||
List<SystemProductLineTreeVo> children = new ArrayList<>();
|
|
||||||
for (SystemDeptTb childDept : deptMap.values()) {
|
|
||||||
if (dept.getId().equals(childDept.getPid())) {
|
|
||||||
children.add(this.buildDeptTreePro(childDept, deptMap));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 子部门按排序字段排序
|
|
||||||
children.sort(Comparator.comparingInt(o -> {
|
|
||||||
Long id = Long.valueOf(o.getValue());
|
|
||||||
return deptMap.get(id) != null ? deptMap.get(id).getDeptSort() : 0;
|
|
||||||
}));
|
|
||||||
vo.setChildren(children);
|
|
||||||
return vo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 产品线选择组件使用
|
|
||||||
*
|
|
||||||
* @param depts 部门集合
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
private List<SystemProductLineVo> buildDeptSelectOptions(List<SystemDeptTb> depts) {
|
|
||||||
// 查询所有部门并按父子关系组织
|
|
||||||
Map<Long, SystemDeptTb> deptMap =
|
|
||||||
depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity()));
|
|
||||||
List<SystemProductLineVo> options = new ArrayList<>();
|
|
||||||
for (SystemDeptTb dept : depts) {
|
|
||||||
// 构建部门ID路径
|
|
||||||
List<Long> pathIds = new ArrayList<>();
|
|
||||||
this.buildDeptIdPath(dept, deptMap, pathIds);
|
|
||||||
// 反转路径,从顶级部门到当前部门
|
|
||||||
Collections.reverse(pathIds);
|
|
||||||
SystemProductLineVo dto = new SystemProductLineVo();
|
|
||||||
dto.setValue(dept.getId());
|
|
||||||
dto.setIdPath(pathIds.stream().map(String::valueOf).collect(Collectors.joining("-")));
|
|
||||||
// 保留名称路径用于显示
|
|
||||||
dto.setLabel(this.buildNamePath(dept, deptMap));
|
|
||||||
options.add(dto);
|
|
||||||
}
|
|
||||||
// 按部门名称路径排序
|
|
||||||
options.sort(Comparator.comparing(SystemProductLineVo::getLabel));
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 产品线选择组件使用
|
|
||||||
*/
|
|
||||||
private void buildDeptIdPath(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap, List<Long> pathIds) {
|
|
||||||
pathIds.add(dept.getId());
|
|
||||||
if (dept.getPid() != null && dept.getPid() != 0 && deptMap.containsKey(dept.getPid())) {
|
|
||||||
this.buildDeptIdPath(deptMap.get(dept.getPid()), deptMap, pathIds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 产品线选择组件使用
|
|
||||||
*/
|
|
||||||
private String buildNamePath(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap) {
|
|
||||||
List<String> pathNames = new ArrayList<>();
|
|
||||||
this.buildDeptNamePath(dept, deptMap, pathNames);
|
|
||||||
Collections.reverse(pathNames);
|
|
||||||
return String.join(" / ", pathNames);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 产品线选择组件使用
|
|
||||||
*/
|
|
||||||
private void buildDeptNamePath(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap, List<String> pathNames) {
|
|
||||||
pathNames.add(dept.getName());
|
|
||||||
if (dept.getPid() != null && dept.getPid() != 0 && deptMap.containsKey(dept.getPid())) {
|
|
||||||
this.buildDeptNamePath(deptMap.get(dept.getPid()), deptMap, pathNames);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询启用的所有部门集合
|
|
||||||
*
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
private List<SystemDeptTb> listEnabledDepts() {
|
|
||||||
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemDeptTb::getEnabled, 1);
|
|
||||||
return systemDeptMapper.selectList(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询部门下所有关联的部门
|
* 查询部门下所有关联的部门
|
||||||
*
|
*
|
||||||
* @param deptTbList /
|
* @param deptTbList /
|
||||||
* @param depts /
|
* @param depts /
|
||||||
*/
|
*/
|
||||||
private void queryRelationDeptByArgs(List<SystemDeptVo> deptTbList, Set<SystemDeptVo> depts) {
|
private void queryRelationDeptByArgs(List<SystemDeptTb> deptTbList, Set<SystemDeptTb> depts) {
|
||||||
for (SystemDeptVo dept : deptTbList) {
|
for (SystemDeptTb dept : deptTbList) {
|
||||||
depts.add(dept);
|
depts.add(dept);
|
||||||
List<SystemDeptVo> deptList = this.listDeptVoByPid(dept.getId());
|
List<SystemDeptTb> deptList = this.listDeptByPid(dept.getId());
|
||||||
if (CollUtil.isNotEmpty(deptList)) {
|
if (CollUtil.isNotEmpty(deptList)) {
|
||||||
this.queryRelationDeptByArgs(deptList, depts);
|
this.queryRelationDeptByArgs(deptList, depts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<SystemDeptVo> listDeptVoByPid(Long pid) {
|
|
||||||
return KitBeanUtil.copyToList(this.listDeptByPid(pid), SystemDeptVo.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据ID查询同级与上级数据
|
* 根据ID查询同级与上级数据
|
||||||
*
|
*
|
||||||
* @param dept /
|
* @param dept /
|
||||||
* @param deptList /
|
* @param deptList /
|
||||||
|
* @param allDeptMap
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
private List<SystemDeptVo> querySuperiorDeptByPid(SystemDeptVo dept, List<SystemDeptVo> deptList) {
|
private List<SystemDeptTb> querySuperiorDeptByPid(SystemDeptTb dept, List<SystemDeptTb> deptList, Map<Long, SystemDeptTb> allDeptMap) {
|
||||||
if (dept.getPid() == null) {
|
if (dept.getPid() == null) {
|
||||||
deptList.addAll(this.listRootDept());
|
deptList.addAll(this.listRootDept());
|
||||||
return deptList;
|
return deptList;
|
||||||
}
|
}
|
||||||
deptList.addAll(this.listDeptVoByPid(dept.getPid()));
|
deptList.addAll(this.listDeptByPid(dept.getPid()));
|
||||||
return querySuperiorDeptByPid(this.getDeptVoById(dept.getPid()), deptList);
|
return querySuperiorDeptByPid(allDeptMap.get(dept.getPid()), deptList, allDeptMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -511,10 +367,10 @@ public class SystemDeptService {
|
|||||||
*
|
*
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
private List<SystemDeptVo> listRootDept() {
|
private List<SystemDeptTb> listRootDept() {
|
||||||
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.isNull(SystemDeptTb::getPid);
|
wrapper.isNull(SystemDeptTb::getPid);
|
||||||
return KitBeanUtil.copyToList(systemDeptMapper.selectList(wrapper), SystemDeptVo.class);
|
return systemDeptMapper.selectList(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -523,7 +379,7 @@ public class SystemDeptService {
|
|||||||
* @param id 部门id
|
* @param id 部门id
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
private SystemDeptTb getDeptById(Long id) {
|
public SystemDeptTb getDeptById(Long id) {
|
||||||
return systemDeptMapper.selectById(id);
|
return systemDeptMapper.selectById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -542,7 +398,7 @@ public class SystemDeptService {
|
|||||||
/**
|
/**
|
||||||
* 筛选出 list 中没有父部门(即 pid 不在其他部门 id 列表中的部门)的部门列表
|
* 筛选出 list 中没有父部门(即 pid 不在其他部门 id 列表中的部门)的部门列表
|
||||||
*/
|
*/
|
||||||
private List<SystemDeptTb> filterRootDeptList(List<SystemDeptTb> list) {
|
public List<SystemDeptTb> filterRootDeptList(List<SystemDeptTb> list) {
|
||||||
List<SystemDeptTb> deptList = new ArrayList<>();
|
List<SystemDeptTb> deptList = new ArrayList<>();
|
||||||
// 使用 Set 存储所有部门的 id
|
// 使用 Set 存储所有部门的 id
|
||||||
Set<Long> idSet = list.stream().map(SystemDeptTb::getId).collect(Collectors.toSet());
|
Set<Long> idSet = list.stream().map(SystemDeptTb::getId).collect(Collectors.toSet());
|
||||||
@@ -561,7 +417,7 @@ public class SystemDeptService {
|
|||||||
* @param args /
|
* @param args /
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
private List<SystemDeptTb> queryDeptByArgs(SystemQueryDeptArgs args) {
|
public List<SystemDeptTb> queryDeptByArgs(SystemQueryDeptArgs args) {
|
||||||
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
wrapper.in(CollUtil.isNotEmpty(args.getIds()), SystemDeptTb::getId, args.getIds());
|
wrapper.in(CollUtil.isNotEmpty(args.getIds()), SystemDeptTb::getId, args.getIds());
|
||||||
|
|||||||
+3
-37
@@ -17,9 +17,7 @@ package cn.odboy.system.service;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.odboy.base.KitPageArgs;
|
|
||||||
import cn.odboy.base.KitPageResult;
|
import cn.odboy.base.KitPageResult;
|
||||||
import cn.odboy.base.KitSelectOptionVo;
|
|
||||||
import cn.odboy.framework.exception.BadRequestException;
|
import cn.odboy.framework.exception.BadRequestException;
|
||||||
import cn.odboy.framework.properties.AppProperties;
|
import cn.odboy.framework.properties.AppProperties;
|
||||||
import cn.odboy.framework.server.core.KitFileLocalUploadHelper;
|
import cn.odboy.framework.server.core.KitFileLocalUploadHelper;
|
||||||
@@ -333,36 +331,6 @@ public class SystemUserService {
|
|||||||
return systemUserMapper.selectCount(wrapper);
|
return systemUserMapper.selectCount(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 模糊查询用户基础信息,限制返回的条数
|
|
||||||
*
|
|
||||||
* @param pageArgs 分页参数
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
public List<KitSelectOptionVo> queryUserMetadataOptions(KitPageArgs<SystemQueryUserArgs> pageArgs) {
|
|
||||||
SystemQueryUserArgs args = pageArgs.getArgs();
|
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.select(
|
|
||||||
SystemUserTb::getId, SystemUserTb::getUsername, SystemUserTb::getNickName, SystemUserTb::getDeptId, SystemUserTb::getEmail, SystemUserTb::getPhone);
|
|
||||||
wrapper.and(c -> {
|
|
||||||
c.eq(SystemUserTb::getPhone, args.getBlurry());
|
|
||||||
c.or();
|
|
||||||
c.eq(SystemUserTb::getEmail, args.getBlurry());
|
|
||||||
c.or();
|
|
||||||
c.like(SystemUserTb::getUsername, args.getBlurry());
|
|
||||||
c.or();
|
|
||||||
c.like(SystemUserTb::getNickName, args.getBlurry());
|
|
||||||
});
|
|
||||||
return systemUserMapper.selectPage(new Page<>(pageArgs.getPage(), 50), wrapper).getRecords().stream().map(m -> {
|
|
||||||
Map<String, Object> ext = new HashMap<>(1);
|
|
||||||
ext.put("id", m.getId());
|
|
||||||
ext.put("deptId", m.getDeptId());
|
|
||||||
ext.put("email", m.getEmail());
|
|
||||||
ext.put("phone", m.getPhone());
|
|
||||||
return KitSelectOptionVo.builder().label(m.getNickName()).value(String.valueOf(m.getId())).ext(ext).build();
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户名查询启用的用户信息
|
* 根据用户名查询启用的用户信息
|
||||||
*
|
*
|
||||||
@@ -399,10 +367,7 @@ public class SystemUserService {
|
|||||||
/**
|
/**
|
||||||
* 聚合查询 -> TestPassed
|
* 聚合查询 -> TestPassed
|
||||||
*/
|
*/
|
||||||
public KitPageResult<SystemUserVo> aggregationSearchUserByArgs(
|
public KitPageResult<SystemUserVo> aggregationSearchUserByArgs(Page<SystemUserTb> page, SystemQueryUserArgs args, String currentUsername) {
|
||||||
Page<SystemUserTb> page, SystemQueryUserArgs args,
|
|
||||||
String currentUsername
|
|
||||||
) {
|
|
||||||
if (!ObjectUtils.isEmpty(args.getDeptId())) {
|
if (!ObjectUtils.isEmpty(args.getDeptId())) {
|
||||||
args.getDeptIds().add(args.getDeptId());
|
args.getDeptIds().add(args.getDeptId());
|
||||||
// 先查找是否存在子节点
|
// 先查找是否存在子节点
|
||||||
@@ -584,7 +549,7 @@ public class SystemUserService {
|
|||||||
SystemUserVo userVo = KitBeanUtil.copyToClass(user, SystemUserVo.class);
|
SystemUserVo userVo = KitBeanUtil.copyToClass(user, SystemUserVo.class);
|
||||||
// 查询关联的部门信息
|
// 查询关联的部门信息
|
||||||
if (user.getDeptId() != null) {
|
if (user.getDeptId() != null) {
|
||||||
userVo.setDept(systemDeptService.getDeptVoById(user.getDeptId()));
|
userVo.setDept(systemDeptService.getDeptById(user.getDeptId()));
|
||||||
}
|
}
|
||||||
// 查询关联的岗位信息
|
// 查询关联的岗位信息
|
||||||
userVo.setJobs(systemUserJobService.listUserJobByUserId(user.getId()));
|
userVo.setJobs(systemUserJobService.listUserJobByUserId(user.getId()));
|
||||||
@@ -592,4 +557,5 @@ public class SystemUserService {
|
|||||||
userVo.setRoles(systemUserRoleService.listUserRoleByUserId(user.getId()));
|
userVo.setRoles(systemUserRoleService.listUserRoleByUserId(user.getId()));
|
||||||
return userVo;
|
return userVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user