fix():格式规范修改

boot3.0
dongzeliang 2025-02-26 21:59:55 +08:00
parent 44a9e29996
commit 782ec652ed
91 changed files with 468 additions and 497 deletions

View File

@ -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;
}
/**
*

View File

@ -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);
}

View File

@ -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;
}
/**
*

View File

@ -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

View File

@ -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;
}
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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) + "]");

View File

@ -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
}
}

View File

@ -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() {

View File

@ -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;
};
}
/**

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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方法

View File

@ -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

View File

@ -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);

View File

@ -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 -> "";
};
}
}

View File

@ -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));

View File

@ -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()) {
// (>|^)

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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_\\ \\,\\.]+";
/**
*

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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)

View File

@ -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();

View File

@ -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) {

View File

@ -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;
}

View File

@ -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();
}
/**

View File

@ -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)) {

View File

@ -13,7 +13,7 @@ public class AuthUtil {
/**
* AuthLogic
*/
public static AuthLogic authLogic = new AuthLogic();
public final static AuthLogic authLogic = new AuthLogic();
/**
*

View File

@ -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("演示模式,不允许操作");
}
}

View File

@ -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();
}
}

View File

@ -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;

View File

@ -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个字符")

View File

@ -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);
/**
* 访

View File

@ -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());
}
}

View File

@ -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)));
}
}

View File

@ -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();
}
}

View File

@ -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 = "内部服务器错误";

View File

@ -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));

View File

@ -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;
/**
*

View File

@ -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());
}
// 保存验证码信息

View File

@ -20,6 +20,7 @@ import reactor.core.publisher.Mono;
* Web
*
*
* @author dongzeliang
*/
@Log4j2
public class WebFrameworkUtils {

View File

@ -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;
}

View File

@ -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>

View File

@ -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();
}

View File

@ -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)) {

View File

@ -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> {
/**
*

View File

@ -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);
}
}
}

View File

@ -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();

View File

@ -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));
}

View File

@ -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());

View File

@ -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);
}

View File

@ -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();
}

View File

@ -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));

View File

@ -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(), "岗位数据");
}

View File

@ -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);

View 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();
}

View File

@ -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();
}

View File

@ -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个字符")

View File

@ -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()

View File

@ -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())

View File

@ -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()

View File

@ -108,6 +108,6 @@ public class SysMenuAddReq {
/**
*
*/
private List<SysMenu> children = new ArrayList<SysMenu>();
private List<SysMenu> children = new ArrayList<>();
}

View File

@ -104,5 +104,5 @@ public class SysMenuListReq extends PageReq {
/**
*
*/
private List<SysMenu> children = new ArrayList<SysMenu>();
private List<SysMenu> children = new ArrayList<>();
}

View File

@ -108,6 +108,6 @@ public class SysMenuUpdReq {
/**
*
*/
private List<SysMenu> children = new ArrayList<SysMenu>();
private List<SysMenu> children = new ArrayList<>();
}

View File

@ -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;
}

View File

@ -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()

View File

@ -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;
/**
*

View File

@ -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> {
/**

View File

@ -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> {

View File

@ -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> {
/**

View File

@ -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> {
/**

View File

@ -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> {
/**
*

View File

@ -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> {
/**

View File

@ -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> {
/**
*

View File

@ -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> {
}

View File

@ -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);
}

View File

@ -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) {

View File

@ -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;
}
/**
*

View File

@ -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);
}

View File

@ -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;
}
/**
*

View File

@ -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;

View File

@ -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;
}
/**
*

View File

@ -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());

View File

@ -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);
}

View File

@ -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);