♻️ Refactoring code. 适配最新 V5 UI

This commit is contained in:
lbw committed 2023-04-06 14:24:56 +08:00
1 parent 2b6c984791
commit be7654d6ca
67 files changed
+1368 -906

No files matched your search

@@ -44,7 +44,7 @@ public class RouterFunctionConfiguration {
@Bean
public RouterFunction routerFunction() {
return RouterFunctions
.route(RequestPredicates.path("/code").and(RequestPredicates.accept(MediaType.TEXT_PLAIN)),
.route(RequestPredicates.path("/code/create").and(RequestPredicates.accept(MediaType.TEXT_PLAIN)),
imageCodeCreateHandler)
.andRoute(RequestPredicates.POST("/code/check").and(RequestPredicates.accept(MediaType.ALL)),
imageCodeCheckHandler);
+5
View File
@@ -54,5 +54,10 @@
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-excel</artifactId>
</dependency>
<!--字段审计注解-->
<dependency>
<groupId>org.javers</groupId>
<artifactId>javers-core</artifactId>
</dependency>
</dependencies>
</project>
+5
View File
@@ -102,6 +102,11 @@
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-xss</artifactId>
</dependency>
<!-- 字段审计 -->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-audit</artifactId>
</dependency>
<!--支持动态路由配置 -->
<dependency>
<groupId>com.pig4cloud</groupId>
@@ -20,15 +20,20 @@ package com.pig4cloud.pigx.admin.controller;
import com.pig4cloud.pigx.admin.service.MobileService;
import com.pig4cloud.pigx.common.core.util.R;
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.AllArgsConstructor;
import me.chanjar.weixin.cp.bean.external.WxCpUserExternalGroupChatStatistic;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
/**
* @author lengleng
* @date 2018/11/14
@@ -5,10 +5,8 @@ import com.pig4cloud.pigx.admin.service.SysUserService;
import com.pig4cloud.pigx.common.core.util.R;
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 lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -24,7 +22,6 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/register")
@RequiredArgsConstructor
@ConditionalOnProperty(name = "register.user", matchIfMissing = true)
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class RegisterController {
private final SysUserService userService;
@@ -17,20 +17,21 @@
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.common.core.util.R;
import com.pig4cloud.pigx.common.log.annotation.SysLog;
import com.pig4cloud.pigx.admin.api.entity.SysAuditLog;
import com.pig4cloud.pigx.admin.service.SysAuditLogService;
import com.pig4cloud.pigx.common.security.annotation.Inner;
import org.springframework.security.access.prepost.PreAuthorize;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.pig4cloud.pigx.common.log.annotation.SysLog;
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 lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -38,13 +39,13 @@ import java.util.List;
/**
* 审计记录表
*
* @author pigx code generator
* @date 2023-02-27 22:33:30
* @author PIG
* @date 2023-02-28 20:12:23
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/audit")
@Tag(description = "sysauditlog", name = "审计记录表管理")
@Tag(description = "audit", name = "审计记录表管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class SysAuditLogController {
@@ -58,9 +59,8 @@ public class SysAuditLogController {
*/
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('admin_sysauditlog_view')")
public R getSysAuditLogPage(Page page, SysAuditLog sysAuditLog) {
return R.ok(sysAuditLogService.page(page, Wrappers.query(sysAuditLog)));
public R getsysAuditLogPage(Page page, SysAuditLog sysAuditLog) {
return R.ok(sysAuditLogService.getAuditsByScope(page, sysAuditLog));
}
/**
@@ -70,7 +70,6 @@ public class SysAuditLogController {
*/
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('admin_sysauditlog_view')")
public R getById(@PathVariable("id") Long id) {
return R.ok(sysAuditLogService.getById(id));
}
@@ -87,30 +86,17 @@ public class SysAuditLogController {
return R.ok(sysAuditLogService.saveBatch(auditLogList));
}
/**
* 修改审计记录表
* @param sysAuditLog 审计记录表
* @return R
*/
@Operation(summary = "修改审计记录表", description = "修改审计记录表")
@SysLog("修改审计记录表")
@PutMapping
@PreAuthorize("@pms.hasPermission('admin_sysauditlog_edit')")
public R updateById(@RequestBody SysAuditLog sysAuditLog) {
return R.ok(sysAuditLogService.updateById(sysAuditLog));
}
/**
* 通过id删除审计记录表
* @param id id
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除审计记录表", description = "通过id删除审计记录表")
@SysLog("通过id删除审计记录表")
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('admin_sysauditlog_del')")
public R removeById(@PathVariable Long id) {
return R.ok(sysAuditLogService.removeById(id));
@DeleteMapping
@PreAuthorize("@pms.hasPermission('sys_audit_del')")
public R removeById(@RequestBody Long[] ids) {
return R.ok(sysAuditLogService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
@@ -120,7 +106,7 @@ public class SysAuditLogController {
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('admin_sysauditlog_export')")
@PreAuthorize("@pms.hasPermission('sys_audit_export')")
public List<SysAuditLog> export(SysAuditLog sysAuditLog) {
return sysAuditLogService.list(Wrappers.query(sysAuditLog));
}
@@ -19,22 +19,32 @@
package com.pig4cloud.pigx.admin.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
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.SysOauthClientDetailsDTO;
import com.pig4cloud.pigx.admin.api.entity.SysOauthClientDetails;
import com.pig4cloud.pigx.admin.config.ClientDetailsInitRunner;
import com.pig4cloud.pigx.admin.service.SysOauthClientDetailsService;
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.core.util.SpringContextHolder;
import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;
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.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
* <p>
@@ -60,8 +70,18 @@ public class SysClientController {
*/
@GetMapping("/{clientId}")
public R getByClientId(@PathVariable String clientId) {
return R.ok(clientDetailsService
.list(Wrappers.<SysOauthClientDetails>lambdaQuery().eq(SysOauthClientDetails::getClientId, clientId)));
SysOauthClientDetails details = clientDetailsService
.getOne(Wrappers.<SysOauthClientDetails>lambdaQuery().eq(SysOauthClientDetails::getClientId, clientId));
String information = details.getAdditionalInformation();
String captchaFlag = JSONUtil.parseObj(information).getStr(CommonConstants.CAPTCHA_FLAG);
String encFlag = JSONUtil.parseObj(information).getStr(CommonConstants.ENC_FLAG);
String onlineQuantity = JSONUtil.parseObj(information).getStr(CommonConstants.ONLINE_QUANTITY);
SysOauthClientDetailsDTO dto = new SysOauthClientDetailsDTO();
BeanUtils.copyProperties(details, dto);
dto.setCaptchaFlag(captchaFlag);
dto.setEncFlag(encFlag);
dto.setOnlineQuantity(onlineQuantity);
return R.ok(dto);
}
/**
@@ -72,7 +92,12 @@ public class SysClientController {
*/
@GetMapping("/page")
public R getOauthClientDetailsPage(Page page, SysOauthClientDetails sysOauthClientDetails) {
return R.ok(clientDetailsService.queryPage(page, sysOauthClientDetails));
LambdaQueryWrapper<SysOauthClientDetails> wrapper = Wrappers.<SysOauthClientDetails>lambdaQuery()
.like(StrUtil.isNotBlank(sysOauthClientDetails.getClientId()), SysOauthClientDetails::getClientId,
sysOauthClientDetails.getClientId())
.like(StrUtil.isNotBlank(sysOauthClientDetails.getClientSecret()),
SysOauthClientDetails::getClientSecret, sysOauthClientDetails.getClientSecret());
return R.ok(clientDetailsService.page(page, wrapper));
}
/**
@@ -89,14 +114,16 @@ public class SysClientController {
/**
* 删除
* @param clientId ID
* @param ids ID 列表
* @return success/false
*/
@SysLog("删除终端")
@DeleteMapping("/{clientId}")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('sys_client_del')")
public R removeById(@PathVariable String clientId) {
return R.ok(clientDetailsService.removeByClientId(clientId));
public R removeById(@RequestBody Long[] ids) {
clientDetailsService.removeBatchByIds(CollUtil.toList(ids));
SpringContextHolder.publishEvent(new ClientDetailsInitRunner.ClientDetailsInitEvent(ids));
return R.ok();
}
/**
@@ -138,4 +165,15 @@ public class SysClientController {
return clientDetailsService.syncClientCache();
}
/**
* 导出所有客户端
* @return excel
*/
@ResponseExcel
@SysLog("导出excel")
@GetMapping("/export")
public List<SysOauthClientDetails> export(SysOauthClientDetails sysOauthClientDetails) {
return clientDetailsService.list(Wrappers.query(sysOauthClientDetails));
}
}
@@ -19,11 +19,8 @@
package com.pig4cloud.pigx.admin.controller;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.pig4cloud.pigx.admin.api.entity.SysDept;
import com.pig4cloud.pigx.admin.api.entity.SysDeptRelation;
import com.pig4cloud.pigx.admin.api.vo.DeptExcelVo;
import com.pig4cloud.pigx.admin.service.SysDeptRelationService;
import com.pig4cloud.pigx.admin.service.SysDeptService;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.excel.annotation.RequestExcel;
@@ -56,8 +53,6 @@ import java.util.List;
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class SysDeptController {
private final SysDeptRelationService relationService;
private final SysDeptService sysDeptService;
/**
@@ -97,7 +92,7 @@ public class SysDeptController {
@PostMapping
@PreAuthorize("@pms.hasPermission('sys_dept_add')")
public R save(@Valid @RequestBody SysDept sysDept) {
return R.ok(sysDeptService.saveDept(sysDept));
return R.ok(sysDeptService.save(sysDept));
}
/**
@@ -122,7 +117,7 @@ public class SysDeptController {
@PreAuthorize("@pms.hasPermission('sys_dept_edit')")
public R update(@Valid @RequestBody SysDept sysDept) {
sysDept.setUpdateTime(LocalDateTime.now());
return R.ok(sysDeptService.updateDeptById(sysDept));
return R.ok(sysDeptService.updateById(sysDept));
}
/**
@@ -131,8 +126,7 @@ public class SysDeptController {
*/
@GetMapping(value = "/getDescendantList/{deptId}")
public R getDescendantList(@PathVariable Long deptId) {
return R.ok(
relationService.list(Wrappers.<SysDeptRelation>lambdaQuery().eq(SysDeptRelation::getAncestor, deptId)));
return R.ok(sysDeptService.listDescendant(deptId));
}
/**
@@ -19,6 +19,7 @@
package com.pig4cloud.pigx.admin.controller;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -28,6 +29,7 @@ import com.pig4cloud.pigx.admin.service.SysDictItemService;
import com.pig4cloud.pigx.admin.service.SysDictService;
import com.pig4cloud.pigx.common.core.constant.CacheConstants;
import com.pig4cloud.pigx.common.core.util.R;
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;
@@ -65,11 +67,21 @@ public class SysDictController {
* @param id ID
* @return 字典信息
*/
@GetMapping("/{id}")
@GetMapping("/details/{id}")
public R getById(@PathVariable Long id) {
return R.ok(sysDictService.getById(id));
}
/**
* 查询字典信息
* @param query 查询信息
* @return 字典信息
*/
@GetMapping("/details")
public R getDetails(SysDict query) {
return R.ok(sysDictService.getOne(Wrappers.query(query), false));
}
/**
* 分页查询字典信息
* @param page 分页对象
@@ -77,7 +89,11 @@ public class SysDictController {
*/
@GetMapping("/page")
public R<IPage> getDictPage(Page page, SysDict sysDict) {
return R.ok(sysDictService.page(page, Wrappers.query(sysDict)));
return R.ok(sysDictService.page(page,
Wrappers.<SysDict>lambdaQuery()
.eq(StrUtil.isNotBlank(sysDict.getSystemFlag()), SysDict::getSystemFlag,
sysDict.getSystemFlag())
.like(StrUtil.isNotBlank(sysDict.getDictType()), SysDict::getDictType, sysDict.getDictType())));
}
/**
@@ -100,19 +116,21 @@ public class SysDictController {
@PostMapping
@PreAuthorize("@pms.hasPermission('sys_dict_add')")
public R save(@Valid @RequestBody SysDict sysDict) {
return R.ok(sysDictService.save(sysDict));
sysDictService.save(sysDict);
return R.ok(sysDict);
}
/**
* 删除字典,并且清除字典缓存
* @param id ID
* @param ids ID
* @return R
*/
@SysLog("删除字典")
@DeleteMapping("/{id}")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('sys_dict_del')")
public R removeById(@PathVariable Long id) {
return sysDictService.removeDict(id);
@CacheEvict(value = CacheConstants.DICT_DETAILS, allEntries = true)
public R removeById(@RequestBody Long[] ids) {
return R.ok(sysDictService.removeDictByIds(ids));
}
/**
@@ -127,6 +145,18 @@ public class SysDictController {
return sysDictService.updateDict(sysDict);
}
/**
* 分页查询
* @param name 名称或者字典项
* @return
*/
@GetMapping("/list")
public R getDictList(String name) {
return R.ok(sysDictService
.list(Wrappers.<SysDict>lambdaQuery().like(StrUtil.isNotBlank(name), SysDict::getDictType, name).or()
.like(StrUtil.isNotBlank(name), SysDict::getDescription, name)));
}
/**
* 分页查询
* @param page 分页对象
@@ -143,11 +173,21 @@ public class SysDictController {
* @param id id
* @return R
*/
@GetMapping("/item/{id}")
@GetMapping("/item/details/{id}")
public R getDictItemById(@PathVariable("id") Long id) {
return R.ok(sysDictItemService.getById(id));
}
/**
* 查询字典项详情
* @param query 查询条件
* @return R
*/
@GetMapping("/item/details")
public R getDictItemDetails(SysDictItem query) {
return R.ok(sysDictItemService.getOne(Wrappers.query(query), false));
}
/**
* 新增字典项
* @param sysDictItem 字典项
@@ -192,4 +232,10 @@ public class SysDictController {
return sysDictService.syncDictCache();
}
@ResponseExcel
@GetMapping("/export")
public List<SysDictItem> export(SysDictItem sysDictItem) {
return sysDictItemService.list(Wrappers.query(sysDictItem));
}
}
@@ -18,6 +18,8 @@
package com.pig4cloud.pigx.admin.controller;
import cn.hutool.core.io.IoUtil;
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.entity.SysFile;
@@ -62,20 +64,25 @@ public class SysFileController {
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
public R getSysFilePage(Page page, SysFile sysFile) {
return R.ok(sysFileService.page(page, Wrappers.query(sysFile)));
LambdaQueryWrapper<SysFile> wrapper = Wrappers.<SysFile>lambdaQuery()
.like(StrUtil.isNotBlank(sysFile.getOriginal()), SysFile::getOriginal, sysFile.getOriginal());
return R.ok(sysFileService.page(page, wrapper));
}
/**
* 通过id删除文件管理
* @param id id
* @param ids id 列表
* @return R
*/
@Operation(summary = "通过id删除文件管理", description = "通过id删除文件管理")
@SysLog("删除文件管理")
@DeleteMapping("/{id}")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('sys_file_del')")
public R removeById(@PathVariable Long id) {
return R.ok(sysFileService.deleteFile(id));
public R removeById(@RequestBody Long[] ids) {
for (Long id : ids) {
sysFileService.deleteFile(id);
}
return R.ok();
}
/**
@@ -0,0 +1,166 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.admin.controller;
import cn.hutool.core.collection.CollUtil;
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.entity.SysI18nEntity;
import com.pig4cloud.pigx.admin.service.SysI18nService;
import com.pig4cloud.pigx.common.core.constant.CacheConstants;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;
import com.pig4cloud.pigx.common.log.annotation.SysLog;
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 lombok.RequiredArgsConstructor;
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.List;
/**
* 系统表-国际化
*
* @author PIG
* @date 2023-02-14 09:07:01
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/i18n")
@Tag(description = "i18n", name = "系统表-国际化管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class SysI18nController {
private final SysI18nService sysI18nService;
/**
* 分页查询
* @param page 分页对象
* @param sysI18n 系统表-国际化
* @return
*/
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('sys_i18n_view')")
public R getsysI18nPage(Page page, SysI18nEntity sysI18n) {
LambdaQueryWrapper<SysI18nEntity> wrapper = Wrappers.lambdaQuery();
wrapper.like(StrUtil.isNotBlank(sysI18n.getName()), SysI18nEntity::getName, sysI18n.getName());
wrapper.like(StrUtil.isNotBlank(sysI18n.getZhCn()), SysI18nEntity::getZhCn, sysI18n.getZhCn());
wrapper.like(StrUtil.isNotBlank(sysI18n.getEn()), SysI18nEntity::getEn, sysI18n.getEn());
return R.ok(sysI18nService.page(page, wrapper));
}
/**
* 通过id查询系统表-国际化
* @param id id
* @return R
*/
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/details/{id}")
public R getById(@PathVariable("id") Long id) {
return R.ok(sysI18nService.getById(id));
}
@GetMapping("/details")
public R getDetails(SysI18nEntity entity) {
return R.ok(sysI18nService.getOne(Wrappers.query(entity)));
}
/**
* 新增系统表-国际化
* @param sysI18n 系统表-国际化
* @return R
*/
@Operation(summary = "新增系统表-国际化", description = "新增系统表-国际化")
@SysLog("新增系统表-国际化")
@PostMapping
@CacheEvict(value = CacheConstants.I18N_DETAILS, allEntries = true)
@PreAuthorize("@pms.hasPermission('sys_i18n_add')")
public R save(@RequestBody SysI18nEntity sysI18n) {
return R.ok(sysI18nService.save(sysI18n));
}
/**
* 修改系统表-国际化
* @param sysI18n 系统表-国际化
* @return R
*/
@Operation(summary = "修改系统表-国际化", description = "修改系统表-国际化")
@SysLog("修改系统表-国际化")
@PutMapping
@CacheEvict(value = CacheConstants.I18N_DETAILS, allEntries = true)
@PreAuthorize("@pms.hasPermission('sys_i18n_edit')")
public R updateById(@RequestBody SysI18nEntity sysI18n) {
return R.ok(sysI18nService.updateById(sysI18n));
}
/**
* 通过id删除系统表-国际化
* @param ids id 列表
* @return R
*/
@Operation(summary = "通过id删除系统表-国际化", description = "通过id删除系统表-国际化")
@SysLog("通过id删除系统表-国际化")
@DeleteMapping
@CacheEvict(value = CacheConstants.I18N_DETAILS, allEntries = true)
@PreAuthorize("@pms.hasPermission('sys_i18n_del')")
public R removeById(@RequestBody Long[] ids) {
return R.ok(sysI18nService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
* 导出excel 表格
* @param sysI18n 查询条件
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('sys_i18n_export')")
public List<SysI18nEntity> export(SysI18nEntity sysI18n) {
return sysI18nService.list(Wrappers.query(sysI18n));
}
/**
* 获取系统I18N配置
* @return I18N 配置
*/
@Operation(summary = "获取系统配置-国际化", description = "获取系统配置-国际化")
@Inner(false)
@GetMapping("/info")
public R list() {
return R.ok(sysI18nService.listMap());
}
/**
* 同步数据
* @return R
*/
@SysLog("同步数据")
@PutMapping("/sync")
public R sync() {
return sysI18nService.syncI18nCache();
}
}
@@ -67,17 +67,6 @@ public class SysLogController {
return R.ok(sysLogService.getLogByPage(page, sysLog));
}
/**
* 删除日志
* @param id ID
* @return success/false
*/
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('sys_log_del')")
public R removeById(@PathVariable Long id) {
return R.ok(sysLogService.removeById(id));
}
/**
* 批量删除日志
* @param ids ID
@@ -57,7 +57,6 @@ public class SysMenuController {
*/
@GetMapping
public R getUserMenu(String type, Long parentId) {
// 获取符合条件的菜单
Set<SysMenu> all = new HashSet<>();
SecurityUtils.getRoles().forEach(roleId -> all.addAll(sysMenuService.findMenuByRoleId(roleId)));
@@ -71,8 +70,8 @@ public class SysMenuController {
* @return 树形菜单
*/
@GetMapping(value = "/tree")
public R getTree(Long parentId, String menuName) {
return R.ok(sysMenuService.treeMenu(parentId, menuName));
public R getTree(Long parentId, String menuName, String type) {
return R.ok(sysMenuService.treeMenu(parentId, menuName, type));
}
/**
@@ -17,6 +17,8 @@
package com.pig4cloud.pigx.admin.controller;
import cn.hutool.core.collection.CollUtil;
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.SysPost;
@@ -67,11 +69,12 @@ public class SysPostController {
* @param sysPost 岗位信息表
* @return
*/
@Operation(summary = "分页查询", description = "分页查询")
@Operation(description = "分页查询", summary = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('sys_post_view')")
public R getSysPostPage(Page page, SysPost sysPost) {
return R.ok(sysPostService.page(page, Wrappers.query(sysPost)));
return R.ok(sysPostService.page(page, Wrappers.<SysPost>lambdaQuery()
.like(StrUtil.isNotBlank(sysPost.getPostName()), SysPost::getPostName, sysPost.getPostName())));
}
/**
@@ -79,19 +82,31 @@ public class SysPostController {
* @param postId id
* @return R
*/
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{postId}")
@Operation(description = "通过id查询", summary = "通过id查询")
@GetMapping("/details/{postId}")
@PreAuthorize("@pms.hasPermission('sys_post_view')")
public R getById(@PathVariable("postId") Long postId) {
return R.ok(sysPostService.getById(postId));
}
/**
* 查询岗位信息信息
* @param query 查询条件
* @return R
*/
@Operation(description = "查询角色信息", summary = "查询角色信息")
@GetMapping("/details")
@PreAuthorize("@pms.hasPermission('sys_post_view')")
public R getDetails(SysPost query) {
return R.ok(sysPostService.getOne(Wrappers.query(query), false));
}
/**
* 新增岗位信息表
* @param sysPost 岗位信息表
* @return R
*/
@Operation(summary = "新增岗位信息表", description = "新增岗位信息表")
@Operation(description = "新增岗位信息表", summary = "新增岗位信息表")
@SysLog("新增岗位信息表")
@PostMapping
@PreAuthorize("@pms.hasPermission('sys_post_add')")
@@ -104,7 +119,7 @@ public class SysPostController {
* @param sysPost 岗位信息表
* @return R
*/
@Operation(summary = "修改岗位信息表", description = "修改岗位信息表")
@Operation(description = "修改岗位信息表", summary = "修改岗位信息表")
@SysLog("修改岗位信息表")
@PutMapping
@PreAuthorize("@pms.hasPermission('sys_post_edit')")
@@ -114,15 +129,15 @@ public class SysPostController {
/**
* 通过id删除岗位信息表
* @param postId id
* @param ids id 列表
* @return R
*/
@Operation(summary = "通过id删除岗位信息表", description = "通过id删除岗位信息表")
@Operation(description = "通过id删除岗位信息表", summary = "通过id删除岗位信息表")
@SysLog("通过id删除岗位信息表")
@DeleteMapping("/{postId}")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('sys_post_del')")
public R removeById(@PathVariable Long postId) {
return R.ok(sysPostService.removeById(postId));
public R removeById(@RequestBody Long[] ids) {
return R.ok(sysPostService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
@@ -17,11 +17,14 @@
package com.pig4cloud.pigx.admin.controller;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.pigx.admin.api.entity.SysPublicParam;
import com.pig4cloud.pigx.admin.service.SysPublicParamService;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;
import com.pig4cloud.pigx.common.log.annotation.SysLog;
import com.pig4cloud.pigx.common.security.annotation.Inner;
import io.swagger.v3.oas.annotations.Operation;
@@ -32,6 +35,8 @@ import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 公共参数
*
@@ -53,7 +58,7 @@ public class SysPublicParamController {
* @return
*/
@Inner(value = false)
@Operation(summary = "查询公共参数值", description = "根据key查询公共参数值")
@Operation(description = "查询公共参数值", summary = "根据key查询公共参数值")
@GetMapping("/publicValue/{publicKey}")
public R publicKey(@PathVariable("publicKey") String publicKey) {
return R.ok(sysPublicParamService.getSysPublicParamKeyToValue(publicKey));
@@ -65,10 +70,18 @@ public class SysPublicParamController {
* @param sysPublicParam 公共参数
* @return
*/
@Operation(summary = "分页查询", description = "分页查询")
@Operation(description = "分页查询", summary = "分页查询")
@GetMapping("/page")
public R getSysPublicParamPage(Page page, SysPublicParam sysPublicParam) {
return R.ok(sysPublicParamService.page(page, Wrappers.query(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());
return R.ok(sysPublicParamService.page(page, wrapper));
}
/**
@@ -76,21 +89,26 @@ public class SysPublicParamController {
* @param publicId id
* @return R
*/
@Operation(summary = "通过id查询公共参数", description = "通过id查询公共参数")
@GetMapping("/{publicId}")
@Operation(description = "通过id查询公共参数", summary = "通过id查询公共参数")
@GetMapping("/details/{publicId}")
public R getById(@PathVariable("publicId") Long publicId) {
return R.ok(sysPublicParamService.getById(publicId));
}
@GetMapping("/details")
public R getDetail(SysPublicParam param) {
return R.ok(sysPublicParamService.getOne(Wrappers.query(param), false));
}
/**
* 新增公共参数
* @param sysPublicParam 公共参数
* @return R
*/
@Operation(summary = "新增公共参数", description = "新增公共参数")
@Operation(description = "新增公共参数", summary = "新增公共参数")
@SysLog("新增公共参数")
@PostMapping
@PreAuthorize("@pms.hasPermission('admin_syspublicparam_add')")
@PreAuthorize("@pms.hasPermission('sys_syspublicparam_add')")
public R save(@RequestBody SysPublicParam sysPublicParam) {
return R.ok(sysPublicParamService.save(sysPublicParam));
}
@@ -100,10 +118,10 @@ public class SysPublicParamController {
* @param sysPublicParam 公共参数
* @return R
*/
@Operation(summary = "修改公共参数", description = "修改公共参数")
@Operation(description = "修改公共参数", summary = "修改公共参数")
@SysLog("修改公共参数")
@PutMapping
@PreAuthorize("@pms.hasPermission('admin_syspublicparam_edit')")
@PreAuthorize("@pms.hasPermission('sys_syspublicparam_edit')")
public R updateById(@RequestBody SysPublicParam sysPublicParam) {
return sysPublicParamService.updateParam(sysPublicParam);
}
@@ -113,12 +131,23 @@ public class SysPublicParamController {
* @param publicId id
* @return R
*/
@Operation(summary = "删除公共参数", description = "删除公共参数")
@Operation(description = "删除公共参数", summary = "删除公共参数")
@SysLog("删除公共参数")
@DeleteMapping("/{publicId}")
@PreAuthorize("@pms.hasPermission('admin_syspublicparam_del')")
public R removeById(@PathVariable Long publicId) {
return sysPublicParamService.removeParam(publicId);
@DeleteMapping
@PreAuthorize("@pms.hasPermission('sys_syspublicparam_del')")
public R removeById(@RequestBody Long[] ids) {
return R.ok(sysPublicParamService.removeParamByIds(ids));
}
/**
* 导出excel 表格
* @return
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('sys_syspublicparam_edit')")
public List<SysPublicParam> export() {
return sysPublicParamService.list();
}
/**
@@ -127,6 +156,7 @@ public class SysPublicParamController {
*/
@SysLog("同步参数")
@PutMapping("/sync")
@PreAuthorize("@pms.hasPermission('sys_syspublicparam_edit')")
public R sync() {
return sysPublicParamService.syncParamCache();
}
@@ -62,19 +62,19 @@ public class SysRoleController {
* @param id ID
* @return 角色信息
*/
@GetMapping("/{id}")
@GetMapping("/details/{id}")
public R getById(@PathVariable Long id) {
return R.ok(sysRoleService.getById(id));
}
/**
* 通过角色编码查询角色信息
* @param code 角色Code
* 查询角色信息
* @param query 查询条件
* @return 角色信息
*/
@GetMapping("/code/{code}")
public R getByRoleCode(@PathVariable String code) {
return R.ok(sysRoleService.list(Wrappers.<SysRole>lambdaQuery().eq(SysRole::getRoleCode, code)));
@GetMapping("/details")
public R getDetails(SysRole query) {
return R.ok(sysRoleService.getOne(Wrappers.query(query), false));
}
/**
@@ -105,15 +105,15 @@ public class SysRoleController {
/**
* 删除角色
* @param id
* @param ids
* @return
*/
@SysLog("删除角色")
@DeleteMapping("/{id}")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('sys_role_del')")
@CacheEvict(value = CacheConstants.ROLE_DETAILS, allEntries = true)
public R removeById(@PathVariable Long id) {
return R.ok(sysRoleService.removeRoleById(id));
public R removeById(@RequestBody Long[] ids) {
return R.ok(sysRoleService.removeRoleByIds(ids));
}
/**
@@ -133,7 +133,8 @@ public class SysRoleController {
*/
@GetMapping("/page")
public R getRolePage(Page page, SysRole role) {
return R.ok(sysRoleService.page(page, Wrappers.query(role)));
return R.ok(sysRoleService.page(page, Wrappers.<SysRole>lambdaQuery()
.like(StrUtil.isNotBlank(role.getRoleName()), SysRole::getRoleName, role.getRoleName())));
}
/**
@@ -0,0 +1,129 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
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.entity.SysScheduleEntity;
import com.pig4cloud.pigx.admin.service.SysScheduleService;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;
import com.pig4cloud.pigx.common.log.annotation.SysLog;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 日程
*
* @author aeizzz
* @date 2023-03-06 14:26:23
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/schedule")
@Tag(description = "schedule", name = "日程管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class SysScheduleController {
private final SysScheduleService sysScheduleService;
/**
* 分页查询
* @param page 分页对象
* @param sysSchedule 日程
* @return
*/
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
public R getSchedulePage(Page page, SysScheduleEntity sysSchedule) {
return R.ok(sysScheduleService.getScheduleByScope(page, sysSchedule));
}
/**
* 通过id查询日程
* @param id id
* @return R
*/
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
public R getById(@PathVariable("id") Long id) {
return R.ok(sysScheduleService.getById(id));
}
/**
* 新增日程
* @param sysSchedule 日程
* @return R
*/
@Operation(summary = "新增日程", description = "新增日程")
@SysLog("新增日程")
@PostMapping
public R save(@RequestBody SysScheduleEntity sysSchedule) {
return R.ok(sysScheduleService.save(sysSchedule));
}
/**
* 修改日程
* @param sysSchedule 日程
* @return R
*/
@Operation(summary = "修改日程", description = "修改日程")
@SysLog("修改日程")
@PutMapping
public R updateById(@RequestBody SysScheduleEntity sysSchedule) {
return R.ok(sysScheduleService.updateById(sysSchedule));
}
/**
* 通过id删除日程
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除日程", description = "通过id删除日程")
@SysLog("通过id删除日程")
@DeleteMapping
public R removeById(@RequestBody Long[] ids) {
return R.ok(sysScheduleService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
* 导出excel 表格
* @param sysSchedule 查询条件
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
public List<SysScheduleEntity> export(SysScheduleEntity sysSchedule) {
return sysScheduleService.list(Wrappers.query(sysSchedule));
}
@Operation(summary = "列表查询", description = "列表查询")
@GetMapping("/list")
public R list(String month) {
List<SysScheduleEntity> list = sysScheduleService.selectListByScope(month);
return R.ok(list);
}
}
@@ -17,10 +17,12 @@
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.entity.SysSocialDetails;
import com.pig4cloud.pigx.admin.service.SysSocialDetailsService;
import com.pig4cloud.pigx.app.api.entity.AppSocialDetails;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.core.util.ValidGroup;
import com.pig4cloud.pigx.common.log.annotation.SysLog;
@@ -34,6 +36,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
* 系统社交登录账号表
@@ -72,6 +75,11 @@ public class SysSocialDetailsController {
.list(Wrappers.<SysSocialDetails>lambdaQuery().eq(SysSocialDetails::getType, type)));
}
@GetMapping("/getById/{id}")
public R info(@PathVariable("id") Long id) {
return R.ok(sysSocialDetailsService.getById(id));
}
/**
* 保存
* @param sysSocialDetails
@@ -99,14 +107,14 @@ public class SysSocialDetailsController {
/**
* 删除
* @param id
* @param ids id 列表
* @return R
*/
@SysLog("删除三方信息")
@DeleteMapping("/{id}")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('sys_social_details_del')")
public R removeById(@PathVariable Long id) {
return R.ok(sysSocialDetailsService.removeById(id));
public R removeById(@RequestBody Long[] ids) {
return R.ok(sysSocialDetailsService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
@@ -131,4 +139,12 @@ public class SysSocialDetailsController {
return R.ok(sysSocialDetailsService.bindSocial(state, code));
}
/**
* 导出
*/
@GetMapping("/export")
public List<SysSocialDetails> export(SysSocialDetails sysSocialDetails) {
return sysSocialDetailsService.list(Wrappers.query(sysSocialDetails));
}
}
@@ -17,12 +17,15 @@
package com.pig4cloud.pigx.admin.controller;
import cn.hutool.core.collection.CollUtil;
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.SysTenantService;
import com.pig4cloud.pigx.common.core.constant.CacheConstants;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;
import com.pig4cloud.pigx.common.log.annotation.SysLog;
import com.pig4cloud.pigx.common.security.annotation.Inner;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
@@ -60,17 +63,28 @@ public class SysTenantController {
*/
@GetMapping("/page")
public R getSysTenantPage(Page page, SysTenant sysTenant) {
return R.ok(sysTenantService.page(page, Wrappers.query(sysTenant)));
return R.ok(sysTenantService.page(page, Wrappers.<SysTenant>lambdaQuery()
.like(StrUtil.isNotBlank(sysTenant.getName()), SysTenant::getName, sysTenant.getName())));
}
/**
* 通过ID 查询租户信息
* @param id ID
* @return R
*/
@GetMapping("/details/{id}")
public R getById(@PathVariable Long id) {
return R.ok(sysTenantService.getById(id));
}
/**
* 查询租户信息
* @param tenant 查询条件
* @param query 查询条件
* @return 租户信息
*/
@GetMapping
public R getByObj(SysTenant tenant) {
return R.ok(sysTenantService.list(Wrappers.query(tenant)));
@GetMapping("/details")
public R getDetails(SysTenant query) {
return R.ok(sysTenantService.getOne(Wrappers.query(query), false));
}
/**
@@ -80,7 +94,7 @@ public class SysTenantController {
*/
@SysLog("新增租户")
@PostMapping
@PreAuthorize("@pms.hasPermission('admin_systenant_add')")
@PreAuthorize("@pms.hasPermission('sys_systenant_add')")
@CacheEvict(value = CacheConstants.TENANT_DETAILS, allEntries = true)
public R save(@RequestBody SysTenant sysTenant) {
return R.ok(sysTenantService.saveTenant(sysTenant));
@@ -93,7 +107,7 @@ public class SysTenantController {
*/
@SysLog("修改租户")
@PutMapping
@PreAuthorize("@pms.hasPermission('admin_systenant_edit')")
@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));
@@ -101,15 +115,17 @@ public class SysTenantController {
/**
* 通过id删除租户
* @param id id
* <p>
* 为了保证安全,这里只删除租户表的数据,不删除基础表中的租户初始化数据。
* @param ids id 列表
* @return R
*/
@SysLog("删除租户")
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('admin_systenant_del')")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('sys_systenant_del')")
@CacheEvict(value = CacheConstants.TENANT_DETAILS, allEntries = true)
public R removeById(@PathVariable Long id) {
return R.ok(sysTenantService.removeById(id));
public R removeById(@RequestBody Long[] ids) {
return R.ok(sysTenantService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
@@ -125,4 +141,15 @@ public class SysTenantController {
return R.ok(tenants);
}
/**
* 导出excel 表格
* @return
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('sys_systenant_export')")
public List<SysTenant> export(SysTenant sysTenant) {
return sysTenantService.list(Wrappers.query(sysTenant));
}
}
@@ -63,7 +63,7 @@ public class SysTenantMenuController {
*/
@SysLog("新增租户")
@PostMapping
@PreAuthorize("@pms.hasPermission('admin_systenantmenu_add')")
@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));
@@ -76,7 +76,7 @@ public class SysTenantMenuController {
*/
@SysLog("修改租户")
@PutMapping
@PreAuthorize("@pms.hasPermission('admin_systenantmenu_edit')")
@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));
@@ -89,7 +89,7 @@ public class SysTenantMenuController {
*/
@SysLog("删除租户")
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('admin_systenantmenu_del')")
@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));
@@ -112,7 +112,7 @@ public class SysTenantMenuController {
Long defaultId = ParamResolver.getLong("TENANT_DEFAULT_ID", 1L);
List<Tree<Long>> trees = new ArrayList<>();
TenantBroker.runAs(defaultId, (id) -> {
trees.addAll(sysMenuService.treeMenu(null, null));
trees.addAll(sysMenuService.treeMenu(null, null, null));
});
return R.ok(trees);
@@ -19,15 +19,13 @@
package com.pig4cloud.pigx.admin.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.pigx.admin.api.dto.UserDTO;
import com.pig4cloud.pigx.admin.api.entity.SysUser;
import com.pig4cloud.pigx.admin.api.vo.CpUserExcelVo;
import com.pig4cloud.pigx.admin.api.vo.DingUserExcelVo;
import com.pig4cloud.pigx.admin.api.vo.UserExcelVO;
import com.pig4cloud.pigx.admin.service.SysUserService;
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
import com.pig4cloud.pigx.common.core.exception.ErrorCodes;
import com.pig4cloud.pigx.common.core.util.MsgUtils;
import com.pig4cloud.pigx.common.core.util.R;
@@ -94,47 +92,34 @@ public class SysUserController {
* @param id ID
* @return 用户信息
*/
@GetMapping("/{id}")
@GetMapping("/details/{id}")
public R user(@PathVariable Long id) {
return R.ok(userService.selectUserVoById(id));
}
/**
* 根据用户名查询用户信息
* @param username 用户名
* @return
* 查询用户信息
* @param query 查询条件
* @return 不为空返回用户名
*/
@GetMapping("/details/{username}")
public R user(@PathVariable String username) {
SysUser condition = new SysUser();
condition.setUsername(username);
return R.ok(userService.getOne(new QueryWrapper<>(condition)));
}
/**
* 根据手机号查询用户信息
* @param phone 用户名
* @return
*/
@GetMapping("/detailsByPhone/{phone}")
public R detailsByPhone(@PathVariable String phone) {
SysUser condition = new SysUser();
condition.setPhone(phone);
return R.ok(userService.getOne(new QueryWrapper<>(condition)));
@Inner(value = false)
@GetMapping("/details")
public R getDetails(SysUser query) {
SysUser sysUser = userService.getOne(Wrappers.query(query), false);
return R.ok(sysUser == null ? null : CommonConstants.SUCCESS);
}
/**
* 删除用户信息
* @param id ID
* @param ids ID
* @return R
*/
@SysLog("删除用户信息")
@DeleteMapping("/{id}")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('sys_user_del')")
@Operation(summary = "删除用户", description = "根据ID删除用户")
public R userDel(@PathVariable Long id) {
SysUser sysUser = userService.getById(id);
return R.ok(userService.deleteUserById(sysUser));
public R userDel(@RequestBody Long[] ids) {
return R.ok(userService.deleteUserByIds(ids));
}
/**
@@ -158,7 +143,7 @@ public class SysUserController {
@PutMapping
@PreAuthorize("@pms.hasPermission('sys_user_edit')")
public R updateUser(@Valid @RequestBody UserDTO userDto) {
return userService.updateUser(userDto);
return R.ok(userService.updateUser(userDto));
}
/**
@@ -216,31 +201,32 @@ public class SysUserController {
return userService.importUser(excelVOList, bindingResult);
}
/**
* 导入钉钉用户
* @param excelVOList
* @param bindingResult
* @return
*/
@PostMapping("/importDingUser")
public R importDingUser(@RequestExcel List<DingUserExcelVo> excelVOList, BindingResult bindingResult) {
return userService.importDingUser(excelVOList, bindingResult);
}
@PostMapping("/importCpUser")
public R importCpUser(@RequestExcel List<CpUserExcelVo> excelVOList, BindingResult bindingResult) {
return userService.importCpUser(excelVOList, bindingResult);
}
/**
* 锁定指定用户
* @param username 用户名
* @return R
*/
@Inner(value = false)
@Inner
@PutMapping("/lock/{username}")
public R lockUser(@PathVariable String username) {
return userService.lockUser(username);
}
@PutMapping("/password")
public R password(@RequestBody UserDTO userDto) {
String username = SecurityUtils.getUser().getUsername();
userDto.setUsername(username);
return userService.changePassword(userDto);
}
@PostMapping("/unbinding")
public R unbinding(String type) {
return userService.unbinding(type);
}
@PostMapping("/check")
public R check(String password) {
return userService.checkPassword(password);
}
}
@@ -0,0 +1,101 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.admin.handler;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.pig4cloud.pigx.admin.api.dto.UserInfo;
import com.pig4cloud.pigx.admin.api.entity.SysSocialDetails;
import com.pig4cloud.pigx.admin.api.entity.SysUser;
import com.pig4cloud.pigx.admin.mapper.SysSocialDetailsMapper;
import com.pig4cloud.pigx.admin.service.SysUserService;
import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
import com.pig4cloud.pigx.common.core.constant.enums.LoginTypeEnum;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author lengleng
* @date 2019年11月02日
* <p>
* 微信小程序
*/
@Slf4j
@Component("MINI")
@AllArgsConstructor
public class MiniAppLoginHandler extends AbstractLoginHandler {
private final SysUserService sysUserService;
private final SysSocialDetailsMapper sysSocialDetailsMapper;
/**
* 小程序登录传入code
* <p>
* 通过code 调用qq 获取唯一标识
* @param code
* @return
*/
@Override
public String identify(String code) {
SysSocialDetails condition = new SysSocialDetails();
condition.setType(LoginTypeEnum.MINI_APP.getType());
SysSocialDetails socialDetails = sysSocialDetailsMapper.selectOne(new QueryWrapper<>(condition));
String url = String.format(SecurityConstants.MINI_APP_AUTHORIZATION_CODE_URL, socialDetails.getAppId(),
socialDetails.getAppSecret(), code);
String result = HttpUtil.get(url);
log.debug("微信小程序响应报文:{}", result);
Object obj = JSONUtil.parseObj(result).get("openid");
return obj.toString();
}
/**
* openId 获取用户信息
* @param openId
* @return
*/
@Override
public UserInfo info(String openId) {
SysUser user = sysUserService.getOne(Wrappers.<SysUser>query().lambda().eq(SysUser::getMiniOpenid, openId));
if (user == null) {
log.info("微信小程序未绑定:{}", openId);
return null;
}
return sysUserService.findUserInfo(user);
}
/**
* 绑定逻辑
* @param user 用户实体
* @param identify 渠道返回唯一标识
* @return
*/
@Override
public Boolean bind(SysUser user, String identify) {
user.setMiniOpenid(identify);
sysUserService.updateById(user);
return true;
}
}
@@ -24,8 +24,8 @@ import org.apache.ibatis.annotations.Mapper;
/**
* 审计记录表
*
* @author pigx code generator
* @date 2023-02-27 22:33:30
* @author PIG
* @date 2023-02-28 20:12:23
*/
@Mapper
public interface SysAuditLogMapper extends PigxBaseMapper<SysAuditLog> {
@@ -23,6 +23,8 @@ import com.pig4cloud.pigx.admin.api.entity.SysDept;
import com.pig4cloud.pigx.common.data.datascope.PigxBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* <p>
* 部门管理 Mapper 接口
@@ -34,4 +36,11 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SysDeptMapper extends PigxBaseMapper<SysDept> {
/**
* 获取部门的所有后代部门列表
* @param deptId 部门ID
* @return 后代部门列表
*/
List<SysDept> listDescendant(Long deptId);
}
@@ -1,55 +0,0 @@
/*
*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*
*/
package com.pig4cloud.pigx.admin.mapper;
import com.pig4cloud.pigx.admin.api.entity.SysDeptRelation;
import com.pig4cloud.pigx.common.data.datascope.PigxBaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author lengleng
* @since 2018-02-12
*/
@Mapper
public interface SysDeptRelationMapper extends PigxBaseMapper<SysDeptRelation> {
/**
* 删除部门 > 删除所有关联此部门子节点的闭包关系
* @param id 部门ID
*/
void deleteDeptRelationsByDeptId(Long id);
/**
* 删除节点数据
* @param deptRelation 关系节点
*/
void deleteDeptRelations(SysDeptRelation deptRelation);
/**
* 新增节点数据
* @param deptRelation 关系节点
*/
void insertDeptRelations(SysDeptRelation deptRelation);
}
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.admin.mapper;
import com.pig4cloud.pigx.admin.api.entity.SysI18nEntity;
import com.pig4cloud.pigx.common.data.datascope.PigxBaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 系统表-国际化
*
* @author PIG
* @date 2023-02-14 09:07:01
*/
@Mapper
public interface SysI18nMapper extends PigxBaseMapper<SysI18nEntity> {
}
File mode changed.
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.admin.mapper;
import com.pig4cloud.pigx.admin.api.entity.SysScheduleEntity;
import com.pig4cloud.pigx.common.data.datascope.PigxBaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 日程
*
* @author aeizzz
* @date 2023-03-06 14:26:23
*/
@Mapper
public interface SysScheduleMapper extends PigxBaseMapper<SysScheduleEntity> {
}
@@ -22,7 +22,6 @@ package com.pig4cloud.pigx.admin.mapper;
import com.pig4cloud.pigx.admin.api.entity.SysUserRole;
import com.pig4cloud.pigx.common.data.datascope.PigxBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* <p>
@@ -35,13 +34,4 @@ import org.apache.ibatis.annotations.Param;
@Mapper
public interface SysUserRoleMapper extends PigxBaseMapper<SysUserRole> {
/**
* 根据用户Id删除该用户的角色关系
* @param userId 用户ID
* @return boolean
* @author 寻欢·李
* @date 2017年12月7日 16:31:38
*/
Boolean deleteByUserId(@Param("userId") Long userId);
}
@@ -17,15 +17,24 @@
package com.pig4cloud.pigx.admin.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.pig4cloud.pigx.admin.api.entity.SysAuditLog;
/**
* 审计记录表
*
* @author pigx code generator
* @date 2023-02-27 22:33:30
* @author PIG
* @date 2023-02-28 20:12:23
*/
public interface SysAuditLogService extends IService<SysAuditLog> {
/**
* 分页查询审计日志(数据权限处理)
* @param page 分页条件
* @param sysAuditLog 查询条件
* @return page
*/
Page<SysAuditLog> getAuditsByScope(Page page, SysAuditLog sysAuditLog);
}
@@ -1,54 +0,0 @@
/*
*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*
*/
package com.pig4cloud.pigx.admin.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.pig4cloud.pigx.admin.api.entity.SysDept;
import com.pig4cloud.pigx.admin.api.entity.SysDeptRelation;
/**
* <p>
* 服务类
* </p>
*
* @author lengleng
* @since 2018-02-12
*/
public interface SysDeptRelationService extends IService<SysDeptRelation> {
/**
* 新建部门关系
* @param sysDept 部门
*/
void insertDeptRelation(SysDept sysDept);
/**
* 通过ID删除部门关系
* @param id
*/
void deleteAllDeptRealtion(Long id);
/**
* 更新部门关系
* @param relation
*/
void updateDeptRealtion(SysDeptRelation relation);
}
@@ -40,18 +40,11 @@ public interface SysDeptService extends IService<SysDept> {
/**
* 查询部门树菜单
* @return 树
* @param deptName 部门名称
* @return 树
*/
List<Tree<Long>> selectTree(String deptName);
/**
* 添加信息部门
* @param sysDept
* @return
*/
Boolean saveDept(SysDept sysDept);
/**
* 删除部门
* @param id 部门 ID
@@ -59,15 +52,15 @@ public interface SysDeptService extends IService<SysDept> {
*/
Boolean removeDeptById(Long id);
/**
* 更新部门
* @param sysDept 部门信息
* @return 成功、失败
*/
Boolean updateDeptById(SysDept sysDept);
List<DeptExcelVo> listExcelVo();
R importDept(List<DeptExcelVo> excelVOList, BindingResult bindingResult);
/**
* 获取部门的所有后代部门列表
* @param deptId 部门ID
* @return 后代部门列表
*/
List<SysDept> listDescendant(Long deptId);
}
@@ -30,10 +30,10 @@ public interface SysDictService extends IService<SysDict> {
/**
* 根据ID 删除字典
* @param id
* @param ids ID列表
* @return
*/
R removeDict(Long id);
R removeDictByIds(Long[] ids);
/**
* 更新字典
@@ -0,0 +1,20 @@
package com.pig4cloud.pigx.admin.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.pig4cloud.pigx.admin.api.entity.SysI18nEntity;
import com.pig4cloud.pigx.admin.api.entity.SysLog;
import com.pig4cloud.pigx.common.core.util.R;
import java.util.Map;
public interface SysI18nService extends IService<SysI18nEntity> {
Map listMap();
/**
* 同步数据
* @return R
*/
R syncI18nCache();
}
@@ -64,7 +64,7 @@ public interface SysMenuService extends IService<SysMenu> {
* @param menuName 菜单名称
* @return
*/
List<Tree<Long>> treeMenu(Long parentId, String menuName);
List<Tree<Long>> treeMenu(Long parentId, String menuName, String type);
/**
* 查询菜单
@@ -35,13 +35,6 @@ import com.pig4cloud.pigx.common.core.util.R;
*/
public interface SysOauthClientDetailsService extends IService<SysOauthClientDetails> {
/**
* 通过ID删除客户端
* @param clientId
* @return
*/
Boolean removeByClientId(String clientId);
/**
* 根据客户端信息
* @param clientDetailsDTO
@@ -45,10 +45,10 @@ public interface SysPublicParamService extends IService<SysPublicParam> {
/**
* 删除参数
* @param publicId
* @param publicIds 参数列表
* @return
*/
R removeParam(Long publicId);
R removeParamByIds(Long[] publicIds);
/**
* 同步缓存
@@ -55,10 +55,10 @@ public interface SysRoleService extends IService<SysRole> {
/**
* 通过角色ID,删除角色
* @param id
* @param ids
* @return
*/
Boolean removeRoleById(Long id);
Boolean removeRoleByIds(Long[] ids);
/**
* 根据角色菜单列表
File mode changed.
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.admin.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.pig4cloud.pigx.admin.api.entity.SysScheduleEntity;
import java.util.List;
/**
* 日程
*
* @author aeizzz
* @date 2023-03-06 14:26:23
*/
public interface SysScheduleService extends IService<SysScheduleEntity> {
IPage<SysScheduleEntity> getScheduleByScope(Page page, SysScheduleEntity sysSchedule);
List<SysScheduleEntity> selectListByScope(String month);
}
@@ -32,13 +32,4 @@ import com.pig4cloud.pigx.admin.api.entity.SysUserRole;
*/
public interface SysUserRoleService extends IService<SysUserRole> {
/**
* 根据用户Id删除该用户的角色关系
* @param userId 用户ID
* @return boolean
* @author 寻欢·李
* @date 2017年12月7日 16:31:38
*/
Boolean deleteByUserId(Long userId);
}
@@ -25,8 +25,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.pig4cloud.pigx.admin.api.dto.UserDTO;
import com.pig4cloud.pigx.admin.api.dto.UserInfo;
import com.pig4cloud.pigx.admin.api.entity.SysUser;
import com.pig4cloud.pigx.admin.api.vo.CpUserExcelVo;
import com.pig4cloud.pigx.admin.api.vo.DingUserExcelVo;
import com.pig4cloud.pigx.admin.api.vo.UserExcelVO;
import com.pig4cloud.pigx.admin.api.vo.UserVO;
import com.pig4cloud.pigx.common.core.util.R;
@@ -57,10 +55,10 @@ public interface SysUserService extends IService<SysUser> {
/**
* 删除用户
* @param sysUser 用户
* @param ids 用户
* @return boolean
*/
Boolean deleteUserById(SysUser sysUser);
Boolean deleteUserByIds(Long[] ids);
/**
* 更新当前用户基本信息
@@ -74,7 +72,7 @@ public interface SysUserService extends IService<SysUser> {
* @param userDto 用户信息
* @return
*/
R<Boolean> updateUser(UserDTO userDto);
Boolean updateUser(UserDTO userDto);
/**
* 通过ID查询用户信息
@@ -126,8 +124,10 @@ public interface SysUserService extends IService<SysUser> {
*/
R<Boolean> lockUser(String username);
R importDingUser(List<DingUserExcelVo> excelVOList, BindingResult bindingResult);
R changePassword(UserDTO userDto);
R importCpUser(List<CpUserExcelVo> excelVOList, BindingResult bindingResult);
R unbinding(String type);
R checkPassword(String password);
}
@@ -90,7 +90,7 @@ public class ConnectServiceImpl implements ConnectService {
// 保存部门以及部门关系
if (CollectionUtils.isNotEmpty(syncDept)) {
syncDept.forEach(sysDeptService::saveDept);
syncDept.forEach(sysDeptService::save);
}
return Boolean.TRUE;
@@ -196,7 +196,7 @@ public class ConnectServiceImpl implements ConnectService {
sysDept.setParentId(dept.getParentId());
sysDept.setSortOrder(dept.getOrder().intValue());
return sysDept;
}).forEach(sysDeptService::saveDept);
}).forEach(sysDeptService::save);
return R.ok();
}
@@ -16,19 +16,47 @@
*/
package com.pig4cloud.pigx.admin.service.impl;
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.pigx.admin.api.entity.SysAuditLog;
import com.pig4cloud.pigx.admin.mapper.SysAuditLogMapper;
import com.pig4cloud.pigx.admin.service.SysAuditLogService;
import com.pig4cloud.pigx.common.data.datascope.DataScope;
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
import org.springframework.stereotype.Service;
/**
* 审计记录表
*
* @author pigx code generator
* @date 2023-02-27 22:33:30
* @author PIG
* @date 2023-02-28 20:12:23
*/
@Service
public class SysAuditLogServiceImpl extends ServiceImpl<SysAuditLogMapper, SysAuditLog> implements SysAuditLogService {
/**
* 分页查询审计日志(数据权限处理)
* @param page 分页条件
* @param sysAuditLog 查询条件
* @return page
*/
@Override
public Page<SysAuditLog> getAuditsByScope(Page page, SysAuditLog sysAuditLog) {
LambdaQueryWrapper<SysAuditLog> wrapper = Wrappers.lambdaQuery();
wrapper.like(StrUtil.isNotBlank(sysAuditLog.getAuditName()), SysAuditLog::getAuditName,
sysAuditLog.getAuditName());
wrapper.like(StrUtil.isNotBlank(sysAuditLog.getAuditField()), SysAuditLog::getAuditField,
sysAuditLog.getAuditField());
wrapper.like(StrUtil.isNotBlank(sysAuditLog.getCreateBy()), SysAuditLog::getCreateBy,
sysAuditLog.getCreateBy());
// 数据权限限制,只查询本人的审计日志
DataScope dataScope = new DataScope();
dataScope.setUsername(SecurityUtils.getUser().getUsername());
return baseMapper.selectPageByScope(page, wrapper, dataScope);
}
}
@@ -1,96 +0,0 @@
/*
*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*
*/
package com.pig4cloud.pigx.admin.service.impl;
import cn.hutool.core.collection.CollUtil;
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.SysDeptRelation;
import com.pig4cloud.pigx.admin.mapper.SysDeptRelationMapper;
import com.pig4cloud.pigx.admin.service.SysDeptRelationService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
/**
* <p>
* 服务实现类
* </p>
*
* @author lengleng
* @since 2018-02-12
*/
@Service
@AllArgsConstructor
public class SysDeptRelationServiceImpl extends ServiceImpl<SysDeptRelationMapper, SysDeptRelation>
implements SysDeptRelationService {
private final SysDeptRelationMapper sysDeptRelationMapper;
/**
* 维护部门关系
* @param sysDept 部门
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void insertDeptRelation(SysDept sysDept) {
// 增加部门关系表
List<SysDeptRelation> relationList = sysDeptRelationMapper.selectList(
Wrappers.<SysDeptRelation>query().lambda().eq(SysDeptRelation::getDescendant, sysDept.getParentId()))
.stream().map(relation -> {
relation.setDescendant(sysDept.getDeptId());
return relation;
}).collect(Collectors.toList());
if (CollUtil.isNotEmpty(relationList)) {
relationList.forEach(ele -> baseMapper.insert(ele));
}
// 自己也要维护到关系表中
SysDeptRelation own = new SysDeptRelation();
own.setDescendant(sysDept.getDeptId());
own.setAncestor(sysDept.getDeptId());
sysDeptRelationMapper.insert(own);
}
/**
* 通过ID删除部门关系
* @param id
*/
@Override
public void deleteAllDeptRealtion(Long id) {
baseMapper.deleteDeptRelationsByDeptId(id);
}
/**
* 更新部门关系
* @param relation
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void updateDeptRealtion(SysDeptRelation relation) {
baseMapper.deleteDeptRelations(relation);
baseMapper.insertDeptRelations(relation);
}
}
@@ -27,10 +27,8 @@ 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.SysDeptRelation;
import com.pig4cloud.pigx.admin.api.vo.DeptExcelVo;
import com.pig4cloud.pigx.admin.mapper.SysDeptMapper;
import com.pig4cloud.pigx.admin.service.SysDeptRelationService;
import com.pig4cloud.pigx.admin.service.SysDeptService;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.data.datascope.DataScope;
@@ -56,25 +54,8 @@ import java.util.stream.Collectors;
@AllArgsConstructor
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements SysDeptService {
private final SysDeptRelationService sysDeptRelationService;
private final SysDeptMapper deptMapper;
/**
* 添加信息部门
* @param dept 部门
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean saveDept(SysDept dept) {
SysDept sysDept = new SysDept();
BeanUtils.copyProperties(dept, sysDept);
this.save(sysDept);
sysDeptRelationService.insertDeptRelation(sysDept);
return Boolean.TRUE;
}
/**
* 删除部门
* @param id 部门 ID
@@ -84,97 +65,17 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
@Transactional(rollbackFor = Exception.class)
public Boolean removeDeptById(Long id) {
// 级联删除部门
List<Long> idList = sysDeptRelationService
.list(Wrappers.<SysDeptRelation>query().lambda().eq(SysDeptRelation::getAncestor, id)).stream()
.map(SysDeptRelation::getDescendant).collect(Collectors.toList());
List<Long> idList = baseMapper.listDescendant(id).stream().map(SysDept::getDeptId).collect(Collectors.toList());
if (CollUtil.isNotEmpty(idList)) {
this.removeByIds(idList);
}
Optional.ofNullable(idList).filter(CollUtil::isNotEmpty).ifPresent(this::removeByIds);
// 删除部门级联关系
sysDeptRelationService.deleteAllDeptRealtion(id);
return Boolean.TRUE;
}
/**
* 更新部门
* @param sysDept 部门信息
* @return 成功、失败
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean updateDeptById(SysDept sysDept) {
// 更新部门状态
this.updateById(sysDept);
// 更新部门关系
SysDeptRelation relation = new SysDeptRelation();
relation.setAncestor(sysDept.getParentId());
relation.setDescendant(sysDept.getDeptId());
sysDeptRelationService.updateDeptRealtion(relation);
return Boolean.TRUE;
}
/**
* 导出部门
* @return
*/
@Override
public List<DeptExcelVo> listExcelVo() {
List<SysDept> list = this.list();
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();
deptExcelVo.setParentName(first.orElse("跟部门"));
deptExcelVo.setSortOrder(item.getSortOrder());
return deptExcelVo;
}).collect(Collectors.toList());
return deptExcelVos;
}
@Override
public R importDept(List<DeptExcelVo> excelVOList, BindingResult bindingResult) {
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
List<SysDept> deptList = this.list();
for (DeptExcelVo item : excelVOList) {
Set<String> errorMsg = new HashSet<>();
boolean exsitUsername = deptList.stream().anyMatch(sysDept -> item.getName().equals(sysDept.getName()));
if (exsitUsername) {
errorMsg.add("部门名称已经存在");
}
SysDept one = this.getOne(Wrappers.<SysDept>lambdaQuery().eq(SysDept::getName, item.getParentName()));
if (item.getParentName().equals("跟部门")) {
one = new SysDept();
one.setDeptId(0L);
}
if (one == null) {
errorMsg.add("上级部门不存在");
}
if (CollUtil.isEmpty(errorMsg)) {
SysDept sysDept = new SysDept();
sysDept.setName(item.getName());
sysDept.setParentId(one.getDeptId());
sysDept.setSortOrder(item.getSortOrder());
this.saveDept(sysDept);
}
else {
// 数据不合法情况
errorMessageList.add(new ErrorMessage(item.getLineNum(), errorMsg));
}
}
if (CollUtil.isNotEmpty(errorMessageList)) {
return R.failed(errorMessageList);
}
return R.ok(null, "部门导入成功");
}
/**
* 查询全部部门树
* @return 树 部门名称
* @param deptName
* @return 树 部门名称
*/
@Override
public List<Tree<Long>> selectTree(String deptName) {
@@ -216,4 +117,70 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
return TreeUtil.build(collect, 0L);
}
/**
* 导出部门
* @return
*/
@Override
public List<DeptExcelVo> listExcelVo() {
List<SysDept> list = this.list();
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();
deptExcelVo.setParentName(first.orElse("根部门"));
deptExcelVo.setSortOrder(item.getSortOrder());
return deptExcelVo;
}).collect(Collectors.toList());
return deptExcelVos;
}
@Override
public R importDept(List<DeptExcelVo> excelVOList, BindingResult bindingResult) {
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
List<SysDept> deptList = this.list();
for (DeptExcelVo item : excelVOList) {
Set<String> errorMsg = new HashSet<>();
boolean exsitUsername = deptList.stream().anyMatch(sysDept -> item.getName().equals(sysDept.getName()));
if (exsitUsername) {
errorMsg.add("部门名称已经存在");
}
SysDept one = this.getOne(Wrappers.<SysDept>lambdaQuery().eq(SysDept::getName, item.getParentName()));
if (item.getParentName().equals("根部门")) {
one = new SysDept();
one.setDeptId(0L);
}
if (one == null) {
errorMsg.add("上级部门不存在");
}
if (CollUtil.isEmpty(errorMsg)) {
SysDept sysDept = new SysDept();
sysDept.setName(item.getName());
sysDept.setParentId(one.getDeptId());
sysDept.setSortOrder(item.getSortOrder());
baseMapper.insert(sysDept);
}
else {
// 数据不合法情况
errorMessageList.add(new ErrorMessage(item.getLineNum(), errorMsg));
}
}
if (CollUtil.isNotEmpty(errorMessageList)) {
return R.failed(errorMessageList);
}
return R.ok(null, "部门导入成功");
}
/**
* 获取部门的所有后代部门列表
* @param deptId 部门ID
* @return 后代部门列表
*/
@Override
public List<SysDept> listDescendant(Long deptId) {
return baseMapper.listDescendant(deptId);
}
}
@@ -16,6 +16,7 @@
*/
package com.pig4cloud.pigx.admin.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.pigx.admin.api.entity.SysDict;
@@ -33,6 +34,9 @@ import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
/**
* 字典表
*
@@ -47,21 +51,21 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
/**
* 根据ID 删除字典
* @param id 字典ID
* @param ids 字典ID 列表
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
@CacheEvict(value = CacheConstants.DICT_DETAILS, allEntries = true)
public R removeDict(Long id) {
SysDict dict = this.getById(id);
// 系统内置
if (DictTypeEnum.SYSTEM.getType().equals(dict.getSystemFlag())) {
return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_DICT_DELETE_SYSTEM));
}
public R removeDictByIds(Long[] ids) {
baseMapper.deleteById(id);
dictItemMapper.delete(Wrappers.<SysDictItem>lambdaQuery().eq(SysDictItem::getDictId, id));
List<Long> dictIdList = baseMapper.selectBatchIds(CollUtil.toList(ids)).stream()
.filter(sysDict -> !sysDict.getSystemFlag().equals(DictTypeEnum.SYSTEM.getType()))// 系统内置类型不删除
.map(SysDict::getId).collect(Collectors.toList());
baseMapper.deleteBatchIds(dictIdList);
dictItemMapper.delete(Wrappers.<SysDictItem>lambdaQuery().in(SysDictItem::getDictId, dictIdList));
return R.ok();
}
@@ -78,7 +82,8 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
if (DictTypeEnum.SYSTEM.getType().equals(sysDict.getSystemFlag())) {
return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_DICT_UPDATE_SYSTEM));
}
return R.ok(this.updateById(dict));
this.updateById(dict);
return R.ok(dict);
}
/**
@@ -37,8 +37,10 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
* 文件管理
@@ -107,6 +109,9 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> impl
@Transactional(rollbackFor = Exception.class)
public Boolean deleteFile(Long id) {
SysFile file = this.getById(id);
if (Objects.isNull(file)) {
return Boolean.FALSE;
}
fileTemplate.removeObject(properties.getBucketName(), file.getFileName());
return this.removeById(id);
}
@@ -0,0 +1,77 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.admin.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.pigx.admin.api.entity.SysI18nEntity;
import com.pig4cloud.pigx.admin.mapper.SysI18nMapper;
import com.pig4cloud.pigx.admin.service.SysI18nService;
import com.pig4cloud.pigx.common.core.constant.CacheConstants;
import com.pig4cloud.pigx.common.core.util.R;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 系统表-国际化
*
* @author PIG
* @date 2023-02-14 09:07:01
*/
@Service
public class SysI18nServiceImpl extends ServiceImpl<SysI18nMapper, SysI18nEntity> implements SysI18nService {
/**
* 生成前段需要的i18n 格式内容
* @return
*/
@Override
@Cacheable(value = CacheConstants.I18N_DETAILS)
public Map listMap() {
List<SysI18nEntity> sysI18nEntities = baseMapper.selectList(null);
HashMap<String, List<Map<String, String>>> stringListHashMap = new HashMap<>();
List<Map<String, String>> zhCh = new ArrayList<>();
List<Map<String, String>> en = new ArrayList<>();
sysI18nEntities.forEach(item -> {
HashMap<String, String> zhChMap = new HashMap<>();
HashMap<String, String> enMap = new HashMap<>();
zhChMap.put(item.getName(), item.getZhCn());
enMap.put(item.getName(), item.getEn());
zhCh.add(zhChMap);
en.add(enMap);
});
stringListHashMap.put("zh-cn", zhCh);
stringListHashMap.put("en", en);
return stringListHashMap;
}
/**
* 同步数据
* @return
*/
@Override
@CacheEvict(value = CacheConstants.I18N_DETAILS, allEntries = true)
public R syncI18nCache() {
return R.ok();
}
}
@@ -23,13 +23,16 @@ import cn.hutool.core.collection.CollUtil;
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.BooleanUtil;
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.SysI18nEntity;
import com.pig4cloud.pigx.admin.api.entity.SysMenu;
import com.pig4cloud.pigx.admin.api.entity.SysRoleMenu;
import com.pig4cloud.pigx.admin.mapper.SysMenuMapper;
import com.pig4cloud.pigx.admin.mapper.SysRoleMenuMapper;
import com.pig4cloud.pigx.admin.service.SysI18nService;
import com.pig4cloud.pigx.admin.service.SysMenuService;
import com.pig4cloud.pigx.common.core.constant.CacheConstants;
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
@@ -38,6 +41,7 @@ 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 lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
@@ -45,10 +49,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.validation.constraints.NotNull;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
@@ -63,10 +64,13 @@ import java.util.stream.Collectors;
*/
@Service
@AllArgsConstructor
@Slf4j
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements SysMenuService {
private final SysRoleMenuMapper sysRoleMenuMapper;
private final SysI18nService sysI18nService;
@Override
@Cacheable(value = CacheConstants.MENU_DETAILS, key = "#roleId", unless = "#result.isEmpty()")
public List<SysMenu> findMenuByRoleId(Long roleId) {
@@ -101,13 +105,13 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
* @return
*/
@Override
public List<Tree<Long>> treeMenu(Long parentId, String menuName) {
public List<Tree<Long>> treeMenu(Long parentId, String menuName, String type) {
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)
.orderByAsc(SysMenu::getSortOrder))
.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());
// 模糊查询 不组装树结构 直接返回 表格方便编辑
@@ -132,8 +136,14 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
*/
@Override
public List<Tree<Long>> filterMenu(Set<SysMenu> all, String type, Long parentId) {
List<TreeNode<Long>> collect = all.stream().filter(menuTypePredicate(type)).map(getNodeFunction())
.collect(Collectors.toList());
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());
}
}).map(getNodeFunction()).collect(Collectors.toList());
Long parent = parentId == null ? CommonConstants.MENU_TREE_ROOT_ID : parentId;
return TreeUtil.build(collect, parent);
}
@@ -148,14 +158,22 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
node.setWeight(menu.getSortOrder());
// 扩展属性
Map<String, Object> extra = new HashMap<>();
extra.put("icon", menu.getIcon());
extra.put("path", menu.getPath());
extra.put("menuType", menu.getMenuType());
extra.put("permission", menu.getPermission());
extra.put("label", menu.getName());
extra.put("sortOrder", menu.getSortOrder());
extra.put("keepAlive", menu.getKeepAlive());
extra.put("visible", menu.getVisible());
// 适配 vue3
Map<String, Object> meta = new HashMap<>();
meta.put("title", menu.getName());
meta.put("isLink", menu.getPath() != null && menu.getPath().startsWith("http") ? menu.getPath() : "");
meta.put("isHide", !BooleanUtil.toBooleanObject(menu.getVisible()));
meta.put("isKeepAlive", BooleanUtil.toBooleanObject(menu.getKeepAlive()));
meta.put("isAffix", false);
meta.put("isIframe", BooleanUtil.toBooleanObject(menu.getEmbedded()));
meta.put("icon", menu.getIcon());
extra.put("meta", meta);
node.setExtra(extra);
return node;
};
@@ -55,30 +55,14 @@ import java.util.stream.Collectors;
public class SysOauthClientDetailsServiceImpl extends ServiceImpl<SysOauthClientDetailsMapper, SysOauthClientDetails>
implements SysOauthClientDetailsService {
/**
* 通过ID删除客户端
* @param clientId
* @return
*/
@Override
@CacheEvict(value = CacheConstants.CLIENT_DETAILS_KEY, key = "#clientId")
public Boolean removeByClientId(String clientId) {
// 更新库
baseMapper
.delete(Wrappers.<SysOauthClientDetails>lambdaQuery().eq(SysOauthClientDetails::getClientId, clientId));
// 更新Redis
SpringContextHolder.publishEvent(new ClientDetailsInitRunner.ClientDetailsInitEvent(clientId));
return Boolean.TRUE;
}
/**
* 根据客户端信息
* @param clientDetailsDTO
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
@CacheEvict(value = CacheConstants.CLIENT_DETAILS_KEY, key = "#clientDetailsDTO.clientId")
@Transactional(rollbackFor = Exception.class)
public Boolean updateClientById(SysOauthClientDetailsDTO clientDetailsDTO) {
this.insertOrUpdate(clientDetailsDTO);
return Boolean.TRUE;
@@ -152,7 +136,6 @@ public class SysOauthClientDetailsServiceImpl extends ServiceImpl<SysOauthClient
}
@Override
@Transactional
@CacheEvict(value = CacheConstants.CLIENT_DETAILS_KEY, allEntries = true)
public R syncClientCache() {
// 更新Redis
@@ -17,6 +17,7 @@
package com.pig4cloud.pigx.admin.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.pigx.admin.api.entity.SysPublicParam;
@@ -32,6 +33,9 @@ import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
/**
* 公共参数配置
*
@@ -73,18 +77,16 @@ public class SysPublicParamServiceImpl extends ServiceImpl<SysPublicParamMapper,
/**
* 删除参数
* @param publicId
* @param publicIds 参数ID列表
* @return
*/
@Override
@CacheEvict(value = CacheConstants.PARAMS_DETAILS, allEntries = true)
public R removeParam(Long publicId) {
SysPublicParam param = this.getById(publicId);
// 系统内置
if (DictTypeEnum.SYSTEM.getType().equals(param.getSystemFlag())) {
return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_PARAM_DELETE_SYSTEM));
}
return R.ok(this.removeById(publicId));
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());
return R.ok(this.removeBatchByIds(idList));
}
/**
@@ -74,7 +74,7 @@ public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRo
// 清空userinfo
cacheManager.getCache(CacheConstants.USER_DETAILS).clear();
roleMenuList.forEach(ele -> baseMapper.insert(ele));
this.saveBatch(roleMenuList);
return Boolean.TRUE;
}
@@ -77,21 +77,22 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
* @return
*/
@Override
@Cacheable(value = CacheConstants.ROLE_DETAILS, key = "#key")
@Cacheable(value = CacheConstants.ROLE_DETAILS, key = "#key", unless = "#result.isEmpty()")
public List<SysRole> findRolesByRoleIds(List<Long> roleIdList, String key) {
return baseMapper.selectBatchIds(roleIdList);
}
/**
* 通过角色ID,删除角色,并清空角色菜单缓存
* @param id
* @param ids
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean removeRoleById(Long id) {
roleMenuService.remove(Wrappers.<SysRoleMenu>update().lambda().eq(SysRoleMenu::getRoleId, id));
return this.removeById(id);
public Boolean removeRoleByIds(Long[] ids) {
roleMenuService
.remove(Wrappers.<SysRoleMenu>update().lambda().in(SysRoleMenu::getRoleId, CollUtil.toList(ids)));
return this.removeBatchByIds(CollUtil.toList(ids));
}
/**
@@ -0,0 +1,71 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.admin.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.pigx.admin.api.entity.SysScheduleEntity;
import com.pig4cloud.pigx.admin.mapper.SysScheduleMapper;
import com.pig4cloud.pigx.admin.service.SysScheduleService;
import com.pig4cloud.pigx.common.data.datascope.DataScope;
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.List;
import java.util.Objects;
/**
* 日程
*
* @author aeizzz
* @date 2023-03-06 14:26:23
*/
@Service
public class SysScheduleServiceImpl extends ServiceImpl<SysScheduleMapper, SysScheduleEntity>
implements SysScheduleService {
@Override
public IPage<SysScheduleEntity> getScheduleByScope(Page page, SysScheduleEntity sysSchedule) {
LambdaQueryWrapper<SysScheduleEntity> wrapper = Wrappers.lambdaQuery();
wrapper.like(StrUtil.isNotBlank(sysSchedule.getTitle()), SysScheduleEntity::getTitle, sysSchedule.getTitle());
wrapper.like(StrUtil.isNotBlank(sysSchedule.getType()), SysScheduleEntity::getType, sysSchedule.getType());
wrapper.eq(Objects.nonNull(sysSchedule.getDate()), SysScheduleEntity::getDate, sysSchedule.getDate());
DataScope dataScope = new DataScope();
dataScope.setUsername(SecurityUtils.getUser().getUsername());
return baseMapper.selectPageByScope(page, wrapper, dataScope);
}
@Override
public List<SysScheduleEntity> selectListByScope(String month) {
LocalDate parse = LocalDate.parse(month, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
LocalDate firstDay = parse.with(TemporalAdjusters.firstDayOfMonth()); // 获取当前月的第一天
LocalDate lastDay = parse.with(TemporalAdjusters.lastDayOfMonth());
LambdaQueryWrapper<SysScheduleEntity> wrapper = Wrappers.lambdaQuery();
wrapper.between(SysScheduleEntity::getDate, firstDay, lastDay);
DataScope dataScope = new DataScope();
dataScope.setUsername(SecurityUtils.getUser().getUsername());
return baseMapper.selectListByScope(wrapper, dataScope);
}
}
@@ -43,7 +43,7 @@ import java.util.stream.Collectors;
/**
* 租户
*
* <p>
* mybatis-plus 3.4.3.3 特殊处理 https://github.com/baomidou/mybatis-plus/pull/3592
*
* @author lengleng
@@ -57,8 +57,6 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
private final SysOauthClientDetailsService clientServices;
private final SysDeptRelationService deptRelationService;
private final SysUserRoleService userRoleService;
private final SysRoleMenuMapper roleMenuMapper;
@@ -118,9 +116,9 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
List<SysDict> dictList = new ArrayList<>(32);
List<Long> dictIdList = new ArrayList<>(32);
List<SysDictItem> dictItemList = new ArrayList<>(64);
List<SysMenu> menuList = new ArrayList<>(128);
List<SysOauthClientDetails> clientDetailsList = new ArrayList<>(16);
List<SysPublicParam> publicParamList = new ArrayList<>(64);
List<SysMenu> menuList = new ArrayList<>();
TenantBroker.runAs(defaultId, (id) -> {
// 查询系统内置字典
@@ -129,27 +127,24 @@ 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));
// 查询当前租户菜单
menuList.addAll(newMenuList);
// 查询客户端配置
clientDetailsList.addAll(clientServices.list());
// 查询系统参数配置
publicParamList.addAll(paramService.list());
SysTenantMenu tenantMenu = sysTenantMenuService.getById(sysTenant.getMenuId());
String[] split = tenantMenu.getMenuIds().split(",");
List<SysMenu> newMenuList = menuService.list(Wrappers.<SysMenu>lambdaQuery().in(SysMenu::getMenuId, split));
menuList.addAll(newMenuList);
});
// 保证插入租户为新的租户
TenantBroker.applyAs(sysTenant.getId(), (id -> {
// 插入部门
SysDept dept = new SysDept();
dept.setName(defaultDeptName);
dept.setParentId(0L);
deptService.save(dept);
// 维护部门关系
deptRelationService.insertDeptRelation(dept);
// 构造初始化用户
SysUser user = new SysUser();
user.setUsername(defaultUsername);
@@ -176,7 +171,6 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
userRole.setRoleId(role.getRoleId());
userRoleService.save(userRole);
// 插入新的菜单
saveTenantMenu(menuList, CommonConstants.MENU_TREE_ROOT_ID, CommonConstants.MENU_TREE_ROOT_ID);
// 重新查询出所有的菜单关联角色
@@ -36,16 +36,4 @@ import org.springframework.stereotype.Service;
@Service
public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUserRole> implements SysUserRoleService {
/**
* 根据用户Id删除该用户的角色关系
* @param userId 用户ID
* @return boolean
* @author 寻欢·李
* @date 2017年12月7日 16:31:38
*/
@Override
public Boolean deleteByUserId(Long userId) {
return baseMapper.deleteByUserId(userId);
}
}
@@ -22,6 +22,8 @@ package com.pig4cloud.pigx.admin.service.impl;
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.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -29,13 +31,13 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.pigx.admin.api.dto.UserDTO;
import com.pig4cloud.pigx.admin.api.dto.UserInfo;
import com.pig4cloud.pigx.admin.api.entity.*;
import com.pig4cloud.pigx.admin.api.vo.CpUserExcelVo;
import com.pig4cloud.pigx.admin.api.vo.DingUserExcelVo;
import com.pig4cloud.pigx.admin.api.vo.UserExcelVO;
import com.pig4cloud.pigx.admin.api.vo.UserVO;
import com.pig4cloud.pigx.admin.mapper.SysUserMapper;
import com.pig4cloud.pigx.admin.mapper.SysUserPostMapper;
import com.pig4cloud.pigx.admin.mapper.SysUserRoleMapper;
import com.pig4cloud.pigx.admin.service.*;
import com.pig4cloud.pigx.common.audit.annotation.Audit;
import com.pig4cloud.pigx.common.core.constant.CacheConstants;
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
import com.pig4cloud.pigx.common.core.exception.ErrorCodes;
@@ -44,9 +46,13 @@ import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.data.datascope.DataScope;
import com.pig4cloud.pigx.common.data.resolver.ParamResolver;
import com.pig4cloud.pigx.common.excel.vo.ErrorMessage;
import com.pig4cloud.pigx.common.security.service.PigxUser;
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
@@ -73,12 +79,16 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
private final SysRoleService sysRoleService;
private final SysPostService sysPostService;
private final SysDeptService sysDeptService;
private final SysUserRoleService sysUserRoleService;
private final SysUserRoleMapper sysUserRoleMapper;
private final SysUserPostMapper sysUserPostMapper;
private final CacheManager cacheManager;
/**
* 保存用户信息
* @param userDto DTO 对象
@@ -112,13 +122,14 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
userDto.setRole(Collections.singletonList(sysRole.getRoleId()));
}
List<SysUserRole> userRoleList = userDto.getRole().stream().map(roleId -> {
// 插入用户角色关系表
userDto.getRole().stream().map(roleId -> {
SysUserRole userRole = new SysUserRole();
userRole.setUserId(sysUser.getUserId());
userRole.setRoleId(roleId);
return userRole;
}).collect(Collectors.toList());
return sysUserRoleService.saveBatch(userRoleList);
}).forEach(sysUserRoleMapper::insert);
return Boolean.TRUE;
}
/**
@@ -170,16 +181,21 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
/**
* 删除用户
* @param sysUser 用户
* @param ids 用户ID 列表
* @return Boolean
*/
@Override
@CacheEvict(value = CacheConstants.USER_DETAILS, key = "#sysUser.username")
public Boolean deleteUserById(SysUser sysUser) {
sysUserRoleService.deleteByUserId(sysUser.getUserId());
// 删除用户部门信息
sysUserPostMapper.delete(Wrappers.<SysUserPost>lambdaQuery().eq(SysUserPost::getUserId, sysUser.getUserId()));
this.removeById(sysUser.getUserId());
@Transactional(rollbackFor = Exception.class)
public Boolean deleteUserByIds(Long[] ids) {
// 删除 spring cache
List<SysUser> userList = baseMapper.selectBatchIds(CollUtil.toList(ids));
Cache cache = cacheManager.getCache(CacheConstants.USER_DETAILS);
for (SysUser sysUser : userList) {
cache.evict(sysUser.getUsername());
}
sysUserRoleMapper.delete(Wrappers.<SysUserRole>lambdaQuery().in(SysUserRole::getUserId, CollUtil.toList(ids)));
this.removeBatchByIds(CollUtil.toList(ids));
return Boolean.TRUE;
}
@@ -187,15 +203,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
@CacheEvict(value = CacheConstants.USER_DETAILS, key = "#userDto.username")
public R<Boolean> updateUserInfo(UserDTO userDto) {
UserVO userVO = baseMapper.getUserVoByUsername(userDto.getUsername());
if (!ENCODER.matches(userDto.getPassword(), userVO.getPassword())) {
log.info("原密码错误,修改个人信息失败:{}", userDto.getUsername());
return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_UPDATE_PASSWORDERROR));
}
SysUser sysUser = new SysUser();
if (StrUtil.isNotBlank(userDto.getNewpassword1())) {
sysUser.setPassword(ENCODER.encode(userDto.getNewpassword1()));
}
sysUser.setPhone(userDto.getPhone());
sysUser.setUserId(userVO.getUserId());
sysUser.setAvatar(userDto.getAvatar());
@@ -207,40 +216,36 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
@Override
@Transactional(rollbackFor = Exception.class)
@Audit(name = "用户更新", spel = "@sysUserMapper.selectById(#userDto.userId)")
@CacheEvict(value = CacheConstants.USER_DETAILS, key = "#userDto.username")
public R<Boolean> updateUser(UserDTO userDto) {
public Boolean updateUser(UserDTO userDto) {
// 更新用户表信息
SysUser sysUser = new SysUser();
boolean exists = baseMapper.exists(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getPhone, userDto.getPhone())
.ne(SysUser::getUserId, userDto.getUserId()));
if (exists) {
return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_PHONE_EXISTING, userDto.getPhone()));
}
BeanUtils.copyProperties(userDto, sysUser);
sysUser.setUpdateTime(LocalDateTime.now());
if (StrUtil.isNotBlank(userDto.getPassword())) {
sysUser.setPassword(ENCODER.encode(userDto.getPassword()));
}
this.updateById(sysUser);
sysUserRoleService
.remove(Wrappers.<SysUserRole>update().lambda().eq(SysUserRole::getUserId, userDto.getUserId()));
userDto.getRole().forEach(roleId -> {
// 更新用户角色表
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);
userRole.insert();
});
return userRole;
}).forEach(SysUserRole::insert);
// 更新用户岗位表
sysUserPostMapper.delete(Wrappers.<SysUserPost>lambdaQuery().eq(SysUserPost::getUserId, userDto.getUserId()));
userDto.getPost().forEach(postId -> {
userDto.getPost().stream().map(postId -> {
SysUserPost userPost = new SysUserPost();
userPost.setUserId(sysUser.getUserId());
userPost.setPostId(postId);
userPost.insert();
});
return R.ok();
return userPost;
}).forEach(SysUserPost::insert);
return Boolean.TRUE;
}
/**
@@ -277,6 +282,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
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));
excelVO.setPostNameList(postNameList);
return excelVO;
}).collect(Collectors.toList());
return userExcelVOList;
@@ -292,14 +300,15 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
public R importUser(List<UserExcelVO> excelVOList, BindingResult bindingResult) {
// 通用校验获取失败的数据
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
// 个性化校验逻辑
List<SysUser> userList = this.list();
List<SysDept> deptList = sysDeptService.list();
List<SysRole> roleList = sysRoleService.list();
List<SysPost> postList = sysPostService.list();
// 执行数据插入操作 组装 UserDto
for (UserExcelVO excel : excelVOList) {
// 个性化校验逻辑
List<SysUser> userList = this.list();
Set<String> errorMsg = new HashSet<>();
// 校验用户名是否存在
boolean exsitUserName = userList.stream()
@@ -326,9 +335,19 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_ROLE_ROLENAME_INEXISTENCE, excel.getRoleNameList()));
}
// 判断输入的部门名称列表是否合法
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());
if (postCollList.size() != postNameList.size()) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_POST_POSTNAME_INEXISTENCE, excel.getPostNameList()));
}
// 数据合法情况
if (CollUtil.isEmpty(errorMsg)) {
insertExcelUser(excel, deptOptional, roleCollList);
insertExcelUser(excel, deptOptional, roleCollList, postCollList);
}
else {
// 数据不合法情况
@@ -346,7 +365,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
/**
* 插入excel User
*/
private void insertExcelUser(UserExcelVO excel, Optional<SysDept> deptOptional, List<SysRole> roleCollList) {
private void insertExcelUser(UserExcelVO excel, Optional<SysDept> deptOptional, List<SysRole> roleCollList,
List<SysPost> postCollList) {
UserDTO userDTO = new UserDTO();
userDTO.setUsername(excel.getUsername());
userDTO.setPhone(excel.getPhone());
@@ -357,6 +377,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
userDTO.setPassword(userDTO.getPhone());
// 根据部门名称查询部门ID
userDTO.setDeptId(deptOptional.get().getDeptId());
// 插入岗位名称
List<Long> postIdList = postCollList.stream().map(SysPost::getPostId).collect(Collectors.toList());
userDTO.setPost(postIdList);
// 根据角色名称查询角色ID
List<Long> roleIdList = roleCollList.stream().map(SysRole::getRoleId).collect(Collectors.toList());
userDTO.setRole(roleIdList);
@@ -394,122 +417,77 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
sysUser.setLockFlag(CommonConstants.STATUS_LOCK);
baseMapper.updateById(sysUser);
}
return R.ok();
}
@Override
public R importDingUser(List<DingUserExcelVo> excelVOList, BindingResult bindingResult) {
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
// 个性化校验逻辑
List<SysUser> userList = this.list();
List<SysDept> deptList = sysDeptService.list();
for (DingUserExcelVo item : excelVOList) {
Set<String> errorMsg = new HashSet<>();
boolean exsitUser = userList.stream().anyMatch(sysUser -> item.getName().equals(sysUser.getName()));
if (exsitUser) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_USER_USERNAME_EXISTING, item.getName()));
}
// 删除手机号中的 +86 前缀
String phone = item.getPhone().split("-")[1];
boolean exsitPhone = userList.stream().anyMatch(sysUser -> phone.equals(sysUser.getPhone()));
if (exsitPhone) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_USER_PHONE_EXISTING, item.getPhone()));
}
// 根据规则获取部门信息
String[] deptNameList = item.getDeptName().split(",")[0].split("-");
String deptName = deptNameList[deptNameList.length - 1];
// 判断输入的部门名称列表是否合法
Optional<SysDept> deptOptional = deptList.stream().filter(dept -> deptName.equals(dept.getName()))
.findFirst();
if (!deptOptional.isPresent()) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_DEPT_DEPTNAME_INEXISTENCE, item.getDeptName()));
}
// 数据合法情况
if (CollUtil.isEmpty(errorMsg)) {
UserDTO userDTO = new UserDTO();
userDTO.setName(item.getName());
// 批量导入初始密码为手机号
userDTO.setPassword(phone);
userDTO.setUsername(phone);
userDTO.setPhone(phone);
userDTO.setDeptId(deptOptional.get().getDeptId());
userDTO.setDelFlag(item.getLockFlag());
userDTO.setEmail(item.getEmail());
this.saveUser(userDTO);
}
else {
// 数据不合法情况
errorMessageList.add(new ErrorMessage(item.getLineNum(), errorMsg));
}
@CacheEvict(value = CacheConstants.USER_DETAILS, key = "#userDto.username")
public R changePassword(UserDTO userDto) {
UserVO userVO = baseMapper.getUserVoByUsername(userDto.getUsername());
if (Objects.isNull(userVO)) {
return R.failed("用户不存在");
}
if (CollUtil.isNotEmpty(errorMessageList)) {
return R.failed(errorMessageList);
if (StrUtil.isEmpty(userDto.getPassword())) {
return R.failed("原密码不能为空");
}
return R.ok(null, MsgUtils.getMessage(ErrorCodes.SYS_USER_IMPORT_SUCCEED));
if (!ENCODER.matches(userDto.getPassword(), userVO.getPassword())) {
log.info("原密码错误,修改个人信息失败:{}", userDto.getUsername());
return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_UPDATE_PASSWORDERROR));
}
if (StrUtil.isEmpty(userDto.getNewpassword1())) {
return R.failed("新密码不能为空");
}
String password = ENCODER.encode(userDto.getNewpassword1());
this.update(Wrappers.<SysUser>lambdaUpdate().set(SysUser::getPassword, password).eq(SysUser::getUserId,
userVO.getUserId()));
return R.ok();
}
/**
* 企业微信用户导入
* @param excelVOList
* @param bindingResult
* @return
*/
@Override
public R importCpUser(List<CpUserExcelVo> excelVOList, BindingResult bindingResult) {
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
// 个性化校验逻辑
List<SysUser> userList = this.list();
List<SysDept> deptList = sysDeptService.list();
for (CpUserExcelVo item : excelVOList) {
Set<String> errorMsg = new HashSet<>();
boolean exsitUsername = userList.stream()
.anyMatch(sysUser -> item.getUsername().equals(sysUser.getUsername()));
if (exsitUsername) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_USER_USERNAME_EXISTING, item.getUsername()));
}
boolean exsitPhone = userList.stream().anyMatch(sysUser -> item.getPhone().equals(sysUser.getPhone()));
if (exsitPhone) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_USER_PHONE_EXISTING, item.getPhone()));
}
// 多部门获取第一个 到部门获取自己点
String[] deptNameList = item.getDeptName().split(";")[0].split("/");
String deptName = deptNameList[deptNameList.length - 1];
// 判断输入的部门名称列表是否合法
Optional<SysDept> deptOptional = deptList.stream().filter(dept -> deptName.equals(dept.getName()))
.findFirst();
if (!deptOptional.isPresent()) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_DEPT_DEPTNAME_INEXISTENCE, deptName));
}
// 数据合法情况
if (CollUtil.isEmpty(errorMsg)) {
UserDTO userDTO = new UserDTO();
userDTO.setName(item.getName());
// 批量导入初始密码为手机号
userDTO.setPassword(item.getPhone());
userDTO.setUsername(item.getUsername());
userDTO.setPhone(item.getPhone());
userDTO.setDeptId(deptOptional.get().getDeptId());
userDTO.setDelFlag(item.getLockFlag());
userDTO.setEmail(item.getEmail());
userDTO.setNickname(item.getNickname());
this.saveUser(userDTO);
}
else {
// 数据不合法情况
errorMessageList.add(new ErrorMessage(item.getLineNum(), errorMsg));
}
public R unbinding(String type) {
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());
}
if (CollUtil.isNotEmpty(errorMessageList)) {
return R.failed(errorMessageList);
else if (type.equals("gitee")) {
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());
}
else if (type.equals("tencent")) {
wrapper = Wrappers.<SysUser>lambdaUpdate().set(SysUser::getTenantId, null).eq(SysUser::getUserId,
user.getId());
}
if (wrapper == null) {
return R.failed("解绑账号类型不存在");
}
this.update(wrapper);
return R.ok();
}
@Override
public R checkPassword(String password) {
String username = SecurityUtils.getUser().getUsername();
SysUser condition = new SysUser();
condition.setUsername(username);
SysUser sysUser = this.getOne(new QueryWrapper<>(condition));
if (!ENCODER.matches(password, sysUser.getPassword())) {
log.info("原密码错误");
return R.failed("密码输入错误");
}
else {
return R.ok();
}
return R.ok(null, MsgUtils.getMessage(ErrorCodes.SYS_USER_IMPORT_SUCCEED));
}
}
@@ -1,37 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2018-2025, lengleng All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~
~ Redistributions of source code must retain the above copyright notice,
~ this list of conditions and the following disclaimer.
~ Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ Neither the name of the pig4cloud.com developer nor the names of its
~ contributors may be used to endorse or promote products derived from
~ this software without specific prior written permission.
~ Author: lengleng (wangiegie@gmail.com)
~
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.pig4cloud.pigx.admin.mapper.SysAuditLogMapper">
<resultMap id="sysAuditLogMap" type="com.pig4cloud.pigx.admin.api.entity.SysAuditLog">
<id property="id" column="id"/>
<result property="auditName" column="audit_name"/>
<result property="auditField" column="audit_field"/>
<result property="beforeVal" column="before_val"/>
<result property="afterVal" column="after_val"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="delFlg" column="del_flg"/>
<result property="tenantId" column="tenant_id"/>
</resultMap>
</mapper>
@@ -19,17 +19,17 @@
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.pig4cloud.pigx.admin.mapper.SysUserRoleMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.pig4cloud.pigx.admin.api.entity.SysUserRole">
<id column="user_id" property="userId"/>
<result column="role_id" property="roleId"/>
</resultMap>
<!--根据用户Id删除该用户的角色关系-->
<delete id="deleteByUserId">
DELETE FROM sys_user_role WHERE user_id = #{userId}
</delete>
<mapper namespace="com.pig4cloud.pigx.admin.mapper.SysDeptMapper">
<!-- 获取部门的所有后代部门列表 -->
<select id="listDescendant" resultType="com.pig4cloud.pigx.admin.api.entity.SysDept">
WITH RECURSIVE cte_dept_tree (dept_id, parent_id, name) AS (
SELECT dept_id, parent_id, name FROM sys_dept WHERE dept_id = #{deptId}
UNION ALL
SELECT d.dept_id, d.parent_id, d.name
FROM cte_dept_tree c
JOIN sys_dept d ON c.dept_id = d.parent_id
)
SELECT dept_id, parent_id, name
FROM cte_dept_tree;
</select>
</mapper>
@@ -1,64 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2018-2025, lengleng All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~
~ Redistributions of source code must retain the above copyright notice,
~ this list of conditions and the following disclaimer.
~ Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ Neither the name of the pig4cloud.com developer nor the names of its
~ contributors may be used to endorse or promote products derived from
~ this software without specific prior written permission.
~ Author: lengleng (wangiegie@gmail.com)
~
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.pig4cloud.pigx.admin.mapper.SysDeptRelationMapper">
<!-- 删除节点关系 -->
<delete id="deleteDeptRelations">
DELETE FROM sys_dept_relation
WHERE
descendant IN ( SELECT temp.descendant FROM
( SELECT descendant FROM sys_dept_relation WHERE ancestor = #{descendant} ) temp )
AND ancestor IN ( SELECT temp.ancestor FROM ( SELECT ancestor FROM
sys_dept_relation WHERE descendant = #{descendant} AND ancestor != descendant ) temp )
</delete>
<!-- 新增节点关系 -->
<insert id="insertDeptRelations">
INSERT INTO sys_dept_relation (ancestor, descendant)
SELECT a.ancestor, b.descendant
FROM sys_dept_relation a
CROSS JOIN sys_dept_relation b
WHERE a.descendant = #{ancestor}
AND b.ancestor = #{descendant}
</insert>
<!--删除部门 > 删除所有关联此部门子节点的闭包关系-->
<delete id="deleteDeptRelationsByDeptId">
DELETE
FROM
sys_dept_relation
WHERE
descendant IN (
SELECT
temp.descendant
FROM
(
SELECT
descendant
FROM
sys_dept_relation
WHERE
ancestor = #{id}
) temp
)
</delete>
</mapper>
@@ -35,6 +35,8 @@
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="del_flag" property="delFlag"/>
<result column="embedded" property="embedded"/>
<result column="visible" property="visible"/>
</resultMap>
<!--通过角色查询菜单信息-->
@@ -48,10 +50,11 @@
sys_menu.sort_order,
sys_menu.keep_alive,
sys_menu.menu_type,
sys_menu.visible,
sys_menu.create_time,
sys_menu.update_time,
sys_menu.del_flag
sys_menu.del_flag,
sys_menu.embedded,
sys_menu.visible
FROM sys_menu
LEFT JOIN sys_role_menu ON sys_menu.menu_id = sys_role_menu.menu_id
WHERE sys_menu.del_flag = '0'
@@ -30,6 +30,8 @@
<result column="avatar" property="avatar"/>
<result column="wx_openid" property="wxOpenid"/>
<result column="qq_openid" property="qqOpenid"/>
<result column="gitee_login" property="giteeOpenId"/>
<result column="osc_id" property="oscOpenId"/>
<result column="ucreate_time" property="createTime"/>
<result column="uupdate_time" property="updateTime"/>
<result column="lock_flag" property="lockFlag"/>
@@ -81,6 +83,8 @@
u.avatar,
u.wx_openid,
u.qq_openid,
u.gitee_login,
u.osc_id,
u.del_flag,
u.lock_flag,
u.tenant_id,
@@ -90,12 +94,6 @@
u.create_by,
u.create_time ucreate_time,
u.update_time uupdate_time,
r.role_id,
r.role_name,
r.role_code,
r.role_desc,
r.create_time rcreate_time,
r.update_time rupdate_time,
d.name dept_name,
d.dept_id
</sql>
@@ -115,8 +113,6 @@
<include refid="userRoleDeptSql"/>
FROM
sys_user u
LEFT JOIN sys_user_role urole ON urole.user_id = u.user_id
LEFT JOIN sys_role r ON r.role_id = urole.role_id
LEFT JOIN sys_dept d ON d.dept_id = u.dept_id
WHERE
u.user_id = #{id}