alibaba代码规约扫描。

pull/183/head
1332987 3 years ago
parent c392e8fb16
commit 1157caddfd

@ -6,7 +6,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.Rust;
import com.ruoyi.system.api.domain.SysFile;
import com.ruoyi.system.api.factory.RemoteFileFallbackFactory;
@ -25,5 +25,5 @@ public interface RemoteFileService
* @return
*/
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public R<SysFile> upload(@RequestPart(value = "file") MultipartFile file);
public Rust<SysFile> upload(@RequestPart(value = "file") MultipartFile file);
}

@ -6,7 +6,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.Rust;
import com.ruoyi.system.api.domain.SysLogininfor;
import com.ruoyi.system.api.domain.SysOperLog;
import com.ruoyi.system.api.factory.RemoteLogFallbackFactory;
@ -27,7 +27,7 @@ public interface RemoteLogService
* @return
*/
@PostMapping("/operlog")
public R<Boolean> saveLog(@RequestBody SysOperLog sysOperLog, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
public Rust<Boolean> saveLog(@RequestBody SysOperLog sysOperLog, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
/**
* 访
@ -37,5 +37,5 @@ public interface RemoteLogService
* @return
*/
@PostMapping("/logininfor")
public R<Boolean> saveLogininfor(@RequestBody SysLogininfor sysLogininfor, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
public Rust<Boolean> saveLogininfor(@RequestBody SysLogininfor sysLogininfor, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}

@ -8,7 +8,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.Rust;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.factory.RemoteUserFallbackFactory;
import com.ruoyi.system.api.model.LoginUser;
@ -29,7 +29,7 @@ public interface RemoteUserService
* @return
*/
@GetMapping("/user/info/{username}")
public R<LoginUser> getUserInfo(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
public Rust<LoginUser> getUserInfo(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
/**
*
@ -39,5 +39,5 @@ public interface RemoteUserService
* @return
*/
@PostMapping("/user/register")
public R<Boolean> registerUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
public Rust<Boolean> registerUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}

@ -5,7 +5,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.Rust;
import com.ruoyi.system.api.RemoteFileService;
import com.ruoyi.system.api.domain.SysFile;
@ -26,9 +26,9 @@ public class RemoteFileFallbackFactory implements FallbackFactory<RemoteFileServ
return new RemoteFileService()
{
@Override
public R<SysFile> upload(MultipartFile file)
public Rust<SysFile> upload(MultipartFile file)
{
return R.fail("上传文件失败:" + throwable.getMessage());
return Rust.fail("上传文件失败:" + throwable.getMessage());
}
};
}

@ -4,7 +4,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.Rust;
import com.ruoyi.system.api.RemoteLogService;
import com.ruoyi.system.api.domain.SysLogininfor;
import com.ruoyi.system.api.domain.SysOperLog;
@ -26,13 +26,13 @@ public class RemoteLogFallbackFactory implements FallbackFactory<RemoteLogServic
return new RemoteLogService()
{
@Override
public R<Boolean> saveLog(SysOperLog sysOperLog, String source)
public Rust<Boolean> saveLog(SysOperLog sysOperLog, String source)
{
return null;
}
@Override
public R<Boolean> saveLogininfor(SysLogininfor sysLogininfor, String source)
public Rust<Boolean> saveLogininfor(SysLogininfor sysLogininfor, String source)
{
return null;
}

@ -4,7 +4,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.Rust;
import com.ruoyi.system.api.RemoteUserService;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.model.LoginUser;
@ -26,15 +26,15 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
return new RemoteUserService()
{
@Override
public R<LoginUser> getUserInfo(String username, String source)
public Rust<LoginUser> getUserInfo(String username, String source)
{
return R.fail("获取用户失败:" + throwable.getMessage());
return Rust.fail("获取用户失败:" + throwable.getMessage());
}
@Override
public R<Boolean> registerUserInfo(SysUser sysUser, String source)
public Rust<Boolean> registerUserInfo(SysUser sysUser, String source)
{
return R.fail("注册用户失败:" + throwable.getMessage());
return Rust.fail("注册用户失败:" + throwable.getMessage());
}
};
}

@ -9,7 +9,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.auth.form.LoginBody;
import com.ruoyi.auth.form.RegisterBody;
import com.ruoyi.auth.service.SysLoginService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.Rust;
import com.ruoyi.common.core.utils.JwtUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.security.auth.AuthUtil;
@ -32,16 +32,16 @@ public class TokenController
private SysLoginService sysLoginService;
@PostMapping("login")
public R<?> login(@RequestBody LoginBody form)
public Rust<?> login(@RequestBody LoginBody form)
{
// 用户登录
LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword());
// 获取登录token
return R.ok(tokenService.createToken(userInfo));
return Rust.ok(tokenService.createToken(userInfo));
}
@DeleteMapping("logout")
public R<?> logout(HttpServletRequest request)
public Rust<?> logout(HttpServletRequest request)
{
String token = SecurityUtils.getToken(request);
if (StringUtils.isNotEmpty(token))
@ -52,27 +52,27 @@ public class TokenController
// 记录用户退出日志
sysLoginService.logout(username);
}
return R.ok();
return Rust.ok();
}
@PostMapping("refresh")
public R<?> refresh(HttpServletRequest request)
public Rust<?> refresh(HttpServletRequest request)
{
LoginUser loginUser = tokenService.getLoginUser(request);
if (StringUtils.isNotNull(loginUser))
{
// 刷新令牌有效期
tokenService.refreshToken(loginUser);
return R.ok();
return Rust.ok();
}
return R.ok();
return Rust.ok();
}
@PostMapping("register")
public R<?> register(@RequestBody RegisterBody registerBody)
public Rust<?> register(@RequestBody RegisterBody registerBody)
{
// 用户注册
sysLoginService.register(registerBody.getUsername(), registerBody.getPassword());
return R.ok();
return Rust.ok();
}
}

@ -5,7 +5,7 @@ import org.springframework.stereotype.Component;
import com.ruoyi.common.core.constant.Constants;
import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.constant.UserConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.Rust;
import com.ruoyi.common.core.enums.UserStatus;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.utils.ServletUtils;
@ -58,9 +58,9 @@ public class SysLoginService
throw new ServiceException("用户名不在指定范围");
}
// 查询用户信息
R<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
Rust<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
if (R.FAIL == userResult.getCode())
if (Rust.FAIL == userResult.getCode())
{
throw new ServiceException(userResult.getMsg());
}
@ -122,9 +122,9 @@ public class SysLoginService
sysUser.setUserName(username);
sysUser.setNickName(username);
sysUser.setPassword(SecurityUtils.encryptPassword(password));
R<?> registerResult = remoteUserService.registerUserInfo(sysUser, SecurityConstants.INNER);
Rust<?> registerResult = remoteUserService.registerUserInfo(sysUser, SecurityConstants.INNER);
if (R.FAIL == registerResult.getCode())
if (Rust.FAIL == registerResult.getCode())
{
throw new ServiceException(registerResult.getMsg());
}
@ -156,4 +156,4 @@ public class SysLoginService
}
remoteLogService.saveLogininfor(logininfor, SecurityConstants.INNER);
}
}
}

@ -40,7 +40,7 @@ public class SecurityContextHolder
Map<String, Object> map = THREAD_LOCAL.get();
if (map == null)
{
map = new ConcurrentHashMap<String, Object>();
map = new ConcurrentHashMap<String, Object>(2);
THREAD_LOCAL.set(map);
}
return map;

