mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 04:39:00 +08:00
♻️ Refactoring code. 简化租户套餐维护功能,删除 sys_tenant_menu表
✨ Introducing new features. #5041 ParamResolver 增加批量获取参数的方法封装 ✨ Introducing new features. 增加文件分组功能 ♻️ Refactoring code. 【用户管理】状态栏修改为 有效 【用户管理】增加修改悬浮输入框密码功能
This commit is contained in:
1 parent
e61920cbde
commit
a6b02b47c2
34 files changed
+751
-364
No files matched your search
+24
@@ -0,0 +1,24 @@
|
||||
package com.pig4cloud.pigx.admin.api.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 文件传输DTO
|
||||
*
|
||||
* @author lengleng
|
||||
* @date 2023/7/26
|
||||
*/
|
||||
@Data
|
||||
public class SysFileGroupDTO {
|
||||
|
||||
/**
|
||||
* 文件组
|
||||
*/
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 文件id
|
||||
*/
|
||||
private Long[] ids;
|
||||
|
||||
}
|
||||
+4
-2
@@ -18,6 +18,7 @@
|
||||
package com.pig4cloud.pigx.admin.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysAuditLog;
|
||||
@@ -108,8 +109,9 @@ public class SysAuditLogController {
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('sys_audit_export')")
|
||||
public List<SysAuditLog> export(SysAuditLog sysAuditLog) {
|
||||
return sysAuditLogService.list(Wrappers.query(sysAuditLog));
|
||||
public List<SysAuditLog> export(SysAuditLog sysAuditLog, Long[] ids) {
|
||||
return sysAuditLogService
|
||||
.list(Wrappers.lambdaQuery(sysAuditLog).in(ArrayUtil.isNotEmpty(ids), SysAuditLog::getId, ids));
|
||||
}
|
||||
|
||||
}
|
||||
+8
-4
@@ -28,13 +28,13 @@ import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;
|
||||
import com.pig4cloud.pigx.common.log.annotation.SysLog;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import javax.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@@ -79,8 +79,8 @@ public class SysDeptController {
|
||||
* @return 树形菜单
|
||||
*/
|
||||
@GetMapping(value = "/tree")
|
||||
public R getTree(String deptName) {
|
||||
return R.ok(sysDeptService.selectTree(deptName));
|
||||
public R getTree(String deptName, Long parentId) {
|
||||
return R.ok(sysDeptService.selectTree(deptName, parentId));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,6 +129,11 @@ public class SysDeptController {
|
||||
return R.ok(sysDeptService.listDescendant(deptId));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/leader/{deptId}")
|
||||
public R getAllDeptLeader(@PathVariable Long deptId) {
|
||||
return R.ok(sysDeptService.listDeptLeader(deptId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出部门
|
||||
* @return
|
||||
@@ -147,7 +152,6 @@ public class SysDeptController {
|
||||
*/
|
||||
@PostMapping("import")
|
||||
public R importDept(@RequestExcel List<DeptExcelVo> excelVOList, BindingResult bindingResult) {
|
||||
|
||||
return sysDeptService.importDept(excelVOList, bindingResult);
|
||||
}
|
||||
|
||||
|
||||
+66
-4
@@ -22,7 +22,9 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pig4cloud.pigx.admin.api.dto.SysFileGroupDTO;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysFile;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysFileGroup;
|
||||
import com.pig4cloud.pigx.admin.service.SysFileService;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.log.annotation.SysLog;
|
||||
@@ -30,6 +32,7 @@ import com.pig4cloud.pigx.common.security.annotation.Inner;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springdoc.api.annotations.ParameterObject;
|
||||
@@ -39,7 +42,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 文件管理
|
||||
@@ -66,7 +69,9 @@ public class SysFileController {
|
||||
@GetMapping("/page")
|
||||
public R getSysFilePage(@ParameterObject Page page, @ParameterObject SysFile sysFile) {
|
||||
LambdaQueryWrapper<SysFile> wrapper = Wrappers.<SysFile>lambdaQuery()
|
||||
.like(StrUtil.isNotBlank(sysFile.getOriginal()), SysFile::getOriginal, sysFile.getOriginal());
|
||||
.eq(StrUtil.isNotBlank(sysFile.getType()), SysFile::getType, sysFile.getType())
|
||||
.eq(Objects.nonNull(sysFile.getGroupId()), SysFile::getGroupId, sysFile.getGroupId())
|
||||
.like(StrUtil.isNotBlank(sysFile.getOriginal()), SysFile::getOriginal, sysFile.getOriginal());
|
||||
return R.ok(sysFileService.page(page, wrapper));
|
||||
}
|
||||
|
||||
@@ -86,14 +91,21 @@ public class SysFileController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PutMapping("/rename")
|
||||
public R rename(@RequestBody SysFile sysFile) {
|
||||
return R.ok(sysFileService.updateById(sysFile));
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件 文件名采用uuid,避免原始文件名中带"-"符号导致下载的时候解析出现异常
|
||||
* @param file 资源
|
||||
* @return R(/ admin / bucketName / filename)
|
||||
*/
|
||||
@PostMapping(value = "/upload")
|
||||
public R upload(@RequestPart("file") MultipartFile file) {
|
||||
return sysFileService.uploadFile(file);
|
||||
public R upload(@RequestPart("file") MultipartFile file,
|
||||
@RequestParam(value = "groupId", required = false) Long groupId,
|
||||
@RequestParam(value = "type", required = false) String type) {
|
||||
return sysFileService.uploadFile(file, groupId, type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,4 +134,54 @@ public class SysFileController {
|
||||
IoUtil.copy(resource.getInputStream(), response.getOutputStream());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询文件组列表
|
||||
* @param fileGroup SysFileGroup对象,用于筛选条件
|
||||
* @return 包含文件组列表的R对象
|
||||
*/
|
||||
@GetMapping("/group/list")
|
||||
public R listGroup(SysFileGroup fileGroup) {
|
||||
return R.ok(sysFileService.listFileGroup(fileGroup));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加文件组
|
||||
* @param fileGroup SysFileGroup对象,要添加的文件组信息
|
||||
* @return 包含添加结果的R对象
|
||||
*/
|
||||
@PostMapping("/group/add")
|
||||
public R addGroup(@RequestBody SysFileGroup fileGroup) {
|
||||
return R.ok(sysFileService.saveOrUpdateGroup(fileGroup));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新文件组
|
||||
* @param fileGroup SysFileGroup对象,要更新的文件组信息
|
||||
* @return 包含更新结果的R对象
|
||||
*/
|
||||
@PutMapping("/group/update")
|
||||
public R updateGroup(@RequestBody SysFileGroup fileGroup) {
|
||||
return R.ok(sysFileService.saveOrUpdateGroup(fileGroup));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件组
|
||||
* @param id 待删除文件组的ID
|
||||
* @return 包含删除结果的R对象
|
||||
*/
|
||||
@DeleteMapping("/group/delete/{id}")
|
||||
public R updateGroup(@PathVariable Long id) {
|
||||
return R.ok(sysFileService.deleteGroup(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 移动文件组
|
||||
* @param fileGroupDTO SysFileGroupDTO对象,要移动的文件组信息
|
||||
* @return 包含移动结果的R对象
|
||||
*/
|
||||
@PutMapping("/group/move")
|
||||
public R moveFileGroup(@RequestBody SysFileGroupDTO fileGroupDTO) {
|
||||
return R.ok(sysFileService.moveFileGroup(fileGroupDTO));
|
||||
}
|
||||
|
||||
}
|
||||
+5
-3
@@ -18,6 +18,7 @@
|
||||
package com.pig4cloud.pigx.admin.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
@@ -85,7 +86,7 @@ public class SysI18nController {
|
||||
}
|
||||
|
||||
@GetMapping("/details")
|
||||
public R getDetails(SysI18nEntity entity) {
|
||||
public R getDetails(@ParameterObject SysI18nEntity entity) {
|
||||
return R.ok(sysI18nService.getOne(Wrappers.query(entity)));
|
||||
}
|
||||
|
||||
@@ -139,8 +140,9 @@ public class SysI18nController {
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('sys_i18n_export')")
|
||||
public List<SysI18nEntity> export(SysI18nEntity sysI18n) {
|
||||
return sysI18nService.list(Wrappers.query(sysI18n));
|
||||
public List<SysI18nEntity> export(SysI18nEntity sysI18n, Long[] ids) {
|
||||
return sysI18nService
|
||||
.list(Wrappers.lambdaQuery(sysI18n).in(ArrayUtil.isNotEmpty(ids), SysI18nEntity::getId, ids));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-2
@@ -39,6 +39,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -108,8 +109,8 @@ public class SysLogController {
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('sys_log_export')")
|
||||
public List<SysLog> export(SysLog sysLog) {
|
||||
return sysLogService.list(Wrappers.query(sysLog));
|
||||
public List<SysLog> export(SysLog sysLog, Long[] ids) {
|
||||
return sysLogService.list(Wrappers.lambdaQuery(sysLog).in(Objects.nonNull(ids), SysLog::getId, ids));
|
||||
}
|
||||
|
||||
}
|
||||
+4
-4
@@ -75,7 +75,7 @@ public class SysPostController {
|
||||
@PreAuthorize("@pms.hasPermission('sys_post_view')")
|
||||
public R getSysPostPage(@ParameterObject Page page, @ParameterObject SysPost sysPost) {
|
||||
return R.ok(sysPostService.page(page, Wrappers.<SysPost>lambdaQuery()
|
||||
.like(StrUtil.isNotBlank(sysPost.getPostName()), SysPost::getPostName, sysPost.getPostName())));
|
||||
.like(StrUtil.isNotBlank(sysPost.getPostName()), SysPost::getPostName, sysPost.getPostName())));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,7 +98,7 @@ public class SysPostController {
|
||||
@Operation(description = "查询角色信息", summary = "查询角色信息")
|
||||
@GetMapping("/details")
|
||||
@PreAuthorize("@pms.hasPermission('sys_post_view')")
|
||||
public R getDetails(SysPost query) {
|
||||
public R getDetails(@ParameterObject SysPost query) {
|
||||
return R.ok(sysPostService.getOne(Wrappers.query(query), false));
|
||||
}
|
||||
|
||||
@@ -148,8 +148,8 @@ public class SysPostController {
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('sys_post_export')")
|
||||
public List<PostExcelVO> export() {
|
||||
return sysPostService.listPost();
|
||||
public List<PostExcelVO> export(SysPost post, Long[] ids) {
|
||||
return sysPostService.listPost(post, ids);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+22
-8
@@ -17,6 +17,7 @@
|
||||
|
||||
package com.pig4cloud.pigx.admin.controller;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
@@ -65,6 +66,18 @@ public class SysPublicParamController {
|
||||
return R.ok(sysPublicParamService.getSysPublicParamKeyToValue(publicKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过key查询公共参数值
|
||||
* @param keys
|
||||
* @return
|
||||
*/
|
||||
@Inner(value = false)
|
||||
@Operation(description = "查询公共参数值", summary = "根据key查询公共参数值")
|
||||
@GetMapping("/publicValues")
|
||||
public R publicKeys(String[] keys) {
|
||||
return R.ok(sysPublicParamService.getSysPublicParamsKeyToValue(keys));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
@@ -75,12 +88,12 @@ public class SysPublicParamController {
|
||||
@GetMapping("/page")
|
||||
public R getSysPublicParamPage(@ParameterObject Page page, @ParameterObject SysPublicParam sysPublicParam) {
|
||||
LambdaUpdateWrapper<SysPublicParam> wrapper = Wrappers.<SysPublicParam>lambdaUpdate()
|
||||
.like(StrUtil.isNotBlank(sysPublicParam.getPublicName()), SysPublicParam::getPublicName,
|
||||
sysPublicParam.getPublicName())
|
||||
.like(StrUtil.isNotBlank(sysPublicParam.getPublicKey()), SysPublicParam::getPublicKey,
|
||||
sysPublicParam.getPublicKey())
|
||||
.eq(StrUtil.isNotBlank(sysPublicParam.getSystemFlag()), SysPublicParam::getSystemFlag,
|
||||
sysPublicParam.getSystemFlag());
|
||||
.like(StrUtil.isNotBlank(sysPublicParam.getPublicName()), SysPublicParam::getPublicName,
|
||||
sysPublicParam.getPublicName())
|
||||
.like(StrUtil.isNotBlank(sysPublicParam.getPublicKey()), SysPublicParam::getPublicKey,
|
||||
sysPublicParam.getPublicKey())
|
||||
.eq(StrUtil.isNotBlank(sysPublicParam.getSystemFlag()), SysPublicParam::getSystemFlag,
|
||||
sysPublicParam.getSystemFlag());
|
||||
|
||||
return R.ok(sysPublicParamService.page(page, wrapper));
|
||||
}
|
||||
@@ -147,8 +160,9 @@ public class SysPublicParamController {
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('sys_syspublicparam_edit')")
|
||||
public List<SysPublicParam> export() {
|
||||
return sysPublicParamService.list();
|
||||
public List<SysPublicParam> export(SysPublicParam param, Long[] ids) {
|
||||
return sysPublicParamService
|
||||
.list(Wrappers.lambdaQuery(param).in(ArrayUtil.isNotEmpty(ids), SysPublicParam::getPublicId, ids));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+6
-4
@@ -34,6 +34,7 @@ import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;
|
||||
import com.pig4cloud.pigx.common.log.annotation.SysLog;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import javax.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springdoc.api.annotations.ParameterObject;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@@ -42,7 +43,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -135,7 +135,7 @@ public class SysRoleController {
|
||||
@GetMapping("/page")
|
||||
public R getRolePage(Page page, SysRole role) {
|
||||
return R.ok(sysRoleService.page(page, Wrappers.<SysRole>lambdaQuery()
|
||||
.like(StrUtil.isNotBlank(role.getRoleName()), SysRole::getRoleName, role.getRoleName())));
|
||||
.like(StrUtil.isNotBlank(role.getRoleName()), SysRole::getRoleName, role.getRoleName())));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -162,13 +162,15 @@ public class SysRoleController {
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
* @param sysRole 查询条件
|
||||
* @param ids 导出ids
|
||||
* @return
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('sys_role_export')")
|
||||
public List<RoleExcelVO> export() {
|
||||
return sysRoleService.listRole();
|
||||
public List<RoleExcelVO> export(SysRole sysRole, Long[] ids) {
|
||||
return sysRoleService.listRole(sysRole, ids);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+6
-4
@@ -18,6 +18,7 @@
|
||||
package com.pig4cloud.pigx.admin.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysSocialDetails;
|
||||
@@ -28,6 +29,7 @@ import com.pig4cloud.pigx.common.log.annotation.SysLog;
|
||||
import com.pig4cloud.pigx.common.security.annotation.Inner;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import javax.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springdoc.api.annotations.ParameterObject;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
@@ -35,7 +37,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -72,7 +73,7 @@ public class SysSocialDetailsController {
|
||||
@GetMapping("/{type}")
|
||||
public R getByType(@PathVariable("type") String type) {
|
||||
return R.ok(sysSocialDetailsService
|
||||
.list(Wrappers.<SysSocialDetails>lambdaQuery().eq(SysSocialDetails::getType, type)));
|
||||
.list(Wrappers.<SysSocialDetails>lambdaQuery().eq(SysSocialDetails::getType, type)));
|
||||
}
|
||||
|
||||
@GetMapping("/getById/{id}")
|
||||
@@ -143,8 +144,9 @@ public class SysSocialDetailsController {
|
||||
* 导出
|
||||
*/
|
||||
@GetMapping("/export")
|
||||
public List<SysSocialDetails> export(SysSocialDetails sysSocialDetails) {
|
||||
return sysSocialDetailsService.list(Wrappers.query(sysSocialDetails));
|
||||
public List<SysSocialDetails> export(SysSocialDetails sysSocialDetails, Long[] ids) {
|
||||
return sysSocialDetailsService
|
||||
.list(Wrappers.lambdaQuery(sysSocialDetails).in(ArrayUtil.isNotEmpty(ids), SysSocialDetails::getId, ids));
|
||||
}
|
||||
|
||||
}
|
||||
+29
-8
@@ -18,13 +18,18 @@
|
||||
package com.pig4cloud.pigx.admin.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysTenant;
|
||||
import com.pig4cloud.pigx.admin.service.SysMenuService;
|
||||
import com.pig4cloud.pigx.admin.service.SysTenantService;
|
||||
import com.pig4cloud.pigx.common.core.constant.CacheConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.data.resolver.ParamResolver;
|
||||
import com.pig4cloud.pigx.common.data.tenant.TenantBroker;
|
||||
import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;
|
||||
import com.pig4cloud.pigx.common.log.annotation.SysLog;
|
||||
import com.pig4cloud.pigx.common.security.annotation.Inner;
|
||||
@@ -38,6 +43,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -56,6 +62,8 @@ public class SysTenantController {
|
||||
|
||||
private final SysTenantService sysTenantService;
|
||||
|
||||
private final SysMenuService sysMenuService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
@@ -65,7 +73,7 @@ public class SysTenantController {
|
||||
@GetMapping("/page")
|
||||
public R getSysTenantPage(@ParameterObject Page page, @ParameterObject SysTenant sysTenant) {
|
||||
return R.ok(sysTenantService.page(page, Wrappers.<SysTenant>lambdaQuery()
|
||||
.like(StrUtil.isNotBlank(sysTenant.getName()), SysTenant::getName, sysTenant.getName())));
|
||||
.like(StrUtil.isNotBlank(sysTenant.getName()), SysTenant::getName, sysTenant.getName())));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,9 +117,8 @@ public class SysTenantController {
|
||||
@SysLog("修改租户")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('sys_systenant_edit')")
|
||||
@CacheEvict(value = CacheConstants.TENANT_DETAILS, allEntries = true)
|
||||
public R updateById(@RequestBody SysTenant sysTenant) {
|
||||
return R.ok(sysTenantService.updateById(sysTenant));
|
||||
return R.ok(sysTenantService.updateTenant(sysTenant));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,9 +143,11 @@ public class SysTenantController {
|
||||
@Inner(value = false)
|
||||
@GetMapping("/list")
|
||||
public R list() {
|
||||
List<SysTenant> tenants = sysTenantService.getNormalTenant().stream()
|
||||
.filter(tenant -> tenant.getStartTime().isBefore(LocalDateTime.now()))
|
||||
.filter(tenant -> tenant.getEndTime().isAfter(LocalDateTime.now())).collect(Collectors.toList());
|
||||
List<SysTenant> tenants = sysTenantService.getNormalTenant()
|
||||
.stream()
|
||||
.filter(tenant -> tenant.getStartTime().isBefore(LocalDateTime.now()))
|
||||
.filter(tenant -> tenant.getEndTime().isAfter(LocalDateTime.now()))
|
||||
.collect(Collectors.toList());
|
||||
return R.ok(tenants);
|
||||
}
|
||||
|
||||
@@ -149,8 +158,20 @@ public class SysTenantController {
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('sys_systenant_export')")
|
||||
public List<SysTenant> export(SysTenant sysTenant) {
|
||||
return sysTenantService.list(Wrappers.query(sysTenant));
|
||||
public List<SysTenant> export(SysTenant sysTenant, Long[] ids) {
|
||||
return sysTenantService
|
||||
.list(Wrappers.lambdaQuery(sysTenant).in(ArrayUtil.isNotEmpty(ids), SysTenant::getId, ids));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/tree/menu")
|
||||
public R getTree() {
|
||||
Long defaultId = ParamResolver.getLong("TENANT_DEFAULT_ID", 1L);
|
||||
List<Tree<Long>> trees = new ArrayList<>();
|
||||
TenantBroker.runAs(defaultId, (id) -> {
|
||||
trees.addAll(sysMenuService.treeMenu(null, null, null));
|
||||
});
|
||||
|
||||
return R.ok(trees);
|
||||
}
|
||||
|
||||
}
|
||||
-122
@@ -1,122 +0,0 @@
|
||||
package com.pig4cloud.pigx.admin.controller;
|
||||
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysTenantMenu;
|
||||
import com.pig4cloud.pigx.admin.service.SysMenuService;
|
||||
import com.pig4cloud.pigx.admin.service.SysTenantMenuService;
|
||||
import com.pig4cloud.pigx.common.core.constant.CacheConstants;
|
||||
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.data.resolver.ParamResolver;
|
||||
import com.pig4cloud.pigx.common.data.tenant.TenantBroker;
|
||||
import com.pig4cloud.pigx.common.log.annotation.SysLog;
|
||||
import com.pig4cloud.pigx.common.security.annotation.Inner;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springdoc.api.annotations.ParameterObject;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/tenant-menu")
|
||||
@Tag(description = "tenant", name = "租户菜单管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class SysTenantMenuController {
|
||||
|
||||
private final SysTenantMenuService sysTenantMenuService;
|
||||
|
||||
private final SysMenuService sysMenuService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
* @param sysTenantMenu 租户菜单
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public R getSysTenantPage(@ParameterObject Page page, @ParameterObject SysTenantMenu sysTenantMenu) {
|
||||
return R.ok(sysTenantMenuService.page(page, Wrappers.query(sysTenantMenu)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询租户信息
|
||||
* @param sysTenantMenu 查询条件
|
||||
* @return 租户信息
|
||||
*/
|
||||
@GetMapping
|
||||
public R getByObj(@ParameterObject SysTenantMenu sysTenantMenu) {
|
||||
return R.ok(sysTenantMenuService.list(Wrappers.query(sysTenantMenu)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增租户
|
||||
* @param sysTenantMenu 租户
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("新增租户")
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('sys_systenantmenu_add')")
|
||||
@CacheEvict(value = CacheConstants.TENANT_DETAILS, allEntries = true)
|
||||
public R save(@RequestBody SysTenantMenu sysTenantMenu) {
|
||||
return R.ok(sysTenantMenuService.saveTenant(sysTenantMenu));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改租户
|
||||
* @param sysTenantMenu 租户
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("修改租户")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('sys_systenantmenu_edit')")
|
||||
@CacheEvict(value = CacheConstants.TENANT_DETAILS, allEntries = true)
|
||||
public R updateById(@RequestBody SysTenantMenu sysTenantMenu) {
|
||||
return R.ok(sysTenantMenuService.updateById(sysTenantMenu));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除租户
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("删除租户")
|
||||
@DeleteMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('sys_systenantmenu_del')")
|
||||
@CacheEvict(value = CacheConstants.TENANT_DETAILS, allEntries = true)
|
||||
public R removeById(@PathVariable Long id) {
|
||||
return R.ok(sysTenantMenuService.removeById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部有效的租户
|
||||
* @return
|
||||
*/
|
||||
@Inner(value = false)
|
||||
@GetMapping("/list")
|
||||
public R list() {
|
||||
List<SysTenantMenu> tenants = sysTenantMenuService.list(
|
||||
Wrappers.<SysTenantMenu>lambdaQuery().eq(SysTenantMenu::getStatus, CommonConstants.STATUS_NORMAL));
|
||||
return R.ok(tenants);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/tree/menu")
|
||||
public R getTree() {
|
||||
Long defaultId = ParamResolver.getLong("TENANT_DEFAULT_ID", 1L);
|
||||
List<Tree<Long>> trees = new ArrayList<>();
|
||||
TenantBroker.runAs(defaultId, (id) -> {
|
||||
trees.addAll(sysMenuService.treeMenu(null, null, null));
|
||||
});
|
||||
|
||||
return R.ok(trees);
|
||||
}
|
||||
|
||||
}
|
||||
+70
-24
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.pig4cloud.pigx.admin.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pig4cloud.pigx.admin.api.dto.UserDTO;
|
||||
@@ -37,6 +38,7 @@ import com.pig4cloud.pigx.common.security.util.SecurityUtils;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import javax.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springdoc.api.annotations.ParameterObject;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
@@ -44,7 +46,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -135,18 +136,6 @@ public class SysUserController {
|
||||
return R.ok(userService.saveUser(userDto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户信息
|
||||
* @param userDto 用户信息
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("更新用户信息")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('sys_user_edit')")
|
||||
public R updateUser(@Valid @RequestBody UserDTO userDto) {
|
||||
return R.ok(userService.updateUser(userDto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询用户
|
||||
* @param page 参数集
|
||||
@@ -159,16 +148,40 @@ public class SysUserController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改个人信息
|
||||
* 管理员更新用户信息
|
||||
* @param userDto 用户信息
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("更新用户信息")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('sys_user_edit')")
|
||||
public R updateUser(@Valid @RequestBody UserDTO userDto) {
|
||||
return R.ok(userService.updateUser(userDto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改个人信息 (当前用户)
|
||||
* @param userDto userDto
|
||||
* @return success/false
|
||||
*/
|
||||
@SysLog("修改个人信息")
|
||||
@PutMapping("/edit")
|
||||
@PutMapping("/personal/edit")
|
||||
public R updateUserInfo(@Valid @RequestBody UserDTO userDto) {
|
||||
return userService.updateUserInfo(userDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改个人密码 (当前用户)
|
||||
* @param userDto 用户DTO对象,包含需要修改密码的用户信息
|
||||
* @return R 返回结果对象,包含修改密码操作的结果信息
|
||||
*/
|
||||
@PutMapping("/personal/password")
|
||||
public R updatePassword(@RequestBody UserDTO userDto) {
|
||||
String username = SecurityUtils.getUser().getUsername();
|
||||
userDto.setUsername(username);
|
||||
return userService.changePassword(userDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param username 用户名称
|
||||
* @return 上级部门用户列表
|
||||
@@ -186,8 +199,8 @@ public class SysUserController {
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('sys_user_export')")
|
||||
public List export(UserDTO userDTO) {
|
||||
return userService.listUser(userDTO);
|
||||
public List export(UserDTO userDTO, Long[] ids) {
|
||||
return userService.listUser(userDTO, ids);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,21 +226,54 @@ public class SysUserController {
|
||||
return userService.lockUser(username);
|
||||
}
|
||||
|
||||
@PutMapping("/password")
|
||||
public R password(@RequestBody UserDTO userDto) {
|
||||
String username = SecurityUtils.getUser().getUsername();
|
||||
userDto.setUsername(username);
|
||||
return userService.changePassword(userDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解绑定接口
|
||||
* @param type 需要解绑定的类型
|
||||
* @return R 返回结果对象,包含解绑定操作的结果信息
|
||||
*/
|
||||
@PostMapping("/unbinding")
|
||||
public R unbinding(String type) {
|
||||
return userService.unbinding(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验密码接口
|
||||
* @param password 需要校验的密码
|
||||
* @return R 返回结果对象,包含校验密码操作的结果信息
|
||||
*/
|
||||
@PostMapping("/check")
|
||||
public R check(String password) {
|
||||
return userService.checkPassword(password);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色ID列表获取用户ID列表接口
|
||||
* @param roleIdList 角色ID列表
|
||||
* @return R 返回结果对象,包含根据角色ID列表获取到的用户ID列表信息
|
||||
*/
|
||||
@GetMapping("/getUserIdListByRoleIdList")
|
||||
public R<List<Long>> getUserIdListByRoleIdList(Long[] roleIdList) {
|
||||
return R.ok(userService.listUserIdByRoleIds(CollUtil.toList(roleIdList)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据部门ID列表获取用户ID列表接口
|
||||
* @param deptIdList 部门ID列表
|
||||
* @return R 返回结果对象,包含根据部门ID列表获取到的用户ID列表信息
|
||||
*/
|
||||
@GetMapping("/getUserIdListByDeptIdList")
|
||||
public R<List<SysUser>> getUserIdListByDeptIdList(Long[] deptIdList) {
|
||||
return R.ok(userService.listUserIdByDeptIds(CollUtil.toList(deptIdList)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户名获取用户列表
|
||||
* @param username 用户名
|
||||
* @return 用户列表
|
||||
*/
|
||||
@GetMapping("/getUserListByUserName")
|
||||
public R<List<SysUser>> getUserListByUserName(String username) {
|
||||
return R.ok(userService.list(Wrappers.<SysUser>lambdaQuery().like(SysUser::getUsername, username)));
|
||||
}
|
||||
|
||||
}
|
||||
+10
-18
@@ -15,27 +15,19 @@
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pigx.act.dto;
|
||||
package com.pig4cloud.pigx.admin.mapper;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysFileGroup;
|
||||
import com.pig4cloud.pigx.common.data.datascope.PigxBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @Author felixu
|
||||
* @Date 2018.08.14
|
||||
* 文件分组管理
|
||||
*
|
||||
* @author lbw
|
||||
* @date 2023年07月25日21:31:48
|
||||
*/
|
||||
@Data
|
||||
public class StartTaskForm {
|
||||
|
||||
@NotEmpty
|
||||
public String procDefKey;
|
||||
|
||||
public String entityId;
|
||||
|
||||
@NotEmpty
|
||||
public String title;
|
||||
|
||||
public String comment;
|
||||
@Mapper
|
||||
public interface SysFileGroupMapper extends PigxBaseMapper<SysFileGroup> {
|
||||
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
package com.pig4cloud.pigx.admin.mapper;
|
||||
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysTenantMenu;
|
||||
import com.pig4cloud.pigx.common.data.datascope.PigxBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface SysTenantMenuMapper extends PigxBaseMapper<SysTenantMenu> {
|
||||
|
||||
}
|
||||
+1
-1
@@ -71,6 +71,6 @@ public interface SysUserMapper extends PigxBaseMapper<SysUser> {
|
||||
* @param dataScope 数据权限声明
|
||||
* @return
|
||||
*/
|
||||
List<UserVO> selectVoListByScope(@Param("query") UserDTO userDTO, DataScope dataScope);
|
||||
List<UserVO> selectVoListByScope(@Param("query") UserDTO userDTO, @Param("ids") Long[] ids, DataScope dataScope);
|
||||
|
||||
}
|
||||
+8
-1
@@ -43,7 +43,7 @@ public interface SysDeptService extends IService<SysDept> {
|
||||
* @param deptName 部门名称
|
||||
* @return 树
|
||||
*/
|
||||
List<Tree<Long>> selectTree(String deptName);
|
||||
List<Tree<Long>> selectTree(String deptName, Long parentId);
|
||||
|
||||
/**
|
||||
* 删除部门
|
||||
@@ -63,4 +63,11 @@ public interface SysDeptService extends IService<SysDept> {
|
||||
*/
|
||||
List<SysDept> listDescendant(Long deptId);
|
||||
|
||||
/**
|
||||
* 获取部门负责人
|
||||
* @param deptId deptId
|
||||
* @return user id list
|
||||
*/
|
||||
List<Long> listDeptLeader(Long deptId);
|
||||
|
||||
}
|
||||
+36
-1
@@ -17,13 +17,18 @@
|
||||
|
||||
package com.pig4cloud.pigx.admin.service;
|
||||
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.pig4cloud.pigx.admin.api.dto.SysFileGroupDTO;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysFile;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysFileGroup;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文件管理
|
||||
*
|
||||
@@ -35,9 +40,11 @@ public interface SysFileService extends IService<SysFile> {
|
||||
/**
|
||||
* 上传文件
|
||||
* @param file
|
||||
* @param groupId
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
R uploadFile(MultipartFile file);
|
||||
R uploadFile(MultipartFile file, Long groupId, String type);
|
||||
|
||||
/**
|
||||
* 读取文件
|
||||
@@ -54,4 +61,32 @@ public interface SysFileService extends IService<SysFile> {
|
||||
*/
|
||||
Boolean deleteFile(Long id);
|
||||
|
||||
/**
|
||||
* 查询文件组列表
|
||||
* @param fileGroup SysFileGroup对象,用于筛选条件
|
||||
* @return 包含文件组列表的Tree对象列表
|
||||
*/
|
||||
List<Tree<Long>> listFileGroup(SysFileGroup fileGroup);
|
||||
|
||||
/**
|
||||
* 添加或更新文件组
|
||||
* @param fileGroup SysFileGroup对象,要添加或更新的文件组信息
|
||||
* @return 添加或更新成功返回true,否则返回false
|
||||
*/
|
||||
Boolean saveOrUpdateGroup(SysFileGroup fileGroup);
|
||||
|
||||
/**
|
||||
* 删除文件组
|
||||
* @param id 待删除文件组的ID
|
||||
* @return 删除成功返回true,否则返回false
|
||||
*/
|
||||
Boolean deleteGroup(Long id);
|
||||
|
||||
/**
|
||||
* 移动文件组
|
||||
* @param fileGroupDTO SysFileGroupDTO对象,要移动的文件组信息
|
||||
* @return 移动成功返回true,否则返回false
|
||||
*/
|
||||
Boolean moveFileGroup(SysFileGroupDTO fileGroupDTO);
|
||||
|
||||
}
|
||||
+1
-1
@@ -37,7 +37,7 @@ public interface SysPostService extends IService<SysPost> {
|
||||
* 导出excel 表格
|
||||
* @return
|
||||
*/
|
||||
List<PostExcelVO> listPost();
|
||||
List<PostExcelVO> listPost(SysPost post, Long[] ids);
|
||||
|
||||
/**
|
||||
* 导入岗位
|
||||
|
||||
+9
@@ -21,6 +21,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysPublicParam;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 公共参数配置
|
||||
*
|
||||
@@ -36,6 +38,13 @@ public interface SysPublicParamService extends IService<SysPublicParam> {
|
||||
*/
|
||||
String getSysPublicParamKeyToValue(String publicKey);
|
||||
|
||||
/**
|
||||
* 通过key查询公共参数指定值
|
||||
* @param keys 参数列表
|
||||
* @return Map
|
||||
*/
|
||||
Map<String, Object> getSysPublicParamsKeyToValue(String[] keys);
|
||||
|
||||
/**
|
||||
* 更新参数
|
||||
* @param sysPublicParam
|
||||
|
||||
+3
-1
@@ -77,8 +77,10 @@ public interface SysRoleService extends IService<SysRole> {
|
||||
|
||||
/**
|
||||
* 查询全部的角色
|
||||
* @param sysRole 查询条件
|
||||
* @param ids 导出ids
|
||||
* @return list
|
||||
*/
|
||||
List<RoleExcelVO> listRole();
|
||||
List<RoleExcelVO> listRole(SysRole sysRole, Long[] ids);
|
||||
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
package com.pig4cloud.pigx.admin.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysTenantMenu;
|
||||
|
||||
public interface SysTenantMenuService extends IService<SysTenantMenu> {
|
||||
|
||||
Boolean saveTenant(SysTenantMenu sysTenantMenu);
|
||||
|
||||
}
|
||||
+7
@@ -43,4 +43,11 @@ public interface SysTenantService extends IService<SysTenant> {
|
||||
*/
|
||||
Boolean saveTenant(SysTenant sysTenant);
|
||||
|
||||
/**
|
||||
* 修改租户
|
||||
* @param sysTenant
|
||||
* @return
|
||||
*/
|
||||
Boolean updateTenant(SysTenant sysTenant);
|
||||
|
||||
}
|
||||
+16
-1
@@ -98,9 +98,10 @@ public interface SysUserService extends IService<SysUser> {
|
||||
/**
|
||||
* 查询全部的用户
|
||||
* @param userDTO 查询条件
|
||||
* @param ids 目标列表
|
||||
* @return list
|
||||
*/
|
||||
List<UserExcelVO> listUser(UserDTO userDTO);
|
||||
List<UserExcelVO> listUser(UserDTO userDTO, Long[] ids);
|
||||
|
||||
/**
|
||||
* excel 导入用户
|
||||
@@ -130,4 +131,18 @@ public interface SysUserService extends IService<SysUser> {
|
||||
|
||||
R checkPassword(String password);
|
||||
|
||||
/**
|
||||
* 根据角色ID列表获取用户ID列表接口
|
||||
* @param roleIdList 角色ID列表
|
||||
* @return List<Long> 返回结果对象,包含根据角色ID列表获取到的用户ID列表信息
|
||||
*/
|
||||
List<Long> listUserIdByRoleIds(List<Long> roleIdList);
|
||||
|
||||
/**
|
||||
* 根据部门ID列表获取用户ID列表接口
|
||||
* @param deptIdList 部门ID列表
|
||||
* @return List<Long> 返回结果对象,包含根据部门ID列表获取到的用户ID列表信息
|
||||
*/
|
||||
List<SysUser> listUserIdByDeptIds(List<Long> deptIdList);
|
||||
|
||||
}
|
||||
+75
-25
@@ -27,8 +27,14 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysDept;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysPost;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysUser;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysUserPost;
|
||||
import com.pig4cloud.pigx.admin.api.vo.DeptExcelVo;
|
||||
import com.pig4cloud.pigx.admin.mapper.SysDeptMapper;
|
||||
import com.pig4cloud.pigx.admin.mapper.SysPostMapper;
|
||||
import com.pig4cloud.pigx.admin.mapper.SysUserMapper;
|
||||
import com.pig4cloud.pigx.admin.mapper.SysUserPostMapper;
|
||||
import com.pig4cloud.pigx.admin.service.SysDeptService;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.data.datascope.DataScope;
|
||||
@@ -54,8 +60,14 @@ import java.util.stream.Collectors;
|
||||
@AllArgsConstructor
|
||||
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements SysDeptService {
|
||||
|
||||
private final SysUserMapper userMapper;
|
||||
|
||||
private final SysDeptMapper deptMapper;
|
||||
|
||||
private final SysPostMapper postMapper;
|
||||
|
||||
private final SysUserPostMapper userPostMapper;
|
||||
|
||||
/**
|
||||
* 删除部门
|
||||
* @param id 部门 ID
|
||||
@@ -75,34 +87,41 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
/**
|
||||
* 查询全部部门树
|
||||
* @param deptName
|
||||
* @param parentId
|
||||
* @return 树 部门名称
|
||||
*/
|
||||
@Override
|
||||
public List<Tree<Long>> selectTree(String deptName) {
|
||||
public List<Tree<Long>> selectTree(String deptName, Long parentId) {
|
||||
// 查询全部部门
|
||||
List<SysDept> deptAllList = deptMapper.selectList(
|
||||
Wrappers.<SysDept>lambdaQuery().like(StrUtil.isNotBlank(deptName), SysDept::getName, deptName));
|
||||
List<SysDept> deptAllList = deptMapper
|
||||
.selectList(Wrappers.<SysDept>lambdaQuery().like(StrUtil.isNotBlank(deptName), SysDept::getName, deptName));
|
||||
// 查询数据权限内部门
|
||||
List<Long> deptOwnIdList = deptMapper.selectListByScope(
|
||||
Wrappers.<SysDept>lambdaQuery().like(StrUtil.isNotBlank(deptName), SysDept::getName, deptName),
|
||||
DataScope.of()).stream().map(SysDept::getDeptId).collect(Collectors.toList());
|
||||
List<Long> deptOwnIdList = deptMapper
|
||||
.selectListByScope(
|
||||
Wrappers.<SysDept>lambdaQuery().like(StrUtil.isNotBlank(deptName), SysDept::getName, deptName),
|
||||
DataScope.of())
|
||||
.stream()
|
||||
.map(SysDept::getDeptId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 权限内部门
|
||||
List<TreeNode<Long>> collect = deptAllList.stream()
|
||||
.filter(dept -> dept.getDeptId().intValue() != dept.getParentId())
|
||||
.sorted(Comparator.comparingInt(SysDept::getSortOrder)).map(dept -> {
|
||||
TreeNode<Long> treeNode = new TreeNode();
|
||||
treeNode.setId(dept.getDeptId());
|
||||
treeNode.setParentId(dept.getParentId());
|
||||
treeNode.setName(dept.getName());
|
||||
treeNode.setWeight(dept.getSortOrder());
|
||||
// 有权限不返回标识
|
||||
Map<String, Object> extra = new HashMap<>(8);
|
||||
extra.put("isLock", !deptOwnIdList.contains(dept.getDeptId()));
|
||||
extra.put("createTime", dept.getCreateTime());
|
||||
treeNode.setExtra(extra);
|
||||
return treeNode;
|
||||
}).collect(Collectors.toList());
|
||||
.filter(dept -> dept.getDeptId().intValue() != dept.getParentId())
|
||||
.sorted(Comparator.comparingInt(SysDept::getSortOrder))
|
||||
.map(dept -> {
|
||||
TreeNode<Long> treeNode = new TreeNode<>();
|
||||
treeNode.setId(dept.getDeptId());
|
||||
treeNode.setParentId(dept.getParentId());
|
||||
treeNode.setName(dept.getName());
|
||||
treeNode.setWeight(dept.getSortOrder());
|
||||
// 有权限不返回标识
|
||||
Map<String, Object> extra = new HashMap<>(8);
|
||||
extra.put("isLock", !deptOwnIdList.contains(dept.getDeptId()));
|
||||
extra.put("createTime", dept.getCreateTime());
|
||||
treeNode.setExtra(extra);
|
||||
return treeNode;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 模糊查询 不组装树结构 直接返回 表格方便编辑
|
||||
if (StrUtil.isNotBlank(deptName)) {
|
||||
@@ -114,7 +133,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return TreeUtil.build(collect, 0L);
|
||||
return TreeUtil.build(collect, parentId == null ? 0 : parentId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,8 +146,11 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
List<DeptExcelVo> deptExcelVos = list.stream().map(item -> {
|
||||
DeptExcelVo deptExcelVo = new DeptExcelVo();
|
||||
deptExcelVo.setName(item.getName());
|
||||
Optional<String> first = this.list().stream().filter(it -> item.getParentId().equals(it.getDeptId()))
|
||||
.map(SysDept::getName).findFirst();
|
||||
Optional<String> first = this.list()
|
||||
.stream()
|
||||
.filter(it -> item.getParentId().equals(it.getDeptId()))
|
||||
.map(SysDept::getName)
|
||||
.findFirst();
|
||||
deptExcelVo.setParentName(first.orElse("根部门"));
|
||||
deptExcelVo.setSortOrder(item.getSortOrder());
|
||||
return deptExcelVo;
|
||||
@@ -188,11 +210,39 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
recursiveDept(allDeptList, deptId, resDeptList);
|
||||
|
||||
// 添加当前节点
|
||||
resDeptList.addAll(allDeptList.stream().filter(sysDept -> deptId.equals(sysDept.getDeptId()))
|
||||
.collect(Collectors.toList()));
|
||||
resDeptList.addAll(allDeptList.stream().filter(sysDept -> deptId.equals(sysDept.getDeptId())).collect(Collectors.toList()));
|
||||
return resDeptList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门负责人
|
||||
*
|
||||
* 1. 根据dept 查询用户 2. 筛选用户列表中 post
|
||||
* @param deptId deptId
|
||||
* @return user id list
|
||||
*/
|
||||
@Override
|
||||
public List<Long> listDeptLeader(Long deptId) {
|
||||
List<SysUser> sysUserList = userMapper
|
||||
.selectList(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getDeptId, deptId));
|
||||
if (CollUtil.isEmpty(sysUserList)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
SysPost deptLeader = postMapper
|
||||
.selectOne(Wrappers.<SysPost>lambdaQuery().eq(SysPost::getPostCode, "DEPT_LEADER"));
|
||||
if (deptLeader == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Long> userIdList = sysUserList.stream().map(SysUser::getUserId).collect(Collectors.toList());
|
||||
return userPostMapper.selectList(Wrappers.<SysUserPost>lambdaQuery().in(SysUserPost::getUserId, userIdList))
|
||||
.stream()
|
||||
.filter(post -> Objects.equals(post.getPostId(), deptLeader.getPostId()))
|
||||
.map(SysUserPost::getUserId)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归查询所有子节点。
|
||||
* @param allDeptList 所有部门列表
|
||||
|
||||
+106
-12
@@ -16,18 +16,28 @@
|
||||
*/
|
||||
package com.pig4cloud.pigx.admin.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.lang.tree.TreeNode;
|
||||
import cn.hutool.core.lang.tree.TreeUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.amazonaws.services.s3.model.S3Object;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.pig4cloud.pigx.admin.api.dto.SysFileGroupDTO;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysFile;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysFileGroup;
|
||||
import com.pig4cloud.pigx.admin.mapper.SysFileGroupMapper;
|
||||
import com.pig4cloud.pigx.admin.mapper.SysFileMapper;
|
||||
import com.pig4cloud.pigx.admin.service.SysFileService;
|
||||
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.file.core.FileProperties;
|
||||
import com.pig4cloud.pigx.common.file.core.FileTemplate;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -35,11 +45,10 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 文件管理
|
||||
@@ -54,15 +63,19 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> impl
|
||||
|
||||
private final FileTemplate fileTemplate;
|
||||
|
||||
private final SysFileGroupMapper fileGroupMapper;
|
||||
|
||||
private final FileProperties properties;
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
* @param file
|
||||
* @param groupId
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R uploadFile(MultipartFile file) {
|
||||
public R uploadFile(MultipartFile file, Long groupId, String type) {
|
||||
String fileName = IdUtil.simpleUUID() + StrUtil.DOT + FileUtil.extName(file.getOriginalFilename());
|
||||
Map<String, String> resultMap = new HashMap<>(4);
|
||||
resultMap.put("bucketName", properties.getBucketName());
|
||||
@@ -72,7 +85,7 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> impl
|
||||
try (InputStream inputStream = file.getInputStream()) {
|
||||
fileTemplate.putObject(properties.getBucketName(), fileName, inputStream, file.getContentType());
|
||||
// 文件管理数据记录,收集管理追踪文件
|
||||
fileLog(file, fileName);
|
||||
fileLog(file, fileName, groupId, type);
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("上传失败", e);
|
||||
@@ -116,17 +129,98 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> impl
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件管理数据记录,收集管理追踪文件
|
||||
* @param file 上传文件格式
|
||||
* @param fileName 文件名
|
||||
* 查询文件组列表
|
||||
* @param fileGroup SysFileGroup对象,用于筛选条件
|
||||
* @return 包含文件组树形结构列表的List对象
|
||||
*/
|
||||
private void fileLog(MultipartFile file, String fileName) {
|
||||
@Override
|
||||
public List<Tree<Long>> listFileGroup(SysFileGroup fileGroup) {
|
||||
// 从数据库查询文件组列表
|
||||
List<TreeNode<Long>> treeNodeList = fileGroupMapper.selectList(Wrappers.query(fileGroup))
|
||||
.stream()
|
||||
.map(group -> {
|
||||
TreeNode<Long> treeNode = new TreeNode<>();
|
||||
treeNode.setName(group.getName());
|
||||
treeNode.setId(group.getId());
|
||||
treeNode.setParentId(group.getPid());
|
||||
return treeNode;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 构建树形结构
|
||||
List<Tree<Long>> treeList = TreeUtil.build(treeNodeList, CommonConstants.MENU_TREE_ROOT_ID);
|
||||
return CollUtil.isEmpty(treeList) ? new ArrayList<>() : treeList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加或更新文件组
|
||||
* @param fileGroup SysFileGroup对象,要添加或更新的文件组信息
|
||||
* @return 添加或更新成功返回true,否则返回false
|
||||
*/
|
||||
@Override
|
||||
public Boolean saveOrUpdateGroup(SysFileGroup fileGroup) {
|
||||
if (Objects.isNull(fileGroup.getId())) {
|
||||
// 插入文件组
|
||||
fileGroupMapper.insert(fileGroup);
|
||||
}
|
||||
else {
|
||||
// 更新文件组
|
||||
fileGroupMapper.updateById(fileGroup);
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件组
|
||||
* @param id 待删除文件组的ID
|
||||
* @return 删除成功返回true,否则返回false
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteGroup(Long id) {
|
||||
// 根据ID删除文件组
|
||||
fileGroupMapper.deleteById(id);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 移动文件组
|
||||
* @param fileGroupDTO SysFileGroupDTO对象,要移动的文件组信息
|
||||
* @return 移动成功返回true,否则返回false
|
||||
*/
|
||||
@Override
|
||||
public Boolean moveFileGroup(SysFileGroupDTO fileGroupDTO) {
|
||||
// 创建SysFile对象并设置groupId属性
|
||||
SysFile file = new SysFile();
|
||||
file.setGroupId(fileGroupDTO.getGroupId());
|
||||
|
||||
// 根据IDS更新对应的SysFile记录
|
||||
baseMapper.update(file, Wrappers.<SysFile>lambdaQuery().in(SysFile::getId, fileGroupDTO.getIds()));
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件管理数据记录,收集管理追踪文件
|
||||
* @param file 上传的文件格式
|
||||
* @param fileName 文件名
|
||||
* @param groupId 文件组ID
|
||||
* @param type 文件类型
|
||||
*/
|
||||
private void fileLog(MultipartFile file, String fileName, Long groupId, String type) {
|
||||
// 创建SysFile对象并设置相关属性
|
||||
SysFile sysFile = new SysFile();
|
||||
sysFile.setFileName(fileName);
|
||||
sysFile.setOriginal(file.getOriginalFilename());
|
||||
|
||||
// 对原始文件名进行编码转换
|
||||
String originalFilename = new String(
|
||||
Objects.requireNonNull(file.getOriginalFilename()).getBytes(StandardCharsets.ISO_8859_1),
|
||||
StandardCharsets.UTF_8);
|
||||
sysFile.setOriginal(originalFilename);
|
||||
sysFile.setFileSize(file.getSize());
|
||||
sysFile.setType(FileUtil.extName(file.getOriginalFilename()));
|
||||
sysFile.setBucketName(properties.getBucketName());
|
||||
sysFile.setType(type);
|
||||
sysFile.setGroupId(groupId);
|
||||
|
||||
// 调用save方法保存SysFile对象
|
||||
this.save(sysFile);
|
||||
}
|
||||
|
||||
|
||||
+9
-8
@@ -40,6 +40,7 @@ import com.pig4cloud.pigx.common.core.constant.enums.MenuTypeEnum;
|
||||
import com.pig4cloud.pigx.common.core.exception.ErrorCodes;
|
||||
import com.pig4cloud.pigx.common.core.util.MsgUtils;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@@ -48,7 +49,6 @@ import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
@@ -109,10 +109,13 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
Long parent = parentId == null ? CommonConstants.MENU_TREE_ROOT_ID : parentId;
|
||||
|
||||
List<TreeNode<Long>> collect = baseMapper
|
||||
.selectList(Wrappers.<SysMenu>lambdaQuery()
|
||||
.like(StrUtil.isNotBlank(menuName), SysMenu::getName, menuName)
|
||||
.eq(StrUtil.isNotBlank(type), SysMenu::getMenuType, type).orderByAsc(SysMenu::getSortOrder))
|
||||
.stream().map(getNodeFunction()).collect(Collectors.toList());
|
||||
.selectList(Wrappers.<SysMenu>lambdaQuery()
|
||||
.like(StrUtil.isNotBlank(menuName), SysMenu::getName, menuName)
|
||||
.eq(StrUtil.isNotBlank(type), SysMenu::getMenuType, type)
|
||||
.orderByAsc(SysMenu::getSortOrder))
|
||||
.stream()
|
||||
.map(getNodeFunction())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 模糊查询 不组装树结构 直接返回 表格方便编辑
|
||||
if (StrUtil.isNotBlank(menuName)) {
|
||||
@@ -139,9 +142,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
List<SysI18nEntity> list = sysI18nService.list();
|
||||
List<TreeNode<Long>> collect = all.stream().filter(menuTypePredicate(type)).peek(item -> {
|
||||
Optional<SysI18nEntity> first = list.stream().filter(it -> it.getZhCn().equals(item.getName())).findFirst();
|
||||
if (first.isPresent()) {
|
||||
item.setName(first.get().getName());
|
||||
}
|
||||
first.ifPresent(sysI18nEntity -> item.setName(sysI18nEntity.getName()));
|
||||
}).map(getNodeFunction()).collect(Collectors.toList());
|
||||
|
||||
Long parent = parentId == null ? CommonConstants.MENU_TREE_ROOT_ID : parentId;
|
||||
|
||||
+7
-4
@@ -18,6 +18,7 @@ package com.pig4cloud.pigx.admin.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysPost;
|
||||
@@ -63,8 +64,9 @@ public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> impl
|
||||
for (PostExcelVO excel : excelVOList) {
|
||||
Set<String> errorMsg = new HashSet<>();
|
||||
// 检验岗位名称或者岗位编码是否存在
|
||||
boolean existPost = postList.stream().anyMatch(post -> excel.getPostName().equals(post.getPostName())
|
||||
|| excel.getPostCode().equals(post.getPostCode()));
|
||||
boolean existPost = postList.stream()
|
||||
.anyMatch(post -> excel.getPostName().equals(post.getPostName())
|
||||
|| excel.getPostCode().equals(post.getPostCode()));
|
||||
|
||||
if (existPost) {
|
||||
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_POST_NAMEORCODE_EXISTING, excel.getPostName(),
|
||||
@@ -91,8 +93,9 @@ public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> impl
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<PostExcelVO> listPost() {
|
||||
List<SysPost> postList = this.list(Wrappers.emptyWrapper());
|
||||
public List<PostExcelVO> listPost(SysPost query, Long[] ids) {
|
||||
List<SysPost> postList = this
|
||||
.list(Wrappers.lambdaQuery(query).in(ArrayUtil.isNotEmpty(ids), SysPost::getPostId, ids));
|
||||
// 转换成execl 对象输出
|
||||
return postList.stream().map(post -> {
|
||||
PostExcelVO postExcelVO = new PostExcelVO();
|
||||
|
||||
+22
-4
@@ -33,7 +33,9 @@ import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -51,7 +53,7 @@ public class SysPublicParamServiceImpl extends ServiceImpl<SysPublicParamMapper,
|
||||
@Cacheable(value = CacheConstants.PARAMS_DETAILS, key = "#publicKey", unless = "#result == null ")
|
||||
public String getSysPublicParamKeyToValue(String publicKey) {
|
||||
SysPublicParam sysPublicParam = this.baseMapper
|
||||
.selectOne(Wrappers.<SysPublicParam>lambdaQuery().eq(SysPublicParam::getPublicKey, publicKey));
|
||||
.selectOne(Wrappers.<SysPublicParam>lambdaQuery().eq(SysPublicParam::getPublicKey, publicKey));
|
||||
|
||||
if (sysPublicParam != null) {
|
||||
return sysPublicParam.getPublicValue();
|
||||
@@ -59,6 +61,20 @@ public class SysPublicParamServiceImpl extends ServiceImpl<SysPublicParamMapper,
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过key查询公共参数指定值
|
||||
* @param keys 参数列表
|
||||
* @return Map
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> getSysPublicParamsKeyToValue(String[] keys) {
|
||||
List<SysPublicParam> paramList = this.baseMapper
|
||||
.selectList(Wrappers.<SysPublicParam>lambdaQuery().in(SysPublicParam::getPublicKey, keys));
|
||||
Map<String, Object> result = new HashMap<>(8);
|
||||
paramList.forEach(param -> result.put(param.getPublicKey(), param.getPublicValue()));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新参数
|
||||
* @param sysPublicParam
|
||||
@@ -83,9 +99,11 @@ public class SysPublicParamServiceImpl extends ServiceImpl<SysPublicParamMapper,
|
||||
@Override
|
||||
@CacheEvict(value = CacheConstants.PARAMS_DETAILS, allEntries = true)
|
||||
public R removeParamByIds(Long[] publicIds) {
|
||||
List<Long> idList = this.baseMapper.selectBatchIds(CollUtil.toList(publicIds)).stream()
|
||||
.filter(p -> !p.getSystemFlag().equals(DictTypeEnum.SYSTEM.getType()))// 系统内置的跳过不能删除
|
||||
.map(SysPublicParam::getPublicId).collect(Collectors.toList());
|
||||
List<Long> idList = this.baseMapper.selectBatchIds(CollUtil.toList(publicIds))
|
||||
.stream()
|
||||
.filter(p -> !p.getSystemFlag().equals(DictTypeEnum.SYSTEM.getType()))// 系统内置的跳过不能删除
|
||||
.map(SysPublicParam::getPublicId)
|
||||
.collect(Collectors.toList());
|
||||
return R.ok(this.removeBatchByIds(idList));
|
||||
}
|
||||
|
||||
|
||||
+8
-5
@@ -21,6 +21,7 @@ package com.pig4cloud.pigx.admin.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysRole;
|
||||
@@ -91,7 +92,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean removeRoleByIds(Long[] ids) {
|
||||
roleMenuService
|
||||
.remove(Wrappers.<SysRoleMenu>update().lambda().in(SysRoleMenu::getRoleId, CollUtil.toList(ids)));
|
||||
.remove(Wrappers.<SysRoleMenu>update().lambda().in(SysRoleMenu::getRoleId, CollUtil.toList(ids)));
|
||||
return this.removeBatchByIds(CollUtil.toList(ids));
|
||||
}
|
||||
|
||||
@@ -123,8 +124,9 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
for (RoleExcelVO excel : excelVOList) {
|
||||
Set<String> errorMsg = new HashSet<>();
|
||||
// 检验角色名称或者角色编码是否存在
|
||||
boolean existRole = roleList.stream().anyMatch(sysRole -> excel.getRoleName().equals(sysRole.getRoleName())
|
||||
|| excel.getRoleCode().equals(sysRole.getRoleCode()));
|
||||
boolean existRole = roleList.stream()
|
||||
.anyMatch(sysRole -> excel.getRoleName().equals(sysRole.getRoleName())
|
||||
|| excel.getRoleCode().equals(sysRole.getRoleCode()));
|
||||
|
||||
if (existRole) {
|
||||
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_ROLE_NAMEORCODE_EXISTING, excel.getRoleName(),
|
||||
@@ -151,8 +153,9 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
* @return list
|
||||
*/
|
||||
@Override
|
||||
public List<RoleExcelVO> listRole() {
|
||||
List<SysRole> roleList = this.list(Wrappers.emptyWrapper());
|
||||
public List<RoleExcelVO> listRole(SysRole sysRole, Long[] ids) {
|
||||
List<SysRole> roleList = this
|
||||
.list(Wrappers.lambdaQuery(sysRole).in(ArrayUtil.isNotEmpty(ids), SysRole::getRoleId, ids));
|
||||
// 转换成execl 对象输出
|
||||
return roleList.stream().map(role -> {
|
||||
RoleExcelVO roleExcelVO = new RoleExcelVO();
|
||||
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
package com.pig4cloud.pigx.admin.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysTenantMenu;
|
||||
import com.pig4cloud.pigx.admin.mapper.SysTenantMenuMapper;
|
||||
import com.pig4cloud.pigx.admin.service.SysTenantMenuService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 租户菜单管理
|
||||
*/
|
||||
@Service
|
||||
public class SysTenantMenuServiceImpl extends ServiceImpl<SysTenantMenuMapper, SysTenantMenu>
|
||||
implements SysTenantMenuService {
|
||||
|
||||
@Override
|
||||
public Boolean saveTenant(SysTenantMenu sysTenantMenu) {
|
||||
return this.save(sysTenantMenu);
|
||||
}
|
||||
|
||||
}
|
||||
+92
-9
@@ -16,6 +16,8 @@
|
||||
*/
|
||||
package com.pig4cloud.pigx.admin.service.impl;
|
||||
|
||||
import cn.hutool.core.util.CharUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.pig4cloud.pigx.admin.api.entity.*;
|
||||
@@ -30,6 +32,7 @@ import com.pig4cloud.pigx.common.data.datascope.DataScopeTypeEnum;
|
||||
import com.pig4cloud.pigx.common.data.resolver.ParamResolver;
|
||||
import com.pig4cloud.pigx.common.data.tenant.TenantBroker;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
@@ -75,7 +78,7 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
|
||||
|
||||
private final SysDictService dictService;
|
||||
|
||||
private final SysTenantMenuService sysTenantMenuService;
|
||||
private final CacheManager cacheManager;
|
||||
|
||||
/**
|
||||
* 获取正常状态租户
|
||||
@@ -87,7 +90,7 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
|
||||
@Cacheable(value = CacheConstants.TENANT_DETAILS)
|
||||
public List<SysTenant> getNormalTenant() {
|
||||
return baseMapper
|
||||
.selectList(Wrappers.<SysTenant>lambdaQuery().eq(SysTenant::getStatus, CommonConstants.STATUS_NORMAL));
|
||||
.selectList(Wrappers.<SysTenant>lambdaQuery().eq(SysTenant::getStatus, CommonConstants.STATUS_NORMAL));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,9 +130,8 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
|
||||
dictIdList.addAll(dictList.stream().map(SysDict::getId).collect(Collectors.toList()));
|
||||
dictItemList.addAll(
|
||||
dictItemService.list(Wrappers.<SysDictItem>lambdaQuery().in(SysDictItem::getDictId, dictIdList)));
|
||||
SysTenantMenu tenantMenu = sysTenantMenuService.getById(sysTenant.getMenuId());
|
||||
String[] split = tenantMenu.getMenuIds().split(",");
|
||||
List<SysMenu> newMenuList = menuService.list(Wrappers.<SysMenu>lambdaQuery().in(SysMenu::getMenuId, split));
|
||||
List<SysMenu> newMenuList = menuService.list(Wrappers.<SysMenu>lambdaQuery()
|
||||
.in(SysMenu::getMenuId, StrUtil.split(sysTenant.getMenuId(), CharUtil.COMMA)));
|
||||
// 查询当前租户菜单
|
||||
menuList.addAll(newMenuList);
|
||||
// 查询客户端配置
|
||||
@@ -187,17 +189,20 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
|
||||
// 插入系统字典
|
||||
dictService.saveBatch(dictList.stream().peek(d -> d.setId(null)).collect(Collectors.toList()));
|
||||
// 处理字典项最新关联的字典ID
|
||||
List<SysDictItem> itemList = dictList.stream().flatMap(dict -> dictItemList.stream()
|
||||
.filter(item -> item.getDictType().equals(dict.getDictType())).peek(item -> {
|
||||
List<SysDictItem> itemList = dictList.stream()
|
||||
.flatMap(dict -> dictItemList.stream()
|
||||
.filter(item -> item.getDictType().equals(dict.getDictType()))
|
||||
.peek(item -> {
|
||||
item.setDictId(dict.getId());
|
||||
item.setId(null);
|
||||
})).collect(Collectors.toList());
|
||||
}))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 插入客户端
|
||||
clientServices.saveBatch(clientDetailsList.stream().peek(d -> d.setId(null)).collect(Collectors.toList()));
|
||||
// 插入系统配置
|
||||
paramService
|
||||
.saveBatch(publicParamList.stream().peek(d -> d.setPublicId(null)).collect(Collectors.toList()));
|
||||
.saveBatch(publicParamList.stream().peek(d -> d.setPublicId(null)).collect(Collectors.toList()));
|
||||
return dictItemService.saveBatch(itemList);
|
||||
}));
|
||||
|
||||
@@ -206,6 +211,84 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改租户
|
||||
* @param tenantDTO
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@CacheEvict(value = CacheConstants.TENANT_DETAILS, allEntries = true)
|
||||
public Boolean updateTenant(SysTenant tenantDTO) {
|
||||
SysTenant tenant = baseMapper.selectById(tenantDTO.getId());
|
||||
// 更新租户数据
|
||||
updateById(tenantDTO);
|
||||
|
||||
// 如果没有修改租户套餐
|
||||
Long defaultId = ParamResolver.getLong("TENANT_DEFAULT_ID", 1L);
|
||||
if (defaultId.equals(tenantDTO.getId())) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
if (tenant.getMenuId().equals(tenantDTO.getMenuId())) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
List<SysMenu> sysMenuList = TenantBroker.applyAs(defaultId,
|
||||
id -> menuService.list(Wrappers.<SysMenu>lambdaQuery()
|
||||
.in(SysMenu::getMenuId, StrUtil.split(tenantDTO.getMenuId(), CharUtil.COMMA))));
|
||||
|
||||
TenantBroker.runAs(tenantDTO.getId(), (tenantId -> {
|
||||
// 查询当前租户的所有菜单
|
||||
List<SysMenu> menuList = menuService.list(Wrappers.emptyWrapper());
|
||||
|
||||
// 套餐功能对比和已有菜单对比 (新增)
|
||||
List<SysMenu> addMenuList = new ArrayList<>();
|
||||
List<SysMenu> delMenuList = new ArrayList<>();
|
||||
|
||||
// 判断新增的菜单列表
|
||||
menuExist(sysMenuList, menuList, addMenuList);
|
||||
|
||||
// 判断删除的菜单列表
|
||||
menuExist(menuList, sysMenuList, delMenuList);
|
||||
|
||||
// 新增的菜单
|
||||
this.saveTenantMenu(addMenuList, CommonConstants.MENU_TREE_ROOT_ID, CommonConstants.MENU_TREE_ROOT_ID);
|
||||
// 套餐删除的菜单
|
||||
List<Long> menuIdList = delMenuList.stream().map(SysMenu::getMenuId).collect(Collectors.toList());
|
||||
menuService.removeBatchByIds(menuIdList);
|
||||
|
||||
// 清空菜单权限
|
||||
cacheManager.getCache(CacheConstants.MENU_DETAILS).clear();
|
||||
}));
|
||||
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断菜单是否存在
|
||||
* @param sysMenuList 要判断的菜单列表
|
||||
* @param menuList 已有菜单列表
|
||||
* @param addMenuList 待添加的菜单列表
|
||||
*/
|
||||
private void menuExist(List<SysMenu> sysMenuList, List<SysMenu> menuList, List<SysMenu> addMenuList) {
|
||||
for (SysMenu sysMenu : sysMenuList) {
|
||||
|
||||
if (StrUtil.isNotBlank(sysMenu.getPath())) {
|
||||
// 根据菜单path名称,查询套餐菜单是否存在
|
||||
if (menuList.stream().noneMatch(menu -> sysMenu.getPath().equals(menu.getPath()))) {
|
||||
addMenuList.add(sysMenu);
|
||||
}
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(sysMenu.getPermission())) {
|
||||
// 根据菜单permission名称,查询套餐菜单是否存在
|
||||
if (menuList.stream().noneMatch(menu -> sysMenu.getPermission().equals(menu.getPermission()))) {
|
||||
addMenuList.add(sysMenu);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新的租户菜单,维护成新的菜单
|
||||
* @param menuList 菜单列表
|
||||
|
||||
+87
-42
@@ -100,6 +100,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
SysUser sysUser = new SysUser();
|
||||
BeanUtils.copyProperties(userDto, sysUser);
|
||||
sysUser.setDelFlag(CommonConstants.STATUS_NORMAL);
|
||||
sysUser.setCreateBy(userDto.getUsername());
|
||||
sysUser.setUpdateBy(userDto.getUsername());
|
||||
sysUser.setPassword(ENCODER.encode(userDto.getPassword()));
|
||||
baseMapper.insert(sysUser);
|
||||
// 保存用户岗位信息
|
||||
@@ -118,7 +120,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
String defaultRole = ParamResolver.getStr("USER_DEFAULT_ROLE");
|
||||
// 默认角色
|
||||
SysRole sysRole = sysRoleService
|
||||
.getOne(Wrappers.<SysRole>lambdaQuery().eq(SysRole::getRoleCode, defaultRole));
|
||||
.getOne(Wrappers.<SysRole>lambdaQuery().eq(SysRole::getRoleCode, defaultRole));
|
||||
userDto.setRole(Collections.singletonList(sysRole.getRoleId()));
|
||||
}
|
||||
|
||||
@@ -142,16 +144,20 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setSysUser(sysUser);
|
||||
// 设置角色列表 (ID)
|
||||
List<Long> roleIds = sysRoleService.findRolesByUserId(sysUser.getUserId()).stream().map(SysRole::getRoleId)
|
||||
.collect(Collectors.toList());
|
||||
List<Long> roleIds = sysRoleService.findRolesByUserId(sysUser.getUserId())
|
||||
.stream()
|
||||
.map(SysRole::getRoleId)
|
||||
.collect(Collectors.toList());
|
||||
userInfo.setRoles(ArrayUtil.toArray(roleIds, Long.class));
|
||||
|
||||
// 设置权限列表(menu.permission)
|
||||
Set<String> permissions = new HashSet<>();
|
||||
roleIds.forEach(roleId -> {
|
||||
List<String> permissionList = sysMenuService.findMenuByRoleId(roleId).stream()
|
||||
.filter(menu -> StrUtil.isNotEmpty(menu.getPermission())).map(SysMenu::getPermission)
|
||||
.collect(Collectors.toList());
|
||||
List<String> permissionList = sysMenuService.findMenuByRoleId(roleId)
|
||||
.stream()
|
||||
.filter(menu -> StrUtil.isNotEmpty(menu.getPermission()))
|
||||
.map(SysMenu::getPermission)
|
||||
.collect(Collectors.toList());
|
||||
permissions.addAll(permissionList);
|
||||
});
|
||||
userInfo.setPermissions(ArrayUtil.toArray(permissions, String.class));
|
||||
@@ -223,28 +229,37 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
SysUser sysUser = new SysUser();
|
||||
BeanUtils.copyProperties(userDto, sysUser);
|
||||
sysUser.setUpdateTime(LocalDateTime.now());
|
||||
|
||||
if (StrUtil.isNotBlank(userDto.getPassword())) {
|
||||
sysUser.setPassword(ENCODER.encode(userDto.getPassword()));
|
||||
}
|
||||
|
||||
this.updateById(sysUser);
|
||||
|
||||
// 更新用户角色表
|
||||
sysUserRoleMapper.delete(Wrappers.<SysUserRole>lambdaQuery().eq(SysUserRole::getUserId, userDto.getUserId()));
|
||||
userDto.getRole().stream().map(roleId -> {
|
||||
SysUserRole userRole = new SysUserRole();
|
||||
userRole.setUserId(sysUser.getUserId());
|
||||
userRole.setRoleId(roleId);
|
||||
return userRole;
|
||||
}).forEach(SysUserRole::insert);
|
||||
if (userDto.getRole() != null) {
|
||||
sysUserRoleMapper
|
||||
.delete(Wrappers.<SysUserRole>lambdaQuery().eq(SysUserRole::getUserId, userDto.getUserId()));
|
||||
userDto.getRole().stream().map(roleId -> {
|
||||
SysUserRole userRole = new SysUserRole();
|
||||
userRole.setUserId(sysUser.getUserId());
|
||||
userRole.setRoleId(roleId);
|
||||
return userRole;
|
||||
}).forEach(SysUserRole::insert);
|
||||
}
|
||||
|
||||
// 更新用户岗位表
|
||||
sysUserPostMapper.delete(Wrappers.<SysUserPost>lambdaQuery().eq(SysUserPost::getUserId, userDto.getUserId()));
|
||||
userDto.getPost().stream().map(postId -> {
|
||||
SysUserPost userPost = new SysUserPost();
|
||||
userPost.setUserId(sysUser.getUserId());
|
||||
userPost.setPostId(postId);
|
||||
return userPost;
|
||||
}).forEach(SysUserPost::insert);
|
||||
if (userDto.getPost() != null) {
|
||||
sysUserPostMapper
|
||||
.delete(Wrappers.<SysUserPost>lambdaQuery().eq(SysUserPost::getUserId, userDto.getUserId()));
|
||||
userDto.getPost().stream().map(postId -> {
|
||||
SysUserPost userPost = new SysUserPost();
|
||||
userPost.setUserId(sysUser.getUserId());
|
||||
userPost.setPostId(postId);
|
||||
return userPost;
|
||||
}).forEach(SysUserPost::insert);
|
||||
}
|
||||
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
@@ -269,21 +284,26 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
/**
|
||||
* 查询全部的用户
|
||||
* @param userDTO 查询条件
|
||||
* @param ids ids 用户列表
|
||||
* @return list
|
||||
*/
|
||||
@Override
|
||||
public List<UserExcelVO> listUser(UserDTO userDTO) {
|
||||
public List<UserExcelVO> listUser(UserDTO userDTO, Long[] ids) {
|
||||
// 根据数据权限查询全部的用户信息
|
||||
List<UserVO> voList = baseMapper.selectVoListByScope(userDTO, DataScope.of());
|
||||
List<UserVO> voList = baseMapper.selectVoListByScope(userDTO, ids, DataScope.of());
|
||||
// 转换成execl 对象输出
|
||||
List<UserExcelVO> userExcelVOList = voList.stream().map(userVO -> {
|
||||
UserExcelVO excelVO = new UserExcelVO();
|
||||
BeanUtils.copyProperties(userVO, excelVO);
|
||||
String roleNameList = userVO.getRoleList().stream().map(SysRole::getRoleName)
|
||||
.collect(Collectors.joining(StrUtil.COMMA));
|
||||
String roleNameList = userVO.getRoleList()
|
||||
.stream()
|
||||
.map(SysRole::getRoleName)
|
||||
.collect(Collectors.joining(StrUtil.COMMA));
|
||||
excelVO.setRoleNameList(roleNameList);
|
||||
String postNameList = userVO.getPostList().stream().map(SysPost::getPostName)
|
||||
.collect(Collectors.joining(StrUtil.COMMA));
|
||||
String postNameList = userVO.getPostList()
|
||||
.stream()
|
||||
.map(SysPost::getPostName)
|
||||
.collect(Collectors.joining(StrUtil.COMMA));
|
||||
excelVO.setPostNameList(postNameList);
|
||||
return excelVO;
|
||||
}).collect(Collectors.toList());
|
||||
@@ -312,7 +332,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
Set<String> errorMsg = new HashSet<>();
|
||||
// 校验用户名是否存在
|
||||
boolean exsitUserName = userList.stream()
|
||||
.anyMatch(sysUser -> excel.getUsername().equals(sysUser.getUsername()));
|
||||
.anyMatch(sysUser -> excel.getUsername().equals(sysUser.getUsername()));
|
||||
|
||||
if (exsitUserName) {
|
||||
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_USER_USERNAME_EXISTING, excel.getUsername()));
|
||||
@@ -320,7 +340,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
|
||||
// 判断输入的部门名称列表是否合法
|
||||
Optional<SysDept> deptOptional = deptList.stream()
|
||||
.filter(dept -> excel.getDeptName().equals(dept.getName())).findFirst();
|
||||
.filter(dept -> excel.getDeptName().equals(dept.getName()))
|
||||
.findFirst();
|
||||
if (!deptOptional.isPresent()) {
|
||||
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_DEPT_DEPTNAME_INEXISTENCE, excel.getDeptName()));
|
||||
}
|
||||
@@ -328,8 +349,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
// 判断输入的角色名称列表是否合法
|
||||
List<String> roleNameList = StrUtil.split(excel.getRoleNameList(), StrUtil.COMMA);
|
||||
List<SysRole> roleCollList = roleList.stream()
|
||||
.filter(role -> roleNameList.stream().anyMatch(name -> role.getRoleName().equals(name)))
|
||||
.collect(Collectors.toList());
|
||||
.filter(role -> roleNameList.stream().anyMatch(name -> role.getRoleName().equals(name)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (roleCollList.size() != roleNameList.size()) {
|
||||
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_ROLE_ROLENAME_INEXISTENCE, excel.getRoleNameList()));
|
||||
@@ -338,8 +359,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
// 判断输入的部门名称列表是否合法
|
||||
List<String> postNameList = StrUtil.split(excel.getPostNameList(), StrUtil.COMMA);
|
||||
List<SysPost> postCollList = postList.stream()
|
||||
.filter(post -> postNameList.stream().anyMatch(name -> post.getPostName().equals(name)))
|
||||
.collect(Collectors.toList());
|
||||
.filter(post -> postNameList.stream().anyMatch(name -> post.getPostName().equals(name)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (postCollList.size() != postNameList.size()) {
|
||||
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_POST_POSTNAME_INEXISTENCE, excel.getPostNameList()));
|
||||
@@ -393,6 +414,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
* @return success/false
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<Boolean> registerUser(UserDTO userDto) {
|
||||
// 判断用户名是否存在
|
||||
SysUser sysUser = this.getOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, userDto.getUsername()));
|
||||
@@ -442,8 +464,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
}
|
||||
String password = ENCODER.encode(userDto.getNewpassword1());
|
||||
|
||||
this.update(Wrappers.<SysUser>lambdaUpdate().set(SysUser::getPassword, password).eq(SysUser::getUserId,
|
||||
userVO.getUserId()));
|
||||
this.update(Wrappers.<SysUser>lambdaUpdate()
|
||||
.set(SysUser::getPassword, password)
|
||||
.eq(SysUser::getUserId, userVO.getUserId()));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -452,20 +475,24 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
PigxUser user = SecurityUtils.getUser();
|
||||
LambdaUpdateWrapper<SysUser> wrapper = null;
|
||||
if (type.equals("wechat")) {
|
||||
wrapper = Wrappers.<SysUser>lambdaUpdate().set(SysUser::getWxOpenid, null).eq(SysUser::getUserId,
|
||||
user.getId());
|
||||
wrapper = Wrappers.<SysUser>lambdaUpdate()
|
||||
.set(SysUser::getWxOpenid, null)
|
||||
.eq(SysUser::getUserId, user.getId());
|
||||
}
|
||||
else if (type.equals("gitee")) {
|
||||
wrapper = Wrappers.<SysUser>lambdaUpdate().set(SysUser::getGiteeLogin, null).eq(SysUser::getUserId,
|
||||
user.getId());
|
||||
wrapper = Wrappers.<SysUser>lambdaUpdate()
|
||||
.set(SysUser::getGiteeLogin, null)
|
||||
.eq(SysUser::getUserId, user.getId());
|
||||
}
|
||||
else if (type.equals("osc")) {
|
||||
wrapper = Wrappers.<SysUser>lambdaUpdate().set(SysUser::getOscId, null).eq(SysUser::getUserId,
|
||||
user.getId());
|
||||
wrapper = Wrappers.<SysUser>lambdaUpdate()
|
||||
.set(SysUser::getOscId, null)
|
||||
.eq(SysUser::getUserId, user.getId());
|
||||
}
|
||||
else if (type.equals("tencent")) {
|
||||
wrapper = Wrappers.<SysUser>lambdaUpdate().set(SysUser::getTenantId, null).eq(SysUser::getUserId,
|
||||
user.getId());
|
||||
wrapper = Wrappers.<SysUser>lambdaUpdate()
|
||||
.set(SysUser::getTenantId, null)
|
||||
.eq(SysUser::getUserId, user.getId());
|
||||
}
|
||||
if (wrapper == null) {
|
||||
return R.failed("解绑账号类型不存在");
|
||||
@@ -490,4 +517,22 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> listUserIdByRoleIds(List<Long> roleIdList) {
|
||||
return sysUserRoleMapper.selectList(Wrappers.<SysUserRole>lambdaQuery().in(SysUserRole::getRoleId, roleIdList))
|
||||
.stream()
|
||||
.map(SysUserRole::getRoleId)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据部门ID列表获取用户ID列表接口
|
||||
* @param deptIdList 部门ID列表
|
||||
* @return List<Long> 返回结果对象,包含根据部门ID列表获取到的用户ID列表信息
|
||||
*/
|
||||
@Override
|
||||
public List<SysUser> listUserIdByDeptIds(List<Long> deptIdList) {
|
||||
return baseMapper.selectList(Wrappers.<SysUser>lambdaQuery().in(SysUser::getDeptId, deptIdList));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -83,7 +83,7 @@
|
||||
u.avatar,
|
||||
u.wx_openid,
|
||||
u.qq_openid,
|
||||
u.gitee_login,
|
||||
u.gitee_login,
|
||||
u.osc_id,
|
||||
u.del_flag,
|
||||
u.lock_flag,
|
||||
@@ -195,6 +195,12 @@
|
||||
<if test="query.deptId != null and query.deptId != ''">
|
||||
AND u.dept_id = #{query.deptId}
|
||||
</if>
|
||||
<if test="ids != null">
|
||||
AND u.user_id in
|
||||
<foreach collection="ids" index="index" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
|
||||
<if test="_databaseId != 'mssql'">
|
||||
|
||||
Reference in new issue
Block a user