Kaynağa Gözat

全局模块:上传缺少的文件

tangxiangan 2 yıl önce
ebeveyn
işleme
444eda1675

+ 20 - 0
backend-common/src/main/java/config/AllowOriginConfig.java

@@ -0,0 +1,20 @@
+package config;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import pojo.AccessControlAllowOriginBean;
+
+@Configuration
+public class AllowOriginConfig {
+
+    @Value("${access-control-allow-origin:*}")
+    private String accessControlAllowOrigin;
+
+    @Bean
+    public AccessControlAllowOriginBean accessControllerAllowOriginBean() {
+        AccessControlAllowOriginBean bean = new AccessControlAllowOriginBean();
+        bean.setAllowOrigin(accessControlAllowOrigin);
+        return bean;
+    }
+}

+ 17 - 0
backend-common/src/main/java/config/SpringContextUtilsConfig.java

@@ -0,0 +1,17 @@
+package config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import utils.SpringContextUtils;
+
+@Configuration
+public class SpringContextUtilsConfig {
+    @Bean
+    /*
+     * SharedSession 中需要用到,直接在这里实例化好了
+     */
+    public SpringContextUtils springContextUtils() {
+        return new SpringContextUtils();
+    }
+
+}

+ 19 - 0
backend-common/src/main/java/enums/SensitiveDataTypeEnum.java

@@ -0,0 +1,19 @@
+package enums;
+
+/**
+ * 敏感数据类型
+ */
+public enum SensitiveDataTypeEnum {
+    /**
+     * 手机
+     */
+    MOBILE,
+    /**
+     *邮件
+     */
+    EMAIL,
+    /**
+     *其他
+     */
+    OTHER
+}

+ 29 - 0
backend-common/src/main/java/enums/ValidStatusEnum.java

@@ -0,0 +1,29 @@
+package enums;
+
+/**
+ * 有效状态(是否可用)
+ * CD101100
+ *
+ * @author tangxiangan
+ */
+public enum ValidStatusEnum {
+
+    /**
+     * 无效
+     */
+    INVALID("0"),
+    /**
+     * 有效
+     */
+    VALID("1");
+
+    private final String value;
+
+    ValidStatusEnum(String value) {
+        this.value = value;
+    }
+
+    public String value() {
+        return value;
+    }
+}

+ 27 - 0
backend-common/src/main/java/pojo/AccessControlAllowOriginBean.java

@@ -0,0 +1,27 @@
+package pojo;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+public class AccessControlAllowOriginBean {
+
+    private String allowOrigin;
+
+    public String getAllowOrigin() {
+        return allowOrigin;
+    }
+
+    public void setAllowOrigin(String allowOrigin) {
+        this.allowOrigin = allowOrigin;
+    }
+
+    public boolean isAll() {
+        return "*".equals(allowOrigin);
+    }
+
+    public Set<String> getDomains() {
+        String[] domains = allowOrigin.trim().split(",");
+        return new HashSet<>(Arrays.asList(domains));
+    }
+}

+ 63 - 0
backend-common/src/main/java/pojo/PageVO.java

@@ -0,0 +1,63 @@
+package pojo;
+
+import java.util.List;
+
+public class PageVO<T> {
+	 //当前页
+    private int pageNum;
+    //每页的数量
+    private int pageSize;
+    //当前页的数量
+    private int size;
+    //总记录数
+    private long total;
+    //总页数
+    private int pages;
+    //list
+	private List<?> list;
+	
+	public PageVO(){
+		
+	}
+
+	public PageVO(List<T> list){
+		this.list = list;
+	}
+	
+	public int getPageNum() {
+		return pageNum;
+	}
+	public void setPageNum(int pageNum) {
+		this.pageNum = pageNum;
+	}
+	public int getPageSize() {
+		return pageSize;
+	}
+	public void setPageSize(int pageSize) {
+		this.pageSize = pageSize;
+	}
+	public int getSize() {
+		return size;
+	}
+	public void setSize(int size) {
+		this.size = size;
+	}
+	public long getTotal() {
+		return total;
+	}
+	public void setTotal(long total) {
+		this.total = total;
+	}
+	public int getPages() {
+		return pages;
+	}
+	public void setPages(int pages) {
+		this.pages = pages;
+	}
+	public List<?> getList() {
+		return list;
+	}
+	public void setList(List<?> list) {
+		this.list = list;
+	}
+}

+ 64 - 0
backend-common/src/main/java/pojo/QueryParams.java

@@ -0,0 +1,64 @@
+package pojo;
+
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @author tangxiangan
+ */
+public class QueryParams {
+
+    @ApiModelProperty(name = "page", value = "页码", example = "1")
+    private Integer page;
+
+    @ApiModelProperty(name = "rows", value = "行数", example = "10")
+    private Integer rows;
+
+    @ApiModelProperty(name = "sidx", value = "排序字段", example = "name")
+    private String sidx;
+
+    @ApiModelProperty(name = "sord", value = "排序规则", example = "asc")
+    private String sord;
+
+    @ApiModelProperty(name = "orderByClause", value = "排序条件", example = "id asc, name asc")
+    private String orderByClause;
+
+    public Integer getPage() {
+        return page;
+    }
+
+    public void setPage(Integer page) {
+        this.page = page;
+    }
+
+    public Integer getRows() {
+        return rows;
+    }
+
+    public void setRows(Integer rows) {
+        this.rows = rows;
+    }
+
+    public String getSidx() {
+        return sidx;
+    }
+
+    public void setSidx(String sidx) {
+        this.sidx = sidx;
+    }
+
+    public String getSord() {
+        return sord;
+    }
+
+    public void setSord(String sord) {
+        this.sord = sord;
+    }
+
+    public String getOrderByClause() {
+        return orderByClause;
+    }
+
+    public void setOrderByClause(String orderByClause) {
+        this.orderByClause = orderByClause;
+    }
+}