@ -1,105 +1,106 @@
package com.ruoyi.common.core.domain;
import java.io.Serializable;
import com.ruoyi.common.core.constant.Constants;
/**
*
*
* @author ruoyi
*/
public class R<T> implements Serializable
{
private static final long serialVersionUID = 1L;
/** 成功 */
public static final int SUCCESS = Constants.SUCCESS;
/** 失败 */
public static final int FAIL = Constants.FAIL;
private int code;
private String msg;
private T data;
public static <T> R<T> ok()
{
return restResult(null, SUCCESS, null);
}
public static <T> R<T> ok(T data)
{
return restResult(data, SUCCESS, null);
}
public static <T> R<T> ok(T data, String msg)
{
return restResult(data, SUCCESS, msg);
}
public static <T> R<T> fail()
{
return restResult(null, FAIL, null);
}
public static <T> R<T> fail(String msg)
{
return restResult(null, FAIL, msg);
}
public static <T> R<T> fail(T data)
{
return restResult(data, FAIL, null);
}
public static <T> R<T> fail(T data, String msg)
{
return restResult(data, FAIL, msg);
}
public static <T> R<T> fail(int code, String msg)
{
return restResult(null, code, msg);
}
private static <T> R<T> restResult(T data, int code, String msg)
{
R<T> apiResult = new R<>();
apiResult.setCode(code);
apiResult.setData(data);
apiResult.setMsg(msg);
return apiResult;
}
public int getCode()
{
return code;
}
public void setCode(int code)
{
this.code = code;
}
public String getMsg()
{
return msg;
}
public void setMsg(String msg)
{
this.msg = msg;
}
public T getData()
{
return data;
}
public void setData(T data)
{
this.data = data;
}
}
package com.ruoyi.common.core.domain;
import com.ruoyi.common.core.constant.Constants;
import java.io.Serializable;
/**
*
*
* @author ruoyi
*/
public class Rust<T> implements Serializable
{
private static final long serialVersionUID = 1L;
/** 成功 */
public static final int SUCCESS = Constants.SUCCESS;
/** 失败 */
public static final int FAIL = Constants.FAIL;
private int code;
private String msg;
private T data;
public static <T> Rust<T> ok()
{
return restResult(null, SUCCESS, null);
}
public static <T> Rust<T> ok(T data)
{
return restResult(data, SUCCESS, null);
}
public static <T> Rust<T> ok(T data, String msg)
{
return restResult(data, SUCCESS, msg);
}
public static <T> Rust<T> fail()
{
return restResult(null, FAIL, null);
}
public static <T> Rust<T> fail(String msg)
{
return restResult(null, FAIL, msg);
}
public static <T> Rust<T> fail(T data)
{
return restResult(data, FAIL, null);
}
public static <T> Rust<T> fail(T data, String msg)
{
return restResult(data, FAIL, msg);
}
public static <T> Rust<T> fail(int code, String msg)
{
return restResult(null, code, msg);
}
private static <T> Rust<T> restResult(T data, int code, String msg)
{
Rust<T> apiResult = new Rust<>();
apiResult.setCode(code);
apiResult.setData(data);
apiResult.setMsg(msg);
return apiResult;
}
public int getCode()
{
return code;
}
public void setCode(int code)
{
this.code = code;
}
public String getMsg()
{
return msg;
}
public void setMsg(String msg)
{
this.msg = msg;
}
public T getData()
{
return data;
}
public void setData(T data)
{
this.data = data;
}
}

