feat: 项目初始化
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>cutejava</artifactId>
|
||||
<groupId>cn.odboy</groupId>
|
||||
<version>1.4.1</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>cutejava-module-system</artifactId>
|
||||
<name>核心模块</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.odboy</groupId>
|
||||
<artifactId>cutejava-framework</artifactId>
|
||||
<version>1.4.1</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/io.minio/minio -->
|
||||
<dependency>
|
||||
<groupId>io.minio</groupId>
|
||||
<artifactId>minio</artifactId>
|
||||
<version>8.5.17</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.constant;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 验证码业务场景
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum SystemCaptchaBizEnum {
|
||||
|
||||
/* 通过手机号码重置邮箱 */
|
||||
PHONE_RESET_EMAIL_CODE("10000", "phone_reset_email_code_", "SystemEmailCaptchaTemplate.ftl", "通过手机号码重置邮箱"),
|
||||
|
||||
/* 通过旧邮箱重置邮箱 */
|
||||
EMAIL_RESET_EMAIL_CODE("10001", "email_reset_email_code_", "SystemEmailCaptchaTemplate.ftl", "通过旧邮箱重置邮箱"),
|
||||
|
||||
/* 通过手机号码重置密码 */
|
||||
PHONE_RESET_PWD_CODE("10002", "phone_reset_pwd_code_", "SystemEmailCaptchaTemplate.ftl", "通过手机号码重置密码"),
|
||||
|
||||
/* 通过邮箱重置密码 */
|
||||
EMAIL_RESET_PWD_CODE("10003", "email_reset_pwd_code_", "SystemEmailCaptchaTemplate.ftl", "通过邮箱重置密码");
|
||||
|
||||
/**
|
||||
* 业务编码
|
||||
*/
|
||||
private final String bizCode;
|
||||
/**
|
||||
* redis中的key
|
||||
*/
|
||||
private final String redisKey;
|
||||
/**
|
||||
* resources文件夹,template中的模版名称
|
||||
*/
|
||||
private final String templateName;
|
||||
/**
|
||||
* 业务描述
|
||||
*/
|
||||
private final String description;
|
||||
|
||||
public static SystemCaptchaBizEnum getByBizCode(String bizCode) {
|
||||
for (SystemCaptchaBizEnum value : SystemCaptchaBizEnum.values()) {
|
||||
if (value.getBizCode().equals(bizCode)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.constant;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 数据权限枚举
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum SystemDataScopeEnum {
|
||||
|
||||
/* 全部的数据权限 */
|
||||
ALL("全部", "全部的数据权限"),
|
||||
|
||||
/* 自己部门的数据权限 */
|
||||
THIS_LEVEL("本级", "自己部门的数据权限"),
|
||||
|
||||
/* 自定义的数据权限 */
|
||||
CUSTOMIZE("自定义", "自定义的数据权限");
|
||||
|
||||
private final String value;
|
||||
private final String description;
|
||||
|
||||
public static SystemDataScopeEnum find(String val) {
|
||||
for (SystemDataScopeEnum dataScopeEnum : SystemDataScopeEnum.values()) {
|
||||
if (dataScopeEnum.getValue().equals(val)) {
|
||||
return dataScopeEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.constant;
|
||||
|
||||
public interface TransferProtocolConst {
|
||||
String PREFIX_HTTP = "http://";
|
||||
String PREFIX_HTTPS = "https://";
|
||||
String PREFIX_HTTPS_BAD_REQUEST = "外链必须以http://或者https://开头";
|
||||
}
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.odboy.annotation.AnonymousPostMapping;
|
||||
import cn.odboy.constant.CaptchaCodeEnum;
|
||||
import cn.odboy.constant.SystemConst;
|
||||
import cn.odboy.framework.exception.BadRequestException;
|
||||
import cn.odboy.framework.properties.AppProperties;
|
||||
import cn.odboy.framework.redis.CsRedisHelper;
|
||||
import cn.odboy.system.dal.model.SystemUserInfoVo;
|
||||
import cn.odboy.system.dal.model.SystemUserJwtVo;
|
||||
import cn.odboy.system.dal.model.SystemUserLoginArgs;
|
||||
import cn.odboy.system.dal.redis.SystemCacheKey;
|
||||
import cn.odboy.system.dal.redis.SystemUserOnlineInfoDAO;
|
||||
import cn.odboy.system.framework.permission.core.CsSecurityHelper;
|
||||
import cn.odboy.system.framework.permission.core.handler.TokenProvider;
|
||||
import cn.odboy.system.framework.permission.core.handler.UserDetailsHandler;
|
||||
import cn.odboy.util.CsRsaEncryptUtil;
|
||||
import cn.odboy.util.CsStringUtil;
|
||||
import com.wf.captcha.base.Captcha;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 授权、根据token获取用户详细信息
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/auth")
|
||||
@Api(tags = "系统:系统授权接口")
|
||||
public class SystemAuthController {
|
||||
@Autowired
|
||||
private CsRedisHelper redisHelper;
|
||||
@Autowired
|
||||
private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO;
|
||||
@Autowired
|
||||
private TokenProvider tokenProvider;
|
||||
@Autowired
|
||||
private AppProperties properties;
|
||||
@Autowired
|
||||
private PasswordEncoder passwordEncoder;
|
||||
@Autowired
|
||||
private UserDetailsHandler userDetailsService;
|
||||
|
||||
@ApiOperation("登录授权")
|
||||
@AnonymousPostMapping(value = "/login")
|
||||
public ResponseEntity<Map<String, Object>> login(@Validated @RequestBody SystemUserLoginArgs loginRequest, HttpServletRequest request) throws Exception {
|
||||
// 密码解密
|
||||
String password = CsRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), loginRequest.getPassword());
|
||||
// 查询验证码
|
||||
String code = redisHelper.get(loginRequest.getUuid(), String.class);
|
||||
// 清除验证码
|
||||
redisHelper.del(loginRequest.getUuid());
|
||||
if (StrUtil.isBlank(code)) {
|
||||
throw new BadRequestException("验证码不存在或已过期");
|
||||
}
|
||||
if (StrUtil.isBlank(loginRequest.getCode()) || !loginRequest.getCode().equalsIgnoreCase(code)) {
|
||||
throw new BadRequestException("验证码错误");
|
||||
}
|
||||
// 获取用户信息
|
||||
SystemUserJwtVo jwtUser = userDetailsService.loadUserByUsername(loginRequest.getUsername());
|
||||
// 验证用户密码
|
||||
if (!passwordEncoder.matches(password, jwtUser.getPassword())) {
|
||||
throw new BadRequestException("登录密码错误");
|
||||
}
|
||||
Authentication authentication = new UsernamePasswordAuthenticationToken(jwtUser, null, jwtUser.getAuthorities());
|
||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
// 生成令牌
|
||||
String token = tokenProvider.createToken(jwtUser);
|
||||
// 返回 token 与 用户信息
|
||||
Map<String, Object> authInfo = new HashMap<>(2) {{
|
||||
put("token", String.format("%s %s", SystemConst.TOKEN_PREFIX, token));
|
||||
put("user", BeanUtil.copyProperties(jwtUser, SystemUserInfoVo.class));
|
||||
}};
|
||||
if (properties.getLogin().isSingle()) {
|
||||
// 踢掉之前已经登录的token
|
||||
systemUserOnlineInfoDAO.kickOutByUsername(loginRequest.getUsername());
|
||||
}
|
||||
// 保存在线信息
|
||||
systemUserOnlineInfoDAO.saveUserJwtModelByToken(jwtUser, token, request);
|
||||
// 返回登录信息
|
||||
return ResponseEntity.ok(authInfo);
|
||||
}
|
||||
|
||||
@ApiOperation("获取用户信息")
|
||||
@PostMapping(value = "/info")
|
||||
public ResponseEntity<SystemUserInfoVo> getUserInfo() {
|
||||
SystemUserJwtVo jwtUser = (SystemUserJwtVo) CsSecurityHelper.getCurrentUser();
|
||||
SystemUserInfoVo userInfoVo = BeanUtil.copyProperties(jwtUser, SystemUserInfoVo.class);
|
||||
return ResponseEntity.ok(userInfoVo);
|
||||
}
|
||||
|
||||
@ApiOperation("获取验证码")
|
||||
@AnonymousPostMapping(value = "/captcha/getImage")
|
||||
public ResponseEntity<Map<String, Object>> getCode() {
|
||||
// 获取运算的结果
|
||||
Captcha captcha = properties.getLogin().getCaptchaSetting().getCaptcha();
|
||||
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)) {
|
||||
captchaValue = captchaValue.split("\\.")[0];
|
||||
}
|
||||
// 保存
|
||||
redisHelper.set(uuid, captchaValue, properties.getLogin().getCaptchaSetting().getExpiration(), TimeUnit.MINUTES);
|
||||
// 验证码信息
|
||||
Map<String, Object> imgResult = new HashMap<String, Object>(2) {{
|
||||
put("img", captcha.toBase64());
|
||||
put("uuid", uuid);
|
||||
}};
|
||||
return ResponseEntity.ok(imgResult);
|
||||
}
|
||||
|
||||
@ApiOperation("退出登录")
|
||||
@AnonymousPostMapping(value = "/logout")
|
||||
public ResponseEntity<Void> logout(HttpServletRequest request) {
|
||||
String token = tokenProvider.getToken(request);
|
||||
systemUserOnlineInfoDAO.logoutByToken(token);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.controller;
|
||||
|
||||
import cn.odboy.system.constant.SystemCaptchaBizEnum;
|
||||
import cn.odboy.system.dal.model.SystemCheckEmailCaptchaArgs;
|
||||
import cn.odboy.system.service.SystemEmailService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/captcha")
|
||||
@Api(tags = "系统:验证码管理")
|
||||
public class SystemCaptchaController {
|
||||
@Autowired
|
||||
private SystemEmailService systemEmailService;
|
||||
|
||||
@ApiOperation("重置邮箱, 发送验证码")
|
||||
@PostMapping(value = "/sendResetEmailCaptcha")
|
||||
public ResponseEntity<Void> sendResetEmailCaptcha(@RequestParam String email) {
|
||||
systemEmailService.sendCaptcha(SystemCaptchaBizEnum.EMAIL_RESET_EMAIL_CODE, email);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("重置密码,发送验证码")
|
||||
@PostMapping(value = "/sendResetPasswordCaptcha")
|
||||
public ResponseEntity<Void> sendResetPasswordCaptcha(@RequestParam String email) {
|
||||
systemEmailService.sendCaptcha(SystemCaptchaBizEnum.EMAIL_RESET_PWD_CODE, email);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("验证码验证")
|
||||
@PostMapping(value = "/checkEmailCaptcha")
|
||||
public ResponseEntity<Void> checkEmailCaptcha(@Validated @RequestBody SystemCheckEmailCaptchaArgs args) {
|
||||
SystemCaptchaBizEnum biEnum = SystemCaptchaBizEnum.getByBizCode(args.getBizCode());
|
||||
systemEmailService.checkEmailCaptcha(biEnum, args.getEmail(), args.getCode());
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.controller;
|
||||
|
||||
import cn.odboy.system.service.SystemDeptService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@Api(tags = "系统:组件数据源")
|
||||
@RequestMapping("/api/component")
|
||||
public class SystemComponentController {
|
||||
@Autowired
|
||||
private SystemDeptService systemDeptService;
|
||||
|
||||
@ApiOperation("查询部门下拉选择数据源")
|
||||
@PostMapping(value = "/queryDeptSelectDataSource")
|
||||
@PreAuthorize("@el.check()")
|
||||
public ResponseEntity<?> queryDeptSelectDataSource() {
|
||||
return ResponseEntity.ok(systemDeptService.queryDeptSelectDataSource());
|
||||
}
|
||||
|
||||
@ApiOperation("查询部门下拉选择Pro数据源")
|
||||
@PostMapping(value = "/queryDeptSelectProDataSource")
|
||||
@PreAuthorize("@el.check()")
|
||||
public ResponseEntity<?> queryDeptSelectProDataSource() {
|
||||
return ResponseEntity.ok(systemDeptService.queryDeptSelectProDataSource());
|
||||
}
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.controller;
|
||||
|
||||
import cn.odboy.base.CsPageArgs;
|
||||
import cn.odboy.base.CsPageResult;
|
||||
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||
import cn.odboy.system.dal.model.SystemCreateDeptArgs;
|
||||
import cn.odboy.system.dal.model.SystemQueryDeptArgs;
|
||||
import cn.odboy.system.service.SystemDeptService;
|
||||
import cn.odboy.util.CsPageUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
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 javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@Api(tags = "系统:部门管理")
|
||||
@RequestMapping("/api/dept")
|
||||
public class SystemDeptController {
|
||||
@Autowired
|
||||
private SystemDeptService systemDeptService;
|
||||
|
||||
@ApiOperation("导出部门数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('dept:list')")
|
||||
public void exportDept(HttpServletResponse response, SystemQueryDeptArgs criteria) throws Exception {
|
||||
systemDeptService.exportDeptExcel(systemDeptService.queryAllDept(criteria, false), response);
|
||||
}
|
||||
|
||||
@ApiOperation("查询部门")
|
||||
@PostMapping
|
||||
@PreAuthorize("@el.check('user:list','dept:list')")
|
||||
public ResponseEntity<CsPageResult<SystemDeptTb>> queryDept(@Validated @RequestBody CsPageArgs<SystemQueryDeptArgs> args) throws Exception {
|
||||
SystemQueryDeptArgs criteria = args.getArgs();
|
||||
List<SystemDeptTb> depts = systemDeptService.queryAllDept(criteria, true);
|
||||
return ResponseEntity.ok(CsPageUtil.toPage(depts));
|
||||
}
|
||||
|
||||
@ApiOperation("查询部门:根据ID获取同级与上级数据")
|
||||
@PostMapping("/queryDeptSuperiorTree")
|
||||
@PreAuthorize("@el.check('user:list','dept:list')")
|
||||
public ResponseEntity<CsPageResult<SystemDeptTb>> queryDeptSuperiorTree(@RequestBody List<Long> ids, @RequestParam(defaultValue = "false") Boolean exclude) {
|
||||
Set<SystemDeptTb> deptSet = new LinkedHashSet<>();
|
||||
for (Long id : ids) {
|
||||
// 同级数据
|
||||
SystemDeptTb dept = systemDeptService.queryDeptById(id);
|
||||
// 上级数据
|
||||
List<SystemDeptTb> depts = systemDeptService.querySuperiorDeptListByPid(dept, new ArrayList<>());
|
||||
if (exclude) {
|
||||
for (SystemDeptTb data : depts) {
|
||||
if (data.getId().equals(dept.getPid())) {
|
||||
data.setSubCount(data.getSubCount() - 1);
|
||||
}
|
||||
}
|
||||
// 编辑部门时不显示自己以及自己下级的数据, 避免出现PID数据环形问题
|
||||
depts = depts.stream().filter(i -> !ids.contains(i.getId())).collect(Collectors.toList());
|
||||
}
|
||||
deptSet.addAll(depts);
|
||||
}
|
||||
return ResponseEntity.ok(systemDeptService.buildDeptTree(new ArrayList<>(deptSet)));
|
||||
}
|
||||
|
||||
@ApiOperation("新增部门")
|
||||
@PostMapping(value = "/saveDept")
|
||||
@PreAuthorize("@el.check('dept:add')")
|
||||
public ResponseEntity<Void> saveDept(@Validated @RequestBody SystemCreateDeptArgs args) {
|
||||
systemDeptService.saveDept(args);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("修改部门")
|
||||
@PostMapping(value = "/modifyDept")
|
||||
@PreAuthorize("@el.check('dept:edit')")
|
||||
public ResponseEntity<Void> modifyDept(@Validated(SystemDeptTb.Update.class) @RequestBody SystemDeptTb args) {
|
||||
systemDeptService.modifyDept(args);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("删除部门")
|
||||
@PostMapping(value = "/removeDeptByIds")
|
||||
@PreAuthorize("@el.check('dept:del')")
|
||||
public ResponseEntity<Void> removeDeptByIds(@RequestBody Set<Long> ids) {
|
||||
// 获取部门, 和其所有子部门
|
||||
Set<SystemDeptTb> depts = systemDeptService.traverseDeptByIdWithPids(ids);
|
||||
// 验证是否被角色或用户关联
|
||||
systemDeptService.verifyBindRelationByIds(depts);
|
||||
systemDeptService.removeDeptByIds(depts);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
}
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.controller;
|
||||
|
||||
import cn.odboy.base.CsPageArgs;
|
||||
import cn.odboy.base.CsPageResult;
|
||||
import cn.odboy.system.dal.dataobject.SystemDictTb;
|
||||
import cn.odboy.system.dal.model.SystemCreateDictArgs;
|
||||
import cn.odboy.system.dal.model.SystemQueryDictArgs;
|
||||
import cn.odboy.system.service.SystemDictService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
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 javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@RestController
|
||||
@Api(tags = "系统:字典管理")
|
||||
@RequestMapping("/api/dict")
|
||||
public class SystemDictController {
|
||||
@Autowired
|
||||
private SystemDictService systemDictService;
|
||||
|
||||
@ApiOperation("导出字典数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('dict:list')")
|
||||
public void exportDict(HttpServletResponse response, SystemQueryDictArgs criteria) throws IOException {
|
||||
systemDictService.exportDictExcel(systemDictService.queryDictByArgs(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("查询字典")
|
||||
@PostMapping(value = "/queryAllDict")
|
||||
@PreAuthorize("@el.check('dict:list')")
|
||||
public ResponseEntity<List<SystemDictTb>> queryAllDict() {
|
||||
return ResponseEntity.ok(systemDictService.queryDictByArgs(new SystemQueryDictArgs()));
|
||||
}
|
||||
|
||||
@ApiOperation("查询字典")
|
||||
@PostMapping
|
||||
@PreAuthorize("@el.check('dict:list')")
|
||||
public ResponseEntity<CsPageResult<SystemDictTb>> queryDictByArgs(@Validated @RequestBody CsPageArgs<SystemQueryDictArgs> args) {
|
||||
Page<SystemDictTb> page;
|
||||
SystemQueryDictArgs criteria = args.getArgs();
|
||||
if (args.getSize() != null) {
|
||||
page = new Page<>(args.getPage(), args.getSize());
|
||||
} else {
|
||||
page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
}
|
||||
return ResponseEntity.ok(systemDictService.queryDictByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@ApiOperation("新增字典")
|
||||
@PostMapping(value = "/saveDict")
|
||||
@PreAuthorize("@el.check('dict:add')")
|
||||
public ResponseEntity<Void> saveDict(@Validated @RequestBody SystemCreateDictArgs args) {
|
||||
systemDictService.saveDict(args);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("修改字典")
|
||||
@PostMapping(value = "/modifyDictById")
|
||||
@PreAuthorize("@el.check('dict:edit')")
|
||||
public ResponseEntity<Void> modifyDictById(@Validated(SystemDictTb.Update.class) @RequestBody SystemDictTb args) {
|
||||
systemDictService.modifyDictById(args);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("删除字典")
|
||||
@PostMapping(value = "/removeDictByIds")
|
||||
@PreAuthorize("@el.check('dict:del')")
|
||||
public ResponseEntity<Void> removeDictByIds(@RequestBody Set<Long> ids) {
|
||||
systemDictService.removeDictByIds(ids);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
}
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.controller;
|
||||
|
||||
import cn.odboy.base.CsPageArgs;
|
||||
import cn.odboy.base.CsPageResult;
|
||||
import cn.odboy.system.dal.dataobject.SystemDictDetailTb;
|
||||
import cn.odboy.system.dal.model.SystemCreateDictDetailArgs;
|
||||
import cn.odboy.system.dal.model.SystemQueryDictDetailArgs;
|
||||
import cn.odboy.system.service.SystemDictDetailService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@Api(tags = "系统:字典详情管理")
|
||||
@RequestMapping("/api/dictDetail")
|
||||
public class SystemDictDetailController {
|
||||
@Autowired
|
||||
private SystemDictDetailService systemDictDetailService;
|
||||
|
||||
@ApiOperation("查询字典详情")
|
||||
@PostMapping
|
||||
public ResponseEntity<CsPageResult<SystemDictDetailTb>> queryDictDetailByCrud(@Validated @RequestBody CsPageArgs<SystemQueryDictDetailArgs> args) {
|
||||
return queryDictDetailByArgs(args);
|
||||
}
|
||||
|
||||
@ApiOperation("查询字典详情")
|
||||
@PostMapping(value = "/queryDictDetailByArgs")
|
||||
public ResponseEntity<CsPageResult<SystemDictDetailTb>> queryDictDetailByArgs(@Validated @RequestBody CsPageArgs<SystemQueryDictDetailArgs> args) {
|
||||
SystemQueryDictDetailArgs criteria = args.getArgs();
|
||||
Page<Object> page = new Page<>(args.getPage(), args.getSize());
|
||||
return ResponseEntity.ok(systemDictDetailService.queryDictDetailByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@ApiOperation("查询多个字典详情")
|
||||
@GetMapping(value = "/getDictDetailMaps")
|
||||
public ResponseEntity<Map<String, List<SystemDictDetailTb>>> getDictDetailMaps(@RequestParam String dictName) {
|
||||
String[] names = dictName.split("[,, ]");
|
||||
Map<String, List<SystemDictDetailTb>> dictMap = new HashMap<>(16);
|
||||
for (String name : names) {
|
||||
dictMap.put(name, systemDictDetailService.queryDictDetailByName(name));
|
||||
}
|
||||
return ResponseEntity.ok(dictMap);
|
||||
}
|
||||
|
||||
@ApiOperation("新增字典详情")
|
||||
@PostMapping(value = "/saveDictDetail")
|
||||
@PreAuthorize("@el.check('dict:add')")
|
||||
public ResponseEntity<Void> saveDictDetail(@Validated @RequestBody SystemCreateDictDetailArgs args) {
|
||||
systemDictDetailService.saveDictDetail(args);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("修改字典详情")
|
||||
@PostMapping(value = "/modifyDictDetailById")
|
||||
@PreAuthorize("@el.check('dict:edit')")
|
||||
public ResponseEntity<Void> modifyDictDetailById(@Validated(SystemDictDetailTb.Update.class) @RequestBody SystemDictDetailTb args) {
|
||||
systemDictDetailService.modifyDictDetailById(args);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("删除字典详情")
|
||||
@PostMapping(value = "/removeDictDetailById")
|
||||
@PreAuthorize("@el.check('dict:del')")
|
||||
public ResponseEntity<Void> removeDictDetailById(@RequestBody SystemDictDetailTb args) {
|
||||
systemDictDetailService.removeDictDetailById(args.getId());
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.controller;
|
||||
|
||||
import cn.odboy.system.dal.dataobject.SystemEmailConfigTb;
|
||||
import cn.odboy.system.dal.model.SystemSendEmailArgs;
|
||||
import cn.odboy.system.service.SystemEmailService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 发送邮件
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("api/email")
|
||||
@Api(tags = "工具:邮件管理")
|
||||
public class SystemEmailController {
|
||||
@Autowired
|
||||
private SystemEmailService systemEmailService;
|
||||
|
||||
@ApiOperation("查询配置")
|
||||
@PostMapping(value = "/getLastEmailConfig")
|
||||
public ResponseEntity<SystemEmailConfigTb> getLastEmailConfig() {
|
||||
return ResponseEntity.ok(systemEmailService.getLastEmailConfig());
|
||||
}
|
||||
|
||||
@ApiOperation("配置邮件")
|
||||
@PostMapping(value = "/modifyEmailConfig")
|
||||
public ResponseEntity<Void> modifyEmailConfig(@Validated @RequestBody SystemEmailConfigTb emailConfig)
|
||||
throws Exception {
|
||||
systemEmailService.modifyEmailConfig(emailConfig);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("发送邮件")
|
||||
@PostMapping(value = "/sendEmail")
|
||||
public ResponseEntity<Void> sendEmail(@Validated @RequestBody SystemSendEmailArgs sendEmailRequest) {
|
||||
systemEmailService.sendEmail(sendEmailRequest);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.controller;
|
||||
|
||||
import cn.odboy.base.CsPageArgs;
|
||||
import cn.odboy.base.CsPageResult;
|
||||
import cn.odboy.system.dal.dataobject.SystemJobTb;
|
||||
import cn.odboy.system.dal.model.SystemCreateJobArgs;
|
||||
import cn.odboy.system.dal.model.SystemQueryJobArgs;
|
||||
import cn.odboy.system.service.SystemJobService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
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 javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
@RestController
|
||||
@Api(tags = "系统:岗位管理")
|
||||
@RequestMapping("/api/job")
|
||||
public class SystemJobController {
|
||||
@Autowired
|
||||
private SystemJobService systemJobService;
|
||||
|
||||
@ApiOperation("导出岗位数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('job:list')")
|
||||
public void exportJob(HttpServletResponse response, SystemQueryJobArgs criteria) throws IOException {
|
||||
systemJobService.exportJobExcel(systemJobService.queryJobByArgs(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("查询岗位")
|
||||
@PostMapping(value = "/queryAllEnableJob")
|
||||
@PreAuthorize("@el.check('job:list','user:list')")
|
||||
public ResponseEntity<CsPageResult<SystemJobTb>> queryJobByArgs(@Validated @RequestBody CsPageArgs<SystemQueryJobArgs> args) {
|
||||
SystemQueryJobArgs criteria = args.getArgs();
|
||||
Page<SystemJobTb> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return ResponseEntity.ok(systemJobService.queryJobByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@ApiOperation("查询岗位")
|
||||
@PostMapping
|
||||
@PreAuthorize("@el.check('job:list','user:list')")
|
||||
public ResponseEntity<CsPageResult<SystemJobTb>> queryJobByCrud(@Validated @RequestBody CsPageArgs<SystemQueryJobArgs> args) {
|
||||
return queryJobByArgs(args);
|
||||
}
|
||||
|
||||
@ApiOperation("新增岗位")
|
||||
@PostMapping(value = "/saveJob")
|
||||
@PreAuthorize("@el.check('job:add')")
|
||||
public ResponseEntity<Void> saveJob(@Validated @RequestBody SystemCreateJobArgs args) {
|
||||
systemJobService.saveJob(args);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("修改岗位")
|
||||
@PostMapping(value = "/modifyJobById")
|
||||
@PreAuthorize("@el.check('job:edit')")
|
||||
public ResponseEntity<Void> modifyJobById(@Validated(SystemJobTb.Update.class) @RequestBody SystemJobTb args) {
|
||||
systemJobService.modifyJobById(args);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("删除岗位")
|
||||
@PostMapping(value = "/removeJobByIds")
|
||||
@PreAuthorize("@el.check('job:del')")
|
||||
public ResponseEntity<Void> removeJobByIds(@RequestBody Set<Long> ids) {
|
||||
// 验证是否被用户关联
|
||||
systemJobService.verifyBindRelationByIds(ids);
|
||||
systemJobService.removeJobByIds(ids);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.controller;
|
||||
|
||||
import cn.odboy.base.CsPageArgs;
|
||||
import cn.odboy.base.CsPageResult;
|
||||
import cn.odboy.constant.FileTypeEnum;
|
||||
import cn.odboy.framework.exception.BadRequestException;
|
||||
import cn.odboy.system.dal.dataobject.SystemLocalStorageTb;
|
||||
import cn.odboy.system.dal.model.SystemQueryStorageArgs;
|
||||
import cn.odboy.system.service.SystemLocalStorageService;
|
||||
import cn.odboy.util.CsFileUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
@RestController
|
||||
@Api(tags = "工具:本地存储管理")
|
||||
@RequestMapping("/api/localStorage")
|
||||
public class SystemLocalStorageController {
|
||||
@Autowired
|
||||
private SystemLocalStorageService localStorageService;
|
||||
|
||||
@ApiOperation("查询文件")
|
||||
@PostMapping
|
||||
@PreAuthorize("@el.check('storage:list')")
|
||||
public ResponseEntity<CsPageResult<SystemLocalStorageTb>> queryLocalStorage(@Validated @RequestBody CsPageArgs<SystemQueryStorageArgs> args) {
|
||||
SystemQueryStorageArgs criteria = args.getArgs();
|
||||
Page<SystemLocalStorageTb> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return ResponseEntity.ok(localStorageService.queryLocalStorage(criteria, page));
|
||||
}
|
||||
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('storage:list')")
|
||||
public void exportFile(HttpServletResponse response, SystemQueryStorageArgs criteria) throws IOException {
|
||||
localStorageService.exportLocalStorageExcel(localStorageService.queryLocalStorage(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("上传文件")
|
||||
@PostMapping(value = "/uploadFile")
|
||||
@PreAuthorize("@el.check('storage:add')")
|
||||
public ResponseEntity<Void> uploadFile(@RequestParam String name, @RequestParam("file") MultipartFile file) {
|
||||
localStorageService.uploadFile(name, file);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("上传图片")
|
||||
@PostMapping("/uploadPicture")
|
||||
public ResponseEntity<SystemLocalStorageTb> uploadPicture(@RequestParam MultipartFile file) {
|
||||
// 判断文件是否为图片
|
||||
String suffix = CsFileUtil.getSuffix(file.getOriginalFilename());
|
||||
if (!FileTypeEnum.IMAGE.getCode().equals(CsFileUtil.getFileType(suffix))) {
|
||||
throw new BadRequestException("只能上传图片");
|
||||
}
|
||||
SystemLocalStorageTb localStorage = localStorageService.uploadFile(null, file);
|
||||
return ResponseEntity.ok(localStorage);
|
||||
}
|
||||
|
||||
@ApiOperation("修改文件")
|
||||
@PostMapping(value = "/modifyLocalStorageById")
|
||||
@PreAuthorize("@el.check('storage:edit')")
|
||||
public ResponseEntity<Void> modifyLocalStorageById(@Validated @RequestBody SystemLocalStorageTb args) {
|
||||
localStorageService.modifyLocalStorageById(args);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("多选删除")
|
||||
@PostMapping(value = "/removeFileByIds")
|
||||
public ResponseEntity<Void> deleteFileByIds(@RequestBody Long[] ids) {
|
||||
localStorageService.removeFileByIds(ids);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
}
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.odboy.base.CsPageArgs;
|
||||
import cn.odboy.base.CsPageResult;
|
||||
import cn.odboy.framework.exception.BadRequestException;
|
||||
import cn.odboy.system.dal.dataobject.SystemMenuTb;
|
||||
import cn.odboy.system.dal.model.SystemMenuVo;
|
||||
import cn.odboy.system.dal.model.SystemQueryMenuArgs;
|
||||
import cn.odboy.system.dal.mysql.SystemMenuMapper;
|
||||
import cn.odboy.system.framework.permission.core.CsSecurityHelper;
|
||||
import cn.odboy.system.service.SystemMenuService;
|
||||
import cn.odboy.util.CsPageUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@Api(tags = "系统:菜单管理")
|
||||
@RequestMapping("/api/menu")
|
||||
public class SystemMenuController {
|
||||
@Autowired
|
||||
private SystemMenuService systemMenuService;
|
||||
@Autowired
|
||||
private SystemMenuMapper systemMenuMapper;
|
||||
|
||||
@ApiOperation("导出菜单数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('menu:list')")
|
||||
public void exportMenu(HttpServletResponse response, SystemQueryMenuArgs criteria) throws Exception {
|
||||
systemMenuService.exportMenuExcel(systemMenuService.queryAllMenu(criteria, false), response);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/buildMenus")
|
||||
@ApiOperation("获取前端所需菜单")
|
||||
public ResponseEntity<List<SystemMenuVo>> buildMenus() {
|
||||
List<SystemMenuTb> menuList = systemMenuService.queryMenuListByUserId(CsSecurityHelper.getCurrentUserId());
|
||||
List<SystemMenuTb> menus = systemMenuService.buildMenuTree(menuList);
|
||||
return ResponseEntity.ok(systemMenuService.buildMenuVo(menus));
|
||||
}
|
||||
|
||||
@ApiOperation("返回全部的菜单")
|
||||
@PostMapping(value = "/queryMenuListByPid")
|
||||
@PreAuthorize("@el.check('menu:list','roles:list')")
|
||||
public ResponseEntity<List<SystemMenuTb>> queryMenuListByPid(@RequestParam Long pid) {
|
||||
return ResponseEntity.ok(systemMenuService.queryMenuByPid(pid));
|
||||
}
|
||||
|
||||
@ApiOperation("根据菜单ID返回所有子节点ID, 包含自身ID")
|
||||
@PostMapping(value = "/queryChildMenuSet")
|
||||
@PreAuthorize("@el.check('menu:list','roles:list')")
|
||||
public ResponseEntity<Set<Long>> queryChildMenuSet(@RequestParam Long id) {
|
||||
Set<SystemMenuTb> menuSet = new HashSet<>();
|
||||
List<SystemMenuTb> menuList = systemMenuService.queryMenuByPid(id);
|
||||
menuSet.add(systemMenuMapper.selectById(id));
|
||||
menuSet = systemMenuService.queryChildMenu(menuList, menuSet);
|
||||
Set<Long> ids = menuSet.stream().map(SystemMenuTb::getId).collect(Collectors.toSet());
|
||||
return ResponseEntity.ok(ids);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation("查询菜单")
|
||||
@PreAuthorize("@el.check('menu:list')")
|
||||
public ResponseEntity<CsPageResult<SystemMenuTb>> queryAllMenuByCrud(@Validated @RequestBody CsPageArgs<SystemQueryMenuArgs> args) throws Exception {
|
||||
return queryAllMenu(args);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/queryMenuByArgs")
|
||||
@ApiOperation("查询菜单")
|
||||
@PreAuthorize("@el.check('menu:list')")
|
||||
public ResponseEntity<CsPageResult<SystemMenuTb>> queryAllMenu(@Validated @RequestBody CsPageArgs<SystemQueryMenuArgs> args) throws Exception {
|
||||
SystemQueryMenuArgs criteria = args.getArgs();
|
||||
List<SystemMenuTb> menuList = systemMenuService.queryAllMenu(criteria, true);
|
||||
return ResponseEntity.ok(CsPageUtil.toPage(menuList));
|
||||
}
|
||||
|
||||
@ApiOperation("查询菜单:根据ID获取同级与上级数据")
|
||||
@PostMapping("/queryMenuSuperior")
|
||||
@PreAuthorize("@el.check('menu:list')")
|
||||
public ResponseEntity<List<SystemMenuTb>> queryMenuSuperior(@RequestBody List<Long> ids) {
|
||||
Set<SystemMenuTb> menus;
|
||||
if (CollectionUtil.isNotEmpty(ids)) {
|
||||
menus = new LinkedHashSet<>(systemMenuService.queryMenuByIds(ids));
|
||||
for (SystemMenuTb menu : menus) {
|
||||
List<SystemMenuTb> menuList = systemMenuService.querySuperiorMenuList(menu, new ArrayList<>());
|
||||
for (SystemMenuTb data : menuList) {
|
||||
if (data.getId().equals(menu.getPid())) {
|
||||
data.setSubCount(data.getSubCount() - 1);
|
||||
}
|
||||
}
|
||||
menus.addAll(menuList);
|
||||
}
|
||||
// 编辑菜单时不显示自己以及自己下级的数据, 避免出现PID数据环形问题
|
||||
menus = menus.stream().filter(i -> !ids.contains(i.getId())).collect(Collectors.toSet());
|
||||
return ResponseEntity.ok(systemMenuService.buildMenuTree(new ArrayList<>(menus)));
|
||||
}
|
||||
return ResponseEntity.ok(systemMenuService.queryMenuByPid(null));
|
||||
}
|
||||
|
||||
@ApiOperation("新增菜单")
|
||||
@PostMapping(value = "/saveMenu")
|
||||
@PreAuthorize("@el.check('menu:add')")
|
||||
public ResponseEntity<Void> saveMenu(@Validated @RequestBody SystemMenuTb args) {
|
||||
if (args.getId() != null) {
|
||||
throw new BadRequestException("无效参数id");
|
||||
}
|
||||
systemMenuService.saveMenu(args);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("修改菜单")
|
||||
@PostMapping(value = "/modifyMenuById")
|
||||
@PreAuthorize("@el.check('menu:edit')")
|
||||
public ResponseEntity<Void> modifyMenuById(@Validated(SystemMenuTb.Update.class) @RequestBody SystemMenuTb args) {
|
||||
systemMenuService.modifyMenuById(args);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("删除菜单")
|
||||
@PostMapping(value = "/removeMenuByIds")
|
||||
@PreAuthorize("@el.check('menu:del')")
|
||||
public ResponseEntity<Void> removeMenuByIds(@RequestBody Set<Long> ids) {
|
||||
systemMenuService.removeMenuByIds(ids);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.controller;
|
||||
|
||||
import cn.odboy.system.service.SystemMonitorService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@Api(tags = "系统-服务监控管理")
|
||||
@RequestMapping("/api/monitor")
|
||||
public class SystemMonitorController {
|
||||
@Autowired
|
||||
private SystemMonitorService systemMonitorService;
|
||||
|
||||
@PostMapping(value = "/queryServerMonitorInfo")
|
||||
@ApiOperation("查询服务监控")
|
||||
@PreAuthorize("@el.check('monitor:list')")
|
||||
public ResponseEntity<Map<String, Object>> queryServerMonitorInfo() {
|
||||
return ResponseEntity.ok(systemMonitorService.queryServerMonitorInfo());
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.controller;
|
||||
|
||||
import cn.odboy.base.CsPageArgs;
|
||||
import cn.odboy.base.CsPageResult;
|
||||
import cn.odboy.system.dal.model.SystemUserOnlineVo;
|
||||
import cn.odboy.system.dal.redis.SystemUserOnlineInfoDAO;
|
||||
import cn.odboy.util.CsDesEncryptUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/user/online")
|
||||
@Api(tags = "系统:在线用户管理")
|
||||
public class SystemOnlineController {
|
||||
@Autowired
|
||||
private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO;
|
||||
|
||||
@ApiOperation("查询在线用户")
|
||||
@PostMapping
|
||||
@PreAuthorize("@el.check()")
|
||||
public ResponseEntity<CsPageResult<SystemUserOnlineVo>> queryOnlineUser(@Validated @RequestBody CsPageArgs<SystemUserOnlineVo> args) {
|
||||
IPage<SystemUserOnlineVo> page = new Page<>(args.getPage(), args.getSize());
|
||||
return ResponseEntity.ok(systemUserOnlineInfoDAO.queryUserOnlineModelPage(args.getArgs(), page));
|
||||
}
|
||||
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check()")
|
||||
public void exportOnlineUser(HttpServletResponse response, String username) throws IOException {
|
||||
systemUserOnlineInfoDAO.downloadUserOnlineModelExcel(systemUserOnlineInfoDAO.queryUserOnlineModelListByUsername(username), response);
|
||||
}
|
||||
|
||||
@ApiOperation("踢出用户")
|
||||
@PostMapping(value = "/kickOutUser")
|
||||
@PreAuthorize("@el.check()")
|
||||
public ResponseEntity<Void> kickOutUser(@RequestBody Set<String> keys) throws Exception {
|
||||
for (String token : keys) {
|
||||
// 解密Key
|
||||
token = CsDesEncryptUtil.desDecrypt(token);
|
||||
systemUserOnlineInfoDAO.logoutByToken(token);
|
||||
}
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.controller;
|
||||
|
||||
import cn.odboy.base.CsPageArgs;
|
||||
import cn.odboy.base.CsPageResult;
|
||||
import cn.odboy.system.dal.dataobject.SystemOssStorageTb;
|
||||
import cn.odboy.system.dal.model.SystemOssStorageVo;
|
||||
import cn.odboy.system.dal.model.SystemQueryStorageArgs;
|
||||
import cn.odboy.system.service.SystemOssStorageService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
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.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Api(tags = "工具:OSS存储管理")
|
||||
@RequestMapping("/api/ossStorage")
|
||||
public class SystemOssStorageController {
|
||||
@Autowired
|
||||
private SystemOssStorageService systemOssStorageService;
|
||||
|
||||
@ApiOperation("查询文件")
|
||||
@PostMapping
|
||||
@PreAuthorize("@el.check('storage:list')")
|
||||
public ResponseEntity<CsPageResult<SystemOssStorageVo>> queryOssStorage(@Validated @RequestBody CsPageArgs<SystemQueryStorageArgs> args) {
|
||||
SystemQueryStorageArgs criteria = args.getArgs();
|
||||
Page<SystemOssStorageTb> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return ResponseEntity.ok(systemOssStorageService.queryOssStorage(criteria, page));
|
||||
}
|
||||
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('storage:list')")
|
||||
public void exportFile(HttpServletResponse response, SystemQueryStorageArgs criteria) throws IOException {
|
||||
systemOssStorageService.exportOssStorageExcel(systemOssStorageService.queryOssStorage(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("上传文件")
|
||||
@PostMapping(value = "/uploadFile")
|
||||
@PreAuthorize("@el.check('storage:add')")
|
||||
public ResponseEntity<String> uploadFile(@RequestParam("file") MultipartFile file) {
|
||||
String fileUrl = systemOssStorageService.uploadFile(file);
|
||||
return ResponseEntity.ok(fileUrl);
|
||||
}
|
||||
|
||||
@ApiOperation("多选删除")
|
||||
@PostMapping(value = "/removeFileByIds")
|
||||
public ResponseEntity<Void> removeFileByIds(@RequestBody Long[] ids) {
|
||||
systemOssStorageService.removeFileByIds(ids);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.controller;
|
||||
|
||||
import cn.odboy.base.CsPageArgs;
|
||||
import cn.odboy.base.CsPageResult;
|
||||
import cn.odboy.framework.context.CsSpringBeanHolder;
|
||||
import cn.odboy.framework.exception.BadRequestException;
|
||||
import cn.odboy.system.dal.dataobject.SystemQuartzJobTb;
|
||||
import cn.odboy.system.dal.dataobject.SystemQuartzLogTb;
|
||||
import cn.odboy.system.dal.model.SystemQueryQuartzJobArgs;
|
||||
import cn.odboy.system.dal.model.SystemUpdateQuartzJobArgs;
|
||||
import cn.odboy.system.service.SystemQuartzJobService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
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 javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/quartzJob")
|
||||
@Api(tags = "系统:定时任务管理")
|
||||
public class SystemQuartzJobController {
|
||||
@Autowired
|
||||
private SystemQuartzJobService systemQuartzJobService;
|
||||
|
||||
@ApiOperation("查询定时任务")
|
||||
@PostMapping
|
||||
@PreAuthorize("@el.check('quartzJob:list')")
|
||||
public ResponseEntity<CsPageResult<SystemQuartzJobTb>> queryQuartzJobByCrud(@Validated @RequestBody CsPageArgs<SystemQueryQuartzJobArgs> args) {
|
||||
SystemQueryQuartzJobArgs criteria = args.getArgs();
|
||||
Page<SystemQuartzJobTb> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return ResponseEntity.ok(systemQuartzJobService.queryQuartzJobByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@ApiOperation("导出任务数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('quartzJob:list')")
|
||||
public void exportQuartzJob(HttpServletResponse response, SystemQueryQuartzJobArgs criteria) throws IOException {
|
||||
systemQuartzJobService.exportQuartzJobExcel(systemQuartzJobService.queryQuartzJobByArgs(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("导出日志数据")
|
||||
@GetMapping(value = "/logs/download")
|
||||
@PreAuthorize("@el.check('quartzJob:list')")
|
||||
public void exportQuartzJobLog(HttpServletResponse response, SystemQueryQuartzJobArgs criteria) throws IOException {
|
||||
systemQuartzJobService.exportQuartzLogExcel(systemQuartzJobService.queryQuartzLogByArgs(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("查询任务执行日志")
|
||||
@PostMapping(value = "/logs")
|
||||
@PreAuthorize("@el.check('quartzJob:list')")
|
||||
public ResponseEntity<CsPageResult<SystemQuartzLogTb>> queryQuartzJobLog(SystemQueryQuartzJobArgs args) {
|
||||
Page<SystemQuartzLogTb> page = new Page<>(args.getPage(), args.getSize());
|
||||
return ResponseEntity.ok(systemQuartzJobService.queryQuartzLogByArgs(args, page));
|
||||
}
|
||||
|
||||
@ApiOperation("新增定时任务")
|
||||
@PostMapping(value = "/createQuartzJob")
|
||||
@PreAuthorize("@el.check('quartzJob:add')")
|
||||
public ResponseEntity<Void> createQuartzJob(@Validated @RequestBody SystemQuartzJobTb args) {
|
||||
if (args.getId() != null) {
|
||||
throw new BadRequestException("无效参数id");
|
||||
}
|
||||
// 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义
|
||||
checkBean(args.getBeanName());
|
||||
systemQuartzJobService.createJob(args);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("修改定时任务")
|
||||
@PutMapping
|
||||
@PreAuthorize("@el.check('quartzJob:edit')")
|
||||
public ResponseEntity<Void> updateQuartzJob(@Validated(SystemQuartzJobTb.Update.class) @RequestBody SystemUpdateQuartzJobArgs args) {
|
||||
// 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义
|
||||
checkBean(args.getBeanName());
|
||||
systemQuartzJobService.modifyQuartzJobResumeCron(args);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("更改定时任务状态")
|
||||
@PostMapping(value = "/switchQuartzJobStatus/{id}")
|
||||
@PreAuthorize("@el.check('quartzJob:edit')")
|
||||
public ResponseEntity<Void> switchQuartzJobStatus(@PathVariable Long id) {
|
||||
systemQuartzJobService.switchQuartzJobStatus(systemQuartzJobService.getQuartzJobById(id));
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("执行定时任务")
|
||||
@PostMapping(value = "/startQuartzJob/{id}")
|
||||
@PreAuthorize("@el.check('quartzJob:edit')")
|
||||
public ResponseEntity<Void> startQuartzJob(@PathVariable Long id) {
|
||||
systemQuartzJobService.startQuartzJob(systemQuartzJobService.getQuartzJobById(id));
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("删除定时任务")
|
||||
@PostMapping(value = "/removeJobByIds")
|
||||
@PreAuthorize("@el.check('quartzJob:del')")
|
||||
public ResponseEntity<Void> removeJobByIds(@RequestBody Set<Long> ids) {
|
||||
systemQuartzJobService.removeJobByIds(ids);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义
|
||||
*
|
||||
* @param beanName Bean名称
|
||||
*/
|
||||
private void checkBean(String beanName) {
|
||||
// 避免调用攻击者可以从SpringContextHolder获得控制jdbcTemplate类
|
||||
// 并使用getDeclaredMethod调用jdbcTemplate的queryForMap函数,执行任意sql命令。
|
||||
if (!CsSpringBeanHolder.getAllServiceBeanName().contains(beanName)) {
|
||||
throw new BadRequestException("非法的 Bean,请重新输入!");
|
||||
}
|
||||
}
|
||||
}
|
||||
+148
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.controller;
|
||||
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.odboy.base.CsPageArgs;
|
||||
import cn.odboy.base.CsPageResult;
|
||||
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.framework.permission.core.CsSecurityHelper;
|
||||
import cn.odboy.system.service.SystemRoleService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@Api(tags = "系统:角色管理")
|
||||
@RequestMapping("/api/role")
|
||||
public class SystemRoleController {
|
||||
@Autowired
|
||||
private SystemRoleService systemRoleService;
|
||||
|
||||
@ApiOperation("获取单个role")
|
||||
@PostMapping(value = "/queryRoleById")
|
||||
@PreAuthorize("@el.check('roles:list')")
|
||||
public ResponseEntity<SystemRoleTb> queryRoleById(@RequestBody SystemRoleTb args) {
|
||||
return ResponseEntity.ok(systemRoleService.getRoleById(args.getId()));
|
||||
}
|
||||
|
||||
@ApiOperation("导出角色数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('role:list')")
|
||||
public void exportRole(HttpServletResponse response, SystemQueryRoleArgs criteria) throws IOException {
|
||||
systemRoleService.exportRoleExcel(systemRoleService.queryRoleByArgs(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("返回全部的角色")
|
||||
@PostMapping(value = "/queryRoleList")
|
||||
@PreAuthorize("@el.check('roles:list','user:add','user:edit')")
|
||||
public ResponseEntity<List<SystemRoleTb>> queryRoleList() {
|
||||
return ResponseEntity.ok(systemRoleService.queryAllRole());
|
||||
}
|
||||
|
||||
@ApiOperation("查询角色")
|
||||
@PostMapping
|
||||
@PreAuthorize("@el.check('roles:list')")
|
||||
public ResponseEntity<CsPageResult<SystemRoleTb>> queryRoleByArgs(@Validated @RequestBody CsPageArgs<SystemQueryRoleArgs> args) {
|
||||
SystemQueryRoleArgs criteria = args.getArgs();
|
||||
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return ResponseEntity.ok(systemRoleService.queryRoleByArgs(criteria, page));
|
||||
}
|
||||
|
||||
@ApiOperation("获取用户级别")
|
||||
@PostMapping(value = "/queryRoleLevel")
|
||||
public ResponseEntity<Dict> queryRoleLevel() {
|
||||
return ResponseEntity.ok(Dict.create().set("level", checkRoleLevels(null)));
|
||||
}
|
||||
|
||||
@ApiOperation("新增角色")
|
||||
@PostMapping(value = "/saveRole")
|
||||
@PreAuthorize("@el.check('roles:add')")
|
||||
public ResponseEntity<Void> saveRole(@Validated @RequestBody SystemCreateRoleArgs args) {
|
||||
checkRoleLevels(args.getLevel());
|
||||
systemRoleService.saveRole(args);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("修改角色")
|
||||
@PostMapping(value = "/modifyRoleById")
|
||||
@PreAuthorize("@el.check('roles:edit')")
|
||||
public ResponseEntity<Void> modifyRoleById(@Validated(SystemRoleTb.Update.class) @RequestBody SystemRoleTb args) {
|
||||
checkRoleLevels(args.getLevel());
|
||||
systemRoleService.modifyRoleById(args);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("修改角色菜单")
|
||||
@PostMapping(value = "/modifyBindMenuById")
|
||||
@PreAuthorize("@el.check('roles:edit')")
|
||||
public ResponseEntity<Void> modifyBindMenuById(@RequestBody SystemRoleTb args) {
|
||||
SystemRoleTb role = systemRoleService.getRoleById(args.getId());
|
||||
checkRoleLevels(role.getLevel());
|
||||
systemRoleService.modifyBindMenuById(args);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("删除角色")
|
||||
@PostMapping(value = "/removeRoleByIds")
|
||||
@PreAuthorize("@el.check('roles:del')")
|
||||
public ResponseEntity<Void> removeRoleByIds(@RequestBody Set<Long> ids) {
|
||||
for (Long id : ids) {
|
||||
SystemRoleTb role = systemRoleService.getRoleById(id);
|
||||
checkRoleLevels(role.getLevel());
|
||||
}
|
||||
// 验证是否被用户关联
|
||||
systemRoleService.verifyBindRelationByIds(ids);
|
||||
systemRoleService.removeRoleByIds(ids);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查用户的角色级别
|
||||
*
|
||||
* @return /
|
||||
*/
|
||||
private int checkRoleLevels(Integer level) {
|
||||
List<Integer> levels =
|
||||
systemRoleService.queryRoleByUsersId(CsSecurityHelper.getCurrentUserId())
|
||||
.stream()
|
||||
.map(SystemRoleTb::getLevel)
|
||||
.collect(Collectors.toList());
|
||||
int min = Collections.min(levels);
|
||||
if (level != null) {
|
||||
if (level < min) {
|
||||
throw new BadRequestException("权限不足, 你的角色级别:" + min + ", 低于操作的角色级别:" + level);
|
||||
}
|
||||
}
|
||||
return min;
|
||||
}
|
||||
}
|
||||
+237
@@ -0,0 +1,237 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.odboy.base.CsPageArgs;
|
||||
import cn.odboy.base.CsPageResult;
|
||||
import cn.odboy.base.CsSelectOptionVo;
|
||||
import cn.odboy.framework.exception.BadRequestException;
|
||||
import cn.odboy.framework.properties.AppProperties;
|
||||
import cn.odboy.system.constant.SystemCaptchaBizEnum;
|
||||
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.SystemQueryUserArgs;
|
||||
import cn.odboy.system.dal.model.SystemUpdateUserPasswordArgs;
|
||||
import cn.odboy.system.framework.permission.core.CsSecurityHelper;
|
||||
import cn.odboy.system.service.*;
|
||||
import cn.odboy.util.CsPageUtil;
|
||||
import cn.odboy.util.CsRsaEncryptUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Api(tags = "系统:用户管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/user")
|
||||
public class SystemUserController {
|
||||
@Autowired
|
||||
private PasswordEncoder passwordEncoder;
|
||||
@Autowired
|
||||
private SystemUserService systemUserService;
|
||||
@Autowired
|
||||
private SystemDataService systemDataService;
|
||||
@Autowired
|
||||
private SystemDeptService systemDeptService;
|
||||
@Autowired
|
||||
private SystemRoleService systemRoleService;
|
||||
@Autowired
|
||||
private SystemEmailService systemEmailService;
|
||||
@Autowired
|
||||
private AppProperties properties;
|
||||
|
||||
@ApiOperation("导出用户数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('user:list')")
|
||||
public void exportUserExcel(HttpServletResponse response, SystemQueryUserArgs criteria) throws IOException {
|
||||
systemUserService.exportUserExcel(systemUserService.queryUserByArgs(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("查询用户")
|
||||
@PostMapping
|
||||
@PreAuthorize("@el.check('user:list')")
|
||||
public ResponseEntity<CsPageResult<SystemUserTb>> queryUserByArgs(@Validated @RequestBody CsPageArgs<SystemQueryUserArgs> args) {
|
||||
Page<SystemUserTb> page = new Page<>(args.getPage(), args.getSize());
|
||||
SystemQueryUserArgs criteria = args.getArgs();
|
||||
if (!ObjectUtils.isEmpty(criteria.getDeptId())) {
|
||||
criteria.getDeptIds().add(criteria.getDeptId());
|
||||
// 先查找是否存在子节点
|
||||
List<SystemDeptTb> data = systemDeptService.queryDeptByPid(criteria.getDeptId());
|
||||
// 然后把子节点的ID都加入到集合中
|
||||
criteria.getDeptIds().addAll(systemDeptService.queryChildDeptIdListByDeptIds(data));
|
||||
}
|
||||
// 数据权限
|
||||
List<Long> dataScopes = systemDataService.queryDeptIdListByArgs(systemUserService.getUserByUsername(CsSecurityHelper.getCurrentUsername()));
|
||||
// criteria.getDeptIds() 不为空并且数据权限不为空则取交集
|
||||
if (!CollectionUtils.isEmpty(criteria.getDeptIds()) && !CollectionUtils.isEmpty(dataScopes)) {
|
||||
// 取交集
|
||||
criteria.getDeptIds().retainAll(dataScopes);
|
||||
if (!CollectionUtil.isEmpty(criteria.getDeptIds())) {
|
||||
return ResponseEntity.ok(systemUserService.queryUserByArgs(criteria, page));
|
||||
}
|
||||
} else {
|
||||
// 否则取并集
|
||||
criteria.getDeptIds().addAll(dataScopes);
|
||||
return ResponseEntity.ok(systemUserService.queryUserByArgs(criteria, page));
|
||||
}
|
||||
return ResponseEntity.ok(CsPageUtil.emptyData());
|
||||
}
|
||||
|
||||
@ApiOperation("新增用户")
|
||||
@PostMapping(value = "/saveUser")
|
||||
@PreAuthorize("@el.check('user:add')")
|
||||
public ResponseEntity<Object> saveUser(@Validated @RequestBody SystemUserTb args) {
|
||||
checkLevel(args);
|
||||
// 默认密码 123456
|
||||
args.setPassword(passwordEncoder.encode("123456"));
|
||||
systemUserService.saveUser(args);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("修改用户")
|
||||
@PostMapping(value = "/modifyUserById")
|
||||
@PreAuthorize("@el.check('user:edit')")
|
||||
public ResponseEntity<Object> modifyUserById(@Validated(SystemUserTb.Update.class) @RequestBody SystemUserTb args) {
|
||||
checkLevel(args);
|
||||
systemUserService.modifyUserById(args);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("修改用户:个人中心")
|
||||
@PostMapping(value = "modifyUserCenterInfoById")
|
||||
public ResponseEntity<Object> modifyUserCenterInfoById(@Validated(SystemUserTb.Update.class) @RequestBody SystemUserTb args) {
|
||||
if (!args.getId().equals(CsSecurityHelper.getCurrentUserId())) {
|
||||
throw new BadRequestException("不能修改他人资料");
|
||||
}
|
||||
systemUserService.modifyUserCenterInfoById(args);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("删除用户")
|
||||
@PostMapping(value = "/removeUserByIds")
|
||||
@PreAuthorize("@el.check('user:del')")
|
||||
public ResponseEntity<Object> removeUserByIds(@RequestBody Set<Long> ids) {
|
||||
for (Long id : ids) {
|
||||
Integer currentLevel = Collections.min(systemRoleService.queryRoleByUsersId(CsSecurityHelper.getCurrentUserId()).stream().map(SystemRoleTb::getLevel).collect(Collectors.toList()));
|
||||
Integer optLevel = Collections.min(systemRoleService.queryRoleByUsersId(id).stream().map(SystemRoleTb::getLevel).collect(Collectors.toList()));
|
||||
if (currentLevel > optLevel) {
|
||||
throw new BadRequestException("角色权限不足, 不能删除:" + systemUserService.getUserById(id).getUsername());
|
||||
}
|
||||
}
|
||||
systemUserService.removeUserByIds(ids);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("修改密码")
|
||||
@PostMapping(value = "/modifyUserPasswordByUsername")
|
||||
public ResponseEntity<Object> modifyUserPasswordByUsername(@RequestBody SystemUpdateUserPasswordArgs passVo) throws Exception {
|
||||
String oldPass = CsRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), passVo.getOldPass());
|
||||
String newPass = CsRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), passVo.getNewPass());
|
||||
SystemUserTb user = systemUserService.getUserByUsername(CsSecurityHelper.getCurrentUsername());
|
||||
if (!passwordEncoder.matches(oldPass, user.getPassword())) {
|
||||
throw new BadRequestException("修改失败,旧密码错误");
|
||||
}
|
||||
if (passwordEncoder.matches(newPass, user.getPassword())) {
|
||||
throw new BadRequestException("新密码不能与旧密码相同");
|
||||
}
|
||||
systemUserService.modifyUserPasswordByUsername(user.getUsername(), passwordEncoder.encode(newPass));
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("重置密码")
|
||||
@PostMapping(value = "/resetUserPasswordByIds")
|
||||
public ResponseEntity<Object> resetUserPasswordByIds(@RequestBody Set<Long> ids) {
|
||||
String defaultPwd = passwordEncoder.encode("123456");
|
||||
systemUserService.resetUserPasswordByIds(ids, defaultPwd);
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("修改头像")
|
||||
@PostMapping(value = "/modifyUserAvatar")
|
||||
public ResponseEntity<Object> modifyUserAvatar(@RequestParam MultipartFile avatar) {
|
||||
return ResponseEntity.ok(systemUserService.modifyUserAvatar(avatar));
|
||||
}
|
||||
|
||||
@ApiOperation("修改邮箱")
|
||||
@PostMapping(value = "/modifyUserEmailByUsername/{code}")
|
||||
public ResponseEntity<Object> modifyUserEmailByUsername(@PathVariable String code, @RequestBody SystemUserTb args) throws Exception {
|
||||
String password = CsRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getPassword());
|
||||
SystemUserTb user = systemUserService.getUserByUsername(CsSecurityHelper.getCurrentUsername());
|
||||
if (!passwordEncoder.matches(password, user.getPassword())) {
|
||||
throw new BadRequestException("密码错误");
|
||||
}
|
||||
systemEmailService.checkEmailCaptcha(SystemCaptchaBizEnum.EMAIL_RESET_EMAIL_CODE, args.getEmail(), code);
|
||||
systemUserService.modifyUserEmailByUsername(user.getUsername(), args.getEmail());
|
||||
return ResponseEntity.ok(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果当前用户的角色级别低于创建用户的角色级别,则抛出权限不足的错误
|
||||
*
|
||||
* @param args /
|
||||
*/
|
||||
private void checkLevel(SystemUserTb args) {
|
||||
Integer currentLevel = Collections.min(systemRoleService.queryRoleByUsersId(CsSecurityHelper.getCurrentUserId()).stream().map(SystemRoleTb::getLevel).collect(Collectors.toList()));
|
||||
Integer optLevel = systemRoleService.getDeptLevelByRoles(args.getRoles());
|
||||
if (currentLevel > optLevel) {
|
||||
throw new BadRequestException("角色权限不足");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("查询用户基础数据")
|
||||
@PostMapping(value = "/queryUserMetadataOptions")
|
||||
@PreAuthorize("@el.check('user:list')")
|
||||
public ResponseEntity<List<CsSelectOptionVo>> queryUserMetadataOptions(@Validated @RequestBody CsPageArgs<SystemQueryUserArgs> args) {
|
||||
int maxPageSize = 50;
|
||||
SystemQueryUserArgs criteria = args.getArgs();
|
||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.and(c -> {
|
||||
c.eq(SystemUserTb::getPhone, criteria.getBlurry());
|
||||
c.or();
|
||||
c.eq(SystemUserTb::getEmail, criteria.getBlurry());
|
||||
c.or();
|
||||
c.like(SystemUserTb::getUsername, criteria.getBlurry());
|
||||
c.or();
|
||||
c.like(SystemUserTb::getNickName, criteria.getBlurry());
|
||||
});
|
||||
List<CsSelectOptionVo> collect = systemUserService.queryUserByBlurry(wrapper, new Page<>(criteria.getPage(), maxPageSize)).getRecords().stream().map(m -> {
|
||||
Map<String, Object> ext = new HashMap<>(1);
|
||||
ext.put("id", m.getId());
|
||||
ext.put("deptId", m.getDeptId());
|
||||
ext.put("email", m.getEmail());
|
||||
ext.put("phone", m.getPhone());
|
||||
return CsSelectOptionVo.builder().label(m.getNickName()).value(String.valueOf(m.getId())).ext(ext).build();
|
||||
}).collect(Collectors.toList());
|
||||
return ResponseEntity.ok(collect);
|
||||
}
|
||||
}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.dataobject;
|
||||
|
||||
import cn.odboy.base.CsBaseUserTimeTb;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("system_dept")
|
||||
public class SystemDeptTb extends CsBaseUserTimeTb {
|
||||
|
||||
@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> roles;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "子部门")
|
||||
private List<SystemDeptTb> children;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer deptSort;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "部门名称")
|
||||
private String name;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "是否启用")
|
||||
private Boolean enabled;
|
||||
|
||||
@ApiModelProperty(value = "上级部门")
|
||||
private Long pid;
|
||||
|
||||
@ApiModelProperty(value = "子节点数目", hidden = true)
|
||||
private Integer subCount = 0;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
SystemDeptTb dept = (SystemDeptTb) o;
|
||||
return Objects.equals(id, dept.id) && Objects.equals(name, dept.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, name);
|
||||
}
|
||||
|
||||
@ApiModelProperty(value = "是否有子节点")
|
||||
public Boolean getHasChildren() {
|
||||
return subCount > 0;
|
||||
}
|
||||
|
||||
@ApiModelProperty(value = "是否为叶子")
|
||||
public Boolean getLeaf() {
|
||||
return subCount <= 0;
|
||||
}
|
||||
|
||||
@ApiModelProperty(value = "标签名称")
|
||||
public String getLabel() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.dataobject;
|
||||
|
||||
import cn.odboy.base.CsBaseUserTimeTb;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("system_dict_detail")
|
||||
public class SystemDictDetailTb extends CsBaseUserTimeTb {
|
||||
|
||||
@NotNull(groups = Update.class)
|
||||
@ApiModelProperty(value = "ID", hidden = true)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@TableField(value = "dict_id")
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Long dictId;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "字典")
|
||||
private SystemDictTb dict;
|
||||
|
||||
@ApiModelProperty(value = "字典标签")
|
||||
private String label;
|
||||
|
||||
@ApiModelProperty(value = "字典值")
|
||||
private String value;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer dictSort = 999;
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.dataobject;
|
||||
|
||||
import cn.odboy.base.CsBaseUserTimeTb;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("system_dict")
|
||||
public class SystemDictTb extends CsBaseUserTimeTb {
|
||||
|
||||
@NotNull(groups = Update.class)
|
||||
@ApiModelProperty(value = "ID", hidden = true)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "描述")
|
||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||
private String description;
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.dataobject;
|
||||
|
||||
import cn.odboy.base.CsObject;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* 邮件配置类,数据存覆盖式存入数据存
|
||||
*/
|
||||
@Data
|
||||
@TableName("system_email_config")
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class SystemEmailConfigTb extends CsObject {
|
||||
|
||||
@TableId("config_id")
|
||||
private Long id;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "邮件服务器SMTP地址")
|
||||
private String host;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "邮件服务器 SMTP 端口")
|
||||
private String port;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "发件者用户名")
|
||||
private String user;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "密码")
|
||||
private String password;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "收件人")
|
||||
private String fromUser;
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.dataobject;
|
||||
|
||||
import cn.odboy.base.CsBaseUserTimeTb;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Objects;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("system_job")
|
||||
public class SystemJobTb extends CsBaseUserTimeTb {
|
||||
|
||||
@NotNull(groups = Update.class)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "ID", hidden = true)
|
||||
private Long id;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "岗位名称")
|
||||
private String name;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "岗位排序")
|
||||
private Long jobSort;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "是否启用")
|
||||
private Boolean enabled;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
SystemJobTb job = (SystemJobTb) o;
|
||||
return Objects.equals(id, job.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id);
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.dataobject;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import cn.odboy.base.CsBaseUserTimeTb;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("system_local_storage")
|
||||
public class SystemLocalStorageTb extends CsBaseUserTimeTb {
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "ID", hidden = true)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "真实文件名")
|
||||
private String realName;
|
||||
|
||||
@ApiModelProperty(value = "文件名")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "后缀")
|
||||
private String suffix;
|
||||
|
||||
@ApiModelProperty(value = "路径")
|
||||
private String path;
|
||||
|
||||
@ApiModelProperty(value = "类型")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(value = "大小")
|
||||
private String size;
|
||||
|
||||
@ApiModelProperty(value = "日期分组")
|
||||
private String dateGroup;
|
||||
|
||||
public void copy(SystemLocalStorageTb source) {
|
||||
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.dataobject;
|
||||
|
||||
import cn.odboy.base.CsBaseUserTimeTb;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("system_menu")
|
||||
public class SystemMenuTb extends CsBaseUserTimeTb {
|
||||
|
||||
@NotNull(groups = {Update.class})
|
||||
@TableId(value = "menu_id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "ID", hidden = true)
|
||||
private Long id;
|
||||
|
||||
@TableField(exist = false)
|
||||
@JSONField(serialize = false)
|
||||
@ApiModelProperty(value = "菜单角色")
|
||||
private Set<SystemRoleTb> roles;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<SystemMenuTb> children;
|
||||
|
||||
@ApiModelProperty(value = "菜单标题")
|
||||
private String title;
|
||||
|
||||
@TableField(value = "name")
|
||||
@ApiModelProperty(value = "菜单组件名称")
|
||||
private String componentName;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer menuSort = 999;
|
||||
|
||||
@ApiModelProperty(value = "组件路径")
|
||||
private String component;
|
||||
|
||||
@ApiModelProperty(value = "路由地址")
|
||||
private String path;
|
||||
|
||||
@ApiModelProperty(value = "菜单类型,目录、菜单、按钮")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "权限标识")
|
||||
private String permission;
|
||||
|
||||
@ApiModelProperty(value = "菜单图标")
|
||||
private String icon;
|
||||
|
||||
@ApiModelProperty(value = "缓存")
|
||||
private Boolean cache;
|
||||
|
||||
@ApiModelProperty(value = "是否隐藏")
|
||||
private Boolean hidden;
|
||||
|
||||
@ApiModelProperty(value = "上级菜单")
|
||||
private Long pid;
|
||||
|
||||
@ApiModelProperty(value = "子节点数目", hidden = true)
|
||||
private Integer subCount = 0;
|
||||
|
||||
@ApiModelProperty(value = "外链菜单")
|
||||
private Boolean iFrame;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
SystemMenuTb menu = (SystemMenuTb) o;
|
||||
return Objects.equals(id, menu.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id);
|
||||
}
|
||||
|
||||
@ApiModelProperty(value = "是否有子节点")
|
||||
public Boolean getHasChildren() {
|
||||
return subCount > 0;
|
||||
}
|
||||
|
||||
@ApiModelProperty(value = "是否为叶子")
|
||||
public Boolean getLeaf() {
|
||||
return subCount <= 0;
|
||||
}
|
||||
|
||||
@ApiModelProperty(value = "标签名称")
|
||||
public String getLabel() {
|
||||
return title;
|
||||
}
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.dataobject;
|
||||
|
||||
import cn.odboy.base.CsObject;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统审计日志
|
||||
* </p>
|
||||
*
|
||||
* @author codegen
|
||||
* @since 2025-05-12
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@TableName("system_operation_log")
|
||||
@ApiModel(value = "SystemOperationLog对象", description = "审计日志")
|
||||
public class SystemOperationLogTb extends CsObject {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@ApiModelProperty("id")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 业务名称
|
||||
*/
|
||||
@TableField("biz_name")
|
||||
private String bizName;
|
||||
/**
|
||||
* 业务方法
|
||||
*/
|
||||
@TableField("method")
|
||||
private String method;
|
||||
/**
|
||||
* 业务参数
|
||||
*/
|
||||
@TableField("params")
|
||||
private String params;
|
||||
/**
|
||||
* 访问来源IP
|
||||
*/
|
||||
@TableField("request_ip")
|
||||
private String requestIp;
|
||||
/**
|
||||
* 执行时间
|
||||
*/
|
||||
@TableField("execute_time")
|
||||
private Long executeTime;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@TableField("username")
|
||||
private String username;
|
||||
/**
|
||||
* 访问来源地址
|
||||
*/
|
||||
@TableField("address")
|
||||
private String address;
|
||||
/**
|
||||
* 浏览器信息
|
||||
*/
|
||||
@TableField("browser_info")
|
||||
private String browserInfo;
|
||||
/**
|
||||
* 异常详情
|
||||
*/
|
||||
@TableField("exception_detail")
|
||||
private String exceptionDetail;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.dataobject;
|
||||
|
||||
import cn.odboy.base.CsBaseUserTimeTb;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* OSS存储
|
||||
* </p>
|
||||
*
|
||||
* @author codegen
|
||||
* @since 2025-07-15
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("system_oss_storage")
|
||||
@ApiModel(value = "SystemOssStorage对象", description = "OSS存储")
|
||||
public class SystemOssStorageTb extends CsBaseUserTimeTb {
|
||||
@ApiModelProperty("ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
@TableField("service_type")
|
||||
@ApiModelProperty("类型,比如minio")
|
||||
private String serviceType;
|
||||
@TableField("endpoint")
|
||||
@ApiModelProperty("服务地址")
|
||||
private String endpoint;
|
||||
@TableField("bucket_name")
|
||||
@ApiModelProperty("存储桶名称")
|
||||
private String bucketName;
|
||||
@TableField("file_name")
|
||||
@ApiModelProperty("完整文件名称")
|
||||
private String fileName;
|
||||
@TableField("file_size")
|
||||
@ApiModelProperty("文件大小, 单位:字节")
|
||||
private Long fileSize;
|
||||
@TableField("file_mime")
|
||||
@ApiModelProperty("文件类型")
|
||||
private String fileMime;
|
||||
@ApiModelProperty("短文件名")
|
||||
@TableField("file_prefix")
|
||||
private String filePrefix;
|
||||
@ApiModelProperty("文件后缀")
|
||||
@TableField("file_suffix")
|
||||
private String fileSuffix;
|
||||
@TableField("file_md5")
|
||||
@ApiModelProperty("文件md5")
|
||||
private String fileMd5;
|
||||
@TableField("file_url")
|
||||
@ApiModelProperty("文件链接")
|
||||
private String fileUrl;
|
||||
@TableField("file_code")
|
||||
@ApiModelProperty("文件编码")
|
||||
private String fileCode;
|
||||
@TableField("object_name")
|
||||
@ApiModelProperty("对象路径")
|
||||
private String objectName;
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.dataobject;
|
||||
|
||||
import cn.odboy.base.CsBaseUserTimeTb;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("system_quartz_job")
|
||||
public class SystemQuartzJobTb extends CsBaseUserTimeTb {
|
||||
|
||||
public static final String JOB_KEY = "JOB_KEY";
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@NotNull(groups = {Update.class})
|
||||
private Long id;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "用于子任务唯一标识", hidden = true)
|
||||
private String uuid;
|
||||
|
||||
@ApiModelProperty(value = "定时器名称")
|
||||
private String jobName;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "Bean名称")
|
||||
private String beanName;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "方法名称")
|
||||
private String methodName;
|
||||
|
||||
@ApiModelProperty(value = "参数")
|
||||
private String params;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "cron表达式")
|
||||
private String cronExpression;
|
||||
|
||||
@ApiModelProperty(value = "状态:暂停或启动")
|
||||
private Boolean isPause = false;
|
||||
|
||||
@ApiModelProperty(value = "负责人")
|
||||
private String personInCharge;
|
||||
|
||||
@ApiModelProperty(value = "报警邮箱")
|
||||
private String email;
|
||||
|
||||
@ApiModelProperty(value = "子任务")
|
||||
private String subTask;
|
||||
|
||||
@ApiModelProperty(value = "失败后暂停")
|
||||
private Boolean pauseAfterFailure;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "备注")
|
||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||
private String description;
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.dataobject;
|
||||
|
||||
import cn.odboy.base.CsObject;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("system_quartz_log")
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class SystemQuartzLogTb extends CsObject {
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "ID", hidden = true)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "任务名称", hidden = true)
|
||||
private String jobName;
|
||||
|
||||
@ApiModelProperty(value = "bean名称", hidden = true)
|
||||
private String beanName;
|
||||
|
||||
@ApiModelProperty(value = "方法名称", hidden = true)
|
||||
private String methodName;
|
||||
|
||||
@ApiModelProperty(value = "参数", hidden = true)
|
||||
private String params;
|
||||
|
||||
@ApiModelProperty(value = "cron表达式", hidden = true)
|
||||
private String cronExpression;
|
||||
|
||||
@ApiModelProperty(value = "状态", hidden = true)
|
||||
private Boolean isSuccess;
|
||||
|
||||
@ApiModelProperty(value = "异常详情", hidden = true)
|
||||
private String exceptionDetail;
|
||||
|
||||
@ApiModelProperty(value = "执行耗时", hidden = true)
|
||||
private Long time;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@ApiModelProperty(value = "创建时间", hidden = true)
|
||||
private Date createTime;
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package cn.odboy.system.dal.dataobject;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 角色菜单
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("system_roles_menus")
|
||||
public class SystemRoleMenuTb {
|
||||
private Long menuId;
|
||||
private Long roleId;
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.dataobject;
|
||||
|
||||
import cn.odboy.base.CsBaseUserTimeTb;
|
||||
import cn.odboy.system.constant.SystemDataScopeEnum;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 角色
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("system_role")
|
||||
public class SystemRoleTb extends CsBaseUserTimeTb {
|
||||
|
||||
@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();
|
||||
|
||||
@ApiModelProperty(value = "级别,数值越小,级别越大")
|
||||
private Integer level = 3;
|
||||
|
||||
@ApiModelProperty(value = "描述")
|
||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||
private String description;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
SystemRoleTb role = (SystemRoleTb) o;
|
||||
return Objects.equals(id, role.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id);
|
||||
}
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.dataobject;
|
||||
|
||||
import cn.odboy.base.CsBaseUserTimeTb;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("system_user")
|
||||
public class SystemUserTb extends CsBaseUserTimeTb {
|
||||
|
||||
@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;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "用户昵称")
|
||||
private String nickName;
|
||||
|
||||
@Email
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "邮箱")
|
||||
private String email;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "电话号码")
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty(value = "用户性别")
|
||||
private String gender;
|
||||
|
||||
@ApiModelProperty(value = "头像真实名称", hidden = true)
|
||||
private String avatarName;
|
||||
|
||||
@ApiModelProperty(value = "头像存储的路径", hidden = true)
|
||||
private String avatarPath;
|
||||
|
||||
@ApiModelProperty(value = "密码")
|
||||
private String password;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "是否启用")
|
||||
private Boolean enabled;
|
||||
|
||||
@ApiModelProperty(value = "是否为admin账号", hidden = true)
|
||||
private Boolean isAdmin = false;
|
||||
|
||||
@ApiModelProperty(value = "最后修改密码的时间", hidden = true)
|
||||
private Date pwdResetTime;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
SystemUserTb user = (SystemUserTb) o;
|
||||
return Objects.equals(id, user.id) && Objects.equals(username, user.username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, username);
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import cn.odboy.base.CsObject;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class SystemCheckEmailCaptchaArgs extends CsObject {
|
||||
@NotBlank(message = "邮箱不能为空")
|
||||
private String email;
|
||||
@NotBlank(message = "验证码不能为空")
|
||||
private String code;
|
||||
@NotBlank(message = "验证码业务标识不能为空")
|
||||
private String bizCode;
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import cn.odboy.base.CsObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class SystemCreateDeptArgs extends CsObject {
|
||||
@NotBlank(message = "部门名称必填")
|
||||
private String name;
|
||||
@NotNull(message = "部门排序必填")
|
||||
private Integer deptSort;
|
||||
private Boolean enabled;
|
||||
private String isTop;
|
||||
private Long pid;
|
||||
private Integer subCount = 0;
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import cn.odboy.base.CsObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class SystemCreateDictArgs extends CsObject {
|
||||
@NotBlank(message = "字典名称必填")
|
||||
private String name;
|
||||
private String description;
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import cn.odboy.base.CsObject;
|
||||
import cn.odboy.system.dal.dataobject.SystemDictTb;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class SystemCreateDictDetailArgs extends CsObject {
|
||||
@NotNull(message = "参数dict必填")
|
||||
private SystemDictTb dict;
|
||||
@NotBlank(message = "字典标签必填")
|
||||
private String label;
|
||||
@NotBlank(message = "字典值必填")
|
||||
private String value;
|
||||
@NotNull(message = "字典排序必填")
|
||||
private Integer dictSort;
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import cn.odboy.base.CsObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class SystemCreateJobArgs extends CsObject {
|
||||
@NotBlank(message = "职位名称必填")
|
||||
private String name;
|
||||
@NotNull(message = "职位排序必填")
|
||||
private Integer jobSort;
|
||||
private Boolean enabled;
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import cn.odboy.base.CsObject;
|
||||
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class SystemCreateRoleArgs extends CsObject {
|
||||
@NotBlank(message = "角色名称必填")
|
||||
private String name;
|
||||
@NotNull(message = "角色级别必填")
|
||||
private Integer level;
|
||||
@NotBlank(message = "数据范围必填")
|
||||
private String dataScope;
|
||||
private String description;
|
||||
/**
|
||||
* 关联的部门
|
||||
*/
|
||||
private Long id;
|
||||
private Set<SystemDeptTb> depts;
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import cn.odboy.base.CsObject;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class SystemMenuMetaVo extends CsObject {
|
||||
|
||||
@ApiModelProperty(value = "菜单标题")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "菜单图标")
|
||||
private String icon;
|
||||
|
||||
@ApiModelProperty(value = "缓存")
|
||||
private Boolean noCache;
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import cn.odboy.base.CsObject;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 构建前端路由时用到
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class SystemMenuVo extends CsObject {
|
||||
|
||||
@ApiModelProperty(value = "菜单名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "路径")
|
||||
private String path;
|
||||
|
||||
@ApiModelProperty(value = "隐藏状态")
|
||||
private Boolean hidden;
|
||||
|
||||
@ApiModelProperty(value = "重定向")
|
||||
private String redirect;
|
||||
|
||||
@ApiModelProperty(value = "组件")
|
||||
private String component;
|
||||
|
||||
@ApiModelProperty(value = "总是显示")
|
||||
private Boolean alwaysShow;
|
||||
|
||||
@ApiModelProperty(value = "元数据")
|
||||
private SystemMenuMetaVo meta;
|
||||
|
||||
@ApiModelProperty(value = "子路由")
|
||||
private List<SystemMenuVo> children;
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import cn.odboy.system.dal.dataobject.SystemOssStorageTb;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class SystemOssStorageVo extends SystemOssStorageTb {
|
||||
private String fileSizeDesc;
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import cn.odboy.base.CsObject;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class SystemProductLineTreeVo extends CsObject {
|
||||
private String value;
|
||||
private String label;
|
||||
private List<SystemProductLineTreeVo> children;
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import cn.odboy.base.CsObject;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class SystemProductLineVo extends CsObject {
|
||||
/**
|
||||
* 部门ID(select的value)
|
||||
*/
|
||||
private Long value;
|
||||
/**
|
||||
* 产品线,如"研发部/华南分部/devops组"
|
||||
*/
|
||||
private String label;
|
||||
/**
|
||||
* ID路径,如"1-2-3"
|
||||
*/
|
||||
private String idPath;
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SystemQueryDeptArgs {
|
||||
|
||||
@ApiModelProperty(value = "部门id集合")
|
||||
private List<Long> ids;
|
||||
|
||||
@ApiModelProperty(value = "部门名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "是否启用")
|
||||
private Boolean enabled;
|
||||
|
||||
@ApiModelProperty(value = "上级部门")
|
||||
private Long pid;
|
||||
|
||||
@ApiModelProperty(value = "PID为空查询")
|
||||
private Boolean pidIsNull;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private List<Date> createTime;
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SystemQueryDictArgs {
|
||||
|
||||
@ApiModelProperty(value = "模糊查询")
|
||||
private String blurry;
|
||||
|
||||
@ApiModelProperty(value = "页码", example = "1")
|
||||
private Integer page = 1;
|
||||
|
||||
@ApiModelProperty(value = "每页数据量", example = "10")
|
||||
private Integer size = 10;
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import cn.odboy.base.CsObject;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class SystemQueryDictDetailArgs extends CsObject {
|
||||
@ApiModelProperty(value = "标签")
|
||||
private String label;
|
||||
|
||||
@ApiModelProperty(value = "字典名称")
|
||||
private String dictName;
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class SystemQueryJobArgs {
|
||||
|
||||
@ApiModelProperty(value = "岗位名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "是否启用")
|
||||
private Boolean enabled;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private List<Date> createTime;
|
||||
|
||||
@ApiModelProperty(value = "页码", example = "1")
|
||||
private Integer page = 1;
|
||||
|
||||
@ApiModelProperty(value = "每页数据量", example = "10")
|
||||
private Integer size = 10;
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SystemQueryMenuArgs {
|
||||
|
||||
@ApiModelProperty(value = "模糊查询")
|
||||
private String blurry;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private List<Date> createTime;
|
||||
|
||||
@ApiModelProperty(value = "PID为空查询")
|
||||
private Boolean pidIsNull;
|
||||
|
||||
@ApiModelProperty(value = "PID")
|
||||
private Long pid;
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SystemQueryQuartzJobArgs {
|
||||
|
||||
@ApiModelProperty(value = "定时任务名称")
|
||||
private String jobName;
|
||||
|
||||
@ApiModelProperty(value = "是否成功")
|
||||
private Boolean isSuccess;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private List<Date> createTime;
|
||||
|
||||
@ApiModelProperty(value = "页码", example = "1")
|
||||
private Integer page = 1;
|
||||
|
||||
@ApiModelProperty(value = "每页数据量", example = "10")
|
||||
private Integer size = 10;
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SystemQueryRoleArgs {
|
||||
|
||||
@ApiModelProperty(value = "模糊查询")
|
||||
private String blurry;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private List<Date> createTime;
|
||||
|
||||
@ApiModelProperty(value = "页码", example = "1")
|
||||
private Integer page = 1;
|
||||
|
||||
@ApiModelProperty(value = "每页数据量", example = "10")
|
||||
private Integer size = 10;
|
||||
|
||||
@ApiModelProperty(value = "偏移量", hidden = true)
|
||||
private long offset;
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SystemQueryStorageArgs {
|
||||
|
||||
@ApiModelProperty(value = "模糊查询")
|
||||
private String blurry;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private List<Date> createTime;
|
||||
|
||||
@ApiModelProperty(value = "页码", example = "1")
|
||||
private Integer page = 1;
|
||||
|
||||
@ApiModelProperty(value = "每页数据量", example = "10")
|
||||
private Integer size = 10;
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import cn.odboy.base.CsObject;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class SystemQueryUserArgs extends CsObject {
|
||||
|
||||
@ApiModelProperty(value = "ID")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "多个ID")
|
||||
private Set<Long> deptIds = new HashSet<>();
|
||||
|
||||
@ApiModelProperty(value = "模糊查询")
|
||||
private String blurry;
|
||||
|
||||
@ApiModelProperty(value = "是否启用")
|
||||
private Boolean enabled;
|
||||
|
||||
@ApiModelProperty(value = "部门ID")
|
||||
private Long deptId;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private List<Date> createTime;
|
||||
|
||||
@ApiModelProperty(value = "页码", example = "1")
|
||||
private Integer page = 1;
|
||||
|
||||
@ApiModelProperty(value = "每页数据量", example = "10")
|
||||
private Integer size = 10;
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
|
||||
/**
|
||||
* 避免序列化问题
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SystemRoleCodeVo implements GrantedAuthority {
|
||||
|
||||
@ApiModelProperty(value = "角色名")
|
||||
private String authority;
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 发送邮件时,接收参数的类
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SystemSendEmailArgs {
|
||||
|
||||
@NotEmpty
|
||||
@ApiModelProperty(value = "收件人")
|
||||
private List<String> tos;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "主题")
|
||||
private String subject;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "内容")
|
||||
private String content;
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import cn.odboy.base.CsObject;
|
||||
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||
import cn.odboy.system.dal.dataobject.SystemJobTb;
|
||||
import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class SystemSimpleUserVo extends CsObject {
|
||||
@ApiModelProperty(value = "ID", hidden = true)
|
||||
private Long id;
|
||||
@ApiModelProperty(value = "用户角色")
|
||||
private Set<SystemRoleTb> roles;
|
||||
@ApiModelProperty(value = "用户岗位")
|
||||
private Set<SystemJobTb> jobs;
|
||||
private Long deptId;
|
||||
@TableField(exist = false)
|
||||
private SystemDeptTb dept;
|
||||
@ApiModelProperty(value = "用户名称")
|
||||
private String username;
|
||||
@ApiModelProperty(value = "用户昵称")
|
||||
private String nickName;
|
||||
@ApiModelProperty(value = "邮箱")
|
||||
private String email;
|
||||
@ApiModelProperty(value = "电话号码")
|
||||
private String phone;
|
||||
@ApiModelProperty(value = "用户性别")
|
||||
private String gender;
|
||||
@ApiModelProperty(value = "头像真实名称", hidden = true)
|
||||
private String avatarName;
|
||||
@ApiModelProperty(value = "是否启用")
|
||||
private Boolean enabled;
|
||||
@ApiModelProperty(value = "是否为admin账号", hidden = true)
|
||||
private Boolean isAdmin = false;
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import cn.odboy.base.CsObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class SystemUpdateQuartzJobArgs extends CsObject {
|
||||
@NotNull
|
||||
private Long id;
|
||||
private String uuid;
|
||||
private String jobName;
|
||||
@NotBlank
|
||||
private String beanName;
|
||||
@NotBlank
|
||||
private String methodName;
|
||||
private String params;
|
||||
@NotBlank
|
||||
private String cronExpression;
|
||||
private Boolean isPause = false;
|
||||
private String personInCharge;
|
||||
private String email;
|
||||
private String subTask;
|
||||
private Boolean pauseAfterFailure;
|
||||
@NotBlank
|
||||
private String description;
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*/
|
||||
@Data
|
||||
public class SystemUpdateUserPasswordArgs {
|
||||
|
||||
@ApiModelProperty(value = "旧密码")
|
||||
private String oldPass;
|
||||
|
||||
@ApiModelProperty(value = "新密码")
|
||||
private String newPass;
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import cn.odboy.base.CsObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class SystemUserInfoVo extends CsObject {
|
||||
private SystemSimpleUserVo user;
|
||||
private List<Long> dataScopes;
|
||||
private List<SystemRoleCodeVo> authorities;
|
||||
|
||||
public Set<String> getRoles() {
|
||||
return authorities.stream().map(SystemRoleCodeVo::getAuthority).collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import cn.odboy.system.dal.dataobject.SystemUserTb;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class SystemUserJwtVo implements UserDetails {
|
||||
|
||||
@ApiModelProperty(value = "用户")
|
||||
private final SystemUserTb user;
|
||||
|
||||
@ApiModelProperty(value = "数据权限")
|
||||
private final List<Long> dataScopes;
|
||||
|
||||
@ApiModelProperty(value = "角色")
|
||||
private final List<SystemRoleCodeVo> authorities;
|
||||
|
||||
public Set<String> getRoles() {
|
||||
return authorities.stream().map(SystemRoleCodeVo::getAuthority).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
@JSONField(serialize = false)
|
||||
public String getPassword() {
|
||||
return user.getPassword();
|
||||
}
|
||||
|
||||
@Override
|
||||
@JSONField(serialize = false)
|
||||
public String getUsername() {
|
||||
return user.getUsername();
|
||||
}
|
||||
|
||||
@Override
|
||||
@JSONField(serialize = false)
|
||||
public boolean isAccountNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JSONField(serialize = false)
|
||||
public boolean isAccountNonLocked() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JSONField(serialize = false)
|
||||
public boolean isCredentialsNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JSONField(serialize = false)
|
||||
public boolean isEnabled() {
|
||||
return user.getEnabled();
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class SystemUserLoginArgs {
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "用户名")
|
||||
private String username;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "密码")
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty(value = "验证码")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty(value = "验证码的key")
|
||||
private String uuid = "";
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.model;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 在线用户
|
||||
*/
|
||||
@Data
|
||||
public class SystemUserOnlineVo {
|
||||
@ApiModelProperty(value = "Token编号")
|
||||
private String uid;
|
||||
|
||||
@ApiModelProperty(value = "用户名")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty(value = "昵称")
|
||||
private String nickName;
|
||||
|
||||
@ApiModelProperty(value = "岗位")
|
||||
private String dept;
|
||||
|
||||
@ApiModelProperty(value = "浏览器")
|
||||
private String browser;
|
||||
|
||||
@ApiModelProperty(value = "IP")
|
||||
private String ip;
|
||||
|
||||
@ApiModelProperty(value = "地址")
|
||||
private String address;
|
||||
|
||||
@ApiModelProperty(value = "token")
|
||||
private String key;
|
||||
|
||||
@ApiModelProperty(value = "登录时间")
|
||||
private Date loginTime;
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.mysql;
|
||||
|
||||
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||
import cn.odboy.system.dal.model.SystemQueryDeptArgs;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 部门 Mapper
|
||||
*
|
||||
* @author odboy
|
||||
*/
|
||||
@Mapper
|
||||
public interface SystemDeptMapper extends BaseMapper<SystemDeptTb> {
|
||||
List<SystemDeptTb> selectDeptByArgs(@Param("criteria") SystemQueryDeptArgs criteria);
|
||||
|
||||
List<SystemDeptTb> selectDeptByPid(@Param("pid") Long pid);
|
||||
|
||||
int countDeptByPid(@Param("pid") Long pid);
|
||||
|
||||
List<SystemDeptTb> selectDeptByPidIsNull();
|
||||
|
||||
List<SystemDeptTb> selectDeptByRoleId(@Param("roleId") Long roleId);
|
||||
|
||||
void updateDeptSubCountById(@Param("count") Integer count, @Param("id") Long id);
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.mysql;
|
||||
|
||||
import cn.odboy.system.dal.dataobject.SystemDictDetailTb;
|
||||
import cn.odboy.system.dal.model.SystemQueryDictDetailArgs;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 字典明细 Mapper
|
||||
*
|
||||
* @author odboy
|
||||
*/
|
||||
@Mapper
|
||||
public interface SystemDictDetailMapper extends BaseMapper<SystemDictDetailTb> {
|
||||
IPage<SystemDictDetailTb> selectDictDetailByArgs(@Param("criteria") SystemQueryDictDetailArgs criteria, Page<Object> page);
|
||||
|
||||
List<SystemDictDetailTb> selectDictDetailByArgs(@Param("criteria") SystemQueryDictDetailArgs criteria);
|
||||
|
||||
void deleteDictDetailByDictIds(@Param("dictIds") Set<Long> dictIds);
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.mysql;
|
||||
|
||||
import cn.odboy.system.dal.dataobject.SystemDictTb;
|
||||
import cn.odboy.system.dal.model.SystemQueryDictArgs;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典 Mapper
|
||||
*
|
||||
* @author odboy
|
||||
*/
|
||||
@Mapper
|
||||
public interface SystemDictMapper extends BaseMapper<SystemDictTb> {
|
||||
IPage<SystemDictTb> selectDictByArgs(@Param("criteria") SystemQueryDictArgs criteria, Page<SystemDictTb> page);
|
||||
|
||||
List<SystemDictTb> selectDictByArgs(@Param("criteria") SystemQueryDictArgs criteria);
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.mysql;
|
||||
|
||||
import cn.odboy.system.dal.dataobject.SystemEmailConfigTb;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 邮件配置 Mapper
|
||||
*
|
||||
* @author odboy
|
||||
*/
|
||||
@Mapper
|
||||
public interface SystemEmailConfigMapper extends BaseMapper<SystemEmailConfigTb> {
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.mysql;
|
||||
|
||||
import cn.odboy.system.dal.dataobject.SystemJobTb;
|
||||
import cn.odboy.system.dal.model.SystemQueryJobArgs;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 职位 Mapper
|
||||
*
|
||||
* @author odboy
|
||||
*/
|
||||
@Mapper
|
||||
public interface SystemJobMapper extends BaseMapper<SystemJobTb> {
|
||||
SystemJobTb getJobByName(@Param("name") String name);
|
||||
|
||||
IPage<SystemJobTb> selectJobByArgs(@Param("criteria") SystemQueryJobArgs criteria, Page<SystemJobTb> page);
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.mysql;
|
||||
|
||||
import cn.odboy.system.dal.dataobject.SystemLocalStorageTb;
|
||||
import cn.odboy.system.dal.model.SystemQueryStorageArgs;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 本地存储记录 Mapper
|
||||
*
|
||||
* @author odboy
|
||||
*/
|
||||
@Mapper
|
||||
public interface SystemLocalStorageMapper extends BaseMapper<SystemLocalStorageTb> {
|
||||
IPage<SystemLocalStorageTb> selectLocalStorageByArgs(@Param("criteria") SystemQueryStorageArgs criteria, Page<SystemLocalStorageTb> page);
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.mysql;
|
||||
|
||||
import cn.odboy.system.dal.dataobject.SystemMenuTb;
|
||||
import cn.odboy.system.dal.model.SystemQueryMenuArgs;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 菜单 Mapper
|
||||
*
|
||||
* @author odboy
|
||||
*/
|
||||
@Mapper
|
||||
public interface SystemMenuMapper extends BaseMapper<SystemMenuTb> {
|
||||
|
||||
List<SystemMenuTb> selectMenuByArgs(@Param("criteria") SystemQueryMenuArgs criteria);
|
||||
|
||||
LinkedHashSet<SystemMenuTb> selectMenuByRoleIdsAndType(@Param("roleIds") Set<Long> roleIds, @Param("type") Integer type);
|
||||
|
||||
List<SystemMenuTb> selectMenuByPidIsNullOrderByMenuSort();
|
||||
|
||||
List<SystemMenuTb> selectMenuByPidOrderByMenuSort(@Param("pid") Long pid);
|
||||
|
||||
SystemMenuTb getMenuByTitle(@Param("title") String title);
|
||||
|
||||
SystemMenuTb getMenuByComponentName(@Param("name") String name);
|
||||
|
||||
Integer countMenuByPid(@Param("pid") Long pid);
|
||||
|
||||
void updateMenuSubCntByMenuId(@Param("count") int count, @Param("menuId") Long menuId);
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.mysql;
|
||||
|
||||
import cn.odboy.system.dal.dataobject.SystemOperationLogTb;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface SystemOperationLogMapper extends BaseMapper<SystemOperationLogTb> {
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.mysql;
|
||||
|
||||
import cn.odboy.system.dal.dataobject.SystemOssStorageTb;
|
||||
import cn.odboy.system.dal.model.SystemQueryStorageArgs;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* OSS存储 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author codegen
|
||||
* @since 2025-07-15
|
||||
*/
|
||||
@Mapper
|
||||
public interface SystemOssStorageMapper extends BaseMapper<SystemOssStorageTb> {
|
||||
IPage<SystemOssStorageTb> selectOssStorageByArgs(SystemQueryStorageArgs criteria, Page<SystemOssStorageTb> page);
|
||||
|
||||
List<SystemOssStorageTb> selectOssStorageByArgs(SystemQueryStorageArgs criteria);
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.mysql;
|
||||
|
||||
import cn.odboy.system.dal.dataobject.SystemQuartzJobTb;
|
||||
import cn.odboy.system.dal.model.SystemQueryQuartzJobArgs;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 定时任务 Mapper
|
||||
*
|
||||
* @author odboy
|
||||
*/
|
||||
@Mapper
|
||||
public interface SystemQuartzJobMapper extends BaseMapper<SystemQuartzJobTb> {
|
||||
IPage<SystemQuartzJobTb> selectQuartzJobByArgs(@Param("criteria") SystemQueryQuartzJobArgs criteria, Page<SystemQuartzJobTb> page);
|
||||
|
||||
List<SystemQuartzJobTb> selectAllEnableQuartzJob();
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.mysql;
|
||||
|
||||
import cn.odboy.system.dal.dataobject.SystemQuartzLogTb;
|
||||
import cn.odboy.system.dal.model.SystemQueryQuartzJobArgs;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 定时任务日志 Mapper
|
||||
*
|
||||
* @author odboy
|
||||
*/
|
||||
@Mapper
|
||||
public interface SystemQuartzLogMapper extends BaseMapper<SystemQuartzLogTb> {
|
||||
IPage<SystemQuartzLogTb> selectQuartzLogByArgs(@Param("criteria") SystemQueryQuartzJobArgs criteria, Page<SystemQuartzLogTb> page);
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.mysql;
|
||||
|
||||
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 角色部门关联 Mapper
|
||||
*
|
||||
* @author odboy
|
||||
*/
|
||||
@Mapper
|
||||
public interface SystemRoleDeptMapper {
|
||||
void batchInsertRoleDept(@Param("depts") Set<SystemDeptTb> depts, @Param("roleId") Long roleId);
|
||||
|
||||
void batchDeleteRoleDept(@Param("roleIds") Set<Long> roleIds);
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.mysql;
|
||||
|
||||
import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
||||
import cn.odboy.system.dal.model.SystemQueryRoleArgs;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 角色 Mapper
|
||||
*
|
||||
* @author odboy
|
||||
*/
|
||||
@Mapper
|
||||
public interface SystemRoleMapper extends BaseMapper<SystemRoleTb> {
|
||||
List<SystemRoleTb> selectAllRole();
|
||||
|
||||
List<SystemRoleTb> selectRoleByArgs(@Param("criteria") SystemQueryRoleArgs criteria);
|
||||
|
||||
Long countRoleByArgs(@Param("criteria") SystemQueryRoleArgs criteria);
|
||||
|
||||
SystemRoleTb getRoleByName(@Param("name") String name);
|
||||
|
||||
SystemRoleTb getRoleById(@Param("roleId") Long roleId);
|
||||
|
||||
List<SystemRoleTb> selectRoleByUserId(@Param("userId") Long userId);
|
||||
|
||||
Integer countRoleByDeptIds(@Param("deptIds") Set<Long> deptIds);
|
||||
|
||||
List<SystemRoleTb> selectRoleByMenuId(@Param("menuId") Long menuId);
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.mysql;
|
||||
|
||||
import cn.odboy.system.dal.dataobject.SystemMenuTb;
|
||||
import cn.odboy.system.dal.dataobject.SystemRoleMenuTb;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 角色菜单关联 Mapper
|
||||
*
|
||||
* @author odboy
|
||||
*/
|
||||
@Mapper
|
||||
public interface SystemRoleMenuMapper extends BaseMapper<SystemRoleMenuTb> {
|
||||
void batchInsertRoleMenu(@Param("menus") Set<SystemMenuTb> menus, @Param("roleId") Long roleId);
|
||||
|
||||
void batchDeleteRoleMenu(@Param("roleIds") Set<Long> roleIds);
|
||||
|
||||
void deleteRoleMenuByRoleId(@Param("roleId") Long roleId);
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.mysql;
|
||||
|
||||
import cn.odboy.system.dal.dataobject.SystemJobTb;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 用户职位关联 Mapper
|
||||
*
|
||||
* @author odboy
|
||||
*/
|
||||
@Mapper
|
||||
public interface SystemUserJobMapper {
|
||||
void batchInsertUserJob(@Param("jobs") Set<SystemJobTb> jobs, @Param("userId") Long userId);
|
||||
|
||||
void batchDeleteUserJob(@Param("userIds") Set<Long> userIds);
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.mysql;
|
||||
|
||||
import cn.odboy.system.dal.dataobject.SystemUserTb;
|
||||
import cn.odboy.system.dal.model.SystemQueryUserArgs;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Mapper
|
||||
public interface SystemUserMapper extends BaseMapper<SystemUserTb> {
|
||||
List<SystemUserTb> selectUserByArgs(@Param("criteria") SystemQueryUserArgs criteria);
|
||||
|
||||
IPage<SystemUserTb> selectUserByArgs(@Param("criteria") SystemQueryUserArgs criteria, Page<SystemUserTb> page);
|
||||
|
||||
SystemUserTb getUserByUsername(@Param("username") String username);
|
||||
|
||||
SystemUserTb getUserByEmail(@Param("email") String email);
|
||||
|
||||
SystemUserTb getUserByPhone(@Param("phone") String phone);
|
||||
|
||||
List<SystemUserTb> selectUserByRoleId(@Param("roleId") Long roleId);
|
||||
|
||||
List<SystemUserTb> selectUserByDeptId(@Param("deptId") Long deptId);
|
||||
|
||||
List<SystemUserTb> selectUserByMenuId(@Param("menuId") Long menuId);
|
||||
|
||||
Long countUserByJobIds(@Param("jobIds") Set<Long> jobIds);
|
||||
|
||||
Long countUserByDeptIds(@Param("deptIds") Set<Long> deptIds);
|
||||
|
||||
Long countUserByRoleIds(@Param("roleIds") Set<Long> roleIds);
|
||||
|
||||
void updateUserPasswordByUsername(@Param("username") String username, @Param("password") String password);
|
||||
|
||||
void updateUserEmailByUsername(@Param("username") String username, @Param("email") String email);
|
||||
|
||||
void batchUpdatePassword(@Param("password") String password, @Param("userIds") Set<Long> userIds);
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.mysql;
|
||||
|
||||
import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Mapper
|
||||
public interface SystemUserRoleMapper {
|
||||
void batchInsertUserRole(@Param("roles") Set<SystemRoleTb> roles, @Param("userId") Long userId);
|
||||
|
||||
void batchDeleteUserRole(@Param("userIds") Set<Long> userIds);
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.dal.redis;
|
||||
|
||||
/**
|
||||
* 关于缓存的Key集合
|
||||
*/
|
||||
public interface SystemCacheKey {
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*/
|
||||
String USER_ID = "user::id:";
|
||||
|
||||
/**
|
||||
* 数据
|
||||
*/
|
||||
String DATA_USER = "data::user:";
|
||||
|
||||
/**
|
||||
* 菜单
|
||||
*/
|
||||
String MENU_ID = "menu::id:";
|
||||
String MENU_USER = "menu::user:";
|
||||
|
||||
/**
|
||||
* 角色授权
|
||||
*/
|
||||
String ROLE_AUTH = "role::auth:";
|
||||
String ROLE_USER = "role::user:";
|
||||
|
||||
/**
|
||||
* 角色信息
|
||||
*/
|
||||
String ROLE_ID = "role::id:";
|
||||
|
||||
/**
|
||||
* 部门
|
||||
*/
|
||||
String DEPT_ID = "dept::id:";
|
||||
|
||||
/**
|
||||
* 岗位
|
||||
*/
|
||||
String JOB_ID = "job::id:";
|
||||
|
||||
/**
|
||||
* 数据字典
|
||||
*/
|
||||
String DICT_NAME = "dict::name:";
|
||||
|
||||
/**
|
||||
* 在线用户
|
||||
*/
|
||||
String ONLINE_USER = "online::token:";
|
||||
|
||||
/**
|
||||
* 登录验证码
|
||||
*/
|
||||
String CAPTCHA_LOGIN = "captcha::login:";
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
String USER_INFO = "user::info:";
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package cn.odboy.system.dal.redis;
|
||||
|
||||
/**
|
||||
* 关于缓存的Key集合
|
||||
*/
|
||||
public interface SystemRedisKey {
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*/
|
||||
String USER_ID = "user::id:";
|
||||
|
||||
/**
|
||||
* 数据
|
||||
*/
|
||||
String DATA_USER = "data::user:";
|
||||
|
||||
/**
|
||||
* 菜单
|
||||
*/
|
||||
String MENU_ID = "menu::id:";
|
||||
String MENU_USER = "menu::user:";
|
||||
|
||||
/**
|
||||
* 角色授权
|
||||
*/
|
||||
String ROLE_AUTH = "role::auth:";
|
||||
String ROLE_USER = "role::user:";
|
||||
|
||||
/**
|
||||
* 角色信息
|
||||
*/
|
||||
String ROLE_ID = "role::id:";
|
||||
|
||||
/**
|
||||
* 部门
|
||||
*/
|
||||
String DEPT_ID = "dept::id:";
|
||||
|
||||
/**
|
||||
* 岗位
|
||||
*/
|
||||
String JOB_ID = "job::id:";
|
||||
|
||||
/**
|
||||
* 数据字典
|
||||
*/
|
||||
String DICT_NAME = "dict::name:";
|
||||
|
||||
/**
|
||||
* 在线用户
|
||||
*/
|
||||
String ONLINE_USER = "online::token:";
|
||||
|
||||
/**
|
||||
* 登录验证码
|
||||
*/
|
||||
String CAPTCHA_LOGIN = "captcha::login:";
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
String USER_INFO = "user::info:";
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
package cn.odboy.system.dal.redis;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.odboy.framework.redis.CsRedisHelper;
|
||||
import cn.odboy.system.dal.model.SystemUserJwtVo;
|
||||
import cn.odboy.util.CsStringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 用户缓存管理
|
||||
*/
|
||||
@Component
|
||||
public class SystemUserInfoDAO {
|
||||
@Autowired
|
||||
private CsRedisHelper redisHelper;
|
||||
|
||||
/**
|
||||
* 添加缓存到Redis
|
||||
*
|
||||
* @param userName 用户名
|
||||
*/
|
||||
@Async
|
||||
public void saveUserLoginInfoByUserName(String userName, SystemUserJwtVo user) {
|
||||
if (StrUtil.isNotEmpty(userName)) {
|
||||
// 添加数据, 避免数据同时过期(2小时左右)
|
||||
long time = 7200 + RandomUtil.randomInt(900, 1800);
|
||||
redisHelper.set(SystemRedisKey.USER_INFO + userName, user, time);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理用户缓存信息 用户信息变更时
|
||||
*
|
||||
* @param userName 用户名
|
||||
*/
|
||||
@Async
|
||||
public void deleteUserLoginInfoByUserName(String userName) {
|
||||
if (StrUtil.isNotEmpty(userName)) {
|
||||
// 清除数据
|
||||
redisHelper.del(SystemRedisKey.USER_INFO + userName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回用户缓存
|
||||
*
|
||||
* @param username 用户名
|
||||
* @return UserJwtVo
|
||||
*/
|
||||
|
||||
public SystemUserJwtVo getUserLoginInfoByUserName(String username) {
|
||||
if (StrUtil.isNotEmpty(username)) {
|
||||
// 获取数据
|
||||
return redisHelper.get(SystemRedisKey.USER_INFO + username, SystemUserJwtVo.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
package cn.odboy.system.dal.redis;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.odboy.base.CsPageResult;
|
||||
import cn.odboy.framework.properties.AppProperties;
|
||||
import cn.odboy.framework.redis.CsRedisHelper;
|
||||
import cn.odboy.system.dal.model.SystemUserJwtVo;
|
||||
import cn.odboy.system.dal.model.SystemUserOnlineVo;
|
||||
import cn.odboy.system.framework.permission.core.handler.TokenProvider;
|
||||
import cn.odboy.util.*;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class SystemUserOnlineInfoDAO {
|
||||
private final AppProperties properties;
|
||||
private final TokenProvider tokenProvider;
|
||||
private final CsRedisHelper redisHelper;
|
||||
|
||||
/**
|
||||
* 保存在线用户信息
|
||||
*
|
||||
* @param userJwtVo /
|
||||
* @param token /
|
||||
* @param request /
|
||||
*/
|
||||
|
||||
public void saveUserJwtModelByToken(SystemUserJwtVo userJwtVo, String token, HttpServletRequest request) {
|
||||
String dept = userJwtVo.getUser().getDept().getName();
|
||||
String ip = CsBrowserUtil.getIp(request);
|
||||
String id = tokenProvider.getId(token);
|
||||
String version = CsBrowserUtil.getVersion(request);
|
||||
String address = CsIPUtil.getCityInfo(ip);
|
||||
SystemUserOnlineVo userOnlineVo = null;
|
||||
try {
|
||||
userOnlineVo = new SystemUserOnlineVo();
|
||||
userOnlineVo.setUid(id);
|
||||
userOnlineVo.setUserName(userJwtVo.getUsername());
|
||||
userOnlineVo.setNickName(userJwtVo.getUser().getNickName());
|
||||
userOnlineVo.setDept(dept);
|
||||
userOnlineVo.setBrowser(version);
|
||||
userOnlineVo.setIp(ip);
|
||||
userOnlineVo.setAddress(address);
|
||||
userOnlineVo.setKey(CsDesEncryptUtil.desEncrypt(token));
|
||||
userOnlineVo.setLoginTime(new Date());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
String loginKey = tokenProvider.loginKey(token);
|
||||
redisHelper.set(loginKey, userOnlineVo, properties.getJwt().getTokenValidityInSeconds(), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*
|
||||
* @param token /
|
||||
*/
|
||||
|
||||
public void logoutByToken(String token) {
|
||||
String loginKey = tokenProvider.loginKey(token);
|
||||
redisHelper.del(loginKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出
|
||||
*
|
||||
* @param all /
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
|
||||
public void downloadUserOnlineModelExcel(List<SystemUserOnlineVo> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (SystemUserOnlineVo user : all) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("用户名", user.getUserName());
|
||||
map.put("部门", user.getDept());
|
||||
map.put("登录IP", user.getIp());
|
||||
map.put("登录地点", user.getAddress());
|
||||
map.put("浏览器", user.getBrowser());
|
||||
map.put("登录日期", user.getLoginTime());
|
||||
list.add(map);
|
||||
}
|
||||
CsFileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户名强退用户
|
||||
*
|
||||
* @param username /
|
||||
*/
|
||||
|
||||
public void kickOutByUsername(String username) {
|
||||
String loginKey = SystemRedisKey.ONLINE_USER + username + "*";
|
||||
redisHelper.scanDel(loginKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @param onlineVo /
|
||||
* @param pageable /
|
||||
* @return /
|
||||
*/
|
||||
|
||||
public CsPageResult<SystemUserOnlineVo> queryUserOnlineModelPage(SystemUserOnlineVo onlineVo, IPage<SystemUserOnlineVo> pageable) {
|
||||
String username = null;
|
||||
if (onlineVo != null) {
|
||||
username = onlineVo.getUserName();
|
||||
}
|
||||
List<SystemUserOnlineVo> onlineUserList = queryUserOnlineModelListByUsername(username);
|
||||
List<SystemUserOnlineVo> paging = CsPageUtil.softPaging(pageable.getCurrent(), pageable.getSize(), onlineUserList);
|
||||
return CsPageUtil.toPage(paging, onlineUserList.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部数据,不分页
|
||||
*
|
||||
* @param username /
|
||||
* @return /
|
||||
*/
|
||||
|
||||
public List<SystemUserOnlineVo> queryUserOnlineModelListByUsername(String username) {
|
||||
String loginKey = SystemRedisKey.ONLINE_USER + (StrUtil.isBlank(username) ? "" : "*" + username);
|
||||
List<String> keys = redisHelper.scan(loginKey + "*");
|
||||
Collections.reverse(keys);
|
||||
List<SystemUserOnlineVo> onlineUserList = new ArrayList<>();
|
||||
for (String key : keys) {
|
||||
onlineUserList.add(redisHelper.get(key, SystemUserOnlineVo.class));
|
||||
}
|
||||
onlineUserList.sort((o1, o2) -> o2.getLoginTime().compareTo(o1.getLoginTime()));
|
||||
return onlineUserList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户
|
||||
*
|
||||
* @param key /
|
||||
* @return /
|
||||
*/
|
||||
|
||||
public SystemUserOnlineVo queryUserOnlineModelByKey(String key) {
|
||||
return redisHelper.get(key, SystemUserOnlineVo.class);
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.framework.bizlock;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 业务锁
|
||||
*
|
||||
* @author odboy
|
||||
* @date 2025-08-14
|
||||
*/
|
||||
@Inherited
|
||||
@Documented
|
||||
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface BizLock {
|
||||
/**
|
||||
* 业务名称
|
||||
*/
|
||||
String bizName() default "";
|
||||
|
||||
/**
|
||||
* 锁key,支持SpEL表达式
|
||||
* 示例:
|
||||
* #user.id - 获取参数user的id属性
|
||||
* #p0 - 获取第一个参数
|
||||
* #root.methodName - 获取方法名
|
||||
*/
|
||||
String key() default "";
|
||||
|
||||
/**
|
||||
* 锁持有时间(秒),默认60秒。锁的持有时间,超过这个时间锁会自动释放
|
||||
*/
|
||||
long leaseTime() default 60;
|
||||
|
||||
/**
|
||||
* 时间单位,默认为秒
|
||||
*/
|
||||
TimeUnit timeUnit() default TimeUnit.SECONDS;
|
||||
|
||||
/**
|
||||
* 获取锁失败后的异常信息
|
||||
*/
|
||||
String errorMessage() default "操作太繁忙,请稍后再试";
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.framework.bizlock;
|
||||
|
||||
import cn.odboy.framework.exception.BadRequestException;
|
||||
import cn.odboy.framework.redis.CsRedisHelper;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.ExpressionParser;
|
||||
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 {
|
||||
private final CsRedisHelper redisHelper;
|
||||
private final ExpressionParser parser = new SpelExpressionParser();
|
||||
|
||||
public BizLockAspect(CsRedisHelper redisHelper) {
|
||||
this.redisHelper = redisHelper;
|
||||
}
|
||||
|
||||
@Around("@annotation(bizLock)")
|
||||
public Object around(ProceedingJoinPoint joinPoint, BizLock bizLock) throws Throwable {
|
||||
// 解析SpEL表达式生成最终的lockKey
|
||||
String lockKey = parseLockKey(joinPoint, bizLock);
|
||||
Boolean success = redisHelper.setIfAbsent(lockKey, lockKey, bizLock.leaseTime(), bizLock.timeUnit());
|
||||
if (success == null || !success) {
|
||||
throw new BadRequestException(bizLock.errorMessage());
|
||||
}
|
||||
try {
|
||||
return joinPoint.proceed();
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
} finally {
|
||||
redisHelper.del(lockKey);
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
// 解析SpEL表达式
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
|
||||
// 创建SpEL上下文
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
|
||||
// 设置方法参数
|
||||
String[] parameterNames = signature.getParameterNames();
|
||||
Object[] args = joinPoint.getArgs();
|
||||
for (int i = 0; i < parameterNames.length; i++) {
|
||||
context.setVariable(parameterNames[i], args[i]);
|
||||
context.setVariable("p" + i, args[i]); // 支持#p0,#p1格式
|
||||
}
|
||||
|
||||
// 设置方法相关信息
|
||||
context.setVariable("methodName", method.getName());
|
||||
context.setVariable("targetClass", joinPoint.getTarget().getClass().getName());
|
||||
|
||||
// 解析表达式
|
||||
Expression expression = parser.parseExpression(bizLock.key());
|
||||
String value = expression.getValue(context, String.class);
|
||||
|
||||
// 组合最终的key: bizName:解析后的key
|
||||
return String.format("%s:%s", bizLock.bizName(), value);
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.framework.mybatisplus;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.odboy.system.framework.permission.core.CsSecurityHelper;
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Component
|
||||
public class MpMetaObjectHandler implements MetaObjectHandler {
|
||||
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
DateTime now = DateTime.now();
|
||||
/* 创建时间 */
|
||||
this.strictInsertFill(metaObject, "createTime", Date.class, now);
|
||||
this.strictInsertFill(metaObject, "updateTime", Date.class, now);
|
||||
/* 操作人 */
|
||||
String username = "System";
|
||||
try {
|
||||
username = CsSecurityHelper.getCurrentUsername();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
this.strictInsertFill(metaObject, "createBy", String.class, username);
|
||||
this.strictInsertFill(metaObject, "updateBy", String.class, username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
/* 更新时间 */
|
||||
this.strictUpdateFill(metaObject, "updateTime", Date.class, DateTime.now());
|
||||
/* 操作人 */
|
||||
String username = "System";
|
||||
try {
|
||||
username = CsSecurityHelper.getCurrentUsername();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
this.strictUpdateFill(metaObject, "updateBy", String.class, username);
|
||||
}
|
||||
}
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.framework.operalog;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 捕捉操作日志
|
||||
*
|
||||
* @author odboy
|
||||
* @date 2025-05-12
|
||||
*/
|
||||
@Inherited
|
||||
@Documented
|
||||
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface OperationLog {
|
||||
String bizName() default "";
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.framework.operalog;
|
||||
|
||||
import cn.hutool.core.date.TimeInterval;
|
||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.odboy.framework.context.CsRequestHolder;
|
||||
import cn.odboy.system.dal.dataobject.SystemOperationLogTb;
|
||||
import cn.odboy.system.dal.mysql.SystemOperationLogMapper;
|
||||
import cn.odboy.system.framework.permission.core.CsSecurityHelper;
|
||||
import cn.odboy.util.CsBrowserUtil;
|
||||
import cn.odboy.util.CsIPUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* 捕捉操作日志
|
||||
*
|
||||
* @author odboy
|
||||
* @date 2025-05-12
|
||||
*/
|
||||
@Slf4j
|
||||
@Aspect
|
||||
@Component
|
||||
public class OperationLogAspect {
|
||||
@Autowired
|
||||
private SystemOperationLogMapper systemOperationLogMapper;
|
||||
|
||||
@Around("@annotation(operationLog)")
|
||||
public Object operationLogCatch(ProceedingJoinPoint joinPoint, OperationLog operationLog) throws Throwable {
|
||||
return handleLog(joinPoint, operationLog);
|
||||
}
|
||||
|
||||
private Object handleLog(ProceedingJoinPoint joinPoint, OperationLog annotation) throws Throwable {
|
||||
TimeInterval timeInterval = new TimeInterval();
|
||||
try {
|
||||
Object result = joinPoint.proceed();
|
||||
SystemOperationLogTb record = getOperationLogTb(joinPoint, annotation, timeInterval);
|
||||
ThreadUtil.execAsync(() -> {
|
||||
try {
|
||||
systemOperationLogMapper.insert(record);
|
||||
} catch (Exception e) {
|
||||
// 忽略
|
||||
}
|
||||
});
|
||||
return result;
|
||||
} catch (Throwable exception) {
|
||||
SystemOperationLogTb record = getOperationLogTb(joinPoint, annotation, timeInterval);
|
||||
record.setExceptionDetail(ExceptionUtil.stacktraceToString(exception));
|
||||
ThreadUtil.execAsync(() -> {
|
||||
try {
|
||||
systemOperationLogMapper.insert(record);
|
||||
} catch (Exception e) {
|
||||
// 忽略
|
||||
}
|
||||
});
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
private SystemOperationLogTb getOperationLogTb(ProceedingJoinPoint joinPoint, OperationLog annotation, TimeInterval timeInterval) {
|
||||
long executeTime = timeInterval.intervalMs();
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
String bizName = annotation.bizName();
|
||||
if (StrUtil.isBlank(bizName)) {
|
||||
Method method = signature.getMethod();
|
||||
ApiOperation apiOperation = method.getAnnotation(ApiOperation.class);
|
||||
if (apiOperation != null) {
|
||||
bizName = apiOperation.value();
|
||||
}
|
||||
}
|
||||
if (StrUtil.isBlank(bizName)) {
|
||||
bizName = "默认业务";
|
||||
}
|
||||
String method = joinPoint.getTarget().getClass().getName() + "." + signature.getName() + "()";
|
||||
Object[] args = joinPoint.getArgs();
|
||||
String params = JSON.toJSONString(args);
|
||||
HttpServletRequest request = CsRequestHolder.getHttpServletRequest();
|
||||
String requestIp = CsBrowserUtil.getIp(request);
|
||||
String browserInfo = CsBrowserUtil.getVersion(request);
|
||||
String address = CsIPUtil.getCityInfo(requestIp);
|
||||
String username = CsSecurityHelper.getCurrentUsername();
|
||||
SystemOperationLogTb record = new SystemOperationLogTb();
|
||||
record.setBizName(bizName);
|
||||
record.setMethod(method);
|
||||
record.setParams(params);
|
||||
record.setRequestIp(requestIp);
|
||||
record.setExecuteTime(executeTime);
|
||||
record.setUsername(username);
|
||||
record.setAddress(address);
|
||||
record.setBrowserInfo(browserInfo);
|
||||
return record;
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.odboy.system.framework.operalog.annotaions;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 捕捉操作日志
|
||||
*
|
||||
* @author odboy
|
||||
* @date 2025-05-12
|
||||
*/
|
||||
@Inherited
|
||||
@Documented
|
||||
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface OperationLog {
|
||||
String bizName() default "";
|
||||
}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.odboy.system.framework.operalog.core;
|
||||
|
||||
import cn.hutool.core.date.TimeInterval;
|
||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.odboy.framework.context.CsRequestHolder;
|
||||
import cn.odboy.system.dal.dataobject.SystemOperationLogTb;
|
||||
import cn.odboy.system.dal.mysql.SystemOperationLogMapper;
|
||||
import cn.odboy.system.framework.operalog.annotaions.OperationLog;
|
||||
import cn.odboy.system.framework.permission.core.CsSecurityHelper;
|
||||
import cn.odboy.util.CsBrowserUtil;
|
||||
import cn.odboy.util.CsIPUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* 捕捉操作日志
|
||||
*
|
||||
* @author odboy
|
||||
* @date 2025-05-12
|
||||
*/
|
||||
@Slf4j
|
||||
@Aspect
|
||||
@Component
|
||||
public class SystemOperationLogAspect {
|
||||
@Autowired
|
||||
private SystemOperationLogMapper systemOperationLogMapper;
|
||||
|
||||
@Around("@annotation(operationLog)")
|
||||
public Object operationLogCatch(ProceedingJoinPoint joinPoint, OperationLog operationLog) throws Throwable {
|
||||
return handleLog(joinPoint, operationLog);
|
||||
}
|
||||
|
||||
private Object handleLog(ProceedingJoinPoint joinPoint, OperationLog annotation) throws Throwable {
|
||||
TimeInterval timeInterval = new TimeInterval();
|
||||
try {
|
||||
Object result = joinPoint.proceed();
|
||||
SystemOperationLogTb record = getOperationLogTb(joinPoint, annotation, timeInterval);
|
||||
ThreadUtil.execAsync(() -> {
|
||||
try {
|
||||
systemOperationLogMapper.insert(record);
|
||||
} catch (Exception e) {
|
||||
// log.error("保存审计日志失败", e);
|
||||
// 忽略
|
||||
}
|
||||
});
|
||||
return result;
|
||||
} catch (Throwable exception) {
|
||||
SystemOperationLogTb record = getOperationLogTb(joinPoint, annotation, timeInterval);
|
||||
record.setExceptionDetail(ExceptionUtil.stacktraceToString(exception));
|
||||
ThreadUtil.execAsync(() -> {
|
||||
try {
|
||||
systemOperationLogMapper.insert(record);
|
||||
} catch (Exception e) {
|
||||
// log.error("保存审计日志失败", e);
|
||||
// 忽略
|
||||
}
|
||||
});
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
private SystemOperationLogTb getOperationLogTb(ProceedingJoinPoint joinPoint, OperationLog annotation, TimeInterval timeInterval) {
|
||||
long executeTime = timeInterval.intervalMs();
|
||||
MethodSignature signature = (MethodSignature)joinPoint.getSignature();
|
||||
String bizName = annotation.bizName();
|
||||
if (StrUtil.isBlank(bizName)) {
|
||||
Method method = signature.getMethod();
|
||||
ApiOperation apiOperation = method.getAnnotation(ApiOperation.class);
|
||||
if (apiOperation != null) {
|
||||
bizName = apiOperation.value();
|
||||
}
|
||||
}
|
||||
if (StrUtil.isBlank(bizName)) {
|
||||
bizName = "默认业务";
|
||||
}
|
||||
String method = joinPoint.getTarget().getClass().getName() + "." + signature.getName() + "()";
|
||||
Object[] args = joinPoint.getArgs();
|
||||
String params = JSON.toJSONString(args);
|
||||
HttpServletRequest request = CsRequestHolder.getHttpServletRequest();
|
||||
String requestIp = CsBrowserUtil.getIp(request);
|
||||
String browserInfo = CsBrowserUtil.getVersion(request);
|
||||
String address = CsIPUtil.getCityInfo(requestIp);
|
||||
String username = CsSecurityHelper.getCurrentUsername();
|
||||
SystemOperationLogTb record = new SystemOperationLogTb();
|
||||
record.setBizName(bizName);
|
||||
record.setMethod(method);
|
||||
record.setParams(params);
|
||||
record.setRequestIp(requestIp);
|
||||
record.setExecuteTime(executeTime);
|
||||
record.setUsername(username);
|
||||
record.setAddress(address);
|
||||
record.setBrowserInfo(browserInfo);
|
||||
return record;
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.framework.permission.config;
|
||||
|
||||
import cn.odboy.system.framework.permission.core.CsSecurityHelper;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service(value = "el")
|
||||
public class AuthorityConfig {
|
||||
|
||||
/**
|
||||
* 判断接口是否有权限
|
||||
*
|
||||
* @param permissions 权限
|
||||
* @return /
|
||||
*/
|
||||
public Boolean check(String... permissions) {
|
||||
// 获取当前用户的所有权限
|
||||
List<String> roleList = CsSecurityHelper.getCurrentUser().getAuthorities().stream().map(GrantedAuthority::getAuthority).collect(Collectors.toList());
|
||||
// 判断当前用户的所有权限是否包含接口上定义的权限
|
||||
return roleList.contains("admin") || Arrays.stream(permissions).anyMatch(roleList::contains);
|
||||
}
|
||||
}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.framework.permission.config;
|
||||
|
||||
import cn.odboy.constant.RequestMethodEnum;
|
||||
import cn.odboy.system.dal.redis.SystemUserOnlineInfoDAO;
|
||||
import cn.odboy.system.framework.permission.core.handler.JwtAccessDeniedHandler;
|
||||
import cn.odboy.system.framework.permission.core.handler.JwtAuthenticationEntryPoint;
|
||||
import cn.odboy.system.framework.permission.core.handler.TokenProvider;
|
||||
import cn.odboy.util.CsAnonTagUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.core.GrantedAuthorityDefaults;
|
||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
import org.springframework.web.filter.CorsFilter;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Configuration
|
||||
@EnableGlobalMethodSecurity(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;
|
||||
|
||||
@Bean
|
||||
public GrantedAuthorityDefaults grantedAuthorityDefaults() {
|
||||
// 去除 ROLE_ 前缀
|
||||
return new GrantedAuthorityDefaults("");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PasswordEncoder passwordEncoder() {
|
||||
// 密码加密方式
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
@Bean
|
||||
protected SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception {
|
||||
// 获取匿名标记
|
||||
Map<String, Set<String>> anonymousUrls = CsAnonTagUtil.getAnonymousUrl(applicationContext);
|
||||
return httpSecurity
|
||||
// 禁用 CSRF
|
||||
.csrf().disable().addFilter(corsFilter)
|
||||
// 授权异常
|
||||
.exceptionHandling().authenticationEntryPoint(authenticationErrorHandler).accessDeniedHandler(jwtAccessDeniedHandler)
|
||||
// 防止iframe 造成跨域
|
||||
.and().headers().frameOptions().disable()
|
||||
// 不创建会话
|
||||
.and().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and().authorizeRequests()
|
||||
// 静态资源等等
|
||||
.antMatchers(HttpMethod.GET, "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/websocket/**").permitAll()
|
||||
// swagger 文档
|
||||
.antMatchers("/swagger-ui.html").permitAll().antMatchers("/swagger-resources/**").permitAll().antMatchers("/webjars/**").permitAll().antMatchers("/*/api-docs").permitAll()
|
||||
// 文件
|
||||
.antMatchers("/avatar/**").permitAll().antMatchers("/file/**").permitAll()
|
||||
// 阿里巴巴 druid
|
||||
.antMatchers("/druid/**").permitAll()
|
||||
// 放行OPTIONS请求
|
||||
.antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
|
||||
// 自定义匿名访问所有url放行:允许匿名和带Token访问,细腻化到每个 Request 类型
|
||||
// GET
|
||||
.antMatchers(HttpMethod.GET, anonymousUrls.get(RequestMethodEnum.GET.getType()).toArray(new String[0])).permitAll()
|
||||
// POST
|
||||
.antMatchers(HttpMethod.POST, anonymousUrls.get(RequestMethodEnum.POST.getType()).toArray(new String[0])).permitAll()
|
||||
// PUT
|
||||
.antMatchers(HttpMethod.PUT, anonymousUrls.get(RequestMethodEnum.PUT.getType()).toArray(new String[0])).permitAll()
|
||||
// PATCH
|
||||
.antMatchers(HttpMethod.PATCH, anonymousUrls.get(RequestMethodEnum.PATCH.getType()).toArray(new String[0])).permitAll()
|
||||
// DELETE
|
||||
.antMatchers(HttpMethod.DELETE, anonymousUrls.get(RequestMethodEnum.DELETE.getType()).toArray(new String[0])).permitAll()
|
||||
// 所有类型的接口都放行
|
||||
.antMatchers(anonymousUrls.get(RequestMethodEnum.ALL.getType()).toArray(new String[0])).permitAll()
|
||||
// 所有请求都需要认证
|
||||
.anyRequest().authenticated().and().apply(securityConfigurerAdapter()).and().build();
|
||||
}
|
||||
|
||||
private TokenConfigurer securityConfigurerAdapter() {
|
||||
return new TokenConfigurer(tokenProvider, systemUserOnlineInfoDAO);
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.framework.permission.config;
|
||||
|
||||
import cn.odboy.system.dal.redis.SystemUserOnlineInfoDAO;
|
||||
import cn.odboy.system.framework.permission.core.handler.TokenFilter;
|
||||
import cn.odboy.system.framework.permission.core.handler.TokenProvider;
|
||||
import org.springframework.security.config.annotation.SecurityConfigurerAdapter;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.web.DefaultSecurityFilterChain;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
|
||||
public class TokenConfigurer extends SecurityConfigurerAdapter<DefaultSecurityFilterChain, HttpSecurity> {
|
||||
private final TokenProvider tokenProvider;
|
||||
private final SystemUserOnlineInfoDAO systemUserOnlineInfoDAO;
|
||||
|
||||
public TokenConfigurer(TokenProvider tokenProvider, SystemUserOnlineInfoDAO systemUserOnlineInfoDAO) {
|
||||
this.tokenProvider = tokenProvider;
|
||||
this.systemUserOnlineInfoDAO = systemUserOnlineInfoDAO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(HttpSecurity http) {
|
||||
TokenFilter customFilter = new TokenFilter(tokenProvider, systemUserOnlineInfoDAO);
|
||||
http.addFilterBefore(customFilter, UsernamePasswordAuthenticationFilter.class);
|
||||
}
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.framework.permission.core;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.jwt.JWT;
|
||||
import cn.hutool.jwt.JWTUtil;
|
||||
import cn.odboy.constant.SystemConst;
|
||||
import cn.odboy.framework.context.CsSpringBeanHolder;
|
||||
import cn.odboy.system.constant.SystemDataScopeEnum;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 获取当前登录的用户
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CsSecurityHelper {
|
||||
/**
|
||||
* 获取当前登录的用户
|
||||
*
|
||||
* @return UserDetails
|
||||
*/
|
||||
public static UserDetails getCurrentUser() {
|
||||
UserDetailsService userDetailsService = CsSpringBeanHolder.getBean(UserDetailsService.class);
|
||||
return userDetailsService.loadUserByUsername(getCurrentUsername());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户的数据权限
|
||||
*
|
||||
* @return /
|
||||
*/
|
||||
public static List<Long> getCurrentUserDataScope() {
|
||||
UserDetails userDetails = getCurrentUser();
|
||||
// 将 Java 对象转换为 JSONObject 对象
|
||||
JSONObject jsonObject = (JSONObject) JSON.toJSON(userDetails);
|
||||
JSONArray jsonArray = jsonObject.getJSONArray("dataScopes");
|
||||
return JSON.parseArray(jsonArray.toJSONString(), Long.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据权限级别
|
||||
*
|
||||
* @return 级别
|
||||
*/
|
||||
public static String getDataScopeType() {
|
||||
List<Long> dataScopes = getCurrentUserDataScope();
|
||||
if (CollUtil.isEmpty(dataScopes)) {
|
||||
return "";
|
||||
}
|
||||
return SystemDataScopeEnum.ALL.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户ID
|
||||
*
|
||||
* @return 系统用户ID
|
||||
*/
|
||||
public static Long getCurrentUserId() {
|
||||
return getCurrentUserId(getToken());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户ID
|
||||
*
|
||||
* @return 系统用户ID
|
||||
*/
|
||||
public static Long getCurrentUserId(String token) {
|
||||
JWT jwt = JWTUtil.parseToken(token);
|
||||
return Long.valueOf(jwt.getPayload("userId").toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统用户名称
|
||||
*
|
||||
* @return 系统用户名称
|
||||
*/
|
||||
public static String getCurrentUsername() {
|
||||
return getCurrentUsername(getToken());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统用户名称
|
||||
*
|
||||
* @return 系统用户名称
|
||||
*/
|
||||
public static String getCurrentUsername(String token) {
|
||||
JWT jwt = JWTUtil.parseToken(token);
|
||||
return jwt.getPayload("sub").toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Token
|
||||
*
|
||||
* @return /
|
||||
*/
|
||||
public static String getToken() {
|
||||
HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
|
||||
String bearerToken = request.getHeader(SystemConst.HEADER_NAME);
|
||||
if (bearerToken != null && bearerToken.startsWith(SystemConst.TOKEN_PREFIX)) {
|
||||
// 去掉令牌前缀
|
||||
return bearerToken.replace(SystemConst.TOKEN_PREFIX, "");
|
||||
} else {
|
||||
log.debug("非法Token:{}", bearerToken);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.framework.permission.core.handler;
|
||||
|
||||
import cn.odboy.framework.exception.handler.ApiError;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.security.web.access.AccessDeniedHandler;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
@Component
|
||||
public class JwtAccessDeniedHandler implements AccessDeniedHandler {
|
||||
|
||||
@Override
|
||||
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(), "禁止访问,您没有权限访问此资源"));
|
||||
response.getWriter().write(jsonResponse);
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.framework.permission.core.handler;
|
||||
|
||||
import cn.odboy.framework.exception.handler.ApiError;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
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 javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint {
|
||||
|
||||
@Override
|
||||
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(), "登录状态已过期,请重新登录"));
|
||||
response.getWriter().write(jsonResponse);
|
||||
}
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.framework.permission.core.handler;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.odboy.constant.SystemConst;
|
||||
import cn.odboy.system.dal.model.SystemUserOnlineVo;
|
||||
import cn.odboy.system.dal.redis.SystemUserOnlineInfoDAO;
|
||||
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 javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
|
||||
@Slf4j
|
||||
public class TokenFilter extends GenericFilterBean {
|
||||
private final TokenProvider tokenProvider;
|
||||
private final SystemUserOnlineInfoDAO systemUserOnlineInfoDAO;
|
||||
|
||||
/**
|
||||
* @param tokenProvider Token
|
||||
* @param systemUserOnlineInfoDAO 用户在线
|
||||
*/
|
||||
public TokenFilter(TokenProvider tokenProvider, SystemUserOnlineInfoDAO systemUserOnlineInfoDAO) {
|
||||
this.systemUserOnlineInfoDAO = systemUserOnlineInfoDAO;
|
||||
this.tokenProvider = tokenProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws ServletException, IOException {
|
||||
HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
|
||||
String token = resolveToken(httpServletRequest);
|
||||
// 对于 Token 为空的不需要去查 Redis
|
||||
if (StrUtil.isNotBlank(token)) {
|
||||
// 获取用户Token的Key
|
||||
String loginKey = tokenProvider.loginKey(token);
|
||||
SystemUserOnlineVo userOnlineVo = systemUserOnlineInfoDAO.queryUserOnlineModelByKey(loginKey);
|
||||
// 判断用户在线信息是否为空
|
||||
if (userOnlineVo != null) {
|
||||
// Token 续期判断
|
||||
tokenProvider.checkRenewal(token);
|
||||
// 获取认证信息,设置上下文
|
||||
Authentication authentication = tokenProvider.getAuthentication(token);
|
||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
}
|
||||
}
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初步检测Token
|
||||
*
|
||||
* @param request /
|
||||
* @return /
|
||||
*/
|
||||
private String resolveToken(HttpServletRequest request) {
|
||||
String bearerToken = request.getHeader(SystemConst.HEADER_NAME);
|
||||
if (StringUtils.hasText(bearerToken) && bearerToken.startsWith(SystemConst.TOKEN_PREFIX)) {
|
||||
// 去掉令牌前缀
|
||||
return bearerToken.replace(SystemConst.TOKEN_PREFIX + " ", "");
|
||||
} else {
|
||||
log.debug("非法Token:{}", bearerToken);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+167
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.framework.permission.core.handler;
|
||||
|
||||
import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.odboy.constant.SystemConst;
|
||||
import cn.odboy.framework.properties.AppProperties;
|
||||
import cn.odboy.framework.redis.CsRedisHelper;
|
||||
import cn.odboy.system.dal.model.SystemUserJwtVo;
|
||||
import cn.odboy.system.dal.redis.SystemCacheKey;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.JwtParser;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.io.Decoders;
|
||||
import io.jsonwebtoken.security.Keys;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
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 {
|
||||
@Autowired
|
||||
private CsRedisHelper redisHelper;
|
||||
@Autowired
|
||||
private AppProperties properties;
|
||||
// 0.11.x版本
|
||||
// private Key signingKey;
|
||||
// 0.12.x版本
|
||||
private SecretKey signingKey;
|
||||
private JwtParser jwtParser;
|
||||
public static final String AUTHORITIES_UUID_KEY = "uid";
|
||||
public static final String AUTHORITIES_UID_KEY = "userId";
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
// 解码Base64密钥并创建签名密钥
|
||||
byte[] keyBytes = Decoders.BASE64.decode(properties.getJwt().getBase64Secret());
|
||||
signingKey = Keys.hmacShaKeyFor(keyBytes);
|
||||
// 0.11.x版本
|
||||
// jwtParser = Jwts.parserBuilder()
|
||||
// // 使用预生成的签名密钥
|
||||
// .setSigningKey(signingKey).build();
|
||||
// 0.12.x版本
|
||||
jwtParser = Jwts.parser().verifyWith(signingKey).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建Token 设置永不过期, Token 的时间有效性转到Redis 维护
|
||||
*
|
||||
* @param user /
|
||||
* @return /
|
||||
*/
|
||||
public String createToken(SystemUserJwtVo user) {
|
||||
// 设置参数
|
||||
Map<String, Object> claims = new HashMap<>(6);
|
||||
// 设置用户ID
|
||||
claims.put(AUTHORITIES_UID_KEY, user.getUser().getId());
|
||||
// 设置UUID,确保每次Token不一样
|
||||
claims.put(AUTHORITIES_UUID_KEY, IdUtil.simpleUUID());
|
||||
// 0.11.x版本
|
||||
// 直接调用 Jwts.builder() 创建新实例Add commentMore actions
|
||||
// return Jwts.builder()
|
||||
// // 设置自定义 Claims
|
||||
// .setClaims(claims)
|
||||
// // 设置主题
|
||||
// .setSubject(user.getUsername())
|
||||
// // 使用预生成的签名密钥和算法签名
|
||||
// .signWith(signingKey, SignatureAlgorithm.HS512).compact();
|
||||
// 0.12.x版本
|
||||
return Jwts.builder().claims(claims).subject(user.getUsername()).signWith(signingKey).compact();
|
||||
}
|
||||
|
||||
/**
|
||||
* 依据Token 获取鉴权信息
|
||||
*
|
||||
* @param token /
|
||||
* @return /
|
||||
*/
|
||||
Authentication getAuthentication(String token) {
|
||||
Claims claims = getClaims(token);
|
||||
User principal = new User(claims.getSubject(), "******", new ArrayList<>());
|
||||
return new UsernamePasswordAuthenticationToken(principal, token, new ArrayList<>());
|
||||
}
|
||||
|
||||
public Claims getClaims(String token) {
|
||||
// 0.11.x版本
|
||||
// return jwtParser.parseClaimsJws(token).getBody();
|
||||
// 0.12.x版本
|
||||
return jwtParser.parseSignedClaims(token).getPayload();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param token 需要检查的token
|
||||
*/
|
||||
public void checkRenewal(String token) {
|
||||
// 判断是否续期token,计算token的过期时间
|
||||
String loginKey = loginKey(token);
|
||||
long time = redisHelper.getExpire(loginKey) * 1000;
|
||||
Date expireDate = DateUtil.offset(new Date(), DateField.MILLISECOND, (int) time);
|
||||
// 判断当前时间与过期时间的时间差
|
||||
long differ = expireDate.getTime() - System.currentTimeMillis();
|
||||
// 如果在续期检查的范围内,则续期
|
||||
if (differ <= properties.getJwt().getDetect()) {
|
||||
long renew = time + properties.getJwt().getRenew();
|
||||
redisHelper.expire(loginKey, renew, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
public String getToken(HttpServletRequest request) {
|
||||
final String requestHeader = request.getHeader(SystemConst.HEADER_NAME);
|
||||
if (requestHeader != null && requestHeader.startsWith(SystemConst.TOKEN_PREFIX)) {
|
||||
return requestHeader.substring(7);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录用户RedisKey
|
||||
*
|
||||
* @param token /
|
||||
* @return key
|
||||
*/
|
||||
public String loginKey(String token) {
|
||||
Claims claims = getClaims(token);
|
||||
return SystemCacheKey.ONLINE_USER + claims.getSubject() + ":" + getId(token);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会话编号
|
||||
*
|
||||
* @param token /
|
||||
* @return /
|
||||
*/
|
||||
public String getId(String token) {
|
||||
Claims claims = getClaims(token);
|
||||
return claims.get(AUTHORITIES_UUID_KEY, String.class);
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright 2021-2025 Odboy
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.odboy.system.framework.permission.core.handler;
|
||||
|
||||
import cn.odboy.framework.exception.BadRequestException;
|
||||
import cn.odboy.system.dal.dataobject.SystemUserTb;
|
||||
import cn.odboy.system.dal.model.SystemRoleCodeVo;
|
||||
import cn.odboy.system.dal.model.SystemUserJwtVo;
|
||||
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 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;
|
||||
|
||||
@Override
|
||||
public SystemUserJwtVo loadUserByUsername(String username) {
|
||||
SystemUserJwtVo userJwtVo = systemUserInfoDAO.getUserLoginInfoByUserName(username);
|
||||
if (userJwtVo == null) {
|
||||
SystemUserTb user = systemUserService.getUserByUsername(username);
|
||||
if (user == null) {
|
||||
throw new BadRequestException("用户不存在");
|
||||
} else {
|
||||
if (!user.getEnabled()) {
|
||||
throw new BadRequestException("账号未激活");
|
||||
}
|
||||
// 获取用户的权限
|
||||
List<SystemRoleCodeVo> authorities = systemRoleService.buildUserRolePermissions(user);
|
||||
// 初始化JwtUserDto
|
||||
userJwtVo = new SystemUserJwtVo(user, systemDataService.queryDeptIdListByArgs(user), authorities);
|
||||
// 添加缓存数据
|
||||
systemUserInfoDAO.saveUserLoginInfoByUserName(username, userJwtVo);
|
||||
}
|
||||
}
|
||||
return userJwtVo;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user