+ 133 - 0
backend-common/src/main/java/utils/AesUtils.java

@@ -0,0 +1,133 @@
+package utils;
+
+import constant.CommonConstant;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import java.nio.charset.StandardCharsets;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.NoSuchAlgorithmException;
+
+public class AesUtils {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(AesUtils.class);
+
+    private static final String ALGORITHM = "AES/CBC/PKCS5Padding";
+
+    private static final String STRIP_STRING = " \0";
+
+    private static Cipher encryptCipher;
+
+    private static Cipher decryptCipher;
+
+    public synchronized static String encrypt(String content) {
+        return encrypt(CommonConstant.DEFAULT_ENCRYPT_KEY, CommonConstant.DEFAULT_ENCRYPT_IV_KEY, content);
+    }
+
+    public synchronized static String encrypt(String keyString, String ivKeyString, String content) {
+        if (StringUtils.isBlank(content)) {
+            return CommonConstant.STRING_EMPTY;
+        }
+        String encryptText = null;
+        try {
+            Key key = new SecretKeySpec(keyString.getBytes(StandardCharsets.US_ASCII), "AES");
+            encryptCipher = Cipher.getInstance(ALGORITHM);
+            encryptCipher.init(Cipher.ENCRYPT_MODE, key, new IvParameterSpec(ivKeyString.getBytes(StandardCharsets.US_ASCII)));
+        } catch (InvalidKeyException e) {
+            LOGGER.error("[AesUtils] invalid key " + keyString, e);
+        } catch (InvalidAlgorithmParameterException e) {
+            LOGGER.error("[AesUtils] invalid algorithm param " + ivKeyString, e);
+        } catch (NoSuchPaddingException | NoSuchAlgorithmException e) {
+            LOGGER.error("[AesUtils] init cipher error", e);
+        }
+        try {
+            byte[] encryptBytes = encryptCipher.doFinal(extendKey(content.getBytes(StandardCharsets.UTF_8)));
+            encryptText = parseByte2Hex(encryptBytes);
+        } catch (Exception e) {
+            LOGGER.error("[AesUtils] encrypt error ", e);
+        }
+        return encryptText;
+    }
+
+    public synchronized static String decrypt(String content) {
+        return decrypt(CommonConstant.DEFAULT_ENCRYPT_KEY, CommonConstant.DEFAULT_ENCRYPT_IV_KEY, content);
+    }
+
+    public synchronized static String decrypt(String keyString, String ivKeyString, String content) {
+        if (StringUtils.isBlank(content)) {
+            return CommonConstant.STRING_EMPTY;
+        }
+        String decryptText = null;
+        try {
+            Key key = new SecretKeySpec(keyString.getBytes(StandardCharsets.US_ASCII), "AES");
+            IvParameterSpec ivKey = new IvParameterSpec(ivKeyString.getBytes(StandardCharsets.US_ASCII));
+            decryptCipher = Cipher.getInstance(ALGORITHM);
+            decryptCipher.init(Cipher.DECRYPT_MODE, key, ivKey);
+        } catch (InvalidKeyException e) {
+            LOGGER.error("[AesUtils]invalid key" + keyString, e);
+        } catch (InvalidAlgorithmParameterException e) {
+            LOGGER.error("[AesUtils] encoding unsupported " + keyString, e);
+        } catch (NoSuchPaddingException | NoSuchAlgorithmException e) {
+            LOGGER.error("[AesUtils] init cipher error", e);
+        }
+        try {
+            byte[] encryptBytes = parseHex2Byte(content);
+            byte[] decryptBytes = decryptCipher.doFinal(encryptBytes);
+            decryptText = new String(decryptBytes, StandardCharsets.UTF_8);
+            decryptText = StringUtils.strip(decryptText, STRIP_STRING);
+        } catch (IllegalBlockSizeException | BadPaddingException e) {
+            LOGGER.error("[AesUtils]invalid key " + keyString, e);
+        }
+        return decryptText;
+    }
+
+    private static byte[] parseHex2Byte(String hexText) {
+        if (StringUtils.isEmpty(hexText)) {
+            return null;
+        }
+        byte[] result = new byte[hexText.length() / 2];
+        for (int i = 0; i < hexText.length() / 2; i++) {
+            int high = Integer.parseInt(hexText.substring(i * 2, i * 2 + 1), 16);
+            int low = Integer.parseInt(hexText.substring(i * 2 + 1, i * 2 + 2), 16);
+            result[i] = (byte) (high * 16 + low);
+        }
+        return result;
+    }
+
+    private static String parseByte2Hex(byte[] bytes) {
+        StringBuilder sb = new StringBuilder();
+        for (byte aByte : bytes) {
+            String hex = Integer.toHexString(aByte & 0xFF);
+            if (hex.length() == 1) {
+                hex = '0' + hex;
+            }
+            sb.append(hex.toLowerCase());
+        }
+        return sb.toString();
+    }
+
+    private static byte[] extendKey(byte[] input) {
+        int rest = input.length % 16;
+        if (rest > 0) {
+            byte[] result = new byte[input.length + (16 - rest)];
+            System.arraycopy(input, 0, result, 0, input.length);
+            return result;
+        }
+        return input;
+    }
+
+    public static void main(String[] args) {
+        System.out.println(encrypt("18627945022"));
+        System.out.println(decrypt(CommonConstant.DEFAULT_ENCRYPT_KEY, CommonConstant.DEFAULT_ENCRYPT_IV_KEY, "54db89effcf52bb979778f718f75aa5493439afa76973581ceeee35150764066"));
+    }
+
+}

+ 326 - 0
backend-common/src/main/java/utils/HttpClientUtils.java