@ -1,12 +1,13 @@
package com.ruoyi.common.core.text;
import com.ruoyi.common.core.utils.StringUtils;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.text.NumberFormat;
import java.util.Set;
import com.ruoyi.common.core.utils.StringUtils;
/**
*
@ -907,7 +908,7 @@ public class Convert
*/
public static String tosbc(String input, Set<Character> notConvertSet)
{
char c[] = input.toCharArray();
char[] c = input.toCharArray();
for (int i = 0; i < c.length; i++)
{
if (null != notConvertSet && notConvertSet.contains(c[i]))
@ -949,7 +950,7 @@ public class Convert
*/
public static String todbc(String text, Set<Character> notConvertSet)
{
char c[] = text.toCharArray();
char[] c = text.toCharArray();
for (int i = 0; i < c.length; i++)
{
if (null != notConvertSet && notConvertSet.contains(c[i]))

@ -1,5 +1,7 @@
package com.ruoyi.common.core.utils;
import com.ruoyi.common.core.text.Convert;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
@ -7,11 +9,10 @@ import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.core.utils.StringUtils;
public class ReUtil
{
/**
* @author pan
*/
public class ReUtil {
public final static Pattern GROUP_VAR = Pattern.compile("\\$(\\d+)");
/**

@ -20,7 +20,7 @@ import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.constant.Constants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.Rust;
import com.ruoyi.common.core.text.Convert;
import reactor.core.publisher.Mono;
@ -251,7 +251,7 @@ public class ServletUtils
*/
public static Mono<Void> webFluxResponseWriter(ServerHttpResponse response, Object value)
{
return webFluxResponseWriter(response, HttpStatus.OK, value, R.FAIL);
return webFluxResponseWriter(response, HttpStatus.OK, value, Rust.FAIL);
}
/**
@ -295,7 +295,7 @@ public class ServletUtils
{
response.setStatusCode(status);
response.getHeaders().add(HttpHeaders.CONTENT_TYPE, contentType);
R<?> result = R.fail(code, value.toString());
Rust<?> result = Rust.fail(code, value.toString());
DataBuffer dataBuffer = response.bufferFactory().wrap(JSONObject.toJSONString(result).getBytes());
return response.writeWith(Mono.just(dataBuffer));
}

@ -1,11 +1,12 @@
package com.ruoyi.common.core.utils;
import com.ruoyi.common.core.constant.Constants;
import com.ruoyi.common.core.text.StrFormatter;
import org.springframework.util.AntPathMatcher;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.springframework.util.AntPathMatcher;
import com.ruoyi.common.core.constant.Constants;
import com.ruoyi.common.core.text.StrFormatter;
/**
*
@ -332,9 +333,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase)
{
sb.append(SEPARATOR);
}
else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase)
{
} else if (i != 0 && !preCharIsUpperCase && curreCharIsUpperCase) {
sb.append(SEPARATOR);
}
sb.append(Character.toLowerCase(c));

@ -1,8 +1,9 @@
package com.ruoyi.common.core.utils.file;
import java.io.File;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
/**
*
*
@ -54,10 +55,10 @@ public class FileTypeUtils
public static String getFileExtendName(byte[] photoByte)
{
String strFileExtendName = "JPG";
if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56)
&& ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97))
{
strFileExtendName = "GIF";
if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56) && (photoByte[5] == 97)) {
if ((photoByte[4] == 55) || (photoByte[4] == 57)) {
strFileExtendName = "GIF";
}
}
else if ((photoByte[6] == 74) && (photoByte[7] == 70) && (photoByte[8] == 73) && (photoByte[9] == 70))
{
@ -73,4 +74,4 @@ public class FileTypeUtils
}
return strFileExtendName;
}
}
}

@ -58,7 +58,7 @@ public class EscapeUtil
*/
public static String clean(String content)
{
return new HTMLFilter().filter(content);
return new HtmlFilter().filter(content);
}
/**

@ -1,10 +1,6 @@
package com.ruoyi.common.core.utils.html;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.regex.Matcher;
@ -15,8 +11,7 @@ import java.util.regex.Pattern;
*
* @author ruoyi
*/
public final class HTMLFilter
{
public final class HtmlFilter {
/**
* regex flag union representing /si modifiers in php
**/
@ -45,7 +40,9 @@ public final class HTMLFilter
private static final Pattern P_RIGHT_ARROW = Pattern.compile(">");
private static final Pattern P_BOTH_ARROWS = Pattern.compile("<>");
// @xxx could grow large... maybe use sesat's ReferenceMap
/**
* @xxx could grow large... maybe use sesat's ReferenceMap
*/
private static final ConcurrentMap<String, Pattern> P_REMOVE_PAIR_BLANKS = new ConcurrentHashMap<>();
private static final ConcurrentMap<String, Pattern> P_REMOVE_SELF_BLANKS = new ConcurrentHashMap<>();
@ -100,8 +97,7 @@ public final class HTMLFilter
/**
* Default constructor.
*/
public HTMLFilter()
{
public HtmlFilter() {
vAllowed = new HashMap<>();
final ArrayList<String> aAtos = new ArrayList<>();
@ -122,13 +118,13 @@ public final class HTMLFilter
vAllowed.put("i", noAtts);
vAllowed.put("em", noAtts);
vSelfClosingTags = new String[] { "img" };
vNeedClosingTags = new String[] { "a", "b", "strong", "i", "em" };
vDisallowed = new String[] {};
vAllowedProtocols = new String[] { "http", "mailto", "https" }; // no ftp.
vProtocolAtts = new String[] { "src", "href" };
vRemoveBlanks = new String[] { "a", "b", "strong", "i", "em" };
vAllowedEntities = new String[] { "amp", "gt", "lt", "quot" };
vSelfClosingTags = new String[]{"img"};
vNeedClosingTags = new String[]{"a", "b", "strong", "i", "em"};
vDisallowed = new String[]{};
vAllowedProtocols = new String[]{"http", "mailto", "https"}; // no ftp.
vProtocolAtts = new String[]{"src", "href"};
vRemoveBlanks = new String[]{"a", "b", "strong", "i", "em"};
vAllowedEntities = new String[]{"amp", "gt", "lt", "quot"};
stripComment = true;
encodeQuotes = true;
alwaysMakeTags = false;
@ -140,8 +136,7 @@ public final class HTMLFilter
* @param conf map containing configuration. keys match field names.
*/
@SuppressWarnings("unchecked")
public HTMLFilter(final Map<String, Object> conf)
{
public HtmlFilter(final Map<String, Object> conf) {
assert conf.containsKey("vAllowed") : "configuration requires vAllowed";
assert conf.containsKey("vSelfClosingTags") : "configuration requires vSelfClosingTags";
@ -165,20 +160,22 @@ public final class HTMLFilter
alwaysMakeTags = conf.containsKey("alwaysMakeTags") ? (Boolean) conf.get("alwaysMakeTags") : true;
}
private void reset()
{
private void reset() {
vTagCounts.clear();
}
// ---------------------------------------------------------------
// my versions of some PHP library functions
public static String chr(final int decimal)
{
/**
* my versions of some PHP library functions
* @param decimal /
* @return /
*/
public static String chr(final int decimal) {
return String.valueOf((char) decimal);
}
public static String htmlSpecialChars(final String s)
{
public static String htmlSpecialChars(final String s) {
String result = s;
result = regexReplace(P_AMP, "&amp;", result);
result = regexReplace(P_QUOTE, "&quot;", result);
@ -195,8 +192,7 @@ public final class HTMLFilter
* @param input text (i.e. submitted by a user) than may contain html
* @return "clean" version of input, with only valid, whitelisted html elements allowed
*/
public String filter(final String input)
{
public String filter(final String input) {
reset();
String s = input;
@ -213,22 +209,18 @@ public final class HTMLFilter
return s;
}
public boolean isAlwaysMakeTags()
{
public boolean isAlwaysMakeTags() {
return alwaysMakeTags;
}
public boolean isStripComments()
{
public boolean isStripComments() {
return stripComment;
}
private String escapeComments(final String s)
{
private String escapeComments(final String s) {
final Matcher m = P_COMMENTS.matcher(s);
final StringBuffer buf = new StringBuffer();
if (m.find())
{
if (m.find()) {
final String match = m.group(1); // (.*?)
m.appendReplacement(buf, Matcher.quoteReplacement("<!--" + htmlSpecialChars(match) + "-->"));
}
@ -237,10 +229,8 @@ public final class HTMLFilter
return buf.toString();
}
private String balancehtml(String s)
{
if (alwaysMakeTags)
{
private String balancehtml(String s) {
if (alwaysMakeTags) {
//
// try and form html
//
@ -249,9 +239,7 @@ public final class HTMLFilter
s = regexReplace(P_BODY_TO_END, "<$1>", s);
s = regexReplace(P_XML_CONTENT, "$1<$2", s);
}
else
{
} else {
//
// escape stray brackets
//
@ -269,13 +257,11 @@ public final class HTMLFilter
return s;
}
private String checkTags(String s)
{
private String checkTags(String s) {
Matcher m = P_TAGS.matcher(s);
final StringBuffer buf = new StringBuffer();
while (m.find())
{
while (m.find()) {
String replaceStr = m.group(1);
replaceStr = processTag(replaceStr);
m.appendReplacement(buf, Matcher.quoteReplacement(replaceStr));
@ -285,10 +271,8 @@ public final class HTMLFilter
// these get tallied in processTag
// (remember to reset before subsequent calls to filter method)
final StringBuilder sBuilder = new StringBuilder(buf.toString());
for (String key : vTagCounts.keySet())
{
for (int ii = 0; ii < vTagCounts.get(key); ii++)
{
for (String key : vTagCounts.keySet()) {
for (int ii = 0; ii < vTagCounts.get(key); ii++) {
sBuilder.append("</").append(key).append(">");
}
}
@ -297,18 +281,14 @@ public final class HTMLFilter
return s;
}
private String processRemoveBlanks(final String s)
{
private String processRemoveBlanks(final String s) {
String result = s;
for (String tag : vRemoveBlanks)
{
if (!P_REMOVE_PAIR_BLANKS.containsKey(tag))
{
for (String tag : vRemoveBlanks) {
if (!P_REMOVE_PAIR_BLANKS.containsKey(tag)) {
P_REMOVE_PAIR_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?></" + tag + ">"));
}
result = regexReplace(P_REMOVE_PAIR_BLANKS.get(tag), "", result);
if (!P_REMOVE_SELF_BLANKS.containsKey(tag))
{
if (!P_REMOVE_SELF_BLANKS.containsKey(tag)) {
P_REMOVE_SELF_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?/>"));
}
result = regexReplace(P_REMOVE_SELF_BLANKS.get(tag), "", result);
@ -317,136 +297,93 @@ public final class HTMLFilter
return result;
}
private static String regexReplace(final Pattern regexPattern, final String replacement, final String s)
{
private static String regexReplace(final Pattern regexPattern, final String replacement, final String s) {
Matcher m = regexPattern.matcher(s);
return m.replaceAll(replacement);
}
private String processTag(final String s)
{
// ending tags
private String processTag(final String s) {
Matcher m = P_END_TAG.matcher(s);
if (m.find())
{
if (m.find()) {
final String name = m.group(1).toLowerCase();
if (allowed(name))
{
if (false == inArray(name, vSelfClosingTags))
{
if (vTagCounts.containsKey(name))
{
if (allowed(name)) {
if (false == inArray(name, vSelfClosingTags)) {
if (vTagCounts.containsKey(name)) {
vTagCounts.put(name, vTagCounts.get(name) - 1);
return "</" + name + ">";
}
}
}
}
// starting tags
m = P_START_TAG.matcher(s);
if (m.find())
{
if (m.find()) {
final String name = m.group(1).toLowerCase();
final String body = m.group(2);
String ending = m.group(3);
// debug( "in a starting tag, name='" + name + "'; body='" + body + "'; ending='" + ending + "'" );
if (allowed(name))
{
if (allowed(name)) {
final StringBuilder params = new StringBuilder();
final Matcher m2 = P_QUOTED_ATTRIBUTES.matcher(body);
final Matcher m3 = P_UNQUOTED_ATTRIBUTES.matcher(body);
final List<String> paramNames = new ArrayList<>();
final List<String> paramValues = new ArrayList<>();
while (m2.find())
{
while (m2.find()) {
paramNames.add(m2.group(1)); // ([a-z0-9]+)
paramValues.add(m2.group(3)); // (.*?)
}
while (m3.find())
{
while (m3.find()) {
paramNames.add(m3.group(1)); // ([a-z0-9]+)
paramValues.add(m3.group(3)); // ([^\"\\s']+)
}
String paramName, paramValue;
for (int ii = 0; ii < paramNames.size(); ii++)
{
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))
{
if (allowedAttribute(name, paramName)) {
if (inArray(paramName, vProtocolAtts)) {
paramValue = processParamProtocol(paramValue);
}
params.append(' ').append(paramName).append("=\\\"").append(paramValue).append("\"");
}
}
if (inArray(name, vSelfClosingTags))
{
if (inArray(name, vSelfClosingTags)) {
ending = " /";
}
if (inArray(name, vNeedClosingTags))
{
if (inArray(name, vNeedClosingTags)) {
ending = "";
}
if (ending == null || ending.length() < 1)
{
if (vTagCounts.containsKey(name))
{
if (ending == null || ending.length() < 1) {
if (vTagCounts.containsKey(name)) {
vTagCounts.put(name, vTagCounts.get(name) + 1);
}
else
{
} else {
vTagCounts.put(name, 1);
}
}
else
{
} else {
ending = " /";
}
return "<" + name + params + ending + ">";
}
else
{
} else {
return "";
}
}
// comments
m = P_COMMENT.matcher(s);
if (!stripComment && m.find())
{
if (!stripComment && m.find()) {
return "<" + m.group() + ">";
}
return "";
}
private String processParamProtocol(String s)
{
private String processParamProtocol(String s) {
s = decodeEntities(s);
final Matcher m = P_PROTOCOL.matcher(s);
if (m.find())
{
if (m.find()) {
final String protocol = m.group(1);
if (!inArray(protocol, vAllowedProtocols))
{
if (!inArray(protocol, vAllowedProtocols)) {
// bad protocol, turn into local anchor link instead
s = "#" + s.substring(protocol.length() + 1);
if (s.startsWith("#//"))
{
if (s.startsWith("#//")) {
s = "#" + s.substring(3);
}
}
@ -455,13 +392,11 @@ public final class HTMLFilter
return s;
}
private String decodeEntities(String s)
{
private String decodeEntities(String s) {
StringBuffer buf = new StringBuffer();
Matcher m = P_ENTITY.matcher(s);
while (m.find())
{
while (m.find()) {
final String match = m.group(1);
final int decimal = Integer.decode(match).intValue();
m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
@ -471,8 +406,7 @@ public final class HTMLFilter
buf = new StringBuffer();
m = P_ENTITY_UNICODE.matcher(s);
while (m.find())
{
while (m.find()) {
final String match = m.group(1);
final int decimal = Integer.valueOf(match, 16).intValue();
m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
@ -482,8 +416,7 @@ public final class HTMLFilter
buf = new StringBuffer();
m = P_ENCODE.matcher(s);
while (m.find())
{
while (m.find()) {
final String match = m.group(1);
final int decimal = Integer.valueOf(match, 16).intValue();
m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
@ -495,14 +428,12 @@ public final class HTMLFilter
return s;
}
private String validateEntities(final String s)
{
private String validateEntities(final String s) {
StringBuffer buf = new StringBuffer();
// validate entities throughout the string
Matcher m = P_VALID_ENTITIES.matcher(s);
while (m.find())
{
while (m.find()) {
final String one = m.group(1); // ([^&;]*)
final String two = m.group(2); // (?=(;|&|$))
m.appendReplacement(buf, Matcher.quoteReplacement(checkEntity(one, two)));
@ -512,14 +443,11 @@ public final class HTMLFilter
return encodeQuotes(buf.toString());
}
private String encodeQuotes(final String s)
{
if (encodeQuotes)
{
private String encodeQuotes(final String s) {
if (encodeQuotes) {
StringBuffer buf = new StringBuffer();
Matcher m = P_VALID_QUOTES.matcher(s);
while (m.find())
{
while (m.find()) {
final String one = m.group(1); // (>|^)
final String two = m.group(2); // ([^<]+?)
final String three = m.group(3); // (<|$)
@ -528,43 +456,34 @@ public final class HTMLFilter
}
m.appendTail(buf);
return buf.toString();
}
else
{
} else {
return s;
}
}
private String checkEntity(final String preamble, final String term)
{
private String checkEntity(final String preamble, final String term) {
return ";".equals(term) && isValidEntity(preamble) ? '&' + preamble : "&amp;" + preamble;
}
private boolean isValidEntity(final String entity)
{
private boolean isValidEntity(final String entity) {
return inArray(entity, vAllowedEntities);
}
private static boolean inArray(final String s, final String[] array)
{
for (String item : array)
{
if (item != null && item.equals(s))
{
private static boolean inArray(final String s, final String[] array) {
for (String item : array) {
if (item != null && item.equals(s)) {
return true;
}
}
return false;
}
private boolean allowed(final String name)
{
private boolean allowed(final String name) {
return (vAllowed.isEmpty() || vAllowed.containsKey(name)) && !inArray(name, vDisallowed);
}
private boolean allowedAttribute(final String name, final String paramName)
{
private boolean allowedAttribute(final String name, final String paramName) {
return allowed(name) && (vAllowed.isEmpty() || vAllowed.get(name).contains(paramName));
}
}
}

@ -68,24 +68,24 @@ public class IpUtils {
final byte b0 = addr[0];
final byte b1 = addr[1];
// 10.x.x.x/8
final byte SECTION1 = 0x0A;
final byte section1 = 0x0A;
// 172.16.x.x/12
final byte SECTION2 = (byte) 0xAC;
final byte SECTION3 = (byte) 0x10;
final byte SECTION4 = (byte) 0x1F;
final byte section2 = (byte) 0xAC;
final byte section3 = (byte) 0x10;
final byte section4 = (byte) 0x1F;
// 192.168.x.x/16
final byte SECTION5 = (byte) 0xC0;
final byte SECTION6 = (byte) 0xA8;
final byte section5 = (byte) 0xC0;
final byte section6 = (byte) 0xA8;
switch (b0) {
case SECTION1:
case section1:
return true;
case SECTION2:
if (b1 >= SECTION3 && b1 <= SECTION4) {
case section2:
if (b1 >= section3 && b1 <= section4) {
return true;
}
case SECTION5:
case section5:
switch (b1) {
case SECTION6: {
case section6: {
return true;
}
default:{
@ -228,4 +228,4 @@ public class IpUtils {
public static boolean isUnknown(String checkString) {
return StringUtils.isBlank(checkString) || "unknown".equalsIgnoreCase(checkString);
}
}
}

@ -1,19 +1,15 @@
package com.ruoyi.common.core.utils.reflect;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Date;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.core.utils.DateUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.apache.poi.ss.usermodel.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.core.utils.DateUtils;
import java.lang.reflect.*;
import java.util.Date;
/**
* . getter/setter, 访, , Class, AOP.
@ -102,7 +98,6 @@ public class ReflectUtils
Field field = getAccessibleField(obj, fieldName);
if (field == null)
{
// throw new IllegalArgumentException("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 ");
logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 ");
return;
}
@ -312,10 +307,10 @@ public class ReflectUtils
*/
public static void makeAccessible(Method method)
{
if ((!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers()))
&& !method.isAccessible())
{
method.setAccessible(true);
if (!method.isAccessible()) {
if (!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) {
method.setAccessible(true);
}
}
}
@ -324,10 +319,11 @@ 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())
{
field.setAccessible(true);
if (!field.isAccessible()) {
if (!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers())
|| Modifier.isFinal(field.getModifiers())) {
field.setAccessible(true);
}
}
}

@ -2,75 +2,63 @@ package com.ruoyi.common.core.utils.sign;
/**
* Base64
*
*
* @author ruoyi
*/
public final class Base64
{
static private final int BASELENGTH = 128;
static private final int LOOKUPLENGTH = 64;
static private final int TWENTYFOURBITGROUP = 24;
static private final int EIGHTBIT = 8;
static private final int SIXTEENBIT = 16;
static private final int FOURBYTE = 4;
static private final int SIGN = -128;
static private final char PAD = '=';
public final class Base64 {
static private final int BASELENGTH = 128;
static private final int LOOKUPLENGTH = 64;
static private final int TWENTYFOURBITGROUP = 24;
static private final int EIGHTBIT = 8;
static private final int SIXTEENBIT = 16;
static private final int FOURBYTE = 4;
static private final int SIGN = -128;
static private final char PAD = '=';
static final private byte[] BASE_64_ALPHABET = new byte[BASELENGTH];
static final private char[] LOOK_UP_BASE_64_ALPHABET = new char[LOOKUPLENGTH];
static
{
for (int i = 0; i < BASELENGTH; ++i)
{
static {
for (int i = 0; i < BASELENGTH; ++i) {
BASE_64_ALPHABET[i] = -1;
}
for (int i = 'Z'; i >= 'A'; i--)
{
for (int i = 'Z'; i >= 'A'; i--) {
BASE_64_ALPHABET[i] = (byte) (i - 'A');
}
for (int i = 'z'; i >= 'a'; i--)
{
for (int i = 'z'; i >= 'a'; i--) {
BASE_64_ALPHABET[i] = (byte) (i - 'a' + 26);
}
for (int i = '9'; i >= '0'; i--)
{
for (int i = '9'; i >= '0'; i--) {
BASE_64_ALPHABET[i] = (byte) (i - '0' + 52);
}
BASE_64_ALPHABET['+'] = 62;
BASE_64_ALPHABET['/'] = 63;
for (int i = 0; i <= 25; i++)
{
for (int i = 0; i <= 25; i++) {
LOOK_UP_BASE_64_ALPHABET[i] = (char) ('A' + i);
}
for (int i = 26, j = 0; i <= 51; i++, j++)
{
for (int i = 26, j = 0; i <= 51; i++, j++) {
LOOK_UP_BASE_64_ALPHABET[i] = (char) ('a' + j);
}
for (int i = 52, j = 0; i <= 61; i++, j++)
{
for (int i = 52, j = 0; i <= 61; i++, j++) {
LOOK_UP_BASE_64_ALPHABET[i] = (char) ('0' + j);
}
LOOK_UP_BASE_64_ALPHABET[62] = (char) '+';
LOOK_UP_BASE_64_ALPHABET[63] = (char) '/';
}
private static boolean isWhiteSpace(char octect)
{
private static boolean isWhiteSpace(char octect) {
return (octect == 0x20 || octect == 0xd || octect == 0xa || octect == 0x9);
}
private static boolean isPad(char octect)
{
private static boolean isPad(char octect) {
return (octect == PAD);
}
private static boolean isData(char octect)
{
private static boolean isData(char octect) {
return (octect < BASELENGTH && BASE_64_ALPHABET[octect] != -1);
}
@ -80,23 +68,20 @@ public final class Base64
* @param binaryData Array containing binaryData
* @return Encoded Base64 array
*/
public static String encode(byte[] binaryData)
{
if (binaryData == null)
{
public static String encode(byte[] binaryData) {
if (binaryData == null) {
return null;
}
int lengthDataBits = binaryData.length * EIGHTBIT;
if (lengthDataBits == 0)
{
if (lengthDataBits == 0) {
return "";
}
int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP;
int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP;
int numberQuartet = fewerThan24bits != 0 ? numberTriplets + 1 : numberTriplets;
char encodedData[] = null;
char[] encodedData = null;
encodedData = new char[numberQuartet * 4];
@ -105,8 +90,7 @@ public final class Base64
int encodedIndex = 0;
int dataIndex = 0;
for (int i = 0; i < numberTriplets; i++)
{
for (int i = 0; i < numberTriplets; i++) {
b1 = binaryData[dataIndex++];
b2 = binaryData[dataIndex++];
b3 = binaryData[dataIndex++];
@ -125,8 +109,7 @@ public final class Base64
}
// form integral number of 6-bit groups
if (fewerThan24bits == EIGHTBIT)
{
if (fewerThan24bits == EIGHTBIT) {
b1 = binaryData[dataIndex];
k = (byte) (b1 & 0x03);
byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
@ -134,9 +117,7 @@ public final class Base64
encodedData[encodedIndex++] = LOOK_UP_BASE_64_ALPHABET[k << 4];
encodedData[encodedIndex++] = PAD;
encodedData[encodedIndex++] = PAD;
}
else if (fewerThan24bits == SIXTEENBIT)
{
} else if (fewerThan24bits == SIXTEENBIT) {
b1 = binaryData[dataIndex];
b2 = binaryData[dataIndex + 1];
l = (byte) (b2 & 0x0f);
@ -159,71 +140,48 @@ public final class Base64
* @param encoded string containing Base64 data
* @return Array containind decoded data.
*/
public static byte[] decode(String encoded)
{
if (encoded == null)
{
public static byte[] decode(String encoded) {
if (encoded == null) {
return null;
}
char[] base64Data = encoded.toCharArray();
// remove white spaces
int len = removeWhiteSpace(base64Data);
if (len % FOURBYTE != 0)
{
return null;// should be divisible by four
int len = removeWhiteSpace(base64Data);// 删除空格
if (len % FOURBYTE != 0) {
return null;// sho应该能被四整除
}
int numberQuadruple = (len / FOURBYTE);
if (numberQuadruple == 0)
{
if (numberQuadruple == 0) {
return new byte[0];
}
byte decodedData[] = null;
byte[] decodedData = null;
byte b1 = 0, b2 = 0, b3 = 0, b4 = 0;
char d1 = 0, d2 = 0, d3 = 0, d4 = 0;
int i = 0;
int encodedIndex = 0;
int dataIndex = 0;
decodedData = new byte[(numberQuadruple) * 3];
for (; i < numberQuadruple - 1; i++)
{
for (; i < numberQuadruple - 1; i++) {
if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++]))
|| !isData((d3 = base64Data[dataIndex++])) || !isData((d4 = base64Data[dataIndex++])))
{
|| !isData((d3 = base64Data[dataIndex++])) || !isData((d4 = base64Data[dataIndex++]))) {
return null;
} // if found "no data" just return null
b1 = BASE_64_ALPHABET[d1];
b2 = BASE_64_ALPHABET[d2];
b3 = BASE_64_ALPHABET[d3];
b4 = BASE_64_ALPHABET[d4];
decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
decodedData[encodedIndex++] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
decodedData[encodedIndex++] = (byte) (b3 << 6 | b4);
}
if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++])))
{
if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++]))) {
return null;// if found "no data" just return null
}
b1 = BASE_64_ALPHABET[d1];
b2 = BASE_64_ALPHABET[d2];
d3 = base64Data[dataIndex++];
d4 = base64Data[dataIndex++];
if (!isData((d3)) || !isData((d4)))
{// Check if they are PAD characters
if (isPad(d3) && isPad(d4))
{
if (!isData((d3)) || !isData((d4))) {// Check if they are PAD characters
if (isPad(d3) && isPad(d4)) {
if ((b2 & 0xf) != 0)// last 4 bits should be zero
{
return null;
@ -232,9 +190,7 @@ public final class Base64
System.arraycopy(decodedData, 0, tmp, 0, i * 3);
tmp[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
return tmp;
}
else if (!isPad(d3) && isPad(d4))
{
} else if (!isPad(d3) && isPad(d4)) {
b3 = BASE_64_ALPHABET[d3];
if ((b3 & 0x3) != 0)// last 2 bits should be zero
{
@ -245,20 +201,15 @@ public final class Base64
tmp[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
tmp[encodedIndex] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
return tmp;
}
else
{
} else {
return null;
}
}
else
{ // No PAD e.g 3cQl
} else { // No PAD e.g 3cQl
b3 = BASE_64_ALPHABET[d3];
b4 = BASE_64_ALPHABET[d4];
decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
decodedData[encodedIndex++] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
decodedData[encodedIndex++] = (byte) (b3 << 6 | b4);
}
return decodedData;
}
@ -269,20 +220,16 @@ public final class Base64
* @param data the byte array of base64 data (with WS)
* @return the new length
*/
private static int removeWhiteSpace(char[] data)
{
if (data == null)
{
private static int removeWhiteSpace(char[] data) {
if (data == null) {
return 0;
}
// count characters that's not whitespace
int newSize = 0;
int len = data.length;
for (int i = 0; i < len; i++)
{
if (!isWhiteSpace(data[i]))
{
for (int i = 0; i < len; i++) {
if (!isWhiteSpace(data[i])) {
data[newSize++] = data[i];
}
}

@ -12,9 +12,9 @@ public class IdUtils
*
* @return UUID
*/
public static String randomUUID()
public static String randomuuid()
{
return UUID.randomUUID().toString();
return UUID.randomuuid().toString();
}
/**
@ -22,9 +22,9 @@ public class IdUtils
*
* @return UUID线
*/
public static String simpleUUID()
public static String simpleuuid()
{
return UUID.randomUUID().toString(true);
return UUID.randomuuid().toString(true);
}
/**
@ -32,9 +32,9 @@ public class IdUtils
*
* @return UUID
*/
public static String fastUUID()
public static String fastuuid()
{
return UUID.fastUUID().toString();
return UUID.fastuuid().toString();
}
/**
@ -42,8 +42,8 @@ public class IdUtils
*
* @return UUID线
*/
public static String fastSimpleUUID()
public static String fastsimpleuuid()
{
return UUID.fastUUID().toString(true);
return UUID.fastuuid().toString(true);
}
}

@ -9,19 +9,29 @@ import com.ruoyi.common.core.utils.StringUtils;
*/
public class Seq
{
// 通用序列类型
/**
*
*/
public static final String COMM_SEQ_TYPE = "COMMON";
// 上传序列类型
/**
*
*/
public static final String UPLOAD_SEQ_TYPE = "UPLOAD";
// 通用接口序列数
/**
*
*/
private static AtomicInteger commSeq = new AtomicInteger(1);
// 上传接口序列数
/**
*
*/
private static AtomicInteger uploadSeq = new AtomicInteger(1);
// 机器标识
/**
*
*/
private static String machineCode = "A";
/**

@ -1,11 +1,12 @@
package com.ruoyi.common.core.utils.uuid;
import com.ruoyi.common.core.exception.UtilException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import com.ruoyi.common.core.exception.UtilException;
/**
* universally unique identifierUUID
@ -70,9 +71,9 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
*
* @return {@code UUID}
*/
public static UUID fastUUID()
public static UUID fastuuid()
{
return randomUUID(false);
return randomuuid(false);
}
/**
@ -80,9 +81,9 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
*
* @return {@code UUID}
*/
public static UUID randomUUID()
public static UUID randomuuid()
{
return randomUUID(true);
return randomuuid(true);
}
/**
@ -91,7 +92,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
* @param isSecure 使{@link SecureRandom}
* @return {@code UUID}
*/
public static UUID randomUUID(boolean isSecure)
public static UUID randomuuid(boolean isSecure)
{
final Random ng = isSecure ? Holder.NUMBER_GENERATOR : getRandom();
@ -111,7 +112,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
*
* @return {@code UUID}
*/
public static UUID nameUUIDFromBytes(byte[] name)
public static UUID nameUuidFromBytes(byte[] name)
{
MessageDigest md;
try
@ -147,7 +148,10 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
}
for (int i = 0; i < 5; i++)
{
components[i] = "0x" + components[i];
StringBuilder sb = new StringBuilder();
sb.append(sb);
sb.append(components[i]);
components[i] = sb.toString();
}
long mostSigBits = Long.decode(components[0]).longValue();

@ -1,10 +1,11 @@
package com.ruoyi.common.core.web.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* Entity
@ -102,7 +103,7 @@ public class BaseEntity implements Serializable
{
if (params == null)
{
params = new HashMap<>();
params = new HashMap<>(2);
}
return params;
}

@ -1,18 +1,17 @@
package com.ruoyi.common.security.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.ruoyi.common.security.config.ApplicationConfig;
import com.ruoyi.common.security.feign.FeignAutoConfiguration;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.Import;
import org.springframework.scheduling.annotation.EnableAsync;
import com.ruoyi.common.security.config.ApplicationConfig;
import com.ruoyi.common.security.feign.FeignAutoConfiguration;
import java.lang.annotation.*;
/**
* @author pan
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented

@ -33,9 +33,10 @@ public class InnerAuthAspect implements Ordered
String userid = ServletUtils.getRequest().getHeader(SecurityConstants.DETAILS_USER_ID);
String username = ServletUtils.getRequest().getHeader(SecurityConstants.DETAILS_USERNAME);
// 用户信息验证
if (innerAuth.isUser() && (StringUtils.isEmpty(userid) || StringUtils.isEmpty(username)))
{
throw new InnerAuthException("没有设置用户信息,不允许访问 ");
if (innerAuth.isUser()) {
if (StringUtils.isEmpty(userid) || StringUtils.isEmpty(username)) {
throw new InnerAuthException("没有设置用户信息,不允许访问 ");
}
}
return point.proceed();
}

@ -1,11 +1,5 @@
package com.ruoyi.common.security.service;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.ruoyi.common.core.constant.CacheConstants;
import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.utils.JwtUtils;
@ -16,6 +10,13 @@ import com.ruoyi.common.core.utils.uuid.IdUtils;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* token
@ -43,7 +44,7 @@ public class TokenService
*/
public Map<String, Object> createToken(LoginUser loginUser)
{
String token = IdUtils.fastUUID();
String token = IdUtils.fastuuid();
Long userId = loginUser.getSysUser().getUserId();
String userName = loginUser.getSysUser().getUserName();
loginUser.setToken(token);
@ -53,13 +54,13 @@ public class TokenService
refreshToken(loginUser);
// Jwt存储信息
Map<String, Object> claimsMap = new HashMap<String, Object>();
Map<String, Object> claimsMap = new HashMap<String, Object>(2);
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<String, Object>(2);
rspMap.put("access_token", JwtUtils.createToken(claimsMap));
rspMap.put("expires_in", EXPIRE_TIME);
return rspMap;
@ -166,4 +167,4 @@ public class TokenService
{
return ACCESS_TOKEN + token;
}
}
}

@ -1,14 +1,13 @@
package com.ruoyi.common.swagger.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.context.annotation.Import;
import com.ruoyi.common.swagger.config.SwaggerAutoConfiguration;
import org.springframework.context.annotation.Import;
import java.lang.annotation.*;
/**
* @author pan
*/
@Target({ ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Documented

@ -1,9 +1,5 @@
package com.ruoyi.common.swagger.config;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@ -12,24 +8,26 @@ import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.ApiKey;
import springfox.documentation.service.AuthorizationScope;
import springfox.documentation.service.Contact;
import springfox.documentation.service.SecurityReference;
import springfox.documentation.service.SecurityScheme;
import springfox.documentation.service.*;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.ApiSelectorBuilder;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
/**
* @author pan
*/
@Configuration
@EnableSwagger2
@EnableAutoConfiguration
@ConditionalOnProperty(name = "swagger.enabled", matchIfMissing = true)
public class SwaggerAutoConfiguration
{
public class SwaggerAutoConfiguration{
/**
* Spring Boot
*/

@ -1,10 +1,14 @@
package com.ruoyi.common.swagger.config;
import java.util.ArrayList;
import java.util.List;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
/**
* @author pan
*/
@Component
@ConfigurationProperties("swagger")
public class SwaggerProperties
@ -342,4 +346,4 @@ public class SwaggerProperties
this.description = description;
}
}
}
}

@ -1,8 +1,9 @@
package com.ruoyi.gateway.config;
import java.util.Random;
import com.google.code.kaptcha.text.impl.DefaultTextCreator;
import java.util.Random;
/**
*
*
@ -30,7 +31,7 @@ public class KaptchaTextCreator extends DefaultTextCreator
}
else if (randomoperands == 1)
{
if (!(x == 0) && y % x == 0)
if ((x != 0) && y % x == 0)
{
result = y / x;
suChinese.append(CNUMBERS[y]);
@ -72,4 +73,4 @@ public class KaptchaTextCreator extends DefaultTextCreator
suChinese.append("=?@" + result);
return suChinese.toString();
}
}
}

@ -31,7 +31,9 @@ public class AuthFilter implements GlobalFilter, Ordered
{
private static final Logger log = LoggerFactory.getLogger(AuthFilter.class);
// 排除过滤的 uri 地址nacos自行添加
/**
* uri nacos
*/
@Autowired
private IgnoreWhiteProperties ignoreWhite;
@ -132,4 +134,4 @@ public class AuthFilter implements GlobalFilter, Ordered
{
return -200;
}
}
}

@ -1,16 +1,15 @@
package com.ruoyi.gateway.filter;
import java.nio.charset.StandardCharsets;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.html.EscapeUtil;
import com.ruoyi.gateway.config.properties.XssProperties;
import io.netty.buffer.ByteBufAllocator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.DataBufferFactory;
import org.springframework.core.io.buffer.DataBufferUtils;
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
import org.springframework.core.io.buffer.NettyDataBufferFactory;
import org.springframework.core.io.buffer.*;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
@ -18,13 +17,11 @@ import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpRequestDecorator;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.html.EscapeUtil;
import com.ruoyi.gateway.config.properties.XssProperties;
import io.netty.buffer.ByteBufAllocator;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.nio.charset.StandardCharsets;
/**
*
*
@ -34,7 +31,9 @@ import reactor.core.publisher.Mono;
@ConditionalOnProperty(value = "security.xss.enabled", havingValue = "true")
public class XssFilter implements GlobalFilter, Ordered
{
// 跨站脚本的 xss 配置nacos自行添加
/**
* xss nacos
*/
@Autowired
private XssProperties xss;

@ -1,6 +1,5 @@
package com.ruoyi.gateway.handler;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@ -8,16 +7,16 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
import springfox.documentation.swagger.web.SecurityConfiguration;
import springfox.documentation.swagger.web.SecurityConfigurationBuilder;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;
import springfox.documentation.swagger.web.UiConfiguration;
import springfox.documentation.swagger.web.UiConfigurationBuilder;
import springfox.documentation.swagger.web.*;
import java.util.Optional;
/**
* @author pan
*/
@RestController
@RequestMapping("/swagger-resources")
public class SwaggerHandler
{
public class SwaggerHandler {
@Autowired(required = false)
private SecurityConfiguration securityConfiguration;

@ -54,7 +54,7 @@ public class ValidateCodeServiceImpl implements ValidateCodeService
}
// 保存验证码信息
String uuid = IdUtils.simpleUUID();
String uuid = IdUtils.simpleuuid();
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
String capStr = null, code = null;

@ -6,7 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.Rust;
import com.ruoyi.common.core.utils.file.FileUtils;
import com.ruoyi.file.service.ISysFileService;
import com.ruoyi.system.api.domain.SysFile;
@ -28,7 +28,7 @@ public class SysFileController
*
*/
@PostMapping("upload")
public R<SysFile> upload(MultipartFile file)
public Rust<SysFile> upload(MultipartFile file)
{
try
{
@ -37,12 +37,12 @@ public class SysFileController
SysFile sysFile = new SysFile();
sysFile.setName(FileUtils.getName(url));
sysFile.setUrl(url);
return R.ok(sysFile);
return Rust.ok(sysFile);
}
catch (Exception e)
{
log.error("上传文件失败", e);
return R.fail(e.getMessage());
return Rust.fail(e.getMessage());
}
}
}
}

@ -1,21 +1,5 @@
package com.ruoyi.gen.controller;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
@ -27,6 +11,16 @@ import com.ruoyi.gen.domain.GenTable;
import com.ruoyi.gen.domain.GenTableColumn;
import com.ruoyi.gen.service.IGenTableColumnService;
import com.ruoyi.gen.service.IGenTableService;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
@ -65,7 +59,7 @@ public class GenController extends BaseController
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<String, Object>(2);
map.put("info", table);
map.put("rows", list);
map.put("tables", tables);

@ -1,26 +1,5 @@
package com.ruoyi.gen.service;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.constant.Constants;
@ -36,6 +15,28 @@ import com.ruoyi.gen.mapper.GenTableMapper;
import com.ruoyi.gen.util.GenUtils;
import com.ruoyi.gen.util.VelocityInitializer;
import com.ruoyi.gen.util.VelocityUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
*
@ -308,13 +309,14 @@ public class GenTableServiceImpl implements IGenTableService
column.setDictType(prevColumn.getDictType());
column.setQueryType(prevColumn.getQueryType());
}
if (StringUtils.isNotEmpty(prevColumn.getIsRequired()) && !column.isPk()
&& (column.isInsert() || column.isEdit())
&& ((column.isUsableColumn()) || (!column.isSuperColumn())))
{
// 如果是(新增/修改&非主键/非忽略及父属性),继续保留必填/显示类型选项
column.setIsRequired(prevColumn.getIsRequired());
column.setHtmlType(prevColumn.getHtmlType());
if (StringUtils.isNotEmpty(prevColumn.getIsRequired()) && !column.isPk()) {
if (column.isInsert() || column.isEdit()) {
if (column.isUsableColumn() || (!column.isSuperColumn())) {
// 如果是(新增/修改&非主键/非忽略及父属性),继续保留必填/显示类型选项
column.setIsRequired(prevColumn.getIsRequired());
column.setHtmlType(prevColumn.getHtmlType());
}
}
}
genTableColumnMapper.updateGenTableColumn(column);
}

@ -1,25 +1,24 @@
package com.ruoyi.gen.util;
import java.util.Arrays;
import org.apache.commons.lang3.RegExUtils;
import com.ruoyi.common.core.constant.GenConstants;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.gen.config.GenConfig;
import com.ruoyi.gen.domain.GenTable;
import com.ruoyi.gen.domain.GenTableColumn;
import org.apache.commons.lang3.RegExUtils;
import java.util.Arrays;
/**
*
*
*
* @author ruoyi
*/
public class GenUtils
{
public class GenUtils {
/**
*
*/
public static void initTable(GenTable genTable, String operName)
{
public static void initTable(GenTable genTable, String operName) {
genTable.setClassName(convertClassName(genTable.getTableName()));
genTable.setPackageName(GenConfig.getPackageName());
genTable.setModuleName(getModuleName(GenConfig.getPackageName()));
@ -32,8 +31,7 @@ public class GenUtils
/**
*
*/
public static void initColumnField(GenTableColumn column, GenTable table)
{
public static void initColumnField(GenTableColumn column, GenTable table) {
String dataType = getDbType(column.getColumnType());
String columnName = column.getColumnName();
column.setTableId(table.getTableId());
@ -43,113 +41,77 @@ public class GenUtils
// 设置默认类型
column.setJavaType(GenConstants.TYPE_STRING);
column.setQueryType(GenConstants.QUERY_EQ);
if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType))
{
if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType)) {
// 字符串长度超过500设置为文本域
Integer columnLength = getColumnLength(column.getColumnType());
String htmlType = columnLength >= 500 || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType) ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT;
column.setHtmlType(htmlType);
}
else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType))
{
} else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType)) {
column.setJavaType(GenConstants.TYPE_DATE);
column.setHtmlType(GenConstants.HTML_DATETIME);
}
else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType))
{
} else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType)) {
column.setHtmlType(GenConstants.HTML_INPUT);
// 如果是浮点型 统一用BigDecimal
String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), ",");
if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0)
{
if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0) {
column.setJavaType(GenConstants.TYPE_BIGDECIMAL);
}
// 如果是整形
else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10)
{
} else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10) {
column.setJavaType(GenConstants.TYPE_INTEGER);
}
// 长整形
else
{
} else {
column.setJavaType(GenConstants.TYPE_LONG);
}
}
// 插入字段(默认所有字段都需要插入)
column.setIsInsert(GenConstants.REQUIRE);
// 编辑字段
if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName) && !column.isPk())
{
if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName) && !column.isPk()) {
column.setIsEdit(GenConstants.REQUIRE);
}
// 列表字段
if (!arraysContains(GenConstants.COLUMNNAME_NOT_LIST, columnName) && !column.isPk())
{
if (!arraysContains(GenConstants.COLUMNNAME_NOT_LIST, columnName) && !column.isPk()) {
column.setIsList(GenConstants.REQUIRE);
}
// 查询字段
if (!arraysContains(GenConstants.COLUMNNAME_NOT_QUERY, columnName) && !column.isPk())
{
if (!arraysContains(GenConstants.COLUMNNAME_NOT_QUERY, columnName) && !column.isPk()) {
column.setIsQuery(GenConstants.REQUIRE);
}
// 查询字段类型
if (StringUtils.endsWithIgnoreCase(columnName, "name"))
{
if (StringUtils.endsWithIgnoreCase(columnName, "name")) {
column.setQueryType(GenConstants.QUERY_LIKE);
}
// 状态字段设置单选框
if (StringUtils.endsWithIgnoreCase(columnName, "status"))
{
if (StringUtils.endsWithIgnoreCase(columnName, "status")) {
column.setHtmlType(GenConstants.HTML_RADIO);
}
// 类型&性别字段设置下拉框
else if (StringUtils.endsWithIgnoreCase(columnName, "type")
|| StringUtils.endsWithIgnoreCase(columnName, "sex"))
{
} else if (StringUtils.endsWithIgnoreCase(columnName, "type")
|| StringUtils.endsWithIgnoreCase(columnName, "sex")) {
column.setHtmlType(GenConstants.HTML_SELECT);
}
// 图片字段设置图片上传控件
else if (StringUtils.endsWithIgnoreCase(columnName, "image"))
{
} else if (StringUtils.endsWithIgnoreCase(columnName, "image")) {
column.setHtmlType(GenConstants.HTML_IMAGE_UPLOAD);
}
// 文件字段设置文件上传控件
else if (StringUtils.endsWithIgnoreCase(columnName, "file"))
{
} else if (StringUtils.endsWithIgnoreCase(columnName, "file")) {
column.setHtmlType(GenConstants.HTML_FILE_UPLOAD);
}
// 内容字段设置富文本控件
else if (StringUtils.endsWithIgnoreCase(columnName, "content"))
{
} else if (StringUtils.endsWithIgnoreCase(columnName, "content")) {
column.setHtmlType(GenConstants.HTML_EDITOR);
}
}
/**
*
*
* @param arr
*
* @param arr
* @param targetValue
* @return
*/
public static boolean arraysContains(String[] arr, String targetValue)
{
public static boolean arraysContains(String[] arr, String targetValue) {
return Arrays.asList(arr).contains(targetValue);
}
/**
*
*
*
* @param packageName
* @return
*/
public static String getModuleName(String packageName)
{
public static String getModuleName(String packageName) {
int lastIndex = packageName.lastIndexOf(".");
int nameLength = packageName.length();
return StringUtils.substring(packageName, lastIndex + 1, nameLength);
@ -157,12 +119,11 @@ public class GenUtils
/**
*
*
*
* @param tableName
* @return
*/
public static String getBusinessName(String tableName)
{
public static String getBusinessName(String tableName) {
int lastIndex = tableName.lastIndexOf("_");
int nameLength = tableName.length();
return StringUtils.substring(tableName, lastIndex + 1, nameLength);
@ -170,16 +131,14 @@ public class GenUtils
/**
* Java
*
*
* @param tableName
* @return
*/
public static String convertClassName(String tableName)
{
public static String convertClassName(String tableName) {
boolean autoRemovePre = GenConfig.getAutoRemovePre();
String tablePrefix = GenConfig.getTablePrefix();
if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix))
{
if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) {
String[] searchList = StringUtils.split(tablePrefix, ",");
tableName = replaceFirst(tableName, searchList);
}
@ -188,18 +147,15 @@ public class GenUtils
/**
*
*
*
* @param replacementm
* @param searchList
* @param searchList
* @return
*/
public static String replaceFirst(String replacementm, String[] searchList)
{
public static String replaceFirst(String replacementm, String[] searchList) {
String text = replacementm;
for (String searchString : searchList)
{
if (replacementm.startsWith(searchString))
{
for (String searchString : searchList) {
if (replacementm.startsWith(searchString)) {
text = replacementm.replaceFirst(searchString, "");
break;
}
@ -209,48 +165,39 @@ public class GenUtils
/**
*
*
*
* @param text
* @return
*/
public static String replaceText(String text)
{
public static String replaceText(String text) {
return RegExUtils.replaceAll(text, "(?:表|若依)", "");
}
/**
*
*
*
* @param columnType
* @return
*/
public static String getDbType(String columnType)
{
if (StringUtils.indexOf(columnType, "(") > 0)
{
public static String getDbType(String columnType) {
if (StringUtils.indexOf(columnType, "(") > 0) {
return StringUtils.substringBefore(columnType, "(");
}
else
{
} else {
return columnType;
}
}
/**
*
*
*
* @param columnType
* @return
*/
public static Integer getColumnLength(String columnType)
{
if (StringUtils.indexOf(columnType, "(") > 0)
{
public static Integer getColumnLength(String columnType) {
if (StringUtils.indexOf(columnType, "(") > 0) {
String length = StringUtils.substringBetween(columnType, "(", ")");
return Integer.valueOf(length);
}
else
{
} else {
return 0;
}
}

@ -37,7 +37,6 @@ public class ScheduleConfig
prop.put("org.quartz.jobStore.txIsolationLevelSerializable", "true");
// sqlserver 启用
// prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?");
prop.put("org.quartz.jobStore.misfireThreshold", "12000");
prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
factory.setQuartzProperties(prop);

@ -1,9 +1,10 @@
package com.ruoyi.job.service;
import java.util.List;
import org.quartz.SchedulerException;
import com.ruoyi.common.core.exception.job.TaskException;
import com.ruoyi.job.domain.SysJob;
import org.quartz.SchedulerException;
import java.util.List;
/**
*
@ -30,9 +31,9 @@ public interface ISysJobService
/**
*
*
* @param job
* @return
* @throws SchedulerException
*/
public int pauseJob(SysJob job) throws SchedulerException;
@ -41,6 +42,7 @@ public interface ISysJobService
*
* @param job
* @return
* @throws SchedulerException
*/
public int resumeJob(SysJob job) throws SchedulerException;
@ -49,6 +51,7 @@ public interface ISysJobService
*
* @param job
* @return
* @throws SchedulerException
*/
public int deleteJob(SysJob job) throws SchedulerException;
@ -99,4 +102,4 @@ public interface ISysJobService
* @return
*/
public boolean checkCronExpressionIsValid(String cronExpression);
}
}

@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.core.constant.UserConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.Rust;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
@ -131,7 +131,7 @@ public class SysProfileController extends BaseController
if (!file.isEmpty())
{
LoginUser loginUser = SecurityUtils.getLoginUser();
R<SysFile> fileResult = remoteFileService.upload(file);
Rust<SysFile> fileResult = remoteFileService.upload(file);
if (StringUtils.isNull(fileResult) || StringUtils.isNull(fileResult.getData()))
{
return AjaxResult.error("文件服务异常,请联系管理员");

@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.core.constant.UserConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.Rust;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
@ -108,12 +108,12 @@ public class SysUserController extends BaseController
*/
@InnerAuth
@GetMapping("/info/{username}")
public R<LoginUser> info(@PathVariable("username") String username)
public Rust<LoginUser> info(@PathVariable("username") String username)
{
SysUser sysUser = userService.selectUserByUserName(username);
if (StringUtils.isNull(sysUser))
{
return R.fail("用户名或密码错误");
return Rust.fail("用户名或密码错误");
}
// 角色集合
Set<String> roles = permissionService.getRolePermission(sysUser.getUserId());
@ -123,7 +123,7 @@ public class SysUserController extends BaseController
sysUserVo.setSysUser(sysUser);
sysUserVo.setRoles(roles);
sysUserVo.setPermissions(permissions);
return R.ok(sysUserVo);
return Rust.ok(sysUserVo);
}
/**
@ -131,18 +131,18 @@ public class SysUserController extends BaseController
*/
@InnerAuth
@PostMapping("/register")
public R<Boolean> register(@RequestBody SysUser sysUser)
public Rust<Boolean> register(@RequestBody SysUser sysUser)
{
String username = sysUser.getUserName();
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
{
return R.fail("当前系统没有开启注册功能!");
return Rust.fail("当前系统没有开启注册功能!");
}
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(username)))
{
return R.fail("保存用户'" + username + "'失败,注册账号已存在");
return Rust.fail("保存用户'" + username + "'失败,注册账号已存在");
}
return R.ok(userService.registerUser(sysUser));
return Rust.ok(userService.registerUser(sysUser));
}
/**

@ -1,8 +1,9 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.api.domain.SysLogininfor;
import java.util.List;
/**
* 访
*
@ -14,6 +15,7 @@ public interface SysLogininforMapper
*
*
* @param logininfor 访
* @return int
*/
public int insertLogininfor(SysLogininfor logininfor);

@ -1,8 +1,9 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.api.domain.SysOperLog;
import java.util.List;
/**
*
*
@ -14,6 +15,7 @@ public interface SysOperLogMapper
*
*
* @param operLog
* @return int
*/
public int insertOperlog(SysOperLog operLog);

@ -1,8 +1,9 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.api.domain.SysLogininfor;
import java.util.List;
/**
* 访
*
@ -14,6 +15,7 @@ public interface ISysLogininforService
*
*
* @param logininfor 访
* @return int
*/
public int insertLogininfor(SysLogininfor logininfor);

@ -2,6 +2,9 @@ package com.ruoyi.system.service;
import java.util.Set;
/**
* @author pan
*/
public interface ISysPermissionService
{
/**

@ -1,14 +1,18 @@
package com.ruoyi.system.service.impl;
import java.util.HashSet;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.service.ISysMenuService;
import com.ruoyi.system.service.ISysPermissionService;
import com.ruoyi.system.service.ISysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashSet;
import java.util.Set;
/**
* @author pan
*/
@Service
public class SysPermissionServiceImpl implements ISysPermissionService
{

Loading…
Cancel
Save