ReView优化 符合阿里规范

v1.4.1
Parker 4 years ago
parent 747303df4a
commit 32860d0ed4

@ -43,6 +43,9 @@ public final class ValidationUtil {
/** 编码格式 */
private static final String CHARSET_NAME = "utf-8";
/** NULL */
private static final String NULL = "null";
/**
*
* @param obj
@ -112,7 +115,9 @@ public final class ValidationUtil {
break;
// 字母,数字和下划线
case IS_GENERAL:
if(StringUtils.isEmpty(value) || "null".equals(value)) break;
if(StringUtils.isEmpty(value) || NULL.equals(value)) {
break;
}
boolean general = Validator.isGeneral(value);
if(!general){
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_GENERAL;
@ -122,7 +127,9 @@ public final class ValidationUtil {
break;
// 数字
case IS_NUMBER:
if(StringUtils.isEmpty(value) || "null".equals(value)) break;
if(StringUtils.isEmpty(value) || NULL.equals(value)){
break;
}
boolean number = Validator.isNumber(value);
if(!number){
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_NUMBER;
@ -132,7 +139,9 @@ public final class ValidationUtil {
break;
// 纯字母
case IS_LETTER:
if(StringUtils.isEmpty(value) || "null".equals(value)) break;
if(StringUtils.isEmpty(value) || NULL.equals(value)){
break;
}
boolean letter = Validator.isLetter(value);
if(!letter){
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_LETTER;
@ -142,7 +151,9 @@ public final class ValidationUtil {
break;
// 大写
case IS_UPPER_CASE:
if(StringUtils.isEmpty(value) || "null".equals(value)) break;
if(StringUtils.isEmpty(value) || NULL.equals(value)){
break;
}
boolean upperCase = Validator.isUpperCase(value);
if(!upperCase){
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_UPPER_CASE;
@ -152,7 +163,9 @@ public final class ValidationUtil {
break;
// 小写
case IS_LOWER_CASE:
if(StringUtils.isEmpty(value) || "null".equals(value)) break;
if(StringUtils.isEmpty(value) || NULL.equals(value)){
break;
}
boolean lowerCase = Validator.isLowerCase(value);
if(!lowerCase){
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_LOWER_CASE;
@ -162,7 +175,9 @@ public final class ValidationUtil {
break;
// IPV4
case IS_IPV4:
if(StringUtils.isEmpty(value) || "null".equals(value)) break;
if(StringUtils.isEmpty(value) || NULL.equals(value)){
break;
}
boolean ipv4 = Validator.isIpv4(value);
if(!ipv4){
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_IPV4;
@ -172,7 +187,9 @@ public final class ValidationUtil {
break;
// 金额
case IS_MONEY:
if(StringUtils.isEmpty(value) || "null".equals(value)) break;
if(StringUtils.isEmpty(value) || NULL.equals(value)){
break;
}
boolean money = Validator.isMoney(value);
if(!money){
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_MONEY;
@ -182,7 +199,9 @@ public final class ValidationUtil {
break;
// 邮箱
case IS_EMAIL:
if(StringUtils.isEmpty(value) || "null".equals(value)) break;
if(StringUtils.isEmpty(value) || NULL.equals(value)){
break;
}
boolean email = Validator.isEmail(value);
if(!email){
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_EMAIL;
@ -192,7 +211,9 @@ public final class ValidationUtil {
break;
// 手机号
case IS_MOBILE:
if(StringUtils.isEmpty(value) || "null".equals(value)) break;
if(StringUtils.isEmpty(value) || NULL.equals(value)){
break;
}
boolean mobile = Validator.isMobile(value);
if(!mobile){
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_MOBILE;
@ -202,7 +223,9 @@ public final class ValidationUtil {
break;
// 18位身份证
case IS_CITIZENID:
if(StringUtils.isEmpty(value) || "null".equals(value)) break;
if(StringUtils.isEmpty(value) || NULL.equals(value)){
break;
}
boolean citizenId = Validator.isCitizenId(value);
if(!citizenId){
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_CITIZENID;
@ -212,7 +235,9 @@ public final class ValidationUtil {
break;
// 邮编
case IS_ZIPCODE:
if(StringUtils.isEmpty(value) || "null".equals(value)) break;
if(StringUtils.isEmpty(value) || NULL.equals(value)){
break;
}
boolean zipCode = Validator.isZipCode(value);
if(!zipCode){
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_ZIPCODE;
@ -222,7 +247,9 @@ public final class ValidationUtil {
break;
// URL
case IS_URL:
if(StringUtils.isEmpty(value) || "null".equals(value)) break;
if(StringUtils.isEmpty(value) || NULL.equals(value)){
break;
}
boolean url = Validator.isUrl(value);
if(!url){
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_URL;
@ -232,7 +259,9 @@ public final class ValidationUtil {
break;
// 汉字
case IS_CHINESE:
if(StringUtils.isEmpty(value) || "null".equals(value)) break;
if(StringUtils.isEmpty(value) || NULL.equals(value)){
break;
}
boolean chinese = Validator.isChinese(value);
if(!chinese){
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_CHINESE;
@ -242,7 +271,9 @@ public final class ValidationUtil {
break;
// 汉字,字母,数字和下划线
case IS_GENERAL_WITH_CHINESE:
if(StringUtils.isEmpty(value) || "null".equals(value)) break;
if(StringUtils.isEmpty(value) || NULL.equals(value)){
break;
}
boolean generalWithChinese = Validator.isGeneralWithChinese(value);
if(!generalWithChinese){
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_GENERAL_WITH_CHINESE;
@ -252,7 +283,9 @@ public final class ValidationUtil {
break;
// MAC地址
case IS_MAC:
if(StringUtils.isEmpty(value) || "null".equals(value)) break;
if(StringUtils.isEmpty(value) || NULL.equals(value)){
break;
}
boolean mac = Validator.isMac(value);
if(!mac){
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_MAC;
@ -262,7 +295,9 @@ public final class ValidationUtil {
break;
// 中国车牌
case IS_PLATE_NUMBER:
if(StringUtils.isEmpty(value) || "null".equals(value)) break;
if(StringUtils.isEmpty(value) || NULL.equals(value)){
break;
}
boolean plateNumber = Validator.isPlateNumber(value);
if(!plateNumber){
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_PLATE_NUMBER;
@ -299,7 +334,7 @@ public final class ValidationUtil {
// 循环验证
try {
String value = String.valueOf(fieldValue);
if(value != null && !"null".equals(value)){
if(value != null && !NULL.equals(value)){
// 转换为 数据库真实 长度
int strLength = value.getBytes(CHARSET_NAME).length;
if(strLength > maxLength){
@ -332,7 +367,7 @@ public final class ValidationUtil {
// 循环验证
try {
String value = String.valueOf(fieldValue);
if(value != null && !"null".equals(value)){
if(value != null && !NULL.equals(value)){
// 转换为 数据库真实 长度
int strLength = value.getBytes(CHARSET_NAME).length;
if(strLength < minLength){

@ -25,21 +25,21 @@ package org.opsli.common.api;
public class TokenThreadLocal {
/** 临时线程存储 token 容器 */
private static final ThreadLocal<String> tokenData = new ThreadLocal<>();
private static final ThreadLocal<String> TOKEN_DATA = new ThreadLocal<>();
public static void put(String token) {
if (tokenData.get() == null) {
tokenData.set(token);
if (TOKEN_DATA.get() == null) {
TOKEN_DATA.set(token);
}
}
public static String get() {
return tokenData.get();
return TOKEN_DATA.get();
}
public static void remove() {
try {
tokenData.remove();
TOKEN_DATA.remove();
}catch (Exception e){}
}
}

@ -27,14 +27,12 @@ import org.opsli.common.utils.Props;
*/
public final class MyBatisConstants {
private static final Props prop = new Props("application.yaml");
/** 逻辑删除值 */
public static final char LOGIC_DELETE_VALUE =
prop.getChar("mybatis-plus.global-config.db-config.logic-delete-value",'1');
public static final char LOGIC_DELETE_VALUE;
/** 逻辑不删除值 */
public static final char LOGIC_NOT_DELETE_VALUE =
prop.getChar("mybatis-plus.global-config.db-config.logic-not-delete-value",'0');
public static final char LOGIC_NOT_DELETE_VALUE;
/** ID */
public static final String FIELD_ID = "id";
@ -55,5 +53,12 @@ public final class MyBatisConstants {
/** 多租户字段 */
public static final String FIELD_TENANT = "tenantId";
static {
Props props = new Props("application.yaml");
LOGIC_DELETE_VALUE = props.getChar("mybatis-plus.global-config.db-config.logic-delete-value",'1');
LOGIC_NOT_DELETE_VALUE = props.getChar("mybatis-plus.global-config.db-config.logic-not-delete-value",'0');
}
private MyBatisConstants(){}
}

@ -50,10 +50,12 @@ public class NameableThreadFactory implements ThreadFactory{
Thread t = new Thread(threadGroup, r,
namePrefix + threadNumber.getAndIncrement(),
0);
if (t.isDaemon())
if (t.isDaemon()){
t.setDaemon(false);
if (t.getPriority() != Thread.NORM_PRIORITY)
}
if (t.getPriority() != Thread.NORM_PRIORITY){
t.setPriority(Thread.NORM_PRIORITY);
}
return t;
}
}

@ -32,8 +32,8 @@ public class BigDecimalUtil {
* @return
*/
public static double add(double value1,double value2){
BigDecimal b1 = new BigDecimal(Double.toString(value1));
BigDecimal b2 = new BigDecimal(Double.toString(value2));
BigDecimal b1 = BigDecimal.valueOf(value1);
BigDecimal b2 = BigDecimal.valueOf(value2);
return b1.add(b2).doubleValue();
}
@ -44,8 +44,8 @@ public class BigDecimalUtil {
* @return
*/
public static double sub(double value1,double value2){
BigDecimal b1 = new BigDecimal(Double.toString(value1));
BigDecimal b2 = new BigDecimal(Double.toString(value2));
BigDecimal b1 = BigDecimal.valueOf(value1);
BigDecimal b2 = BigDecimal.valueOf(value2);
return b1.subtract(b2).doubleValue();
}
@ -56,8 +56,8 @@ public class BigDecimalUtil {
* @return
*/
public static double mul(double value1,double value2){
BigDecimal b1 = new BigDecimal(Double.toString(value1));
BigDecimal b2 = new BigDecimal(Double.toString(value2));
BigDecimal b1 = BigDecimal.valueOf(value1);
BigDecimal b2 = BigDecimal.valueOf(value2);
return b1.multiply(b2).doubleValue();
}
@ -83,8 +83,8 @@ public class BigDecimalUtil {
if(scale<0){
throw new IllegalAccessException("精确度不能小于0");
}
BigDecimal b1 = new BigDecimal(Double.toString(value1));
BigDecimal b2 = new BigDecimal(Double.toString(value2));
BigDecimal b1 = BigDecimal.valueOf(value1);
BigDecimal b2 = BigDecimal.valueOf(value2);
return b1.divide(b2, scale, model).doubleValue();
}
public static double div(double value1,double value2,int scale) throws IllegalAccessException{
@ -92,8 +92,8 @@ public class BigDecimalUtil {
if(scale<0){
throw new IllegalAccessException("精确度不能小于0");
}
BigDecimal b1 = new BigDecimal(Double.toString(value1));
BigDecimal b2 = new BigDecimal(Double.toString(value2));
BigDecimal b1 = BigDecimal.valueOf(value1);
BigDecimal b2 = BigDecimal.valueOf(value2);
return b1.divide(b2, scale,4).doubleValue();
}
}

@ -39,7 +39,7 @@ public final class HumpUtil {
public static String underlineToHump(String para) {
StringBuilder result = new StringBuilder();
String a[] = para.split(UNDERLINE);
String[] a = para.split(UNDERLINE);
for (String s : a) {
if (!para.contains(UNDERLINE)) {
result.append(s);

@ -26,6 +26,8 @@ import javax.servlet.http.HttpServletRequest;
*/
public final class IPUtil {
private static final String UNKNOWN = "unknown";
/**
* ip(穿)
*
@ -34,19 +36,19 @@ public final class IPUtil {
*/
public static String getRemoteAddr(HttpServletRequest request) {
String ip = request.getHeader("X-Forwarded-For");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
return ip;
@ -73,7 +75,7 @@ public final class IPUtil {
public static String getClientIpAddress(HttpServletRequest request) {
for (String header : HEADERS_TO_TRY) {
String ip = request.getHeader(header);
if (ip != null && ip.length() != 0 && !"unknown".equalsIgnoreCase(ip)) {
if (ip != null && ip.length() != 0 && !UNKNOWN.equalsIgnoreCase(ip)) {
return ip;
}
}
@ -86,37 +88,37 @@ public final class IPUtil {
*/
public static String getClientIpAddr(HttpServletRequest request) {
String ip = request.getHeader("X-Forwarded-For");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_CLUSTER_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_FORWARDED");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_VIA");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getHeader("REMOTE_ADDR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
return ip;
@ -124,12 +126,12 @@ public final class IPUtil {
public static String getIpAddr(HttpServletRequest request) {
String ip = request.getHeader("X-Real-IP");
if (null != ip && !"".equals(ip.trim())
&& !"unknown".equalsIgnoreCase(ip)) {
&& !UNKNOWN.equalsIgnoreCase(ip)) {
return ip;
}
ip = request.getHeader("X-Forwarded-For");
if (null != ip && !"".equals(ip.trim())
&& !"unknown".equalsIgnoreCase(ip)) {
&& !UNKNOWN.equalsIgnoreCase(ip)) {
// get first ip from proxy ip
int index = ip.indexOf(',');
if (index != -1) {
@ -143,5 +145,6 @@ public final class IPUtil {
// ===============
private IPUtil(){}
}

@ -190,7 +190,9 @@ public class CacheDataAop {
try {
// 获得方法
Method objMethod = this.getMethod(point);
if(objMethod == null) return null;
if(objMethod == null) {
return null;
}
// 获取注解参数
HotDataPut aCache= objMethod.getAnnotation(HotDataPut.class);
@ -239,7 +241,9 @@ public class CacheDataAop {
try {
// 获得方法
Method objMethod = this.getMethod(point);
if(objMethod == null) return null;
if(objMethod == null) {
return null;
}
// 获取注解参数
HotDataDel aCache= objMethod.getAnnotation(HotDataDel.class);

@ -45,6 +45,8 @@ import static org.opsli.common.constants.OrderConstants.PARAM_VALIDATE_AOP_SORT;
@Component
public class ValitaionArgsAop {
/** post请求 */
private static final String POST_TYPE = "POST";
@Pointcut("execution(public * org.opsli.modulars*..*.*Controller*.*(..))")
public void requestMapping() {
@ -60,12 +62,14 @@ public class ValitaionArgsAop {
try {
RequestAttributes ra = RequestContextHolder.getRequestAttributes();
ServletRequestAttributes sra = (ServletRequestAttributes) ra;
if(sra == null) return;
if(sra == null){
return;
}
HttpServletRequest request = sra.getRequest();
String method = request.getMethod();
// 只有 post 请求 才会去验证数据
if("POST".equals(method)){
if(POST_TYPE.equals(method)){
for (Object arg : args) {
// 参数校验
if(arg instanceof ApiWrapper){

@ -79,11 +79,11 @@ public abstract class BaseRestController <T extends BaseEntity, E extends ApiWra
/** Entity Clazz 类 */
protected Class<T> entityClazz;
/** Entity 泛型游标 */
private static final int entityIndex = 0;
private static final int ENTITY_INDEX = 0;
/** Model Clazz 类 */
protected Class<E> modelClazz;
/** Model 泛型游标 */
private static final int modelIndex = 1;
private static final int MODEL_INDEX = 1;
@Autowired(required = false)
protected S IService;
@ -326,7 +326,7 @@ public abstract class BaseRestController <T extends BaseEntity, E extends ApiWra
*/
private Class<E> getModelClass(){
Class<E> tClass = null;
Type typeArgument = TypeUtil.getTypeArgument(getClass().getGenericSuperclass(), modelIndex);
Type typeArgument = TypeUtil.getTypeArgument(getClass().getGenericSuperclass(), MODEL_INDEX);
if(typeArgument != null){
tClass = (Class<E>) typeArgument;
}
@ -339,7 +339,7 @@ public abstract class BaseRestController <T extends BaseEntity, E extends ApiWra
*/
private Class<T> getEntityClass(){
Class<T> tClass = null;
Type typeArgument = TypeUtil.getTypeArgument(getClass().getGenericSuperclass(), entityIndex);
Type typeArgument = TypeUtil.getTypeArgument(getClass().getGenericSuperclass(), ENTITY_INDEX);
if(typeArgument != null){
tClass = (Class<T>) typeArgument;
}

@ -66,11 +66,11 @@ public abstract class CrudServiceImpl<M extends BaseMapper<T>, T extends BaseEnt
/** Entity Clazz 类 */
protected Class<T> entityClazz;
/** Entity 泛型游标 */
private static final int entityIndex = 1;
private static final int ENTITY_INDEX = 1;
/** Model Clazz 类 */
protected Class<E> modelClazz;
/** Model 泛型游标 */
private static final int modelIndex = 2;
private static final int MODEL_INDEX = 2;
@Override
public E get(String id) {
@ -81,7 +81,9 @@ public abstract class CrudServiceImpl<M extends BaseMapper<T>, T extends BaseEnt
@Override
public E get(E model) {
if(model == null) return null;
if(model == null){
return null;
}
return transformT2M(
super.getById(model.getId())
);
@ -90,7 +92,9 @@ public abstract class CrudServiceImpl<M extends BaseMapper<T>, T extends BaseEnt
@Override
@Transactional(readOnly = false)
public E insert(E model) {
if(model == null) return null;
if(model == null){
return null;
}
// 默认清空 创建人和修改人
if(model.getIzManual() != null && !model.getIzManual()){
@ -111,7 +115,9 @@ public abstract class CrudServiceImpl<M extends BaseMapper<T>, T extends BaseEnt
@Override
@Transactional(readOnly = false)
public boolean insertBatch(List<E> models) {
if(models == null || models.size() == 0) return false;
if(models == null || models.size() == 0){
return false;
}
for (E model : models) {
// 默认清空 创建人和修改人
@ -131,7 +137,9 @@ public abstract class CrudServiceImpl<M extends BaseMapper<T>, T extends BaseEnt
@Override
@Transactional(readOnly = false)
public E update(E model) {
if(model == null) return null;
if(model == null){
return null;
}
// 默认清空 创建人和修改人
if(model.getIzManual() != null && !model.getIzManual()){
@ -150,7 +158,9 @@ public abstract class CrudServiceImpl<M extends BaseMapper<T>, T extends BaseEnt
@Override
@Transactional(readOnly = false)
public E save(E model) {
if(model == null) return null;
if(model == null){
return null;
}
// 修改
if(StringUtils.isNotBlank(model.getId())){
@ -171,14 +181,18 @@ public abstract class CrudServiceImpl<M extends BaseMapper<T>, T extends BaseEnt
@Override
@Transactional(readOnly = false)
public boolean delete(E model) {
if(model == null) return false;
if(model == null){
return false;
}
return super.removeById(model.getId());
}
@Override
@Transactional(readOnly = false)
public boolean deleteAll(String[] ids) {
if(ids == null) return false;
if(ids == null){
return false;
}
List<String> idList = Convert.toList(String.class, ids);
return super.removeByIds(idList);
}
@ -186,7 +200,9 @@ public abstract class CrudServiceImpl<M extends BaseMapper<T>, T extends BaseEnt
@Override
@Transactional(readOnly = false)
public boolean deleteAll(Collection<E> models) {
if(models == null || models.isEmpty()) return false;
if(models == null || models.isEmpty()){
return false;
}
List<String> idList = Lists.newArrayListWithCapacity(models.size());
for (E entity : models) {
idList.add(entity.getId());
@ -287,7 +303,7 @@ public abstract class CrudServiceImpl<M extends BaseMapper<T>, T extends BaseEnt
*/
private Class<E> getModelClazz(){
Class<E> tClass = null;
Type typeArgument = TypeUtil.getTypeArgument(getClass().getGenericSuperclass(), modelIndex);
Type typeArgument = TypeUtil.getTypeArgument(getClass().getGenericSuperclass(), MODEL_INDEX);
if(typeArgument != null){
tClass = (Class<E>) typeArgument;
}
@ -300,7 +316,7 @@ public abstract class CrudServiceImpl<M extends BaseMapper<T>, T extends BaseEnt
*/
private Class<T> getEntityClazz(){
Class<T> tClass = null;
Type typeArgument = TypeUtil.getTypeArgument(getClass().getGenericSuperclass(), entityIndex);
Type typeArgument = TypeUtil.getTypeArgument(getClass().getGenericSuperclass(), ENTITY_INDEX);
if(typeArgument != null){
tClass = (Class<T>) typeArgument;
}

@ -57,14 +57,18 @@ public class DictHandler implements RedisPushSubHandler{
Collection<Object> dicts = (Collection<Object>) msgJson.get(MsgArgsType.DICT_MODELS.toString());
for (Object dictObj : dicts) {
JSONObject jsonObject = msgJson.getJSONObject(MsgArgsType.DICT_MODEL.toString());
if(jsonObject == null) continue;
if(jsonObject == null){
continue;
}
DictWrapper dictWrapperModel = jsonObject.toJavaObject(DictWrapper.class);
this.handler(dictWrapperModel, type);
}
} else if(DictModelType.OBJECT == dictModelType){
JSONObject jsonObject = msgJson.getJSONObject(MsgArgsType.DICT_MODEL.toString());
if(jsonObject == null) return;
if(jsonObject == null){
return;
}
DictWrapper dictWrapperModel = jsonObject.toJavaObject(DictWrapper.class);
this.handler(dictWrapperModel, type);

@ -57,7 +57,9 @@ public class MenuHandler implements RedisPushSubHandler{
private void menuHandler(JSONObject msgJson){
JSONObject data = msgJson.getJSONObject(MsgArgsType.MENU_MODEL_DATA.toString());
// 数据为空则不执行
if(data == null) return;
if(data == null){
return;
}
// 获得菜单编号
String menuCode = (String) msgJson.get(MsgArgsType.MENU_CODE.toString());

@ -58,7 +58,9 @@ public class OrgHandler implements RedisPushSubHandler{
private void orgHandler(JSONObject msgJson){
JSONObject data = msgJson.getJSONObject(MsgArgsType.ORG_USER_DATA.toString());
// 数据为空则不执行
if(data == null) return;
if(data == null){
return;
}
// 获得用户ID
String userId = (String) msgJson.get(MsgArgsType.ORG_USER_ID.toString());

@ -77,7 +77,9 @@ public class UserHandler implements RedisPushSubHandler{
private void userHandler(JSONObject msgJson){
JSONObject data = msgJson.getJSONObject(MsgArgsType.USER_MODEL_DATA.toString());
// 数据为空则不执行
if(data == null) return;
if(data == null){
return;
}
// 获得用户ID 和 用户名
String userId = (String) msgJson.get(MsgArgsType.USER_ID.toString());
@ -101,7 +103,9 @@ public class UserHandler implements RedisPushSubHandler{
private void userRolesHandler(JSONObject msgJson){
JSONArray dataArray = msgJson.getJSONArray(MsgArgsType.USER_MODEL_DATA.toString());
// 数据为空则不执行
if(dataArray == null || dataArray.isEmpty()) return;
if(dataArray == null || dataArray.isEmpty()){
return;
}
// 获得用户ID
String userId = (String) msgJson.get(MsgArgsType.USER_ID.toString());
@ -122,7 +126,9 @@ public class UserHandler implements RedisPushSubHandler{
private void userPermsHandler(JSONObject msgJson){
JSONArray dataArray = msgJson.getJSONArray(MsgArgsType.USER_MODEL_DATA.toString());
// 数据为空则不执行
if(dataArray == null || dataArray.isEmpty()) return;
if(dataArray == null || dataArray.isEmpty()){
return;
}
// 获得用户ID
String userId = (String) msgJson.get(MsgArgsType.USER_ID.toString());
@ -143,7 +149,9 @@ public class UserHandler implements RedisPushSubHandler{
private void userMenusHandler(JSONObject msgJson){
JSONArray dataArray = msgJson.getJSONArray(MsgArgsType.USER_MODEL_DATA.toString());
// 数据为空则不执行
if(dataArray == null || dataArray.isEmpty()) return;
if(dataArray == null || dataArray.isEmpty()){
return;
}
// 获得用户ID
String userId = (String) msgJson.get(MsgArgsType.USER_ID.toString());

@ -16,6 +16,7 @@
package org.opsli.core.conf;
import cn.hutool.core.collection.CollUtil;
import com.google.common.collect.Maps;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.session.mgt.SessionManager;
import org.apache.shiro.spring.LifecycleBeanPostProcessor;
@ -71,11 +72,11 @@ public class ShiroConfig {
shiroFilter.setSecurityManager(securityManager);
//oauth过滤
Map<String, Filter> filters = new HashMap<>();
Map<String, Filter> filters = Maps.newHashMapWithExpectedSize(1);
filters.put("oauth2", new OAuth2Filter());
shiroFilter.setFilters(filters);
Map<String, String> filterMap = new LinkedHashMap<>();
Map<String, String> filterMap = Maps.newLinkedHashMap();
filterMap.put("/webjars/**", "anon");
filterMap.put("/druid/**", "anon");
filterMap.put("/app/**", "anon");

@ -51,6 +51,8 @@ import java.util.*;
@Intercepts(@Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class}))
public class AutoFillInterceptor implements Interceptor {
private static final String ET = "et";
@Override
public Object intercept(Invocation invocation) throws IllegalAccessException, InvocationTargetException {
fillField(invocation);
@ -69,11 +71,12 @@ public class AutoFillInterceptor implements Interceptor {
//String className = arg.getClass().getName();
//log.info(i + " 参数类型:" + className);
//第一个参数处理。根据它判断是否给“操作属性”赋值。
if (arg instanceof MappedStatement) {//如果是第一个参数 MappedStatement
//如果是第一个参数 MappedStatement
if (arg instanceof MappedStatement) {
MappedStatement ms = (MappedStatement) arg;
sqlCommandType = ms.getSqlCommandType();
//log.info("操作类型:" + sqlCommandType);
if (sqlCommandType == SqlCommandType.INSERT || sqlCommandType == SqlCommandType.UPDATE) {//如果是“增加”或“更新”操作,则继续进行默认操作信息赋值。否则,则退出
//如果是“增加”或“更新”操作,则继续进行默认操作信息赋值。否则,则退出
if (sqlCommandType == SqlCommandType.INSERT || sqlCommandType == SqlCommandType.UPDATE) {
continue;
} else {
break;
@ -96,7 +99,9 @@ public class AutoFillInterceptor implements Interceptor {
* @param arg
*/
public void insertFill(Object arg) {
if(arg == null ) return;
if(arg == null ){
return;
}
Field[] fields = ReflectUtil.getFields(arg.getClass());
for (Field f : fields) {
@ -162,14 +167,16 @@ public class AutoFillInterceptor implements Interceptor {
* @param arg
*/
public void updateFill(Object arg) {
if(arg == null ) return;
if(arg == null ){
return;
}
// 2020-09-19
// 修改这儿 有可能会拿到一个 MapperMethod需要特殊处理
Field[] fields;
if (arg instanceof MapperMethod.ParamMap) {
MapperMethod.ParamMap<?> paramMap = (MapperMethod.ParamMap<?>) arg;
if (paramMap.containsKey("et")) {
if (paramMap.containsKey(ET)) {
arg = paramMap.get("et");
} else {
arg = paramMap.get("param1");

@ -43,6 +43,8 @@ import static org.opsli.common.constants.OrderConstants.EXCEPTION_HANDLER_ORDER;
@Order(EXCEPTION_HANDLER_ORDER)
public class GlobalExceptionHandler {
private static final String SQL_EXCEPTION = "doesn't have a default value";
/*
ArithmeticException
NullPointerException
@ -197,7 +199,7 @@ public class GlobalExceptionHandler {
public ResultVo<?> sqlException(SQLException e) {
//log.error("数据异常:{}",e.getMessage(),e);
// 默认值异常
if(StringUtils.contains(e.getMessage(),"doesn't have a default value")){
if(StringUtils.contains(e.getMessage(),SQL_EXCEPTION)){
String Field = e.getMessage().replaceAll("Field '","")
.replaceAll("' doesn't have a default value","");
String msg = StrFormatter.format(CoreMsg.SQL_EXCEPTION_NOT_HAVE_DEFAULT_VALUE.getMessage(), Field);

@ -26,6 +26,7 @@ import org.opsli.common.base.msg.BaseMsg;
*/
public enum JwtMsg implements BaseMsg {
/** 异常消息 */
EXCEPTION_TOKEN(11000,"认证解密异常: {}"),
EXCEPTION_DECODE(10101,"解密异常: {}"),
EXCEPTION_ENCODE(10102,"加密异常: {}"),

@ -113,7 +113,7 @@ public class Page<T extends BaseEntity,E extends ApiWrapper> extends PageSeriali
* @return map
*/
public Map<String, Object> getBootstrapData(){
Map<String, Object> map = new HashMap<>();
Map<String, Object> map = new HashMap<>(2);
map.put("rows", this.getList());
map.put("total", this.getTotal());
return map;

@ -25,6 +25,9 @@ import java.util.List;
@Component
public class OAuth2Realm extends AuthorizingRealm {
/** 账号锁定状态 */
private static final char LOCK_VAL = '1';
@Override
public boolean supports(AuthenticationToken token) {
return token instanceof OAuth2Token;
@ -73,7 +76,7 @@ public class OAuth2Realm extends AuthorizingRealm {
UserModel user = UserUtil.getUser(userId);
// 3. 校验账户是否锁定
if(user == null || user.getLocked().equals('1')){
if(user == null || user.getLocked().equals(LOCK_VAL)){
// 账号已被锁定,请联系管理员
// token失效请重新登录
throw new TokenException(

@ -24,7 +24,7 @@ import org.opsli.api.wrapper.system.user.UserModel;
/**
* Shiro
*
*
* @author
* @date 20161112 9:49:19
@ -32,12 +32,12 @@ import org.opsli.api.wrapper.system.user.UserModel;
public class ShiroUtils {
/** 加密算法 */
public final static String hashAlgorithmName = "MD5";
public final static String HASH_ALGORITHM_NAME = "MD5";
/** 循环次数 */
public final static int hashIterations = 1;
public final static int HASH_ITERATIONS = 1;
public static String sha256(String password, String salt) {
return new SimpleHash(hashAlgorithmName, password, salt, hashIterations).toString();
return new SimpleHash(HASH_ALGORITHM_NAME, password, salt, HASH_ITERATIONS).toString();
}
public static Session getSession() {
@ -55,7 +55,7 @@ public class ShiroUtils {
public static String getUserId() {
return getUser().getId();
}
public static void setSessionAttribute(Object key, Object value) {
getSession().setAttribute(key, value);
}
@ -71,7 +71,7 @@ public class ShiroUtils {
public static void logout() {
SecurityUtils.getSubject().logout();
}
public static String getKaptcha(String key) throws RuntimeException {
Object kaptcha = getSessionAttribute(key);
if(kaptcha == null){

@ -90,7 +90,9 @@ public class CaptchaUtil{
* @return
*/
public static boolean validate(String uuid, String code) {
if(StringUtils.isEmpty(uuid)) return false;
if(StringUtils.isEmpty(uuid)){
return false;
}
// 验证码
String codeTemp = (String) redisPlugin.get(PREFIX_NAME + PREFIX + uuid);
@ -112,7 +114,9 @@ public class CaptchaUtil{
* @return
*/
public static boolean delCaptcha(String uuid) {
if(StringUtils.isEmpty(uuid)) return false;
if(StringUtils.isEmpty(uuid)){
return false;
}
//删除验证码
return redisPlugin.del(PREFIX_NAME + PREFIX + uuid);

@ -81,7 +81,9 @@ public class DictUtil {
if (cacheModel != null){
dictName = cacheModel.getDictName();
}
if (StringUtils.isNotEmpty(dictName)) return dictName;
if (StringUtils.isNotEmpty(dictName)){
return dictName;
}
// 防止缓存穿透判断
@ -112,7 +114,9 @@ public class DictUtil {
if (cacheModel != null){
dictName = cacheModel.getDictName();
}
if (StringUtils.isNotEmpty(dictName)) return dictName;
if (StringUtils.isNotEmpty(dictName)){
return dictName;
}
// 查询数据库 并保存到缓存内
ResultVo<List<DictDetailModel>> resultVo = dictDetailApi.findListByTypeCode(typeCode);
@ -168,7 +172,9 @@ public class DictUtil {
if (cacheModel != null){
dictValue = cacheModel.getDictValue();
}
if (StringUtils.isNotEmpty(dictValue)) return dictValue;
if (StringUtils.isNotEmpty(dictValue)){
return dictValue;
}
// 防止缓存穿透判断
boolean hasNilFlag = CacheUtil.hasNilFlag(DictConstants.CACHE_PREFIX_NAME + typeCode + ":" + dictName);
@ -196,7 +202,9 @@ public class DictUtil {
if (cacheModel != null){
dictValue = cacheModel.getDictValue();
}
if (StringUtils.isNotEmpty(dictValue)) return dictValue;
if (StringUtils.isNotEmpty(dictValue)){
return dictValue;
}
// 查询数据库 并保存到缓存内
ResultVo<List<DictDetailModel>> resultVo = dictDetailApi.findListByTypeCode(typeCode);

@ -177,7 +177,9 @@ public class ExcelUtil extends ExcelPlugin {
String typeCode = entry.getValue();
List<DictWrapper> dictWrapperList = DictUtil.getDictList(typeCode);
// 如果字典 List 为空 则走下一个
if(dictWrapperList == null || dictWrapperList.size() == 0) continue;
if(dictWrapperList == null || dictWrapperList.size() == 0){
continue;
}
typeCodeAndValue.put(typeCode, dictWrapperList);
}
return typeCodeAndValue;

@ -32,7 +32,7 @@ public final class JwtUtil {
/**
* JWT(Base64)
*/
private static final String encryptJWTKey="a30ade6452725123436288ccae58570738ee";
private static final String ENCRYPT_JWT_KEY = "a30ade6452725123436288ccae58570738ee";
static {
Props props = new Props("application.yaml");
@ -48,7 +48,7 @@ public final class JwtUtil {
*/
public static boolean verify(String token) {
try {
String secret = getClaim(token, SignConstants.ACCOUNT) + Base64ConvertUtil.decode(encryptJWTKey);
String secret = getClaim(token, SignConstants.ACCOUNT) + Base64ConvertUtil.decode(ENCRYPT_JWT_KEY);
Algorithm algorithm = Algorithm.HMAC256(secret);
JWTVerifier verifier = JWT.require(algorithm).build();
verifier.verify(token);
@ -85,7 +85,7 @@ public final class JwtUtil {
public static String sign(String account, String userId) {
try {
// 帐号加JWT私钥加密
String secret = account + Base64ConvertUtil.decode(encryptJWTKey);
String secret = account + Base64ConvertUtil.decode(ENCRYPT_JWT_KEY);
// 此处过期时间是以毫秒为单位所以乘以1000
Date date = new Date(System.currentTimeMillis() + EXPIRE);
Algorithm algorithm = Algorithm.HMAC256(secret);
@ -114,5 +114,6 @@ public final class JwtUtil {
}
// ==================
private JwtUtil(){}
}

@ -61,7 +61,9 @@ public final class LogUtil {
RequestAttributes ra = RequestContextHolder.getRequestAttributes();
ServletRequestAttributes sra = (ServletRequestAttributes) ra;
if(sra == null) return;
if(sra == null){
return;
}
HttpServletRequest request = sra.getRequest();
// EnableLog 如果不被 EnableLog修饰 则直接退出

@ -35,7 +35,7 @@ public final class TokenGenerator {
return generateValue(UUID.randomUUID().toString());
}
private static final char[] hexCode = "0123456789abcdef".toCharArray();
private static final char[] HEX_CODE = "0123456789abcdef".toCharArray();
/**
@ -64,13 +64,14 @@ public final class TokenGenerator {
}
StringBuilder r = new StringBuilder(data.length*2);
for ( byte b : data) {
r.append(hexCode[(b >> 4) & 0xF]);
r.append(hexCode[(b & 0xF)]);
r.append(HEX_CODE[(b >> 4) & 0xF]);
r.append(HEX_CODE[(b & 0xF)]);
}
return r.toString();
}
// =========================
private TokenGenerator(){}
}

@ -153,7 +153,9 @@ public class UserTokenUtil {
* @return
*/
public static String getUserIdByToken(String token) {
if(StringUtils.isEmpty(token)) return null;
if(StringUtils.isEmpty(token)){
return null;
}
String userId = "";
try {
userId = JwtUtil.getClaim(token, SignConstants.USER_ID);
@ -167,7 +169,9 @@ public class UserTokenUtil {
* @return
*/
public static String getUserNameByToken(String token) {
if(StringUtils.isEmpty(token)) return null;
if(StringUtils.isEmpty(token)){
return null;
}
String username = "";
try {
username = JwtUtil.getClaim(token, SignConstants.ACCOUNT);
@ -182,7 +186,9 @@ public class UserTokenUtil {
* @param token
*/
public static void logout(String token) {
if(StringUtils.isEmpty(token)) return;
if(StringUtils.isEmpty(token)){
return;
}
try {
// 生成MD5 16进制码 用于缩减存储
String signTokenHex = new Md5Hash(token).toHex();
@ -207,7 +213,9 @@ public class UserTokenUtil {
* @param token
*/
public static boolean verify(String token) {
if(StringUtils.isEmpty(token)) return false;
if(StringUtils.isEmpty(token)){
return false;
}
try {
// 1. 校验是否是有效的 token

@ -27,6 +27,34 @@ import java.util.regex.Pattern;
* */
public final class XSSFilterKit {
private static final Pattern SCRIPT_ALL_PATTERN;
private static final Pattern SCRIPT_INNER_PATTERN;
private static final Pattern SCRIPT_PATTERN;
private static final Pattern EVAL_PATTERN;
private static final Pattern EXPRESSION_PATTERN;
private static final Pattern JAVASCRIPT_PATTERN;
private static final Pattern VBSCRIPT_PATTERN;
private static final Pattern ONLOAD_PATTERN;
static {
SCRIPT_ALL_PATTERN = Pattern.compile("<script>(.*?)</script>", Pattern.CASE_INSENSITIVE);
SCRIPT_INNER_PATTERN = Pattern.compile("<script(.*?)>", Pattern.CASE_INSENSITIVE
| Pattern.MULTILINE | Pattern.DOTALL);
SCRIPT_PATTERN = Pattern.compile("</script>", Pattern.CASE_INSENSITIVE);
EVAL_PATTERN = Pattern.compile("eval\\((.*?)\\)", Pattern.CASE_INSENSITIVE
| Pattern.MULTILINE | Pattern.DOTALL);
EXPRESSION_PATTERN = Pattern.compile("expression\\((.*?)\\)", Pattern.CASE_INSENSITIVE
| Pattern.MULTILINE | Pattern.DOTALL);
JAVASCRIPT_PATTERN = Pattern.compile("javascript:", Pattern.CASE_INSENSITIVE);
VBSCRIPT_PATTERN = Pattern.compile("vbscript:", Pattern.CASE_INSENSITIVE);
ONLOAD_PATTERN = Pattern.compile("onload(.*?)=", Pattern.CASE_INSENSITIVE
| Pattern.MULTILINE | Pattern.DOTALL);
}
/**
* @Description XSS
* @param value
@ -43,8 +71,7 @@ public final class XSSFilterKit {
rlt = value.replaceAll("", "");
// Avoid anything between script tags
Pattern scriptPattern = Pattern.compile("<script>(.*?)</script>", Pattern.CASE_INSENSITIVE);
rlt = scriptPattern.matcher(rlt).replaceAll("");
rlt = SCRIPT_ALL_PATTERN.matcher(rlt).replaceAll("");
// Avoid anything in a src='...' type of expression
/*scriptPattern = Pattern.compile("src[\r\n]*=[\r\n]*\\\'(.*?)\\\'", Pattern.CASE_INSENSITIVE
@ -56,36 +83,25 @@ public final class XSSFilterKit {
rlt = scriptPattern.matcher(rlt).replaceAll("");*/
// Remove any lonesome </script> tag
scriptPattern = Pattern.compile("</script>", Pattern.CASE_INSENSITIVE);
rlt = scriptPattern.matcher(rlt).replaceAll("");
rlt = SCRIPT_PATTERN.matcher(rlt).replaceAll("");
// Remove any lonesome <script ...> tag
scriptPattern = Pattern.compile("<script(.*?)>", Pattern.CASE_INSENSITIVE
| Pattern.MULTILINE | Pattern.DOTALL);
rlt = scriptPattern.matcher(rlt).replaceAll("");
rlt = SCRIPT_INNER_PATTERN.matcher(rlt).replaceAll("");
// Avoid eval(...) expressions
scriptPattern = Pattern.compile("eval\\((.*?)\\)", Pattern.CASE_INSENSITIVE
| Pattern.MULTILINE | Pattern.DOTALL);
rlt = scriptPattern.matcher(rlt).replaceAll("");
rlt = EVAL_PATTERN.matcher(rlt).replaceAll("");
// Avoid expression(...) expressions
scriptPattern = Pattern.compile("expression\\((.*?)\\)", Pattern.CASE_INSENSITIVE
| Pattern.MULTILINE | Pattern.DOTALL);
rlt = scriptPattern.matcher(rlt).replaceAll("");
rlt = EXPRESSION_PATTERN.matcher(rlt).replaceAll("");
// Avoid javascript:... expressions
scriptPattern = Pattern.compile("javascript:", Pattern.CASE_INSENSITIVE);
rlt = scriptPattern.matcher(rlt).replaceAll("");
rlt = JAVASCRIPT_PATTERN.matcher(rlt).replaceAll("");
// Avoid vbscript:... expressions
scriptPattern = Pattern.compile("vbscript:", Pattern.CASE_INSENSITIVE);
rlt = scriptPattern.matcher(rlt).replaceAll("");
rlt = VBSCRIPT_PATTERN.matcher(rlt).replaceAll("");
// Avoid onload= expressions
scriptPattern = Pattern.compile("onload(.*?)=", Pattern.CASE_INSENSITIVE
| Pattern.MULTILINE | Pattern.DOTALL);
rlt = scriptPattern.matcher(rlt).replaceAll("");
rlt = ONLOAD_PATTERN.matcher(rlt).replaceAll("");
}
return rlt;

@ -52,6 +52,7 @@ import java.util.Map;
*/
public enum CodeBuilder {
/** 实例对象 */
INSTANCE;
/** 排除字段 */
@ -74,7 +75,9 @@ public enum CodeBuilder {
*
*/
public void build(CreaterBuilderModel builderModel, HttpServletResponse response){
if(builderModel == null) return;
if(builderModel == null){
return;
}
String dataStr = DateUtil.format(DateUtil.date(), "yyyyMMddHHmmss");

@ -41,6 +41,7 @@ import java.util.Map;
*/
public enum JavaCodeBuilder {
/** 实例对象 */
INSTANCE;
/**

@ -41,6 +41,7 @@ import java.util.*;
*/
public enum VueCodeBuilder {
/** 实例对象 */
INSTANCE;
/** 虚拟根路径 */

@ -39,6 +39,7 @@ import java.util.Map;
*/
public enum ReadMeBuilder {
/** 实例对象 */
INSTANCE;
/**

@ -77,7 +77,9 @@ public class MySQLSyncBuilder implements SyncStrategy {
@Override
@Transactional(rollbackFor = Exception.class)
public void execute(CreaterTableAndColumnModel model) {
if(model == null) return;
if(model == null){
return;
}
CreaterTableModel currTable = iTableService.get(model.getId());
if(currTable == null){

@ -31,39 +31,40 @@ import java.util.Map;
*/
public enum MySQLSyncColumnType {
/** 实例对象 */
INSTANCE;
private static final Map<String, FieldTypeAttribute> fieldTypeMap = new HashMap<>();
private static final Map<String, FieldTypeAttribute> FIELD_TYPE_MAP = new HashMap<>();
static {
fieldTypeMap.put("tinyint", new FieldTypeAttribute(true, false));
fieldTypeMap.put("smallint", new FieldTypeAttribute(true, false));
fieldTypeMap.put("mediumint", new FieldTypeAttribute(true, false));
fieldTypeMap.put("int", new FieldTypeAttribute(true, false));
fieldTypeMap.put("integer", new FieldTypeAttribute(true, false));
fieldTypeMap.put("bigint", new FieldTypeAttribute(true, false));
fieldTypeMap.put("real", new FieldTypeAttribute(true, true));
fieldTypeMap.put("float", new FieldTypeAttribute(true, true));
fieldTypeMap.put("double", new FieldTypeAttribute(true, true));
fieldTypeMap.put("decimal", new FieldTypeAttribute(true, true));
fieldTypeMap.put("numeric", new FieldTypeAttribute(true, true));
fieldTypeMap.put("char", new FieldTypeAttribute(true, false));
fieldTypeMap.put("varchar", new FieldTypeAttribute(true, false));
fieldTypeMap.put("date", new FieldTypeAttribute(false, false));
fieldTypeMap.put("time", new FieldTypeAttribute(false, false));
fieldTypeMap.put("timestamp", new FieldTypeAttribute(false, false));
fieldTypeMap.put("datetime", new FieldTypeAttribute(false, false));
fieldTypeMap.put("blob", new FieldTypeAttribute(false, false));
fieldTypeMap.put("mediumblob", new FieldTypeAttribute(false, false));
fieldTypeMap.put("longblob", new FieldTypeAttribute(false, false));
fieldTypeMap.put("tinytext", new FieldTypeAttribute(false, false));
fieldTypeMap.put("text", new FieldTypeAttribute(false, false));
fieldTypeMap.put("mediumtext", new FieldTypeAttribute(false, false));
fieldTypeMap.put("longtext", new FieldTypeAttribute(false, false));
FIELD_TYPE_MAP.put("tinyint", new FieldTypeAttribute(true, false));
FIELD_TYPE_MAP.put("smallint", new FieldTypeAttribute(true, false));
FIELD_TYPE_MAP.put("mediumint", new FieldTypeAttribute(true, false));
FIELD_TYPE_MAP.put("int", new FieldTypeAttribute(true, false));
FIELD_TYPE_MAP.put("integer", new FieldTypeAttribute(true, false));
FIELD_TYPE_MAP.put("bigint", new FieldTypeAttribute(true, false));
FIELD_TYPE_MAP.put("real", new FieldTypeAttribute(true, true));
FIELD_TYPE_MAP.put("float", new FieldTypeAttribute(true, true));
FIELD_TYPE_MAP.put("double", new FieldTypeAttribute(true, true));
FIELD_TYPE_MAP.put("decimal", new FieldTypeAttribute(true, true));
FIELD_TYPE_MAP.put("numeric", new FieldTypeAttribute(true, true));
FIELD_TYPE_MAP.put("char", new FieldTypeAttribute(true, false));
FIELD_TYPE_MAP.put("varchar", new FieldTypeAttribute(true, false));
FIELD_TYPE_MAP.put("date", new FieldTypeAttribute(false, false));
FIELD_TYPE_MAP.put("time", new FieldTypeAttribute(false, false));
FIELD_TYPE_MAP.put("timestamp", new FieldTypeAttribute(false, false));
FIELD_TYPE_MAP.put("datetime", new FieldTypeAttribute(false, false));
FIELD_TYPE_MAP.put("blob", new FieldTypeAttribute(false, false));
FIELD_TYPE_MAP.put("mediumblob", new FieldTypeAttribute(false, false));
FIELD_TYPE_MAP.put("longblob", new FieldTypeAttribute(false, false));
FIELD_TYPE_MAP.put("tinytext", new FieldTypeAttribute(false, false));
FIELD_TYPE_MAP.put("text", new FieldTypeAttribute(false, false));
FIELD_TYPE_MAP.put("mediumtext", new FieldTypeAttribute(false, false));
FIELD_TYPE_MAP.put("longtext", new FieldTypeAttribute(false, false));
}
public FieldTypeAttribute getAttr(String fieldType){
return fieldTypeMap.get(fieldType);
return FIELD_TYPE_MAP.get(fieldType);
}
}

@ -70,7 +70,9 @@ public class SQLSyncUtil {
* @param model
*/
public static void execute(CreaterTableAndColumnModel model){
if(model == null) return;
if(model == null){
return;
}
SyncStrategy syncStrategy = HANDLER_MAP.get(model.getJdbcType());
if(syncStrategy != null){

@ -54,7 +54,9 @@ public class TableColumnServiceImpl extends CrudServiceImpl<TableColumnMapper, C
// 验证对象
ValidationUtil.verify(model);
if(model == null) return null;
if(model == null){
return null;
}
CreaterTableColumn entity = super.transformM2T(model);
// 唯一验证
@ -76,7 +78,9 @@ public class TableColumnServiceImpl extends CrudServiceImpl<TableColumnMapper, C
@Transactional(rollbackFor = Exception.class)
public boolean insertBatch(List<CreaterTableColumnModel> models) {
if(models == null || models.size() == 0) return false;
if(models == null || models.size() == 0){
return false;
}
for (CreaterTableColumnModel model : models) {
@ -113,7 +117,9 @@ public class TableColumnServiceImpl extends CrudServiceImpl<TableColumnMapper, C
// 验证对象
ValidationUtil.verify(model);
if(model == null) return null;
if(model == null){
return null;
}
CreaterTableColumn entity = super.transformM2T(model);
// 唯一验证

@ -62,7 +62,9 @@ public class TableServiceImpl extends CrudServiceImpl<TableMapper, CreaterTable,
@Override
@Transactional(rollbackFor = Exception.class)
public CreaterTableModel insert(CreaterTableModel model) {
if(model == null) return null;
if(model == null){
return null;
}
CreaterTable entity = super.transformM2T(model);
// 唯一验证
@ -87,7 +89,9 @@ public class TableServiceImpl extends CrudServiceImpl<TableMapper, CreaterTable,
@Override
@Transactional(rollbackFor = Exception.class)
public CreaterTableModel update(CreaterTableModel model) {
if(model == null) return null;
if(model == null){
return null;
}
CreaterTable entity = super.transformM2T(model);
// 唯一验证

@ -57,7 +57,9 @@ public class SysAreaServiceImpl extends CrudServiceImpl<SysAreaMapper, SysArea,
@Override
@Transactional(rollbackFor = Exception.class)
public SysAreaModel insert(SysAreaModel model) {
if(model == null) return null;
if(model == null){
return null;
}
SysArea entity = super.transformM2T(model);
// 唯一验证
@ -78,7 +80,9 @@ public class SysAreaServiceImpl extends CrudServiceImpl<SysAreaMapper, SysArea,
@Transactional(rollbackFor = Exception.class)
@Override
public SysAreaModel update(SysAreaModel model) {
if(model == null) return null;
if(model == null){
return null;
}
SysArea entity = super.transformM2T(model);
// 唯一验证

@ -317,7 +317,9 @@ public class DictDetailServiceImpl extends CrudServiceImpl<DictDetailMapper, Sys
@Transactional(rollbackFor = Exception.class)
@Override
public boolean delByParent(String parentId) {
if(StringUtils.isEmpty(parentId)) return false;
if(StringUtils.isEmpty(parentId)){
return false;
}
String key = HumpUtil.humpToUnderline("typeId");
QueryBuilder<SysDictDetail> queryBuilder = new GenQueryBuilder<>();
@ -355,7 +357,9 @@ public class DictDetailServiceImpl extends CrudServiceImpl<DictDetailMapper, Sys
*/
@Override
public List<DictDetailModel> findListByTypeCode(String typeCode) {
if(StringUtils.isEmpty(typeCode)) return null;
if(StringUtils.isEmpty(typeCode)){
return null;
}
String key = HumpUtil.humpToUnderline("typeCode");
String deleted = HumpUtil.humpToUnderline("deleted");

@ -50,7 +50,9 @@ public class DictServiceImpl extends CrudServiceImpl<DictMapper, SysDict, DictMo
@Override
public DictModel insert(DictModel model) {
if(model == null) return null;
if(model == null){
return null;
}
SysDict entity = super.transformM2T(model);
// 唯一验证
@ -66,7 +68,9 @@ public class DictServiceImpl extends CrudServiceImpl<DictMapper, SysDict, DictMo
@Transactional(rollbackFor = Exception.class)
@Override
public DictModel update(DictModel model) {
if(model == null) return null;
if(model == null){
return null;
}
SysDict entity = super.transformM2T(model);
// 唯一验证
@ -123,7 +127,9 @@ public class DictServiceImpl extends CrudServiceImpl<DictMapper, SysDict, DictMo
@Transactional(rollbackFor = Exception.class)
@Override
public boolean deleteAll(String[] ids) {
if(ids == null) return false;
if(ids == null){
return false;
}
// 删除字典明细表
for (String id : ids) {
@ -136,7 +142,9 @@ public class DictServiceImpl extends CrudServiceImpl<DictMapper, SysDict, DictMo
@Transactional(rollbackFor = Exception.class)
@Override
public boolean deleteAll(Collection<DictModel> models) {
if(models == null || models.isEmpty()) return false;
if(models == null || models.isEmpty()){
return false;
}
// 删除字典明细表
for (DictModel model : models) {

@ -38,6 +38,9 @@ import java.util.Date;
@Service
public class LogsServiceImpl extends CrudServiceImpl<LogsMapper, SysLogs, LogsModel> implements ILogsService {
/** Log 存储量阈值 */
private static final int LOG_BIG_COUNT = 10_0000;
@Autowired(required = false)
private LogsMapper mapper;
@ -46,7 +49,7 @@ public class LogsServiceImpl extends CrudServiceImpl<LogsMapper, SysLogs, LogsMo
public LogsModel insert(LogsModel model) {
int count = super.count();
// 如果日志存储量为10万 则自动清空上月前数据
if(count > 10_0000){
if(count > LOG_BIG_COUNT){
this.emptyByOneMonth();
}
return super.insert(model);

@ -70,7 +70,9 @@ public class MenuServiceImpl extends CrudServiceImpl<MenuMapper, SysMenu, MenuMo
@Override
@Transactional(rollbackFor = Exception.class)
public MenuModel insert(MenuModel model) {
if(model == null) return null;
if(model == null){
return null;
}
SysMenu entity = super.transformM2T(model);
// 唯一验证
@ -91,7 +93,9 @@ public class MenuServiceImpl extends CrudServiceImpl<MenuMapper, SysMenu, MenuMo
@Transactional(rollbackFor = Exception.class)
@Override
public MenuModel update(MenuModel model) {
if(model == null) return null;
if(model == null){
return null;
}
SysMenu entity = super.transformM2T(model);
// 唯一验证

@ -60,6 +60,10 @@ import java.util.Map;
@ApiRestController("/sys/menu")
public class MenuRestController extends BaseRestController<SysMenu, MenuModel, IMenuService>
implements MenuApi {
/** 外部链接值 */
private static final String EXTERNAL_LINKS_VAL = "3";
/**
* -
* @return ResultVo
@ -116,7 +120,7 @@ public class MenuRestController extends BaseRestController<SysMenu, MenuModel, I
tree.setName(treeNode.getMenuName());
// 扩展属性 ...
// 不是外链 则处理组件
if(!"3".equals(treeNode.getType())){
if(!EXTERNAL_LINKS_VAL.equals(treeNode.getType())){
tree.putExtra("component", treeNode.getComponent());
}
tree.putExtra("type", treeNode.getType());
@ -127,7 +131,7 @@ public class MenuRestController extends BaseRestController<SysMenu, MenuModel, I
metaMap.put("title", treeNode.getMenuName());
metaMap.put("icon", treeNode.getIcon());
// 外链处理
if("3".equals(treeNode.getType())){
if(EXTERNAL_LINKS_VAL.equals(treeNode.getType())){
metaMap.put("target", "_blank");
metaMap.put("badge", "New");
}
@ -179,7 +183,7 @@ public class MenuRestController extends BaseRestController<SysMenu, MenuModel, I
tree.setName(treeNode.getMenuCode());
// 扩展属性 ...
// 不是外链 则处理组件
if(!"3".equals(treeNode.getType())){
if(!EXTERNAL_LINKS_VAL.equals(treeNode.getType())){
tree.putExtra("component", treeNode.getComponent());
}else{
// 如果是外链 则判断是否存在 BASE_PATH
@ -198,7 +202,7 @@ public class MenuRestController extends BaseRestController<SysMenu, MenuModel, I
metaMap.put("title", treeNode.getMenuName());
metaMap.put("icon", treeNode.getIcon());
// 外链处理
if("3".equals(treeNode.getType())){
if(EXTERNAL_LINKS_VAL.equals(treeNode.getType())){
metaMap.put("target", "_blank");
}
tree.putExtra("meta", metaMap);

@ -60,7 +60,9 @@ public class SysOrgServiceImpl extends CrudServiceImpl<SysOrgMapper, SysOrg, Sys
@Override
@Transactional(rollbackFor = Exception.class)
public SysOrgModel insert(SysOrgModel model) {
if(model == null) return null;
if(model == null){
return null;
}
SysOrg entity = super.transformM2T(model);
// 唯一验证
@ -81,7 +83,9 @@ public class SysOrgServiceImpl extends CrudServiceImpl<SysOrgMapper, SysOrg, Sys
@Transactional(rollbackFor = Exception.class)
@Override
public SysOrgModel update(SysOrgModel model) {
if(model == null) return null;
if(model == null){
return null;
}
SysOrg entity = super.transformM2T(model);
// 唯一验证

@ -60,6 +60,8 @@ import java.util.Set;
public class SysOrgRestController extends BaseRestController<SysOrg, SysOrgModel, ISysOrgService>
implements SysOrgRestApi {
/** 父节点ID */
private static final String PARENT_ID = "0";
/** 显示全部 */
public static final String ORG_ALL = "all";
/** 未分组 */
@ -81,7 +83,7 @@ public class SysOrgRestController extends BaseRestController<SysOrg, SysOrgModel
List<SysOrg> dataList = IService.findList(wrapper);
List<SysOrgModel> orgModelList = WrapperUtil.transformInstance(dataList, SysOrgModel.class);
// 0 为初始值
if("0".equals(parentId)){
if(PARENT_ID.equals(parentId)){
// 显示全部
SysOrgModel orgAll = new SysOrgModel();
orgAll.setId(ORG_ALL);

@ -47,7 +47,9 @@ public class RoleServiceImpl extends CrudServiceImpl<RoleMapper, SysRole, RoleMo
@Override
@Transactional(rollbackFor = Exception.class)
public RoleModel insert(RoleModel model) {
if(model == null) return null;
if(model == null){
return null;
}
SysRole entity = super.transformM2T(model);
// 唯一验证
@ -63,7 +65,9 @@ public class RoleServiceImpl extends CrudServiceImpl<RoleMapper, SysRole, RoleMo
@Override
@Transactional(rollbackFor = Exception.class)
public RoleModel update(RoleModel model) {
if(model == null) return null;
if(model == null){
return null;
}
SysRole entity = super.transformM2T(model);
// 唯一验证

@ -109,7 +109,9 @@ public class RoleMenuRefRestController implements RoleMenuRefApi {
// 演示模式 不允许操作
this.demoError();
if(model == null) return ResultVo.error("设置权限失败");
if(model == null){
return ResultVo.error("设置权限失败");
}
RoleModel roleModel = iRoleService.get(model.getRoleId());
// 内置数据 只有超级管理员可以修改

@ -43,7 +43,9 @@ public class TenantServiceImpl extends CrudServiceImpl<TenantMapper, SysTenant,
@Override
@Transactional(rollbackFor = Exception.class)
public TenantModel insert(TenantModel model) {
if(model == null) return null;
if(model == null){
return null;
}
SysTenant entity = super.transformM2T(model);
// 唯一验证
@ -59,7 +61,9 @@ public class TenantServiceImpl extends CrudServiceImpl<TenantMapper, SysTenant,
@Override
@Transactional(rollbackFor = Exception.class)
public TenantModel update(TenantModel model) {
if(model == null) return null;
if(model == null){
return null;
}
SysTenant entity = super.transformM2T(model);
// 唯一验证

@ -65,7 +65,9 @@ public class UserServiceImpl extends CrudServiceImpl<UserMapper, SysUser, UserMo
@Override
@Transactional(rollbackFor = Exception.class)
public UserModel insert(UserModel model) {
if(model == null) return null;
if(model == null){
return null;
}
SysUser entity = super.transformM2T(model);
// 唯一验证
@ -104,7 +106,9 @@ public class UserServiceImpl extends CrudServiceImpl<UserMapper, SysUser, UserMo
@Override
@Transactional(rollbackFor = Exception.class)
public UserModel update(UserModel model) {
if(model == null) return null;
if(model == null){
return null;
}
SysUser entity = super.transformM2T(model);
// 唯一验证 - 用户名
@ -272,6 +276,7 @@ public class UserServiceImpl extends CrudServiceImpl<UserMapper, SysUser, UserMo
return mapper.findList(qWrapper);
}
@Override
public Page<SysUserAndOrg,UserAndOrgModel> findPageByCus(Page<SysUserAndOrg,UserAndOrgModel> page) {
page.pageHelperBegin();
try{

Loading…
Cancel
Save