@@ -0,0 +1,326 @@
+package utils;
+
+import constant.CommonConstant;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpStatus;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.*;
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.TrustStrategy;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicHttpResponse;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.util.CollectionUtils;
+
+import javax.net.ssl.SSLContext;
+import java.net.URLEncoder;
+import java.nio.charset.Charset;
+import java.security.KeyManagementException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+/**
+ * 处理简单http请求的类
+ *
+ * @author tangxiangan
+ */
+public class HttpClientUtils {
+    private static final Logger LOGGER = LoggerFactory.getLogger(HttpClientUtils.class);
+
+    private static CloseableHttpClient getHttpClient() {
+        TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true;
+
+        SSLContext sslContext;
+        try {
+            sslContext = org.apache.http.ssl.SSLContexts.custom()
+                    .loadTrustMaterial(null, acceptingTrustStrategy)
+                    .build();
+
+            SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
+
+            return HttpClients.custom()
+                    .setSSLSocketFactory(csf)
+                    .build();
+
+        } catch (NoSuchAlgorithmException | KeyManagementException | KeyStoreException e) {
+            LOGGER.error(e.getMessage(), e);
+        }
+
+        LOGGER.warn("error create http client, create default client will not support https!!!!");
+        return HttpClients.createDefault();
+    }
+
+
+    // 处理GET类请求,参数URL应包含完整的请求参数
+    public static String doGet(String url) {
+        return doGet(url, null);
+    }
+
+    public static String doGet(String url, Map<String, Object> params) {
+        return doGet(url, params, null);
+    }
+
+    public static String doGet(String url, Map<String, Object> params, Map<String, String> headers) {
+        try {
+            CloseableHttpClient httpClient = getHttpClient();
+            StringBuilder urlBuilder = new StringBuilder(url);
+            int i = 0;
+            if (!CollectionUtils.isEmpty(params)) for (String key : params.keySet()) {
+                urlBuilder.append((i == 0) ? "?" : "&");
+                urlBuilder.append(key).append("=");
+                if (params.get(key) != null) {
+                    urlBuilder.append(URLEncoder.encode(String.valueOf(params.get(key)), "utf-8"));
+                }
+                i++;
+            }
+
+            HttpGet httpGet = new HttpGet(urlBuilder.toString());
+
+            if (!CollectionUtils.isEmpty(headers)) {
+                for (String key : headers.keySet()) {
+                    httpGet.setHeader(key, headers.get(key));
+                }
+            }
+
+            CloseableHttpResponse response = httpClient.execute(httpGet);
+            HttpEntity entity = response.getEntity();
+            String content = EntityUtils.toString(entity);
+            EntityUtils.consume(entity);
+            return content;
+        } catch (Exception e) {
+            LOGGER.error("ERROR, call http get" + e.getMessage(), e);
+        }
+        return null;
+    }
+
+    /**
+     * 处理POST类请求,表格类型
+     */
+    public static String doPost(String url, Map<String, String> params) {
+        return doPost(url, params, null);
+    }
+
+    // 处理POST类请求
+    public static String doPost(String url, Object object) {
+        return doPost(url, object, null);
+    }
+
+    /**
+     * 处理POST类请求,body类型
+     */
+    public static String doPost(String url, Object body, Map<String, String> headers) {
+        try {
+            CloseableHttpClient httpClient = getHttpClient();
+            HttpPost httpPost = new HttpPost(url);
+            httpPost.setHeader("Accept", "application/json; charset=UTF-8");
+            httpPost.setHeader("Content-Type", "application/json; charset=UTF-8");
+            RequestConfig config = RequestConfig.custom()
+                    .setConnectionRequestTimeout(30000)
+                    .setConnectTimeout(30000).setSocketTimeout(30000).build();
+
+
+            if (body == null) {
+                body = new Object();
+            }
+
+            StringEntity strEntity = new StringEntity(JsonUtils.getJsonString(body),
+                    Charset.forName("UTF-8"));
+            httpPost.setEntity(strEntity);
+            httpPost.setConfig(config);
+
+            if (!CollectionUtils.isEmpty(headers)) {
+                for (Entry<String, String> entry : headers.entrySet()) {
+                    httpPost.setHeader(entry.getKey(), entry.getValue());
+                }
+            }
+
+            CloseableHttpResponse response = httpClient.execute(httpPost);
+            //资源创建成功 返回状态码201 返回数据为空
+            if(response.getStatusLine().getStatusCode() == HttpStatus.SC_CREATED){
+                return CommonConstant.RESULT_SUCCESS;
+            }
+            HttpEntity entity = response.getEntity();
+            String content = EntityUtils.toString(entity);
+            EntityUtils.consume(entity);
+            return content;
+        } catch (Exception e) {
+            LOGGER.error("ERROR, call http post" + e.getMessage(), e);
+        }
+        return null;
+    }
+
+
+    /**
+     * 处理POST类请求,表格类型
+     */
+    public static String doPost(String url, Map<String, String> params, Map<String, String> headers) {
+        try {
+            CloseableHttpClient httpClient = getHttpClient();
+            HttpPost httpPost = new HttpPost(url);
+            httpPost.setHeader("Accept", "application/json; charset=UTF-8");
+            RequestConfig config = RequestConfig.custom()
+                    .setConnectionRequestTimeout(60000)
+                    .setConnectTimeout(30000).setSocketTimeout(30000).build();
+
+            List<BasicNameValuePair> formParams = new ArrayList<>();
+
+            if (!CollectionUtils.isEmpty(params)) {
+                for (Entry<String, String> entry : params.entrySet()) {
+                    formParams.add(new BasicNameValuePair(entry.getKey(), entry
+                            .getValue()));
+                }
+            }
+
+            StringEntity strEntity = new UrlEncodedFormEntity(formParams,
+                    Charset.forName("UTF-8"));
+            httpPost.setEntity(strEntity);
+            httpPost.setConfig(config);
+
+            if (!CollectionUtils.isEmpty(headers)) {
+                for (Entry<String, String> entry : headers.entrySet()) {
+                    httpPost.setHeader(entry.getKey(), entry.getValue());
+                }
+            }
+
+            CloseableHttpResponse response = httpClient.execute(httpPost);
+            HttpEntity entity = response.getEntity();
+            String content = EntityUtils.toString(entity);
+            EntityUtils.consume(entity);
+            return content;
+        } catch (Exception e) {
+            LOGGER.error("ERROR, call http post" + e.getMessage(), e);
+        }
+        return null;
+    }
+
+    public static String doPut(String url, Map<String, Object> params) {
+        return doPut(url, params, null);
+    }
+
+    public static String doPut(String url, Map<String, Object> params, Map<String, String> headers) {
+        CloseableHttpClient httpClient = getHttpClient();
+        CloseableHttpResponse response;
+        try {
+
+            StringBuilder urlBuilder = new StringBuilder(url);
+            int i = 0;
+            if (!CollectionUtils.isEmpty(params)) {
+                for (Entry<String, Object> entry : params.entrySet()) {
+                    urlBuilder.append((i == 0) ? "?" : "&");
+                    urlBuilder.append(entry.getKey()).append("=").append(entry.getValue());
+                    i++;
+                }
+            }
+            HttpPut httpPut = new HttpPut(urlBuilder.toString());
+            if (!CollectionUtils.isEmpty(headers)) {
+                for (Entry<String, String> entry : headers.entrySet()) {
+                    httpPut.setHeader(entry.getKey(), entry.getValue());
+                }
+            }
+
+            response = httpClient.execute(httpPut);
+            HttpEntity entity = response.getEntity();
+            String content = EntityUtils.toString(entity);
+            EntityUtils.consume(entity);
+            return content;
+        } catch (Exception e) {
+            LOGGER.error("ERROR, call http put" + e.getMessage(), e);
+        }
+        return null;
+    }
+
+    /**
+     * contentType 为text/plain 或application/json
+     * @param url
+     * @param body
+     * @param headers
+     * @return
+     */
+    public static String doPut(String url, Object body, Map<String, String> headers,String contentType) {
+        CloseableHttpClient httpClient = getHttpClient();
+        CloseableHttpResponse response;
+        HttpPut httpPut = new HttpPut(url);
+        httpPut.setHeader("Content-Type", contentType+"; charset=UTF-8");
+        try {
+            if (body == null) {
+                body = new Object();
+            }
+            if (!CollectionUtils.isEmpty(headers)) {
+                for (Entry<String, String> entry : headers.entrySet()) {
+                    httpPut.setHeader(entry.getKey(), entry.getValue());
+                }
+            }
+
+            StringEntity strEntity ;
+            if(contentType.equals("application/json")){
+                strEntity = new StringEntity(JsonUtils.getJsonString(body), Charset.forName("UTF-8"));
+            }else{
+                strEntity = new StringEntity(body.toString());
+            }
+            httpPut.setEntity(strEntity);
+            response = httpClient.execute(httpPut);
+            if(response.getStatusLine().getStatusCode() == HttpStatus.SC_NO_CONTENT){
+                return CommonConstant.RESULT_SUCCESS;
+            }
+            HttpEntity entity = response.getEntity();
+            String content = EntityUtils.toString(entity);
+            EntityUtils.consume(entity);
+            return content;
+        } catch (Exception e) {
+            LOGGER.error("ERROR, call http put" + e.getMessage(), e);
+        }
+        return null;
+    }
+
+    public static String doDelete(String url) {
+        return doDelete(url, null);
+    }
+
+    public static String doDelete(String url, Map<String, Object> params) {
+        return doDelete(url, params, null);
+    }
+
+    public static String doDelete(String url, Map<String, Object> params, Map<String, String> headers) {
+        try {
+            CloseableHttpClient httpClient = getHttpClient();
+            StringBuilder urlBuilder = new StringBuilder(url);
+            int i = 0;
+            if (!CollectionUtils.isEmpty(params)) for (String key : params.keySet()) {
+                urlBuilder.append((i == 0) ? "?" : "&");
+                urlBuilder.append(key).append("=").append(params.get(key));
+                i++;
+            }
+            HttpDelete httpDelete = new HttpDelete(urlBuilder.toString());
+
+            if (!CollectionUtils.isEmpty(headers)) {
+                for (String key : headers.keySet()) {
+                    httpDelete.setHeader(key, headers.get(key));
+                }
+            }
+
+            CloseableHttpResponse response = httpClient.execute(httpDelete);
+            if(response.getStatusLine().getStatusCode() == HttpStatus.SC_NO_CONTENT){
+                return CommonConstant.STRING_EMPTY;
+            }
+            HttpEntity entity = response.getEntity();
+            String content = EntityUtils.toString(entity);
+            EntityUtils.consume(entity);
+            return content;
+        } catch (Exception e) {
+            LOGGER.error("ERROR, call http get" + e.getMessage(), e);
+        }
+        return null;
+    }
+}

