fix():格式规范修改
parent
44a9e29996
commit
782ec652ed
|
@ -25,17 +25,22 @@ import org.springframework.stereotype.Component;
|
|||
*/
|
||||
@Component
|
||||
public class SysLoginService {
|
||||
@Autowired
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
private final RemoteUserService remoteUserService;
|
||||
|
||||
private final SysPasswordService passwordService;
|
||||
|
||||
private final SysRecordLogService recordLogService;
|
||||
|
||||
private final RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
private SysPasswordService passwordService;
|
||||
|
||||
@Autowired
|
||||
private SysRecordLogService recordLogService;
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
public SysLoginService(RemoteUserService remoteUserService, SysPasswordService passwordService, SysRecordLogService recordLogService, RedisService redisService) {
|
||||
this.remoteUserService = remoteUserService;
|
||||
this.passwordService = passwordService;
|
||||
this.recordLogService = recordLogService;
|
||||
this.redisService = redisService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录
|
||||
|
|
|
@ -18,15 +18,15 @@ import java.util.concurrent.TimeUnit;
|
|||
*/
|
||||
@Component
|
||||
public class SysPasswordService {
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
private int maxRetryCount = CacheConstants.PASSWORD_MAX_RETRY_COUNT;
|
||||
|
||||
private Long lockTime = CacheConstants.PASSWORD_LOCK_TIME;
|
||||
private SysRecordLogService recordLogService;
|
||||
|
||||
@Autowired
|
||||
private SysRecordLogService recordLogService;
|
||||
public SysPasswordService(RedisService redisService, SysRecordLogService recordLogService) {
|
||||
this.redisService = redisService;
|
||||
this.recordLogService = recordLogService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录账户密码错误次数缓存键名
|
||||
|
@ -48,8 +48,10 @@ public class SysPasswordService {
|
|||
retryCount = 0;
|
||||
}
|
||||
|
||||
if (retryCount >= Integer.valueOf(maxRetryCount).intValue()) {
|
||||
String errMsg = String.format("密码输入错误%s次,帐户锁定%s分钟", maxRetryCount, lockTime);
|
||||
int passwordMaxRetryCount = CacheConstants.PASSWORD_MAX_RETRY_COUNT;
|
||||
Long lockTime = CacheConstants.PASSWORD_LOCK_TIME;
|
||||
if (retryCount >= passwordMaxRetryCount) {
|
||||
String errMsg = String.format("密码输入错误%s次,帐户锁定%s分钟", passwordMaxRetryCount, lockTime);
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, errMsg);
|
||||
throw new ServiceException(errMsg);
|
||||
}
|
||||
|
|
|
@ -16,8 +16,12 @@ import org.springframework.stereotype.Component;
|
|||
*/
|
||||
@Component
|
||||
public class SysRecordLogService {
|
||||
private final RemoteLogService remoteLogService;
|
||||
|
||||
@Autowired
|
||||
private RemoteLogService remoteLogService;
|
||||
public SysRecordLogService(RemoteLogService remoteLogService) {
|
||||
this.remoteLogService = remoteLogService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录登录信息
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
/**
|
||||
* 自定义导出Excel数据注解
|
||||
|
@ -51,7 +52,7 @@ public @interface Excel {
|
|||
/**
|
||||
* BigDecimal 舍入规则 默认:BigDecimal.ROUND_HALF_EVEN
|
||||
*/
|
||||
int roundingMode () default BigDecimal.ROUND_HALF_EVEN;
|
||||
RoundingMode roundingMode () default RoundingMode.HALF_UP;
|
||||
|
||||
/**
|
||||
* 导出时在excel中每个列的高度
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
package com.muyu.common.core.constant;
|
||||
|
||||
/**
|
||||
* 任务调度通用常量
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class ScheduleConstants {
|
||||
public static final String TASK_CLASS_NAME = "TASK_CLASS_NAME";
|
||||
|
||||
/**
|
||||
* 执行目标key
|
||||
*/
|
||||
public static final String TASK_PROPERTIES = "TASK_PROPERTIES";
|
||||
|
||||
/**
|
||||
* 默认
|
||||
*/
|
||||
public static final String MISFIRE_DEFAULT = "0";
|
||||
|
||||
/**
|
||||
* 立即触发执行
|
||||
*/
|
||||
public static final String MISFIRE_IGNORE_MISFIRES = "1";
|
||||
|
||||
/**
|
||||
* 触发一次执行
|
||||
*/
|
||||
public static final String MISFIRE_FIRE_AND_PROCEED = "2";
|
||||
|
||||
/**
|
||||
* 不触发立即执行
|
||||
*/
|
||||
public static final String MISFIRE_DO_NOTHING = "3";
|
||||
|
||||
public enum Status {
|
||||
/**
|
||||
* 正常
|
||||
*/
|
||||
NORMAL("0"),
|
||||
/**
|
||||
* 暂停
|
||||
*/
|
||||
PAUSE("1");
|
||||
|
||||
private String value;
|
||||
|
||||
private Status (String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue () {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -35,7 +35,7 @@ public class SecurityContextHolder {
|
|||
public static Map<String, Object> getLocalMap () {
|
||||
Map<String, Object> map = THREAD_LOCAL.get();
|
||||
if (map == null) {
|
||||
map = new ConcurrentHashMap<String, Object>();
|
||||
map = new ConcurrentHashMap<>();
|
||||
THREAD_LOCAL.set(map);
|
||||
}
|
||||
return map;
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package com.muyu.common.core.exception;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 全局异常
|
||||
*
|
||||
|
@ -16,7 +19,7 @@ public class GlobalException extends RuntimeException {
|
|||
/**
|
||||
* 错误明细,内部调试错误
|
||||
* <p>
|
||||
* 和 {@link CommonResult#getDetailMessage()} 一致的设计
|
||||
* 和 {@link Result#getMsg()} ()} 一致的设计
|
||||
*/
|
||||
private String detailMessage;
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.muyu.common.core.exception;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
|
||||
/**
|
||||
* 业务异常
|
||||
*
|
||||
|
@ -21,7 +23,7 @@ public final class ServiceException extends RuntimeException {
|
|||
/**
|
||||
* 错误明细,内部调试错误
|
||||
* <p>
|
||||
* 和 {@link CommonResult#getDetailMessage()} 一致的设计
|
||||
* 和 {@link Result#getMsg()} 一致的设计
|
||||
*/
|
||||
private String detailMessage;
|
||||
|
||||
|
|
|
@ -11,22 +11,22 @@ public class BaseException extends RuntimeException {
|
|||
/**
|
||||
* 所属模块
|
||||
*/
|
||||
private String module;
|
||||
private final String module;
|
||||
|
||||
/**
|
||||
* 错误码
|
||||
*/
|
||||
private String code;
|
||||
private final String code;
|
||||
|
||||
/**
|
||||
* 错误码对应的参数
|
||||
*/
|
||||
private Object[] args;
|
||||
private final Object[] args;
|
||||
|
||||
/**
|
||||
* 错误消息
|
||||
*/
|
||||
private String defaultMessage;
|
||||
private final String defaultMessage;
|
||||
|
||||
public BaseException (String module, String code, Object[] args, String defaultMessage) {
|
||||
this.module = module;
|
||||
|
|
|
@ -10,9 +10,9 @@ import java.util.Arrays;
|
|||
public class InvalidExtensionException extends FileUploadException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String[] allowedExtension;
|
||||
private String extension;
|
||||
private String filename;
|
||||
private final String[] allowedExtension;
|
||||
private final String extension;
|
||||
private final String filename;
|
||||
|
||||
public InvalidExtensionException (String[] allowedExtension, String extension, String filename) {
|
||||
super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : [" + Arrays.toString(allowedExtension) + "]");
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
package com.muyu.common.core.exception.job;
|
||||
|
||||
/**
|
||||
* 计划策略异常
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class TaskException extends Exception {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Code code;
|
||||
|
||||
public TaskException (String msg, Code code) {
|
||||
this(msg, code, null);
|
||||
}
|
||||
|
||||
public TaskException (String msg, Code code, Exception nestedEx) {
|
||||
super(msg, nestedEx);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Code getCode () {
|
||||
return code;
|
||||
}
|
||||
|
||||
public enum Code {
|
||||
TASK_EXISTS, NO_TASK_EXISTS, TASK_ALREADY_STARTED, UNKNOWN, CONFIG_ERROR, TASK_NODE_NOT_AVAILABLE
|
||||
}
|
||||
}
|
|
@ -5,12 +5,12 @@ import org.springframework.cloud.openfeign.support.SpringMvcContract;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 定义OpenFigen契约
|
||||
* @author dongzeliang
|
||||
*/
|
||||
@Configuration
|
||||
public class FeginConfig {
|
||||
// @Bean
|
||||
// public Contract feignConfiguration() {
|
||||
// return new feign.Contract.Default();
|
||||
// }
|
||||
|
||||
@Bean
|
||||
public Contract feignConfiguration() {
|
||||
|
|
|
@ -511,19 +511,11 @@ public class Convert {
|
|||
return defaultValue;
|
||||
}
|
||||
valueStr = valueStr.trim().toLowerCase();
|
||||
switch (valueStr) {
|
||||
case "true":
|
||||
case "yes":
|
||||
case "ok":
|
||||
case "1":
|
||||
return true;
|
||||
case "false":
|
||||
case "no":
|
||||
case "0":
|
||||
return false;
|
||||
default:
|
||||
return defaultValue;
|
||||
}
|
||||
return switch (valueStr) {
|
||||
case "true", "yes", "ok", "1" -> true;
|
||||
case "false", "no", "0" -> false;
|
||||
default -> defaultValue;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,17 +14,17 @@ import java.util.Date;
|
|||
* @author muyu
|
||||
*/
|
||||
public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
||||
public static String YYYY = "yyyy";
|
||||
public static final String YYYY = "yyyy";
|
||||
|
||||
public static String YYYY_MM = "yyyy-MM";
|
||||
public static final String YYYY_MM = "yyyy-MM";
|
||||
|
||||
public static String YYYY_MM_DD = "yyyy-MM-dd";
|
||||
public static final String YYYY_MM_DD = "yyyy-MM-dd";
|
||||
|
||||
public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
|
||||
public static final String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
|
||||
|
||||
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||
public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
private static String[] parsePatterns = {
|
||||
private static final String[] PARSE_PATTERNS = {
|
||||
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
|
||||
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
|
||||
"yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
|
||||
|
@ -99,7 +99,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||
return null;
|
||||
}
|
||||
try {
|
||||
return parseDate(str.toString(), parsePatterns);
|
||||
return parseDate(str.toString(), PARSE_PATTERNS);
|
||||
} catch (ParseException e) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -487,17 +487,13 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
if (s != null) {
|
||||
final int len = s.length();
|
||||
if (s.length() <= size) {
|
||||
for (int i = size - len ; i > 0 ; i--) {
|
||||
sb.append(c);
|
||||
}
|
||||
sb.append(String.valueOf(c).repeat(size - len));
|
||||
sb.append(s);
|
||||
} else {
|
||||
return s.substring(len - size, len);
|
||||
}
|
||||
} else {
|
||||
for (int i = size ; i > 0 ; i--) {
|
||||
sb.append(c);
|
||||
}
|
||||
sb.append(String.valueOf(c).repeat(Math.max(0, size)));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class BeanUtils extends org.springframework.beans.BeanUtils {
|
|||
*/
|
||||
public static List<Method> getSetterMethods (Object obj) {
|
||||
// setter方法列表
|
||||
List<Method> setterMethods = new ArrayList<Method>();
|
||||
List<Method> setterMethods = new ArrayList<>();
|
||||
|
||||
// 获取所有方法
|
||||
Method[] methods = obj.getClass().getMethods();
|
||||
|
@ -77,7 +77,7 @@ public class BeanUtils extends org.springframework.beans.BeanUtils {
|
|||
|
||||
public static List<Method> getGetterMethods (Object obj) {
|
||||
// getter方法列表
|
||||
List<Method> getterMethods = new ArrayList<Method>();
|
||||
List<Method> getterMethods = new ArrayList<>();
|
||||
// 获取所有方法
|
||||
Method[] methods = obj.getClass().getMethods();
|
||||
// 查找getter方法
|
||||
|
|
|
@ -25,7 +25,7 @@ public class FileUtils {
|
|||
*/
|
||||
public static final char BACKSLASH = '\\';
|
||||
|
||||
public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+";
|
||||
public final static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+";
|
||||
|
||||
/**
|
||||
* 输出指定文件的byte数组
|
||||
|
|
|
@ -23,7 +23,7 @@ public class ImageUtils {
|
|||
try {
|
||||
return IOUtils.toByteArray(is);
|
||||
} catch (Exception e) {
|
||||
log.error("图片加载异常 {}", e);
|
||||
log.error("图片加载异常 {}", e.getMessage(), e);
|
||||
return null;
|
||||
} finally {
|
||||
IOUtils.closeQuietly(is);
|
||||
|
@ -36,7 +36,7 @@ public class ImageUtils {
|
|||
result = Arrays.copyOf(result, result.length);
|
||||
return new ByteArrayInputStream(result);
|
||||
} catch (Exception e) {
|
||||
log.error("获取图片异常 {}", e);
|
||||
log.error("获取图片异常 {}", e.getMessage(), e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class ImageUtils {
|
|||
in = urlConnection.getInputStream();
|
||||
return IOUtils.toByteArray(in);
|
||||
} catch (Exception e) {
|
||||
log.error("访问文件异常 {}", e);
|
||||
log.error("访问文件异常 {}", e.getMessage(), e);
|
||||
return null;
|
||||
} finally {
|
||||
IOUtils.closeQuietly(in);
|
||||
|
|
|
@ -38,19 +38,13 @@ public class MimeTypeUtils {
|
|||
"pdf"};
|
||||
|
||||
public static String getExtension (String prefix) {
|
||||
switch (prefix) {
|
||||
case IMAGE_PNG:
|
||||
return "png";
|
||||
case IMAGE_JPG:
|
||||
return "jpg";
|
||||
case IMAGE_JPEG:
|
||||
return "jpeg";
|
||||
case IMAGE_BMP:
|
||||
return "bmp";
|
||||
case IMAGE_GIF:
|
||||
return "gif";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
return switch (prefix) {
|
||||
case IMAGE_PNG -> "png";
|
||||
case IMAGE_JPG -> "jpg";
|
||||
case IMAGE_JPEG -> "jpeg";
|
||||
case IMAGE_BMP -> "bmp";
|
||||
case IMAGE_GIF -> "gif";
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,9 +140,6 @@ public class EscapeUtil {
|
|||
public static void main (String[] args) {
|
||||
String html = "<script>alert(1);</script>";
|
||||
String escape = EscapeUtil.escape(html);
|
||||
// String html = "<scr<script>ipt>alert(\"XSS\")</scr<script>ipt>";
|
||||
// String html = "<123";
|
||||
// String html = "123>";
|
||||
System.out.println("clean: " + EscapeUtil.clean(html));
|
||||
System.out.println("escape: " + escape);
|
||||
System.out.println("unescape: " + EscapeUtil.unescape(escape));
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.muyu.common.core.utils.html;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
@ -15,15 +17,14 @@ public final class HTMLFilter {
|
|||
/**
|
||||
* regex flag union representing /si modifiers in php
|
||||
**/
|
||||
private static final int REGEX_FLAGS_SI = Pattern.CASE_INSENSITIVE | Pattern.DOTALL;
|
||||
private static final Pattern P_COMMENTS = Pattern.compile("<!--(.*?)-->", Pattern.DOTALL);
|
||||
private static final Pattern P_COMMENT = Pattern.compile("^!--(.*)--$", REGEX_FLAGS_SI);
|
||||
private static final Pattern P_COMMENT = Pattern.compile("^!--(.*)--$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
|
||||
private static final Pattern P_TAGS = Pattern.compile("<(.*?)>", Pattern.DOTALL);
|
||||
private static final Pattern P_END_TAG = Pattern.compile("^/([a-z0-9]+)", REGEX_FLAGS_SI);
|
||||
private static final Pattern P_START_TAG = Pattern.compile("^([a-z0-9]+)(.*?)(/?)$", REGEX_FLAGS_SI);
|
||||
private static final Pattern P_QUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)=([\"'])(.*?)\\2", REGEX_FLAGS_SI);
|
||||
private static final Pattern P_UNQUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)(=)([^\"\\s']+)", REGEX_FLAGS_SI);
|
||||
private static final Pattern P_PROTOCOL = Pattern.compile("^([^:]+):", REGEX_FLAGS_SI);
|
||||
private static final Pattern P_END_TAG = Pattern.compile("^/([a-z0-9]+)", Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
|
||||
private static final Pattern P_START_TAG = Pattern.compile("^([a-z0-9]+)(.*?)(/?)$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
|
||||
private static final Pattern P_QUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)=([\"'])(.*?)\\2", Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
|
||||
private static final Pattern P_UNQUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)(=)([^\"\\s']+)", Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
|
||||
private static final Pattern P_PROTOCOL = Pattern.compile("^([^:]+):", Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
|
||||
private static final Pattern P_ENTITY = Pattern.compile("&#(\\d+);?");
|
||||
private static final Pattern P_ENTITY_UNICODE = Pattern.compile("&#x([0-9a-f]+);?");
|
||||
private static final Pattern P_ENCODE = Pattern.compile("%([0-9a-f]{2});?");
|
||||
|
@ -90,6 +91,7 @@ public final class HTMLFilter {
|
|||
* flag determining whether to try to make tags when presented with "unbalanced" angle brackets (e.g. "<b text </b>"
|
||||
* becomes "<b> text </b>"). If set to false, unbalanced angle brackets will be html escaped.
|
||||
*/
|
||||
@Getter
|
||||
private final boolean alwaysMakeTags;
|
||||
|
||||
/**
|
||||
|
@ -98,23 +100,23 @@ public final class HTMLFilter {
|
|||
public HTMLFilter () {
|
||||
vAllowed = new HashMap<>();
|
||||
|
||||
final ArrayList<String> a_atts = new ArrayList<>();
|
||||
a_atts.add("href");
|
||||
a_atts.add("target");
|
||||
vAllowed.put("a", a_atts);
|
||||
final List<String> aAttList = new ArrayList<>();
|
||||
aAttList.add("href");
|
||||
aAttList.add("target");
|
||||
vAllowed.put("a", aAttList);
|
||||
|
||||
final ArrayList<String> img_atts = new ArrayList<>();
|
||||
img_atts.add("src");
|
||||
img_atts.add("width");
|
||||
img_atts.add("height");
|
||||
img_atts.add("alt");
|
||||
vAllowed.put("img", img_atts);
|
||||
final List<String> imgAttList = new ArrayList<>();
|
||||
imgAttList.add("src");
|
||||
imgAttList.add("width");
|
||||
imgAttList.add("height");
|
||||
imgAttList.add("alt");
|
||||
vAllowed.put("img", imgAttList);
|
||||
|
||||
final ArrayList<String> no_atts = new ArrayList<>();
|
||||
vAllowed.put("b", no_atts);
|
||||
vAllowed.put("strong", no_atts);
|
||||
vAllowed.put("i", no_atts);
|
||||
vAllowed.put("em", no_atts);
|
||||
final List<String> noAttList = new ArrayList<>();
|
||||
vAllowed.put("b", noAttList);
|
||||
vAllowed.put("strong", noAttList);
|
||||
vAllowed.put("i", noAttList);
|
||||
vAllowed.put("em", noAttList);
|
||||
|
||||
vSelfClosingTags = new String[]{"img"};
|
||||
vNeedClosingTags = new String[]{"a", "b", "strong", "i", "em"};
|
||||
|
@ -174,8 +176,8 @@ public final class HTMLFilter {
|
|||
return result;
|
||||
}
|
||||
|
||||
private static String regexReplace (final Pattern regex_pattern, final String replacement, final String s) {
|
||||
Matcher m = regex_pattern.matcher(s);
|
||||
private static String regexReplace (final Pattern regexPattern, final String replacement, final String s) {
|
||||
Matcher m = regexPattern.matcher(s);
|
||||
return m.replaceAll(replacement);
|
||||
}
|
||||
|
||||
|
@ -218,10 +220,6 @@ public final class HTMLFilter {
|
|||
return s;
|
||||
}
|
||||
|
||||
public boolean isAlwaysMakeTags () {
|
||||
return alwaysMakeTags;
|
||||
}
|
||||
|
||||
public boolean isStripComments () {
|
||||
return stripComment;
|
||||
}
|
||||
|
@ -270,7 +268,7 @@ public final class HTMLFilter {
|
|||
private String checkTags (String s) {
|
||||
Matcher m = P_TAGS.matcher(s);
|
||||
|
||||
final StringBuffer buf = new StringBuffer();
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
while (m.find()) {
|
||||
String replaceStr = m.group(1);
|
||||
replaceStr = processTag(replaceStr);
|
||||
|
@ -354,11 +352,6 @@ public final class HTMLFilter {
|
|||
for (int ii = 0 ; ii < paramNames.size() ; ii++) {
|
||||
paramName = paramNames.get(ii).toLowerCase();
|
||||
paramValue = paramValues.get(ii);
|
||||
|
||||
// debug( "paramName='" + paramName + "'" );
|
||||
// debug( "paramValue='" + paramValue + "'" );
|
||||
// debug( "allowed? " + vAllowed.get( name ).contains( paramName ) );
|
||||
|
||||
if (allowedAttribute(name, paramName)) {
|
||||
if (inArray(paramName, vProtocolAtts)) {
|
||||
paramValue = processParamProtocol(paramValue);
|
||||
|
@ -375,7 +368,7 @@ public final class HTMLFilter {
|
|||
ending = "";
|
||||
}
|
||||
|
||||
if (ending == null || ending.length() < 1) {
|
||||
if (ending == null || ending.isEmpty()) {
|
||||
if (vTagCounts.containsKey(name)) {
|
||||
vTagCounts.put(name, vTagCounts.get(name) + 1);
|
||||
} else {
|
||||
|
@ -417,32 +410,32 @@ public final class HTMLFilter {
|
|||
}
|
||||
|
||||
private String decodeEntities (String s) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
||||
Matcher m = P_ENTITY.matcher(s);
|
||||
while (m.find()) {
|
||||
final String match = m.group(1);
|
||||
final int decimal = Integer.decode(match).intValue();
|
||||
final int decimal = Integer.decode(match);
|
||||
m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
|
||||
}
|
||||
m.appendTail(buf);
|
||||
s = buf.toString();
|
||||
|
||||
buf = new StringBuffer();
|
||||
buf = new StringBuilder();
|
||||
m = P_ENTITY_UNICODE.matcher(s);
|
||||
while (m.find()) {
|
||||
final String match = m.group(1);
|
||||
final int decimal = Integer.valueOf(match, 16).intValue();
|
||||
final int decimal = Integer.valueOf(match, 16);
|
||||
m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
|
||||
}
|
||||
m.appendTail(buf);
|
||||
s = buf.toString();
|
||||
|
||||
buf = new StringBuffer();
|
||||
buf = new StringBuilder();
|
||||
m = P_ENCODE.matcher(s);
|
||||
while (m.find()) {
|
||||
final String match = m.group(1);
|
||||
final int decimal = Integer.valueOf(match, 16).intValue();
|
||||
final int decimal = Integer.valueOf(match, 16);
|
||||
m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
|
||||
}
|
||||
m.appendTail(buf);
|
||||
|
@ -453,7 +446,7 @@ public final class HTMLFilter {
|
|||
}
|
||||
|
||||
private String validateEntities (final String s) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
||||
// validate entities throughout the string
|
||||
Matcher m = P_VALID_ENTITIES.matcher(s);
|
||||
|
@ -471,7 +464,7 @@ public final class HTMLFilter {
|
|||
|
||||
private String encodeQuotes (final String s) {
|
||||
if (encodeQuotes) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
Matcher m = P_VALID_QUOTES.matcher(s);
|
||||
while (m.find()) {
|
||||
// (>|^)
|
||||
|
|
|
@ -57,7 +57,7 @@ public class ExcelUtil<T> {
|
|||
/**
|
||||
* 实体对象
|
||||
*/
|
||||
public Class<T> clazz;
|
||||
public final Class<T> clazz;
|
||||
/**
|
||||
* 需要排除列属性
|
||||
*/
|
||||
|
@ -121,7 +121,7 @@ public class ExcelUtil<T> {
|
|||
/**
|
||||
* 统计列表
|
||||
*/
|
||||
private Map<Integer, Double> statistics = new HashMap<Integer, Double>();
|
||||
private final Map<Integer, Double> statistics = new HashMap<>();
|
||||
|
||||
public ExcelUtil (Class<T> clazz) {
|
||||
this.clazz = clazz;
|
||||
|
@ -210,7 +210,7 @@ public class ExcelUtil<T> {
|
|||
|
||||
public void init (List<T> list, String sheetName, String title, Type type) {
|
||||
if (list == null) {
|
||||
list = new ArrayList<T>();
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
this.list = list;
|
||||
this.sheetName = sheetName;
|
||||
|
@ -311,7 +311,7 @@ public class ExcelUtil<T> {
|
|||
public List<T> importExcel (String sheetName, InputStream is, int titleNum) throws Exception {
|
||||
this.type = Type.IMPORT;
|
||||
this.wb = WorkbookFactory.create(is);
|
||||
List<T> list = new ArrayList<T>();
|
||||
List<T> list = new ArrayList<>();
|
||||
// 如果指定sheet名,则取指定sheet中的内容 否则默认指向第1个sheet
|
||||
Sheet sheet = StringUtils.isNotEmpty(sheetName) ? wb.getSheet(sheetName) : wb.getSheetAt(0);
|
||||
if (sheet == null) {
|
||||
|
@ -322,7 +322,7 @@ public class ExcelUtil<T> {
|
|||
int rows = sheet.getLastRowNum();
|
||||
if (rows > 0) {
|
||||
// 定义一个map用于存放excel列的序号和field.
|
||||
Map<String, Integer> cellMap = new HashMap<String, Integer>();
|
||||
Map<String, Integer> cellMap = new HashMap<>();
|
||||
// 获取表头
|
||||
Row heard = sheet.getRow(titleNum);
|
||||
for (int i = 0 ; i < heard.getPhysicalNumberOfCells() ; i++) {
|
||||
|
@ -336,7 +336,7 @@ public class ExcelUtil<T> {
|
|||
}
|
||||
// 有数据时才处理 得到类的所有field.
|
||||
List<Object[]> fields = this.getFields();
|
||||
Map<Integer, Object[]> fieldsMap = new HashMap<Integer, Object[]>();
|
||||
Map<Integer, Object[]> fieldsMap = new HashMap<>();
|
||||
for (Object[] objects : fields) {
|
||||
Excel attr = (Excel) objects[1];
|
||||
Integer column = cellMap.get(attr.name());
|
||||
|
@ -356,7 +356,7 @@ public class ExcelUtil<T> {
|
|||
Object val = this.getCellValue(row, entry.getKey());
|
||||
|
||||
// 如果不存在实例则新建.
|
||||
entity = (entity == null ? clazz.newInstance() : entity);
|
||||
entity = (entity == null ? clazz.getDeclaredConstructor().newInstance() : entity);
|
||||
// 从map中得到对应列的field.
|
||||
Field field = (Field) entry.getValue()[0];
|
||||
Excel attr = (Excel) entry.getValue()[1];
|
||||
|
@ -582,7 +582,7 @@ public class ExcelUtil<T> {
|
|||
*/
|
||||
private Map<String, CellStyle> createStyles (Workbook wb) {
|
||||
// 写入各条记录,每条记录对应excel表中的一行
|
||||
Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
|
||||
Map<String, CellStyle> styles = new HashMap<>();
|
||||
CellStyle style = wb.createCellStyle();
|
||||
style.setAlignment(HorizontalAlignment.CENTER);
|
||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
|
@ -634,7 +634,7 @@ public class ExcelUtil<T> {
|
|||
* @return 自定义样式列表
|
||||
*/
|
||||
private Map<String, CellStyle> annotationHeaderStyles (Workbook wb, Map<String, CellStyle> styles) {
|
||||
Map<String, CellStyle> headerStyles = new HashMap<String, CellStyle>();
|
||||
Map<String, CellStyle> headerStyles = new HashMap<>();
|
||||
for (Object[] os : fields) {
|
||||
Excel excel = (Excel) os[1];
|
||||
String key = StringUtils.format("header_{}_{}", excel.headerColor(), excel.headerBackgroundColor());
|
||||
|
@ -665,7 +665,7 @@ public class ExcelUtil<T> {
|
|||
* @return 自定义样式列表
|
||||
*/
|
||||
private Map<String, CellStyle> annotationDataStyles (Workbook wb) {
|
||||
Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
|
||||
Map<String, CellStyle> styles = new HashMap<>();
|
||||
for (Object[] os : fields) {
|
||||
Excel excel = (Excel) os[1];
|
||||
String key = StringUtils.format("data_{}_{}_{}", excel.align(), excel.color(), excel.backgroundColor());
|
||||
|
@ -697,7 +697,7 @@ public class ExcelUtil<T> {
|
|||
/**
|
||||
* 创建单元格
|
||||
*/
|
||||
public Cell createHeadCell (Excel attr, Row row, int column) {
|
||||
public void createHeadCell (Excel attr, Row row, int column) {
|
||||
// 创建列
|
||||
Cell cell = row.createCell(column);
|
||||
// 写入列信息
|
||||
|
@ -711,7 +711,6 @@ public class ExcelUtil<T> {
|
|||
sheet.addMergedRegion(new CellRangeAddress(rownum - 1, rownum, column, column));
|
||||
}
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -764,7 +763,7 @@ public class ExcelUtil<T> {
|
|||
* 创建表格样式
|
||||
*/
|
||||
public void setDataValidation (Excel attr, Row row, int column) {
|
||||
if (attr.name().indexOf("注:") >= 0) {
|
||||
if (attr.name().contains("注:")) {
|
||||
sheet.setColumnWidth(column, 6000);
|
||||
} else {
|
||||
// 设置列宽
|
||||
|
@ -784,7 +783,7 @@ public class ExcelUtil<T> {
|
|||
/**
|
||||
* 添加单元格
|
||||
*/
|
||||
public Cell addCell (Excel attr, Row row, T vo, Field field, int column) {
|
||||
public void addCell (Excel attr, Row row, T vo, Field field, int column) {
|
||||
Cell cell = null;
|
||||
try {
|
||||
// 设置行高
|
||||
|
@ -819,9 +818,8 @@ public class ExcelUtil<T> {
|
|||
addStatisticsData(column, Convert.toStr(value), attr);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("导出Excel失败{}", e);
|
||||
log.error("导出Excel失败{}", e.getMessage(), e);
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -913,11 +911,11 @@ public class ExcelUtil<T> {
|
|||
*/
|
||||
public String dataFormatHandlerAdapter (Object value, Excel excel, Cell cell) {
|
||||
try {
|
||||
Object instance = excel.handler().newInstance();
|
||||
Object instance = excel.handler().getDeclaredConstructor().newInstance();
|
||||
Method formatMethod = excel.handler().getMethod("format", new Class[]{Object.class, String[].class, Cell.class, Workbook.class});
|
||||
value = formatMethod.invoke(instance, value, excel.args(), cell, this.wb);
|
||||
} catch (Exception e) {
|
||||
log.error("不能格式化数据 " + excel.handler(), e.getMessage());
|
||||
log.error("不能格式化数据 「{}-{}」", excel.handler() , e.getMessage());
|
||||
}
|
||||
return Convert.toStr(value);
|
||||
}
|
||||
|
@ -1019,7 +1017,7 @@ public class ExcelUtil<T> {
|
|||
* 获取字段注解信息
|
||||
*/
|
||||
public List<Object[]> getFields () {
|
||||
List<Object[]> fields = new ArrayList<Object[]>();
|
||||
List<Object[]> fields = new ArrayList<>();
|
||||
List<Field> tempFields = new ArrayList<>();
|
||||
tempFields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields()));
|
||||
tempFields.addAll(Arrays.asList(clazz.getDeclaredFields()));
|
||||
|
@ -1204,7 +1202,7 @@ public class ExcelUtil<T> {
|
|||
try {
|
||||
value = subMethod.invoke(obj, new Object[]{});
|
||||
} catch (Exception e) {
|
||||
return new ArrayList<Object>();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return (Collection<?>) value;
|
||||
}
|
||||
|
@ -1218,7 +1216,7 @@ public class ExcelUtil<T> {
|
|||
* @return 子列表方法
|
||||
*/
|
||||
public Method getSubMethod (String name, Class<?> pojoClass) {
|
||||
StringBuffer getMethodName = new StringBuffer("get");
|
||||
StringBuilder getMethodName = new StringBuilder("get");
|
||||
getMethodName.append(name.substring(0, 1).toUpperCase());
|
||||
getMethodName.append(name.substring(1));
|
||||
Method method = null;
|
||||
|
|
|
@ -127,7 +127,7 @@ public class ReflectUtils {
|
|||
Method method = getAccessibleMethodByName(obj, methodName, args.length);
|
||||
if (method == null) {
|
||||
// 如果为空不报错,直接返回空。
|
||||
log.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + methodName + "] 方法 ");
|
||||
log.debug("在 [{}] 中,没有找到 [{}}] 方法 ", obj.getClass(), methodName);
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
|
@ -238,7 +238,7 @@ public class ReflectUtils {
|
|||
*/
|
||||
public static void makeAccessible (Method method) {
|
||||
if ((!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers()))
|
||||
&& !method.isAccessible()) {
|
||||
&& !method.canAccess(null)) {
|
||||
method.setAccessible(true);
|
||||
}
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ public class ReflectUtils {
|
|||
*/
|
||||
public static void makeAccessible (Field field) {
|
||||
if ((!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers())
|
||||
|| Modifier.isFinal(field.getModifiers())) && !field.isAccessible()) {
|
||||
|| Modifier.isFinal(field.getModifiers())) && !field.canAccess(null)) {
|
||||
field.setAccessible(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@ public class SqlUtil {
|
|||
/**
|
||||
* 定义常用的 sql关键字
|
||||
*/
|
||||
public static String SQL_REGEX = "and |extractvalue|updatexml|exec |insert |select |delete |update |drop |count |chr |mid |master |truncate |char |declare |or |+|user()";
|
||||
public final static String SQL_REGEX = "and |extractvalue|updatexml|exec |insert |select |delete |update |drop |count |chr |mid |master |truncate |char |declare |or |+|user()";
|
||||
/**
|
||||
* 仅支持字母、数字、下划线、空格、逗号、小数点(支持多个字段排序)
|
||||
*/
|
||||
public static String SQL_PATTERN = "[a-zA-Z0-9_\\ \\,\\.]+";
|
||||
public final static String SQL_PATTERN = "[a-zA-Z0-9_\\ \\,\\.]+";
|
||||
|
||||
/**
|
||||
* 检查字符,防止注入绕过
|
||||
|
|
|
@ -10,16 +10,16 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
*/
|
||||
public class Seq {
|
||||
// 通用序列类型
|
||||
public static final String commSeqType = "COMMON";
|
||||
public static final String COMM_SEQ_TYPE = "COMMON";
|
||||
|
||||
// 上传序列类型
|
||||
public static final String uploadSeqType = "UPLOAD";
|
||||
public static final String UPLOAD_SEQ_TYPE = "UPLOAD";
|
||||
// 机器标识
|
||||
private static final String machineCode = "A";
|
||||
private static final String MACHINE_CODE = "A";
|
||||
// 通用接口序列数
|
||||
private static AtomicInteger commSeq = new AtomicInteger(1);
|
||||
private final static AtomicInteger COMM_SEQ = new AtomicInteger(1);
|
||||
// 上传接口序列数
|
||||
private static AtomicInteger uploadSeq = new AtomicInteger(1);
|
||||
private final static AtomicInteger UPLOAD_SEQ = new AtomicInteger(1);
|
||||
|
||||
/**
|
||||
* 获取通用序列号
|
||||
|
@ -27,7 +27,7 @@ public class Seq {
|
|||
* @return 序列值
|
||||
*/
|
||||
public static String getId () {
|
||||
return getId(commSeqType);
|
||||
return getId(COMM_SEQ_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -36,9 +36,9 @@ public class Seq {
|
|||
* @return 序列值
|
||||
*/
|
||||
public static String getId (String type) {
|
||||
AtomicInteger atomicInt = commSeq;
|
||||
if (uploadSeqType.equals(type)) {
|
||||
atomicInt = uploadSeq;
|
||||
AtomicInteger atomicInt = COMM_SEQ;
|
||||
if (UPLOAD_SEQ_TYPE.equals(type)) {
|
||||
atomicInt = UPLOAD_SEQ;
|
||||
}
|
||||
return getId(atomicInt, 3);
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class Seq {
|
|||
*/
|
||||
public static String getId (AtomicInteger atomicInt, int length) {
|
||||
String result = DateUtils.dateTimeNow();
|
||||
result += machineCode;
|
||||
result += MACHINE_CODE;
|
||||
result += getSeq(atomicInt, length);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -139,15 +139,15 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
|
|||
components[i] = "0x" + components[i];
|
||||
}
|
||||
|
||||
long mostSigBits = Long.decode(components[0]).longValue();
|
||||
long mostSigBits = Long.decode(components[0]);
|
||||
mostSigBits <<= 16;
|
||||
mostSigBits |= Long.decode(components[1]).longValue();
|
||||
mostSigBits |= Long.decode(components[1]);
|
||||
mostSigBits <<= 16;
|
||||
mostSigBits |= Long.decode(components[2]).longValue();
|
||||
mostSigBits |= Long.decode(components[2]);
|
||||
|
||||
long leastSigBits = Long.decode(components[3]).longValue();
|
||||
long leastSigBits = Long.decode(components[3]);
|
||||
leastSigBits <<= 48;
|
||||
leastSigBits |= Long.decode(components[4]).longValue();
|
||||
leastSigBits |= Long.decode(components[4]);
|
||||
|
||||
return new UUID(mostSigBits, leastSigBits);
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public class DataScopeAspect {
|
|||
*/
|
||||
public static void dataScopeFilter (JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias, String permission) {
|
||||
StringBuilder sqlString = new StringBuilder();
|
||||
List<String> conditions = new ArrayList<String>();
|
||||
List<String> conditions = new ArrayList<>();
|
||||
|
||||
for (SysRole role : user.getRoles()) {
|
||||
String dataScope = role.getDataScope();
|
||||
|
@ -116,7 +116,7 @@ public class DataScopeAspect {
|
|||
}
|
||||
|
||||
@Before("@annotation(controllerDataScope)")
|
||||
public void doBefore (JoinPoint point, DataScope controllerDataScope) throws Throwable {
|
||||
public void doBefore (JoinPoint point, DataScope controllerDataScope) {
|
||||
clearDataScope(point);
|
||||
handleDataScope(point, controllerDataScope);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class LogAspect {
|
|||
/**
|
||||
* 计算操作消耗时间
|
||||
*/
|
||||
private static final ThreadLocal<Long> TIME_THREADLOCAL = new NamedThreadLocal<Long>("Cost Time");
|
||||
private static final ThreadLocal<Long> TIME_THREADLOCAL = new NamedThreadLocal<>("Cost Time");
|
||||
|
||||
@Autowired
|
||||
private AsyncLogService asyncLogService;
|
||||
|
@ -150,9 +150,8 @@ public class LogAspect {
|
|||
*
|
||||
* @param operLog 操作日志
|
||||
*
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
private void setRequestValue (JoinPoint joinPoint, SysOperLog operLog, String[] excludeParamNames) throws Exception {
|
||||
private void setRequestValue (JoinPoint joinPoint, SysOperLog operLog, String[] excludeParamNames) {
|
||||
String requestMethod = operLog.getRequestMethod();
|
||||
Map<?, ?> paramsMap = ServletUtils.getParamMap(ServletUtils.getRequest());
|
||||
if (StringUtils.isEmpty(paramsMap)
|
||||
|
|
|
@ -22,7 +22,7 @@ public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T> {
|
|||
|
||||
static final Filter AUTO_TYPE_FILTER = JSONReader.autoTypeFilter(Constants.JSON_WHITELIST_STR);
|
||||
|
||||
private Class<T> clazz;
|
||||
private final Class<T> clazz;
|
||||
|
||||
public FastJson2JsonRedisSerializer (Class<T> clazz) {
|
||||
super();
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.muyu.common.redis.configure;
|
|||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
|
||||
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
@ -18,7 +17,7 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
|
|||
@Configuration
|
||||
@EnableCaching
|
||||
@AutoConfigureBefore(RedisAutoConfiguration.class)
|
||||
public class RedisConfig extends CachingConfigurerSupport {
|
||||
public class RedisConfig {
|
||||
@Bean
|
||||
@SuppressWarnings(value = {"unchecked", "rawtypes"})
|
||||
public RedisTemplate<Object, Object> redisTemplate (RedisConnectionFactory connectionFactory) {
|
||||
|
|
|
@ -156,9 +156,8 @@ public class RedisService {
|
|||
*/
|
||||
public <T> BoundSetOperations<String, T> setCacheSet (final String key, final Set<T> dataSet) {
|
||||
BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
|
||||
Iterator<T> it = dataSet.iterator();
|
||||
while (it.hasNext()) {
|
||||
setOperation.add(it.next());
|
||||
for (T t : dataSet) {
|
||||
setOperation.add(t);
|
||||
}
|
||||
return setOperation;
|
||||
}
|
||||
|
|
|
@ -55,13 +55,8 @@ public class PreAuthorizeAspect {
|
|||
// 注解鉴权
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
checkMethodAnnotation(signature.getMethod());
|
||||
try {
|
||||
// 执行原有逻辑
|
||||
Object obj = joinPoint.proceed();
|
||||
return obj;
|
||||
} catch (Throwable e) {
|
||||
throw e;
|
||||
}
|
||||
return joinPoint.proceed();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,7 +35,7 @@ public class AuthLogic {
|
|||
*/
|
||||
private static final String SUPER_ADMIN = "admin";
|
||||
|
||||
public TokenService tokenService = SpringUtils.getBean(TokenService.class);
|
||||
public final TokenService tokenService = SpringUtils.getBean(TokenService.class);
|
||||
|
||||
/**
|
||||
* 会话注销
|
||||
|
@ -114,8 +114,6 @@ public class AuthLogic {
|
|||
* 验证用户是否具备某权限, 如果验证未通过,则抛出异常: NotPermissionException
|
||||
*
|
||||
* @param permission 权限字符串
|
||||
*
|
||||
* @return 用户是否具备某权限
|
||||
*/
|
||||
public void checkPermi (String permission) {
|
||||
if (!hasPermi(getPermiList(), permission)) {
|
||||
|
|
|
@ -13,7 +13,7 @@ public class AuthUtil {
|
|||
/**
|
||||
* 底层的 AuthLogic 对象
|
||||
*/
|
||||
public static AuthLogic authLogic = new AuthLogic();
|
||||
public final static AuthLogic authLogic = new AuthLogic();
|
||||
|
||||
/**
|
||||
* 会话注销
|
||||
|
|
|
@ -20,6 +20,8 @@ import org.springframework.web.method.annotation.MethodArgumentTypeMismatchExcep
|
|||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 全局异常处理器
|
||||
*
|
||||
|
@ -33,9 +35,9 @@ public class GlobalExceptionHandler {
|
|||
* 权限码异常
|
||||
*/
|
||||
@ExceptionHandler(NotPermissionException.class)
|
||||
public Result handleNotPermissionException (NotPermissionException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',权限码校验失败'{}'", requestURI, e.getMessage());
|
||||
public Result<String> handleNotPermissionException (NotPermissionException e, HttpServletRequest request) {
|
||||
String requestUri = request.getRequestURI();
|
||||
log.error("请求地址'{}',权限码校验失败'{}'", requestUri, e.getMessage());
|
||||
return Result.error(HttpStatus.FORBIDDEN, "没有访问权限,请联系管理员授权");
|
||||
}
|
||||
|
||||
|
@ -43,9 +45,9 @@ public class GlobalExceptionHandler {
|
|||
* 角色权限异常
|
||||
*/
|
||||
@ExceptionHandler(NotRoleException.class)
|
||||
public Result handleNotRoleException (NotRoleException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',角色权限校验失败'{}'", requestURI, e.getMessage());
|
||||
public Result<String> handleNotRoleException (NotRoleException e, HttpServletRequest request) {
|
||||
String requestUri = request.getRequestURI();
|
||||
log.error("请求地址'{}',角色权限校验失败'{}'", requestUri, e.getMessage());
|
||||
return Result.error(HttpStatus.FORBIDDEN, "没有访问权限,请联系管理员授权");
|
||||
}
|
||||
|
||||
|
@ -53,9 +55,9 @@ public class GlobalExceptionHandler {
|
|||
* 请求方式不支持
|
||||
*/
|
||||
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
||||
public Result handleHttpRequestMethodNotSupported (HttpRequestMethodNotSupportedException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',不支持'{}'请求", requestURI, e.getMethod());
|
||||
public Result<String> handleHttpRequestMethodNotSupported (HttpRequestMethodNotSupportedException e, HttpServletRequest request) {
|
||||
String requestUri = request.getRequestURI();
|
||||
log.error("请求地址'{}',不支持'{}'请求", requestUri, e.getMethod());
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
|
||||
|
@ -63,19 +65,19 @@ public class GlobalExceptionHandler {
|
|||
* 业务异常
|
||||
*/
|
||||
@ExceptionHandler(ServiceException.class)
|
||||
public Result handleServiceException (ServiceException e, HttpServletRequest request) {
|
||||
public Result<String> handleServiceException (ServiceException e, HttpServletRequest request) {
|
||||
log.error(e.getMessage(), e);
|
||||
Integer code = e.getCode();
|
||||
return StringUtils.isNotNull(code) ? Result.error(code, e.getMessage()) : Result.error(e.getMessage());
|
||||
return StringUtils.isNotNull(code) ? Result.error(code.intValue(), e.getMessage()) : Result.error(e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求路径中缺少必需的路径变量
|
||||
*/
|
||||
@ExceptionHandler(MissingPathVariableException.class)
|
||||
public Result handleMissingPathVariableException (MissingPathVariableException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求路径中缺少必需的路径变量'{}',发生系统异常.", requestURI, e);
|
||||
public Result<String> handleMissingPathVariableException (MissingPathVariableException e, HttpServletRequest request) {
|
||||
String requestUri = request.getRequestURI();
|
||||
log.error("请求路径中缺少必需的路径变量'{}',发生系统异常.", requestUri, e);
|
||||
return Result.error(String.format("请求路径中缺少必需的路径变量[%s]", e.getVariableName()));
|
||||
}
|
||||
|
||||
|
@ -83,9 +85,9 @@ public class GlobalExceptionHandler {
|
|||
* 请求参数类型不匹配
|
||||
*/
|
||||
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
|
||||
public Result handleMethodArgumentTypeMismatchException (MethodArgumentTypeMismatchException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求参数类型不匹配'{}',发生系统异常.", requestURI, e);
|
||||
public Result<String> handleMethodArgumentTypeMismatchException (MethodArgumentTypeMismatchException e, HttpServletRequest request) {
|
||||
String requestUri = request.getRequestURI();
|
||||
log.error("请求参数类型不匹配'{}',发生系统异常.", requestUri, e);
|
||||
return Result.error(String.format("请求参数类型不匹配,参数[%s]要求类型为:'%s',但输入值为:'%s'", e.getName(), e.getRequiredType().getName(), e.getValue()));
|
||||
}
|
||||
|
||||
|
@ -93,9 +95,9 @@ public class GlobalExceptionHandler {
|
|||
* 拦截未知的运行时异常
|
||||
*/
|
||||
@ExceptionHandler(RuntimeException.class)
|
||||
public Result handleRuntimeException (RuntimeException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',发生未知异常.", requestURI, e);
|
||||
public Result<String> handleRuntimeException (RuntimeException e, HttpServletRequest request) {
|
||||
String requestUri = request.getRequestURI();
|
||||
log.error("请求地址'{}',发生未知异常.", requestUri, e);
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
|
||||
|
@ -103,9 +105,9 @@ public class GlobalExceptionHandler {
|
|||
* 系统异常
|
||||
*/
|
||||
@ExceptionHandler(Exception.class)
|
||||
public Result handleException (Exception e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',发生系统异常.", requestURI, e);
|
||||
public Result<String> handleException (Exception e, HttpServletRequest request) {
|
||||
String requestUri = request.getRequestURI();
|
||||
log.error("请求地址'{}',发生系统异常.", requestUri, e);
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
|
||||
|
@ -113,7 +115,7 @@ public class GlobalExceptionHandler {
|
|||
* 自定义验证异常
|
||||
*/
|
||||
@ExceptionHandler(BindException.class)
|
||||
public Result handleBindException (BindException e) {
|
||||
public Result<String> handleBindException (BindException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
String message = e.getAllErrors().get(0).getDefaultMessage();
|
||||
return Result.error(message);
|
||||
|
@ -125,7 +127,7 @@ public class GlobalExceptionHandler {
|
|||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public Object handleMethodArgumentNotValidException (MethodArgumentNotValidException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
String message = e.getBindingResult().getFieldError().getDefaultMessage();
|
||||
String message = Objects.requireNonNull(e.getBindingResult().getFieldError()).getDefaultMessage();
|
||||
return Result.error(message);
|
||||
}
|
||||
|
||||
|
@ -133,7 +135,7 @@ public class GlobalExceptionHandler {
|
|||
* 内部认证异常
|
||||
*/
|
||||
@ExceptionHandler(InnerAuthException.class)
|
||||
public Result handleInnerAuthException (InnerAuthException e) {
|
||||
public Result<String> handleInnerAuthException (InnerAuthException e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
|
||||
|
@ -141,7 +143,7 @@ public class GlobalExceptionHandler {
|
|||
* 演示模式异常
|
||||
*/
|
||||
@ExceptionHandler(DemoModeException.class)
|
||||
public Result handleDemoModeException (DemoModeException e) {
|
||||
public Result<String> handleDemoModeException (DemoModeException e) {
|
||||
return Result.error("演示模式,不允许操作");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
|||
public class HeaderInterceptor implements AsyncHandlerInterceptor {
|
||||
|
||||
@Override
|
||||
public boolean preHandle (HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
public boolean preHandle (HttpServletRequest request, HttpServletResponse response, Object handler) {
|
||||
if (!(handler instanceof HandlerMethod)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -43,8 +43,7 @@ public class HeaderInterceptor implements AsyncHandlerInterceptor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void afterCompletion (HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
|
||||
throws Exception {
|
||||
public void afterCompletion (HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
|
||||
SecurityContextHolder.remove();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,13 +51,13 @@ public class TokenService {
|
|||
refreshToken(loginUser);
|
||||
|
||||
// Jwt存储信息
|
||||
Map<String, Object> claimsMap = new HashMap<String, Object>();
|
||||
Map<String, Object> claimsMap = new HashMap<>();
|
||||
claimsMap.put(SecurityConstants.USER_KEY, token);
|
||||
claimsMap.put(SecurityConstants.DETAILS_USER_ID, userId);
|
||||
claimsMap.put(SecurityConstants.DETAILS_USERNAME, userName);
|
||||
|
||||
// 接口返回信息
|
||||
Map<String, Object> rspMap = new HashMap<String, Object>();
|
||||
Map<String, Object> rspMap = new HashMap<>();
|
||||
rspMap.put("access_token", JwtUtils.createToken(claimsMap));
|
||||
rspMap.put("expires_in", expireTime);
|
||||
return rspMap;
|
||||
|
|
|
@ -90,7 +90,7 @@ public class SysDept extends BaseEntity {
|
|||
* 子部门
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<SysDept> children = new ArrayList<SysDept>();
|
||||
private List<SysDept> children = new ArrayList<>();
|
||||
|
||||
@NotBlank(message = "部门名称不能为空")
|
||||
@Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符")
|
||||
|
|
|
@ -27,7 +27,7 @@ public interface RemoteLogService {
|
|||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/operlog")
|
||||
public Result<Boolean> saveLog (@RequestBody SysOperLog sysOperLog, @RequestHeader(SecurityConstants.FROM_SOURCE) String source) throws Exception;
|
||||
public Result<Boolean> saveLog (@RequestBody SysOperLog sysOperLog, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* 保存访问记录
|
||||
|
|
|
@ -21,11 +21,6 @@ public class RemoteFileFallbackFactory implements FallbackFactory<RemoteFileServ
|
|||
@Override
|
||||
public RemoteFileService create (Throwable throwable) {
|
||||
log.error("文件服务调用失败:{}", throwable.getMessage());
|
||||
return new RemoteFileService() {
|
||||
@Override
|
||||
public Result<SysFile> upload (MultipartFile file) {
|
||||
return Result.error("上传文件失败:" + throwable.getMessage());
|
||||
}
|
||||
};
|
||||
return file -> Result.error("上传文件失败:" + throwable.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public class BlackListUrlFilter extends AbstractGatewayFilterFactory<BlackListUr
|
|||
public static class Config {
|
||||
private List<String> blacklistUrl;
|
||||
|
||||
private List<Pattern> blacklistUrlPattern = new ArrayList<>();
|
||||
private final List<Pattern> blacklistUrlPattern = new ArrayList<>();
|
||||
|
||||
public boolean matchBlacklist (String url) {
|
||||
return !blacklistUrlPattern.isEmpty() && blacklistUrlPattern.stream().anyMatch(p -> p.matcher(url).find());
|
||||
|
@ -49,9 +49,7 @@ public class BlackListUrlFilter extends AbstractGatewayFilterFactory<BlackListUr
|
|||
public void setBlacklistUrl (List<String> blacklistUrl) {
|
||||
this.blacklistUrl = blacklistUrl;
|
||||
this.blacklistUrlPattern.clear();
|
||||
this.blacklistUrl.forEach(url -> {
|
||||
this.blacklistUrlPattern.add(Pattern.compile(url.replaceAll("\\*\\*", "(.*?)"), Pattern.CASE_INSENSITIVE));
|
||||
});
|
||||
this.blacklistUrl.forEach(url -> this.blacklistUrlPattern.add(Pattern.compile(url.replaceAll("\\*\\*", "(.*?)"), Pattern.CASE_INSENSITIVE)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,15 +9,10 @@ import com.muyu.gateway.service.ValidateCodeService;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.gateway.filter.GatewayFilter;
|
||||
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DataBufferUtils;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.stereotype.Component;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/**
|
||||
* 验证码过滤器
|
||||
|
@ -29,10 +24,22 @@ public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object> {
|
|||
private final static String[] VALIDATE_URL = new String[]{"/auth/login", "/auth/register"};
|
||||
private static final String CODE = "code";
|
||||
private static final String UUID = "uuid";
|
||||
|
||||
private final ValidateCodeService validateCodeService;
|
||||
|
||||
private final CaptchaProperties captchaProperties;
|
||||
|
||||
@Autowired
|
||||
private ValidateCodeService validateCodeService;
|
||||
@Autowired
|
||||
private CaptchaProperties captchaProperties;
|
||||
public ValidateCodeFilter(ValidateCodeService validateCodeService, CaptchaProperties captchaProperties) {
|
||||
this.validateCodeService = validateCodeService;
|
||||
this.captchaProperties = captchaProperties;
|
||||
}
|
||||
|
||||
public ValidateCodeFilter(Class<Object> configClass, ValidateCodeService validateCodeService, CaptchaProperties captchaProperties) {
|
||||
super(configClass);
|
||||
this.validateCodeService = validateCodeService;
|
||||
this.captchaProperties = captchaProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GatewayFilter apply (Object config) {
|
||||
|
@ -57,13 +64,13 @@ public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object> {
|
|||
|
||||
private String resolveBodyFromRequest (ServerHttpRequest serverHttpRequest) {
|
||||
// 获取请求体
|
||||
Flux<DataBuffer> body = serverHttpRequest.getBody();
|
||||
AtomicReference<String> bodyRef = new AtomicReference<>();
|
||||
body.subscribe(buffer -> {
|
||||
CharBuffer charBuffer = StandardCharsets.UTF_8.decode(buffer.asByteBuffer());
|
||||
DataBufferUtils.release(buffer);
|
||||
bodyRef.set(charBuffer.toString());
|
||||
});
|
||||
return bodyRef.get();
|
||||
return DataBufferUtils.join(serverHttpRequest.getBody())
|
||||
.map(dataBuffer -> {
|
||||
byte[] bytes = new byte[dataBuffer.readableByteCount()];
|
||||
dataBuffer.read(bytes);
|
||||
DataBufferUtils.release(dataBuffer);
|
||||
return new String(bytes, StandardCharsets.UTF_8);
|
||||
})
|
||||
.block();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,8 +34,7 @@ public class GatewayExceptionHandler implements ErrorWebExceptionHandler {
|
|||
|
||||
if (ex instanceof NotFoundException) {
|
||||
msg = "服务未找到";
|
||||
} else if (ex instanceof ResponseStatusException) {
|
||||
ResponseStatusException responseStatusException = (ResponseStatusException) ex;
|
||||
} else if (ex instanceof ResponseStatusException responseStatusException) {
|
||||
msg = responseStatusException.getMessage();
|
||||
} else {
|
||||
msg = "内部服务器错误";
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.gateway.handler;
|
|||
|
||||
import com.muyu.common.core.exception.CaptchaException;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.gateway.model.resp.CaptchaCodeResp;
|
||||
import com.muyu.gateway.service.ValidateCodeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
@ -26,10 +27,10 @@ public class ValidateCodeHandler implements HandlerFunction<ServerResponse> {
|
|||
|
||||
@Override
|
||||
public Mono<ServerResponse> handle (ServerRequest serverRequest) {
|
||||
Result ajax;
|
||||
Result<CaptchaCodeResp> ajax;
|
||||
try {
|
||||
ajax = validateCodeService.createCaptcha();
|
||||
} catch (CaptchaException | IOException e) {
|
||||
} catch (CaptchaException e) {
|
||||
return Mono.error(e);
|
||||
}
|
||||
return ServerResponse.status(HttpStatus.OK).body(BodyInserters.fromValue(ajax));
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.gateway.service;
|
|||
|
||||
import com.muyu.common.core.exception.CaptchaException;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.gateway.model.resp.CaptchaCodeResp;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -14,7 +15,7 @@ public interface ValidateCodeService {
|
|||
/**
|
||||
* 生成验证码
|
||||
*/
|
||||
public Result createCaptcha () throws IOException, CaptchaException;
|
||||
public Result<CaptchaCodeResp> createCaptcha () throws CaptchaException;
|
||||
|
||||
/**
|
||||
* 校验验证码
|
||||
|
|
|
@ -45,12 +45,12 @@ public class ValidateCodeServiceImpl implements ValidateCodeService {
|
|||
* 生成验证码
|
||||
*/
|
||||
@Override
|
||||
public Result createCaptcha () throws IOException, CaptchaException {
|
||||
public Result<CaptchaCodeResp> createCaptcha () throws CaptchaException {
|
||||
boolean captchaEnabled = captchaProperties.getEnabled();
|
||||
CaptchaCodeResp.CaptchaCodeRespBuilder respBuilder = CaptchaCodeResp.builder()
|
||||
.captchaEnabled(captchaEnabled);
|
||||
if (!captchaEnabled) {
|
||||
return Result.success(respBuilder);
|
||||
return Result.success(respBuilder.build());
|
||||
}
|
||||
|
||||
// 保存验证码信息
|
||||
|
|
|
@ -20,6 +20,7 @@ import reactor.core.publisher.Mono;
|
|||
* Web 工具类
|
||||
*
|
||||
*
|
||||
* @author dongzeliang
|
||||
*/
|
||||
@Log4j2
|
||||
public class WebFrameworkUtils {
|
||||
|
|
|
@ -89,10 +89,10 @@ public class FileUploadUtils {
|
|||
*/
|
||||
public static final String extractFilename (MultipartFile file) {
|
||||
return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(),
|
||||
FilenameUtils.getBaseName(file.getOriginalFilename()), Seq.getId(Seq.uploadSeqType), FileTypeUtils.getExtension(file));
|
||||
FilenameUtils.getBaseName(file.getOriginalFilename()), Seq.getId(Seq.UPLOAD_SEQ_TYPE), FileTypeUtils.getExtension(file));
|
||||
}
|
||||
|
||||
private static final File getAbsoluteFile (String uploadDir, String fileName) throws IOException {
|
||||
private static final File getAbsoluteFile (String uploadDir, String fileName) {
|
||||
File desc = new File(uploadDir + File.separator + fileName);
|
||||
|
||||
if (!desc.exists()) {
|
||||
|
@ -103,7 +103,7 @@ public class FileUploadUtils {
|
|||
return desc.isAbsolute() ? desc : desc.getAbsoluteFile();
|
||||
}
|
||||
|
||||
private static final String getPathFileName (String fileName) throws IOException {
|
||||
private static final String getPathFileName (String fileName) {
|
||||
String pathFileName = "/" + fileName;
|
||||
return pathFileName;
|
||||
}
|
||||
|
|
|
@ -65,12 +65,6 @@
|
|||
<artifactId>cloud-common-api-doc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- XllJob定时任务 -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-xxl</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -51,11 +51,11 @@ public class GenController extends BaseController {
|
|||
*/
|
||||
@RequiresPermissions("tool:gen:query")
|
||||
@GetMapping(value = "/{tableId}")
|
||||
public Result getInfo (@PathVariable("tableId") Long tableId) {
|
||||
public Result<Map<String, Object>> getInfo (@PathVariable("tableId") Long tableId) {
|
||||
GenTable table = genTableService.selectGenTableById(tableId);
|
||||
List<GenTable> tables = genTableService.selectGenTableAll();
|
||||
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("info", table);
|
||||
map.put("rows", list);
|
||||
map.put("tables", tables);
|
||||
|
@ -92,7 +92,7 @@ public class GenController extends BaseController {
|
|||
@RequiresPermissions("tool:gen:import")
|
||||
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
|
||||
@PostMapping("/importTable")
|
||||
public Result importTableSave (String tables) {
|
||||
public Result<String> importTableSave (String tables) {
|
||||
String[] tableNames = Convert.toStrArray(tables);
|
||||
// 查询表信息
|
||||
List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
|
||||
|
@ -106,7 +106,7 @@ public class GenController extends BaseController {
|
|||
@RequiresPermissions("tool:gen:edit")
|
||||
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public Result editSave (@Validated @RequestBody GenTable genTable) {
|
||||
public Result<String> editSave (@Validated @RequestBody GenTable genTable) {
|
||||
genTableService.validateEdit(genTable);
|
||||
genTableService.updateGenTable(genTable);
|
||||
return success();
|
||||
|
@ -118,7 +118,7 @@ public class GenController extends BaseController {
|
|||
@RequiresPermissions("tool:gen:remove")
|
||||
@Log(title = "代码生成", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{tableIds}")
|
||||
public Result remove (@PathVariable("tableIds")List<Long> tableIds) {
|
||||
public Result<String> remove (@PathVariable("tableIds")List<Long> tableIds) {
|
||||
genTableService.deleteGenTableByIds(tableIds);
|
||||
return success();
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ public class GenController extends BaseController {
|
|||
*/
|
||||
@RequiresPermissions("tool:gen:preview")
|
||||
@GetMapping("/preview/{tableId}")
|
||||
public Result preview (@PathVariable("tableId") Long tableId) throws IOException {
|
||||
public Result<Map<String, String>> preview (@PathVariable("tableId") Long tableId) {
|
||||
Map<String, String> dataMap = genTableService.previewCode(tableId);
|
||||
return success(dataMap);
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ public class GenController extends BaseController {
|
|||
@RequiresPermissions("tool:gen:code")
|
||||
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
||||
@GetMapping("/genCode/{tableName}")
|
||||
public Result genCode (@PathVariable("tableName") String tableName) {
|
||||
public Result<String> genCode (@PathVariable("tableName") String tableName) {
|
||||
genTableService.generatorCode(tableName);
|
||||
return success();
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ public class GenController extends BaseController {
|
|||
@RequiresPermissions("tool:gen:edit")
|
||||
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
|
||||
@GetMapping("/synchDb/{tableName}")
|
||||
public Result synchDb (@PathVariable("tableName") String tableName) {
|
||||
public Result<String> synchDb (@PathVariable("tableName") String tableName) {
|
||||
genTableService.synchDb(tableName);
|
||||
return success();
|
||||
}
|
||||
|
|
|
@ -341,7 +341,7 @@ public class GenTableColumn extends BaseEntity {
|
|||
|
||||
public String readConverterExp () {
|
||||
String remarks = StringUtils.substringBetween(this.columnComment, "(", ")");
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (StringUtils.isNotEmpty(remarks)) {
|
||||
for (String value : remarks.split(" ")) {
|
||||
if (StringUtils.isNotEmpty(value)) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.gen.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.gen.domain.GenTableColumn;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -10,6 +11,7 @@ import java.util.List;
|
|||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Mapper
|
||||
public interface GenTableColumnMapper extends BaseMapper<GenTableColumn> {
|
||||
/**
|
||||
* 根据表名称查询列信息
|
||||
|
|
|
@ -47,11 +47,15 @@ import java.util.zip.ZipOutputStream;
|
|||
public class GenTableServiceImpl implements IGenTableService {
|
||||
private static final Logger log = LoggerFactory.getLogger(GenTableServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private GenTableMapper genTableMapper;
|
||||
private final GenTableMapper genTableMapper;
|
||||
|
||||
private final GenTableColumnMapper genTableColumnMapper;
|
||||
|
||||
@Autowired
|
||||
private GenTableColumnMapper genTableColumnMapper;
|
||||
public GenTableServiceImpl(GenTableMapper genTableMapper, GenTableColumnMapper genTableColumnMapper) {
|
||||
this.genTableMapper = genTableMapper;
|
||||
this.genTableColumnMapper = genTableColumnMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取代码生成地址
|
||||
|
@ -370,7 +374,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||
zip.flush();
|
||||
zip.closeEntry();
|
||||
} catch (IOException e) {
|
||||
log.error("渲染模板失败,表名:" + table.getTableName(), e);
|
||||
log.error("渲染模板失败,表名:{}", table.getTableName(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ public class VelocityUtils {
|
|||
* @return 模板列表
|
||||
*/
|
||||
public static List<String> getTemplateList (String tplCategory) {
|
||||
List<String> templates = new ArrayList<String>();
|
||||
List<String> templates = new ArrayList<>();
|
||||
templates.add("vm/java/domain.java.vm");
|
||||
templates.add("vm/java/mapper.java.vm");
|
||||
templates.add("vm/java/service.java.vm");
|
||||
|
@ -213,7 +213,7 @@ public class VelocityUtils {
|
|||
public static HashSet<String> getImportList (GenTable genTable) {
|
||||
List<GenTableColumn> columns = genTable.getColumns();
|
||||
GenTable subGenTable = genTable.getSubTable();
|
||||
HashSet<String> importList = new HashSet<String>();
|
||||
HashSet<String> importList = new HashSet<>();
|
||||
if (StringUtils.isNotNull(subGenTable)) {
|
||||
importList.add("java.util.List");
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ public class VelocityUtils {
|
|||
*/
|
||||
public static String getDicts (GenTable genTable) {
|
||||
List<GenTableColumn> columns = genTable.getColumns();
|
||||
Set<String> dicts = new HashSet<String>();
|
||||
Set<String> dicts = new HashSet<>();
|
||||
addDicts(dicts, columns);
|
||||
if (StringUtils.isNotNull(genTable.getSubTable())) {
|
||||
List<GenTableColumn> subColumns = genTable.getSubTable().getColumns();
|
||||
|
|
|
@ -50,7 +50,7 @@ public class SysDeptController extends BaseController {
|
|||
*/
|
||||
@RequiresPermissions("system:dept:list")
|
||||
@GetMapping("/list/exclude/{deptId}")
|
||||
public Result excludeChild (@PathVariable(value = "deptId", required = false) Long deptId) {
|
||||
public Result<List<SysDept>> excludeChild (@PathVariable(value = "deptId", required = false) Long deptId) {
|
||||
List<SysDept> deptList = deptService.queryList(SysDeptPageQueryModel.builder().build());
|
||||
deptList.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId));
|
||||
return success(deptList);
|
||||
|
@ -61,7 +61,7 @@ public class SysDeptController extends BaseController {
|
|||
*/
|
||||
@RequiresPermissions("system:dept:query")
|
||||
@GetMapping(value = "/{deptId}")
|
||||
public Result getInfo (@PathVariable("deptId") Long deptId) {
|
||||
public Result<SysDept> getInfo (@PathVariable("deptId") Long deptId) {
|
||||
deptService.checkDeptDataScope(deptId);
|
||||
return success(deptService.selectDeptById(deptId));
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public class SysDictDataController extends BaseController {
|
|||
public Result<DataPageResp<SysDictDataListResp>> list (@RequestBody SysDictDataListReq sysDictDataListReq) {
|
||||
List<SysDictData> sysDictDataList = dictDataService.selectDictDataList(SysDictDataPageQueryModel.reqBuild(sysDictDataListReq)).getDataList();
|
||||
List<SysDictDataListResp> sysDictDataListRespList = sysDictDataList.stream().map(
|
||||
sysDictData -> SysDictDataListResp.buildResp(sysDictData)
|
||||
SysDictDataListResp::buildResp
|
||||
).distinct().collect(Collectors.toList());
|
||||
PageQueryModel<SysDictDataListResp> sysDictDataListRespPageQueryModel = new PageQueryModel<>();
|
||||
sysDictDataListRespPageQueryModel.setTotal(sysDictDataListRespList.size());
|
||||
|
|
|
@ -55,7 +55,7 @@ public class SysDictTypeController extends BaseController {
|
|||
.stream()
|
||||
.map(SysDictTypeListResp::buildResp)
|
||||
.collect(Collectors.toList());
|
||||
ExcelUtil<SysDictTypeListResp> util = new ExcelUtil<SysDictTypeListResp>(SysDictTypeListResp.class);
|
||||
ExcelUtil<SysDictTypeListResp> util = new ExcelUtil<>(SysDictTypeListResp.class);
|
||||
util.exportExcel(response, dictTypeListResps, "字典类型");
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class SysDictTypeController extends BaseController {
|
|||
*/
|
||||
@RequiresPermissions("system:dict:query")
|
||||
@GetMapping(value = "/{dictId}")
|
||||
public Result getInfo (@PathVariable("dictId") Long dictId) {
|
||||
public Result<SysDictType> getInfo (@PathVariable("dictId") Long dictId) {
|
||||
return success(dictTypeService.selectDictTypeById(dictId));
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class SysDictTypeController extends BaseController {
|
|||
@RequiresPermissions("system:dict:add")
|
||||
@Log(title = "字典类型", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public Result add (@Validated @RequestBody SysDictTypeAddReq sysDictTypeAddReq) {
|
||||
public Result<String> add (@Validated @RequestBody SysDictTypeAddReq sysDictTypeAddReq) {
|
||||
if (!dictTypeService.checkDictTypeUnique(SysDictTypeAddModel.buildModel(sysDictTypeAddReq))) {
|
||||
return error("新增字典'" + sysDictTypeAddReq.getDictName() + "'失败,字典类型已存在");
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ public class SysDictTypeController extends BaseController {
|
|||
@RequiresPermissions("system:dict:edit")
|
||||
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public Result edit (@Validated @RequestBody SysDictTypeUpdReq sysDictTypeUpdReq) {
|
||||
public Result<String> edit (@Validated @RequestBody SysDictTypeUpdReq sysDictTypeUpdReq) {
|
||||
if (!dictTypeService.checkDictTypeUnique(SysDictTypeUpdModel.buildUpdModel(sysDictTypeUpdReq))) {
|
||||
return error("修改字典'" + sysDictTypeUpdReq.getDictName() + "'失败,字典类型已存在");
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ public class SysDictTypeController extends BaseController {
|
|||
@RequiresPermissions("system:dict:remove")
|
||||
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{dictIds}")
|
||||
public Result remove (@PathVariable("dictIds") List<Long> dictIds) {
|
||||
public Result<String> remove (@PathVariable("dictIds") List<Long> dictIds) {
|
||||
dictTypeService.deleteDictTypeByIds(dictIds);
|
||||
return success();
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ public class SysDictTypeController extends BaseController {
|
|||
@RequiresPermissions("system:dict:remove")
|
||||
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/refreshCache")
|
||||
public Result refreshCache () {
|
||||
public Result<String> refreshCache () {
|
||||
dictTypeService.resetDictCache();
|
||||
return success();
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ public class SysDictTypeController extends BaseController {
|
|||
* 获取字典选择框列表
|
||||
*/
|
||||
@GetMapping("/optionselect")
|
||||
public Result optionselect () {
|
||||
public Result<List<SysDictType>> optionselect () {
|
||||
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
|
||||
return success(dictTypes);
|
||||
}
|
||||
|
|
|
@ -33,11 +33,15 @@ import java.util.List;
|
|||
@RestController
|
||||
@RequestMapping("/logininfor")
|
||||
public class SysLogininforController extends BaseController {
|
||||
@Autowired
|
||||
private SysLogininforService logininforService;
|
||||
private final SysLogininforService logininforService;
|
||||
|
||||
private final RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
public SysLogininforController(SysLogininforService logininforService, RedisService redisService) {
|
||||
this.logininforService = logininforService;
|
||||
this.redisService = redisService;
|
||||
}
|
||||
|
||||
@RequiresPermissions("system:logininfor:list")
|
||||
@PostMapping("/list")
|
||||
|
@ -60,14 +64,14 @@ public class SysLogininforController extends BaseController {
|
|||
@PostMapping("/export")
|
||||
public void export (HttpServletResponse response, SysLogininforListReq sysLogininforListReq) {
|
||||
List<SysLogininfor> sysLogininforList = logininforService.exportQuery(SysLogininforExportModel.reqBuild(sysLogininforListReq));
|
||||
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
|
||||
ExcelUtil<SysLogininfor> util = new ExcelUtil<>(SysLogininfor.class);
|
||||
util.exportExcel(response, sysLogininforList, "登录日志");
|
||||
}
|
||||
|
||||
@RequiresPermissions("system:logininfor:remove")
|
||||
@Log(title = "登录日志", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{infoIds}")
|
||||
public Result remove (@PathVariable("infoIds") List<Long> infoIds) {
|
||||
public Result<String> remove (@PathVariable("infoIds") List<Long> infoIds) {
|
||||
logininforService.deleteLogininforByIds(infoIds);
|
||||
return Result.success();
|
||||
}
|
||||
|
@ -75,22 +79,22 @@ public class SysLogininforController extends BaseController {
|
|||
@RequiresPermissions("system:logininfor:remove")
|
||||
@Log(title = "登录日志", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/clean")
|
||||
public Result clean () {
|
||||
public Result<String> clean () {
|
||||
logininforService.cleanLogininfor();
|
||||
return success();
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@RequiresPermissions("system:logininfor:unlock")
|
||||
@Log(title = "账户解锁", businessType = BusinessType.OTHER)
|
||||
@GetMapping("/unlock/{userName}")
|
||||
public Result unlock (@PathVariable("userName") String userName) {
|
||||
public Result<String> unlock (@PathVariable("userName") String userName) {
|
||||
redisService.deleteObject(CacheConstants.PWD_ERR_CNT_KEY + userName);
|
||||
return success();
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/*@InnerAuth*/
|
||||
@PostMapping
|
||||
public Result add (@RequestBody SysLogininforAddReq logininforAddReq) {
|
||||
public Result<String> add (@RequestBody SysLogininforAddReq logininforAddReq) {
|
||||
logininforService.insertLogininfor(SysLogininforAddModel.of(logininforAddReq));
|
||||
return Result.success();
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@ import com.muyu.system.domain.rep.SysMenuListReq;
|
|||
import com.muyu.system.domain.rep.SysMenuUpdReq;
|
||||
import com.muyu.system.domain.resp.RoleMenuTreeResp;
|
||||
import com.muyu.system.domain.resp.SysMenuListResp;
|
||||
import com.muyu.system.domain.vo.RouterVo;
|
||||
import com.muyu.system.domain.vo.TreeSelect;
|
||||
import com.muyu.system.service.SysMenuService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
@ -53,7 +55,7 @@ public class SysMenuController extends BaseController {
|
|||
*/
|
||||
@RequiresPermissions("system:menu:query")
|
||||
@GetMapping(value = "/{menuId}")
|
||||
public Result getInfo (@PathVariable("menuId") Long menuId) {
|
||||
public Result<SysMenu> getInfo (@PathVariable("menuId") Long menuId) {
|
||||
return success(menuService.selectMenuById(menuId));
|
||||
}
|
||||
|
||||
|
@ -61,7 +63,7 @@ public class SysMenuController extends BaseController {
|
|||
* 获取菜单下拉树列表
|
||||
*/
|
||||
@GetMapping("/treeselect")
|
||||
public Result treeselect (SysMenuListReq sysMenuListReq) {
|
||||
public Result<List<TreeSelect>> treeselect (SysMenuListReq sysMenuListReq) {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
List<SysMenuListModel> sysMenus = menuService.selectMenuList(SysMenuListModel.of(sysMenuListReq), userId);
|
||||
return success(menuService.buildMenuTreeSelect(sysMenus));
|
||||
|
@ -71,7 +73,7 @@ public class SysMenuController extends BaseController {
|
|||
* 加载对应角色菜单列表树
|
||||
*/
|
||||
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
||||
public Result roleMenuTreeselect (@PathVariable("roleId") Long roleId) {
|
||||
public Result<RoleMenuTreeResp> roleMenuTreeselect (@PathVariable("roleId") Long roleId) {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
List<SysMenuListModel> menus = menuService.selectMenuList(userId);
|
||||
return Result.success(
|
||||
|
@ -88,7 +90,7 @@ public class SysMenuController extends BaseController {
|
|||
@RequiresPermissions("system:menu:add")
|
||||
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public Result add (@Validated @RequestBody SysMenuAddReq sysMenuAddReq) {
|
||||
public Result<String> add (@Validated @RequestBody SysMenuAddReq sysMenuAddReq) {
|
||||
SysMenuAddModel sysMenuAddModel = SysMenuAddModel.of(sysMenuAddReq);
|
||||
if (!menuService.checkMenuNameUnique(sysMenuAddModel)) {
|
||||
return error("新增菜单'" + sysMenuAddModel.getMenuName() + "'失败,菜单名称已存在");
|
||||
|
@ -107,7 +109,7 @@ public class SysMenuController extends BaseController {
|
|||
@RequiresPermissions("system:menu:edit")
|
||||
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public Result edit (@Validated @RequestBody SysMenuUpdReq sysMenuUpdReq) {
|
||||
public Result<String> edit (@Validated @RequestBody SysMenuUpdReq sysMenuUpdReq) {
|
||||
SysMenuAddModel sysMenuAddModel = SysMenuAddModel.buildSysMenuAddModel(sysMenuUpdReq);
|
||||
if (!menuService.checkMenuNameUnique(sysMenuAddModel)) {
|
||||
return error("新增菜单'" + sysMenuAddModel.getMenuName() + "'失败,菜单名称已存在");
|
||||
|
@ -127,7 +129,7 @@ public class SysMenuController extends BaseController {
|
|||
@RequiresPermissions("system:menu:remove")
|
||||
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{menuId}")
|
||||
public Result remove (@PathVariable("menuId") Long menuId) {
|
||||
public Result<String> remove (@PathVariable("menuId") Long menuId) {
|
||||
if (menuService.hasChildByMenuId(menuId)) {
|
||||
return warn("存在子菜单,不允许删除");
|
||||
}
|
||||
|
@ -144,7 +146,7 @@ public class SysMenuController extends BaseController {
|
|||
* @return 路由信息
|
||||
*/
|
||||
@GetMapping("getRouters")
|
||||
public Result getRouters () {
|
||||
public Result<List<RouterVo>> getRouters () {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
|
||||
return success(menuService.buildMenus(menus));
|
||||
|
|
|
@ -51,7 +51,7 @@ public class SysPostController extends BaseController {
|
|||
public void export (HttpServletResponse response, SysPostListReq postListReq) {
|
||||
// TODO 导出重写
|
||||
PageQueryModel<SysPostListModel> sysPostPageQueryModel = postService.getList(SysPostPageQueryModel.reqBuild(postListReq));
|
||||
ExcelUtil<SysPostListResp> util = new ExcelUtil<SysPostListResp>(SysPostListResp.class);
|
||||
ExcelUtil<SysPostListResp> util = new ExcelUtil<>(SysPostListResp.class);
|
||||
util.exportExcel(response, sysPostPageQueryModel.getDataList().stream().map(SysPostListResp::listBuild).toList(), "岗位数据");
|
||||
}
|
||||
|
||||
|
|
|
@ -29,20 +29,24 @@ import java.util.Arrays;
|
|||
@RestController
|
||||
@RequestMapping("/user/profile")
|
||||
public class SysProfileController extends BaseController {
|
||||
@Autowired
|
||||
private SysUserService userService;
|
||||
private final SysUserService userService;
|
||||
|
||||
private final TokenService tokenService;
|
||||
|
||||
private final RemoteFileService remoteFileService;
|
||||
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
@Autowired
|
||||
private RemoteFileService remoteFileService;
|
||||
public SysProfileController(SysUserService userService, TokenService tokenService, RemoteFileService remoteFileService) {
|
||||
this.userService = userService;
|
||||
this.tokenService = tokenService;
|
||||
this.remoteFileService = remoteFileService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 个人信息
|
||||
*/
|
||||
@GetMapping
|
||||
public Result profile () {
|
||||
public Result<ProfileResp> profile () {
|
||||
String username = SecurityUtils.getUsername();
|
||||
SysUser user = userService.selectUserByUserName(username);
|
||||
return Result.success(
|
||||
|
@ -106,7 +110,7 @@ public class SysProfileController extends BaseController {
|
|||
*/
|
||||
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/avatar")
|
||||
public Result avatar (@RequestParam("avatarfile") MultipartFile file) {
|
||||
public Result<String> avatar (@RequestParam("avatarfile") MultipartFile file) {
|
||||
if (!file.isEmpty()) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
String extension = FileTypeUtils.getExtension(file);
|
||||
|
|
|
@ -51,7 +51,7 @@ public class SysRoleController extends BaseController {
|
|||
@PostMapping("/export")
|
||||
public void export (HttpServletResponse response, SysRole role) {
|
||||
List<SysRole> list = roleService.selectRoleList(role);
|
||||
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
|
||||
ExcelUtil<SysRole> util = new ExcelUtil<>(SysRole.class);
|
||||
util.exportExcel(response, list, "角色数据");
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class SysRoleController extends BaseController {
|
|||
*/
|
||||
@RequiresPermissions("system:role:query")
|
||||
@GetMapping(value = "/{roleId}")
|
||||
public Result getInfo (@PathVariable("roleId") Long roleId) {
|
||||
public Result<SysRole> getInfo (@PathVariable("roleId") Long roleId) {
|
||||
roleService.checkRoleDataScope(roleId);
|
||||
return success(roleService.selectRoleById(roleId));
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class SysRoleController extends BaseController {
|
|||
@RequiresPermissions("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public Result edit (@Validated @RequestBody SysRole role) {
|
||||
public Result<String> edit (@Validated @RequestBody SysRole role) {
|
||||
roleService.checkRoleAllowed(role);
|
||||
roleService.checkRoleDataScope(role.getRoleId());
|
||||
if (!roleService.checkRoleNameUnique(role)) {
|
||||
|
@ -173,7 +173,7 @@ public class SysRoleController extends BaseController {
|
|||
@RequiresPermissions("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authUser/cancel")
|
||||
public Result cancelAuthUser (@RequestBody SysUserRole userRole) {
|
||||
public Result<String> cancelAuthUser (@RequestBody SysUserRole userRole) {
|
||||
roleService.deleteAuthUser(userRole);
|
||||
return Result.success();
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.muyu.common.redis.service.RedisService;
|
|||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import com.muyu.system.domain.SysUserOnline;
|
||||
import com.muyu.system.domain.rep.SysUserOnlineListReq;
|
||||
import com.muyu.system.service.SysUserOnlineService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -36,9 +37,11 @@ public class SysUserOnlineController extends BaseController {
|
|||
|
||||
@RequiresPermissions("monitor:online:list")
|
||||
@PostMapping("/list")
|
||||
public Result<DataPageResp<SysUserOnline>> list (@RequestBody String ipaddr, String userName) {
|
||||
public Result<DataPageResp<SysUserOnline>> list (@RequestBody SysUserOnlineListReq sysUserOnlineListReq) {
|
||||
String ipaddr = sysUserOnlineListReq.getIpaddr();
|
||||
String userName = sysUserOnlineListReq.getUserName();
|
||||
Collection<String> keys = redisService.keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
|
||||
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
|
||||
List<SysUserOnline> userOnlineList = new ArrayList<>();
|
||||
for (String key : keys) {
|
||||
LoginUser user = redisService.getCacheObject(key);
|
||||
if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) {
|
||||
|
@ -53,7 +56,7 @@ public class SysUserOnlineController extends BaseController {
|
|||
}
|
||||
Collections.reverse(userOnlineList);
|
||||
userOnlineList.removeAll(Collections.singleton(null));
|
||||
return Result.success(new DataPageResp(0, userOnlineList));
|
||||
return Result.success(new DataPageResp<>(userOnlineList.size(), userOnlineList));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,7 +65,7 @@ public class SysUserOnlineController extends BaseController {
|
|||
@RequiresPermissions("monitor:online:forceLogout")
|
||||
@Log(title = "在线用户", businessType = BusinessType.FORCE)
|
||||
@DeleteMapping("/{tokenId}")
|
||||
public Result forceLogout (@PathVariable("tokenId") String tokenId) {
|
||||
public Result<String> forceLogout (@PathVariable("tokenId") String tokenId) {
|
||||
redisService.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId);
|
||||
return success();
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ public class SysMenu extends BaseEntity {
|
|||
*/
|
||||
@Builder.Default
|
||||
@TableField(exist = false)
|
||||
private List<SysMenu> children = new ArrayList<SysMenu>();
|
||||
private List<SysMenu> children = new ArrayList<>();
|
||||
|
||||
@NotBlank(message = "菜单名称不能为空")
|
||||
@Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符")
|
||||
|
|
|
@ -97,7 +97,7 @@ public class SysMenuAddModel {
|
|||
/**
|
||||
* 子菜单
|
||||
*/
|
||||
private List<SysMenu> children = new ArrayList<SysMenu>();
|
||||
private List<SysMenu> children = new ArrayList<>();
|
||||
|
||||
public static SysMenuAddModel of(SysMenuAddReq sysMenuAddReq) {
|
||||
return SysMenuAddModel.builder()
|
||||
|
|
|
@ -101,7 +101,7 @@ public class SysMenuListModel {
|
|||
/**
|
||||
* 子菜单
|
||||
*/
|
||||
private List<SysMenu> children = new ArrayList<SysMenu>();
|
||||
private List<SysMenu> children = new ArrayList<>();
|
||||
public static SysMenuListModel of(SysMenuListReq sysMenuListReq) {
|
||||
return SysMenuListModel.builder()
|
||||
.menuId(sysMenuListReq.getMenuId())
|
||||
|
|
|
@ -95,7 +95,7 @@ public class SysMenuUpdModel {
|
|||
/**
|
||||
* 子菜单
|
||||
*/
|
||||
private List<SysMenu> children = new ArrayList<SysMenu>();
|
||||
private List<SysMenu> children = new ArrayList<>();
|
||||
|
||||
public static SysMenuUpdModel of(SysMenuUpdReq sysMenuUpdReq) {
|
||||
return SysMenuUpdModel.builder()
|
||||
|
|
|
@ -108,6 +108,6 @@ public class SysMenuAddReq {
|
|||
/**
|
||||
* 子菜单
|
||||
*/
|
||||
private List<SysMenu> children = new ArrayList<SysMenu>();
|
||||
private List<SysMenu> children = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
|
|
@ -104,5 +104,5 @@ public class SysMenuListReq extends PageReq {
|
|||
/**
|
||||
* 子菜单
|
||||
*/
|
||||
private List<SysMenu> children = new ArrayList<SysMenu>();
|
||||
private List<SysMenu> children = new ArrayList<>();
|
||||
}
|
||||
|
|
|
@ -108,6 +108,6 @@ public class SysMenuUpdReq {
|
|||
/**
|
||||
* 子菜单
|
||||
*/
|
||||
private List<SysMenu> children = new ArrayList<SysMenu>();
|
||||
private List<SysMenu> children = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package com.muyu.system.domain.rep;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author dongzeliang
|
||||
* @version 1.0
|
||||
* @description: 在线用户列表查询
|
||||
* @date 2025/2/26 21:57
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SysUserOnlineListReq {
|
||||
|
||||
/**
|
||||
* IP地址
|
||||
*/
|
||||
private String ipaddr;
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
private String userName;
|
||||
}
|
|
@ -102,7 +102,7 @@ public class SysMenuListResp {
|
|||
/**
|
||||
* 子菜单
|
||||
*/
|
||||
private List<SysMenu> children = new ArrayList<SysMenu>();
|
||||
private List<SysMenu> children = new ArrayList<>();
|
||||
|
||||
public static SysMenuListResp buildSysMenuListResp(SysMenuListModel sysMenuListModel){
|
||||
return SysMenuListResp.builder()
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.system.domain.resp;
|
|||
|
||||
import com.muyu.common.system.domain.SysRole;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.system.domain.SysPost;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
@ -28,7 +29,7 @@ public class UserDetailInfoResp {
|
|||
/**
|
||||
* 岗位集合
|
||||
*/
|
||||
private List posts;
|
||||
private List<SysPost> posts;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.system.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.common.system.domain.SysDept;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -11,6 +12,7 @@ import java.util.List;
|
|||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysDeptMapper extends BaseMapper<SysDept> {
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,12 +2,14 @@ package com.muyu.system.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.common.system.domain.SysLogininfor;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 系统访问日志情况信息 数据层
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysLogininforMapper extends BaseMapper<SysLogininfor> {
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.system.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.system.domain.SysMenu;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -11,6 +12,7 @@ import java.util.List;
|
|||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,12 +2,15 @@ package com.muyu.system.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.common.system.domain.SysOperLog;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* 操作日志 数据层
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysOperLogMapper extends BaseMapper<SysOperLog> {
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.system.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.system.domain.SysPost;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -10,6 +11,7 @@ import java.util.List;
|
|||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysPostMapper extends BaseMapper<SysPost> {
|
||||
/**
|
||||
* 查询岗位数据集合
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.system.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.common.system.domain.SysRole;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -10,6 +11,7 @@ import java.util.List;
|
|||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysRoleMapper extends BaseMapper<SysRole> {
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.system.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -10,6 +11,7 @@ import java.util.List;
|
|||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
|
|
|
@ -2,12 +2,15 @@ package com.muyu.system.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.system.domain.SysUserRole;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* 用户与角色关联表 数据层
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
|
||||
|
||||
}
|
||||
|
|
|
@ -13,18 +13,18 @@ public interface SysPermissionService {
|
|||
/**
|
||||
* 获取角色数据权限
|
||||
*
|
||||
* @param userId 用户Id
|
||||
* @param sysUser 用户
|
||||
*
|
||||
* @return 角色权限信息
|
||||
*/
|
||||
public Set<String> getRolePermission (SysUser user);
|
||||
public Set<String> getRolePermission (SysUser sysUser);
|
||||
|
||||
/**
|
||||
* 获取菜单数据权限
|
||||
*
|
||||
* @param userId 用户Id
|
||||
* @param sysUser 用户
|
||||
*
|
||||
* @return 菜单权限信息
|
||||
*/
|
||||
public Set<String> getMenuPermission (SysUser user);
|
||||
public Set<String> getMenuPermission (SysUser sysUser);
|
||||
}
|
||||
|
|
|
@ -39,15 +39,18 @@ import java.util.stream.Collectors;
|
|||
@Service
|
||||
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
|
||||
implements SysDeptService {
|
||||
@Autowired
|
||||
private SysDeptMapper deptMapper;
|
||||
private final SysDeptMapper deptMapper;
|
||||
|
||||
private final SysRoleMapper roleMapper;
|
||||
|
||||
private final SysUserService sysUserService;
|
||||
|
||||
@Autowired
|
||||
private SysRoleMapper roleMapper;
|
||||
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
|
||||
public SysDeptServiceImpl(SysDeptMapper deptMapper, SysRoleMapper roleMapper, SysUserService sysUserService) {
|
||||
this.deptMapper = deptMapper;
|
||||
this.roleMapper = roleMapper;
|
||||
this.sysUserService = sysUserService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysDept> queryList(SysDeptPageQueryModel sysDeptPageQueryModel) {
|
||||
|
|
|
@ -26,8 +26,12 @@ import java.util.List;
|
|||
@Service
|
||||
public class SysLogininforServiceImpl extends ServiceImpl<SysLogininforMapper, SysLogininfor> implements SysLogininforService {
|
||||
|
||||
private final SysLogininforMapper logininforMapper;
|
||||
|
||||
@Autowired
|
||||
private SysLogininforMapper logininforMapper;
|
||||
public SysLogininforServiceImpl(SysLogininforMapper logininforMapper) {
|
||||
this.logininforMapper = logininforMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增系统登录日志
|
||||
|
|
|
@ -34,14 +34,18 @@ import java.util.stream.Collectors;
|
|||
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements SysMenuService {
|
||||
public static final String PREMISSION_STRING = "perms[\"{0}\"]";
|
||||
|
||||
@Autowired
|
||||
private SysMenuMapper menuMapper;
|
||||
private final SysMenuMapper menuMapper;
|
||||
|
||||
private final SysRoleMapper roleMapper;
|
||||
|
||||
private final SysRoleMenuService sysRoleMenuService;
|
||||
|
||||
@Autowired
|
||||
private SysRoleMapper roleMapper;
|
||||
|
||||
@Autowired
|
||||
private SysRoleMenuService sysRoleMenuService;
|
||||
public SysMenuServiceImpl(SysMenuMapper menuMapper, SysRoleMapper roleMapper, SysRoleMenuService sysRoleMenuService) {
|
||||
this.menuMapper = menuMapper;
|
||||
this.roleMapper = roleMapper;
|
||||
this.sysRoleMenuService = sysRoleMenuService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户查询系统菜单列表
|
||||
|
@ -164,7 +168,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
*/
|
||||
@Override
|
||||
public List<RouterVo> buildMenus (List<SysMenu> menus) {
|
||||
List<RouterVo> routers = new LinkedList<RouterVo>();
|
||||
List<RouterVo> routers = new LinkedList<>();
|
||||
for (SysMenu menu : menus) {
|
||||
RouterVo router = new RouterVo();
|
||||
router.setHidden("1".equals(menu.getVisible()));
|
||||
|
@ -187,7 +191,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
router.setChildren(buildMenus(cMenus));
|
||||
} else if (isMenuFrame(menu)) {
|
||||
router.setMeta(null);
|
||||
List<RouterVo> childrenList = new ArrayList<RouterVo>();
|
||||
List<RouterVo> childrenList = new ArrayList<>();
|
||||
RouterVo children = new RouterVo();
|
||||
children.setPath(menu.getPath());
|
||||
children.setComponent(menu.getComponent());
|
||||
|
@ -206,7 +210,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
} else if (menu.getParentId().intValue() == 0 && isInnerLink(menu)) {
|
||||
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon()));
|
||||
router.setPath("/");
|
||||
List<RouterVo> childrenList = new ArrayList<RouterVo>();
|
||||
List<RouterVo> childrenList = new ArrayList<>();
|
||||
RouterVo children = new RouterVo();
|
||||
String routerPath = innerLinkReplaceEach(menu.getPath());
|
||||
children.setPath(routerPath);
|
||||
|
@ -230,10 +234,9 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
*/
|
||||
@Override
|
||||
public List<SysMenu> buildMenuTree (List<SysMenu> menus) {
|
||||
List<SysMenu> returnList = new ArrayList<SysMenu>();
|
||||
List<SysMenu> returnList = new ArrayList<>();
|
||||
List<Long> tempList = menus.stream().map(SysMenu::getMenuId).collect(Collectors.toList());
|
||||
for (Iterator<SysMenu> iterator = menus.iterator() ; iterator.hasNext() ; ) {
|
||||
SysMenu menu = (SysMenu) iterator.next();
|
||||
for (SysMenu menu : menus) {
|
||||
// 如果是顶级节点, 遍历该父节点的所有子节点
|
||||
if (!tempList.contains(menu.getParentId())) {
|
||||
recursionFn(menus, menu);
|
||||
|
@ -461,9 +464,8 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
* @return String
|
||||
*/
|
||||
public List<SysMenu> getChildPerms (List<SysMenu> list, int parentId) {
|
||||
List<SysMenu> returnList = new ArrayList<SysMenu>();
|
||||
for (Iterator<SysMenu> iterator = list.iterator() ; iterator.hasNext() ; ) {
|
||||
SysMenu t = iterator.next();
|
||||
List<SysMenu> returnList = new ArrayList<>();
|
||||
for (SysMenu t : list) {
|
||||
// 一、根据传入的某个父节点ID,遍历该父节点的所有子节点
|
||||
if (t.getParentId() == parentId) {
|
||||
recursionFn(list, t);
|
||||
|
@ -494,10 +496,8 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
* 得到子节点列表
|
||||
*/
|
||||
private List<SysMenu> getChildList (List<SysMenu> list, SysMenu t) {
|
||||
List<SysMenu> tlist = new ArrayList<SysMenu>();
|
||||
Iterator<SysMenu> it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
SysMenu n = (SysMenu) it.next();
|
||||
List<SysMenu> tlist = new ArrayList<>();
|
||||
for (SysMenu n : list) {
|
||||
if (n.getParentId().longValue() == t.getMenuId().longValue()) {
|
||||
tlist.add(n);
|
||||
}
|
||||
|
|
|
@ -14,8 +14,6 @@ import com.muyu.system.service.SysOperLogService;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -26,8 +24,12 @@ import java.util.Objects;
|
|||
*/
|
||||
@Service
|
||||
public class SysOperLogServiceImpl extends ServiceImpl<SysOperLogMapper, SysOperLog> implements SysOperLogService {
|
||||
private final SysOperLogMapper operLogMapper;
|
||||
|
||||
@Autowired
|
||||
private SysOperLogMapper operLogMapper;
|
||||
public SysOperLogServiceImpl(SysOperLogMapper operLogMapper) {
|
||||
this.operLogMapper = operLogMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增操作日志
|
||||
|
|
|
@ -29,18 +29,18 @@ public class SysPermissionServiceImpl implements SysPermissionService {
|
|||
/**
|
||||
* 获取角色数据权限
|
||||
*
|
||||
* @param userId 用户Id
|
||||
* @param sysUser 用户Id
|
||||
*
|
||||
* @return 角色权限信息
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getRolePermission (SysUser user) {
|
||||
public Set<String> getRolePermission (SysUser sysUser) {
|
||||
Set<String> roles = new HashSet<String>();
|
||||
// 管理员拥有所有权限
|
||||
if (user.isAdmin()) {
|
||||
if (sysUser.isAdmin()) {
|
||||
roles.add("admin");
|
||||
} else {
|
||||
roles.addAll(roleService.selectRolePermissionByUserId(user.getUserId()));
|
||||
roles.addAll(roleService.selectRolePermissionByUserId(sysUser.getUserId()));
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
|
@ -48,18 +48,18 @@ public class SysPermissionServiceImpl implements SysPermissionService {
|
|||
/**
|
||||
* 获取菜单数据权限
|
||||
*
|
||||
* @param userId 用户Id
|
||||
* @param sysUser 用户Id
|
||||
*
|
||||
* @return 菜单权限信息
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getMenuPermission (SysUser user) {
|
||||
Set<String> perms = new HashSet<String>();
|
||||
public Set<String> getMenuPermission (SysUser sysUser) {
|
||||
Set<String> perms = new HashSet<>();
|
||||
// 管理员拥有所有权限
|
||||
if (user.isAdmin()) {
|
||||
if (sysUser.isAdmin()) {
|
||||
perms.add("*:*:*");
|
||||
} else {
|
||||
List<SysRole> roles = user.getRoles();
|
||||
List<SysRole> roles = sysUser.getRoles();
|
||||
if (!CollectionUtils.isEmpty(roles)) {
|
||||
// 多角色设置permissions属性,以便数据权限匹配权限
|
||||
for (SysRole role : roles) {
|
||||
|
@ -68,7 +68,7 @@ public class SysPermissionServiceImpl implements SysPermissionService {
|
|||
perms.addAll(rolePerms);
|
||||
}
|
||||
} else {
|
||||
perms.addAll(menuService.selectMenuPermsByUserId(user.getUserId()));
|
||||
perms.addAll(menuService.selectMenuPermsByUserId(sysUser.getUserId()));
|
||||
}
|
||||
}
|
||||
return perms;
|
||||
|
|
|
@ -27,14 +27,15 @@ import java.util.List;
|
|||
*/
|
||||
@Service
|
||||
public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> implements SysPostService {
|
||||
@Autowired
|
||||
private SysPostMapper postMapper;
|
||||
private final SysPostMapper postMapper;
|
||||
|
||||
private final SysUserPostService sysUserPostService;
|
||||
|
||||
@Autowired
|
||||
private SysUserPostMapper userPostMapper;
|
||||
|
||||
@Autowired
|
||||
private SysUserPostService sysUserPostService;
|
||||
public SysPostServiceImpl(SysPostMapper postMapper, SysUserPostService sysUserPostService) {
|
||||
this.postMapper = postMapper;
|
||||
this.sysUserPostService = sysUserPostService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有岗位
|
||||
|
|
|
@ -36,17 +36,21 @@ import java.util.*;
|
|||
*/
|
||||
@Service
|
||||
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {
|
||||
@Autowired
|
||||
private SysRoleMapper roleMapper;
|
||||
private final SysRoleMapper roleMapper;
|
||||
|
||||
private final SysUserRoleService sysUserRoleService;
|
||||
|
||||
private final SysRoleMenuService sysRoleMenuService;
|
||||
|
||||
private final SysRoleDeptService sysRoleDeptService;
|
||||
|
||||
@Autowired
|
||||
private SysUserRoleService sysUserRoleService;
|
||||
|
||||
@Autowired
|
||||
private SysRoleMenuService sysRoleMenuService;
|
||||
|
||||
@Autowired
|
||||
private SysRoleDeptService sysRoleDeptService;
|
||||
public SysRoleServiceImpl(SysRoleMapper roleMapper, SysUserRoleService sysUserRoleService, SysRoleMenuService sysRoleMenuService, SysRoleDeptService sysRoleDeptService) {
|
||||
this.roleMapper = roleMapper;
|
||||
this.sysUserRoleService = sysUserRoleService;
|
||||
this.sysRoleMenuService = sysRoleMenuService;
|
||||
this.sysRoleDeptService = sysRoleDeptService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件分页查询角色数据
|
||||
|
@ -322,7 +326,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||
return 0;
|
||||
}
|
||||
// 新增用户与角色管理
|
||||
List<SysRoleMenu> list = new ArrayList<SysRoleMenu>();
|
||||
List<SysRoleMenu> list = new ArrayList<>();
|
||||
for (Long menuId : role.getMenuIds()) {
|
||||
SysRoleMenu rm = new SysRoleMenu();
|
||||
rm.setRoleId(role.getRoleId());
|
||||
|
@ -344,7 +348,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||
public int insertRoleDept (SysRole role) {
|
||||
int rows = 1;
|
||||
// 新增角色与部门(数据权限)管理
|
||||
List<SysRoleDept> list = new ArrayList<SysRoleDept>();
|
||||
List<SysRoleDept> list = new ArrayList<>();
|
||||
for (Long deptId : role.getDeptIds()) {
|
||||
SysRoleDept rd = new SysRoleDept();
|
||||
rd.setRoleId(role.getRoleId());
|
||||
|
|
|
@ -57,7 +57,7 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
|
|||
// from sys_user_role
|
||||
// where user_id = #{userId}
|
||||
// and role_id = #{roleId}
|
||||
LambdaUpdateWrapper<SysUserRole> lambdaUpdateWrapper = new LambdaUpdateWrapper<SysUserRole>();
|
||||
LambdaUpdateWrapper<SysUserRole> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||
lambdaUpdateWrapper.eq(SysUserRole::getUserId, userRole.getUserId());
|
||||
lambdaUpdateWrapper.eq(SysUserRole::getRoleId, userRole.getRoleId());
|
||||
this.remove(lambdaUpdateWrapper);
|
||||
|
@ -85,7 +85,7 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
|
|||
*/
|
||||
@Override
|
||||
public void deleteUserRole(List<Long> userIds) {
|
||||
LambdaQueryWrapper<SysUserRole> lambdaQueryWrapper = new LambdaQueryWrapper<SysUserRole>();
|
||||
LambdaQueryWrapper<SysUserRole> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.in(SysUserRole::getUserId, userIds);
|
||||
this.remove(lambdaQueryWrapper);
|
||||
}
|
||||
|
|
|
@ -45,23 +45,24 @@ import java.util.stream.Collectors;
|
|||
@Service
|
||||
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {
|
||||
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
|
||||
@Autowired
|
||||
protected Validator validator;
|
||||
@Autowired
|
||||
private SysUserMapper userMapper;
|
||||
@Autowired
|
||||
private SysRoleMapper roleMapper;
|
||||
@Autowired
|
||||
private SysPostMapper postMapper;
|
||||
@Autowired
|
||||
private SysUserRoleMapper userRoleMapper;
|
||||
protected final Validator validator;
|
||||
private final SysUserMapper userMapper;
|
||||
private final SysRoleMapper roleMapper;
|
||||
private final SysPostMapper postMapper;
|
||||
private final SysUserRoleService sysUserRoleService;
|
||||
private final SysUserPostService sysUserPostService;
|
||||
private final SysConfigService configService;
|
||||
|
||||
@Autowired
|
||||
private SysUserRoleService sysUserRoleService;
|
||||
@Autowired
|
||||
private SysUserPostService sysUserPostService;
|
||||
@Autowired
|
||||
private SysConfigService configService;
|
||||
public SysUserServiceImpl(Validator validator, SysUserMapper userMapper, SysRoleMapper roleMapper, SysPostMapper postMapper, SysUserRoleService sysUserRoleService, SysUserPostService sysUserPostService, SysConfigService configService) {
|
||||
this.validator = validator;
|
||||
this.userMapper = userMapper;
|
||||
this.roleMapper = roleMapper;
|
||||
this.postMapper = postMapper;
|
||||
this.sysUserRoleService = sysUserRoleService;
|
||||
this.sysUserPostService = sysUserPostService;
|
||||
this.configService = configService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
|
@ -404,7 +405,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
Long[] posts = user.getPostIds();
|
||||
if (StringUtils.isNotEmpty(posts)) {
|
||||
// 新增用户与岗位管理
|
||||
List<SysUserPost> list = new ArrayList<SysUserPost>();
|
||||
List<SysUserPost> list = new ArrayList<>();
|
||||
for (Long postId : posts) {
|
||||
SysUserPost up = new SysUserPost();
|
||||
up.setUserId(user.getUserId());
|
||||
|
@ -424,7 +425,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
public void insertUserRole (Long userId, Long[] roleIds) {
|
||||
if (StringUtils.isNotEmpty(roleIds)) {
|
||||
// 新增用户与角色管理
|
||||
List<SysUserRole> list = new ArrayList<SysUserRole>();
|
||||
List<SysUserRole> list = new ArrayList<>();
|
||||
for (Long roleId : roleIds) {
|
||||
SysUserRole ur = new SysUserRole();
|
||||
ur.setUserId(userId);
|
||||
|
|
Loading…
Reference in New Issue