refactor(util): 移除废弃类并优化验证工具类
- 删除 TaskTemplateInfoVo 类 - 删除 ServerException 类 - 删除 KitDistributedIdUtil 类 - 删除 SystemQuartzJobVo 类 - 在 KitBigDecimalUtil 中新增格式化金额方法 - 在 KitDateUtil 中新增获取周几方法 - 在 KitCollUtil 中修复空集合验证逻辑 - 移除 KitStringUtil 中的日期相关代码 - 在 KitValidUtil 中新增多种验证方法 - 修改 SystemMenuController 中的菜单保存逻辑 - 优化 SystemQuartzJobController 中的定时任务操作方法 - 为 SystemQuartzJobTb 添加扩展字段 uuid
This commit is contained in:
+1
-3
@@ -13,13 +13,11 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cn.odboy.framework.exception;
|
package cn.odboy.framework.exception;
|
||||||
|
|
||||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 统一异常处理
|
* 统一异常处理
|
||||||
|
|||||||
+1
-3
@@ -13,13 +13,11 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cn.odboy.framework.exception;
|
package cn.odboy.framework.exception;
|
||||||
|
|
||||||
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class ServerException extends RuntimeException {
|
public class ServerException extends RuntimeException {
|
||||||
|
|||||||
-3
@@ -13,7 +13,6 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cn.odboy.framework.exception.handler;
|
package cn.odboy.framework.exception.handler;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -42,5 +41,3 @@ public final class ApiError {
|
|||||||
return apiError;
|
return apiError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -13,7 +13,6 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cn.odboy.framework.exception.handler;
|
package cn.odboy.framework.exception.handler;
|
||||||
|
|
||||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||||
@@ -77,8 +76,8 @@ public class GlobalExceptionHandler {
|
|||||||
log.error(ExceptionUtil.stacktraceToString(e));
|
log.error(ExceptionUtil.stacktraceToString(e));
|
||||||
ObjectError objectError = e.getBindingResult().getAllErrors().get(0);
|
ObjectError objectError = e.getBindingResult().getAllErrors().get(0);
|
||||||
String message = objectError.getDefaultMessage();
|
String message = objectError.getDefaultMessage();
|
||||||
if (objectError instanceof FieldError fieldError) {
|
if (objectError instanceof FieldError) {
|
||||||
message = fieldError.getField() + ": " + message;
|
message = ((FieldError) objectError).getField() + ": " + message;
|
||||||
}
|
}
|
||||||
return buildResponseEntity(ApiError.error(message));
|
return buildResponseEntity(ApiError.error(message));
|
||||||
}
|
}
|
||||||
|
|||||||
+52
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package cn.odboy.framework.properties;
|
||||||
|
|
||||||
|
import cn.odboy.framework.properties.model.CaptchaModel;
|
||||||
|
import cn.odboy.framework.properties.model.ContentRsaEncodeSettingModel;
|
||||||
|
import cn.odboy.framework.properties.model.JwtAuthSettingModel;
|
||||||
|
import cn.odboy.framework.properties.model.StorageOSSModel;
|
||||||
|
import cn.odboy.framework.properties.model.SwaggerApiDocSettingModel;
|
||||||
|
import cn.odboy.framework.properties.model.ThreadPoolSettingModel;
|
||||||
|
import cn.odboy.framework.properties.model.UserLoginSettingModel;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用配置
|
||||||
|
*
|
||||||
|
* @author odboy
|
||||||
|
* @date 2025-04-13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Component
|
||||||
|
@ConfigurationProperties(prefix = "app")
|
||||||
|
public class AppProperties {
|
||||||
|
|
||||||
|
private ContentRsaEncodeSettingModel rsa;
|
||||||
|
private JwtAuthSettingModel jwt;
|
||||||
|
private UserLoginSettingModel login;
|
||||||
|
private SwaggerApiDocSettingModel swagger;
|
||||||
|
private ThreadPoolSettingModel asyncTaskPool;
|
||||||
|
private CaptchaModel captcha;
|
||||||
|
private StorageOSSModel oss;
|
||||||
|
/**
|
||||||
|
* 自动识别json对象白名单配置(仅允许解析的包名, 范围越小越安全)<br/> 未配置可能导致, 登录失败, 反复登录等问题
|
||||||
|
*/
|
||||||
|
private List<String> serialWhiteList;
|
||||||
|
}
|
||||||
+6
-9
@@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package cn.odboy.task.dal.model;
|
package cn.odboy.framework.properties.model;
|
||||||
|
|
||||||
import cn.odboy.base.KitObject;
|
import cn.odboy.base.KitObject;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -21,13 +21,10 @@ import lombok.Setter;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class TaskTemplateInfoVo extends KitObject {
|
public class CaptchaModel extends KitObject {
|
||||||
|
|
||||||
private String changeType;
|
/**
|
||||||
private String name;
|
* 验证码有效时间, 单位: 秒
|
||||||
private String description;
|
*/
|
||||||
private String envAlias;
|
private Long expireTime;
|
||||||
private String language;
|
|
||||||
private String contextName;
|
|
||||||
private String templateInfo;
|
|
||||||
}
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package cn.odboy.framework.properties.model;
|
||||||
|
|
||||||
|
import cn.odboy.base.KitObject;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密码加密传输, 前端公钥加密,后端私钥解密
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class ContentRsaEncodeSettingModel extends KitObject {
|
||||||
|
|
||||||
|
private String privateKey;
|
||||||
|
}
|
||||||
+45
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package cn.odboy.framework.properties.model;
|
||||||
|
|
||||||
|
import cn.odboy.base.KitObject;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Jwt参数配置
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class JwtAuthSettingModel extends KitObject {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 必须使用最少88位的Base64对该令牌进行编码
|
||||||
|
*/
|
||||||
|
private String base64Secret;
|
||||||
|
/**
|
||||||
|
* 令牌过期时间 此处单位/毫秒
|
||||||
|
*/
|
||||||
|
private Long tokenValidityInSeconds;
|
||||||
|
/**
|
||||||
|
* token 续期检查
|
||||||
|
*/
|
||||||
|
private Long detect;
|
||||||
|
/**
|
||||||
|
* 续期时间
|
||||||
|
*/
|
||||||
|
private Long renew;
|
||||||
|
}
|
||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package cn.odboy.framework.properties.model;
|
||||||
|
|
||||||
|
import cn.odboy.base.KitObject;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class OSSConfigModel extends KitObject {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务地址
|
||||||
|
*/
|
||||||
|
private String endpoint;
|
||||||
|
/**
|
||||||
|
* 存储桶名称
|
||||||
|
*/
|
||||||
|
private String bucketName;
|
||||||
|
/**
|
||||||
|
* Access Key
|
||||||
|
*/
|
||||||
|
private String accessKey;
|
||||||
|
/**
|
||||||
|
* Secret Key
|
||||||
|
*/
|
||||||
|
private String secretKey;
|
||||||
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package cn.odboy.framework.properties.model;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class StorageOSSModel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传大小, 单位: M
|
||||||
|
*/
|
||||||
|
private Long maxSize;
|
||||||
|
private OSSConfigModel minio;
|
||||||
|
}
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package cn.odboy.framework.properties.model;
|
||||||
|
|
||||||
|
import cn.odboy.base.KitObject;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author odboy
|
||||||
|
* @date 2025-04-13
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class SwaggerApiDocSettingModel extends KitObject {
|
||||||
|
|
||||||
|
private Boolean enabled;
|
||||||
|
}
|
||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package cn.odboy.framework.properties.model;
|
||||||
|
|
||||||
|
import cn.odboy.base.KitObject;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 线程池 配置
|
||||||
|
*
|
||||||
|
* @author odboy
|
||||||
|
* @date 2025-04-13
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class ThreadPoolSettingModel extends KitObject {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 核心线程池大小
|
||||||
|
*/
|
||||||
|
private int corePoolSize;
|
||||||
|
/**
|
||||||
|
* 最大线程数
|
||||||
|
*/
|
||||||
|
private int maxPoolSize;
|
||||||
|
/**
|
||||||
|
* 活跃时间
|
||||||
|
*/
|
||||||
|
private int keepAliveSeconds;
|
||||||
|
/**
|
||||||
|
* 队列容量
|
||||||
|
*/
|
||||||
|
private int queueCapacity;
|
||||||
|
}
|
||||||
+126
@@ -0,0 +1,126 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package cn.odboy.framework.properties.model;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.odboy.base.KitObject;
|
||||||
|
import cn.odboy.constant.CaptchaCodeEnum;
|
||||||
|
import cn.odboy.framework.exception.BadRequestException;
|
||||||
|
import com.wf.captcha.ArithmeticCaptcha;
|
||||||
|
import com.wf.captcha.ChineseCaptcha;
|
||||||
|
import com.wf.captcha.ChineseGifCaptcha;
|
||||||
|
import com.wf.captcha.GifCaptcha;
|
||||||
|
import com.wf.captcha.SpecCaptcha;
|
||||||
|
import com.wf.captcha.base.Captcha;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证码配置
|
||||||
|
*
|
||||||
|
* @author odboy
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class UserLoginCaptchaSettingModel extends KitObject {
|
||||||
|
|
||||||
|
private CaptchaCodeEnum codeType;
|
||||||
|
/**
|
||||||
|
* 验证码有效期 分钟
|
||||||
|
*/
|
||||||
|
private Long expiration = 5L;
|
||||||
|
/**
|
||||||
|
* 验证码内容长度
|
||||||
|
*/
|
||||||
|
private int length = 4;
|
||||||
|
/**
|
||||||
|
* 验证码宽度
|
||||||
|
*/
|
||||||
|
private int width = 111;
|
||||||
|
/**
|
||||||
|
* 验证码高度
|
||||||
|
*/
|
||||||
|
private int height = 36;
|
||||||
|
/**
|
||||||
|
* 验证码字体
|
||||||
|
*/
|
||||||
|
private String fontName;
|
||||||
|
/**
|
||||||
|
* 字体大小
|
||||||
|
*/
|
||||||
|
private int fontSize = 25;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 依据配置信息生产验证码
|
||||||
|
*
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
public Captcha getCaptcha() {
|
||||||
|
Captcha captcha;
|
||||||
|
switch (codeType) {
|
||||||
|
case ARITHMETIC:
|
||||||
|
// 算术类型 https://gitee.com/whvse/EasyCaptcha
|
||||||
|
captcha = new FixedArithmeticCaptcha(width, height);
|
||||||
|
// 几位数运算, 默认是两位
|
||||||
|
captcha.setLen(length);
|
||||||
|
break;
|
||||||
|
case CHINESE:
|
||||||
|
captcha = new ChineseCaptcha(width, height);
|
||||||
|
captcha.setLen(length);
|
||||||
|
break;
|
||||||
|
case CHINESE_GIF:
|
||||||
|
captcha = new ChineseGifCaptcha(width, height);
|
||||||
|
captcha.setLen(length);
|
||||||
|
break;
|
||||||
|
case GIF:
|
||||||
|
captcha = new GifCaptcha(width, height);
|
||||||
|
captcha.setLen(length);
|
||||||
|
break;
|
||||||
|
case SPEC:
|
||||||
|
captcha = new SpecCaptcha(width, height);
|
||||||
|
captcha.setLen(length);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new BadRequestException("验证码配置信息错误!正确配置查看 LoginCodeEnum ");
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(fontName)) {
|
||||||
|
captcha.setFont(new Font(fontName, Font.PLAIN, fontSize));
|
||||||
|
}
|
||||||
|
return captcha;
|
||||||
|
}
|
||||||
|
|
||||||
|
static class FixedArithmeticCaptcha extends ArithmeticCaptcha {
|
||||||
|
|
||||||
|
public FixedArithmeticCaptcha(int width, int height) {
|
||||||
|
super(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected char[] alphas() {
|
||||||
|
// 生成随机数字和运算符
|
||||||
|
int n1 = num(1, 10), n2 = num(1, 10);
|
||||||
|
int opt = num(3);
|
||||||
|
// 计算结果
|
||||||
|
int res = new int[]{n1 + n2, n1 - n2, n1 * n2}[opt];
|
||||||
|
// 转换为字符运算符
|
||||||
|
char optChar = "+-x".charAt(opt);
|
||||||
|
this.setArithmeticString(String.format("%s%c%s=?", n1, optChar, n2));
|
||||||
|
this.chars = String.valueOf(res);
|
||||||
|
return chars.toCharArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package cn.odboy.framework.properties.model;
|
||||||
|
|
||||||
|
import cn.odboy.base.KitObject;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录配置
|
||||||
|
*
|
||||||
|
* @author odboy
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class UserLoginSettingModel extends KitObject {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 账号单用户 登录
|
||||||
|
*/
|
||||||
|
private boolean single = false;
|
||||||
|
private UserLoginCaptchaSettingModel captchaSetting;
|
||||||
|
}
|
||||||
+19
-21
@@ -17,6 +17,14 @@ package cn.odboy.util;
|
|||||||
|
|
||||||
import cn.odboy.annotation.AnonymousAccess;
|
import cn.odboy.annotation.AnonymousAccess;
|
||||||
import cn.odboy.constant.RequestMethodEnum;
|
import cn.odboy.constant.RequestMethodEnum;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.method.HandlerMethod;
|
||||||
|
import org.springframework.web.servlet.mvc.condition.PathPatternsRequestCondition;
|
||||||
|
import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition;
|
||||||
|
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
|
||||||
|
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -24,13 +32,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.method.HandlerMethod;
|
|
||||||
import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition;
|
|
||||||
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
|
|
||||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 匿名标记工具
|
* 匿名标记工具
|
||||||
@@ -45,10 +46,9 @@ public class KitAnonTagUtil {
|
|||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public static Map<String, Set<String>> getAnonymousUrl(final ApplicationContext applicationContext) {
|
public static Map<String, Set<String>> getAnonymousUrl(final ApplicationContext applicationContext) {
|
||||||
RequestMappingHandlerMapping requestMappingHandlerMapping =
|
RequestMappingHandlerMapping requestMappingHandlerMapping = (RequestMappingHandlerMapping) applicationContext.getBean("requestMappingHandlerMapping");
|
||||||
(RequestMappingHandlerMapping) applicationContext.getBean("requestMappingHandlerMapping");
|
|
||||||
Map<RequestMappingInfo, HandlerMethod> handlerMethodMap = requestMappingHandlerMapping.getHandlerMethods();
|
Map<RequestMappingInfo, HandlerMethod> handlerMethodMap = requestMappingHandlerMapping.getHandlerMethods();
|
||||||
Map<String, java.util.Set<String>> anonymousUrls = new HashMap<>(8);
|
Map<String, Set<String>> anonymousUrls = new HashMap<>(8);
|
||||||
// 获取匿名标记
|
// 获取匿名标记
|
||||||
Set<String> get = new HashSet<>();
|
Set<String> get = new HashSet<>();
|
||||||
Set<String> post = new HashSet<>();
|
Set<String> post = new HashSet<>();
|
||||||
@@ -60,30 +60,28 @@ public class KitAnonTagUtil {
|
|||||||
HandlerMethod handlerMethod = infoEntry.getValue();
|
HandlerMethod handlerMethod = infoEntry.getValue();
|
||||||
AnonymousAccess anonymousAccess = handlerMethod.getMethodAnnotation(AnonymousAccess.class);
|
AnonymousAccess anonymousAccess = handlerMethod.getMethodAnnotation(AnonymousAccess.class);
|
||||||
if (null != anonymousAccess && infoEntry.getKey() != null) {
|
if (null != anonymousAccess && infoEntry.getKey() != null) {
|
||||||
List<RequestMethod> requestMethods =
|
List<RequestMethod> requestMethods = new ArrayList<>(infoEntry.getKey().getMethodsCondition().getMethods());
|
||||||
new ArrayList<>(infoEntry.getKey().getMethodsCondition().getMethods());
|
RequestMethodEnum request = RequestMethodEnum.find(requestMethods.isEmpty() ? RequestMethodEnum.ALL.getType() : requestMethods.get(0).name());
|
||||||
RequestMethodEnum request = RequestMethodEnum.find(
|
PathPatternsRequestCondition patternsCondition = infoEntry.getKey().getPathPatternsCondition();
|
||||||
requestMethods.isEmpty() ? RequestMethodEnum.ALL.getType() : requestMethods.get(0).name());
|
|
||||||
PatternsRequestCondition patternsCondition = infoEntry.getKey().getPatternsCondition();
|
|
||||||
if (patternsCondition != null) {
|
if (patternsCondition != null) {
|
||||||
switch (Objects.requireNonNull(request)) {
|
switch (Objects.requireNonNull(request)) {
|
||||||
case GET:
|
case GET:
|
||||||
get.addAll(patternsCondition.getPatterns());
|
get.addAll(patternsCondition.getPatternValues());
|
||||||
break;
|
break;
|
||||||
case POST:
|
case POST:
|
||||||
post.addAll(patternsCondition.getPatterns());
|
post.addAll(patternsCondition.getPatternValues());
|
||||||
break;
|
break;
|
||||||
case PUT:
|
case PUT:
|
||||||
put.addAll(patternsCondition.getPatterns());
|
put.addAll(patternsCondition.getPatternValues());
|
||||||
break;
|
break;
|
||||||
case PATCH:
|
case PATCH:
|
||||||
patch.addAll(patternsCondition.getPatterns());
|
patch.addAll(patternsCondition.getPatternValues());
|
||||||
break;
|
break;
|
||||||
case DELETE:
|
case DELETE:
|
||||||
delete.addAll(patternsCondition.getPatterns());
|
delete.addAll(patternsCondition.getPatternValues());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
all.addAll(patternsCondition.getPatterns());
|
all.addAll(patternsCondition.getPatternValues());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -17,8 +17,8 @@ package cn.odboy.util;
|
|||||||
|
|
||||||
import cn.hutool.core.codec.Base64Encoder;
|
import cn.hutool.core.codec.Base64Encoder;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加密令牌生成工具
|
* 加密令牌生成工具
|
||||||
|
|||||||
+1
-1
@@ -17,10 +17,10 @@ package cn.odboy.util;
|
|||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.bean.copier.CopyOptions;
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bean拷贝相关
|
* Bean拷贝相关
|
||||||
|
|||||||
+19
-1
@@ -15,9 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package cn.odboy.util;
|
package cn.odboy.util;
|
||||||
|
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import lombok.experimental.UtilityClass;
|
import java.text.NumberFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算类
|
* 计算类
|
||||||
@@ -133,6 +134,23 @@ public final class KitBigDecimalUtil {
|
|||||||
return yuan.multiply(BigDecimal.valueOf(100)).setScale(0, RoundingMode.HALF_UP).longValue();
|
return yuan.multiply(BigDecimal.valueOf(100)).setScale(0, RoundingMode.HALF_UP).longValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化为 xxx,xxx,xxx 格式
|
||||||
|
*
|
||||||
|
* @param obj 金额
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
public static String formatGroupingAmount(Object obj) {
|
||||||
|
if (obj == null) {
|
||||||
|
return "0";
|
||||||
|
}
|
||||||
|
BigDecimal bigDecimal = toBigDecimal(obj);
|
||||||
|
NumberFormat nf = NumberFormat.getInstance();
|
||||||
|
// 启用千位分隔符
|
||||||
|
nf.setGroupingUsed(true);
|
||||||
|
return nf.format(bigDecimal.setScale(0, RoundingMode.HALF_UP));
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
BigDecimal num1 = new BigDecimal("10.123");
|
BigDecimal num1 = new BigDecimal("10.123");
|
||||||
BigDecimal num2 = new BigDecimal("2.456");
|
BigDecimal num2 = new BigDecimal("2.456");
|
||||||
|
|||||||
+3
-3
@@ -17,11 +17,11 @@ package cn.odboy.util;
|
|||||||
|
|
||||||
import cn.hutool.http.useragent.UserAgent;
|
import cn.hutool.http.useragent.UserAgent;
|
||||||
import cn.hutool.http.useragent.UserAgentUtil;
|
import cn.hutool.http.useragent.UserAgentUtil;
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.UnknownHostException;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 浏览器 相关
|
* 浏览器 相关
|
||||||
|
|||||||
+1
-1
@@ -15,10 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package cn.odboy.util;
|
package cn.odboy.util;
|
||||||
|
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类 相关
|
* 类 相关
|
||||||
|
|||||||
+1
-1
@@ -15,8 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package cn.odboy.util;
|
package cn.odboy.util;
|
||||||
|
|
||||||
import java.io.Closeable;
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
import java.io.Closeable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用于关闭各种连接, 缺啥补啥
|
* 用于关闭各种连接, 缺啥补啥
|
||||||
|
|||||||
+2
-4
@@ -15,10 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package cn.odboy.util;
|
package cn.odboy.util;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.odboy.base.KitSelectOptionVo;
|
import cn.odboy.base.KitSelectOptionVo;
|
||||||
import cn.odboy.framework.exception.BadRequestException;
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
@@ -31,7 +30,6 @@ import java.util.Objects;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 集合工具
|
* 集合工具
|
||||||
@@ -194,7 +192,7 @@ public final class KitCollUtil extends cn.hutool.core.collection.CollUtil {
|
|||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public static BigDecimal streamBigDecimalAvg(List<BigDecimal> data) {
|
public static BigDecimal streamBigDecimalAvg(List<BigDecimal> data) {
|
||||||
KitValidUtil.notEmpty(data, "data");
|
KitValidUtil.isEmpty(data, "data");
|
||||||
return data.stream().filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add)
|
return data.stream().filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add)
|
||||||
.divide(BigDecimal.valueOf(data.size()), 6, RoundingMode.FLOOR);
|
.divide(BigDecimal.valueOf(data.size()), 6, RoundingMode.FLOOR);
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-1
@@ -17,8 +17,9 @@ package cn.odboy.util;
|
|||||||
|
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import java.util.Date;
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 时间相关工具
|
* 时间相关工具
|
||||||
@@ -129,4 +130,22 @@ public class KitDateUtil {
|
|||||||
}
|
}
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得当天是周几
|
||||||
|
*/
|
||||||
|
public static String getWeekDay() {
|
||||||
|
String[] weekDays = {"星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
cal.setTime(new Date());
|
||||||
|
int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
|
||||||
|
if (w < 0) {
|
||||||
|
w = 0;
|
||||||
|
}
|
||||||
|
return weekDays[w];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.err.println(getWeekDay());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -15,13 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package cn.odboy.util;
|
package cn.odboy.util;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import lombok.experimental.UtilityClass;
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
import javax.crypto.SecretKey;
|
import javax.crypto.SecretKey;
|
||||||
import javax.crypto.SecretKeyFactory;
|
import javax.crypto.SecretKeyFactory;
|
||||||
import javax.crypto.spec.DESKeySpec;
|
import javax.crypto.spec.DESKeySpec;
|
||||||
import javax.crypto.spec.IvParameterSpec;
|
import javax.crypto.spec.IvParameterSpec;
|
||||||
import lombok.experimental.UtilityClass;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DES加密
|
* DES加密
|
||||||
|
|||||||
+9
-10
@@ -15,11 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package cn.odboy.util;
|
package cn.odboy.util;
|
||||||
|
|
||||||
import static cn.odboy.constant.SystemConst.SYMBOL_ADD;
|
|
||||||
import static cn.odboy.constant.SystemConst.SYMBOL_AT;
|
|
||||||
import static cn.odboy.constant.SystemConst.SYMBOL_EQUAL;
|
|
||||||
import static cn.odboy.constant.SystemConst.SYMBOL_SUBTRACT;
|
|
||||||
|
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
@@ -29,6 +24,11 @@ import cn.hutool.poi.excel.ExcelUtil;
|
|||||||
import cn.odboy.constant.FileTypeEnum;
|
import cn.odboy.constant.FileTypeEnum;
|
||||||
import cn.odboy.constant.SystemConst;
|
import cn.odboy.constant.SystemConst;
|
||||||
import cn.odboy.framework.exception.BadRequestException;
|
import cn.odboy.framework.exception.BadRequestException;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.poi.util.IOUtils;
|
||||||
|
import org.apache.poi.xssf.streaming.SXSSFSheet;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import jakarta.servlet.ServletOutputStream;
|
import jakarta.servlet.ServletOutputStream;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
@@ -46,11 +46,10 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import lombok.experimental.UtilityClass;
|
import static cn.odboy.constant.SystemConst.SYMBOL_ADD;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import static cn.odboy.constant.SystemConst.SYMBOL_AT;
|
||||||
import org.apache.poi.util.IOUtils;
|
import static cn.odboy.constant.SystemConst.SYMBOL_EQUAL;
|
||||||
import org.apache.poi.xssf.streaming.SXSSFSheet;
|
import static cn.odboy.constant.SystemConst.SYMBOL_SUBTRACT;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File工具类, 扩展 hutool 工具包
|
* File工具类, 扩展 hutool 工具包
|
||||||
|
|||||||
@@ -16,12 +16,12 @@
|
|||||||
package cn.odboy.util;
|
package cn.odboy.util;
|
||||||
|
|
||||||
import cn.odboy.framework.context.KitSpringBeanHolder;
|
import cn.odboy.framework.context.KitSpringBeanHolder;
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.NetworkInterface;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.dreamlu.mica.ip2region.core.Ip2regionSearcher;
|
import net.dreamlu.mica.ip2region.core.Ip2regionSearcher;
|
||||||
import net.dreamlu.mica.ip2region.core.IpInfo;
|
import net.dreamlu.mica.ip2region.core.IpInfo;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.NetworkInterface;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IP地址 相关
|
* IP地址 相关
|
||||||
|
|||||||
+1
-1
@@ -17,9 +17,9 @@ package cn.odboy.util;
|
|||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.TypeReference;
|
import com.alibaba.fastjson2.TypeReference;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Json工具
|
* Json工具
|
||||||
|
|||||||
+2
-2
@@ -17,11 +17,11 @@ package cn.odboy.util;
|
|||||||
|
|
||||||
import cn.hutool.core.date.DateTime;
|
import cn.hutool.core.date.DateTime;
|
||||||
import cn.odboy.base.KitBaseUserTimeTb;
|
import cn.odboy.base.KitBaseUserTimeTb;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List 工具
|
* List 工具
|
||||||
@@ -40,7 +40,7 @@ public final class KitListUtil {
|
|||||||
*/
|
*/
|
||||||
public static <T, K> List<T> distinctByArgs(List<T> items, Function<? super T, ? extends K> classifier) {
|
public static <T, K> List<T> distinctByArgs(List<T> items, Function<? super T, ? extends K> classifier) {
|
||||||
return items.stream().collect(Collectors.groupingBy(classifier)).values().stream()
|
return items.stream().collect(Collectors.groupingBy(classifier)).values().stream()
|
||||||
.map(List::getFirst).collect(Collectors.toList());
|
.map(monitorItem -> monitorItem.iterator().next()).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-1
@@ -17,9 +17,9 @@ package cn.odboy.util;
|
|||||||
|
|
||||||
import cn.odboy.base.KitPageResult;
|
import cn.odboy.base.KitPageResult;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页工具
|
* 分页工具
|
||||||
|
|||||||
+2
-2
@@ -15,13 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package cn.odboy.util;
|
package cn.odboy.util;
|
||||||
|
|
||||||
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
|
import org.aspectj.lang.reflect.MethodSignature;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
|
||||||
import org.aspectj.lang.reflect.MethodSignature;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回值处理 工具
|
* 返回值处理 工具
|
||||||
|
|||||||
+3
-3
@@ -15,6 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package cn.odboy.util;
|
package cn.odboy.util;
|
||||||
|
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
import javax.crypto.Cipher;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.security.KeyFactory;
|
import java.security.KeyFactory;
|
||||||
import java.security.KeyPair;
|
import java.security.KeyPair;
|
||||||
@@ -26,9 +29,6 @@ import java.security.interfaces.RSAPrivateKey;
|
|||||||
import java.security.interfaces.RSAPublicKey;
|
import java.security.interfaces.RSAPublicKey;
|
||||||
import java.security.spec.PKCS8EncodedKeySpec;
|
import java.security.spec.PKCS8EncodedKeySpec;
|
||||||
import java.security.spec.X509EncodedKeySpec;
|
import java.security.spec.X509EncodedKeySpec;
|
||||||
import javax.crypto.Cipher;
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rsa 工具类, 公钥私钥生成, 加解密
|
* Rsa 工具类, 公钥私钥生成, 加解密
|
||||||
|
|||||||
-17
@@ -15,8 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package cn.odboy.util;
|
package cn.odboy.util;
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@@ -97,19 +95,4 @@ public final class KitStringUtil {
|
|||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得当天是周几
|
|
||||||
*/
|
|
||||||
public static String getWeekDay() {
|
|
||||||
// String[] weekDays = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
|
|
||||||
String[] weekDays = {"星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期天"};
|
|
||||||
Calendar cal = Calendar.getInstance();
|
|
||||||
cal.setTime(new Date());
|
|
||||||
int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
|
|
||||||
if (w < 0) {
|
|
||||||
w = 0;
|
|
||||||
}
|
|
||||||
return weekDays[w];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
package cn.odboy.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
|
|
||||||
|
public class KitThreadUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 可中断的睡眠
|
||||||
|
*/
|
||||||
|
public static void interruptSleep(int i) throws InterruptedException {
|
||||||
|
Thread.sleep(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void safeSleep(int i) {
|
||||||
|
ThreadUtil.safeSleep(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
+109
-17
@@ -18,16 +18,16 @@ package cn.odboy.util;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.odboy.framework.exception.BadRequestException;
|
import cn.odboy.framework.exception.BadRequestException;
|
||||||
import java.util.List;
|
import lombok.experimental.UtilityClass;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import jakarta.validation.ConstraintViolation;
|
import jakarta.validation.ConstraintViolation;
|
||||||
import jakarta.validation.Validation;
|
import jakarta.validation.Validation;
|
||||||
import jakarta.validation.Validator;
|
import jakarta.validation.Validator;
|
||||||
import jakarta.validation.ValidatorFactory;
|
import jakarta.validation.ValidatorFactory;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import jakarta.validation.groups.Default;
|
import jakarta.validation.groups.Default;
|
||||||
import lombok.experimental.UtilityClass;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bean验证工具
|
* Bean验证工具
|
||||||
@@ -46,6 +46,12 @@ public final class KitValidUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证实体是否通过校验 <br/> 实体内通过 javax.validation.constraints 中的表达式限制参数 <br/>
|
||||||
|
*
|
||||||
|
* @param object /
|
||||||
|
* @param <T> /
|
||||||
|
*/
|
||||||
public static <T> void validate(T object) {
|
public static <T> void validate(T object) {
|
||||||
Set<ConstraintViolation<T>> violations = VALIDATOR.validate(object, Default.class);
|
Set<ConstraintViolation<T>> violations = VALIDATOR.validate(object, Default.class);
|
||||||
if (!violations.isEmpty()) {
|
if (!violations.isEmpty()) {
|
||||||
@@ -54,39 +60,125 @@ public final class KitValidUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void notNull(Object value) {
|
/**
|
||||||
|
* 参数为null,抛异常
|
||||||
|
*
|
||||||
|
* @param value 参数值
|
||||||
|
*/
|
||||||
|
public static void isNull(Object value) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new BadRequestException("参数必填");
|
throw new BadRequestException("参数必填");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void isNull(Object value) {
|
/**
|
||||||
if (value != null) {
|
* 参数为空,抛异常
|
||||||
throw new BadRequestException("参数非必填");
|
*
|
||||||
}
|
* @param value 参数值
|
||||||
}
|
* @param name 参数名称
|
||||||
|
* @param code 参数编码
|
||||||
public static void notNull(Object value, @NotNull String name, @NotNull String code) {
|
*/
|
||||||
|
public static void isNull(Object value, @NotNull String name, @NotNull String code) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new BadRequestException(String.format("参数 %s(%s) 必填", name, code));
|
throw new BadRequestException(String.format("参数 %s(%s) 必填", name, code));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void isBlank(CharSequence value, @NotNull String name, @NotNull String code) {
|
/**
|
||||||
if (StrUtil.isNotBlank(value)) {
|
* 参数为空,抛异常
|
||||||
throw new BadRequestException(String.format("参数 %s(%s) 非必填", name, code));
|
*
|
||||||
|
* @param value 参数值
|
||||||
|
* @param message 异常信息
|
||||||
|
*/
|
||||||
|
public static void isNull(Object value, @NotNull String message) {
|
||||||
|
if (value == null) {
|
||||||
|
throw new BadRequestException(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void notBlank(CharSequence value, @NotNull String name, @NotNull String code) {
|
/**
|
||||||
|
* 参数为空,抛异常
|
||||||
|
*
|
||||||
|
* @param value 参数值
|
||||||
|
* @param code 参数编码
|
||||||
|
*/
|
||||||
|
public static void isNullF(Object value, @NotNull String code) {
|
||||||
|
if (value == null) {
|
||||||
|
throw new BadRequestException(String.format("参数 %s 必填", code));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数为空字符串,抛异常
|
||||||
|
*
|
||||||
|
* @param value 参数值
|
||||||
|
* @param name 参数名称
|
||||||
|
* @param code 参数编码
|
||||||
|
*/
|
||||||
|
public static void isBlank(CharSequence value, @NotNull String name, @NotNull String code) {
|
||||||
if (StrUtil.isBlank(value)) {
|
if (StrUtil.isBlank(value)) {
|
||||||
throw new BadRequestException(String.format("参数 %s(%s) 必填", name, code));
|
throw new BadRequestException(String.format("参数 %s(%s) 必填", name, code));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void notEmpty(List<?> data, @NotNull String code) {
|
/**
|
||||||
|
* 集合为空,抛异常
|
||||||
|
*
|
||||||
|
* @param data 集合值
|
||||||
|
* @param code 参数编码
|
||||||
|
*/
|
||||||
|
public static void isEmpty(List<?> data, @NotNull String code) {
|
||||||
if (CollUtil.isEmpty(data)) {
|
if (CollUtil.isEmpty(data)) {
|
||||||
throw new BadRequestException(String.format("参数 %s 必填", code));
|
throw new BadRequestException(String.format("参数 %s 必填", code));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 集合为空,抛异常
|
||||||
|
*
|
||||||
|
* @param data 集合值
|
||||||
|
* @param name 参数名称
|
||||||
|
* @param code 参数编码
|
||||||
|
*/
|
||||||
|
public static void isEmpty(List<?> data, @NotNull String name, @NotNull String code) {
|
||||||
|
if (CollUtil.isEmpty(data)) {
|
||||||
|
throw new BadRequestException(String.format("参数 %s(%s) 必填", name, code));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表达式为true,抛异常
|
||||||
|
*
|
||||||
|
* @param condition 表达式
|
||||||
|
* @param message 异常信息
|
||||||
|
*/
|
||||||
|
public static void isTrue(boolean condition, String message) {
|
||||||
|
if (condition) {
|
||||||
|
throw new BadRequestException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表达式为false,抛异常
|
||||||
|
*
|
||||||
|
* @param condition 表达式
|
||||||
|
* @param message 异常信息
|
||||||
|
*/
|
||||||
|
public static void isFalse(boolean condition, String message) {
|
||||||
|
if (!condition) {
|
||||||
|
throw new BadRequestException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数为空字符串,抛异常
|
||||||
|
*
|
||||||
|
* @param value 参数值
|
||||||
|
* @param message 异常信息
|
||||||
|
*/
|
||||||
|
public static void isBlank(String value, String message) {
|
||||||
|
if (StrUtil.isBlank(value)) {
|
||||||
|
throw new BadRequestException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -3,12 +3,12 @@ package cn.odboy.util.xlsx;
|
|||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.idev.excel.EasyExcel;
|
import cn.idev.excel.EasyExcel;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EasyExcel 导出增强工具类 (支持普通/分页模式)
|
* EasyExcel 导出增强工具类 (支持普通/分页模式)
|
||||||
|
|||||||
+2
-2
@@ -6,14 +6,14 @@ import cn.hutool.core.date.DateUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.idev.excel.FastExcel;
|
import cn.idev.excel.FastExcel;
|
||||||
import cn.odboy.framework.exception.BadRequestException;
|
import cn.odboy.framework.exception.BadRequestException;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xlsx文件导出工具
|
* xlsx文件导出工具
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application;
|
package cn.odboy.system.application;
|
||||||
|
|
||||||
import cn.odboy.system.application.model.CuteDeptTreeVo;
|
import cn.odboy.system.application.model.CuteDeptTreeVo;
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application;
|
package cn.odboy.system.application;
|
||||||
|
|
||||||
import cn.odboy.system.application.service.CuteFileUploadService;
|
import cn.odboy.system.application.service.CuteFileUploadService;
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application;
|
package cn.odboy.system.application;
|
||||||
|
|
||||||
import cn.odboy.system.application.service.CuteProductLineSelectService;
|
import cn.odboy.system.application.service.CuteProductLineSelectService;
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application;
|
package cn.odboy.system.application;
|
||||||
|
|
||||||
import cn.odboy.system.application.service.CuteProductLineSelectProService;
|
import cn.odboy.system.application.service.CuteProductLineSelectProService;
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application;
|
package cn.odboy.system.application;
|
||||||
|
|
||||||
import cn.odboy.system.application.model.CuteUserSelectVo;
|
import cn.odboy.system.application.model.CuteUserSelectVo;
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application.model;
|
package cn.odboy.system.application.model;
|
||||||
|
|
||||||
import cn.odboy.base.KitObject;
|
import cn.odboy.base.KitObject;
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application.model;
|
package cn.odboy.system.application.model;
|
||||||
|
|
||||||
import cn.odboy.base.KitObject;
|
import cn.odboy.base.KitObject;
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application.service;
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application.service;
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application.service;
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application.service;
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
import cn.odboy.system.application.model.CuteProductLineSelectProVo;
|
import cn.odboy.system.application.model.CuteProductLineSelectProVo;
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application.service;
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
import cn.odboy.system.application.model.CuteProductLineSelectVo;
|
import cn.odboy.system.application.model.CuteProductLineSelectVo;
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application.service;
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
|||||||
-4
@@ -17,7 +17,6 @@ package cn.odboy.system.controller;
|
|||||||
|
|
||||||
import cn.odboy.base.KitPageArgs;
|
import cn.odboy.base.KitPageArgs;
|
||||||
import cn.odboy.base.KitPageResult;
|
import cn.odboy.base.KitPageResult;
|
||||||
import cn.odboy.framework.exception.BadRequestException;
|
|
||||||
import cn.odboy.system.dal.dataobject.SystemMenuTb;
|
import cn.odboy.system.dal.dataobject.SystemMenuTb;
|
||||||
import cn.odboy.system.dal.model.request.SystemQueryMenuArgs;
|
import cn.odboy.system.dal.model.request.SystemQueryMenuArgs;
|
||||||
import cn.odboy.system.dal.model.response.SystemMenuRouterVo;
|
import cn.odboy.system.dal.model.response.SystemMenuRouterVo;
|
||||||
@@ -102,9 +101,6 @@ public class SystemMenuController {
|
|||||||
@PostMapping(value = "/saveMenu")
|
@PostMapping(value = "/saveMenu")
|
||||||
@PreAuthorize("@el.check('menu:add')")
|
@PreAuthorize("@el.check('menu:add')")
|
||||||
public ResponseEntity<Void> saveMenu(@Validated @RequestBody SystemMenuTb args) {
|
public ResponseEntity<Void> saveMenu(@Validated @RequestBody SystemMenuTb args) {
|
||||||
if (args.getId() != null) {
|
|
||||||
throw new BadRequestException("无效参数id");
|
|
||||||
}
|
|
||||||
systemMenuService.saveMenu(args);
|
systemMenuService.saveMenu(args);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-8
@@ -21,10 +21,8 @@ import cn.odboy.system.dal.dataobject.SystemQuartzJobTb;
|
|||||||
import cn.odboy.system.dal.dataobject.SystemQuartzLogTb;
|
import cn.odboy.system.dal.dataobject.SystemQuartzLogTb;
|
||||||
import cn.odboy.system.dal.model.request.SystemQueryQuartzJobArgs;
|
import cn.odboy.system.dal.model.request.SystemQueryQuartzJobArgs;
|
||||||
import cn.odboy.system.dal.model.request.SystemUpdateQuartzJobArgs;
|
import cn.odboy.system.dal.model.request.SystemUpdateQuartzJobArgs;
|
||||||
import cn.odboy.system.dal.model.response.SystemQuartzJobVo;
|
|
||||||
import cn.odboy.system.framework.operalog.OperationLog;
|
import cn.odboy.system.framework.operalog.OperationLog;
|
||||||
import cn.odboy.system.service.SystemQuartzJobService;
|
import cn.odboy.system.service.SystemQuartzJobService;
|
||||||
import cn.odboy.util.KitBeanUtil;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
@@ -96,8 +94,7 @@ public class SystemQuartzJobController {
|
|||||||
@ApiOperation("修改定时任务")
|
@ApiOperation("修改定时任务")
|
||||||
@PostMapping(value = "/updateQuartzJobResumeCron")
|
@PostMapping(value = "/updateQuartzJobResumeCron")
|
||||||
@PreAuthorize("@el.check('quartzJob:edit')")
|
@PreAuthorize("@el.check('quartzJob:edit')")
|
||||||
public ResponseEntity<Void> updateQuartzJob(
|
public ResponseEntity<Void> updateQuartzJob(@Validated(SystemQuartzJobTb.Update.class) @RequestBody SystemUpdateQuartzJobArgs args) {
|
||||||
@Validated(SystemQuartzJobTb.Update.class) @RequestBody SystemUpdateQuartzJobArgs args) {
|
|
||||||
systemQuartzJobService.updateQuartzJobResumeCron(args);
|
systemQuartzJobService.updateQuartzJobResumeCron(args);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
@@ -108,8 +105,7 @@ public class SystemQuartzJobController {
|
|||||||
@PreAuthorize("@el.check('quartzJob:edit')")
|
@PreAuthorize("@el.check('quartzJob:edit')")
|
||||||
public ResponseEntity<Void> switchQuartzJobStatus(@PathVariable Long id) {
|
public ResponseEntity<Void> switchQuartzJobStatus(@PathVariable Long id) {
|
||||||
SystemQuartzJobTb quartzJobTb = systemQuartzJobService.getQuartzJobById(id);
|
SystemQuartzJobTb quartzJobTb = systemQuartzJobService.getQuartzJobById(id);
|
||||||
SystemQuartzJobVo quartzJobVo = KitBeanUtil.copyToClass(quartzJobTb, SystemQuartzJobVo.class);
|
systemQuartzJobService.switchQuartzJobStatus(quartzJobTb);
|
||||||
systemQuartzJobService.switchQuartzJobStatus(quartzJobVo);
|
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,8 +115,7 @@ public class SystemQuartzJobController {
|
|||||||
@PreAuthorize("@el.check('quartzJob:edit')")
|
@PreAuthorize("@el.check('quartzJob:edit')")
|
||||||
public ResponseEntity<Void> startQuartzJob(@PathVariable Long id) {
|
public ResponseEntity<Void> startQuartzJob(@PathVariable Long id) {
|
||||||
SystemQuartzJobTb quartzJobTb = systemQuartzJobService.getQuartzJobById(id);
|
SystemQuartzJobTb quartzJobTb = systemQuartzJobService.getQuartzJobById(id);
|
||||||
SystemQuartzJobVo quartzJobVo = KitBeanUtil.copyToClass(quartzJobTb, SystemQuartzJobVo.class);
|
systemQuartzJobService.startQuartzJob(quartzJobTb);
|
||||||
systemQuartzJobService.startQuartzJob(quartzJobVo);
|
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -20,9 +20,9 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
|||||||
+6
@@ -63,4 +63,10 @@ public class SystemQuartzJobTb extends KitBaseUserTimeTb {
|
|||||||
@ApiModelProperty(value = "备注")
|
@ApiModelProperty(value = "备注")
|
||||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||||
private String description;
|
private String description;
|
||||||
|
/**
|
||||||
|
* 扩展字段
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
@ApiModelProperty(value = "用于子任务唯一标识", hidden = true)
|
||||||
|
private String uuid;
|
||||||
}
|
}
|
||||||
|
|||||||
-55
@@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021-2026 Odboy
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package cn.odboy.system.dal.model.response;
|
|
||||||
|
|
||||||
import cn.odboy.base.KitBaseUserTimeTb;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
public class SystemQuartzJobVo extends KitBaseUserTimeTb {
|
|
||||||
|
|
||||||
private Long id;
|
|
||||||
@ApiModelProperty(value = "定时器名称")
|
|
||||||
private String jobName;
|
|
||||||
@ApiModelProperty(value = "Bean名称")
|
|
||||||
private String beanName;
|
|
||||||
@ApiModelProperty(value = "方法名称")
|
|
||||||
private String methodName;
|
|
||||||
@ApiModelProperty(value = "参数")
|
|
||||||
private String params;
|
|
||||||
@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;
|
|
||||||
@ApiModelProperty(value = "备注")
|
|
||||||
private String description;
|
|
||||||
/**
|
|
||||||
* 扩展字段
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "用于子任务唯一标识", hidden = true)
|
|
||||||
private String uuid;
|
|
||||||
}
|
|
||||||
+9
-12
@@ -85,8 +85,10 @@ public class SpringSecurityConfig {
|
|||||||
.addFilterBefore(customFilter, UsernamePasswordAuthenticationFilter.class)
|
.addFilterBefore(customFilter, UsernamePasswordAuthenticationFilter.class)
|
||||||
// 授权异常
|
// 授权异常
|
||||||
.exceptionHandling(
|
.exceptionHandling(
|
||||||
exceptionHandling -> exceptionHandling.authenticationEntryPoint(authenticationErrorHandler)
|
exceptionHandling -> exceptionHandling
|
||||||
.accessDeniedHandler(jwtAccessDeniedHandler))
|
.authenticationEntryPoint(authenticationErrorHandler)
|
||||||
|
.accessDeniedHandler(jwtAccessDeniedHandler)
|
||||||
|
)
|
||||||
// 防止iframe 造成跨域
|
// 防止iframe 造成跨域
|
||||||
.headers(headers -> headers.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable))
|
.headers(headers -> headers.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable))
|
||||||
// 不创建会话
|
// 不创建会话
|
||||||
@@ -106,20 +108,15 @@ public class SpringSecurityConfig {
|
|||||||
.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
|
.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
|
||||||
// 自定义匿名访问所有url放行:允许匿名和带Token访问,细腻化到每个 Request 类型
|
// 自定义匿名访问所有url放行:允许匿名和带Token访问,细腻化到每个 Request 类型
|
||||||
// GET
|
// GET
|
||||||
.requestMatchers(HttpMethod.GET,
|
.requestMatchers(HttpMethod.GET, anonymousUrls.get(RequestMethodEnum.GET.getType()).toArray(new String[0])).permitAll()
|
||||||
anonymousUrls.get(RequestMethodEnum.GET.getType()).toArray(new String[0])).permitAll()
|
|
||||||
// POST
|
// POST
|
||||||
.requestMatchers(HttpMethod.POST,
|
.requestMatchers(HttpMethod.POST, anonymousUrls.get(RequestMethodEnum.POST.getType()).toArray(new String[0])).permitAll()
|
||||||
anonymousUrls.get(RequestMethodEnum.POST.getType()).toArray(new String[0])).permitAll()
|
|
||||||
// PUT
|
// PUT
|
||||||
.requestMatchers(HttpMethod.PUT,
|
.requestMatchers(HttpMethod.PUT, anonymousUrls.get(RequestMethodEnum.PUT.getType()).toArray(new String[0])).permitAll()
|
||||||
anonymousUrls.get(RequestMethodEnum.PUT.getType()).toArray(new String[0])).permitAll()
|
|
||||||
// PATCH
|
// PATCH
|
||||||
.requestMatchers(HttpMethod.PATCH,
|
.requestMatchers(HttpMethod.PATCH, anonymousUrls.get(RequestMethodEnum.PATCH.getType()).toArray(new String[0])).permitAll()
|
||||||
anonymousUrls.get(RequestMethodEnum.PATCH.getType()).toArray(new String[0])).permitAll()
|
|
||||||
// DELETE
|
// DELETE
|
||||||
.requestMatchers(HttpMethod.DELETE,
|
.requestMatchers(HttpMethod.DELETE, anonymousUrls.get(RequestMethodEnum.DELETE.getType()).toArray(new String[0])).permitAll()
|
||||||
anonymousUrls.get(RequestMethodEnum.DELETE.getType()).toArray(new String[0])).permitAll()
|
|
||||||
// 所有类型的接口都放行
|
// 所有类型的接口都放行
|
||||||
.requestMatchers(anonymousUrls.get(RequestMethodEnum.ALL.getType()).toArray(new String[0])).permitAll()
|
.requestMatchers(anonymousUrls.get(RequestMethodEnum.ALL.getType()).toArray(new String[0])).permitAll()
|
||||||
// 所有请求都需要认证
|
// 所有请求都需要认证
|
||||||
|
|||||||
-42
@@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021-2026 Odboy
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package cn.odboy.system.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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+2
-2
@@ -23,11 +23,11 @@ import cn.odboy.system.dal.redis.SystemUserInfoDAO;
|
|||||||
import cn.odboy.system.service.SystemDataService;
|
import cn.odboy.system.service.SystemDataService;
|
||||||
import cn.odboy.system.service.SystemRoleService;
|
import cn.odboy.system.service.SystemRoleService;
|
||||||
import cn.odboy.system.service.SystemUserService;
|
import cn.odboy.system.service.SystemUserService;
|
||||||
import java.util.List;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户名判断用户信息,并获取拥有的权限与部门
|
* 通过用户名判断用户信息,并获取拥有的权限与部门
|
||||||
@@ -49,7 +49,7 @@ public class UserDetailsHandler implements UserDetailsService {
|
|||||||
public SystemUserJwtVo loadUserByUsername(String username) {
|
public SystemUserJwtVo loadUserByUsername(String username) {
|
||||||
SystemUserJwtVo userJwtVo = systemUserInfoDAO.getUserLoginInfoByUserName(username);
|
SystemUserJwtVo userJwtVo = systemUserInfoDAO.getUserLoginInfoByUserName(username);
|
||||||
if (userJwtVo == null) {
|
if (userJwtVo == null) {
|
||||||
SystemUserVo user = systemUserService.getUserVoByUsername(username);
|
SystemUserVo user = systemUserService.getUserVoWithPasswordByUsername(username);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new BadRequestException("用户不存在");
|
throw new BadRequestException("用户不存在");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+2
-5
@@ -16,15 +16,13 @@
|
|||||||
package cn.odboy.system.framework.quartz;
|
package cn.odboy.system.framework.quartz;
|
||||||
|
|
||||||
import cn.odboy.system.dal.dataobject.SystemQuartzJobTb;
|
import cn.odboy.system.dal.dataobject.SystemQuartzJobTb;
|
||||||
import cn.odboy.system.dal.model.response.SystemQuartzJobVo;
|
|
||||||
import cn.odboy.system.service.SystemQuartzJobService;
|
import cn.odboy.system.service.SystemQuartzJobService;
|
||||||
import cn.odboy.util.KitBeanUtil;
|
|
||||||
import java.util.List;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationArguments;
|
||||||
import org.springframework.boot.ApplicationRunner;
|
import org.springframework.boot.ApplicationRunner;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@@ -43,8 +41,7 @@ public class ActiveJobRegister implements ApplicationRunner {
|
|||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments applicationArguments) {
|
public void run(ApplicationArguments applicationArguments) {
|
||||||
List<SystemQuartzJobTb> quartzJobTbs = systemQuartzJobService.listEnableQuartzJob();
|
List<SystemQuartzJobTb> quartzJobTbs = systemQuartzJobService.listEnableQuartzJob();
|
||||||
List<SystemQuartzJobVo> quartzJobVos = KitBeanUtil.copyToList(quartzJobTbs, SystemQuartzJobVo.class);
|
quartzJobTbs.forEach(quartzManage::addJob);
|
||||||
quartzJobVos.forEach(quartzManage::addJob);
|
|
||||||
log.info("Timing task injection complete");
|
log.info("Timing task injection complete");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-8
@@ -27,19 +27,19 @@ import cn.odboy.framework.redis.KitRedisHelper;
|
|||||||
import cn.odboy.system.dal.dataobject.SystemQuartzJobTb;
|
import cn.odboy.system.dal.dataobject.SystemQuartzJobTb;
|
||||||
import cn.odboy.system.dal.dataobject.SystemQuartzLogTb;
|
import cn.odboy.system.dal.dataobject.SystemQuartzLogTb;
|
||||||
import cn.odboy.system.dal.model.request.SystemSendEmailArgs;
|
import cn.odboy.system.dal.model.request.SystemSendEmailArgs;
|
||||||
import cn.odboy.system.dal.model.response.SystemQuartzJobVo;
|
|
||||||
import cn.odboy.system.dal.mysql.SystemQuartzLogMapper;
|
import cn.odboy.system.dal.mysql.SystemQuartzLogMapper;
|
||||||
import cn.odboy.system.service.SystemEmailService;
|
import cn.odboy.system.service.SystemEmailService;
|
||||||
import cn.odboy.system.service.SystemQuartzJobService;
|
import cn.odboy.system.service.SystemQuartzJobService;
|
||||||
|
import cn.odboy.util.KitBeanUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.quartz.JobExecutionContext;
|
||||||
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||||
|
import org.springframework.scheduling.quartz.QuartzJobBean;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.quartz.JobExecutionContext;
|
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
||||||
import org.springframework.scheduling.quartz.QuartzJobBean;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ExecutionJobBean extends QuartzJobBean {
|
public class ExecutionJobBean extends QuartzJobBean {
|
||||||
@@ -52,7 +52,7 @@ public class ExecutionJobBean extends QuartzJobBean {
|
|||||||
@Override
|
@Override
|
||||||
public void executeInternal(JobExecutionContext context) {
|
public void executeInternal(JobExecutionContext context) {
|
||||||
// 获取任务
|
// 获取任务
|
||||||
SystemQuartzJobVo quartzJob = (SystemQuartzJobVo) context.getMergedJobDataMap().get(SystemQuartzJobTb.JOB_KEY);
|
SystemQuartzJobTb quartzJob = (SystemQuartzJobTb) context.getMergedJobDataMap().get(SystemQuartzJobTb.JOB_KEY);
|
||||||
// 获取spring bean
|
// 获取spring bean
|
||||||
SystemQuartzLogMapper quartzLogMapper = KitSpringBeanHolder.getBean(SystemQuartzLogMapper.class);
|
SystemQuartzLogMapper quartzLogMapper = KitSpringBeanHolder.getBean(SystemQuartzLogMapper.class);
|
||||||
SystemQuartzJobService systemQuartzJobService = KitSpringBeanHolder.getBean(SystemQuartzJobService.class);
|
SystemQuartzJobService systemQuartzJobService = KitSpringBeanHolder.getBean(SystemQuartzJobService.class);
|
||||||
@@ -99,7 +99,8 @@ public class ExecutionJobBean extends QuartzJobBean {
|
|||||||
if (quartzJob.getPauseAfterFailure() != null && quartzJob.getPauseAfterFailure()) {
|
if (quartzJob.getPauseAfterFailure() != null && quartzJob.getPauseAfterFailure()) {
|
||||||
quartzJob.setIsPause(false);
|
quartzJob.setIsPause(false);
|
||||||
// 更新状态
|
// 更新状态
|
||||||
systemQuartzJobService.switchQuartzJobStatus(quartzJob);
|
SystemQuartzJobTb quartzJobTb = KitBeanUtil.copyToClass(quartzJob, SystemQuartzJobTb.class);
|
||||||
|
systemQuartzJobService.switchQuartzJobStatus(quartzJobTb);
|
||||||
}
|
}
|
||||||
if (quartzJob.getEmail() != null) {
|
if (quartzJob.getEmail() != null) {
|
||||||
SystemEmailService emailService = KitSpringBeanHolder.getBean(SystemEmailService.class);
|
SystemEmailService emailService = KitSpringBeanHolder.getBean(SystemEmailService.class);
|
||||||
@@ -114,7 +115,7 @@ public class ExecutionJobBean extends QuartzJobBean {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private SystemSendEmailArgs taskAlarm(SystemQuartzJobVo quartzJob, String msg) {
|
private SystemSendEmailArgs taskAlarm(SystemQuartzJobTb quartzJob, String msg) {
|
||||||
SystemSendEmailArgs sendEmailRequest = new SystemSendEmailArgs();
|
SystemSendEmailArgs sendEmailRequest = new SystemSendEmailArgs();
|
||||||
sendEmailRequest.setSubject("定时任务【" + quartzJob.getJobName() + "】执行失败,请尽快处理!");
|
sendEmailRequest.setSubject("定时任务【" + quartzJob.getJobName() + "】执行失败,请尽快处理!");
|
||||||
Map<String, Object> data = new HashMap<>(16);
|
Map<String, Object> data = new HashMap<>(16);
|
||||||
|
|||||||
+11
-14
@@ -17,9 +17,6 @@ package cn.odboy.system.framework.quartz;
|
|||||||
|
|
||||||
import cn.odboy.framework.exception.BadRequestException;
|
import cn.odboy.framework.exception.BadRequestException;
|
||||||
import cn.odboy.system.dal.dataobject.SystemQuartzJobTb;
|
import cn.odboy.system.dal.dataobject.SystemQuartzJobTb;
|
||||||
import cn.odboy.system.dal.model.response.SystemQuartzJobVo;
|
|
||||||
import cn.odboy.util.KitBeanUtil;
|
|
||||||
import java.util.Date;
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.quartz.CronScheduleBuilder;
|
import org.quartz.CronScheduleBuilder;
|
||||||
@@ -35,6 +32,7 @@ import org.quartz.TriggerBuilder;
|
|||||||
import org.quartz.TriggerKey;
|
import org.quartz.TriggerKey;
|
||||||
import org.quartz.impl.triggers.CronTriggerImpl;
|
import org.quartz.impl.triggers.CronTriggerImpl;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@@ -44,7 +42,7 @@ public class QuartzManage {
|
|||||||
@Resource
|
@Resource
|
||||||
private Scheduler scheduler;
|
private Scheduler scheduler;
|
||||||
|
|
||||||
public void addJob(SystemQuartzJobVo quartzJob) {
|
public void addJob(SystemQuartzJobTb quartzJob) {
|
||||||
try {
|
try {
|
||||||
String uuid = JOB_NAME + quartzJob.getId();
|
String uuid = JOB_NAME + quartzJob.getId();
|
||||||
// 构建job信息
|
// 构建job信息
|
||||||
@@ -83,23 +81,22 @@ public class QuartzManage {
|
|||||||
*/
|
*/
|
||||||
public void updateJobCron(SystemQuartzJobTb quartzJob) {
|
public void updateJobCron(SystemQuartzJobTb quartzJob) {
|
||||||
try {
|
try {
|
||||||
SystemQuartzJobVo quartzJobVo = KitBeanUtil.copyToClass(quartzJob, SystemQuartzJobVo.class);
|
TriggerKey triggerKey = TriggerKey.triggerKey(JOB_NAME + quartzJob.getId());
|
||||||
TriggerKey triggerKey = TriggerKey.triggerKey(JOB_NAME + quartzJobVo.getId());
|
|
||||||
CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey);
|
CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey);
|
||||||
// 如果不存在则创建一个定时任务
|
// 如果不存在则创建一个定时任务
|
||||||
if (trigger == null) {
|
if (trigger == null) {
|
||||||
addJob(quartzJobVo);
|
addJob(quartzJob);
|
||||||
trigger = (CronTrigger) scheduler.getTrigger(triggerKey);
|
trigger = (CronTrigger) scheduler.getTrigger(triggerKey);
|
||||||
}
|
}
|
||||||
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(quartzJobVo.getCronExpression());
|
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(quartzJob.getCronExpression());
|
||||||
trigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(scheduleBuilder).build();
|
trigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(scheduleBuilder).build();
|
||||||
// 重置启动时间
|
// 重置启动时间
|
||||||
((CronTriggerImpl) trigger).setStartTime(new Date());
|
((CronTriggerImpl) trigger).setStartTime(new Date());
|
||||||
trigger.getJobDataMap().put(SystemQuartzJobTb.JOB_KEY, quartzJobVo);
|
trigger.getJobDataMap().put(SystemQuartzJobTb.JOB_KEY, quartzJob);
|
||||||
scheduler.rescheduleJob(triggerKey, trigger);
|
scheduler.rescheduleJob(triggerKey, trigger);
|
||||||
// 暂停任务
|
// 暂停任务
|
||||||
if (quartzJobVo.getIsPause()) {
|
if (quartzJob.getIsPause()) {
|
||||||
pauseJob(quartzJobVo);
|
pauseJob(quartzJob);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("更新定时任务失败", e);
|
log.error("更新定时任务失败", e);
|
||||||
@@ -128,7 +125,7 @@ public class QuartzManage {
|
|||||||
*
|
*
|
||||||
* @param quartzJob /
|
* @param quartzJob /
|
||||||
*/
|
*/
|
||||||
public void resumeJob(SystemQuartzJobVo quartzJob) {
|
public void resumeJob(SystemQuartzJobTb quartzJob) {
|
||||||
try {
|
try {
|
||||||
TriggerKey triggerKey = TriggerKey.triggerKey(JOB_NAME + quartzJob.getId());
|
TriggerKey triggerKey = TriggerKey.triggerKey(JOB_NAME + quartzJob.getId());
|
||||||
CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey);
|
CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey);
|
||||||
@@ -149,7 +146,7 @@ public class QuartzManage {
|
|||||||
*
|
*
|
||||||
* @param quartzJob /
|
* @param quartzJob /
|
||||||
*/
|
*/
|
||||||
public void runJobNow(SystemQuartzJobVo quartzJob) {
|
public void runJobNow(SystemQuartzJobTb quartzJob) {
|
||||||
try {
|
try {
|
||||||
String uuid = JOB_NAME + quartzJob.getId();
|
String uuid = JOB_NAME + quartzJob.getId();
|
||||||
TriggerKey triggerKey = TriggerKey.triggerKey(uuid);
|
TriggerKey triggerKey = TriggerKey.triggerKey(uuid);
|
||||||
@@ -173,7 +170,7 @@ public class QuartzManage {
|
|||||||
*
|
*
|
||||||
* @param quartzJob /
|
* @param quartzJob /
|
||||||
*/
|
*/
|
||||||
public void pauseJob(SystemQuartzJobVo quartzJob) {
|
public void pauseJob(SystemQuartzJobTb quartzJob) {
|
||||||
try {
|
try {
|
||||||
JobKey jobKey = JobKey.jobKey(JOB_NAME + quartzJob.getId());
|
JobKey jobKey = JobKey.jobKey(JOB_NAME + quartzJob.getId());
|
||||||
scheduler.pauseJob(jobKey);
|
scheduler.pauseJob(jobKey);
|
||||||
|
|||||||
+7
-10
@@ -16,7 +16,6 @@
|
|||||||
package cn.odboy.system.service;
|
package cn.odboy.system.service;
|
||||||
|
|
||||||
import cn.odboy.constant.SystemConst;
|
import cn.odboy.constant.SystemConst;
|
||||||
import cn.odboy.framework.exception.BadRequestException;
|
|
||||||
import cn.odboy.framework.properties.AppProperties;
|
import cn.odboy.framework.properties.AppProperties;
|
||||||
import cn.odboy.system.dal.model.request.SystemUserLoginArgs;
|
import cn.odboy.system.dal.model.request.SystemUserLoginArgs;
|
||||||
import cn.odboy.system.dal.model.response.SystemAuthVo;
|
import cn.odboy.system.dal.model.response.SystemAuthVo;
|
||||||
@@ -57,25 +56,23 @@ public class SystemAuthService {
|
|||||||
private SystemCaptchaService systemCaptchaService;
|
private SystemCaptchaService systemCaptchaService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录 -> TestPassed
|
* 登录
|
||||||
*
|
*
|
||||||
* @param loginArgs /
|
* @param loginArgs /
|
||||||
* @param request /
|
* @param request /
|
||||||
*/
|
*/
|
||||||
public SystemAuthVo doLogin(SystemUserLoginArgs loginArgs, HttpServletRequest request) throws Exception {
|
public SystemAuthVo doLogin(SystemUserLoginArgs loginArgs, HttpServletRequest request) throws Exception {
|
||||||
KitValidUtil.notNull(loginArgs);
|
KitValidUtil.isNull(loginArgs);
|
||||||
|
|
||||||
// 密码解密
|
// 密码解密
|
||||||
String password =
|
String password = KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), loginArgs.getPassword());
|
||||||
KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), loginArgs.getPassword());
|
|
||||||
// 校验验证码
|
// 校验验证码
|
||||||
systemCaptchaService.validate(loginArgs.getUuid(), loginArgs.getCode());
|
systemCaptchaService.validate(loginArgs.getUuid(), loginArgs.getCode());
|
||||||
// 查询用户信息
|
// 查询用户信息
|
||||||
SystemUserJwtVo jwtUser = userDetailsService.loadUserByUsername(loginArgs.getUsername());
|
SystemUserJwtVo jwtUser = userDetailsService.loadUserByUsername(loginArgs.getUsername());
|
||||||
|
|
||||||
// 验证用户密码
|
// 验证用户密码
|
||||||
if (!passwordEncoder.matches(password, jwtUser.getPassword())) {
|
KitValidUtil.isTrue(!passwordEncoder.matches(password, jwtUser.getPassword()), "登录密码错误");
|
||||||
throw new BadRequestException("登录密码错误");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 登录验证
|
// 登录验证
|
||||||
Authentication authentication =
|
Authentication authentication =
|
||||||
@@ -101,7 +98,7 @@ public class SystemAuthService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询当前登录人信息 -> TestPassed
|
* 查询当前登录人信息
|
||||||
*/
|
*/
|
||||||
public SystemUserJwtVo getCurrentUserInfo() {
|
public SystemUserJwtVo getCurrentUserInfo() {
|
||||||
SystemUserJwtVo jwtUser = (SystemUserJwtVo) KitSecurityHelper.getCurrentUser();
|
SystemUserJwtVo jwtUser = (SystemUserJwtVo) KitSecurityHelper.getCurrentUser();
|
||||||
@@ -112,7 +109,7 @@ public class SystemAuthService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退出登录 -> TestPassed
|
* 退出登录
|
||||||
*
|
*
|
||||||
* @param request /
|
* @param request /
|
||||||
*/
|
*/
|
||||||
|
|||||||
+5
-9
@@ -19,11 +19,11 @@ import cn.hutool.core.util.IdUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.odboy.constant.CaptchaCodeEnum;
|
import cn.odboy.constant.CaptchaCodeEnum;
|
||||||
import cn.odboy.constant.SystemConst;
|
import cn.odboy.constant.SystemConst;
|
||||||
import cn.odboy.framework.exception.BadRequestException;
|
|
||||||
import cn.odboy.framework.properties.AppProperties;
|
import cn.odboy.framework.properties.AppProperties;
|
||||||
import cn.odboy.framework.redis.KitRedisHelper;
|
import cn.odboy.framework.redis.KitRedisHelper;
|
||||||
import cn.odboy.system.constant.SystemCacheKey;
|
import cn.odboy.system.constant.SystemCacheKey;
|
||||||
import cn.odboy.system.dal.model.response.SystemCaptchaVo;
|
import cn.odboy.system.dal.model.response.SystemCaptchaVo;
|
||||||
|
import cn.odboy.util.KitValidUtil;
|
||||||
import com.wf.captcha.base.Captcha;
|
import com.wf.captcha.base.Captcha;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -41,7 +41,7 @@ public class SystemCaptchaService {
|
|||||||
private AppProperties properties;
|
private AppProperties properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询登录验证码 -> TestPassed
|
* 查询登录验证码
|
||||||
*/
|
*/
|
||||||
public SystemCaptchaVo getLoginCaptcha() {
|
public SystemCaptchaVo getLoginCaptcha() {
|
||||||
// 查询运算的结果
|
// 查询运算的结果
|
||||||
@@ -63,7 +63,7 @@ public class SystemCaptchaService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证验证码 -> TestPassed
|
* 验证验证码
|
||||||
*
|
*
|
||||||
* @param uuid 验证码uuid
|
* @param uuid 验证码uuid
|
||||||
* @param inputCode 用户输入的验证码
|
* @param inputCode 用户输入的验证码
|
||||||
@@ -71,13 +71,9 @@ public class SystemCaptchaService {
|
|||||||
public void validate(String uuid, String inputCode) {
|
public void validate(String uuid, String inputCode) {
|
||||||
// 查询验证码
|
// 查询验证码
|
||||||
String code = redisHelper.get(uuid, String.class);
|
String code = redisHelper.get(uuid, String.class);
|
||||||
if (StrUtil.isBlank(code)) {
|
KitValidUtil.isBlank(code, "验证码不存在或已过期");
|
||||||
throw new BadRequestException("验证码不存在或已过期");
|
|
||||||
}
|
|
||||||
// 清除验证码
|
// 清除验证码
|
||||||
redisHelper.del(uuid);
|
redisHelper.del(uuid);
|
||||||
if (StrUtil.isBlank(inputCode) || !code.equalsIgnoreCase(inputCode)) {
|
KitValidUtil.isTrue(StrUtil.isBlank(inputCode) || !code.equalsIgnoreCase(inputCode), "验证码错误");
|
||||||
throw new BadRequestException("验证码错误");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -45,7 +45,7 @@ public class SystemDataService {
|
|||||||
private SystemRoleDeptService systemRoleDeptService;
|
private SystemRoleDeptService systemRoleDeptService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询数据权限 -> TestPassed
|
* 查询数据权限
|
||||||
*
|
*
|
||||||
* @param user /
|
* @param user /
|
||||||
* @return /
|
* @return /
|
||||||
@@ -75,7 +75,7 @@ public class SystemDataService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询自定义的数据权限 -> TestPassed
|
* 查询自定义的数据权限
|
||||||
*
|
*
|
||||||
* @param deptIds 部门ID(外部数据)
|
* @param deptIds 部门ID(外部数据)
|
||||||
* @param roleId 角色ID
|
* @param roleId 角色ID
|
||||||
|
|||||||
+10
-23
@@ -34,10 +34,10 @@ import cn.odboy.util.KitClassUtil;
|
|||||||
import cn.odboy.util.KitValidUtil;
|
import cn.odboy.util.KitValidUtil;
|
||||||
import cn.odboy.util.xlsx.KitExcelExporter;
|
import cn.odboy.util.xlsx.KitExcelExporter;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -58,13 +58,13 @@ public class SystemDeptService {
|
|||||||
private SystemRoleDeptService systemRoleDeptService;
|
private SystemRoleDeptService systemRoleDeptService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建 -> TestPassed
|
* 创建
|
||||||
*
|
*
|
||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void saveDept(SystemCreateDeptArgs args) {
|
public void saveDept(SystemCreateDeptArgs args) {
|
||||||
KitValidUtil.notNull(args);
|
KitValidUtil.isNull(args);
|
||||||
|
|
||||||
SystemDeptTb record = KitBeanUtil.copyToClass(args, SystemDeptTb.class);
|
SystemDeptTb record = KitBeanUtil.copyToClass(args, SystemDeptTb.class);
|
||||||
systemDeptMapper.insert(record);
|
systemDeptMapper.insert(record);
|
||||||
@@ -73,13 +73,13 @@ public class SystemDeptService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑 -> TestPassed
|
* 编辑
|
||||||
*
|
*
|
||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateDeptById(SystemDeptTb args) {
|
public void updateDeptById(SystemDeptTb args) {
|
||||||
KitValidUtil.notNull(args);
|
KitValidUtil.isNull(args);
|
||||||
// 旧的父部门
|
// 旧的父部门
|
||||||
Long oldPid = this.getDeptById(args.getId()).getPid();
|
Long oldPid = this.getDeptById(args.getId()).getPid();
|
||||||
// 新的父部门
|
// 新的父部门
|
||||||
@@ -104,7 +104,9 @@ public class SystemDeptService {
|
|||||||
// 查询部门, 和其所有子部门
|
// 查询部门, 和其所有子部门
|
||||||
Set<SystemDeptTb> depts = this.traverseDeptByIdWithPids(ids);
|
Set<SystemDeptTb> depts = this.traverseDeptByIdWithPids(ids);
|
||||||
// 验证是否被角色或用户关联
|
// 验证是否被角色或用户关联
|
||||||
this.verifyBindRelationByIds(depts);
|
Set<Long> deptIds = depts.stream().map(SystemDeptTb::getId).collect(Collectors.toSet());
|
||||||
|
KitValidUtil.isTrue(systemUserDeptService.countUserByDeptIds(deptIds) > 0, "所选部门存在用户关联,请解除后再试");
|
||||||
|
KitValidUtil.isTrue(systemRoleDeptService.countRoleByDeptIds(deptIds) > 0, "所选部门存在角色关联,请解除后再试");
|
||||||
for (SystemDeptTb dept : depts) {
|
for (SystemDeptTb dept : depts) {
|
||||||
systemDeptMapper.deleteById(dept.getId());
|
systemDeptMapper.deleteById(dept.getId());
|
||||||
this.updateDeptSubCnt(dept.getPid());
|
this.updateDeptSubCnt(dept.getPid());
|
||||||
@@ -112,7 +114,7 @@ public class SystemDeptService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新父节点中子节点数目 -> TestPassed
|
* 更新父节点中子节点数目
|
||||||
*
|
*
|
||||||
* @param deptId 部门id
|
* @param deptId 部门id
|
||||||
*/
|
*/
|
||||||
@@ -252,21 +254,6 @@ public class SystemDeptService {
|
|||||||
return systemDeptMapper.selectList(wrapper).stream().collect(Collectors.toMap(SystemDeptTb::getId, i -> i, (m, n) -> m));
|
return systemDeptMapper.selectList(wrapper).stream().collect(Collectors.toMap(SystemDeptTb::getId, i -> i, (m, n) -> m));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证是否被角色或用户关联
|
|
||||||
*
|
|
||||||
* @param deptSet /
|
|
||||||
*/
|
|
||||||
public void verifyBindRelationByIds(Set<SystemDeptTb> deptSet) {
|
|
||||||
Set<Long> deptIds = deptSet.stream().map(SystemDeptTb::getId).collect(Collectors.toSet());
|
|
||||||
if (systemUserDeptService.countUserByDeptIds(deptIds) > 0) {
|
|
||||||
throw new BadRequestException("所选部门存在用户关联,请解除后再试!");
|
|
||||||
}
|
|
||||||
if (systemRoleDeptService.countRoleByDeptIds(deptIds) > 0) {
|
|
||||||
throw new BadRequestException("所选部门存在角色关联,请解除后再试!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据部门id遍历所有部门和子部门
|
* 根据部门id遍历所有部门和子部门
|
||||||
*
|
*
|
||||||
@@ -374,7 +361,7 @@ public class SystemDeptService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据部门id查询部门信息 -> TestPassed
|
* 根据部门id查询部门信息
|
||||||
*
|
*
|
||||||
* @param id 部门id
|
* @param id 部门id
|
||||||
* @return /
|
* @return /
|
||||||
|
|||||||
+8
-8
@@ -49,21 +49,21 @@ public class SystemDictDetailService {
|
|||||||
private SystemDictMapper systemDictMapper;
|
private SystemDictMapper systemDictMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建 -> TestPassed
|
* 创建
|
||||||
*
|
*
|
||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void saveDictDetail(SystemCreateDictDetailArgs args) {
|
public void saveDictDetail(SystemCreateDictDetailArgs args) {
|
||||||
KitValidUtil.notNull(args);
|
KitValidUtil.isNull(args);
|
||||||
KitValidUtil.notNull(args.getDict());
|
KitValidUtil.isNull(args.getDict());
|
||||||
SystemDictDetailTb dictDetail = KitBeanUtil.copyToClass(args, SystemDictDetailTb.class);
|
SystemDictDetailTb dictDetail = KitBeanUtil.copyToClass(args, SystemDictDetailTb.class);
|
||||||
dictDetail.setDictId(args.getDict().getId());
|
dictDetail.setDictId(args.getDict().getId());
|
||||||
systemDictDetailMapper.insert(dictDetail);
|
systemDictDetailMapper.insert(dictDetail);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑 -> TestPassed
|
* 编辑
|
||||||
*
|
*
|
||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@@ -71,11 +71,11 @@ public class SystemDictDetailService {
|
|||||||
public void updateDictDetailById(SystemDictDetailTb args) {
|
public void updateDictDetailById(SystemDictDetailTb args) {
|
||||||
SystemDictDetailTb dictDetail = systemDictDetailMapper.selectById(args.getId());
|
SystemDictDetailTb dictDetail = systemDictDetailMapper.selectById(args.getId());
|
||||||
args.setId(dictDetail.getId());
|
args.setId(dictDetail.getId());
|
||||||
systemDictDetailMapper.insertOrUpdate(args);
|
systemDictDetailMapper.updateById(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除 -> TestPassed
|
* 删除
|
||||||
*
|
*
|
||||||
* @param id /
|
* @param id /
|
||||||
*/
|
*/
|
||||||
@@ -99,7 +99,7 @@ public class SystemDictDetailService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询 -> TestPassed
|
* 分页查询
|
||||||
*
|
*
|
||||||
* @param args 条件
|
* @param args 条件
|
||||||
* @param page 分页参数
|
* @param page 分页参数
|
||||||
@@ -123,7 +123,7 @@ public class SystemDictDetailService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据字典名称查询字典详情 -> TestPassed
|
* 根据字典名称查询字典详情
|
||||||
*
|
*
|
||||||
* @param name 字典名称
|
* @param name 字典名称
|
||||||
* @return /
|
* @return /
|
||||||
|
|||||||
+4
-4
@@ -46,7 +46,7 @@ public class SystemDictService {
|
|||||||
private SystemDictDetailService systemDictDetailService;
|
private SystemDictDetailService systemDictDetailService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建 -> TestPassed
|
* 创建
|
||||||
*
|
*
|
||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@@ -57,7 +57,7 @@ public class SystemDictService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑 -> TestPassed
|
* 编辑
|
||||||
*
|
*
|
||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@@ -70,7 +70,7 @@ public class SystemDictService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除 -> TestPassed
|
* 删除
|
||||||
*
|
*
|
||||||
* @param ids /
|
* @param ids /
|
||||||
*/
|
*/
|
||||||
@@ -83,7 +83,7 @@ public class SystemDictService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询 -> TestPassed
|
* 分页查询
|
||||||
*
|
*
|
||||||
* @param args 条件
|
* @param args 条件
|
||||||
* @param page 分页参数
|
* @param page 分页参数
|
||||||
|
|||||||
+11
-22
@@ -30,6 +30,7 @@ import cn.odboy.system.dal.model.request.SystemSendEmailArgs;
|
|||||||
import cn.odboy.system.dal.mysql.SystemEmailConfigMapper;
|
import cn.odboy.system.dal.mysql.SystemEmailConfigMapper;
|
||||||
import cn.odboy.util.KitDesEncryptUtil;
|
import cn.odboy.util.KitDesEncryptUtil;
|
||||||
import cn.odboy.util.KitResourceTemplateUtil;
|
import cn.odboy.util.KitResourceTemplateUtil;
|
||||||
|
import cn.odboy.util.KitValidUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -48,7 +49,7 @@ public class SystemEmailService {
|
|||||||
private AppProperties properties;
|
private AppProperties properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新邮件配置 -> TestPassed
|
* 更新邮件配置
|
||||||
*
|
*
|
||||||
* @param emailConfig 邮箱配置
|
* @param emailConfig 邮箱配置
|
||||||
*/
|
*/
|
||||||
@@ -64,15 +65,13 @@ public class SystemEmailService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送邮件 -> TestPassed
|
* 发送邮件
|
||||||
*
|
*
|
||||||
* @param sendEmailRequest 邮件发送的内容
|
* @param sendEmailRequest 邮件发送的内容
|
||||||
*/
|
*/
|
||||||
public void sendEmail(SystemSendEmailArgs sendEmailRequest) {
|
public void sendEmail(SystemSendEmailArgs sendEmailRequest) {
|
||||||
SystemEmailConfigTb systemEmailConfigTb = getLastEmailConfig();
|
SystemEmailConfigTb systemEmailConfigTb = getLastEmailConfig();
|
||||||
if (systemEmailConfigTb.getId() == null) {
|
KitValidUtil.isNull(systemEmailConfigTb.getId(), "请先配置, 再操作");
|
||||||
throw new BadRequestException("请先配置, 再操作");
|
|
||||||
}
|
|
||||||
// 封装
|
// 封装
|
||||||
MailAccount account = new MailAccount();
|
MailAccount account = new MailAccount();
|
||||||
// 设置用户
|
// 设置用户
|
||||||
@@ -112,23 +111,18 @@ public class SystemEmailService {
|
|||||||
* 发送给邮箱验证码
|
* 发送给邮箱验证码
|
||||||
*/
|
*/
|
||||||
public void sendCaptcha(SystemCaptchaBizEnum biEnum, String email) {
|
public void sendCaptcha(SystemCaptchaBizEnum biEnum, String email) {
|
||||||
if (biEnum == null) {
|
KitValidUtil.isNull(biEnum, "biEnum必填");
|
||||||
throw new BadRequestException("biEnum必填");
|
|
||||||
}
|
|
||||||
String content;
|
String content;
|
||||||
String redisKey = biEnum.getRedisKey() + email;
|
String redisKey = biEnum.getRedisKey() + email;
|
||||||
String oldCode = redisHelper.get(redisKey, String.class);
|
String oldCode = redisHelper.get(redisKey, String.class);
|
||||||
if (oldCode == null) {
|
if (oldCode == null) {
|
||||||
String code = RandomUtil.randomNumbers(6);
|
String code = RandomUtil.randomNumbers(6);
|
||||||
// 存入缓存
|
// 存入缓存
|
||||||
if (!redisHelper.set(redisKey, code, properties.getCaptcha().getExpireTime())) {
|
KitValidUtil.isTrue(!redisHelper.set(redisKey, code, properties.getCaptcha().getExpireTime()), "服务异常, 请联系网站负责人");
|
||||||
throw new BadRequestException("服务异常, 请联系网站负责人");
|
|
||||||
}
|
|
||||||
// 存在就再次发送原来的验证码
|
// 存在就再次发送原来的验证码
|
||||||
content = KitResourceTemplateUtil.render(null, biEnum.getTemplateName(), Dict.create().set("code", code));
|
content = KitResourceTemplateUtil.render(null, biEnum.getTemplateName(), Dict.create().set("code", code));
|
||||||
} else {
|
} else {
|
||||||
content =
|
content = KitResourceTemplateUtil.render(null, biEnum.getTemplateName(), Dict.create().set("code", oldCode));
|
||||||
KitResourceTemplateUtil.render(null, biEnum.getTemplateName(), Dict.create().set("code", oldCode));
|
|
||||||
}
|
}
|
||||||
SystemSendEmailArgs sendEmailRequest =
|
SystemSendEmailArgs sendEmailRequest =
|
||||||
new SystemSendEmailArgs(Collections.singletonList(email), SystemConst.CURRENT_APP_TITLE, content);
|
new SystemSendEmailArgs(Collections.singletonList(email), SystemConst.CURRENT_APP_TITLE, content);
|
||||||
@@ -146,23 +140,18 @@ public class SystemEmailService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验邮箱验证码 -> TestPassed
|
* 校验邮箱验证码
|
||||||
*/
|
*/
|
||||||
public void checkEmailCaptcha(SystemCheckEmailCaptchaArgs args) {
|
public void checkEmailCaptcha(SystemCheckEmailCaptchaArgs args) {
|
||||||
SystemCaptchaBizEnum biEnum = SystemCaptchaBizEnum.getByBizCode(args.getBizCode());
|
SystemCaptchaBizEnum biEnum = SystemCaptchaBizEnum.getByBizCode(args.getBizCode());
|
||||||
if (biEnum == null) {
|
KitValidUtil.isNull(biEnum, "不支持的业务");
|
||||||
throw new BadRequestException("不支持的业务");
|
|
||||||
}
|
|
||||||
this.checkEmailCaptchaV1(biEnum, args.getEmail(), args.getCode());
|
this.checkEmailCaptchaV1(biEnum, args.getEmail(), args.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkEmailCaptchaV1(SystemCaptchaBizEnum biEnum, String email, String code) {
|
public void checkEmailCaptchaV1(SystemCaptchaBizEnum biEnum, String email, String code) {
|
||||||
String redisKey = biEnum.getRedisKey() + email;
|
String redisKey = biEnum.getRedisKey() + email;
|
||||||
String value = redisHelper.get(redisKey, String.class);
|
String value = redisHelper.get(redisKey, String.class);
|
||||||
if (value == null || !value.equals(code)) {
|
KitValidUtil.isTrue(value == null || !value.equals(code), "无效验证码");
|
||||||
throw new BadRequestException("无效验证码");
|
redisHelper.del(redisKey);
|
||||||
} else {
|
|
||||||
redisHelper.del(redisKey);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-27
@@ -18,7 +18,6 @@ package cn.odboy.system.service;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.odboy.base.KitPageResult;
|
import cn.odboy.base.KitPageResult;
|
||||||
import cn.odboy.framework.exception.BadRequestException;
|
|
||||||
import cn.odboy.system.dal.dataobject.SystemJobTb;
|
import cn.odboy.system.dal.dataobject.SystemJobTb;
|
||||||
import cn.odboy.system.dal.model.export.SystemJobExportRowVo;
|
import cn.odboy.system.dal.model.export.SystemJobExportRowVo;
|
||||||
import cn.odboy.system.dal.model.request.SystemCreateJobArgs;
|
import cn.odboy.system.dal.model.request.SystemCreateJobArgs;
|
||||||
@@ -26,6 +25,7 @@ import cn.odboy.system.dal.model.request.SystemQueryJobArgs;
|
|||||||
import cn.odboy.system.dal.mysql.SystemJobMapper;
|
import cn.odboy.system.dal.mysql.SystemJobMapper;
|
||||||
import cn.odboy.util.KitBeanUtil;
|
import cn.odboy.util.KitBeanUtil;
|
||||||
import cn.odboy.util.KitPageUtil;
|
import cn.odboy.util.KitPageUtil;
|
||||||
|
import cn.odboy.util.KitValidUtil;
|
||||||
import cn.odboy.util.xlsx.KitExcelExporter;
|
import cn.odboy.util.xlsx.KitExcelExporter;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
@@ -46,48 +46,44 @@ public class SystemJobService {
|
|||||||
private SystemUserJobService systemUserJobService;
|
private SystemUserJobService systemUserJobService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建 -> TestPassed
|
* 创建
|
||||||
*
|
*
|
||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void saveJob(SystemCreateJobArgs args) {
|
public void saveJob(SystemCreateJobArgs args) {
|
||||||
if (this.existJobWithName(args.getName())) {
|
KitValidUtil.isTrue(this.existJobWithName(args.getName()), "职位名称已存在");
|
||||||
throw new BadRequestException("职位名称已存在");
|
|
||||||
}
|
|
||||||
SystemJobTb systemJobTb = KitBeanUtil.copyToClass(args, SystemJobTb.class);
|
SystemJobTb systemJobTb = KitBeanUtil.copyToClass(args, SystemJobTb.class);
|
||||||
systemJobMapper.insert(systemJobTb);
|
systemJobMapper.insert(systemJobTb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑 -> TestPassed
|
* 编辑
|
||||||
*
|
*
|
||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateJobById(SystemJobTb args) {
|
public void updateJobById(SystemJobTb args) {
|
||||||
SystemJobTb job = systemJobMapper.selectById(args.getId());
|
SystemJobTb job = systemJobMapper.selectById(args.getId());
|
||||||
if (this.existJobWithNameNeSelf(args.getName(), job.getId())) {
|
KitValidUtil.isTrue(this.existJobWithNameNeSelf(args.getName(), job.getId()), "职位名称已存在");
|
||||||
throw new BadRequestException("职位名称已存在");
|
|
||||||
}
|
|
||||||
args.setId(job.getId());
|
args.setId(job.getId());
|
||||||
systemJobMapper.updateById(args);
|
systemJobMapper.updateById(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除 -> TestPassed
|
* 删除
|
||||||
*
|
*
|
||||||
* @param ids /
|
* @param ids /
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteJobByIds(Set<Long> ids) {
|
public void deleteJobByIds(Set<Long> ids) {
|
||||||
// 验证是否被用户关联
|
// 验证是否被用户关联
|
||||||
this.verifyBindRelationByIds(ids);
|
KitValidUtil.isTrue(systemUserJobService.countUserByJobIds(ids) > 0, "所选的岗位中存在用户关联, 请解除关联再试");
|
||||||
systemJobMapper.deleteByIds(ids);
|
systemJobMapper.deleteByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询 -> TestPassed
|
* 分页查询
|
||||||
*
|
*
|
||||||
* @param args 条件
|
* @param args 条件
|
||||||
* @param page 分页参数
|
* @param page 分页参数
|
||||||
@@ -100,7 +96,7 @@ public class SystemJobService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询全部数据 -> TestPassed
|
* 查询全部数据
|
||||||
*/
|
*/
|
||||||
public List<SystemJobTb> queryJobByArgs(SystemQueryJobArgs args) {
|
public List<SystemJobTb> queryJobByArgs(SystemQueryJobArgs args) {
|
||||||
LambdaQueryWrapper<SystemJobTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemJobTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
@@ -109,18 +105,7 @@ public class SystemJobService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证是否被用户关联 -> TestPassed
|
* 导出岗位数据
|
||||||
*
|
|
||||||
* @param ids /
|
|
||||||
*/
|
|
||||||
public void verifyBindRelationByIds(Set<Long> ids) {
|
|
||||||
if (systemUserJobService.countUserByJobIds(ids) > 0) {
|
|
||||||
throw new BadRequestException("所选的岗位中存在用户关联, 请解除关联再试!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出岗位数据 -> TestPassed
|
|
||||||
*/
|
*/
|
||||||
public void exportJobXlsx(HttpServletResponse response, SystemQueryJobArgs args) {
|
public void exportJobXlsx(HttpServletResponse response, SystemQueryJobArgs args) {
|
||||||
List<SystemJobTb> systemJobTbs = this.queryJobByArgs(args);
|
List<SystemJobTb> systemJobTbs = this.queryJobByArgs(args);
|
||||||
@@ -136,7 +121,7 @@ public class SystemJobService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据岗位名称查询岗位是否存在 -> TestPassed
|
* 根据岗位名称查询岗位是否存在
|
||||||
*/
|
*/
|
||||||
private boolean existJobWithName(String name) {
|
private boolean existJobWithName(String name) {
|
||||||
LambdaQueryWrapper<SystemJobTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemJobTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
@@ -145,7 +130,7 @@ public class SystemJobService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据岗位名称和岗位id查询岗位是否存在 -> TestPassed
|
* 根据岗位名称和岗位id查询岗位是否存在
|
||||||
*/
|
*/
|
||||||
private boolean existJobWithNameNeSelf(String name, Long currentJobId) {
|
private boolean existJobWithNameNeSelf(String name, Long currentJobId) {
|
||||||
LambdaQueryWrapper<SystemJobTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemJobTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
|||||||
+10
-13
@@ -32,6 +32,7 @@ import cn.odboy.system.dal.mysql.SystemLocalStorageMapper;
|
|||||||
import cn.odboy.util.KitBeanUtil;
|
import cn.odboy.util.KitBeanUtil;
|
||||||
import cn.odboy.util.KitFileUtil;
|
import cn.odboy.util.KitFileUtil;
|
||||||
import cn.odboy.util.KitPageUtil;
|
import cn.odboy.util.KitPageUtil;
|
||||||
|
import cn.odboy.util.KitValidUtil;
|
||||||
import cn.odboy.util.xlsx.KitExcelExporter;
|
import cn.odboy.util.xlsx.KitExcelExporter;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
@@ -61,7 +62,7 @@ public class SystemLocalStorageService {
|
|||||||
private SystemLocalStorageService localStorageService;
|
private SystemLocalStorageService localStorageService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传 -> TestPassed
|
* 上传
|
||||||
*
|
*
|
||||||
* @param name 文件名称
|
* @param name 文件名称
|
||||||
* @param multipartFile 文件
|
* @param multipartFile 文件
|
||||||
@@ -75,9 +76,7 @@ public class SystemLocalStorageService {
|
|||||||
String type = KitFileUtil.getFileType(suffix);
|
String type = KitFileUtil.getFileType(suffix);
|
||||||
String uploadDateStr = DateUtil.format(new Date(), DatePattern.PURE_DATE_FORMAT);
|
String uploadDateStr = DateUtil.format(new Date(), DatePattern.PURE_DATE_FORMAT);
|
||||||
File file = KitFileUtil.upload(multipartFile, fileUploadPathHelper.getPath() + uploadDateStr + File.separator);
|
File file = KitFileUtil.upload(multipartFile, fileUploadPathHelper.getPath() + uploadDateStr + File.separator);
|
||||||
if (file == null) {
|
KitValidUtil.isNull(file, "上传失败");
|
||||||
throw new BadRequestException("上传失败");
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
String formatSize = KitFileUtil.getSize(size);
|
String formatSize = KitFileUtil.getSize(size);
|
||||||
String prefixName = KitFileUtil.getPrefix(multipartFile.getOriginalFilename(), name);
|
String prefixName = KitFileUtil.getPrefix(multipartFile.getOriginalFilename(), name);
|
||||||
@@ -99,7 +98,7 @@ public class SystemLocalStorageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑 -> TestPassed
|
* 编辑
|
||||||
*
|
*
|
||||||
* @param args 文件信息
|
* @param args 文件信息
|
||||||
*/
|
*/
|
||||||
@@ -109,7 +108,7 @@ public class SystemLocalStorageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 多选删除 -> TestPassed
|
* 多选删除
|
||||||
*
|
*
|
||||||
* @param ids /
|
* @param ids /
|
||||||
*/
|
*/
|
||||||
@@ -127,7 +126,7 @@ public class SystemLocalStorageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询 -> TestPassed
|
* 分页查询
|
||||||
*
|
*
|
||||||
* @param args 条件
|
* @param args 条件
|
||||||
* @param page 分页参数
|
* @param page 分页参数
|
||||||
@@ -141,7 +140,7 @@ public class SystemLocalStorageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询文件上传记录 -> TestPassed
|
* 查询文件上传记录
|
||||||
*/
|
*/
|
||||||
public List<SystemLocalStorageTb> queryLocalStorageByArgs(SystemQueryStorageArgs args) {
|
public List<SystemLocalStorageTb> queryLocalStorageByArgs(SystemQueryStorageArgs args) {
|
||||||
LambdaQueryWrapper<SystemLocalStorageTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemLocalStorageTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
@@ -150,20 +149,18 @@ public class SystemLocalStorageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传图片 -> TestPassed
|
* 上传图片
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public SystemLocalStorageTb uploadPicture(MultipartFile file) {
|
public SystemLocalStorageTb uploadPicture(MultipartFile file) {
|
||||||
// 判断文件是否为图片
|
// 判断文件是否为图片
|
||||||
String suffix = KitFileUtil.getSuffix(file.getOriginalFilename());
|
String suffix = KitFileUtil.getSuffix(file.getOriginalFilename());
|
||||||
if (!FileTypeEnum.IMAGE.getCode().equals(KitFileUtil.getFileType(suffix))) {
|
KitValidUtil.isTrue(!FileTypeEnum.IMAGE.getCode().equals(KitFileUtil.getFileType(suffix)), "只能上传图片");
|
||||||
throw new BadRequestException("只能上传图片");
|
|
||||||
}
|
|
||||||
return localStorageService.uploadFile(null, file);
|
return localStorageService.uploadFile(null, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出文件上传记录 -> TestPassed
|
* 导出文件上传记录
|
||||||
*/
|
*/
|
||||||
public void exportLocalStorageXlsx(HttpServletResponse response, SystemQueryStorageArgs args) {
|
public void exportLocalStorageXlsx(HttpServletResponse response, SystemQueryStorageArgs args) {
|
||||||
List<SystemLocalStorageTb> systemLocalStorageTbs = this.queryLocalStorageByArgs(args);
|
List<SystemLocalStorageTb> systemLocalStorageTbs = this.queryLocalStorageByArgs(args);
|
||||||
|
|||||||
+21
-31
@@ -64,19 +64,15 @@ public class SystemMenuService {
|
|||||||
private SystemMenuService proxyService;
|
private SystemMenuService proxyService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建 -> TestPassed
|
* 创建
|
||||||
*
|
*
|
||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void saveMenu(SystemMenuTb args) {
|
public void saveMenu(SystemMenuTb args) {
|
||||||
if (this.existMenuWithTitle(args.getTitle())) {
|
KitValidUtil.isTrue(this.existMenuWithTitle(args.getTitle()), "菜单标题已存在");
|
||||||
throw new BadRequestException("菜单标题已存在");
|
|
||||||
}
|
|
||||||
if (StrUtil.isNotBlank(args.getComponentName())) {
|
if (StrUtil.isNotBlank(args.getComponentName())) {
|
||||||
if (this.existMenuWithComponentName(args.getComponentName())) {
|
KitValidUtil.isTrue(this.existMenuWithComponentName(args.getComponentName()), "菜单组件名称已存在");
|
||||||
throw new BadRequestException("菜单组件名称已存在");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (Long.valueOf(0L).equals(args.getPid())) {
|
if (Long.valueOf(0L).equals(args.getPid())) {
|
||||||
// 顶级目录
|
// 顶级目录
|
||||||
@@ -96,25 +92,20 @@ public class SystemMenuService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑 -> TestPassed
|
* 编辑
|
||||||
*
|
*
|
||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateMenuById(SystemMenuTb args) {
|
public void updateMenuById(SystemMenuTb args) {
|
||||||
if (args.getId().equals(args.getPid())) {
|
KitValidUtil.isNullF(args.getId(), "id");
|
||||||
throw new BadRequestException("上级不能为自己");
|
KitValidUtil.isTrue(args.getId().equals(args.getPid()), "上级不能为自己");
|
||||||
}
|
|
||||||
SystemMenuTb menu = systemMenuMapper.selectById(args.getId());
|
SystemMenuTb menu = systemMenuMapper.selectById(args.getId());
|
||||||
if (args.getIFrame()) {
|
if (args.getIFrame()) {
|
||||||
if (!(args.getPath().toLowerCase().startsWith(SystemTransferProtocolConst.PREFIX_HTTP) || args.getPath()
|
KitValidUtil.isTrue(!(args.getPath().toLowerCase().startsWith(SystemTransferProtocolConst.PREFIX_HTTP) || args.getPath()
|
||||||
.toLowerCase().startsWith(SystemTransferProtocolConst.PREFIX_HTTPS))) {
|
.toLowerCase().startsWith(SystemTransferProtocolConst.PREFIX_HTTPS)), SystemTransferProtocolConst.PREFIX_HTTPS_BAD_REQUEST);
|
||||||
throw new BadRequestException(SystemTransferProtocolConst.PREFIX_HTTPS_BAD_REQUEST);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.existMenuWithTitleNeSelf(args.getTitle(), menu.getId())) {
|
|
||||||
throw new BadRequestException("菜单标题已存在");
|
|
||||||
}
|
}
|
||||||
|
KitValidUtil.isTrue(this.existMenuWithTitleNeSelf(args.getTitle(), menu.getId()), "菜单标题已存在");
|
||||||
if (args.getPid().equals(0L)) {
|
if (args.getPid().equals(0L)) {
|
||||||
args.setPid(null);
|
args.setPid(null);
|
||||||
}
|
}
|
||||||
@@ -122,9 +113,7 @@ public class SystemMenuService {
|
|||||||
Long oldPid = menu.getPid();
|
Long oldPid = menu.getPid();
|
||||||
Long newPid = args.getPid();
|
Long newPid = args.getPid();
|
||||||
if (StrUtil.isNotBlank(args.getComponentName())) {
|
if (StrUtil.isNotBlank(args.getComponentName())) {
|
||||||
if (this.existMenuWithComponentNameNeSelf(args.getTitle(), menu.getId())) {
|
KitValidUtil.isTrue(this.existMenuWithComponentNameNeSelf(args.getTitle(), menu.getId()), "菜单组件名称已存在");
|
||||||
throw new BadRequestException("菜单组件名称已存在");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
menu.setTitle(args.getTitle());
|
menu.setTitle(args.getTitle());
|
||||||
menu.setComponent(args.getComponent());
|
menu.setComponent(args.getComponent());
|
||||||
@@ -148,7 +137,7 @@ public class SystemMenuService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除 -> TestPassed
|
* 删除
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteMenuByIds(Set<Long> ids) {
|
public void deleteMenuByIds(Set<Long> ids) {
|
||||||
@@ -261,7 +250,7 @@ public class SystemMenuService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据ID查询同级与上级数据 -> TestPassed
|
* 根据ID查询同级与上级数据
|
||||||
*
|
*
|
||||||
* @param menu /
|
* @param menu /
|
||||||
* @param menus /
|
* @param menus /
|
||||||
@@ -443,7 +432,7 @@ public class SystemMenuService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<SystemMenuTb> queryMenuByArgs(SystemQueryMenuArgs args) {
|
private List<SystemMenuTb> queryMenuByArgs(SystemQueryMenuArgs args) {
|
||||||
KitValidUtil.notNull(args);
|
KitValidUtil.isNull(args);
|
||||||
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.isNull(args.getPidIsNull() != null, SystemMenuTb::getPid);
|
wrapper.isNull(args.getPidIsNull() != null, SystemMenuTb::getPid);
|
||||||
wrapper.eq(args.getPid() != null, SystemMenuTb::getPid, args.getPid());
|
wrapper.eq(args.getPid() != null, SystemMenuTb::getPid, args.getPid());
|
||||||
@@ -458,7 +447,7 @@ public class SystemMenuService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询根目录 -> TestPassed
|
* 查询根目录
|
||||||
*/
|
*/
|
||||||
private List<SystemMenuTb> listRootMenu() {
|
private List<SystemMenuTb> listRootMenu() {
|
||||||
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
@@ -468,7 +457,7 @@ public class SystemMenuService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据组件名称查询菜单是否存在 -> TestPassed
|
* 根据组件名称查询菜单是否存在
|
||||||
*
|
*
|
||||||
* @param componentName 组件名称
|
* @param componentName 组件名称
|
||||||
* @return /
|
* @return /
|
||||||
@@ -480,7 +469,7 @@ public class SystemMenuService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据组件名称查询菜单是否存在 -> TestPassed
|
* 根据组件名称查询菜单是否存在
|
||||||
*
|
*
|
||||||
* @param componentName 组件名称
|
* @param componentName 组件名称
|
||||||
* @return /
|
* @return /
|
||||||
@@ -493,7 +482,7 @@ public class SystemMenuService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据菜单标题查询菜单是否存在 -> TestPassed
|
* 根据菜单标题查询菜单是否存在
|
||||||
*
|
*
|
||||||
* @param title 菜单标题
|
* @param title 菜单标题
|
||||||
* @return /
|
* @return /
|
||||||
@@ -505,7 +494,7 @@ public class SystemMenuService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据菜单标题查询菜单是否存在 -> TestPassed
|
* 根据菜单标题查询菜单是否存在
|
||||||
*
|
*
|
||||||
* @param title 菜单标题
|
* @param title 菜单标题
|
||||||
* @return /
|
* @return /
|
||||||
@@ -537,7 +526,8 @@ public class SystemMenuService {
|
|||||||
List<SystemMenuTb> children = parentToChildrenMap.get(parentId);
|
List<SystemMenuTb> children = parentToChildrenMap.get(parentId);
|
||||||
if (children != null && !children.isEmpty()) {
|
if (children != null && !children.isEmpty()) {
|
||||||
for (SystemMenuTb child : children) {
|
for (SystemMenuTb child : children) {
|
||||||
if (result.add(child.getId())) { // 如果成功添加(之前不存在),则继续查找其子菜单
|
// 如果成功添加(之前不存在),则继续查找其子菜单
|
||||||
|
if (result.add(child.getId())) {
|
||||||
nextLevelIds.add(child.getId());
|
nextLevelIds.add(child.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -563,7 +553,7 @@ public class SystemMenuService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据菜单id查询目录 -> TestPassed
|
* 根据菜单id查询目录
|
||||||
*
|
*
|
||||||
* @param id 菜单id
|
* @param id 菜单id
|
||||||
*/
|
*/
|
||||||
|
|||||||
+6
-6
@@ -47,7 +47,7 @@ public class SystemMonitorService {
|
|||||||
private final DecimalFormat df = new DecimalFormat("0.00");
|
private final DecimalFormat df = new DecimalFormat("0.00");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询服务器监控信息 -> TestPassed
|
* 查询服务器监控信息
|
||||||
*
|
*
|
||||||
* @return Map<String, Object>
|
* @return Map<String, Object>
|
||||||
*/
|
*/
|
||||||
@@ -75,7 +75,7 @@ public class SystemMonitorService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询磁盘信息 -> TestPassed
|
* 查询磁盘信息
|
||||||
*
|
*
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
@@ -109,7 +109,7 @@ public class SystemMonitorService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询交换区信息 -> TestPassed
|
* 查询交换区信息
|
||||||
*
|
*
|
||||||
* @param memory /
|
* @param memory /
|
||||||
* @return /
|
* @return /
|
||||||
@@ -131,7 +131,7 @@ public class SystemMonitorService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询内存信息 -> TestPassed
|
* 查询内存信息
|
||||||
*
|
*
|
||||||
* @param memory /
|
* @param memory /
|
||||||
* @return /
|
* @return /
|
||||||
@@ -149,7 +149,7 @@ public class SystemMonitorService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询Cpu相关信息 -> TestPassed
|
* 查询Cpu相关信息
|
||||||
*
|
*
|
||||||
* @param processor /
|
* @param processor /
|
||||||
* @return /
|
* @return /
|
||||||
@@ -196,7 +196,7 @@ public class SystemMonitorService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询系统相关信息,系统、运行天数、系统IP -> TestPassed
|
* 查询系统相关信息,系统、运行天数、系统IP
|
||||||
*
|
*
|
||||||
* @param os /
|
* @param os /
|
||||||
* @return /
|
* @return /
|
||||||
|
|||||||
+1
-1
@@ -33,7 +33,7 @@ public class SystemOperationLogService {
|
|||||||
private SystemOperationLogMapper systemOperationLogMapper;
|
private SystemOperationLogMapper systemOperationLogMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户操作日志 -> TestPassed
|
* 查询用户操作日志
|
||||||
*/
|
*/
|
||||||
public IPage<SystemOperationLogTb> searchUserLog(KitPageArgs<SystemQueryOperationLogArgs> pageArgs) {
|
public IPage<SystemOperationLogTb> searchUserLog(KitPageArgs<SystemQueryOperationLogArgs> pageArgs) {
|
||||||
LambdaQueryWrapper<SystemOperationLogTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemOperationLogTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
|||||||
+31
-43
@@ -28,12 +28,12 @@ import cn.odboy.system.dal.model.export.SystemQuartzJobExportRowVo;
|
|||||||
import cn.odboy.system.dal.model.export.SystemQuartzLogExportRowVo;
|
import cn.odboy.system.dal.model.export.SystemQuartzLogExportRowVo;
|
||||||
import cn.odboy.system.dal.model.request.SystemQueryQuartzJobArgs;
|
import cn.odboy.system.dal.model.request.SystemQueryQuartzJobArgs;
|
||||||
import cn.odboy.system.dal.model.request.SystemUpdateQuartzJobArgs;
|
import cn.odboy.system.dal.model.request.SystemUpdateQuartzJobArgs;
|
||||||
import cn.odboy.system.dal.model.response.SystemQuartzJobVo;
|
|
||||||
import cn.odboy.system.dal.mysql.SystemQuartzJobMapper;
|
import cn.odboy.system.dal.mysql.SystemQuartzJobMapper;
|
||||||
import cn.odboy.system.dal.mysql.SystemQuartzLogMapper;
|
import cn.odboy.system.dal.mysql.SystemQuartzLogMapper;
|
||||||
import cn.odboy.system.framework.quartz.QuartzManage;
|
import cn.odboy.system.framework.quartz.QuartzManage;
|
||||||
import cn.odboy.util.KitBeanUtil;
|
import cn.odboy.util.KitBeanUtil;
|
||||||
import cn.odboy.util.KitPageUtil;
|
import cn.odboy.util.KitPageUtil;
|
||||||
|
import cn.odboy.util.KitValidUtil;
|
||||||
import cn.odboy.util.xlsx.KitExcelExporter;
|
import cn.odboy.util.xlsx.KitExcelExporter;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
@@ -60,27 +60,23 @@ public class SystemQuartzJobService {
|
|||||||
private KitRedisHelper redisHelper;
|
private KitRedisHelper redisHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建 -> TestPassed
|
* 创建
|
||||||
*
|
*
|
||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void createJob(SystemQuartzJobTb args) {
|
public void createJob(SystemQuartzJobTb args) {
|
||||||
if (args.getId() != null) {
|
|
||||||
throw new BadRequestException("无效参数id");
|
|
||||||
}
|
|
||||||
// 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义
|
// 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义
|
||||||
checkBean(args.getBeanName());
|
checkBean(args.getBeanName());
|
||||||
if (!CronExpression.isValidExpression(args.getCronExpression())) {
|
if (!CronExpression.isValidExpression(args.getCronExpression())) {
|
||||||
throw new BadRequestException("cron表达式格式错误");
|
throw new BadRequestException("cron表达式格式错误");
|
||||||
}
|
}
|
||||||
systemQuartzJobMapper.insert(args);
|
systemQuartzJobMapper.insert(args);
|
||||||
SystemQuartzJobVo quartzJobVo = KitBeanUtil.copyToClass(args, SystemQuartzJobVo.class);
|
quartzManage.addJob(args);
|
||||||
quartzManage.addJob(quartzJobVo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改任务并重新调度 -> TestPassed
|
* 修改任务并重新调度
|
||||||
*
|
*
|
||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@@ -88,14 +84,10 @@ public class SystemQuartzJobService {
|
|||||||
public void updateQuartzJobResumeCron(SystemUpdateQuartzJobArgs args) {
|
public void updateQuartzJobResumeCron(SystemUpdateQuartzJobArgs args) {
|
||||||
// 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义
|
// 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义
|
||||||
checkBean(args.getBeanName());
|
checkBean(args.getBeanName());
|
||||||
if (!CronExpression.isValidExpression(args.getCronExpression())) {
|
KitValidUtil.isTrue(!CronExpression.isValidExpression(args.getCronExpression()), "Cron表达式格式错误");
|
||||||
throw new BadRequestException("cron表达式格式错误");
|
|
||||||
}
|
|
||||||
if (StrUtil.isNotBlank(args.getSubTask())) {
|
if (StrUtil.isNotBlank(args.getSubTask())) {
|
||||||
List<String> tasks = Arrays.asList(args.getSubTask().split("[,,]"));
|
List<String> tasks = Arrays.asList(args.getSubTask().split("[,,]"));
|
||||||
if (tasks.contains(args.getId().toString())) {
|
KitValidUtil.isTrue(tasks.contains(args.getId().toString()), "子任务中不能添加当前任务ID");
|
||||||
throw new BadRequestException("子任务中不能添加当前任务ID");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
SystemQuartzJobTb jobTb = KitBeanUtil.copyToClass(args, SystemQuartzJobTb.class);
|
SystemQuartzJobTb jobTb = KitBeanUtil.copyToClass(args, SystemQuartzJobTb.class);
|
||||||
systemQuartzJobMapper.updateById(jobTb);
|
systemQuartzJobMapper.updateById(jobTb);
|
||||||
@@ -103,35 +95,34 @@ public class SystemQuartzJobService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更改定时任务状态 -> TestPassed
|
* 更改定时任务状态
|
||||||
*
|
*
|
||||||
* @param quartzJobVo /
|
* @param quartzJobTb /
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void switchQuartzJobStatus(SystemQuartzJobVo quartzJobVo) {
|
public void switchQuartzJobStatus(SystemQuartzJobTb quartzJobTb) {
|
||||||
// 置换暂停状态
|
// 置换暂停状态
|
||||||
if (quartzJobVo.getIsPause()) {
|
if (quartzJobTb.getIsPause()) {
|
||||||
quartzManage.resumeJob(quartzJobVo);
|
quartzManage.resumeJob(quartzJobTb);
|
||||||
quartzJobVo.setIsPause(false);
|
quartzJobTb.setIsPause(false);
|
||||||
} else {
|
} else {
|
||||||
quartzManage.pauseJob(quartzJobVo);
|
quartzManage.pauseJob(quartzJobTb);
|
||||||
quartzJobVo.setIsPause(true);
|
quartzJobTb.setIsPause(true);
|
||||||
}
|
}
|
||||||
SystemQuartzJobTb record = KitBeanUtil.copyToClass(quartzJobVo, SystemQuartzJobTb.class);
|
systemQuartzJobMapper.updateById(quartzJobTb);
|
||||||
systemQuartzJobMapper.updateById(record);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 立即执行定时任务 -> TestPassed
|
* 立即执行定时任务
|
||||||
*
|
*
|
||||||
* @param quartzJob /
|
* @param quartzJob /
|
||||||
*/
|
*/
|
||||||
public void startQuartzJob(SystemQuartzJobVo quartzJob) {
|
public void startQuartzJob(SystemQuartzJobTb quartzJob) {
|
||||||
quartzManage.runJobNow(quartzJob);
|
quartzManage.runJobNow(quartzJob);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除任务 -> TestPassed
|
* 删除任务
|
||||||
*
|
*
|
||||||
* @param ids /
|
* @param ids /
|
||||||
*/
|
*/
|
||||||
@@ -145,7 +136,7 @@ public class SystemQuartzJobService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行子任务 -> TestPassed
|
* 执行子任务
|
||||||
*
|
*
|
||||||
* @param tasks /
|
* @param tasks /
|
||||||
* @throws InterruptedException /
|
* @throws InterruptedException /
|
||||||
@@ -162,11 +153,10 @@ public class SystemQuartzJobService {
|
|||||||
// 防止子任务不存在
|
// 防止子任务不存在
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
SystemQuartzJobVo quartzJobVo = KitBeanUtil.copyToClass(quartzJobTb, SystemQuartzJobVo.class);
|
|
||||||
// 执行任务
|
// 执行任务
|
||||||
String uuid = IdUtil.simpleUUID();
|
String uuid = IdUtil.simpleUUID();
|
||||||
quartzJobVo.setUuid(uuid);
|
quartzJobTb.setUuid(uuid);
|
||||||
startQuartzJob(quartzJobVo);
|
startQuartzJob(quartzJobTb);
|
||||||
// 查询执行状态, 如果执行失败则停止后面的子任务执行
|
// 查询执行状态, 如果执行失败则停止后面的子任务执行
|
||||||
Boolean result = redisHelper.get(uuid, Boolean.class);
|
Boolean result = redisHelper.get(uuid, Boolean.class);
|
||||||
while (result == null) {
|
while (result == null) {
|
||||||
@@ -182,7 +172,7 @@ public class SystemQuartzJobService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询 -> TestPassed
|
* 分页查询
|
||||||
*
|
*
|
||||||
* @param args 条件
|
* @param args 条件
|
||||||
* @param page 分页参数
|
* @param page 分页参数
|
||||||
@@ -195,7 +185,7 @@ public class SystemQuartzJobService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询日志 -> TestPassed
|
* 分页查询日志
|
||||||
*
|
*
|
||||||
* @param args 条件
|
* @param args 条件
|
||||||
* @param page 分页参数
|
* @param page 分页参数
|
||||||
@@ -208,7 +198,7 @@ public class SystemQuartzJobService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询全部 -> TestPassed
|
* 查询全部
|
||||||
*
|
*
|
||||||
* @param args 条件
|
* @param args 条件
|
||||||
* @return /
|
* @return /
|
||||||
@@ -220,7 +210,7 @@ public class SystemQuartzJobService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询全部 -> TestPassed
|
* 查询全部
|
||||||
*
|
*
|
||||||
* @param args 条件
|
* @param args 条件
|
||||||
* @return /
|
* @return /
|
||||||
@@ -232,7 +222,7 @@ public class SystemQuartzJobService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询启用的定时任务 -> TestPassed
|
* 查询启用的定时任务
|
||||||
*/
|
*/
|
||||||
public List<SystemQuartzJobTb> listEnableQuartzJob() {
|
public List<SystemQuartzJobTb> listEnableQuartzJob() {
|
||||||
LambdaQueryWrapper<SystemQuartzJobTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemQuartzJobTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
@@ -241,7 +231,7 @@ public class SystemQuartzJobService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出定时任务数据 -> TestPassed
|
* 导出定时任务数据
|
||||||
*/
|
*/
|
||||||
public void exportQuartzJobXlsx(HttpServletResponse response, SystemQueryQuartzJobArgs args) {
|
public void exportQuartzJobXlsx(HttpServletResponse response, SystemQueryQuartzJobArgs args) {
|
||||||
List<SystemQuartzJobTb> systemQuartzJobTbs = this.queryQuartzJobByArgs(args);
|
List<SystemQuartzJobTb> systemQuartzJobTbs = this.queryQuartzJobByArgs(args);
|
||||||
@@ -262,7 +252,7 @@ public class SystemQuartzJobService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出定时任务日志数据 -> TestPassed
|
* 导出定时任务日志数据
|
||||||
*/
|
*/
|
||||||
public void exportQuartzLogXlsx(HttpServletResponse response, SystemQueryQuartzJobArgs args) {
|
public void exportQuartzLogXlsx(HttpServletResponse response, SystemQueryQuartzJobArgs args) {
|
||||||
List<SystemQuartzLogTb> systemQuartzLogTbs = this.queryQuartzLogByArgs(args);
|
List<SystemQuartzLogTb> systemQuartzLogTbs = this.queryQuartzLogByArgs(args);
|
||||||
@@ -284,7 +274,7 @@ public class SystemQuartzJobService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据任务id查询定时任务 -> TestPassed
|
* 根据任务id查询定时任务
|
||||||
*/
|
*/
|
||||||
public SystemQuartzJobTb getQuartzJobById(Long id) {
|
public SystemQuartzJobTb getQuartzJobById(Long id) {
|
||||||
return systemQuartzJobMapper.selectById(id);
|
return systemQuartzJobMapper.selectById(id);
|
||||||
@@ -332,9 +322,7 @@ public class SystemQuartzJobService {
|
|||||||
*/
|
*/
|
||||||
private void checkBean(String beanName) {
|
private void checkBean(String beanName) {
|
||||||
// 避免调用攻击者可以从SpringContextHolder获得控制jdbcTemplate类
|
// 避免调用攻击者可以从SpringContextHolder获得控制jdbcTemplate类
|
||||||
// 并使用getDeclaredMethod调用jdbcTemplate的queryForMap函数,执行任意sql命令。
|
// 并使用getDeclaredMethod调用jdbcTemplate的queryForMap函数,执行任意sql命令
|
||||||
if (!KitSpringBeanHolder.getAllServiceBeanName().contains(beanName)) {
|
KitValidUtil.isTrue(!KitSpringBeanHolder.getAllServiceBeanName().contains(beanName), "非法的 Bean,请重新输入");
|
||||||
throw new BadRequestException("非法的 Bean,请重新输入!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -34,7 +34,7 @@ public class SystemRoleDeptService {
|
|||||||
private SystemRoleDeptMapper systemRoleDeptMapper;
|
private SystemRoleDeptMapper systemRoleDeptMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除角色部门关联 -> TestPassed
|
* 批量删除角色部门关联
|
||||||
*
|
*
|
||||||
* @param roleIds 角色id集合
|
* @param roleIds 角色id集合
|
||||||
*/
|
*/
|
||||||
@@ -48,7 +48,7 @@ public class SystemRoleDeptService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量绑定角色部门关联 -> TestPassed
|
* 批量绑定角色部门关联
|
||||||
*
|
*
|
||||||
* @param depts 部门集合
|
* @param depts 部门集合
|
||||||
* @param roleId 角色id
|
* @param roleId 角色id
|
||||||
@@ -68,7 +68,7 @@ public class SystemRoleDeptService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据部门ID统计角色数量 -> TestPassed
|
* 根据部门ID统计角色数量
|
||||||
*
|
*
|
||||||
* @param deptIds 部门id集合
|
* @param deptIds 部门id集合
|
||||||
* @return /
|
* @return /
|
||||||
@@ -83,7 +83,7 @@ public class SystemRoleDeptService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据角色id查询部门信息 -> TestPassed
|
* 根据角色id查询部门信息
|
||||||
*
|
*
|
||||||
* @param roleId 角色id
|
* @param roleId 角色id
|
||||||
* @return /
|
* @return /
|
||||||
|
|||||||
+6
-6
@@ -36,7 +36,7 @@ public class SystemRoleMenuService {
|
|||||||
private SystemRoleMenuMapper systemRoleMenuMapper;
|
private SystemRoleMenuMapper systemRoleMenuMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除角色菜单关联 -> TestPassed
|
* 删除角色菜单关联
|
||||||
*
|
*
|
||||||
* @param roleId 角色id
|
* @param roleId 角色id
|
||||||
*/
|
*/
|
||||||
@@ -48,7 +48,7 @@ public class SystemRoleMenuService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量绑定角色菜单关联 -> TestPassed
|
* 批量绑定角色菜单关联
|
||||||
*
|
*
|
||||||
* @param menus 菜单集合
|
* @param menus 菜单集合
|
||||||
* @param roleId 角色id
|
* @param roleId 角色id
|
||||||
@@ -68,7 +68,7 @@ public class SystemRoleMenuService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除角色菜单关联 -> TestPassed
|
* 批量删除角色菜单关联
|
||||||
*
|
*
|
||||||
* @param roleIds 角色id集合
|
* @param roleIds 角色id集合
|
||||||
*/
|
*/
|
||||||
@@ -82,7 +82,7 @@ public class SystemRoleMenuService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param roleIds 角色id集合 -> TestPassed
|
* @param roleIds 角色id集合
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public List<SystemMenuTb> listMenuByRoleIds(Set<Long> roleIds, boolean hasButton) {
|
public List<SystemMenuTb> listMenuByRoleIds(Set<Long> roleIds, boolean hasButton) {
|
||||||
@@ -109,7 +109,7 @@ public class SystemRoleMenuService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除菜单角色关联 -> TestPassed
|
* 批量删除菜单角色关联
|
||||||
*
|
*
|
||||||
* @param menuIds 菜单id集合
|
* @param menuIds 菜单id集合
|
||||||
*/
|
*/
|
||||||
@@ -124,7 +124,7 @@ public class SystemRoleMenuService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据角色id集合查询菜单权限 -> TestPassed
|
* 根据角色id集合查询菜单权限
|
||||||
*
|
*
|
||||||
* @param roleIds 角色id集合
|
* @param roleIds 角色id集合
|
||||||
* @return /
|
* @return /
|
||||||
|
|||||||
+14
-31
@@ -19,7 +19,6 @@ import cn.hutool.core.collection.CollUtil;
|
|||||||
import cn.hutool.core.lang.Dict;
|
import cn.hutool.core.lang.Dict;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.odboy.base.KitPageResult;
|
import cn.odboy.base.KitPageResult;
|
||||||
import cn.odboy.framework.exception.BadRequestException;
|
|
||||||
import cn.odboy.system.dal.dataobject.SystemMenuTb;
|
import cn.odboy.system.dal.dataobject.SystemMenuTb;
|
||||||
import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
||||||
import cn.odboy.system.dal.model.export.SystemRoleExportRowVo;
|
import cn.odboy.system.dal.model.export.SystemRoleExportRowVo;
|
||||||
@@ -32,6 +31,7 @@ import cn.odboy.system.dal.mysql.SystemRoleMapper;
|
|||||||
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
|
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
|
||||||
import cn.odboy.util.KitBeanUtil;
|
import cn.odboy.util.KitBeanUtil;
|
||||||
import cn.odboy.util.KitPageUtil;
|
import cn.odboy.util.KitPageUtil;
|
||||||
|
import cn.odboy.util.KitValidUtil;
|
||||||
import cn.odboy.util.xlsx.KitExcelExporter;
|
import cn.odboy.util.xlsx.KitExcelExporter;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
@@ -60,16 +60,14 @@ public class SystemRoleService {
|
|||||||
private SystemUserRoleService systemUserRoleService;
|
private SystemUserRoleService systemUserRoleService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建 -> TestPassed
|
* 创建
|
||||||
*
|
*
|
||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void saveRole(SystemCreateRoleArgs args) {
|
public void saveRole(SystemCreateRoleArgs args) {
|
||||||
this.checkRoleLevels(args.getLevel());
|
this.checkRoleLevels(args.getLevel());
|
||||||
if (this.existRoleWithName(args.getName())) {
|
KitValidUtil.isTrue(this.existRoleWithName(args.getName()), "角色名称已存在");
|
||||||
throw new BadRequestException("角色名称已存在");
|
|
||||||
}
|
|
||||||
SystemRoleTb roleTb = KitBeanUtil.copyToClass(args, SystemRoleTb.class);
|
SystemRoleTb roleTb = KitBeanUtil.copyToClass(args, SystemRoleTb.class);
|
||||||
systemRoleMapper.insert(roleTb);
|
systemRoleMapper.insert(roleTb);
|
||||||
// 判断是否有部门数据, 若有, 则需创建关联
|
// 判断是否有部门数据, 若有, 则需创建关联
|
||||||
@@ -79,7 +77,7 @@ public class SystemRoleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改 -> TestPassed
|
* 修改
|
||||||
*
|
*
|
||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@@ -87,9 +85,7 @@ public class SystemRoleService {
|
|||||||
public void updateRoleById(SystemRoleVo args) {
|
public void updateRoleById(SystemRoleVo args) {
|
||||||
this.checkRoleLevels(args.getLevel());
|
this.checkRoleLevels(args.getLevel());
|
||||||
SystemRoleTb role = systemRoleMapper.selectById(args.getId());
|
SystemRoleTb role = systemRoleMapper.selectById(args.getId());
|
||||||
if (this.existRoleWithNameNeSelf(args.getName(), role.getId())) {
|
KitValidUtil.isTrue(this.existRoleWithNameNeSelf(args.getName(), role.getId()), "角色名称已存在");
|
||||||
throw new BadRequestException("角色名称已存在");
|
|
||||||
}
|
|
||||||
role.setName(args.getName());
|
role.setName(args.getName());
|
||||||
role.setDescription(args.getDescription());
|
role.setDescription(args.getDescription());
|
||||||
role.setDataScope(args.getDataScope());
|
role.setDataScope(args.getDataScope());
|
||||||
@@ -105,7 +101,7 @@ public class SystemRoleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改绑定的菜单 -> TestPassed
|
* 修改绑定的菜单
|
||||||
*
|
*
|
||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@@ -122,7 +118,7 @@ public class SystemRoleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除 -> TestPassed
|
* 删除
|
||||||
*
|
*
|
||||||
* @param ids /
|
* @param ids /
|
||||||
*/
|
*/
|
||||||
@@ -133,7 +129,7 @@ public class SystemRoleService {
|
|||||||
this.checkRoleLevels(roleLevel);
|
this.checkRoleLevels(roleLevel);
|
||||||
}
|
}
|
||||||
// 验证是否被用户关联
|
// 验证是否被用户关联
|
||||||
this.verifyBindRelationByIds(ids);
|
KitValidUtil.isTrue(systemUserRoleService.existUserWithRoleIds(ids), "所选角色存在用户关联, 请解除关联再试");
|
||||||
// 删除角色
|
// 删除角色
|
||||||
systemRoleMapper.deleteByIds(ids);
|
systemRoleMapper.deleteByIds(ids);
|
||||||
// 删除角色部门关联数据、角色菜单关联数据
|
// 删除角色部门关联数据、角色菜单关联数据
|
||||||
@@ -142,7 +138,7 @@ public class SystemRoleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询全部角色 -> TestPassed
|
* 查询全部角色
|
||||||
*/
|
*/
|
||||||
public List<SystemRoleTb> listAllRole() {
|
public List<SystemRoleTb> listAllRole() {
|
||||||
LambdaQueryWrapper<SystemRoleTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemRoleTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
@@ -151,7 +147,7 @@ public class SystemRoleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据条件查询全部角色 -> TestPassed
|
* 根据条件查询全部角色
|
||||||
*
|
*
|
||||||
* @param args 条件
|
* @param args 条件
|
||||||
* @param rolePage 分页参数
|
* @param rolePage 分页参数
|
||||||
@@ -164,7 +160,7 @@ public class SystemRoleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询角色 -> TestPassed
|
* 分页查询角色
|
||||||
*
|
*
|
||||||
* @param args 条件
|
* @param args 条件
|
||||||
* @param page 分页条件
|
* @param page 分页条件
|
||||||
@@ -178,7 +174,7 @@ public class SystemRoleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户权限信息 -> TestPassed?
|
* 查询用户权限信息?
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 权限信息
|
* @return 权限信息
|
||||||
@@ -204,17 +200,6 @@ public class SystemRoleService {
|
|||||||
return permissions.stream().map(SystemRoleCodeVo::new).collect(Collectors.toList());
|
return permissions.stream().map(SystemRoleCodeVo::new).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证是否被用户关联 -> TestPassed
|
|
||||||
*
|
|
||||||
* @param ids /
|
|
||||||
*/
|
|
||||||
public void verifyBindRelationByIds(Set<Long> ids) {
|
|
||||||
if (systemUserRoleService.existUserWithRoleIds(ids)) {
|
|
||||||
throw new BadRequestException("所选角色存在用户关联, 请解除关联再试!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据角色id查询用户可访问的部门和菜单信息
|
* 根据角色id查询用户可访问的部门和菜单信息
|
||||||
*
|
*
|
||||||
@@ -281,7 +266,7 @@ public class SystemRoleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查用户的角色级别 -> TestPassed
|
* 检查用户的角色级别
|
||||||
*
|
*
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
@@ -289,9 +274,7 @@ public class SystemRoleService {
|
|||||||
Set<Integer> levels = systemUserRoleService.listUserRoleLevelByUserId(KitSecurityHelper.getCurrentUserId());
|
Set<Integer> levels = systemUserRoleService.listUserRoleLevelByUserId(KitSecurityHelper.getCurrentUserId());
|
||||||
int min = Collections.min(levels);
|
int min = Collections.min(levels);
|
||||||
if (level != null) {
|
if (level != null) {
|
||||||
if (level < min) {
|
KitValidUtil.isTrue(level < min, "权限不足, 你的角色级别:" + min + ", 低于操作的角色级别:" + level);
|
||||||
throw new BadRequestException("权限不足, 你的角色级别:" + min + ", 低于操作的角色级别:" + level);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -29,7 +29,7 @@ public class SystemUserDeptService {
|
|||||||
private SystemUserMapper systemUserMapper;
|
private SystemUserMapper systemUserMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据部门id统计用户数量 -> TestPassed
|
* 根据部门id统计用户数量
|
||||||
*/
|
*/
|
||||||
public long countUserByDeptIds(Set<Long> deptIds) {
|
public long countUserByDeptIds(Set<Long> deptIds) {
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
|||||||
+4
-4
@@ -34,7 +34,7 @@ public class SystemUserJobService {
|
|||||||
private SystemUserJobMapper systemUserJobMapper;
|
private SystemUserJobMapper systemUserJobMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量绑定用户岗位 -> TestPassed
|
* 批量绑定用户岗位
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void batchInsertUserJob(Set<SystemJobTb> jobs, Long userId) {
|
public void batchInsertUserJob(Set<SystemJobTb> jobs, Long userId) {
|
||||||
@@ -51,7 +51,7 @@ public class SystemUserJobService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量解绑用户岗位 -> TestPassed
|
* 批量解绑用户岗位
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void batchDeleteUserJob(Set<Long> userIds) {
|
public void batchDeleteUserJob(Set<Long> userIds) {
|
||||||
@@ -63,7 +63,7 @@ public class SystemUserJobService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据岗位ID统计用户数量 -> TestPassed
|
* 根据岗位ID统计用户数量
|
||||||
*
|
*
|
||||||
* @param jobIds /
|
* @param jobIds /
|
||||||
* @return /
|
* @return /
|
||||||
@@ -78,7 +78,7 @@ public class SystemUserJobService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户id查询岗位 -> TestPassed
|
* 根据用户id查询岗位
|
||||||
*
|
*
|
||||||
* @param userId /
|
* @param userId /
|
||||||
* @return /
|
* @return /
|
||||||
|
|||||||
+9
-9
@@ -52,7 +52,7 @@ public class SystemUserRoleService {
|
|||||||
private SystemRoleDeptService systemRoleDeptService;
|
private SystemRoleDeptService systemRoleDeptService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量绑定用户角色 -> TestPassed
|
* 批量绑定用户角色
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void batchInsertUserRole(Set<SystemRoleTb> roles, Long userId) {
|
public void batchInsertUserRole(Set<SystemRoleTb> roles, Long userId) {
|
||||||
@@ -69,7 +69,7 @@ public class SystemUserRoleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量解绑用户角色 -> TestPassed
|
* 批量解绑用户角色
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void batchDeleteUserRole(Set<Long> userIds) {
|
public void batchDeleteUserRole(Set<Long> userIds) {
|
||||||
@@ -101,7 +101,7 @@ public class SystemUserRoleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户ID查询 -> TestPassed
|
* 根据用户ID查询
|
||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @return /
|
* @return /
|
||||||
@@ -112,7 +112,7 @@ public class SystemUserRoleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据角色查询角色级别 -> TestPassed
|
* 根据角色查询角色级别
|
||||||
*
|
*
|
||||||
* @param roles /
|
* @param roles /
|
||||||
* @return /
|
* @return /
|
||||||
@@ -136,7 +136,7 @@ public class SystemUserRoleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 如果当前用户的角色级别低于创建用户的角色级别,则抛出权限不足的错误 -> TestPassed
|
* 如果当前用户的角色级别低于创建用户的角色级别,则抛出权限不足的错误
|
||||||
*
|
*
|
||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@@ -150,7 +150,7 @@ public class SystemUserRoleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户id查询角色 -> TestPassed
|
* 根据用户id查询角色
|
||||||
*
|
*
|
||||||
* @param userId /
|
* @param userId /
|
||||||
* @return /
|
* @return /
|
||||||
@@ -160,7 +160,7 @@ public class SystemUserRoleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户id查询角色级别集合 -> TestPassed
|
* 根据用户id查询角色级别集合
|
||||||
*
|
*
|
||||||
* @param userId /
|
* @param userId /
|
||||||
* @return /
|
* @return /
|
||||||
@@ -170,7 +170,7 @@ public class SystemUserRoleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户id查询角色id集合 -> TestPassed
|
* 根据用户id查询角色id集合
|
||||||
*
|
*
|
||||||
* @param userId /
|
* @param userId /
|
||||||
* @return /
|
* @return /
|
||||||
@@ -180,7 +180,7 @@ public class SystemUserRoleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据角色id集合判断是否存在关联用户 -> TestPassed
|
* 根据角色id集合判断是否存在关联用户
|
||||||
*
|
*
|
||||||
* @param ids 角色id集合
|
* @param ids 角色id集合
|
||||||
* @return /
|
* @return /
|
||||||
|
|||||||
+34
-68
@@ -18,7 +18,6 @@ package cn.odboy.system.service;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.odboy.base.KitPageResult;
|
import cn.odboy.base.KitPageResult;
|
||||||
import cn.odboy.framework.exception.BadRequestException;
|
|
||||||
import cn.odboy.framework.properties.AppProperties;
|
import cn.odboy.framework.properties.AppProperties;
|
||||||
import cn.odboy.framework.server.core.KitFileLocalUploadHelper;
|
import cn.odboy.framework.server.core.KitFileLocalUploadHelper;
|
||||||
import cn.odboy.system.constant.SystemCaptchaBizEnum;
|
import cn.odboy.system.constant.SystemCaptchaBizEnum;
|
||||||
@@ -39,6 +38,7 @@ import cn.odboy.util.KitBeanUtil;
|
|||||||
import cn.odboy.util.KitFileUtil;
|
import cn.odboy.util.KitFileUtil;
|
||||||
import cn.odboy.util.KitPageUtil;
|
import cn.odboy.util.KitPageUtil;
|
||||||
import cn.odboy.util.KitRsaEncryptUtil;
|
import cn.odboy.util.KitRsaEncryptUtil;
|
||||||
|
import cn.odboy.util.KitValidUtil;
|
||||||
import cn.odboy.util.xlsx.KitExcelExporter;
|
import cn.odboy.util.xlsx.KitExcelExporter;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
@@ -87,7 +87,7 @@ public class SystemUserService {
|
|||||||
private PasswordEncoder passwordEncoder;
|
private PasswordEncoder passwordEncoder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增用户 -> TestPassed
|
* 新增用户
|
||||||
*
|
*
|
||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@@ -98,15 +98,9 @@ public class SystemUserService {
|
|||||||
// 默认密码 123456
|
// 默认密码 123456
|
||||||
record.setPassword(passwordEncoder.encode("123456"));
|
record.setPassword(passwordEncoder.encode("123456"));
|
||||||
record.setDeptId(args.getDept().getId());
|
record.setDeptId(args.getDept().getId());
|
||||||
if (this.existUserWithUsername(record.getUsername())) {
|
KitValidUtil.isTrue(this.existUserWithUsername(record.getUsername()), "用户名已存在");
|
||||||
throw new BadRequestException("用户名已存在");
|
KitValidUtil.isTrue(this.existUserWithEmail(record.getEmail()), "邮箱已存在");
|
||||||
}
|
KitValidUtil.isTrue(this.existUserWithPhone(record.getPhone()), "手机号已存在");
|
||||||
if (this.existUserWithEmail(record.getEmail())) {
|
|
||||||
throw new BadRequestException("邮箱已存在");
|
|
||||||
}
|
|
||||||
if (this.existUserWithPhone(record.getPhone())) {
|
|
||||||
throw new BadRequestException("手机号已存在");
|
|
||||||
}
|
|
||||||
// 保存用户
|
// 保存用户
|
||||||
systemUserMapper.insert(record);
|
systemUserMapper.insert(record);
|
||||||
// 保存用户岗位
|
// 保存用户岗位
|
||||||
@@ -116,7 +110,7 @@ public class SystemUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑用户 -> TestPassed
|
* 编辑用户
|
||||||
*
|
*
|
||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@@ -124,15 +118,9 @@ public class SystemUserService {
|
|||||||
public void updateUserById(SystemUserVo args) {
|
public void updateUserById(SystemUserVo args) {
|
||||||
systemUserRoleService.checkLevel(args);
|
systemUserRoleService.checkLevel(args);
|
||||||
SystemUserTb user = systemUserMapper.selectById(args.getId());
|
SystemUserTb user = systemUserMapper.selectById(args.getId());
|
||||||
if (this.existUserWithUsernameNeSelf(args.getUsername(), user.getId())) {
|
KitValidUtil.isTrue(this.existUserWithUsernameNeSelf(args.getUsername(), user.getId()), "用户名已存在");
|
||||||
throw new BadRequestException("用户名已存在");
|
KitValidUtil.isTrue(this.existUserWithEmailNeSelf(args.getEmail(), user.getId()), "邮箱已存在");
|
||||||
}
|
KitValidUtil.isTrue(this.existUserWithPhoneNeSelf(args.getPhone(), user.getId()), "手机号已存在");
|
||||||
if (this.existUserWithEmailNeSelf(args.getEmail(), user.getId())) {
|
|
||||||
throw new BadRequestException("邮箱已存在");
|
|
||||||
}
|
|
||||||
if (this.existUserWithPhoneNeSelf(args.getPhone(), user.getId())) {
|
|
||||||
throw new BadRequestException("手机号已存在");
|
|
||||||
}
|
|
||||||
// 如果用户被禁用, 则清除用户登录信息
|
// 如果用户被禁用, 则清除用户登录信息
|
||||||
if (!args.getEnabled()) {
|
if (!args.getEnabled()) {
|
||||||
systemUserOnlineInfoDAO.kickOutByUsername(args.getUsername());
|
systemUserOnlineInfoDAO.kickOutByUsername(args.getUsername());
|
||||||
@@ -156,19 +144,15 @@ public class SystemUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户自助修改资料 -> TestPassed
|
* 用户自助修改资料
|
||||||
*
|
*
|
||||||
* @param args /
|
* @param args /
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateUserCenterInfoById(SystemUserTb args) {
|
public void updateUserCenterInfoById(SystemUserTb args) {
|
||||||
if (!args.getId().equals(KitSecurityHelper.getCurrentUserId())) {
|
KitValidUtil.isTrue(!args.getId().equals(KitSecurityHelper.getCurrentUserId()), "不能修改他人资料");
|
||||||
throw new BadRequestException("不能修改他人资料");
|
|
||||||
}
|
|
||||||
SystemUserTb user = systemUserMapper.selectById(args.getId());
|
SystemUserTb user = systemUserMapper.selectById(args.getId());
|
||||||
if (this.existUserWithPhoneNeSelf(args.getPhone(), user.getId())) {
|
KitValidUtil.isTrue(this.existUserWithPhoneNeSelf(args.getPhone(), user.getId()), "手机号已存在");
|
||||||
throw new BadRequestException("手机号已存在");
|
|
||||||
}
|
|
||||||
user.setNickName(args.getNickName());
|
user.setNickName(args.getNickName());
|
||||||
user.setPhone(args.getPhone());
|
user.setPhone(args.getPhone());
|
||||||
user.setGender(args.getGender());
|
user.setGender(args.getGender());
|
||||||
@@ -177,7 +161,7 @@ public class SystemUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除用户 -> TestPassed
|
* 删除用户
|
||||||
*
|
*
|
||||||
* @param ids /
|
* @param ids /
|
||||||
*/
|
*/
|
||||||
@@ -186,12 +170,10 @@ public class SystemUserService {
|
|||||||
Long currentUserId = KitSecurityHelper.getCurrentUserId();
|
Long currentUserId = KitSecurityHelper.getCurrentUserId();
|
||||||
// 校验权限
|
// 校验权限
|
||||||
for (Long id : ids) {
|
for (Long id : ids) {
|
||||||
|
SystemUserTb systemUserTb = systemUserMapper.selectById(id);
|
||||||
Integer currentLevel = Collections.min(systemUserRoleService.listUserRoleLevelByUserId(currentUserId));
|
Integer currentLevel = Collections.min(systemUserRoleService.listUserRoleLevelByUserId(currentUserId));
|
||||||
Integer optLevel = Collections.min(systemUserRoleService.listUserRoleLevelByUserId(id));
|
Integer optLevel = Collections.min(systemUserRoleService.listUserRoleLevelByUserId(id));
|
||||||
if (currentLevel > optLevel) {
|
KitValidUtil.isTrue(currentLevel > optLevel, "角色权限不足, 不能删除:" + systemUserTb.getUsername());
|
||||||
SystemUserTb systemUserTb = systemUserMapper.selectById(id);
|
|
||||||
throw new BadRequestException("角色权限不足, 不能删除:" + systemUserTb.getUsername());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 清理缓存
|
// 清理缓存
|
||||||
List<String> usernameList = systemUserMapper.listUsernameByIds(ids);
|
List<String> usernameList = systemUserMapper.listUsernameByIds(ids);
|
||||||
@@ -207,7 +189,7 @@ public class SystemUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改密码 -> TestPassed
|
* 修改密码
|
||||||
*
|
*
|
||||||
* @param username 用户名
|
* @param username 用户名
|
||||||
* @param args 参数
|
* @param args 参数
|
||||||
@@ -217,19 +199,15 @@ public class SystemUserService {
|
|||||||
String oldPass = KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getOldPass());
|
String oldPass = KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getOldPass());
|
||||||
String newPass = KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getNewPass());
|
String newPass = KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getNewPass());
|
||||||
SystemUserTb user = this.getUserByUsername(username);
|
SystemUserTb user = this.getUserByUsername(username);
|
||||||
if (!passwordEncoder.matches(oldPass, user.getPassword())) {
|
KitValidUtil.isTrue(!passwordEncoder.matches(oldPass, user.getPassword()), "修改失败,旧密码错误");
|
||||||
throw new BadRequestException("修改失败,旧密码错误");
|
KitValidUtil.isTrue(passwordEncoder.matches(newPass, user.getPassword()), "新密码不能与旧密码相同");
|
||||||
}
|
|
||||||
if (passwordEncoder.matches(newPass, user.getPassword())) {
|
|
||||||
throw new BadRequestException("新密码不能与旧密码相同");
|
|
||||||
}
|
|
||||||
String encryptPassword = passwordEncoder.encode(newPass);
|
String encryptPassword = passwordEncoder.encode(newPass);
|
||||||
systemUserMapper.updateUserPasswordByUsername(username, encryptPassword);
|
systemUserMapper.updateUserPasswordByUsername(username, encryptPassword);
|
||||||
systemUserInfoDAO.deleteUserLoginInfoByUserName(username);
|
systemUserInfoDAO.deleteUserLoginInfoByUserName(username);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重置密码 -> TestPassed
|
* 重置密码
|
||||||
*
|
*
|
||||||
* @param ids 用户id
|
* @param ids 用户id
|
||||||
*/
|
*/
|
||||||
@@ -249,7 +227,7 @@ public class SystemUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改头像 -> TestPassed
|
* 修改头像
|
||||||
*
|
*
|
||||||
* @param multipartFile 文件
|
* @param multipartFile 文件
|
||||||
* @return /
|
* @return /
|
||||||
@@ -258,17 +236,13 @@ public class SystemUserService {
|
|||||||
public Map<String, String> updateUserAvatar(MultipartFile multipartFile) {
|
public Map<String, String> updateUserAvatar(MultipartFile multipartFile) {
|
||||||
SystemUserTb user = this.getUserByUsername(KitSecurityHelper.getCurrentUsername());
|
SystemUserTb user = this.getUserByUsername(KitSecurityHelper.getCurrentUsername());
|
||||||
String username = user.getUsername();
|
String username = user.getUsername();
|
||||||
if (StrUtil.isBlank(username)) {
|
KitValidUtil.isBlank(username, "异常用户数据, 请联系管理员处理");
|
||||||
throw new BadRequestException("异常用户数据, 请联系管理员处理!");
|
|
||||||
}
|
|
||||||
// 文件大小验证
|
// 文件大小验证
|
||||||
KitFileUtil.checkSize(fileUploadPathHelper.getAvatarMaxSize(), multipartFile.getSize());
|
KitFileUtil.checkSize(fileUploadPathHelper.getAvatarMaxSize(), multipartFile.getSize());
|
||||||
// 验证文件上传的格式
|
// 验证文件上传的格式
|
||||||
String image = "gif jpg png jpeg";
|
String image = "gif jpg png jpeg";
|
||||||
String fileType = KitFileUtil.getSuffix(multipartFile.getOriginalFilename());
|
String fileType = KitFileUtil.getSuffix(multipartFile.getOriginalFilename());
|
||||||
if (fileType != null && !image.contains(fileType)) {
|
KitValidUtil.isTrue(fileType != null && !image.contains(fileType), "文件格式错误, 仅支持 " + image + " 格式");
|
||||||
throw new BadRequestException("文件格式错误, 仅支持 " + image + " 格式!");
|
|
||||||
}
|
|
||||||
String oldPath = user.getAvatarPath();
|
String oldPath = user.getAvatarPath();
|
||||||
File file = KitFileUtil.upload(multipartFile, fileUploadPathHelper.getPath());
|
File file = KitFileUtil.upload(multipartFile, fileUploadPathHelper.getPath());
|
||||||
user.setAvatarPath(Objects.requireNonNull(file).getPath());
|
user.setAvatarPath(Objects.requireNonNull(file).getPath());
|
||||||
@@ -284,7 +258,7 @@ public class SystemUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改邮箱 -> TestPassed
|
* 修改邮箱
|
||||||
*
|
*
|
||||||
* @param username 用户名
|
* @param username 用户名
|
||||||
* @param args 参数
|
* @param args 参数
|
||||||
@@ -294,16 +268,14 @@ public class SystemUserService {
|
|||||||
public void updateUserEmailByUsername(String username, SystemUserTb args, String code) throws Exception {
|
public void updateUserEmailByUsername(String username, SystemUserTb args, String code) throws Exception {
|
||||||
String password = KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getPassword());
|
String password = KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getPassword());
|
||||||
SystemUserTb user = this.getUserByUsername(username);
|
SystemUserTb user = this.getUserByUsername(username);
|
||||||
if (!passwordEncoder.matches(password, user.getPassword())) {
|
KitValidUtil.isTrue(!passwordEncoder.matches(password, user.getPassword()), "密码错误");
|
||||||
throw new BadRequestException("密码错误");
|
|
||||||
}
|
|
||||||
systemEmailService.checkEmailCaptchaV1(SystemCaptchaBizEnum.EMAIL_RESET_EMAIL_CODE, args.getEmail(), code);
|
systemEmailService.checkEmailCaptchaV1(SystemCaptchaBizEnum.EMAIL_RESET_EMAIL_CODE, args.getEmail(), code);
|
||||||
systemUserMapper.updateUserEmailByUsername(username, args.getEmail());
|
systemUserMapper.updateUserEmailByUsername(username, args.getEmail());
|
||||||
systemUserInfoDAO.deleteUserLoginInfoByUserName(username);
|
systemUserInfoDAO.deleteUserLoginInfoByUserName(username);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询全部 -> TestPassed
|
* 查询全部
|
||||||
*
|
*
|
||||||
* @param args 条件
|
* @param args 条件
|
||||||
* @param page 分页参数
|
* @param page 分页参数
|
||||||
@@ -360,12 +332,12 @@ public class SystemUserService {
|
|||||||
* @param username 用户名
|
* @param username 用户名
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public SystemUserVo getUserVoByUsername(String username) {
|
public SystemUserVo getUserVoByUsername(String username, boolean includePassword) {
|
||||||
return this.convertToUserVo(this.getUserByUsername(username), false);
|
return this.convertToUserVo(this.getUserByUsername(username), includePassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 聚合查询 -> TestPassed
|
* 聚合查询
|
||||||
*/
|
*/
|
||||||
public KitPageResult<SystemUserVo> aggregationSearchUserByArgs(Page<SystemUserTb> page, SystemQueryUserArgs args, String currentUsername) {
|
public KitPageResult<SystemUserVo> aggregationSearchUserByArgs(Page<SystemUserTb> page, SystemQueryUserArgs args, String currentUsername) {
|
||||||
if (!ObjectUtils.isEmpty(args.getDeptId())) {
|
if (!ObjectUtils.isEmpty(args.getDeptId())) {
|
||||||
@@ -377,7 +349,7 @@ public class SystemUserService {
|
|||||||
args.getDeptIds().addAll(systemDeptService.queryChildDeptIdByDeptIds(data, deptPidMap));
|
args.getDeptIds().addAll(systemDeptService.queryChildDeptIdByDeptIds(data, deptPidMap));
|
||||||
}
|
}
|
||||||
// 数据权限
|
// 数据权限
|
||||||
List<Long> dataScopes = systemDataService.queryDeptIdByArgs(this.getUserVoByUsername(currentUsername));
|
List<Long> dataScopes = systemDataService.queryDeptIdByArgs(this.getUserVoByUsername(currentUsername, false));
|
||||||
// args.getDeptIds() 不为空并且数据权限不为空则取交集
|
// args.getDeptIds() 不为空并且数据权限不为空则取交集
|
||||||
if (!CollUtil.isEmpty(args.getDeptIds()) && !CollUtil.isEmpty(dataScopes)) {
|
if (!CollUtil.isEmpty(args.getDeptIds()) && !CollUtil.isEmpty(dataScopes)) {
|
||||||
// 取交集
|
// 取交集
|
||||||
@@ -394,7 +366,7 @@ public class SystemUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出 -> TestPassed
|
* 导出
|
||||||
*/
|
*/
|
||||||
public void exportUserXlsx(HttpServletResponse response, SystemQueryUserArgs args) {
|
public void exportUserXlsx(HttpServletResponse response, SystemQueryUserArgs args) {
|
||||||
long totalCount = this.countUserByArgs(args);
|
long totalCount = this.countUserByArgs(args);
|
||||||
@@ -511,15 +483,9 @@ public class SystemUserService {
|
|||||||
*/
|
*/
|
||||||
private void injectQueryParams(SystemQueryUserArgs args, LambdaQueryWrapper<SystemUserTb> wrapper) {
|
private void injectQueryParams(SystemQueryUserArgs args, LambdaQueryWrapper<SystemUserTb> wrapper) {
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
if (args.getId() != null) {
|
wrapper.eq(args.getId() != null, SystemUserTb::getId, args.getId());
|
||||||
wrapper.eq(SystemUserTb::getId, args.getId());
|
wrapper.eq(args.getEnabled() != null, SystemUserTb::getEnabled, args.getEnabled());
|
||||||
}
|
wrapper.in(CollUtil.isNotEmpty(args.getDeptIds()), SystemUserTb::getDeptId, args.getDeptIds());
|
||||||
if (args.getEnabled() != null) {
|
|
||||||
wrapper.eq(SystemUserTb::getEnabled, args.getEnabled());
|
|
||||||
}
|
|
||||||
if (CollUtil.isNotEmpty(args.getDeptIds())) {
|
|
||||||
wrapper.in(SystemUserTb::getDeptId, args.getDeptIds());
|
|
||||||
}
|
|
||||||
if (StrUtil.isNotBlank(args.getBlurry())) {
|
if (StrUtil.isNotBlank(args.getBlurry())) {
|
||||||
wrapper.and(w -> w.like(SystemUserTb::getUsername, args.getBlurry()).or()
|
wrapper.and(w -> w.like(SystemUserTb::getUsername, args.getBlurry()).or()
|
||||||
.like(SystemUserTb::getNickName, args.getBlurry()).or().like(SystemUserTb::getEmail, args.getBlurry()));
|
.like(SystemUserTb::getNickName, args.getBlurry()).or().like(SystemUserTb::getEmail, args.getBlurry()));
|
||||||
@@ -532,7 +498,7 @@ public class SystemUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换为SystemUserVo并关联查询部门、角色、岗位信息 -> TestPassed
|
* 转换为SystemUserVo并关联查询部门、角色、岗位信息
|
||||||
*
|
*
|
||||||
* @param user 用户基本信息
|
* @param user 用户基本信息
|
||||||
* @param includePassword 是否包含用户密码
|
* @param includePassword 是否包含用户密码
|
||||||
|
|||||||
+2
-5
@@ -80,11 +80,8 @@ public class SystemMinioStorageServiceImpl extends ServiceImpl<SystemOssStorageM
|
|||||||
return KitPageUtil.toPage(ossStorageTbs);
|
return KitPageUtil.toPage(ossStorageTbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IPage<SystemOssStorageVo> selectOssStorageByArgs(
|
private IPage<SystemOssStorageVo> selectOssStorageByArgs(SystemQueryStorageArgs args, Page<SystemOssStorageTb> page) {
|
||||||
SystemQueryStorageArgs args,
|
KitValidUtil.isNull(args);
|
||||||
Page<SystemOssStorageTb> page
|
|
||||||
) {
|
|
||||||
KitValidUtil.notNull(args);
|
|
||||||
LambdaQueryWrapper<SystemOssStorageTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemOssStorageTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.and(
|
wrapper.and(
|
||||||
StrUtil.isNotBlank(args.getBlurry()),
|
StrUtil.isNotBlank(args.getBlurry()),
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ package cn.odboy.util;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
|
import java.text.NumberFormat;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -133,6 +134,23 @@ public final class KitBigDecimalUtil {
|
|||||||
return yuan.multiply(BigDecimal.valueOf(100)).setScale(0, RoundingMode.HALF_UP).longValue();
|
return yuan.multiply(BigDecimal.valueOf(100)).setScale(0, RoundingMode.HALF_UP).longValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化为 xxx,xxx,xxx 格式
|
||||||
|
*
|
||||||
|
* @param obj 金额
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
public static String formatGroupingAmount(Object obj) {
|
||||||
|
if (obj == null) {
|
||||||
|
return "0";
|
||||||
|
}
|
||||||
|
BigDecimal bigDecimal = toBigDecimal(obj);
|
||||||
|
NumberFormat nf = NumberFormat.getInstance();
|
||||||
|
// 启用千位分隔符
|
||||||
|
nf.setGroupingUsed(true);
|
||||||
|
return nf.format(bigDecimal.setScale(0, RoundingMode.HALF_UP));
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
BigDecimal num1 = new BigDecimal("10.123");
|
BigDecimal num1 = new BigDecimal("10.123");
|
||||||
BigDecimal num2 = new BigDecimal("2.456");
|
BigDecimal num2 = new BigDecimal("2.456");
|
||||||
|
|||||||
@@ -15,9 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package cn.odboy.util;
|
package cn.odboy.util;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.odboy.base.KitSelectOptionVo;
|
import cn.odboy.base.KitSelectOptionVo;
|
||||||
import cn.odboy.framework.exception.BadRequestException;
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -194,7 +192,7 @@ public final class KitCollUtil extends cn.hutool.core.collection.CollUtil {
|
|||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public static BigDecimal streamBigDecimalAvg(List<BigDecimal> data) {
|
public static BigDecimal streamBigDecimalAvg(List<BigDecimal> data) {
|
||||||
KitValidUtil.notEmpty(data, "data");
|
KitValidUtil.isEmpty(data, "data");
|
||||||
return data.stream().filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add)
|
return data.stream().filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add)
|
||||||
.divide(BigDecimal.valueOf(data.size()), 6, RoundingMode.FLOOR);
|
.divide(BigDecimal.valueOf(data.size()), 6, RoundingMode.FLOOR);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ package cn.odboy.util;
|
|||||||
|
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
@@ -129,4 +130,22 @@ public class KitDateUtil {
|
|||||||
}
|
}
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得当天是周几
|
||||||
|
*/
|
||||||
|
public static String getWeekDay() {
|
||||||
|
String[] weekDays = {"星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
cal.setTime(new Date());
|
||||||
|
int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
|
||||||
|
if (w < 0) {
|
||||||
|
w = 0;
|
||||||
|
}
|
||||||
|
return weekDays[w];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.err.println(getWeekDay());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package cn.odboy.util;
|
package cn.odboy.util;
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@@ -97,19 +95,4 @@ public final class KitStringUtil {
|
|||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得当天是周几
|
|
||||||
*/
|
|
||||||
public static String getWeekDay() {
|
|
||||||
// String[] weekDays = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
|
|
||||||
String[] weekDays = {"星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期天"};
|
|
||||||
Calendar cal = Calendar.getInstance();
|
|
||||||
cal.setTime(new Date());
|
|
||||||
int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
|
|
||||||
if (w < 0) {
|
|
||||||
w = 0;
|
|
||||||
}
|
|
||||||
return weekDays[w];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package cn.odboy.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
|
|
||||||
|
public class KitThreadUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 可中断的睡眠
|
||||||
|
*/
|
||||||
|
public static void interruptSleep(int i) throws InterruptedException {
|
||||||
|
Thread.sleep(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void safeSleep(int i) {
|
||||||
|
ThreadUtil.safeSleep(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -46,6 +46,12 @@ public final class KitValidUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证实体是否通过校验 <br/> 实体内通过 javax.validation.constraints 中的表达式限制参数 <br/>
|
||||||
|
*
|
||||||
|
* @param object /
|
||||||
|
* @param <T> /
|
||||||
|
*/
|
||||||
public static <T> void validate(T object) {
|
public static <T> void validate(T object) {
|
||||||
Set<ConstraintViolation<T>> violations = VALIDATOR.validate(object, Default.class);
|
Set<ConstraintViolation<T>> violations = VALIDATOR.validate(object, Default.class);
|
||||||
if (!violations.isEmpty()) {
|
if (!violations.isEmpty()) {
|
||||||
@@ -54,39 +60,125 @@ public final class KitValidUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void notNull(Object value) {
|
/**
|
||||||
|
* 参数为null,抛异常
|
||||||
|
*
|
||||||
|
* @param value 参数值
|
||||||
|
*/
|
||||||
|
public static void isNull(Object value) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new BadRequestException("参数必填");
|
throw new BadRequestException("参数必填");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void isNull(Object value) {
|
/**
|
||||||
if (value != null) {
|
* 参数为空,抛异常
|
||||||
throw new BadRequestException("参数非必填");
|
*
|
||||||
}
|
* @param value 参数值
|
||||||
}
|
* @param name 参数名称
|
||||||
|
* @param code 参数编码
|
||||||
public static void notNull(Object value, @NotNull String name, @NotNull String code) {
|
*/
|
||||||
|
public static void isNull(Object value, @NotNull String name, @NotNull String code) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new BadRequestException(String.format("参数 %s(%s) 必填", name, code));
|
throw new BadRequestException(String.format("参数 %s(%s) 必填", name, code));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void isBlank(CharSequence value, @NotNull String name, @NotNull String code) {
|
/**
|
||||||
if (StrUtil.isNotBlank(value)) {
|
* 参数为空,抛异常
|
||||||
throw new BadRequestException(String.format("参数 %s(%s) 非必填", name, code));
|
*
|
||||||
|
* @param value 参数值
|
||||||
|
* @param message 异常信息
|
||||||
|
*/
|
||||||
|
public static void isNull(Object value, @NotNull String message) {
|
||||||
|
if (value == null) {
|
||||||
|
throw new BadRequestException(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void notBlank(CharSequence value, @NotNull String name, @NotNull String code) {
|
/**
|
||||||
|
* 参数为空,抛异常
|
||||||
|
*
|
||||||
|
* @param value 参数值
|
||||||
|
* @param code 参数编码
|
||||||
|
*/
|
||||||
|
public static void isNullF(Object value, @NotNull String code) {
|
||||||
|
if (value == null) {
|
||||||
|
throw new BadRequestException(String.format("参数 %s 必填", code));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数为空字符串,抛异常
|
||||||
|
*
|
||||||
|
* @param value 参数值
|
||||||
|
* @param name 参数名称
|
||||||
|
* @param code 参数编码
|
||||||
|
*/
|
||||||
|
public static void isBlank(CharSequence value, @NotNull String name, @NotNull String code) {
|
||||||
if (StrUtil.isBlank(value)) {
|
if (StrUtil.isBlank(value)) {
|
||||||
throw new BadRequestException(String.format("参数 %s(%s) 必填", name, code));
|
throw new BadRequestException(String.format("参数 %s(%s) 必填", name, code));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void notEmpty(List<?> data, @NotNull String code) {
|
/**
|
||||||
|
* 集合为空,抛异常
|
||||||
|
*
|
||||||
|
* @param data 集合值
|
||||||
|
* @param code 参数编码
|
||||||
|
*/
|
||||||
|
public static void isEmpty(List<?> data, @NotNull String code) {
|
||||||
if (CollUtil.isEmpty(data)) {
|
if (CollUtil.isEmpty(data)) {
|
||||||
throw new BadRequestException(String.format("参数 %s 必填", code));
|
throw new BadRequestException(String.format("参数 %s 必填", code));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 集合为空,抛异常
|
||||||
|
*
|
||||||
|
* @param data 集合值
|
||||||
|
* @param name 参数名称
|
||||||
|
* @param code 参数编码
|
||||||
|
*/
|
||||||
|
public static void isEmpty(List<?> data, @NotNull String name, @NotNull String code) {
|
||||||
|
if (CollUtil.isEmpty(data)) {
|
||||||
|
throw new BadRequestException(String.format("参数 %s(%s) 必填", name, code));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表达式为true,抛异常
|
||||||
|
*
|
||||||
|
* @param condition 表达式
|
||||||
|
* @param message 异常信息
|
||||||
|
*/
|
||||||
|
public static void isTrue(boolean condition, String message) {
|
||||||
|
if (condition) {
|
||||||
|
throw new BadRequestException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表达式为false,抛异常
|
||||||
|
*
|
||||||
|
* @param condition 表达式
|
||||||
|
* @param message 异常信息
|
||||||
|
*/
|
||||||
|
public static void isFalse(boolean condition, String message) {
|
||||||
|
if (!condition) {
|
||||||
|
throw new BadRequestException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数为空字符串,抛异常
|
||||||
|
*
|
||||||
|
* @param value 参数值
|
||||||
|
* @param message 异常信息
|
||||||
|
*/
|
||||||
|
public static void isBlank(String value, String message) {
|
||||||
|
if (StrUtil.isBlank(value)) {
|
||||||
|
throw new BadRequestException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application;
|
package cn.odboy.system.application;
|
||||||
|
|
||||||
import cn.odboy.system.application.model.CuteDeptTreeVo;
|
import cn.odboy.system.application.model.CuteDeptTreeVo;
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application;
|
package cn.odboy.system.application;
|
||||||
|
|
||||||
import cn.odboy.system.application.service.CuteFileUploadService;
|
import cn.odboy.system.application.service.CuteFileUploadService;
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application;
|
package cn.odboy.system.application;
|
||||||
|
|
||||||
import cn.odboy.system.application.service.CuteProductLineSelectService;
|
import cn.odboy.system.application.service.CuteProductLineSelectService;
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application;
|
package cn.odboy.system.application;
|
||||||
|
|
||||||
import cn.odboy.system.application.service.CuteProductLineSelectProService;
|
import cn.odboy.system.application.service.CuteProductLineSelectProService;
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application;
|
package cn.odboy.system.application;
|
||||||
|
|
||||||
import cn.odboy.system.application.model.CuteUserSelectVo;
|
import cn.odboy.system.application.model.CuteUserSelectVo;
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application.model;
|
package cn.odboy.system.application.model;
|
||||||
|
|
||||||
import cn.odboy.base.KitObject;
|
import cn.odboy.base.KitObject;
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application.model;
|
package cn.odboy.system.application.model;
|
||||||
|
|
||||||
import cn.odboy.base.KitObject;
|
import cn.odboy.base.KitObject;
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application.service;
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application.service;
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application.service;
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application.service;
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
import cn.odboy.system.application.model.CuteProductLineSelectProVo;
|
import cn.odboy.system.application.model.CuteProductLineSelectProVo;
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application.service;
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||||
|
|||||||
+15
@@ -1,3 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021-2026 Odboy
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package cn.odboy.system.application.service;
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user