+ 134 - 0
backend-common/src/main/java/utils/JsonUtils.java

@@ -0,0 +1,134 @@
+package utils;
+
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.util.StringUtils;
+import pojo.ResultMap;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+public class JsonUtils {
+    private final static SimpleDateFormat DEFAULT_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+    /**
+     * 将对象转换成JSON字符串
+     *
+     * @param bean 可以为基本的object 或者为 数组
+     * @return JSON字符串
+     */
+    public static String getJsonString(Object bean) {
+        return getJsonString(bean, DEFAULT_FORMAT);
+    }
+
+    /**
+     * 将对象转换成JSON字符串
+     *
+     * @param bean 可以为基本的object 或者为 数组
+     * @return JSON字符串
+     */
+    public static String getJsonString(Object bean, DateFormat dateFormat) {
+        ObjectMapper mapper = new ObjectMapper();
+        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+        mapper.setDateFormat(dateFormat);
+        try {
+            return mapper.writeValueAsString(bean);
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    /**
+     * 将json格式的字符串的转化为Bean对象
+     *
+     * @param <T>
+     * @param jsonStr
+     * @param clazz
+     * @return
+     */
+    public static <T> T jsonStringToBean(String jsonStr, Class<T> clazz, DateFormat dateFormat) {
+        if (StringUtils.isEmpty(jsonStr)) {
+            return null;
+        }
+        try {
+            ObjectMapper mapper = new ObjectMapper();
+            mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+            mapper.setDateFormat(dateFormat);
+            return mapper.readValue(jsonStr, clazz);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    /**
+     * 将json格式的字符串的转化为Bean对象
+     *
+     * @param <T>
+     * @param jsonStr
+     * @param clazz
+     * @return
+     */
+    public static <T> T jsonStringToBean(String jsonStr, Class<T> clazz) {
+        return jsonStringToBean(jsonStr, clazz, DEFAULT_FORMAT);
+    }
+
+    /**
+     * 将json格式的字符串(数组形式)的转化为List对象
+     *
+     * @param <T>
+     * @param jsonArrStr
+     * @param clazz      List中对象类型
+     * @return
+     */
+    public static <T> List<T> jsonStringToList(String jsonArrStr, Class<T> clazz) {
+        return jsonStringToList(jsonArrStr, clazz, DEFAULT_FORMAT);
+    }
+
+    /**
+     * 将json格式的字符串(数组形式)的转化为List对象
+     *
+     * @param <T>
+     * @param jsonArrStr
+     * @param clazz      List中对象类型
+     * @return
+     */
+    public static <T> List<T> jsonStringToList(String jsonArrStr, Class<T> clazz, DateFormat dateFormat) {
+        if (StringUtils.isEmpty(jsonArrStr)) {
+            return new ArrayList<>();
+        }
+        try {
+            ObjectMapper mapper = new ObjectMapper();
+            mapper.setDateFormat(dateFormat);
+            JavaType javaType = mapper.getTypeFactory().constructParametricType(List.class, clazz);
+            mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+            return mapper.readValue(jsonArrStr, javaType);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return new ArrayList<>();
+        }
+    }
+
+
+    public static <T> ResultMap<T> jsonStringToResultMap(String jsonArrStr, Class<T> clazz) {
+        if (StringUtils.isEmpty(jsonArrStr)) {
+            return new ResultMap<>();
+        }
+
+        try {
+            ObjectMapper mapper = new ObjectMapper();
+            mapper.setDateFormat(DEFAULT_FORMAT);
+            JavaType javaType = mapper.getTypeFactory().constructParametricType(ResultMap.class, clazz);
+            mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+            return mapper.readValue(jsonArrStr, javaType);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+}

+ 34 - 0
backend-common/src/main/java/utils/MD5Utils.java

@@ -0,0 +1,34 @@
+package utils;
+
+import java.security.MessageDigest;
+
+/**
+ * tangxiangan
+ */
+public class MD5Utils {
+
+    public static String encode(String s) {
+        char[] hexDigits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
+        try {
+            byte[] btInput = s.getBytes();
+            // 获得MD5摘要算法的 MessageDigest 对象
+            MessageDigest mdInst = MessageDigest.getInstance("MD5");
+            // 使用指定的字节更新摘要
+            mdInst.update(btInput);
+            // 获得密文
+            byte[] md = mdInst.digest();
+            // 把密文转换成十六进制的字符串形式
+            int j = md.length;
+            char[] str = new char[j * 2];
+            int k = 0;
+            for (byte byte0 : md) {
+                str[k++] = hexDigits[byte0 >>> 4 & 0xf];
+                str[k++] = hexDigits[byte0 & 0xf];
+            }
+            return new String(str);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+}

+ 66 - 0
backend-common/src/main/java/utils/PageUtils.java

@@ -0,0 +1,66 @@
+package utils;
+
+import org.apache.commons.lang.StringUtils;
+import pojo.PageVO;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class PageUtils {
+	public static Integer getParamToInt(Integer param, Integer defaultValue) {
+		Integer num = defaultValue;
+		if (param != null && param > 0) {
+			num = param;
+		}
+		return num;
+	}
+
+	public static String getOrderByClause(String orderColumn, String orderRule, String defaultOrderByClause) {
+		// orderColumn 排序字段
+		// orderRule 排序规则:ASC/DESC缺省为:DESC
+		// 获取排序信息
+		String orderByClause = defaultOrderByClause;
+		// 构造排序子句
+		if (StringUtils.isNotBlank(orderColumn)) {
+			orderByClause = orderColumn + " DESC";
+			if (StringUtils.isNotBlank(orderRule)) {
+				orderByClause = orderColumn + " " + orderRule;
+			}
+		}
+		return orderByClause;
+	}
+
+	public static String getLikeQuery(String name){
+		if (StringUtils.isNotBlank(name)) {
+			return "%"+name+"%";
+		}
+		return name;
+	}
+
+	public static <E> PageVO<E> pageByList(int pageNum, int pageSize, List<E> infoList) {
+		List<E> iList = new ArrayList<E>();
+		int begin = (pageNum - 1) * pageSize;
+		int end = pageNum * pageSize;
+
+		for (int i = 0; i < infoList.size(); i++) {
+			if (i >= begin && i < end) {
+				iList.add(infoList.get(i));
+			}
+		}
+
+		PageVO<E> pageVO = new PageVO<E>();
+		pageVO.setList(iList);
+		pageVO.setPageNum(pageNum);
+		pageVO.setPageSize(pageSize);
+		if (infoList.size() % pageSize == 0) {
+			pageVO.setPages(infoList.size() / pageSize);
+			pageVO.setSize(infoList.size() / pageSize);
+		} else {
+			pageVO.setPages(infoList.size() / pageSize + 1);
+			pageVO.setSize(infoList.size() / pageSize + 1);
+		}
+		pageVO.setTotal(infoList.size());
+		return pageVO;
+	}
+
+}

+ 72 - 0
backend-common/src/main/java/utils/QueryUtils.java

@@ -0,0 +1,72 @@
+package utils;
+
+
+import com.github.pagehelper.PageInfo;
+import constant.CommonConstant;
+import org.springframework.beans.BeanUtils;
+import org.springframework.util.CollectionUtils;
+import pojo.PageVO;
+import pojo.QueryParams;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.stream.Collectors;
+
+public class QueryUtils {
+
+    public static String generateLikeString(String string){
+        try {
+            string = URLDecoder.decode(URLDecoder.decode(string, CommonConstant.ENCODING_UTF8), CommonConstant.ENCODING_UTF8);
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException("unsupport encoding");
+        }
+        return "%"+string+"%";
+    }
+
+    public static String generateLikeStringHalf(String string){
+        try {
+            //处理下%和_的问题,应该还有其他通配符
+            string = string.replace(CommonConstant.STRING_PERCENT,"\\" + CommonConstant.STRING_PERCENT)
+                    .replace(CommonConstant.STRING_UNDERLINE,"\\" + CommonConstant.STRING_UNDERLINE);
+            string = URLDecoder.decode(URLEncoder.encode(string, CommonConstant.ENCODING_UTF8), CommonConstant.ENCODING_UTF8);
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException("unsupport encoding");
+        }
+        return string+"%";
+    }
+
+
+
+    public static <T extends QueryParams> void handlePageAndRow(T param) {
+        param.setPage(PageUtils.getParamToInt(param.getPage(), CommonConstant.PAGENUM));
+        param.setRows(PageUtils.getParamToInt(param.getRows(), CommonConstant.PAGESIZE));
+    }
+
+    public static <T extends QueryParams> void handleParam(T param) {
+        Integer pageNum = PageUtils.getParamToInt(param.getPage(), CommonConstant.PAGENUM);
+        Integer pageSize = PageUtils.getParamToInt(param.getRows(), CommonConstant.PAGESIZE);
+        String orderByClause = PageUtils.getOrderByClause(param.getSidx(), param.getSord(), CommonConstant.ORDERBYCLAUSE);
+        param.setOrderByClause(orderByClause);
+        param.setPage(pageNum);
+        param.setRows(pageSize);
+    }
+
+    public static <T,V> PageVO<T> convertPageInfoToVO(PageInfo<V> pageInfo, BeanConverter<V,T> converter){
+        PageVO<T> pageVO = new PageVO<>();
+        BeanUtils.copyProperties(pageInfo,pageVO);
+        pageVO.setList(convertListToVO(pageInfo.getList(),converter));
+        return pageVO;
+    }
+
+
+    public static <T,V> List<T> convertListToVO(List<V> list, BeanConverter<V,T> converter){
+        List<T> voList = new CopyOnWriteArrayList<>();
+        if(!CollectionUtils.isEmpty(list)){
+            voList = list.stream().map(converter::convert).collect(Collectors.toList());
+        }
+        return voList;
+    }
+}

+ 626 - 0
backend-common/src/main/java/utils/RedisUtils.java

@@ -0,0 +1,626 @@
+package utils;
+
+import exception.BackendRuntimeException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+@Component
+public class RedisUtils<K, V> {
+
+    @Autowired
+    private RedisTemplate<K, V> redisTemplate;
+
+    public RedisTemplate getInstance() {
+        return redisTemplate;
+    }
+
+    /**
+     * 指定缓存失效时间
+     *
+     * @param key  键
+     * @param time 时间(秒)
+     * @return
+     */
+    public boolean expire(K key, long time) {
+        try {
+            if (time > 0) {
+                redisTemplate.expire(key, time, TimeUnit.SECONDS);
+            }
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    /**
+     * 根据key 获取过期时间
+     *
+     * @param key 键 不能为null
+     * @return 时间(秒) 返回0代表为永久有效
+     */
+    public long getExpire(K key) {
+        return redisTemplate.getExpire(key, TimeUnit.SECONDS);
+    }
+
+    /**
+     * 判断key是否存在
+     *
+     * @param key 键
+     * @return true 存在 false不存在
+     */
+    public boolean exists(K key) {
+        try {
+            return redisTemplate.hasKey(key);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    /**
+     * 删除缓存
+     *
+     * @param key 可以传一个值 或多个
+     */
+    @SuppressWarnings("unchecked")
+    public void del(K... key) {
+        if (key != null && key.length > 0) {
+            if (key.length == 1) {
+                redisTemplate.delete(key[0]);
+            } else {
+                redisTemplate.delete(CollectionUtils.arrayToList(key));
+            }
+        }
+    }
+
+    //============================String=============================
+
+    /**
+     * 普通缓存获取
+     *
+     * @param key 键
+     * @return 值
+     */
+    public V get(K key) {
+        return key == null ? null : redisTemplate.opsForValue().get(key);
+    }
+
+    /**
+     * 普通缓存放入
+     *
+     * @param key   键
+     * @param value 值
+     * @return true成功 false失败
+     */
+    public boolean set(K key, V value) {
+        try {
+            redisTemplate.opsForValue().set(key, value);
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+
+    }
+
+    /**
+     * 普通缓存放入并设置时间
+     *
+     * @param key   键
+     * @param value 值
+     * @param time  时间(秒) time要大于0 如果time小于等于0 将设置无限期
+     * @return true成功 false 失败
+     */
+    public boolean set(K key, V value, long time) {
+        return set(key, value, time, TimeUnit.SECONDS);
+    }
+
+    /**
+     * 普通缓存放入并设置时间
+     *
+     * @param key   键
+     * @param value 值
+     * @param time  时间(秒) time要大于0 如果time小于等于0 将设置无限期
+     * @return true成功 false 失败
+     */
+    public boolean set(K key, V value, long time, TimeUnit timeUnit) {
+        try {
+            if (time > 0) {
+                redisTemplate.opsForValue().set(key, value, time, timeUnit);
+            } else {
+                set(key, value);
+            }
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    /**
+     * 递增
+     *
+     * @param key   键
+     * @param delta 要增加几(大于0)
+     * @return
+     */
+    public long incr(K key, long delta) {
+        if (delta < 0) {
+            throw new BackendRuntimeException("递增因子必须大于0");
+        }
+        return redisTemplate.opsForValue().increment(key, delta);
+    }
+
+    /**
+     * 递减
+     *
+     * @param key   键
+     * @param delta 要减少几(小于0)
+     * @return
+     */
+    public long decr(K key, long delta) {
+        if (delta < 0) {
+            throw new BackendRuntimeException("递减因子必须大于0");
+        }
+        return redisTemplate.opsForValue().increment(key, -delta);
+    }
+
+    //================================Map=================================
+
+    /**
+     * HashGet
+     *
+     * @param key  键 不能为null
+     * @param item 项 不能为null
+     * @return 值
+     */
+    public String hget(K key, String item) {
+        return (String) redisTemplate.opsForHash().get(key, item);
+    }
+
+    /**
+     * 获取hashKey对应的所有键值
+     *
+     * @param key 键
+     * @return 对应的多个键值
+     */
+    public Map<Object, Object> hmget(K key) {
+        return redisTemplate.opsForHash().entries(key);
+    }
+
+    /**
+     * HashSet
+     *
+     * @param key 键
+     * @param map 对应多个键值
+     * @return true 成功 false 失败
+     */
+    public boolean hmset(K key, Map<String, Object> map) {
+        try {
+            redisTemplate.opsForHash().putAll(key, map);
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    /**
+     * HashSet 并设置时间
+     *
+     * @param key  键
+     * @param map  对应多个键值
+     * @param time 时间(秒)
+     * @return true成功 false失败
+     */
+    public boolean hmset(K key, Map<String, String> map, long time) {
+        try {
+            redisTemplate.opsForHash().putAll(key, map);
+            if (time > 0) {
+                expire(key, time);
+            }
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    /**
+     * 向一张hash表中放入数据,如果不存在将创建
+     *
+     * @param key   键
+     * @param item  项
+     * @param value 值
+     * @return true 成功 false失败
+     */
+    public boolean hset(K key, String item, String value) {
+        try {
+            redisTemplate.opsForHash().put(key, item, value);
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    public boolean hsetBean(K key, String item, Object value) {
+        try {
+            redisTemplate.opsForHash().put(key, item, value);
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    /**
+     * 向一张hash表中放入数据,如果不存在将创建
+     *
+     * @param key   键
+     * @param item  项
+     * @param value 值
+     * @param time  时间(秒)  注意:如果已存在的hash表有时间,这里将会替换原有的时间
+     * @return true 成功 false失败
+     */
+    public boolean hset(K key, String item, V value, long time) {
+        try {
+            redisTemplate.opsForHash().put(key, item, value);
+            if (time > 0) {
+                expire(key, time);
+            }
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    /**
+     * 删除hash表中的值
+     *
+     * @param key  键 不能为null
+     * @param item 项 可以使多个 不能为null
+     */
+    public void hdel(K key, String... item) {
+        redisTemplate.opsForHash().delete(key, item);
+    }
+
+    /**
+     * 判断hash表中是否有该项的值
+     *
+     * @param key  键 不能为null
+     * @param item 项 不能为null
+     * @return true 存在 false不存在
+     */
+    public boolean hHasKey(K key, String item) {
+        return redisTemplate.opsForHash().hasKey(key, item);
+    }
+
+    /**
+     * hash递增 如果不存在,就会创建一个 并把新增后的值返回
+     *
+     * @param key  键
+     * @param item 项
+     * @param by   要增加几(大于0)
+     * @return
+     */
+    public double hincr(K key, String item, double by) {
+        return redisTemplate.opsForHash().increment(key, item, by);
+    }
+
+    /**
+     * hash递减
+     *
+     * @param key  键
+     * @param item 项
+     * @param by   要减少记(小于0)
+     * @return
+     */
+    public double hdecr(K key, String item, double by) {
+        return redisTemplate.opsForHash().increment(key, item, -by);
+    }
+
+    //============================set=============================
+
+    /**
+     * 根据key获取Set中的所有值
+     *
+     * @param key 键
+     * @return
+     */
+    public Set<V> sGet(K key) {
+        try {
+            return redisTemplate.opsForSet().members(key);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    /**
+     * 根据value从一个set中查询,是否存在
+     *
+     * @param key   键
+     * @param value 值
+     * @return true 存在 false不存在
+     */
+    public boolean sHasKey(K key, V value) {
+        try {
+            return redisTemplate.opsForSet().isMember(key, value);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    /**
+     * 将数据放入set缓存
+     *
+     * @param key    键
+     * @param values 值 可以是多个
+     * @return 成功个数
+     */
+    public long sSet(K key, V... values) {
+        try {
+            return redisTemplate.opsForSet().add(key, values);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return 0;
+        }
+    }
+
+    /**
+     * 将set数据放入缓存
+     *
+     * @param key    键
+     * @param time   时间(秒)
+     * @param values 值 可以是多个
+     * @return 成功个数
+     */
+    public long sSetAndTime(K key, long time, V... values) {
+        try {
+            Long count = redisTemplate.opsForSet().add(key, values);
+            if (time > 0) expire(key, time);
+            return count;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return 0;
+        }
+    }
+
+    /**
+     * 获取set缓存的长度
+     *
+     * @param key 键
+     * @return
+     */
+    public long sGetSetSize(K key) {
+        try {
+            return redisTemplate.opsForSet().size(key);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return 0;
+        }
+    }
+
+    /**
+     * 移除值为value的
+     *
+     * @param key    键
+     * @param values 值 可以是多个
+     * @return 移除的个数
+     */
+    public long setRemove(K key, Object... values) {
+        try {
+            Long count = redisTemplate.opsForSet().remove(key, values);
+            return count;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return 0;
+        }
+    }
+    //===============================list=================================
+
+    /**
+     * 获取list缓存的内容
+     *
+     * @param key   键
+     * @param start 开始
+     * @param end   结束  0 到 -1代表所有值
+     * @return
+     */
+    public List<V> lrange(K key, long start, long end) {
+        try {
+            return redisTemplate.opsForList().range(key, start, end);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    /**
+     * 获取list缓存的长度
+     *
+     * @param key 键
+     * @return
+     */
+    public long llen(K key) {
+        try {
+            return redisTemplate.opsForList().size(key);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return 0;
+        }
+    }
+
+    /**
+     * 通过索引 获取list中的值
+     *
+     * @param key   键
+     * @param index 索引  index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推
+     * @return
+     */
+    public Object lGetIndex(K key, long index) {
+        try {
+            return redisTemplate.opsForList().index(key, index);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    /**
+     * 将list放入缓存
+     *
+     * @param key   键
+     * @param value 值
+     * @return
+     */
+    public boolean lpush(K key, V value) {
+        try {
+            redisTemplate.opsForList().leftPush(key, value);
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    public boolean lpop(K key) {
+        try {
+            redisTemplate.opsForList().leftPop(key);
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    /**
+     * 将list放入缓存
+     *
+     * @param key   键
+     * @param value 值
+     * @return
+     */
+    public boolean rpush(K key, V value) {
+        try {
+            redisTemplate.opsForList().rightPush(key, value);
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    /**
+     * 将list放入缓存
+     *
+     * @param key   键
+     * @param value 值
+     * @param time  时间(秒)
+     * @return
+     */
+    public boolean lSet(K key, V value, long time) {
+        try {
+            redisTemplate.opsForList().rightPush(key, value);
+            if (time > 0) expire(key, time);
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    /**
+     * 将list放入缓存
+     *
+     * @param key   键
+     * @param value 值
+     * @return
+     */
+    public boolean lSet(K key, List<V> value) {
+        try {
+            redisTemplate.opsForList().rightPushAll(key, value);
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    /**
+     * 将list放入缓存
+     *
+     * @param key   键
+     * @param value 值
+     * @param time  时间(秒)
+     * @return
+     */
+    public boolean lSet(K key, List<V> value, long time) {
+        try {
+            redisTemplate.opsForList().rightPushAll(key, value);
+            if (time > 0) expire(key, time);
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    /**
+     * 根据索引修改list中的某条数据
+     *
+     * @param key   键
+     * @param index 索引
+     * @param value 值
+     * @return
+     */
+    public boolean lUpdateIndex(K key, long index, V value) {
+        try {
+            redisTemplate.opsForList().set(key, index, value);
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    /**
+     * 移除N个值为value
+     *
+     * @param key   键
+     * @param count 移除多少个
+     * @param value 值
+     * @return 移除的个数
+     */
+    public long lRemove(K key, long count, V value) {
+        try {
+            Long remove = redisTemplate.opsForList().remove(key, count, value);
+            return remove;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return 0;
+        }
+    }
+
+    public Boolean hexists(K key, String item) {
+        return !StringUtils.isEmpty(hget(key, item));
+    }
+
+    public Set<K> queryKeys(K pattern) {
+        return redisTemplate.keys(pattern);
+    }
+}
+
+

+ 31 - 0
backend-common/src/main/java/utils/SpringContextUtils.java

@@ -0,0 +1,31 @@
+package utils;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+/**
+ * Created by tangxiangan.
+ */
+public class SpringContextUtils implements ApplicationContextAware {
+
+    private static ApplicationContext context;
+
+    @Override
+    public void setApplicationContext(ApplicationContext context) throws BeansException {
+        SpringContextUtils.context = context;
+    }
+
+    public static Object getBean(String beanName) {
+        return context.getBean(beanName);
+    }
+
+    public static <T> T getBean(Class<T> tClass) {
+        return context.getBean(tClass);
+    }
+
+    public static String getProperty(String key) {
+        return context.getEnvironment().getProperty(key);
+    }
+
+}

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1266 - 0
backend-core/src/main/java/cn/kdan/pdf/backend/core/model/PricingsExample.java


Dosya farkı çok büyük olduğundan ihmal edildi
+ 1221 - 0
backend-core/src/main/java/cn/kdan/pdf/backend/core/model/SetPricingsExample.java


+ 30 - 0
backend-core/src/main/java/cn/kdan/pdf/backend/core/properties/HttpMatchersProperties.java

@@ -0,0 +1,30 @@
+package cn.kdan.pdf.backend.core.properties;//package properties;
+
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+import java.util.List;
+
+@ConfigurationProperties("http")
+public class HttpMatchersProperties {
+
+    private List<String> requestMatchers;
+
+    private List<String> webMatchers;
+
+    public List<String> getRequestMatchers() {
+        return requestMatchers;
+    }
+
+    public void setRequestMatchers(List<String> requestMatchers) {
+        this.requestMatchers = requestMatchers;
+    }
+
+    public List<String> getWebMatchers() {
+        return webMatchers;
+    }
+
+    public void setWebMatchers(List<String> webMatchers) {
+        this.webMatchers = webMatchers;
+    }
+}

+ 29 - 0
backend-core/src/main/java/cn/kdan/pdf/backend/core/properties/Oauth2LoginProperties.java

@@ -0,0 +1,29 @@
+package cn.kdan.pdf.backend.core.properties;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+@Data
+@ConfigurationProperties(prefix = "oauth2.login")
+public class Oauth2LoginProperties {
+
+    /**
+     * 智通登录成功携带授权码重定向地址
+     */
+    private String codeRedirectUri;
+
+    /**
+     * 默认账号密码
+     */
+    private String defaultPassword;
+
+    /**
+     * 智通登录失败重定向地址
+     */
+    private String errorRedirectUri;
+
+    /**
+     * 管理端未添加用户登录重定向地址
+     */
+    private String userNotAddRedirectUri;
+}