style(pom): 格式化pom.xml文件结构
- 统一XML元素的缩进格式 - 调整依赖项和模块的缩进层级 - 优化配置元素的布局结构 style(annotations): 优化注解类代码格式 - 调整AnonymousAccess注解的结构 - 重新格式化AnonymousDeleteMapping注解的属性布局 - 重新格式化AnonymousGetMapping注解的属性布局 - 重新格式化AnonymousPatchMapping注解的属性布局 - 重新格式化AnonymousPostMapping注解的属性布局 - 统一注解属性的缩进和换行格式
This commit is contained in:
+2
-1
@@ -27,7 +27,8 @@ import lombok.Getter;
|
||||
public enum SystemCaptchaBizEnum {
|
||||
|
||||
/* 通过手机号码重置邮箱 */
|
||||
PHONE_RESET_EMAIL_CODE("10000", "phone_reset_email_code_", "SystemEmailCaptchaTemplate.ftl", "通过手机号码重置邮箱"),
|
||||
PHONE_RESET_EMAIL_CODE("10000", "phone_reset_email_code_", "SystemEmailCaptchaTemplate.ftl",
|
||||
"通过手机号码重置邮箱"),
|
||||
|
||||
/* 通过旧邮箱重置邮箱 */
|
||||
EMAIL_RESET_EMAIL_CODE("10001", "email_reset_email_code_", "SystemEmailCaptchaTemplate.ftl", "通过旧邮箱重置邮箱"),
|
||||
|
||||
+20
-22
@@ -38,6 +38,9 @@ import com.wf.captcha.base.Captcha;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -51,10 +54,6 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 授权、根据token获取用户详细信息
|
||||
*/
|
||||
@@ -63,24 +62,20 @@ import java.util.concurrent.TimeUnit;
|
||||
@RequestMapping("/auth")
|
||||
@Tag(name = "系统:系统授权接口")
|
||||
public class SystemAuthController {
|
||||
@Autowired
|
||||
private KitRedisHelper redisHelper;
|
||||
@Autowired
|
||||
private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO;
|
||||
@Autowired
|
||||
private TokenProvider tokenProvider;
|
||||
@Autowired
|
||||
private AppProperties properties;
|
||||
@Autowired
|
||||
private PasswordEncoder passwordEncoder;
|
||||
@Autowired
|
||||
private UserDetailsHandler userDetailsService;
|
||||
@Autowired private KitRedisHelper redisHelper;
|
||||
@Autowired private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO;
|
||||
@Autowired private TokenProvider tokenProvider;
|
||||
@Autowired private AppProperties properties;
|
||||
@Autowired private PasswordEncoder passwordEncoder;
|
||||
@Autowired private UserDetailsHandler userDetailsService;
|
||||
|
||||
@Operation(summary = "登录授权")
|
||||
@AnonymousPostMapping(value = "/login")
|
||||
public ResponseEntity<Map<String, Object>> login(@Validated @RequestBody SystemUserLoginArgs loginRequest, HttpServletRequest request) throws Exception {
|
||||
public ResponseEntity<Map<String, Object>> login(@Validated @RequestBody SystemUserLoginArgs loginRequest,
|
||||
HttpServletRequest request) throws Exception {
|
||||
// 密码解密
|
||||
String password = KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), loginRequest.getPassword());
|
||||
String password =
|
||||
KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), loginRequest.getPassword());
|
||||
// 查询验证码
|
||||
String code = redisHelper.get(loginRequest.getUuid(), String.class);
|
||||
// 清除验证码
|
||||
@@ -97,7 +92,8 @@ public class SystemAuthController {
|
||||
if (!passwordEncoder.matches(password, jwtUser.getPassword())) {
|
||||
throw new BadRequestException("登录密码错误");
|
||||
}
|
||||
Authentication authentication = new UsernamePasswordAuthenticationToken(jwtUser, null, jwtUser.getAuthorities());
|
||||
Authentication authentication =
|
||||
new UsernamePasswordAuthenticationToken(jwtUser, null, jwtUser.getAuthorities());
|
||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
// 生成令牌
|
||||
String token = tokenProvider.createToken(jwtUser);
|
||||
@@ -119,7 +115,7 @@ public class SystemAuthController {
|
||||
@Operation(summary = "获取用户信息")
|
||||
@PostMapping(value = "/info")
|
||||
public ResponseEntity<SystemUserInfoVo> getUserInfo() {
|
||||
SystemUserJwtVo jwtUser = (SystemUserJwtVo) KitSecurityHelper.getCurrentUser();
|
||||
SystemUserJwtVo jwtUser = (SystemUserJwtVo)KitSecurityHelper.getCurrentUser();
|
||||
SystemUserInfoVo userInfoVo = BeanUtil.copyProperties(jwtUser, SystemUserInfoVo.class);
|
||||
return ResponseEntity.ok(userInfoVo);
|
||||
}
|
||||
@@ -132,11 +128,13 @@ public class SystemAuthController {
|
||||
String uuid = SystemCacheKey.CAPTCHA_LOGIN + IdUtil.simpleUUID();
|
||||
//当验证码类型为 arithmetic时且长度 >= 2 时, captcha.text()的结果有几率为浮点型
|
||||
String captchaValue = captcha.text();
|
||||
if (captcha.getCharType() - 1 == CaptchaCodeEnum.ARITHMETIC.ordinal() && captchaValue.contains(SystemConst.SYMBOL_DOT)) {
|
||||
if (captcha.getCharType() - 1 == CaptchaCodeEnum.ARITHMETIC.ordinal() &&
|
||||
captchaValue.contains(SystemConst.SYMBOL_DOT)) {
|
||||
captchaValue = captchaValue.split("\\.")[0];
|
||||
}
|
||||
// 保存
|
||||
redisHelper.set(uuid, captchaValue, properties.getLogin().getCaptchaSetting().getExpiration(), TimeUnit.MINUTES);
|
||||
redisHelper.set(uuid, captchaValue, properties.getLogin().getCaptchaSetting().getExpiration(),
|
||||
TimeUnit.MINUTES);
|
||||
// 验证码信息
|
||||
Map<String, Object> imgResult = new HashMap<>(2) {{
|
||||
put("img", captcha.toBase64());
|
||||
|
||||
+6
-3
@@ -25,14 +25,17 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/captcha")
|
||||
@Tag(name = "系统:验证码管理")
|
||||
public class SystemCaptchaController {
|
||||
@Autowired
|
||||
private SystemEmailService systemEmailService;
|
||||
@Autowired private SystemEmailService systemEmailService;
|
||||
|
||||
@Operation(summary = "重置邮箱, 发送验证码")
|
||||
@PostMapping(value = "/sendResetEmailCaptcha")
|
||||
|
||||
+1
-2
@@ -30,8 +30,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@Tag(name = "系统:组件数据源")
|
||||
@RequestMapping("/api/component")
|
||||
public class SystemComponentController {
|
||||
@Autowired
|
||||
private SystemDeptService systemDeptService;
|
||||
@Autowired private SystemDeptService systemDeptService;
|
||||
|
||||
@Operation(summary = "查询部门下拉选择数据源")
|
||||
@PostMapping(value = "/queryDeptSelectDataSource")
|
||||
|
||||
+14
-10
@@ -26,23 +26,26 @@ import cn.odboy.util.KitPageUtil;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@Tag(name = "系统:部门管理")
|
||||
@RequestMapping("/api/dept")
|
||||
public class SystemDeptController {
|
||||
@Autowired
|
||||
private SystemDeptService systemDeptService;
|
||||
@Autowired private SystemDeptService systemDeptService;
|
||||
|
||||
@Operation(summary = "导出部门数据")
|
||||
@GetMapping(value = "/download")
|
||||
@@ -54,7 +57,8 @@ public class SystemDeptController {
|
||||
@Operation(summary = "查询部门")
|
||||
@PostMapping
|
||||
@PreAuthorize("@el.check('user:list','dept:list')")
|
||||
public ResponseEntity<KitPageResult<SystemDeptTb>> queryDept(@Validated @RequestBody KitPageArgs<SystemQueryDeptArgs> args) throws Exception {
|
||||
public ResponseEntity<KitPageResult<SystemDeptTb>> queryDept(
|
||||
@Validated @RequestBody KitPageArgs<SystemQueryDeptArgs> args) throws Exception {
|
||||
SystemQueryDeptArgs criteria = args.getArgs();
|
||||
List<SystemDeptTb> depts = systemDeptService.queryAllDept(criteria, true);
|
||||
return ResponseEntity.ok(KitPageUtil.toPage(depts));
|
||||
@@ -64,7 +68,7 @@ public class SystemDeptController {
|
||||
@PostMapping("/queryDeptSuperiorTree")
|
||||
@PreAuthorize("@el.check('user:list','dept:list')")
|
||||
public ResponseEntity<KitPageResult<SystemDeptTb>> queryDeptSuperiorTree(@RequestBody List<Long> ids,
|
||||
@RequestParam(defaultValue = "false") Boolean exclude) {
|
||||
@RequestParam(defaultValue = "false") Boolean exclude) {
|
||||
Set<SystemDeptTb> deptSet = new LinkedHashSet<>();
|
||||
for (Long id : ids) {
|
||||
// 同级数据
|
||||
|
||||
+11
-8
@@ -26,22 +26,24 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@Tag(name = "系统:字典管理")
|
||||
@RequestMapping("/api/dict")
|
||||
public class SystemDictController {
|
||||
@Autowired
|
||||
private SystemDictService systemDictService;
|
||||
@Autowired private SystemDictService systemDictService;
|
||||
|
||||
@Operation(summary = "导出字典数据")
|
||||
@GetMapping(value = "/download")
|
||||
@@ -60,7 +62,8 @@ public class SystemDictController {
|
||||
@Operation(summary = "查询字典")
|
||||
@PostMapping
|
||||
@PreAuthorize("@el.check('dict:list')")
|
||||
public ResponseEntity<KitPageResult<SystemDictTb>> queryDictByArgs(@Validated @RequestBody KitPageArgs<SystemQueryDictArgs> args) {
|
||||
public ResponseEntity<KitPageResult<SystemDictTb>> queryDictByArgs(
|
||||
@Validated @RequestBody KitPageArgs<SystemQueryDictArgs> args) {
|
||||
Page<SystemDictTb> page;
|
||||
SystemQueryDictArgs criteria = args.getArgs();
|
||||
if (args.getSize() != null) {
|
||||
|
||||
+19
-12
@@ -20,37 +20,43 @@ import cn.odboy.base.KitPageArgs;
|
||||
import cn.odboy.base.KitPageResult;
|
||||
import cn.odboy.system.dal.dataobject.SystemDictDetailTb;
|
||||
import cn.odboy.system.dal.model.SystemCreateDictDetailArgs;
|
||||
import cn.odboy.system.dal.model.SystemDictDetailVo;
|
||||
import cn.odboy.system.dal.model.SystemQueryDictDetailArgs;
|
||||
import cn.odboy.system.service.SystemDictDetailService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@Tag(name = "系统:字典详情管理")
|
||||
@RequestMapping("/api/dictDetail")
|
||||
public class SystemDictDetailController {
|
||||
@Autowired
|
||||
private SystemDictDetailService systemDictDetailService;
|
||||
@Autowired private SystemDictDetailService systemDictDetailService;
|
||||
|
||||
@Operation(summary = "查询字典详情")
|
||||
@PostMapping
|
||||
public ResponseEntity<KitPageResult<SystemDictDetailTb>> queryDictDetailByCrud(@Validated @RequestBody KitPageArgs<SystemQueryDictDetailArgs> args) {
|
||||
public ResponseEntity<KitPageResult<SystemDictDetailVo>> queryDictDetailByCrud(
|
||||
@Validated @RequestBody KitPageArgs<SystemQueryDictDetailArgs> args) {
|
||||
return queryDictDetailByArgs(args);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询字典详情")
|
||||
@PostMapping(value = "/queryDictDetailByArgs")
|
||||
public ResponseEntity<KitPageResult<SystemDictDetailTb>> queryDictDetailByArgs(@Validated @RequestBody KitPageArgs<SystemQueryDictDetailArgs> args) {
|
||||
public ResponseEntity<KitPageResult<SystemDictDetailVo>> queryDictDetailByArgs(
|
||||
@Validated @RequestBody KitPageArgs<SystemQueryDictDetailArgs> args) {
|
||||
SystemQueryDictDetailArgs criteria = args.getArgs();
|
||||
Page<SystemDictDetailTb> page = new Page<>(args.getPage(), args.getSize());
|
||||
return ResponseEntity.ok(systemDictDetailService.queryDictDetailByArgs(criteria, page));
|
||||
@@ -58,9 +64,9 @@ public class SystemDictDetailController {
|
||||
|
||||
@Operation(summary = "查询多个字典详情")
|
||||
@GetMapping(value = "/getDictDetailMaps")
|
||||
public ResponseEntity<Map<String, List<SystemDictDetailTb>>> getDictDetailMaps(@RequestParam String dictName) {
|
||||
public ResponseEntity<Map<String, List<SystemDictDetailVo>>> getDictDetailMaps(@RequestParam String dictName) {
|
||||
String[] names = dictName.split("[,, ]");
|
||||
Map<String, List<SystemDictDetailTb>> dictMap = new HashMap<>(16);
|
||||
Map<String, List<SystemDictDetailVo>> dictMap = new HashMap<>(16);
|
||||
for (String name : names) {
|
||||
dictMap.put(name, systemDictDetailService.queryDictDetailByName(name));
|
||||
}
|
||||
@@ -78,7 +84,8 @@ public class SystemDictDetailController {
|
||||
@Operation(summary = "修改字典详情")
|
||||
@PostMapping(value = "/modifyDictDetailById")
|
||||
@PreAuthorize("@el.check('dict:edit')")
|
||||
public ResponseEntity<Void> modifyDictDetailById(@Validated(SystemDictDetailTb.Update.class) @RequestBody SystemDictDetailTb args) {
|
||||
public ResponseEntity<Void> modifyDictDetailById(
|
||||
@Validated(SystemDictDetailTb.Update.class) @RequestBody SystemDictDetailTb args) {
|
||||
systemDictDetailService.modifyDictDetailById(args);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
+3
-3
@@ -36,8 +36,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequestMapping("api/email")
|
||||
@Tag(name = "工具:邮件管理")
|
||||
public class SystemEmailController {
|
||||
@Autowired
|
||||
private SystemEmailService systemEmailService;
|
||||
@Autowired private SystemEmailService systemEmailService;
|
||||
|
||||
@Operation(summary = "查询配置")
|
||||
@PostMapping(value = "/getLastEmailConfig")
|
||||
@@ -47,7 +46,8 @@ public class SystemEmailController {
|
||||
|
||||
@Operation(summary = "配置邮件")
|
||||
@PostMapping(value = "/modifyEmailConfig")
|
||||
public ResponseEntity<Void> modifyEmailConfig(@Validated @RequestBody SystemEmailConfigTb emailConfig) throws Exception {
|
||||
public ResponseEntity<Void> modifyEmailConfig(@Validated @RequestBody SystemEmailConfigTb emailConfig)
|
||||
throws Exception {
|
||||
systemEmailService.modifyEmailConfig(emailConfig);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
+12
-8
@@ -26,21 +26,23 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@Tag(name = "系统:岗位管理")
|
||||
@RequestMapping("/api/job")
|
||||
public class SystemJobController {
|
||||
@Autowired
|
||||
private SystemJobService systemJobService;
|
||||
@Autowired private SystemJobService systemJobService;
|
||||
|
||||
@Operation(summary = "导出岗位数据")
|
||||
@GetMapping(value = "/download")
|
||||
@@ -52,7 +54,8 @@ public class SystemJobController {
|
||||
@Operation(summary = "查询岗位")
|
||||
@PostMapping(value = "/queryAllEnableJob")
|
||||
@PreAuthorize("@el.check('job:list','user:list')")
|
||||
public ResponseEntity<KitPageResult<SystemJobTb>> queryJobByArgs(@Validated @RequestBody KitPageArgs<SystemQueryJobArgs> args) {
|
||||
public ResponseEntity<KitPageResult<SystemJobTb>> queryJobByArgs(
|
||||
@Validated @RequestBody KitPageArgs<SystemQueryJobArgs> args) {
|
||||
SystemQueryJobArgs criteria = args.getArgs();
|
||||
Page<SystemJobTb> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return ResponseEntity.ok(systemJobService.queryJobByArgs(criteria, page));
|
||||
@@ -61,7 +64,8 @@ public class SystemJobController {
|
||||
@Operation(summary = "查询岗位")
|
||||
@PostMapping
|
||||
@PreAuthorize("@el.check('job:list','user:list')")
|
||||
public ResponseEntity<KitPageResult<SystemJobTb>> queryJobByCrud(@Validated @RequestBody KitPageArgs<SystemQueryJobArgs> args) {
|
||||
public ResponseEntity<KitPageResult<SystemJobTb>> queryJobByCrud(
|
||||
@Validated @RequestBody KitPageArgs<SystemQueryJobArgs> args) {
|
||||
return queryJobByArgs(args);
|
||||
}
|
||||
|
||||
|
||||
+10
-6
@@ -28,26 +28,30 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@RestController
|
||||
@Tag(name = "工具:本地存储管理")
|
||||
@RequestMapping("/api/localStorage")
|
||||
public class SystemLocalStorageController {
|
||||
@Autowired
|
||||
private SystemLocalStorageService localStorageService;
|
||||
@Autowired private SystemLocalStorageService localStorageService;
|
||||
|
||||
@Operation(summary = "查询文件")
|
||||
@PostMapping
|
||||
@PreAuthorize("@el.check('storage:list')")
|
||||
public ResponseEntity<KitPageResult<SystemLocalStorageTb>> queryLocalStorage(@Validated @RequestBody KitPageArgs<SystemQueryStorageArgs> args) {
|
||||
public ResponseEntity<KitPageResult<SystemLocalStorageTb>> queryLocalStorage(
|
||||
@Validated @RequestBody KitPageArgs<SystemQueryStorageArgs> args) {
|
||||
SystemQueryStorageArgs criteria = args.getArgs();
|
||||
Page<SystemLocalStorageTb> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return ResponseEntity.ok(localStorageService.queryLocalStorage(criteria, page));
|
||||
|
||||
+18
-10
@@ -30,23 +30,29 @@ import cn.odboy.util.KitPageUtil;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@Tag(name = "系统:菜单管理")
|
||||
@RequestMapping("/api/menu")
|
||||
public class SystemMenuController {
|
||||
@Autowired
|
||||
private SystemMenuService systemMenuService;
|
||||
@Autowired
|
||||
private SystemMenuMapper systemMenuMapper;
|
||||
@Autowired private SystemMenuService systemMenuService;
|
||||
@Autowired private SystemMenuMapper systemMenuMapper;
|
||||
|
||||
@Operation(summary = "导出菜单数据")
|
||||
@GetMapping(value = "/download")
|
||||
@@ -85,14 +91,16 @@ public class SystemMenuController {
|
||||
@PostMapping
|
||||
@Operation(summary = "查询菜单")
|
||||
@PreAuthorize("@el.check('menu:list')")
|
||||
public ResponseEntity<KitPageResult<SystemMenuTb>> queryAllMenuByCrud(@Validated @RequestBody KitPageArgs<SystemQueryMenuArgs> args) throws Exception {
|
||||
public ResponseEntity<KitPageResult<SystemMenuTb>> queryAllMenuByCrud(
|
||||
@Validated @RequestBody KitPageArgs<SystemQueryMenuArgs> args) throws Exception {
|
||||
return queryAllMenu(args);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/queryMenuByArgs")
|
||||
@Operation(summary = "查询菜单")
|
||||
@PreAuthorize("@el.check('menu:list')")
|
||||
public ResponseEntity<KitPageResult<SystemMenuTb>> queryAllMenu(@Validated @RequestBody KitPageArgs<SystemQueryMenuArgs> args) throws Exception {
|
||||
public ResponseEntity<KitPageResult<SystemMenuTb>> queryAllMenu(
|
||||
@Validated @RequestBody KitPageArgs<SystemQueryMenuArgs> args) throws Exception {
|
||||
SystemQueryMenuArgs criteria = args.getArgs();
|
||||
List<SystemMenuTb> menuList = systemMenuService.queryAllMenu(criteria, true);
|
||||
return ResponseEntity.ok(KitPageUtil.toPage(menuList));
|
||||
|
||||
+2
-4
@@ -19,6 +19,7 @@ package cn.odboy.system.controller;
|
||||
import cn.odboy.system.service.SystemMonitorService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.Map;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -26,14 +27,11 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@Tag(name = "系统-服务监控管理")
|
||||
@RequestMapping("/api/monitor")
|
||||
public class SystemMonitorController {
|
||||
@Autowired
|
||||
private SystemMonitorService systemMonitorService;
|
||||
@Autowired private SystemMonitorService systemMonitorService;
|
||||
|
||||
@PostMapping(value = "/queryServerMonitorInfo")
|
||||
@Operation(summary = "查询服务监控")
|
||||
|
||||
+12
-8
@@ -26,26 +26,29 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/user/online")
|
||||
@Tag(name = "系统:在线用户管理")
|
||||
public class SystemOnlineController {
|
||||
@Autowired
|
||||
private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO;
|
||||
@Autowired private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO;
|
||||
|
||||
@Operation(summary = "查询在线用户")
|
||||
@PostMapping
|
||||
@PreAuthorize("@el.check()")
|
||||
public ResponseEntity<KitPageResult<SystemUserOnlineVo>> queryOnlineUser(@Validated @RequestBody KitPageArgs<SystemUserOnlineVo> args) {
|
||||
public ResponseEntity<KitPageResult<SystemUserOnlineVo>> queryOnlineUser(
|
||||
@Validated @RequestBody KitPageArgs<SystemUserOnlineVo> args) {
|
||||
IPage<SystemUserOnlineVo> page = new Page<>(args.getPage(), args.getSize());
|
||||
return ResponseEntity.ok(systemUserOnlineInfoDAO.queryUserOnlineModelPage(args.getArgs(), page));
|
||||
}
|
||||
@@ -54,7 +57,8 @@ public class SystemOnlineController {
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check()")
|
||||
public void exportOnlineUser(HttpServletResponse response, String username) throws IOException {
|
||||
systemUserOnlineInfoDAO.downloadUserOnlineModelExcel(systemUserOnlineInfoDAO.queryUserOnlineModelListByUsername(username), response);
|
||||
systemUserOnlineInfoDAO.downloadUserOnlineModelExcel(
|
||||
systemUserOnlineInfoDAO.queryUserOnlineModelListByUsername(username), response);
|
||||
}
|
||||
|
||||
@Operation(summary = "踢出用户")
|
||||
|
||||
+10
-6
@@ -26,28 +26,32 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Tag(name = "工具:OSS存储管理")
|
||||
@RequestMapping("/api/ossStorage")
|
||||
public class SystemOssStorageController {
|
||||
@Autowired
|
||||
private SystemOssStorageService systemOssStorageService;
|
||||
@Autowired private SystemOssStorageService systemOssStorageService;
|
||||
|
||||
@Operation(summary = "查询文件")
|
||||
@PostMapping
|
||||
@PreAuthorize("@el.check('storage:list')")
|
||||
public ResponseEntity<KitPageResult<SystemOssStorageVo>> queryOssStorage(@Validated @RequestBody KitPageArgs<SystemQueryStorageArgs> args) {
|
||||
public ResponseEntity<KitPageResult<SystemOssStorageVo>> queryOssStorage(
|
||||
@Validated @RequestBody KitPageArgs<SystemQueryStorageArgs> args) {
|
||||
SystemQueryStorageArgs criteria = args.getArgs();
|
||||
Page<SystemOssStorageTb> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return ResponseEntity.ok(systemOssStorageService.queryOssStorage(criteria, page));
|
||||
|
||||
+14
-8
@@ -29,28 +29,33 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/quartzJob")
|
||||
@Tag(name = "系统:定时任务管理")
|
||||
public class SystemQuartzJobController {
|
||||
@Autowired
|
||||
private SystemQuartzJobService systemQuartzJobService;
|
||||
@Autowired private SystemQuartzJobService systemQuartzJobService;
|
||||
|
||||
@Operation(summary = "查询定时任务")
|
||||
@PostMapping
|
||||
@PreAuthorize("@el.check('quartzJob:list')")
|
||||
public ResponseEntity<KitPageResult<SystemQuartzJobTb>> queryQuartzJobByCrud(@Validated @RequestBody KitPageArgs<SystemQueryQuartzJobArgs> args) {
|
||||
public ResponseEntity<KitPageResult<SystemQuartzJobTb>> queryQuartzJobByCrud(
|
||||
@Validated @RequestBody KitPageArgs<SystemQueryQuartzJobArgs> args) {
|
||||
SystemQueryQuartzJobArgs criteria = args.getArgs();
|
||||
Page<SystemQuartzJobTb> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return ResponseEntity.ok(systemQuartzJobService.queryQuartzJobByArgs(criteria, page));
|
||||
@@ -94,7 +99,8 @@ public class SystemQuartzJobController {
|
||||
@Operation(summary = "修改定时任务")
|
||||
@PutMapping
|
||||
@PreAuthorize("@el.check('quartzJob:edit')")
|
||||
public ResponseEntity<Void> updateQuartzJob(@Validated(SystemQuartzJobTb.Update.class) @RequestBody SystemUpdateQuartzJobArgs args) {
|
||||
public ResponseEntity<Void> updateQuartzJob(
|
||||
@Validated(SystemQuartzJobTb.Update.class) @RequestBody SystemUpdateQuartzJobArgs args) {
|
||||
// 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义
|
||||
checkBean(args.getBeanName());
|
||||
systemQuartzJobService.modifyQuartzJobResumeCron(args);
|
||||
|
||||
+29
-25
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.controller;
|
||||
|
||||
import cn.hutool.core.lang.Dict;
|
||||
@@ -23,67 +22,71 @@ import cn.odboy.framework.exception.BadRequestException;
|
||||
import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
||||
import cn.odboy.system.dal.model.SystemCreateRoleArgs;
|
||||
import cn.odboy.system.dal.model.SystemQueryRoleArgs;
|
||||
import cn.odboy.system.dal.model.SystemRoleVo;
|
||||
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
|
||||
import cn.odboy.system.service.SystemRoleService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@Tag(name = "系统:角色管理")
|
||||
@Api(tags = "系统:角色管理")
|
||||
@RequestMapping("/api/role")
|
||||
public class SystemRoleController {
|
||||
@Autowired
|
||||
private SystemRoleService systemRoleService;
|
||||
@Autowired private SystemRoleService systemRoleService;
|
||||
|
||||
@Operation(summary = "获取单个role")
|
||||
@ApiOperation("获取单个role")
|
||||
@PostMapping(value = "/queryRoleById")
|
||||
@PreAuthorize("@el.check('roles:list')")
|
||||
public ResponseEntity<SystemRoleTb> queryRoleById(@RequestBody SystemRoleTb args) {
|
||||
return ResponseEntity.ok(systemRoleService.getRoleById(args.getId()));
|
||||
}
|
||||
|
||||
@Operation(summary = "导出角色数据")
|
||||
@ApiOperation("导出角色数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('role:list')")
|
||||
public void exportRole(HttpServletResponse response, SystemQueryRoleArgs criteria) throws IOException {
|
||||
systemRoleService.exportRoleExcel(systemRoleService.queryRoleByArgs(criteria), response);
|
||||
}
|
||||
|
||||
@Operation(summary = "返回全部的角色")
|
||||
@ApiOperation("返回全部的角色")
|
||||
@PostMapping(value = "/queryRoleList")
|
||||
@PreAuthorize("@el.check('roles:list','user:add','user:edit')")
|
||||
public ResponseEntity<List<SystemRoleTb>> queryRoleList() {
|
||||
return ResponseEntity.ok(systemRoleService.queryAllRole());
|
||||
}
|
||||
|
||||
@Operation(summary = "查询角色")
|
||||
@ApiOperation("查询角色")
|
||||
@PostMapping
|
||||
@PreAuthorize("@el.check('roles:list')")
|
||||
public ResponseEntity<KitPageResult<SystemRoleTb>> queryRoleByArgs(@Validated @RequestBody KitPageArgs<SystemQueryRoleArgs> args) {
|
||||
public ResponseEntity<KitPageResult<SystemRoleVo>> queryRoleByArgs(
|
||||
@Validated @RequestBody KitPageArgs<SystemQueryRoleArgs> args) {
|
||||
SystemQueryRoleArgs criteria = args.getArgs();
|
||||
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return ResponseEntity.ok(systemRoleService.queryRoleByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@Operation(summary = "获取用户级别")
|
||||
@ApiOperation("获取用户级别")
|
||||
@PostMapping(value = "/queryRoleLevel")
|
||||
public ResponseEntity<Dict> queryRoleLevel() {
|
||||
return ResponseEntity.ok(Dict.create().set("level", checkRoleLevels(null)));
|
||||
}
|
||||
|
||||
@Operation(summary = "新增角色")
|
||||
@ApiOperation("新增角色")
|
||||
@PostMapping(value = "/saveRole")
|
||||
@PreAuthorize("@el.check('roles:add')")
|
||||
public ResponseEntity<Void> saveRole(@Validated @RequestBody SystemCreateRoleArgs args) {
|
||||
@@ -92,26 +95,26 @@ public class SystemRoleController {
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "修改角色")
|
||||
@ApiOperation("修改角色")
|
||||
@PostMapping(value = "/modifyRoleById")
|
||||
@PreAuthorize("@el.check('roles:edit')")
|
||||
public ResponseEntity<Void> modifyRoleById(@Validated(SystemRoleTb.Update.class) @RequestBody SystemRoleTb args) {
|
||||
public ResponseEntity<Void> modifyRoleById(@Validated(SystemRoleTb.Update.class) @RequestBody SystemRoleVo args) {
|
||||
checkRoleLevels(args.getLevel());
|
||||
systemRoleService.modifyRoleById(args);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "修改角色菜单")
|
||||
@ApiOperation("修改角色菜单")
|
||||
@PostMapping(value = "/modifyBindMenuById")
|
||||
@PreAuthorize("@el.check('roles:edit')")
|
||||
public ResponseEntity<Void> modifyBindMenuById(@RequestBody SystemRoleTb args) {
|
||||
public ResponseEntity<Void> modifyBindMenuById(@RequestBody SystemRoleVo args) {
|
||||
SystemRoleTb role = systemRoleService.getRoleById(args.getId());
|
||||
checkRoleLevels(role.getLevel());
|
||||
systemRoleService.modifyBindMenuById(args);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除角色")
|
||||
@ApiOperation("删除角色")
|
||||
@PostMapping(value = "/removeRoleByIds")
|
||||
@PreAuthorize("@el.check('roles:del')")
|
||||
public ResponseEntity<Void> removeRoleByIds(@RequestBody Set<Long> ids) {
|
||||
@@ -131,7 +134,8 @@ public class SystemRoleController {
|
||||
* @return /
|
||||
*/
|
||||
private int checkRoleLevels(Integer level) {
|
||||
List<Integer> levels = systemRoleService.queryRoleByUsersId(KitSecurityHelper.getCurrentUserId()).stream().map(SystemRoleTb::getLevel).toList();
|
||||
List<Integer> levels = systemRoleService.queryRoleByUsersId(KitSecurityHelper.getCurrentUserId()).stream()
|
||||
.map(SystemRoleTb::getLevel).toList();
|
||||
int min = Collections.min(levels);
|
||||
if (level != null) {
|
||||
if (level < min) {
|
||||
|
||||
+17
-18
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
@@ -28,6 +27,7 @@ import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
||||
import cn.odboy.system.dal.dataobject.SystemUserTb;
|
||||
import cn.odboy.system.dal.model.SystemQueryUserArgs;
|
||||
import cn.odboy.system.dal.model.SystemUpdateUserPasswordArgs;
|
||||
import cn.odboy.system.dal.model.SystemUserVo;
|
||||
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
|
||||
import cn.odboy.system.service.SystemDataService;
|
||||
import cn.odboy.system.service.SystemDeptService;
|
||||
@@ -37,9 +37,8 @@ import cn.odboy.system.service.SystemUserService;
|
||||
import cn.odboy.util.KitPageUtil;
|
||||
import cn.odboy.util.KitRsaEncryptUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
@@ -61,7 +60,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Tag(name = "系统:用户管理")
|
||||
@Api(tags = "系统:用户管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/user")
|
||||
public class SystemUserController {
|
||||
@@ -73,17 +72,17 @@ public class SystemUserController {
|
||||
@Autowired private SystemEmailService systemEmailService;
|
||||
@Autowired private AppProperties properties;
|
||||
|
||||
@Operation(summary = "导出用户数据")
|
||||
@ApiOperation("导出用户数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('user:list')")
|
||||
public void exportUserExcel(HttpServletResponse response, SystemQueryUserArgs criteria) throws IOException {
|
||||
systemUserService.exportUserExcel(systemUserService.queryUserByArgs(criteria), response);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询用户")
|
||||
@ApiOperation("查询用户")
|
||||
@PostMapping
|
||||
@PreAuthorize("@el.check('user:list')")
|
||||
public ResponseEntity<KitPageResult<SystemUserTb>> queryUserByArgs(
|
||||
public ResponseEntity<KitPageResult<SystemUserVo>> queryUserByArgs(
|
||||
@Validated @RequestBody KitPageArgs<SystemQueryUserArgs> args) {
|
||||
Page<SystemUserTb> page = new Page<>(args.getPage(), args.getSize());
|
||||
SystemQueryUserArgs criteria = args.getArgs();
|
||||
@@ -112,10 +111,10 @@ public class SystemUserController {
|
||||
return ResponseEntity.ok(KitPageUtil.emptyData());
|
||||
}
|
||||
|
||||
@Operation(summary = "新增用户")
|
||||
@ApiOperation("新增用户")
|
||||
@PostMapping(value = "/saveUser")
|
||||
@PreAuthorize("@el.check('user:add')")
|
||||
public ResponseEntity<Object> saveUser(@Validated @RequestBody SystemUserTb args) {
|
||||
public ResponseEntity<Object> saveUser(@Validated @RequestBody SystemUserVo args) {
|
||||
checkLevel(args);
|
||||
// 默认密码 123456
|
||||
args.setPassword(passwordEncoder.encode("123456"));
|
||||
@@ -123,16 +122,16 @@ public class SystemUserController {
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "修改用户")
|
||||
@ApiOperation("修改用户")
|
||||
@PostMapping(value = "/modifyUserById")
|
||||
@PreAuthorize("@el.check('user:edit')")
|
||||
public ResponseEntity<Object> modifyUserById(@Validated(SystemUserTb.Update.class) @RequestBody SystemUserTb args) {
|
||||
public ResponseEntity<Object> modifyUserById(@Validated(SystemUserTb.Update.class) @RequestBody SystemUserVo args) {
|
||||
checkLevel(args);
|
||||
systemUserService.modifyUserById(args);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "修改用户:个人中心")
|
||||
@ApiOperation("修改用户:个人中心")
|
||||
@PostMapping(value = "modifyUserCenterInfoById")
|
||||
public ResponseEntity<Object> modifyUserCenterInfoById(
|
||||
@Validated(SystemUserTb.Update.class) @RequestBody SystemUserTb args) {
|
||||
@@ -143,7 +142,7 @@ public class SystemUserController {
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除用户")
|
||||
@ApiOperation("删除用户")
|
||||
@PostMapping(value = "/removeUserByIds")
|
||||
@PreAuthorize("@el.check('user:del')")
|
||||
public ResponseEntity<Object> removeUserByIds(@RequestBody Set<Long> ids) {
|
||||
@@ -162,7 +161,7 @@ public class SystemUserController {
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "修改密码")
|
||||
@ApiOperation("修改密码")
|
||||
@PostMapping(value = "/modifyUserPasswordByUsername")
|
||||
public ResponseEntity<Object> modifyUserPasswordByUsername(@RequestBody SystemUpdateUserPasswordArgs passVo)
|
||||
throws Exception {
|
||||
@@ -181,7 +180,7 @@ public class SystemUserController {
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "重置密码")
|
||||
@ApiOperation("重置密码")
|
||||
@PostMapping(value = "/resetUserPasswordByIds")
|
||||
public ResponseEntity<Object> resetUserPasswordByIds(@RequestBody Set<Long> ids) {
|
||||
String defaultPwd = passwordEncoder.encode("123456");
|
||||
@@ -189,13 +188,13 @@ public class SystemUserController {
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "修改头像")
|
||||
@ApiOperation("修改头像")
|
||||
@PostMapping(value = "/modifyUserAvatar")
|
||||
public ResponseEntity<Object> modifyUserAvatar(@RequestParam MultipartFile avatar) {
|
||||
return ResponseEntity.ok(systemUserService.modifyUserAvatar(avatar));
|
||||
}
|
||||
|
||||
@Operation(summary = "修改邮箱")
|
||||
@ApiOperation("修改邮箱")
|
||||
@PostMapping(value = "/modifyUserEmailByUsername/{code}")
|
||||
public ResponseEntity<Object> modifyUserEmailByUsername(@PathVariable String code, @RequestBody SystemUserTb args)
|
||||
throws Exception {
|
||||
@@ -215,7 +214,7 @@ public class SystemUserController {
|
||||
*
|
||||
* @param args /
|
||||
*/
|
||||
private void checkLevel(SystemUserTb args) {
|
||||
private void checkLevel(SystemUserVo args) {
|
||||
Integer currentLevel = Collections.min(
|
||||
systemRoleService.queryRoleByUsersId(KitSecurityHelper.getCurrentUserId()).stream()
|
||||
.map(SystemRoleTb::getLevel).toList());
|
||||
|
||||
+1
@@ -34,6 +34,7 @@ import lombok.Setter;
|
||||
@Setter
|
||||
@TableName("system_dept")
|
||||
public class SystemDeptTb extends KitBaseUserTimeTb {
|
||||
|
||||
@NotNull(groups = Update.class) @TableId(value = "dept_id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "ID", hidden = true) private Long id;
|
||||
@TableField(exist = false) @JSONField(serialize = false) @ApiModelProperty(value = "角色") private Set<SystemRoleTb>
|
||||
|
||||
+1
-1
@@ -20,9 +20,9 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.Objects;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.Objects;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
+1
-1
@@ -22,10 +22,10 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
+1
-5
@@ -23,10 +23,9 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.Objects;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -39,9 +38,6 @@ import lombok.Setter;
|
||||
public class SystemRoleTb extends KitBaseUserTimeTb {
|
||||
@NotNull(groups = {Update.class}) @TableId(value = "role_id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "ID", hidden = true) private Long id;
|
||||
@TableField(exist = false) @ApiModelProperty(value = "用户", hidden = true) private Set<SystemUserTb> users;
|
||||
@TableField(exist = false) @ApiModelProperty(value = "菜单", hidden = true) private Set<SystemMenuTb> menus;
|
||||
@TableField(exist = false) @ApiModelProperty(value = "部门", hidden = true) private Set<SystemDeptTb> depts;
|
||||
@NotBlank @ApiModelProperty(value = "名称", hidden = true) private String name;
|
||||
@ApiModelProperty(value = "数据权限,全部 、 本级 、 自定义") private String dataScope =
|
||||
SystemDataScopeEnum.THIS_LEVEL.getValue();
|
||||
|
||||
+2
-5
@@ -21,12 +21,11 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -36,8 +35,6 @@ import lombok.Setter;
|
||||
public class SystemUserTb extends KitBaseUserTimeTb {
|
||||
@NotNull(groups = Update.class) @TableId(value = "user_id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "ID", hidden = true) private Long id;
|
||||
@TableField(exist = false) @ApiModelProperty(value = "用户角色") private Set<SystemRoleTb> roles;
|
||||
@TableField(exist = false) @ApiModelProperty(value = "用户岗位") private Set<SystemJobTb> jobs;
|
||||
@TableField(value = "dept_id") @ApiModelProperty(hidden = true) private Long deptId;
|
||||
@ApiModelProperty(value = "用户部门") @TableField(exist = false) private SystemDeptTb dept;
|
||||
@NotBlank @ApiModelProperty(value = "用户名称") private String username;
|
||||
|
||||
+1
-1
@@ -17,9 +17,9 @@ package cn.odboy.system.dal.model;
|
||||
|
||||
import cn.odboy.base.KitObject;
|
||||
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||
import java.util.Set;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.Set;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||
import cn.odboy.system.dal.dataobject.SystemMenuTb;
|
||||
import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
||||
import cn.odboy.system.dal.dataobject.SystemUserTb;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.Set;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class SystemRoleVo extends SystemRoleTb {
|
||||
@ApiModelProperty(value = "用户", hidden = true) private Set<SystemUserTb> users;
|
||||
@ApiModelProperty(value = "菜单", hidden = true) private Set<SystemMenuTb> menus;
|
||||
@ApiModelProperty(value = "部门", hidden = true) private Set<SystemDeptTb> depts;
|
||||
}
|
||||
+1
-1
@@ -16,9 +16,9 @@
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.List;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import cn.odboy.system.dal.dataobject.SystemJobTb;
|
||||
import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
||||
import cn.odboy.system.dal.dataobject.SystemUserTb;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.Set;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class SystemUserVo extends SystemUserTb {
|
||||
@ApiModelProperty(value = "用户角色") private Set<SystemRoleTb> roles;
|
||||
@ApiModelProperty(value = "用户岗位") private Set<SystemJobTb> jobs;
|
||||
}
|
||||
+5
-4
@@ -19,6 +19,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
||||
import cn.odboy.system.dal.model.SystemQueryRoleArgs;
|
||||
import cn.odboy.system.dal.model.SystemRoleVo;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import java.util.List;
|
||||
@@ -46,9 +47,9 @@ public interface SystemRoleMapper extends BaseMapper<SystemRoleTb> {
|
||||
}
|
||||
return selectCount(wrapper);
|
||||
}
|
||||
List<SystemRoleTb> selectRoleByArgs(@Param("criteria") SystemQueryRoleArgs criteria);
|
||||
List<SystemRoleTb> selectRoleByUserId(@Param("userId") Long userId);
|
||||
List<SystemRoleTb> selectRoleByMenuId(@Param("menuId") Long menuId);
|
||||
SystemRoleTb getRoleById(@Param("roleId") Long roleId);
|
||||
List<SystemRoleVo> selectRoleByArgs(@Param("criteria") SystemQueryRoleArgs criteria);
|
||||
List<SystemRoleVo> selectRoleByUserId(@Param("userId") Long userId);
|
||||
List<SystemRoleVo> selectRoleByMenuId(@Param("menuId") Long menuId);
|
||||
SystemRoleVo getRoleById(@Param("roleId") Long roleId);
|
||||
Integer countRoleByDeptIds(@Param("deptIds") Set<Long> deptIds);
|
||||
}
|
||||
|
||||
+7
-6
@@ -17,6 +17,7 @@ package cn.odboy.system.dal.mysql;
|
||||
|
||||
import cn.odboy.system.dal.dataobject.SystemUserTb;
|
||||
import cn.odboy.system.dal.model.SystemQueryUserArgs;
|
||||
import cn.odboy.system.dal.model.SystemUserVo;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
@@ -29,14 +30,14 @@ import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface SystemUserMapper extends BaseMapper<SystemUserTb> {
|
||||
List<SystemUserTb> selectUserByArgs(@Param("criteria") SystemQueryUserArgs criteria);
|
||||
IPage<SystemUserTb> selectUserByArgs(@Param("criteria") SystemQueryUserArgs criteria, Page<SystemUserTb> page);
|
||||
List<SystemUserTb> selectUserByRoleId(@Param("roleId") Long roleId);
|
||||
List<SystemUserTb> selectUserByDeptId(@Param("deptId") Long deptId);
|
||||
List<SystemUserTb> selectUserByMenuId(@Param("menuId") Long menuId);
|
||||
List<SystemUserVo> selectUserByArgs(@Param("criteria") SystemQueryUserArgs criteria);
|
||||
IPage<SystemUserVo> selectUserByArgs(@Param("criteria") SystemQueryUserArgs criteria, Page<SystemUserTb> page);
|
||||
List<SystemUserVo> selectUserByRoleId(@Param("roleId") Long roleId);
|
||||
List<SystemUserVo> selectUserByDeptId(@Param("deptId") Long deptId);
|
||||
List<SystemUserVo> selectUserByMenuId(@Param("menuId") Long menuId);
|
||||
Long countUserByJobIds(@Param("jobIds") Set<Long> jobIds);
|
||||
Long countUserByRoleIds(@Param("roleIds") Set<Long> roleIds);
|
||||
SystemUserTb getUserByUsername(@Param("username") String username);
|
||||
SystemUserVo getUserByUsername(@Param("username") String username);
|
||||
default long countUserByDeptIds(Set<Long> deptIds) {
|
||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.in(SystemUserTb::getDeptId, deptIds);
|
||||
|
||||
+6
-1
@@ -16,7 +16,12 @@
|
||||
|
||||
package cn.odboy.system.framework.bizlock;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
|
||||
+3
-3
@@ -18,6 +18,7 @@ package cn.odboy.system.framework.bizlock;
|
||||
|
||||
import cn.odboy.framework.exception.BadRequestException;
|
||||
import cn.odboy.framework.redis.KitRedisHelper;
|
||||
import java.lang.reflect.Method;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
@@ -28,8 +29,6 @@ import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
public class BizLockAspect {
|
||||
@@ -60,7 +59,8 @@ public class BizLockAspect {
|
||||
private String parseLockKey(ProceedingJoinPoint joinPoint, BizLock bizLock) {
|
||||
// 如果key为空,使用默认格式: bizName:方法名
|
||||
if (bizLock.key().isEmpty()) {
|
||||
return String.format("%s:%s", bizLock.bizName(), ((MethodSignature)joinPoint.getSignature()).getMethod().getName());
|
||||
return String.format("%s:%s", bizLock.bizName(),
|
||||
((MethodSignature)joinPoint.getSignature()).getMethod().getName());
|
||||
}
|
||||
|
||||
// 解析SpEL表达式
|
||||
|
||||
+1
-2
@@ -19,11 +19,10 @@ package cn.odboy.system.framework.mybatisplus;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import java.util.Date;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Component
|
||||
public class MpMetaObjectHandler implements MetaObjectHandler {
|
||||
|
||||
|
||||
+6
-1
@@ -16,7 +16,12 @@
|
||||
|
||||
package cn.odboy.system.framework.operalog;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 捕捉操作日志
|
||||
|
||||
+4
-5
@@ -28,6 +28,7 @@ import cn.odboy.util.KitIPUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Method;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
@@ -36,8 +37,6 @@ import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* 捕捉操作日志
|
||||
*
|
||||
@@ -48,8 +47,7 @@ import java.lang.reflect.Method;
|
||||
@Aspect
|
||||
@Component
|
||||
public class OperationLogAspect {
|
||||
@Autowired
|
||||
private SystemOperationLogMapper systemOperationLogMapper;
|
||||
@Autowired private SystemOperationLogMapper systemOperationLogMapper;
|
||||
|
||||
@Around("@annotation(operationLog)")
|
||||
public Object operationLogCatch(ProceedingJoinPoint joinPoint, OperationLog operationLog) throws Throwable {
|
||||
@@ -83,7 +81,8 @@ public class OperationLogAspect {
|
||||
}
|
||||
}
|
||||
|
||||
private SystemOperationLogTb getOperationLogTb(ProceedingJoinPoint joinPoint, OperationLog annotation, TimeInterval timeInterval) {
|
||||
private SystemOperationLogTb getOperationLogTb(ProceedingJoinPoint joinPoint, OperationLog annotation,
|
||||
TimeInterval timeInterval) {
|
||||
long executeTime = timeInterval.intervalMs();
|
||||
MethodSignature signature = (MethodSignature)joinPoint.getSignature();
|
||||
String bizName = annotation.bizName();
|
||||
|
||||
+6
-1
@@ -15,7 +15,12 @@
|
||||
*/
|
||||
package cn.odboy.system.framework.operalog.annotaions;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 捕捉操作日志
|
||||
|
||||
+4
-5
@@ -28,6 +28,7 @@ import cn.odboy.util.KitIPUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Method;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
@@ -36,8 +37,6 @@ import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* 捕捉操作日志
|
||||
*
|
||||
@@ -48,8 +47,7 @@ import java.lang.reflect.Method;
|
||||
@Aspect
|
||||
@Component
|
||||
public class SystemOperationLogAspect {
|
||||
@Autowired
|
||||
private SystemOperationLogMapper systemOperationLogMapper;
|
||||
@Autowired private SystemOperationLogMapper systemOperationLogMapper;
|
||||
|
||||
@Around("@annotation(operationLog)")
|
||||
public Object operationLogCatch(ProceedingJoinPoint joinPoint, OperationLog operationLog) throws Throwable {
|
||||
@@ -85,7 +83,8 @@ public class SystemOperationLogAspect {
|
||||
}
|
||||
}
|
||||
|
||||
private SystemOperationLogTb getOperationLogTb(ProceedingJoinPoint joinPoint, OperationLog annotation, TimeInterval timeInterval) {
|
||||
private SystemOperationLogTb getOperationLogTb(ProceedingJoinPoint joinPoint, OperationLog annotation,
|
||||
TimeInterval timeInterval) {
|
||||
long executeTime = timeInterval.intervalMs();
|
||||
MethodSignature signature = (MethodSignature)joinPoint.getSignature();
|
||||
String bizName = annotation.bizName();
|
||||
|
||||
+4
-4
@@ -17,11 +17,10 @@
|
||||
package cn.odboy.system.framework.permission.config;
|
||||
|
||||
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service(value = "el")
|
||||
public class AuthorityConfig {
|
||||
@@ -34,7 +33,8 @@ public class AuthorityConfig {
|
||||
*/
|
||||
public Boolean check(String... permissions) {
|
||||
// 获取当前用户的所有权限
|
||||
List<String> roleList = KitSecurityHelper.getCurrentUser().getAuthorities().stream().map(GrantedAuthority::getAuthority).toList();
|
||||
List<String> roleList =
|
||||
KitSecurityHelper.getCurrentUser().getAuthorities().stream().map(GrantedAuthority::getAuthority).toList();
|
||||
// 判断当前用户的所有权限是否包含接口上定义的权限
|
||||
return roleList.contains("admin") || Arrays.stream(permissions).anyMatch(roleList::contains);
|
||||
}
|
||||
|
||||
+26
-25
@@ -23,6 +23,8 @@ import cn.odboy.system.framework.permission.core.handler.JwtAuthenticationEntryP
|
||||
import cn.odboy.system.framework.permission.core.handler.TokenFilter;
|
||||
import cn.odboy.system.framework.permission.core.handler.TokenProvider;
|
||||
import cn.odboy.util.KitAnonTagUtil;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -40,24 +42,15 @@ import org.springframework.security.web.SecurityFilterChain;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
import org.springframework.web.filter.CorsFilter;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Configuration
|
||||
@EnableMethodSecurity(prePostEnabled = true, securedEnabled = true)
|
||||
public class SpringSecurityConfig {
|
||||
@Autowired
|
||||
private TokenProvider tokenProvider;
|
||||
@Autowired
|
||||
private CorsFilter corsFilter;
|
||||
@Autowired
|
||||
private JwtAuthenticationEntryPoint authenticationErrorHandler;
|
||||
@Autowired
|
||||
private JwtAccessDeniedHandler jwtAccessDeniedHandler;
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
@Autowired
|
||||
private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO;
|
||||
@Autowired private TokenProvider tokenProvider;
|
||||
@Autowired private CorsFilter corsFilter;
|
||||
@Autowired private JwtAuthenticationEntryPoint authenticationErrorHandler;
|
||||
@Autowired private JwtAccessDeniedHandler jwtAccessDeniedHandler;
|
||||
@Autowired private ApplicationContext applicationContext;
|
||||
@Autowired private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO;
|
||||
|
||||
@Bean
|
||||
public GrantedAuthorityDefaults grantedAuthorityDefaults() {
|
||||
@@ -81,20 +74,23 @@ public class SpringSecurityConfig {
|
||||
|
||||
return httpSecurity
|
||||
// 禁用 CSRF
|
||||
.csrf(AbstractHttpConfigurer::disable).addFilter(corsFilter).addFilterBefore(customFilter, UsernamePasswordAuthenticationFilter.class)
|
||||
.csrf(AbstractHttpConfigurer::disable).addFilter(corsFilter)
|
||||
.addFilterBefore(customFilter, UsernamePasswordAuthenticationFilter.class)
|
||||
// 授权异常
|
||||
.exceptionHandling(
|
||||
exceptionHandling -> exceptionHandling.authenticationEntryPoint(authenticationErrorHandler).accessDeniedHandler(jwtAccessDeniedHandler))
|
||||
exceptionHandling -> exceptionHandling.authenticationEntryPoint(authenticationErrorHandler)
|
||||
.accessDeniedHandler(jwtAccessDeniedHandler))
|
||||
// 防止iframe 造成跨域
|
||||
.headers(headers -> headers.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable))
|
||||
// 不创建会话
|
||||
.sessionManagement(sessionManagement -> sessionManagement.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
||||
.sessionManagement(
|
||||
sessionManagement -> sessionManagement.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
||||
.authorizeHttpRequests(authorizeRequests -> authorizeRequests
|
||||
// 静态资源等等
|
||||
.requestMatchers(HttpMethod.GET, "*.html", "*.css", "*.js", "/websocket/**").permitAll()
|
||||
// Knife4j 和 OpenAPI 相关路径
|
||||
.requestMatchers("/doc.html", "/webjars/**", "/v3/api-docs", "/v3/api-docs/**", "/swagger-resources", "/swagger-resources/**",
|
||||
"/configuration/ui", "/configuration/security").permitAll()
|
||||
.requestMatchers("/doc.html", "/webjars/**", "/v3/api-docs", "/v3/api-docs/**", "/swagger-resources",
|
||||
"/swagger-resources/**", "/configuration/ui", "/configuration/security").permitAll()
|
||||
// 文件
|
||||
.requestMatchers("/avatar/**").permitAll().requestMatchers("/file/**").permitAll()
|
||||
// 阿里巴巴 druid
|
||||
@@ -103,15 +99,20 @@ public class SpringSecurityConfig {
|
||||
.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
|
||||
// 自定义匿名访问所有url放行:允许匿名和带Token访问,细腻化到每个 Request 类型
|
||||
// GET
|
||||
.requestMatchers(HttpMethod.GET, anonymousUrls.get(RequestMethodEnum.GET.getType()).toArray(new String[0])).permitAll()
|
||||
.requestMatchers(HttpMethod.GET,
|
||||
anonymousUrls.get(RequestMethodEnum.GET.getType()).toArray(new String[0])).permitAll()
|
||||
// POST
|
||||
.requestMatchers(HttpMethod.POST, anonymousUrls.get(RequestMethodEnum.POST.getType()).toArray(new String[0])).permitAll()
|
||||
.requestMatchers(HttpMethod.POST,
|
||||
anonymousUrls.get(RequestMethodEnum.POST.getType()).toArray(new String[0])).permitAll()
|
||||
// PUT
|
||||
.requestMatchers(HttpMethod.PUT, anonymousUrls.get(RequestMethodEnum.PUT.getType()).toArray(new String[0])).permitAll()
|
||||
.requestMatchers(HttpMethod.PUT,
|
||||
anonymousUrls.get(RequestMethodEnum.PUT.getType()).toArray(new String[0])).permitAll()
|
||||
// PATCH
|
||||
.requestMatchers(HttpMethod.PATCH, anonymousUrls.get(RequestMethodEnum.PATCH.getType()).toArray(new String[0])).permitAll()
|
||||
.requestMatchers(HttpMethod.PATCH,
|
||||
anonymousUrls.get(RequestMethodEnum.PATCH.getType()).toArray(new String[0])).permitAll()
|
||||
// DELETE
|
||||
.requestMatchers(HttpMethod.DELETE, anonymousUrls.get(RequestMethodEnum.DELETE.getType()).toArray(new String[0])).permitAll()
|
||||
.requestMatchers(HttpMethod.DELETE,
|
||||
anonymousUrls.get(RequestMethodEnum.DELETE.getType()).toArray(new String[0])).permitAll()
|
||||
// 所有类型的接口都放行
|
||||
.requestMatchers(anonymousUrls.get(RequestMethodEnum.ALL.getType()).toArray(new String[0])).permitAll()
|
||||
// 所有请求都需要认证
|
||||
|
||||
+4
-4
@@ -26,6 +26,8 @@ import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
@@ -33,9 +35,6 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 获取当前登录的用户
|
||||
*/
|
||||
@@ -122,7 +121,8 @@ public class KitSecurityHelper {
|
||||
* @return /
|
||||
*/
|
||||
public static String getToken() {
|
||||
HttpServletRequest request = ((ServletRequestAttributes)Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
|
||||
HttpServletRequest request = ((ServletRequestAttributes)Objects.requireNonNull(
|
||||
RequestContextHolder.getRequestAttributes())).getRequest();
|
||||
String bearerToken = request.getHeader(SystemConst.HEADER_NAME);
|
||||
if (bearerToken != null && bearerToken.startsWith(SystemConst.TOKEN_PREFIX)) {
|
||||
// 去掉令牌前缀
|
||||
|
||||
+5
-4
@@ -20,23 +20,24 @@ import cn.odboy.framework.exception.handler.ApiError;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.security.web.access.AccessDeniedHandler;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Component
|
||||
public class JwtAccessDeniedHandler implements AccessDeniedHandler {
|
||||
|
||||
@Override
|
||||
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException {
|
||||
public void handle(HttpServletRequest request, HttpServletResponse response,
|
||||
AccessDeniedException accessDeniedException) throws IOException {
|
||||
//当用户在没有授权的情况下访问受保护的REST资源时,将调用此方法发送403 Forbidden响应
|
||||
response.setStatus(HttpStatus.FORBIDDEN.value());
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String jsonResponse = objectMapper.writeValueAsString(ApiError.error(HttpStatus.FORBIDDEN.value(), "禁止访问,您没有权限访问此资源"));
|
||||
String jsonResponse = objectMapper.writeValueAsString(
|
||||
ApiError.error(HttpStatus.FORBIDDEN.value(), "禁止访问,您没有权限访问此资源"));
|
||||
response.getWriter().write(jsonResponse);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-4
@@ -20,26 +20,27 @@ import cn.odboy.framework.exception.handler.ApiError;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint {
|
||||
|
||||
@Override
|
||||
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException {
|
||||
public void commence(HttpServletRequest request, HttpServletResponse response,
|
||||
AuthenticationException authException) throws IOException {
|
||||
// 当用户尝试访问安全的REST资源而不提供任何凭据时,将调用此方法发送401 响应
|
||||
int code = HttpStatus.UNAUTHORIZED.value();
|
||||
response.setStatus(code);
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String jsonResponse = objectMapper.writeValueAsString(ApiError.error(HttpStatus.UNAUTHORIZED.value(), "登录状态已过期,请重新登录"));
|
||||
String jsonResponse = objectMapper.writeValueAsString(
|
||||
ApiError.error(HttpStatus.UNAUTHORIZED.value(), "登录状态已过期,请重新登录"));
|
||||
response.getWriter().write(jsonResponse);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -25,14 +25,13 @@ import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.filter.GenericFilterBean;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Slf4j
|
||||
public class TokenFilter extends GenericFilterBean {
|
||||
private final TokenProvider tokenProvider;
|
||||
@@ -48,7 +47,8 @@ public class TokenFilter extends GenericFilterBean {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws ServletException, IOException {
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
|
||||
throws ServletException, IOException {
|
||||
HttpServletRequest httpServletRequest = (HttpServletRequest)servletRequest;
|
||||
String token = resolveToken(httpServletRequest);
|
||||
// 对于 Token 为空的不需要去查 Redis
|
||||
|
||||
+8
-11
@@ -30,6 +30,12 @@ import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.io.Decoders;
|
||||
import io.jsonwebtoken.security.Keys;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.crypto.SecretKey;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -38,22 +44,13 @@ import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.crypto.SecretKey;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class TokenProvider implements InitializingBean {
|
||||
public static final String AUTHORITIES_UUID_KEY = "uid";
|
||||
public static final String AUTHORITIES_UID_KEY = "userId";
|
||||
@Autowired
|
||||
private KitRedisHelper redisHelper;
|
||||
@Autowired
|
||||
private AppProperties properties;
|
||||
@Autowired private KitRedisHelper redisHelper;
|
||||
@Autowired private AppProperties properties;
|
||||
// 0.11.x版本
|
||||
// private Key signingKey;
|
||||
// 0.12.x版本
|
||||
|
||||
+5
-10
@@ -24,27 +24,22 @@ import cn.odboy.system.dal.redis.SystemUserInfoDAO;
|
||||
import cn.odboy.system.service.SystemDataService;
|
||||
import cn.odboy.system.service.SystemRoleService;
|
||||
import cn.odboy.system.service.SystemUserService;
|
||||
import java.util.List;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* TODO 通过用户名判断用户信息,并获取拥有的权限与部门
|
||||
*/
|
||||
@Slf4j
|
||||
@Service("userDetailsService")
|
||||
public class UserDetailsHandler implements UserDetailsService {
|
||||
@Autowired
|
||||
private SystemRoleService systemRoleService;
|
||||
@Autowired
|
||||
private SystemUserService systemUserService;
|
||||
@Autowired
|
||||
private SystemDataService systemDataService;
|
||||
@Autowired
|
||||
private SystemUserInfoDAO systemUserInfoDAO;
|
||||
@Autowired private SystemRoleService systemRoleService;
|
||||
@Autowired private SystemUserService systemUserService;
|
||||
@Autowired private SystemDataService systemDataService;
|
||||
@Autowired private SystemUserInfoDAO systemUserInfoDAO;
|
||||
|
||||
@Override
|
||||
public SystemUserJwtVo loadUserByUsername(String username) {
|
||||
|
||||
+8
-7
@@ -31,16 +31,15 @@ import cn.odboy.system.dal.model.SystemSendEmailArgs;
|
||||
import cn.odboy.system.dal.mysql.SystemQuartzLogMapper;
|
||||
import cn.odboy.system.service.SystemEmailService;
|
||||
import cn.odboy.system.service.SystemQuartzJobService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.scheduling.quartz.QuartzJobBean;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Future;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.scheduling.quartz.QuartzJobBean;
|
||||
|
||||
@Slf4j
|
||||
public class ExecutionJobBean extends QuartzJobBean {
|
||||
@@ -69,7 +68,8 @@ public class ExecutionJobBean extends QuartzJobBean {
|
||||
quartzLog.setCronExpression(quartzJob.getCronExpression());
|
||||
try {
|
||||
// 执行任务
|
||||
QuartzRunnable task = new QuartzRunnable(quartzJob.getBeanName(), quartzJob.getMethodName(), quartzJob.getParams());
|
||||
QuartzRunnable task =
|
||||
new QuartzRunnable(quartzJob.getBeanName(), quartzJob.getMethodName(), quartzJob.getParams());
|
||||
Future<?> future = executor.submit(task);
|
||||
// 忽略任务执行结果
|
||||
future.get();
|
||||
@@ -122,7 +122,8 @@ public class ExecutionJobBean extends QuartzJobBean {
|
||||
Map<String, Object> data = new HashMap<>(16);
|
||||
data.put("task", quartzJob);
|
||||
data.put("msg", msg);
|
||||
TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig("template", TemplateConfig.ResourceMode.CLASSPATH));
|
||||
TemplateEngine engine =
|
||||
TemplateUtil.createEngine(new TemplateConfig("template", TemplateConfig.ResourceMode.CLASSPATH));
|
||||
Template template = engine.getTemplate("SystemQuartzJobTaskAlarmTemplate.ftl");
|
||||
sendEmailRequest.setContent(template.render(data));
|
||||
List<String> emails = Arrays.asList(quartzJob.getEmail().split("[,,]"));
|
||||
|
||||
+15
-6
@@ -19,26 +19,35 @@ package cn.odboy.system.framework.quartz;
|
||||
import cn.odboy.framework.exception.BadRequestException;
|
||||
import cn.odboy.system.dal.dataobject.SystemQuartzJobTb;
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.quartz.*;
|
||||
import org.quartz.CronScheduleBuilder;
|
||||
import org.quartz.CronTrigger;
|
||||
import org.quartz.JobBuilder;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobDetail;
|
||||
import org.quartz.JobKey;
|
||||
import org.quartz.ObjectAlreadyExistsException;
|
||||
import org.quartz.Scheduler;
|
||||
import org.quartz.Trigger;
|
||||
import org.quartz.TriggerBuilder;
|
||||
import org.quartz.TriggerKey;
|
||||
import org.quartz.impl.triggers.CronTriggerImpl;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class QuartzManage {
|
||||
|
||||
private static final String JOB_NAME = "TASK_";
|
||||
|
||||
@Resource
|
||||
private Scheduler scheduler;
|
||||
@Resource private Scheduler scheduler;
|
||||
|
||||
public void addJob(SystemQuartzJobTb quartzJob) {
|
||||
try {
|
||||
// 构建job信息
|
||||
JobDetail jobDetail = JobBuilder.newJob(ExecutionJobBean.class).withIdentity(JOB_NAME + quartzJob.getId()).build();
|
||||
JobDetail jobDetail =
|
||||
JobBuilder.newJob(ExecutionJobBean.class).withIdentity(JOB_NAME + quartzJob.getId()).build();
|
||||
|
||||
// 通过触发器名和cron 表达式创建 Trigger
|
||||
Trigger trigger = TriggerBuilder.newTrigger().withIdentity(JOB_NAME + quartzJob.getId()).startNow()
|
||||
|
||||
+3
-3
@@ -28,14 +28,14 @@ import org.springframework.context.annotation.Configuration;
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class OssStorageConfiguration {
|
||||
@Autowired
|
||||
private AppProperties properties;
|
||||
@Autowired private AppProperties properties;
|
||||
|
||||
@Bean
|
||||
public MinioClient minioClient() {
|
||||
try {
|
||||
OSSConfigModel minio = properties.getOss().getMinio();
|
||||
return MinioClient.builder().endpoint(minio.getEndpoint()).credentials(minio.getAccessKey(), minio.getSecretKey()).build();
|
||||
return MinioClient.builder().endpoint(minio.getEndpoint())
|
||||
.credentials(minio.getAccessKey(), minio.getSecretKey()).build();
|
||||
} catch (Exception e) {
|
||||
log.error("创建Minio客户端失败", e);
|
||||
throw new BadRequestException("创建Minio客户端失败");
|
||||
|
||||
+3
-6
@@ -19,6 +19,7 @@ package cn.odboy.system.framework.storage.local;
|
||||
import cn.odboy.framework.exception.BadRequestException;
|
||||
import cn.odboy.framework.properties.AppProperties;
|
||||
import jakarta.servlet.MultipartConfigElement;
|
||||
import java.io.File;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -27,15 +28,11 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.util.unit.DataSize;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class MultipartConfig {
|
||||
@Value("${spring.application.name}")
|
||||
private String name;
|
||||
@Autowired
|
||||
private AppProperties properties;
|
||||
@Value("${spring.application.name}") private String name;
|
||||
@Autowired private AppProperties properties;
|
||||
|
||||
/**
|
||||
* 文件上传临时路径
|
||||
|
||||
+36
-22
@@ -30,30 +30,37 @@ import cn.odboy.framework.properties.model.StorageOSSModel;
|
||||
import cn.odboy.system.dal.dataobject.SystemOssStorageTb;
|
||||
import cn.odboy.util.KitDateUtil;
|
||||
import cn.odboy.util.KitFileUtil;
|
||||
import io.minio.*;
|
||||
import io.minio.BucketExistsArgs;
|
||||
import io.minio.GetObjectArgs;
|
||||
import io.minio.GetObjectResponse;
|
||||
import io.minio.GetPresignedObjectUrlArgs;
|
||||
import io.minio.ListObjectsArgs;
|
||||
import io.minio.MakeBucketArgs;
|
||||
import io.minio.MinioClient;
|
||||
import io.minio.PutObjectArgs;
|
||||
import io.minio.RemoveBucketArgs;
|
||||
import io.minio.RemoveObjectArgs;
|
||||
import io.minio.Result;
|
||||
import io.minio.http.Method;
|
||||
import io.minio.messages.Bucket;
|
||||
import io.minio.messages.Item;
|
||||
import jakarta.servlet.ServletOutputStream;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MinioRepository {
|
||||
@Autowired
|
||||
private AppProperties properties;
|
||||
@Autowired
|
||||
private MinioClient minioClient;
|
||||
@Autowired private AppProperties properties;
|
||||
@Autowired private MinioClient minioClient;
|
||||
|
||||
/**
|
||||
* 检查存储bucket是否存在
|
||||
@@ -136,7 +143,8 @@ public class MinioRepository {
|
||||
* @param md5 文件md5
|
||||
* @return String 上传后的文件名,上传失败返回 null
|
||||
*/
|
||||
public SystemOssStorageTb upload(File tempFile, String originalFilename, long fileSize, String contentType, String md5) {
|
||||
public SystemOssStorageTb upload(File tempFile, String originalFilename, long fileSize, String contentType,
|
||||
String md5) {
|
||||
StorageOSSModel ossConfig = properties.getOss();
|
||||
OSSConfigModel ossMinioConfig = ossConfig.getMinio();
|
||||
String type = FileTypeUtil.getType(tempFile);
|
||||
@@ -164,9 +172,8 @@ public class MinioRepository {
|
||||
systemOssStorageTb.setObjectName(objectName);
|
||||
|
||||
try (InputStream fileInputStream = KitFileUtil.getInputStream(tempFile)) {
|
||||
PutObjectArgs objectArgs =
|
||||
PutObjectArgs.builder().bucket(ossMinioConfig.getBucketName()).object(objectName).stream(fileInputStream, fileSize, -1).contentType(contentType)
|
||||
.build();
|
||||
PutObjectArgs objectArgs = PutObjectArgs.builder().bucket(ossMinioConfig.getBucketName()).object(objectName)
|
||||
.stream(fileInputStream, fileSize, -1).contentType(contentType).build();
|
||||
minioClient.putObject(objectArgs);
|
||||
log.info("文件上传成功,并删除临时文件,文件名:{}", originalFilename);
|
||||
return systemOssStorageTb;
|
||||
@@ -204,8 +211,8 @@ public class MinioRepository {
|
||||
log.info("准备上传文件,原文件名:{},上传后文件名:{}", originalFilename, fileName);
|
||||
try (InputStream fileInputStream = file.getInputStream()) {
|
||||
PutObjectArgs objectArgs =
|
||||
PutObjectArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).object(objectName).stream(fileInputStream, file.getSize(), -1)
|
||||
.contentType(file.getContentType()).build();
|
||||
PutObjectArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).object(objectName)
|
||||
.stream(fileInputStream, file.getSize(), -1).contentType(file.getContentType()).build();
|
||||
// 使用重试机制进行上传
|
||||
uploadWithRetry(objectArgs, 3);
|
||||
log.info("文件上传成功,objectName: {}", objectName);
|
||||
@@ -254,7 +261,8 @@ public class MinioRepository {
|
||||
}
|
||||
try {
|
||||
GetPresignedObjectUrlArgs presignedUrlArgs =
|
||||
GetPresignedObjectUrlArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).object(fullFileName).method(Method.GET)
|
||||
GetPresignedObjectUrlArgs.builder().bucket(properties.getOss().getMinio().getBucketName())
|
||||
.object(fullFileName).method(Method.GET)
|
||||
// 设置 URL 过期时间为 7 天, 最大 7 天, 别挣扎了
|
||||
.expiry(3600 * 24 * 7).build();
|
||||
String url = minioClient.getPresignedObjectUrl(presignedUrlArgs);
|
||||
@@ -273,9 +281,11 @@ public class MinioRepository {
|
||||
* @param res HTTP 响应
|
||||
*/
|
||||
public void download(String fileName, HttpServletResponse res) {
|
||||
GetObjectArgs objectArgs = GetObjectArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).object(fileName).build();
|
||||
GetObjectArgs objectArgs =
|
||||
GetObjectArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).object(fileName).build();
|
||||
|
||||
try (GetObjectResponse response = minioClient.getObject(objectArgs); FastByteArrayOutputStream os = new FastByteArrayOutputStream()) {
|
||||
try (GetObjectResponse response = minioClient.getObject(objectArgs);
|
||||
FastByteArrayOutputStream os = new FastByteArrayOutputStream()) {
|
||||
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
@@ -303,7 +313,8 @@ public class MinioRepository {
|
||||
* @param res HTTP 响应
|
||||
*/
|
||||
public void downloadOptimizedVersion(String fileName, HttpServletResponse res) {
|
||||
GetObjectArgs objectArgs = GetObjectArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).object(fileName).build();
|
||||
GetObjectArgs objectArgs =
|
||||
GetObjectArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).object(fileName).build();
|
||||
|
||||
try (GetObjectResponse response = minioClient.getObject(objectArgs)) {
|
||||
// 增大缓冲区
|
||||
@@ -337,7 +348,8 @@ public class MinioRepository {
|
||||
*/
|
||||
public List<Item> queryAllObjects() {
|
||||
try {
|
||||
Iterable<Result<Item>> results = minioClient.listObjects(ListObjectsArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).build());
|
||||
Iterable<Result<Item>> results = minioClient.listObjects(
|
||||
ListObjectsArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).build());
|
||||
List<Item> items = new ArrayList<>();
|
||||
for (Result<Item> result : results) {
|
||||
items.add(result.get());
|
||||
@@ -357,7 +369,9 @@ public class MinioRepository {
|
||||
*/
|
||||
public boolean removeBucketFile(String fileName) {
|
||||
try {
|
||||
minioClient.removeObject(RemoveObjectArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).object(fileName).build());
|
||||
minioClient.removeObject(
|
||||
RemoveObjectArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).object(fileName)
|
||||
.build());
|
||||
log.info("删除文件成功,fileName: {}", fileName);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@ import cn.odboy.system.constant.SystemDataScopeEnum;
|
||||
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||
import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
||||
import cn.odboy.system.dal.dataobject.SystemUserTb;
|
||||
import cn.odboy.system.dal.model.SystemRoleVo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -47,7 +48,7 @@ public class SystemDataService {
|
||||
public List<Long> findDeptIdListByArgs(SystemUserTb user) {
|
||||
List<Long> deptIds = new ArrayList<>();
|
||||
// 查询用户角色
|
||||
List<SystemRoleTb> roleList = systemRoleService.queryRoleByUsersId(user.getId());
|
||||
List<SystemRoleVo> roleList = systemRoleService.queryRoleByUsersId(user.getId());
|
||||
// 获取对应的部门ID
|
||||
for (SystemRoleTb role : roleList) {
|
||||
SystemDataScopeEnum dataScopeEnum = SystemDataScopeEnum.find(role.getDataScope());
|
||||
|
||||
-2
@@ -21,7 +21,6 @@ import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.odboy.base.KitPageResult;
|
||||
import cn.odboy.framework.context.KitSpringBeanHolder;
|
||||
import cn.odboy.framework.exception.BadRequestException;
|
||||
import cn.odboy.system.constant.SystemDataScopeEnum;
|
||||
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||
@@ -35,7 +34,6 @@ import cn.odboy.system.dal.mysql.SystemUserMapper;
|
||||
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
|
||||
import cn.odboy.util.KitClassUtil;
|
||||
import cn.odboy.util.KitFileUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
+2
-1
@@ -28,6 +28,7 @@ import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
||||
import cn.odboy.system.dal.model.SystemMenuMetaVo;
|
||||
import cn.odboy.system.dal.model.SystemMenuVo;
|
||||
import cn.odboy.system.dal.model.SystemQueryMenuArgs;
|
||||
import cn.odboy.system.dal.model.SystemRoleVo;
|
||||
import cn.odboy.system.dal.mysql.SystemMenuMapper;
|
||||
import cn.odboy.system.dal.mysql.SystemRoleMenuMapper;
|
||||
import cn.odboy.util.KitClassUtil;
|
||||
@@ -241,7 +242,7 @@ public class SystemMenuService {
|
||||
* @return /
|
||||
*/
|
||||
public List<SystemMenuTb> queryMenuListByUserId(Long currentUserId) {
|
||||
List<SystemRoleTb> roles = systemRoleService.queryRoleByUsersId(currentUserId);
|
||||
List<SystemRoleVo> roles = systemRoleService.queryRoleByUsersId(currentUserId);
|
||||
Set<Long> roleIds = roles.stream().map(SystemRoleTb::getId).collect(Collectors.toSet());
|
||||
return new ArrayList<>(systemRoleMenuService.queryMenuByRoleIdsAndType(roleIds, 2));
|
||||
}
|
||||
|
||||
+11
-10
@@ -27,6 +27,7 @@ import cn.odboy.system.dal.dataobject.SystemUserTb;
|
||||
import cn.odboy.system.dal.model.SystemCreateRoleArgs;
|
||||
import cn.odboy.system.dal.model.SystemQueryRoleArgs;
|
||||
import cn.odboy.system.dal.model.SystemRoleCodeVo;
|
||||
import cn.odboy.system.dal.model.SystemRoleVo;
|
||||
import cn.odboy.system.dal.mysql.SystemRoleMapper;
|
||||
import cn.odboy.system.dal.mysql.SystemUserMapper;
|
||||
import cn.odboy.util.KitFileUtil;
|
||||
@@ -83,8 +84,8 @@ public class SystemRoleService {
|
||||
* @param args /
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void modifyRoleById(SystemRoleTb args) {
|
||||
SystemRoleTb role = systemRoleMapper.selectById(args.getId());
|
||||
public void modifyRoleById(SystemRoleVo args) {
|
||||
SystemRoleVo role = BeanUtil.copyProperties(systemRoleMapper.selectById(args.getId()), SystemRoleVo.class);
|
||||
SystemRoleTb role1 = this.getRoleByName(args.getName());
|
||||
if (role1 != null && !role1.getId().equals(role.getId())) {
|
||||
throw new BadRequestException("角色名称已存在");
|
||||
@@ -109,7 +110,7 @@ public class SystemRoleService {
|
||||
*
|
||||
* @param role /
|
||||
*/
|
||||
public void modifyBindMenuById(SystemRoleTb role) {
|
||||
public void modifyBindMenuById(SystemRoleVo role) {
|
||||
// 更新菜单
|
||||
systemRoleMenuService.deleteRoleMenuByRoleId(role.getId());
|
||||
// 判断是否为空
|
||||
@@ -138,9 +139,9 @@ public class SystemRoleService {
|
||||
* @param response /
|
||||
* @throws IOException
|
||||
*/
|
||||
public void exportRoleExcel(List<SystemRoleTb> roles, HttpServletResponse response) throws IOException {
|
||||
public void exportRoleExcel(List<SystemRoleVo> roles, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (SystemRoleTb role : roles) {
|
||||
for (SystemRoleVo role : roles) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("角色名称", role.getName());
|
||||
map.put("角色级别", role.getLevel());
|
||||
@@ -172,7 +173,7 @@ public class SystemRoleService {
|
||||
* @param criteria 条件
|
||||
* @return
|
||||
*/
|
||||
public List<SystemRoleTb> queryRoleByArgs(SystemQueryRoleArgs criteria) {
|
||||
public List<SystemRoleVo> queryRoleByArgs(SystemQueryRoleArgs criteria) {
|
||||
return systemRoleMapper.selectRoleByArgs(criteria);
|
||||
}
|
||||
|
||||
@@ -183,9 +184,9 @@ public class SystemRoleService {
|
||||
* @param page 分页参数
|
||||
* @return
|
||||
*/
|
||||
public KitPageResult<SystemRoleTb> queryRoleByArgs(SystemQueryRoleArgs criteria, Page<Object> page) {
|
||||
public KitPageResult<SystemRoleVo> queryRoleByArgs(SystemQueryRoleArgs criteria, Page<Object> page) {
|
||||
criteria.setOffset(page.offset());
|
||||
List<SystemRoleTb> roles = systemRoleMapper.selectRoleByArgs(criteria);
|
||||
List<SystemRoleVo> roles = systemRoleMapper.selectRoleByArgs(criteria);
|
||||
Long total = systemRoleMapper.countRoleByArgs(criteria);
|
||||
return KitPageUtil.toPage(roles, total);
|
||||
}
|
||||
@@ -196,7 +197,7 @@ public class SystemRoleService {
|
||||
* @param userId 用户ID
|
||||
* @return /
|
||||
*/
|
||||
public List<SystemRoleTb> queryRoleByUsersId(Long userId) {
|
||||
public List<SystemRoleVo> queryRoleByUsersId(Long userId) {
|
||||
return systemRoleMapper.selectRoleByUserId(userId);
|
||||
}
|
||||
|
||||
@@ -230,7 +231,7 @@ public class SystemRoleService {
|
||||
permissions.add("admin");
|
||||
return permissions.stream().map(SystemRoleCodeVo::new).collect(Collectors.toList());
|
||||
}
|
||||
List<SystemRoleTb> roles = systemRoleMapper.selectRoleByUserId(user.getId());
|
||||
List<SystemRoleVo> roles = systemRoleMapper.selectRoleByUserId(user.getId());
|
||||
permissions = roles.stream().flatMap(role -> role.getMenus().stream()).map(SystemMenuTb::getPermission)
|
||||
.filter(StrUtil::isNotBlank).collect(Collectors.toSet());
|
||||
return permissions.stream().map(SystemRoleCodeVo::new).collect(Collectors.toList());
|
||||
|
||||
+11
-9
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package cn.odboy.system.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.odboy.base.KitPageArgs;
|
||||
import cn.odboy.base.KitPageResult;
|
||||
@@ -25,6 +26,7 @@ import cn.odboy.system.dal.dataobject.SystemJobTb;
|
||||
import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
||||
import cn.odboy.system.dal.dataobject.SystemUserTb;
|
||||
import cn.odboy.system.dal.model.SystemQueryUserArgs;
|
||||
import cn.odboy.system.dal.model.SystemUserVo;
|
||||
import cn.odboy.system.dal.mysql.SystemUserMapper;
|
||||
import cn.odboy.system.dal.redis.SystemUserInfoDAO;
|
||||
import cn.odboy.system.dal.redis.SystemUserOnlineInfoDAO;
|
||||
@@ -66,7 +68,7 @@ public class SystemUserService {
|
||||
* @param args /
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveUser(SystemUserTb args) {
|
||||
public void saveUser(SystemUserVo args) {
|
||||
args.setDeptId(args.getDept().getId());
|
||||
if (systemUserMapper.getUserByUsername(args.getUsername()) != null) {
|
||||
throw new BadRequestException("用户名已存在");
|
||||
@@ -91,9 +93,9 @@ public class SystemUserService {
|
||||
* @throws Exception /
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void modifyUserById(SystemUserTb args) {
|
||||
SystemUserTb user = systemUserMapper.selectById(args.getId());
|
||||
SystemUserTb user1 = systemUserMapper.getUserByUsername(args.getUsername());
|
||||
public void modifyUserById(SystemUserVo args) {
|
||||
SystemUserVo user = BeanUtil.copyProperties(systemUserMapper.selectById(args.getId()), SystemUserVo.class);
|
||||
SystemUserVo user1 = systemUserMapper.getUserByUsername(args.getUsername());
|
||||
SystemUserTb user2 = systemUserMapper.getUserByEmail(args.getEmail());
|
||||
SystemUserTb user3 = systemUserMapper.getUserByPhone(args.getPhone());
|
||||
if (user1 != null && !user.getId().equals(user1.getId())) {
|
||||
@@ -254,9 +256,9 @@ public class SystemUserService {
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
public void exportUserExcel(List<SystemUserTb> users, HttpServletResponse response) throws IOException {
|
||||
public void exportUserExcel(List<SystemUserVo> users, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (SystemUserTb user : users) {
|
||||
for (SystemUserVo user : users) {
|
||||
List<String> roles = user.getRoles().stream().map(SystemRoleTb::getName).collect(Collectors.toList());
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("用户名", user.getUsername());
|
||||
@@ -280,8 +282,8 @@ public class SystemUserService {
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
public KitPageResult<SystemUserTb> queryUserByArgs(SystemQueryUserArgs criteria, Page<SystemUserTb> page) {
|
||||
IPage<SystemUserTb> users = systemUserMapper.selectUserByArgs(criteria, page);
|
||||
public KitPageResult<SystemUserVo> queryUserByArgs(SystemQueryUserArgs criteria, Page<SystemUserTb> page) {
|
||||
IPage<SystemUserVo> users = systemUserMapper.selectUserByArgs(criteria, page);
|
||||
return KitPageUtil.toPage(users);
|
||||
}
|
||||
|
||||
@@ -291,7 +293,7 @@ public class SystemUserService {
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
public List<SystemUserTb> queryUserByArgs(SystemQueryUserArgs criteria) {
|
||||
public List<SystemUserVo> queryUserByArgs(SystemQueryUserArgs criteria) {
|
||||
return systemUserMapper.selectUserByArgs(criteria);
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -22,9 +22,6 @@ import cn.odboy.util.KitCloseUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -35,6 +32,8 @@ import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.List;
|
||||
import javax.sql.DataSource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public final class KitSqlUtil {
|
||||
@@ -165,7 +164,8 @@ public final class KitSqlUtil {
|
||||
private static List<String> readSqlList(File sqlFile) throws Exception {
|
||||
List<String> sqlList = Lists.newArrayList();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(Files.newInputStream(sqlFile.toPath()), StandardCharsets.UTF_8))) {
|
||||
try (BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(Files.newInputStream(sqlFile.toPath()), StandardCharsets.UTF_8))) {
|
||||
String tmp;
|
||||
while ((tmp = reader.readLine()) != null) {
|
||||
log.info("line:{}", tmp);
|
||||
|
||||
+42
-42
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="cn.odboy.system.dal.mysql.SystemRoleMapper">
|
||||
<resultMap id="BaseResultMap" type="cn.odboy.system.dal.dataobject.SystemRoleTb">
|
||||
<resultMap id="BaseResultMap" type="cn.odboy.system.dal.model.SystemRoleVo">
|
||||
<id column="role_role_id" property="id"/>
|
||||
<result column="role_name" property="name"/>
|
||||
<result column="role_data_scope" property="dataScope"/>
|
||||
@@ -54,50 +54,50 @@
|
||||
order by role.role_level
|
||||
</select>
|
||||
<select id="getRoleById" resultMap="BaseResultMap">
|
||||
select role.role_id as role_role_id,
|
||||
role.name as role_name,
|
||||
role.data_scope as role_data_scope,
|
||||
role.level as role_level,
|
||||
role.description as role_description,
|
||||
role.create_by as role_create_by,
|
||||
role.update_by as role_update_by,
|
||||
role.create_time as role_create_time,
|
||||
role.update_time as role_update_time,
|
||||
dept.dept_id as dept_id,
|
||||
dept.name as dept_name,
|
||||
menu.menu_id as menu_id,
|
||||
menu.title as menu_title,
|
||||
menu.permission as menu_permission
|
||||
select role.role_id as role_role_id,
|
||||
role.name as role_name,
|
||||
role.data_scope as role_data_scope,
|
||||
role.level as role_level,
|
||||
role.description as role_description,
|
||||
role.create_by as role_create_by,
|
||||
role.update_by as role_update_by,
|
||||
role.create_time as role_create_time,
|
||||
role.update_time as role_update_time,
|
||||
dept.dept_id as dept_id,
|
||||
dept.name as dept_name,
|
||||
menu.menu_id as menu_id,
|
||||
menu.title as menu_title,
|
||||
menu.permission as menu_permission
|
||||
from system_role role
|
||||
left join system_roles_menus srm on role.role_id = srm.role_id
|
||||
left join system_menu menu on menu.menu_id = srm.menu_id
|
||||
left join system_roles_depts srd on role.role_id = srd.role_id
|
||||
left join system_dept dept on dept.dept_id = srd.dept_id
|
||||
left join system_roles_menus srm on role.role_id = srm.role_id
|
||||
left join system_menu menu on menu.menu_id = srm.menu_id
|
||||
left join system_roles_depts srd on role.role_id = srd.role_id
|
||||
left join system_dept dept on dept.dept_id = srd.dept_id
|
||||
where role.role_id = #{roleId}
|
||||
</select>
|
||||
<select id="selectRoleByUserId" resultMap="BaseResultMap">
|
||||
SELECT role.role_id as role_role_id,
|
||||
role.name as role_name,
|
||||
role.data_scope as role_data_scope,
|
||||
role.level as role_level,
|
||||
role.description as role_description,
|
||||
role.create_by as role_create_by,
|
||||
role.update_by as role_update_by,
|
||||
role.create_time as role_create_time,
|
||||
role.update_time as role_update_time,
|
||||
dept.dept_id as dept_id,
|
||||
dept.name as dept_name,
|
||||
menu.menu_id as menu_id,
|
||||
menu.title as menu_title,
|
||||
menu.permission as menu_permission
|
||||
SELECT role.role_id as role_role_id,
|
||||
role.name as role_name,
|
||||
role.data_scope as role_data_scope,
|
||||
role.level as role_level,
|
||||
role.description as role_description,
|
||||
role.create_by as role_create_by,
|
||||
role.update_by as role_update_by,
|
||||
role.create_time as role_create_time,
|
||||
role.update_time as role_update_time,
|
||||
dept.dept_id as dept_id,
|
||||
dept.name as dept_name,
|
||||
menu.menu_id as menu_id,
|
||||
menu.title as menu_title,
|
||||
menu.permission as menu_permission
|
||||
from system_role role
|
||||
left join system_roles_menus srm on role.role_id = srm.role_id
|
||||
left join system_menu menu on menu.menu_id = srm.menu_id
|
||||
left join system_roles_depts srd on role.role_id = srd.role_id
|
||||
left join system_dept dept on dept.dept_id = srd.dept_id
|
||||
left join system_users_roles ur on role.role_id = ur.role_id
|
||||
left join system_roles_menus srm on role.role_id = srm.role_id
|
||||
left join system_menu menu on menu.menu_id = srm.menu_id
|
||||
left join system_roles_depts srd on role.role_id = srd.role_id
|
||||
left join system_dept dept on dept.dept_id = srd.dept_id
|
||||
left join system_users_roles ur on role.role_id = ur.role_id
|
||||
WHERE role.role_id = ur.role_id
|
||||
AND ur.user_id = #{userId}
|
||||
AND ur.user_id = #{userId}
|
||||
</select>
|
||||
<select id="countRoleByDeptIds" resultType="int">
|
||||
select count(*)
|
||||
@@ -108,11 +108,11 @@
|
||||
#{deptId}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="selectRoleByMenuId" resultType="cn.odboy.system.dal.dataobject.SystemRoleTb">
|
||||
<select id="selectRoleByMenuId" resultType="cn.odboy.system.dal.model.SystemRoleVo">
|
||||
SELECT role.role_id as id
|
||||
FROM system_role role,
|
||||
system_roles_menus rm
|
||||
system_roles_menus rm
|
||||
WHERE role.role_id = rm.role_id
|
||||
AND rm.menu_id = #{menuId}
|
||||
AND rm.menu_id = #{menuId}
|
||||
</select>
|
||||
</mapper>
|
||||
+36
-36
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="cn.odboy.system.dal.mysql.SystemUserMapper">
|
||||
<resultMap id="BaseResultMap" type="cn.odboy.system.dal.dataobject.SystemUserTb">
|
||||
<resultMap id="BaseResultMap" type="cn.odboy.system.dal.model.SystemUserVo">
|
||||
<id column="user_user_id" property="id"/>
|
||||
<result column="user_dept_id" property="deptId"/>
|
||||
<result column="user_username" property="username"/>
|
||||
@@ -27,7 +27,7 @@
|
||||
<id column="job_id" property="id"/>
|
||||
<result column="job_name" property="name"/>
|
||||
</collection>
|
||||
<collection property="roles" ofType="cn.odboy.system.dal.dataobject.SystemRoleTb">
|
||||
<collection property="roles" ofType="cn.odboy.system.dal.model.SystemRoleVo">
|
||||
<id column="role_id" property="id"/>
|
||||
<result column="role_name" property="name"/>
|
||||
<result column="role_level" property="level"/>
|
||||
@@ -91,56 +91,56 @@
|
||||
order by u.user_id desc
|
||||
</select>
|
||||
<select id="getUserByUsername" resultMap="BaseResultMap">
|
||||
select u.password user_password,
|
||||
u.is_admin user_is_admin,
|
||||
u.user_id as user_user_id,
|
||||
u.dept_id as user_dept_id,
|
||||
u.username as user_username,
|
||||
u.nick_name as user_nick_name,
|
||||
u.email as user_email,
|
||||
u.phone as user_phone,
|
||||
u.gender as user_gender,
|
||||
u.avatar_name as user_avatar_name,
|
||||
u.avatar_path as user_avatar_path,
|
||||
u.enabled as user_enabled,
|
||||
u.pwd_reset_time as user_pwd_reset_time,
|
||||
u.create_by as user_create_by,
|
||||
u.update_by as user_update_by,
|
||||
u.create_time as user_create_time,
|
||||
u.update_time as user_update_time,
|
||||
d.dept_id as dept_id,
|
||||
d.name as dept_name
|
||||
select u.password user_password,
|
||||
u.is_admin user_is_admin,
|
||||
u.user_id as user_user_id,
|
||||
u.dept_id as user_dept_id,
|
||||
u.username as user_username,
|
||||
u.nick_name as user_nick_name,
|
||||
u.email as user_email,
|
||||
u.phone as user_phone,
|
||||
u.gender as user_gender,
|
||||
u.avatar_name as user_avatar_name,
|
||||
u.avatar_path as user_avatar_path,
|
||||
u.enabled as user_enabled,
|
||||
u.pwd_reset_time as user_pwd_reset_time,
|
||||
u.create_by as user_create_by,
|
||||
u.update_by as user_update_by,
|
||||
u.create_time as user_create_time,
|
||||
u.update_time as user_update_time,
|
||||
d.dept_id as dept_id,
|
||||
d.name as dept_name
|
||||
from system_user u
|
||||
left join system_dept d on u.dept_id = d.dept_id
|
||||
left join system_dept d on u.dept_id = d.dept_id
|
||||
where u.username = #{username}
|
||||
and u.enabled = 1
|
||||
and u.enabled = 1
|
||||
</select>
|
||||
<select id="selectUserByRoleId" resultType="cn.odboy.system.dal.dataobject.SystemUserTb">
|
||||
<select id="selectUserByRoleId" resultType="cn.odboy.system.dal.model.SystemUserVo">
|
||||
SELECT u.user_id as id, u.username
|
||||
FROM system_user u,
|
||||
system_users_roles r
|
||||
system_users_roles r
|
||||
WHERE u.user_id = r.user_id
|
||||
AND r.role_id = #{roleId}
|
||||
AND r.role_id = #{roleId}
|
||||
group by u.user_id
|
||||
</select>
|
||||
<select id="selectUserByDeptId" resultType="cn.odboy.system.dal.dataobject.SystemUserTb">
|
||||
<select id="selectUserByDeptId" resultType="cn.odboy.system.dal.model.SystemUserVo">
|
||||
SELECT u.*
|
||||
FROM system_user u,
|
||||
system_users_roles r,
|
||||
system_roles_depts d
|
||||
system_users_roles r,
|
||||
system_roles_depts d
|
||||
WHERE u.user_id = r.user_id
|
||||
AND r.role_id = d.role_id
|
||||
AND d.dept_id = #{deptId}
|
||||
AND r.role_id = d.role_id
|
||||
AND d.dept_id = #{deptId}
|
||||
group by u.user_id
|
||||
</select>
|
||||
<select id="selectUserByMenuId" resultType="cn.odboy.system.dal.dataobject.SystemUserTb">
|
||||
<select id="selectUserByMenuId" resultType="cn.odboy.system.dal.model.SystemUserVo">
|
||||
SELECT u.user_id as id, u.username
|
||||
FROM system_user u,
|
||||
system_users_roles ur,
|
||||
system_roles_menus rm
|
||||
system_users_roles ur,
|
||||
system_roles_menus rm
|
||||
WHERE u.user_id = ur.user_id
|
||||
AND ur.role_id = rm.role_id
|
||||
AND rm.menu_id = #{menuId}
|
||||
AND ur.role_id = rm.role_id
|
||||
AND rm.menu_id = #{menuId}
|
||||
group by u.user_id
|
||||
</select>
|
||||
<select id="countUserByJobIds" resultType="Long">
|
||||
|
||||
+18
-18
@@ -1,12 +1,12 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<style>
|
||||
@page {
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<style>
|
||||
@page {
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body style="margin: 0px;
|
||||
padding: 0px;
|
||||
@@ -18,10 +18,10 @@
|
||||
margin: 0 auto;
|
||||
margin-top: 20px;
|
||||
border: 1px solid #eee;">
|
||||
<div style="padding: 10px;padding-bottom: 0px;">
|
||||
<p style="margin-bottom: 10px;padding-bottom: 0px;">尊敬的用户, 您好:</p>
|
||||
<p style="text-indent: 2em; margin-bottom: 10px;">您正在申请邮箱验证,您的验证码为:</p>
|
||||
<p style="text-align: center;
|
||||
<div style="padding: 10px;padding-bottom: 0px;">
|
||||
<p style="margin-bottom: 10px;padding-bottom: 0px;">尊敬的用户, 您好:</p>
|
||||
<p style="text-indent: 2em; margin-bottom: 10px;">您正在申请邮箱验证,您的验证码为:</p>
|
||||
<p style="text-align: center;
|
||||
font-family: Times New Roman;
|
||||
font-size: 22px;
|
||||
color: #C60024;
|
||||
@@ -29,22 +29,22 @@
|
||||
margin-bottom: 10px;
|
||||
font-weight: bold;
|
||||
background: #ebebeb;">${code}</p>
|
||||
<div class="foot-hr hr" style="margin: 0 auto;
|
||||
<div class="foot-hr hr" style="margin: 0 auto;
|
||||
z-index: 111;
|
||||
width: 800px;
|
||||
margin-top: 30px;
|
||||
border-top: 1px solid #DA251D;">
|
||||
</div>
|
||||
<div style="text-align: center;
|
||||
</div>
|
||||
<div style="text-align: center;
|
||||
font-size: 12px;
|
||||
padding: 20px 0px;
|
||||
font-family: Microsoft YaHei;">
|
||||
Copyright ©${.now?string("yyyy")} <a hover="color: #DA251D;" style="color: #999;"
|
||||
href="https://github.com/odboy-tianjun/cutejava" target="_blank">CuteJava</a>
|
||||
后台管理系统 All Rights Reserved.
|
||||
</div>
|
||||
|
||||
Copyright ©${.now?string("yyyy")} <a hover="color: #DA251D;" style="color: #999;"
|
||||
href="https://github.com/odboy-tianjun/cutejava" target="_blank">CuteJava</a>
|
||||
后台管理系统 All Rights Reserved.
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+38
-38
@@ -1,12 +1,12 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<style>
|
||||
@page {
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<style>
|
||||
@page {
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body style="margin: 0px;
|
||||
padding: 0px;
|
||||
@@ -17,30 +17,30 @@
|
||||
margin-top: 20px;
|
||||
padding: 20px;
|
||||
border: 1px solid #eee;">
|
||||
<div>
|
||||
<p style="margin-bottom: 10px;">任务信息:</p>
|
||||
<table style="border-collapse: collapse;">
|
||||
<tr>
|
||||
<th style="padding: .65em;background: #666;border: 1px solid #777;color: #fff;">任务名称</th>
|
||||
<th style="padding: .65em;background: #666;border: 1px solid #777;color: #fff;">Bean名称</th>
|
||||
<th style="padding: .65em;background: #666;border: 1px solid #777;color: #fff;">执行方法</th>
|
||||
<th style="padding: .65em;background: #666;border: 1px solid #777;color: #fff;">参数内容</th>
|
||||
<th style="padding: .65em;background: #666;border: 1px solid #777;color: #fff;">Cron表达式</th>
|
||||
<th style="padding: .65em;background: #666;border: 1px solid #777;color: #fff;">描述内容</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding: .65em;border: 1px solid#777;">${task.jobName}</td>
|
||||
<td style="padding: .65em;border: 1px solid#777;">${task.beanName}</td>
|
||||
<td style="padding: .65em;border: 1px solid#777;">${task.methodName}</td>
|
||||
<td style="padding: .65em;border: 1px solid#777;">${(task.params)!""}</td>
|
||||
<td style="padding: .65em;border: 1px solid#777;">${task.cronExpression}</td>
|
||||
<td style="padding: .65em;border: 1px solid#777;">${(task.description)!""}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
<p style="margin-bottom: 10px;">异常信息:</p>
|
||||
<pre style="position: relative;
|
||||
<div>
|
||||
<p style="margin-bottom: 10px;">任务信息:</p>
|
||||
<table style="border-collapse: collapse;">
|
||||
<tr>
|
||||
<th style="padding: .65em;background: #666;border: 1px solid #777;color: #fff;">任务名称</th>
|
||||
<th style="padding: .65em;background: #666;border: 1px solid #777;color: #fff;">Bean名称</th>
|
||||
<th style="padding: .65em;background: #666;border: 1px solid #777;color: #fff;">执行方法</th>
|
||||
<th style="padding: .65em;background: #666;border: 1px solid #777;color: #fff;">参数内容</th>
|
||||
<th style="padding: .65em;background: #666;border: 1px solid #777;color: #fff;">Cron表达式</th>
|
||||
<th style="padding: .65em;background: #666;border: 1px solid #777;color: #fff;">描述内容</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding: .65em;border: 1px solid#777;">${task.jobName}</td>
|
||||
<td style="padding: .65em;border: 1px solid#777;">${task.beanName}</td>
|
||||
<td style="padding: .65em;border: 1px solid#777;">${task.methodName}</td>
|
||||
<td style="padding: .65em;border: 1px solid#777;">${(task.params)!""}</td>
|
||||
<td style="padding: .65em;border: 1px solid#777;">${task.cronExpression}</td>
|
||||
<td style="padding: .65em;border: 1px solid#777;">${(task.description)!""}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
<p style="margin-bottom: 10px;">异常信息:</p>
|
||||
<pre style="position: relative;
|
||||
padding: 15px;
|
||||
line-height: 20px;
|
||||
border-left: 5px solid #ddd;
|
||||
@@ -49,21 +49,21 @@
|
||||
font-size: 12px">
|
||||
${msg}
|
||||
</pre>
|
||||
</div>
|
||||
<div class="foot-hr hr" style="margin: 0 auto;
|
||||
</div>
|
||||
<div class="foot-hr hr" style="margin: 0 auto;
|
||||
z-index: 111;
|
||||
width: 800px;
|
||||
margin-top: 30px;
|
||||
border-top: 1px solid #DA251D;">
|
||||
</div>
|
||||
<div style="text-align: center;
|
||||
</div>
|
||||
<div style="text-align: center;
|
||||
font-size: 12px;
|
||||
padding: 20px 0px;
|
||||
font-family: Microsoft YaHei;">
|
||||
Copyright ©${.now?string("yyyy")} <a hover="color: #DA251D;" style="color: #999;"
|
||||
href="https://github.com/odboy-tianjun/cutejava" target="_blank">CuteJava</a>
|
||||
后台管理系统 All Rights Reserved.
|
||||
</div>
|
||||
Copyright ©${.now?string("yyyy")} <a hover="color: #DA251D;" style="color: #999;"
|
||||
href="https://github.com/odboy-tianjun/cutejava" target="_blank">CuteJava</a>
|
||||
后台管理系统 All Rights Reserved.
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user