Compare commits
2 Commits
58a14e31c2
...
e471b56281
Author | SHA1 | Date |
---|---|---|
1iyc | e471b56281 | 1 week ago |
1iyc | 4bd634fa63 | 1 week ago |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,31 @@
|
|||||||
|
package com.lyr.common.core.domain;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.lyr.common.constant.HttpStatus;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作消息提醒
|
||||||
|
*
|
||||||
|
* @author liyc
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class ServiceResult extends HashMap<String, Object> {
|
||||||
|
|
||||||
|
|
||||||
|
private Integer code;
|
||||||
|
private String message;
|
||||||
|
private Map data;
|
||||||
|
|
||||||
|
public static ServiceResult success(String name) {
|
||||||
|
ImmutableMap<Object, Object> data1 = ImmutableMap.of();
|
||||||
|
return new ServiceResult(HttpStatus.SUCCESS, name, data1);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,104 @@
|
|||||||
|
package com.lyr.common.utils;
|
||||||
|
|
||||||
|
|
||||||
|
import com.lyr.common.exception.ServiceException;
|
||||||
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Admin
|
||||||
|
*/
|
||||||
|
public class AssertUtil {
|
||||||
|
|
||||||
|
|
||||||
|
public static void notEmpty(Long val, String s, Integer... codes) throws ServiceException {
|
||||||
|
if (val == null) {
|
||||||
|
Integer code = (codes.length == 0) ? 500 : codes[0];
|
||||||
|
throw new ServiceException(s, code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void notEmpty(Collection c, String s, Integer... codes) throws ServiceException {
|
||||||
|
if (CollectionUtils.isEmpty(c)) {
|
||||||
|
Integer code = (codes.length == 0) ? 500 : codes[0];
|
||||||
|
throw new ServiceException(s, code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void notEmpty(String val, String s, Integer... codes) throws ServiceException {
|
||||||
|
if (StringUtils.isEmpty(val)) {
|
||||||
|
Integer code = (codes.length == 0) ? 500 : codes[0];
|
||||||
|
throw new ServiceException(s, code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void notEmpty(Object val, String s, Integer... codes) throws ServiceException {
|
||||||
|
if (val == null) {
|
||||||
|
Integer code = (codes.length == 0) ? 500 : codes[0];
|
||||||
|
throw new ServiceException(s, code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不为空时抛出异常信息
|
||||||
|
*
|
||||||
|
* @param obj
|
||||||
|
* @param s
|
||||||
|
*/
|
||||||
|
public static void empty(Object obj, String s, Integer... codes) {
|
||||||
|
if (null != obj) {
|
||||||
|
Integer code = (codes.length == 0) ? 500 : codes[0];
|
||||||
|
throw new ServiceException(s, code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void empty(Object obj, String s, List<T> t, Integer... codes) {
|
||||||
|
if (null != obj) {
|
||||||
|
Integer code = (codes.length == 0) ? 500 : codes[0];
|
||||||
|
throw new ServiceException(s, code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void empty(Collection c, String s) {
|
||||||
|
if (!CollectionUtils.isEmpty(c)) {
|
||||||
|
throw new ServiceException(s, 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void notEqual(boolean val, String s, Integer... codes) {
|
||||||
|
if (val) {
|
||||||
|
Integer code = (codes.length == 0) ? 500 : codes[0];
|
||||||
|
throw new ServiceException(s, code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void equal(boolean val, String s) {
|
||||||
|
notEqual(!val, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void isFalse(boolean b, String s, Integer... codes) {
|
||||||
|
if (b) {
|
||||||
|
Integer code = (codes.length == 0) ? 500 : codes[0];
|
||||||
|
throw new ServiceException(s, code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void isTrue(boolean b, String s, Integer... codes) throws ServiceException {
|
||||||
|
if (!b) {
|
||||||
|
Integer code = (codes.length == 0) ? 500 : codes[0];
|
||||||
|
throw new ServiceException(s, code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void test() {
|
||||||
|
throw new ServiceException("222");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,49 @@
|
|||||||
|
package com.lyr.common.utils;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.expression.ExpressionParser;
|
||||||
|
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||||
|
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.Parameter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* spel 工具类
|
||||||
|
*
|
||||||
|
* @author liyc
|
||||||
|
* @date 2024/10/30
|
||||||
|
* @description TODO
|
||||||
|
**/
|
||||||
|
@Component
|
||||||
|
public class SpElUtil {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
public ExpressionParser expressionParser;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ExpressionParser expressionParser() {
|
||||||
|
return new SpelExpressionParser();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析表达式
|
||||||
|
*
|
||||||
|
* @param method
|
||||||
|
* @param args
|
||||||
|
* @param expression
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String parseExpression(Method method, Object[] args, String expression) {
|
||||||
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||||
|
Parameter[] parameters = method.getParameters();
|
||||||
|
for (int i = 0; i < parameters.length; i++) {
|
||||||
|
Parameter parameter = parameters[i];
|
||||||
|
context.setVariable(parameter.getName(), args[i]);
|
||||||
|
}
|
||||||
|
return expressionParser.parseExpression(expression).getValue(context, String.class);
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue