初始化
parent
8ce91c2c61
commit
7284f627f2
|
@ -0,0 +1,15 @@
|
|||
package com.zcloud;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
|
||||
@SpringBootApplication
|
||||
public class MainApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MainApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.zcloud;
|
||||
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
|
||||
/**
|
||||
* 说明:项目以war包方式运行时用到
|
||||
*/
|
||||
public class SpringBootStartApplication extends SpringBootServletInitializer {
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
|
||||
return builder.sources(MainApplication.class); //这里要指向原先用main方法执行的FHmainApplication启动类
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.zcloud.common.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 系统日志注解
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface SysLog {
|
||||
String value() default "";
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
|
||||
|
||||
package com.zcloud.common.aspect;
|
||||
|
||||
import com.zcloud.common.exception.ZException;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Redis切面处理类
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Aspect
|
||||
@Configuration
|
||||
public class RedisAspect {
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
//是否开启redis缓存 true开启 false关闭
|
||||
@Value("${spring.redis.open: false}")
|
||||
private boolean open;
|
||||
|
||||
@Around("execution(* com.zcloud.common.utils.RedisUtils.*(..))")
|
||||
public Object around(ProceedingJoinPoint point) throws Throwable {
|
||||
Object result = null;
|
||||
if(open){
|
||||
try{
|
||||
result = point.proceed();
|
||||
}catch (Exception e){
|
||||
logger.error("redis error", e);
|
||||
throw new ZException("Redis服务异常");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
|
||||
|
||||
package com.zcloud.common.aspect;
|
||||
import com.google.gson.Gson;
|
||||
import com.zcloud.common.annotation.SysLog;
|
||||
import com.zcloud.common.utils.HttpContextUtils;
|
||||
import com.zcloud.common.utils.IPUtils;
|
||||
import com.zcloud.modules.sys.entity.SysLogEntity;
|
||||
import com.zcloud.modules.sys.entity.SysUserEntity;
|
||||
import com.zcloud.modules.sys.service.SysLogService;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 系统日志,切面处理类
|
||||
*
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
public class SysLogAspect {
|
||||
@Autowired
|
||||
private SysLogService sysLogService;
|
||||
|
||||
@Pointcut("@annotation(com.zcloud.common.annotation.SysLog)")
|
||||
public void logPointCut() {
|
||||
|
||||
}
|
||||
|
||||
@Around("logPointCut()")
|
||||
public Object around(ProceedingJoinPoint point) throws Throwable {
|
||||
long beginTime = System.currentTimeMillis();
|
||||
//执行方法
|
||||
Object result = point.proceed();
|
||||
//执行时长(毫秒)
|
||||
long time = System.currentTimeMillis() - beginTime;
|
||||
|
||||
//保存日志
|
||||
saveSysLog(point, time);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void saveSysLog(ProceedingJoinPoint joinPoint, long time) {
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
|
||||
SysLogEntity sysLog = new SysLogEntity();
|
||||
SysLog syslog = method.getAnnotation(SysLog.class);
|
||||
if(syslog != null){
|
||||
//注解上的描述
|
||||
sysLog.setOperation(syslog.value());
|
||||
}
|
||||
|
||||
//请求的方法名
|
||||
String className = joinPoint.getTarget().getClass().getName();
|
||||
String methodName = signature.getName();
|
||||
sysLog.setMethod(className + "." + methodName + "()");
|
||||
|
||||
//请求的参数
|
||||
Object[] args = joinPoint.getArgs();
|
||||
try{
|
||||
String params = new Gson().toJson(args);
|
||||
sysLog.setParams(params);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
|
||||
//获取request
|
||||
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
|
||||
//设置IP地址
|
||||
sysLog.setIp(IPUtils.getIpAddr(request));
|
||||
|
||||
//用户名
|
||||
String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername();
|
||||
sysLog.setUsername(username);
|
||||
sysLog.setCorpinfoId(((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getCorpinfoId());
|
||||
|
||||
sysLog.setTime(time);
|
||||
sysLog.setCreateDate(new Date());
|
||||
//保存系统日志
|
||||
sysLogService.saveLog(sysLog);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
|
||||
|
||||
package com.zcloud.common.exception;
|
||||
|
||||
/**
|
||||
* 自定义异常
|
||||
*
|
||||
*/
|
||||
public class ZException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String msg;
|
||||
private int code = 500;
|
||||
|
||||
public ZException(String msg) {
|
||||
super(msg);
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public ZException(String msg, Throwable e) {
|
||||
super(msg, e);
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public ZException(String msg, int code) {
|
||||
super(msg);
|
||||
this.msg = msg;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public ZException(String msg, int code, Throwable e) {
|
||||
super(msg, e);
|
||||
this.msg = msg;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.zcloud.common.exception;
|
||||
|
||||
import com.zcloud.common.utils.R;
|
||||
import org.apache.shiro.authz.AuthorizationException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||
|
||||
/**
|
||||
* 异常处理器
|
||||
*
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
public class ZExceptionHandler {
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
/**
|
||||
* 处理自定义异常
|
||||
*/
|
||||
@ExceptionHandler(ZException.class)
|
||||
public R handleRRException(ZException e){
|
||||
R r = new R();
|
||||
r.put("code", e.getCode());
|
||||
r.put("msg", e.getMessage());
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@ExceptionHandler(NoHandlerFoundException.class)
|
||||
public R handlerNoFoundException(Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return R.error(404, "路径不存在,请检查路径是否正确");
|
||||
}
|
||||
|
||||
@ExceptionHandler(DuplicateKeyException.class)
|
||||
public R handleDuplicateKeyException(DuplicateKeyException e){
|
||||
logger.error(e.getMessage(), e);
|
||||
return R.error("数据库中已存在该记录");
|
||||
}
|
||||
|
||||
@ExceptionHandler(AuthorizationException.class)
|
||||
public R handleAuthorizationException(AuthorizationException e){
|
||||
logger.error(e.getMessage(), e);
|
||||
return R.error("没有权限,请联系管理员授权");
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public R handleException(Exception e){
|
||||
logger.error(e.getMessage(), e);
|
||||
return R.error();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.zcloud.common.handler;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
@Component
|
||||
public class MultipartJackson2HttpMessageConverter extends AbstractJackson2HttpMessageConverter {
|
||||
|
||||
/**
|
||||
* Converter for support http request with header Content-Type: multipart/form-data
|
||||
*/
|
||||
public MultipartJackson2HttpMessageConverter(ObjectMapper objectMapper) {
|
||||
super(objectMapper, MediaType.APPLICATION_OCTET_STREAM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWrite(Type type, Class<?> clazz, MediaType mediaType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWrite(Class<?> clazz, MediaType mediaType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canWrite(MediaType mediaType) {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.zcloud.common.handler;
|
||||
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import com.zcloud.common.utils.DateUtil;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Component
|
||||
public class MyMetaObjectHandler implements MetaObjectHandler {
|
||||
|
||||
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
this.setFieldValByName("isDelete", 0, metaObject);
|
||||
this.setFieldValByName("createTime", DateUtil.date2Str(new Date()), metaObject);
|
||||
this.setFieldValByName("operatTime", DateUtil.date2Str(new Date()), metaObject);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
this.setFieldValByName("operatTime", DateUtil.date2Str(new Date()), metaObject);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,127 @@
|
|||
package com.zcloud.common.handler;
|
||||
|
||||
import cn.hutool.log.Log;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zcloud.common.utils.HttpRequestUtil;
|
||||
import com.zcloud.common.utils.MD5;
|
||||
import com.zcloud.common.utils.PageUtils;
|
||||
import com.zcloud.common.utils.R;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author fangjiakai
|
||||
* @date 2023/10/19 10:44
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "customer")
|
||||
@Component
|
||||
public class PlatVideoHandler {
|
||||
private String id;
|
||||
private String secret_key;
|
||||
private String url;
|
||||
private String domain;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getSecret_key() {
|
||||
return secret_key;
|
||||
}
|
||||
|
||||
public void setSecret_key(String secret_key) {
|
||||
this.secret_key = secret_key;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
public void setDomain(String domain) {
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
public PageUtils syncCurList(Map<String, Object> params) {
|
||||
HashMap<String, String> request = new HashMap<>();
|
||||
request.put("id", id);
|
||||
String key = MD5.md5(secret_key + domain);
|
||||
request.put("SECRET_KEY", key);
|
||||
if(params.get("name")!=null) request.put("KEYWORDS", params.get("name").toString());
|
||||
request.put("showCount", params.get("limit").toString());
|
||||
request.put("currentPage", params.get("curPage").toString());
|
||||
String _response = HttpRequestUtil.doPost(url + "/curriculum/getCurList", JSONObject.toJSONString(request));
|
||||
JSONObject responseResult = JSONObject.parseObject(_response);
|
||||
System.out.println(responseResult);
|
||||
Page page = new Page();
|
||||
page.setRecords(responseResult.getJSONArray("curriculumList"));
|
||||
page.setTotal(Long.parseLong(responseResult.getJSONObject("page").getString("totalResult")));
|
||||
page.setSize(Long.parseLong(params.get("limit").toString()));
|
||||
page.setCurrent(Long.parseLong(responseResult.getJSONObject("page").getString("currentPage")));
|
||||
page.setPages(Long.parseLong(responseResult.getJSONObject("page").getString("totalPage")));
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
public JSONObject syncCurInfo(Map<String, Object> params) {
|
||||
HashMap<String, String> request = new HashMap<>();
|
||||
request.put("CURRICULUM_ID", params.get("curriculum_id").toString());
|
||||
request.put("id", id);
|
||||
String key = MD5.md5(secret_key + domain);
|
||||
request.put("SECRET_KEY", key);
|
||||
String _response = HttpRequestUtil.doPost(url + "/curriculum/getCurInfo", JSONObject.toJSONString(request));
|
||||
JSONObject responseResult = JSONObject.parseObject(_response);
|
||||
System.out.println(responseResult);
|
||||
if(responseResult != null && responseResult.get("code") != null && StringUtils.isNotBlank(responseResult.get("code").toString()) && "0".equals(responseResult.get("code"))){
|
||||
return responseResult;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public R syncVideoPlayAuth(Map<String, Object> video) {
|
||||
HashMap<String, String> request = new HashMap<>();
|
||||
request.put("id", this.id);
|
||||
request.put("videoId", video.get("video_id_remote").toString());
|
||||
request.put("curriculumId", video.get("curriculum_id_remote").toString());
|
||||
request.put("type", "0");
|
||||
String key = MD5.md5(secret_key + domain);
|
||||
request.put("SECRET_KEY", key);
|
||||
String _response = HttpRequestUtil.doPost(url + "/videoCourseware/getPlayInfo", JSONObject.toJSONString(request));
|
||||
Map response = JSONObject.parseObject(_response, Map.class);
|
||||
return R.ok().put("responseBody",response);
|
||||
}
|
||||
|
||||
/**
|
||||
* description: 获取视频封面<p/>
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public Map syncVideoInfo(Map video) {
|
||||
HashMap<String, String> request = new HashMap<>();
|
||||
request.put("id", id);
|
||||
request.put("videoId", video.get("videocourseware_id_remote").toString());
|
||||
request.put("curriculumId", video.get("curriculum_id_remote").toString());
|
||||
request.put("type", "0");
|
||||
String key = MD5.md5(secret_key + domain);
|
||||
request.put("SECRET_KEY", key);
|
||||
String _response = HttpRequestUtil.doPost(url + "/videoCourseware/getPlayUrl", JSONObject.toJSONString(request));
|
||||
Map response = JSONObject.parseObject(_response, Map.class);
|
||||
return response;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,152 @@
|
|||
package com.zcloud.common.utils;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import sun.misc.BASE64Decoder;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.KeyGenerator;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* AES的加密和解密
|
||||
* @author libo
|
||||
*/
|
||||
public class AesEncryptor {
|
||||
//密钥 (需要前端和后端保持一致)
|
||||
// private static final String KEY = "qwertyuiqwertyui";
|
||||
private static final String KEY = "daac3ae52eff4cec";
|
||||
//算法
|
||||
private static final String ALGORITHMSTR = "AES/ECB/PKCS5Padding";
|
||||
|
||||
/**
|
||||
* aes解密
|
||||
* @param encrypt 内容
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String aesDecrypt(String encrypt) {
|
||||
try {
|
||||
return aesDecrypt(encrypt, KEY);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* aes加密
|
||||
* @param content
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String aesEncrypt(String content) {
|
||||
try {
|
||||
return aesEncrypt(content, KEY);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将byte[]转为各种进制的字符串
|
||||
* @param bytes byte[]
|
||||
* @param radix 可以转换进制的范围,从Character.MIN_RADIX到Character.MAX_RADIX,超出范围后变为10进制
|
||||
* @return 转换后的字符串
|
||||
*/
|
||||
public static String binary(byte[] bytes, int radix){
|
||||
return new BigInteger(1, bytes).toString(radix);// 这里的1代表正数
|
||||
}
|
||||
|
||||
/**
|
||||
* base 64 encode
|
||||
* @param bytes 待编码的byte[]
|
||||
* @return 编码后的base 64 code
|
||||
*/
|
||||
public static String base64Encode(byte[] bytes){
|
||||
return Base64.encodeBase64String(bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* base 64 decode
|
||||
* @param base64Code 待解码的base 64 code
|
||||
* @return 解码后的byte[]
|
||||
* @throws Exception
|
||||
*/
|
||||
public static byte[] base64Decode(String base64Code) throws Exception{
|
||||
return StringUtils.isEmpty(base64Code) ? null : new BASE64Decoder().decodeBuffer(base64Code);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* AES加密
|
||||
* @param content 待加密的内容
|
||||
* @param encryptKey 加密密钥
|
||||
* @return 加密后的byte[]
|
||||
* @throws Exception
|
||||
*/
|
||||
public static byte[] aesEncryptToBytes(String content, String encryptKey) throws Exception {
|
||||
KeyGenerator kgen = KeyGenerator.getInstance("AES");
|
||||
kgen.init(128);
|
||||
Cipher cipher = Cipher.getInstance(ALGORITHMSTR);
|
||||
cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(encryptKey.getBytes(), "AES"));
|
||||
|
||||
return cipher.doFinal(content.getBytes("utf-8"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* AES加密为base 64 code
|
||||
* @param content 待加密的内容
|
||||
* @param encryptKey 加密密钥
|
||||
* @return 加密后的base 64 code
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String aesEncrypt(String content, String encryptKey) throws Exception {
|
||||
return base64Encode(aesEncryptToBytes(content, encryptKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* AES解密
|
||||
* @param encryptBytes 待解密的byte[]
|
||||
* @param decryptKey 解密密钥
|
||||
* @return 解密后的String
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String aesDecryptByBytes(byte[] encryptBytes, String decryptKey) throws Exception {
|
||||
KeyGenerator kgen = KeyGenerator.getInstance("AES");
|
||||
kgen.init(128);
|
||||
|
||||
Cipher cipher = Cipher.getInstance(ALGORITHMSTR);
|
||||
cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(decryptKey.getBytes(), "AES"));
|
||||
byte[] decryptBytes = cipher.doFinal(encryptBytes);
|
||||
return new String(decryptBytes);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将base 64 code AES解密
|
||||
* @param encryptStr 待解密的base 64 code
|
||||
* @param decryptKey 解密密钥
|
||||
* @return 解密后的string
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String aesDecrypt(String encryptStr, String decryptKey) throws Exception {
|
||||
return StringUtils.isEmpty(encryptStr) ? null : aesDecryptByBytes(base64Decode(encryptStr), decryptKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
String content = "123";
|
||||
System.out.println("加密前:" + content);
|
||||
System.out.println("加密密钥和解密密钥:" + KEY);
|
||||
String encrypt = aesEncrypt(content, KEY);
|
||||
System.out.println("加密后:" + encrypt);
|
||||
String decrypt = aesDecrypt(encrypt, KEY);
|
||||
System.out.println("解密后:" + decrypt);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,142 @@
|
|||
package com.zcloud.common.utils;
|
||||
|
||||
import org.apache.shiro.codec.Base64;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* BASE64编码解码工具包
|
||||
* </p>
|
||||
*/
|
||||
public class Base64Utils {
|
||||
|
||||
/** */
|
||||
/**
|
||||
* 文件读取缓冲区大小
|
||||
*/
|
||||
private static final int CACHE_SIZE = 1024;
|
||||
|
||||
/** */
|
||||
/**
|
||||
* <p>
|
||||
* BASE64字符串解码为二进制数据
|
||||
* </p>
|
||||
*
|
||||
* @param base64
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static byte[] decode(String base64) throws Exception {
|
||||
return Base64.decode(base64.getBytes());
|
||||
}
|
||||
|
||||
/** */
|
||||
/**
|
||||
* <p>
|
||||
* 二进制数据编码为BASE64字符串
|
||||
* </p>
|
||||
*
|
||||
* @param bytes
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String encode(byte[] bytes) throws Exception {
|
||||
return new String(Base64.encode(bytes));
|
||||
}
|
||||
|
||||
/** */
|
||||
/**
|
||||
* <p>
|
||||
* 将文件编码为BASE64字符串
|
||||
* </p>
|
||||
* <p>
|
||||
* 大文件慎用,可能会导致内存溢出
|
||||
* </p>
|
||||
*
|
||||
* @param filePath
|
||||
* 文件绝对路径
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String encodeFile(String filePath) throws Exception {
|
||||
byte[] bytes = fileToByte(filePath);
|
||||
return encode(bytes);
|
||||
}
|
||||
|
||||
/** */
|
||||
/**
|
||||
* <p>
|
||||
* BASE64字符串转回文件
|
||||
* </p>
|
||||
*
|
||||
* @param filePath
|
||||
* 文件绝对路径
|
||||
* @param base64
|
||||
* 编码字符串
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void decodeToFile(String filePath, String base64) throws Exception {
|
||||
byte[] bytes = decode(base64);
|
||||
byteArrayToFile(bytes, filePath);
|
||||
}
|
||||
|
||||
/** */
|
||||
/**
|
||||
* <p>
|
||||
* 文件转换为二进制数组
|
||||
* </p>
|
||||
*
|
||||
* @param filePath
|
||||
* 文件路径
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static byte[] fileToByte(String filePath) throws Exception {
|
||||
byte[] data = new byte[0];
|
||||
File file = new File(filePath);
|
||||
if (file.exists()) {
|
||||
FileInputStream in = new FileInputStream(file);
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream(2048);
|
||||
byte[] cache = new byte[CACHE_SIZE];
|
||||
int nRead = 0;
|
||||
while ((nRead = in.read(cache)) != -1) {
|
||||
out.write(cache, 0, nRead);
|
||||
out.flush();
|
||||
}
|
||||
out.close();
|
||||
in.close();
|
||||
data = out.toByteArray();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/** */
|
||||
/**
|
||||
* <p>
|
||||
* 二进制数据写文件
|
||||
* </p>
|
||||
*
|
||||
* @param bytes
|
||||
* 二进制数据
|
||||
* @param filePath
|
||||
* 文件生成目录
|
||||
*/
|
||||
public static void byteArrayToFile(byte[] bytes, String filePath) throws Exception {
|
||||
InputStream in = new ByteArrayInputStream(bytes);
|
||||
File destFile = new File(filePath);
|
||||
if (!destFile.getParentFile().exists()) {
|
||||
destFile.getParentFile().mkdirs();
|
||||
}
|
||||
destFile.createNewFile();
|
||||
OutputStream out = new FileOutputStream(destFile);
|
||||
byte[] cache = new byte[CACHE_SIZE];
|
||||
int nRead = 0;
|
||||
while ((nRead = in.read(cache)) != -1) {
|
||||
out.write(cache, 0, nRead);
|
||||
out.flush();
|
||||
}
|
||||
out.close();
|
||||
in.close();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package com.zcloud.common.utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class CamelCaseUtil {
|
||||
|
||||
public static <V> Map<String, V> camelToUnderline(Map<String, V> sourceMap) {
|
||||
Map<String, V> targetMap = new HashMap<>();
|
||||
for (Map.Entry<String, V> entry : sourceMap.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String newKey = camelToUnderline(key);
|
||||
targetMap.put(newKey, entry.getValue());
|
||||
}
|
||||
return targetMap;
|
||||
}
|
||||
|
||||
private static String camelToUnderline(String camelCase) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < camelCase.length(); i++) {
|
||||
char c = camelCase.charAt(i);
|
||||
if (Character.isUpperCase(c)) {
|
||||
sb.append("_").append(Character.toLowerCase(c));
|
||||
} else {
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Map<String, String> sourceMap = new HashMap<>();
|
||||
sourceMap.put("helloWorld", "value1");
|
||||
sourceMap.put("exampleKey", "value2");
|
||||
Map<String, String> targetMap = camelToUnderline(sourceMap);
|
||||
System.out.println(targetMap); // 输出: {hello_world=value1, example_key=value2}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.zcloud.common.utils;
|
||||
|
||||
/**
|
||||
* 系统参数相关Key
|
||||
*
|
||||
*/
|
||||
public class ConfigConstant {
|
||||
/**
|
||||
* 云存储配置KEY
|
||||
*/
|
||||
public final static String CLOUD_STORAGE_CONFIG_KEY = "CLOUD_STORAGE_CONFIG_KEY";
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package com.zcloud.common.utils;
|
||||
|
||||
/**
|
||||
* 说明:常量
|
||||
* 作者:luoxiaobao
|
||||
* 官网:www.qdkjchina.com
|
||||
*/
|
||||
public class Const {
|
||||
|
||||
public static final String SESSION_USER = "SESSION_USER"; //session用的用户
|
||||
public static final String SESSION_USERROL = "SESSION_USERROL"; //用户对象(包含角色信息)
|
||||
public static final String SESSION_ROLE_RIGHTS = "SESSION_ROLE_RIGHTS"; //角色菜单权限
|
||||
public static final String SHIROSET = "SHIROSET"; //菜单权限标识
|
||||
public static final String SESSION_USERNAME = "USERNAME"; //用户名
|
||||
public static final String SESSION_U_NAME = "SESSION_U_NAME"; //用户姓名
|
||||
public static final String SESSION_ROLE = "SESSION_ROLE"; //主职角色信息
|
||||
public static final String SESSION_RNUMBERS = "RNUMBERS"; //角色编码数组
|
||||
public static final String SESSION_ALLMENU = "SESSION_ALLMENU"; //全部菜单
|
||||
public static final String SKIN = "SKIN"; //用户皮肤
|
||||
|
||||
public static final String SYSSET = "config/sysSet.ini"; //系统设置配置文件路径
|
||||
public static final String SYSNAME = "sysName"; //系统名称
|
||||
public static final String SHOWCOUNT = "showCount"; //每页条数
|
||||
|
||||
public static final String FILEPATHFILE = "/uploadFiles/file/"; //文件上传路径
|
||||
public static final String BIFILEPATHFILE = "/uploadFiles/Bfile/"; //文件上传路径
|
||||
public static final String FILEPATHIMG = "/uploadFiles/imgs/"; //图片上传路径
|
||||
public static final String FILEPATHIMGSPECIAL = "/uploadFiles/imgs/special/"; //图片上传路径(特种装备)
|
||||
public static final String FILEPATHDZJM = "/uploadFiles/dzjm/"; //图片上传路径
|
||||
public static final String FILEPATHYHTP = "/uploadFiles/yhtp/"; //图片上传路径
|
||||
public static final String FILEPATHFXSST = "/uploadFiles/fxsst/"; //图片上传路径 风险四色图
|
||||
|
||||
public static final String FILEACTIVITI = "/uploadFiles/activitiFile/"; //工作流生成XML和PNG目录
|
||||
|
||||
public static final String DEPARTMENT_IDS = "DEPARTMENT_IDS"; //当前用户拥有的最高部门权限集合
|
||||
public static final String DEPARTMENT_ID = "DEPARTMENT_ID"; //当前用户拥有的最高部门权限
|
||||
public static final String CORPINFO_ID = "CORPINFO_ID"; //当前用户所属企业
|
||||
public static final String POST_ID = "POST_ID"; //当前用户所属企业
|
||||
public static final String PRECINCT_ID = "PRECINCT_ID"; //当前用户拥有的最高部门权限
|
||||
public static final String USER_ID = "USER_ID"; //当前用户userid
|
||||
public static final String IS_MAIN = "IS_MAIN"; //是否主账号
|
||||
public static final String ISSUPERVISE = "ISSUPERVISE"; //是否监管部门
|
||||
|
||||
|
||||
public static final String FILEURL = "/mnt/qyag/file/"; //文件服务器地址
|
||||
public static final String HTTPFILEURL = "https://qyag.zcloudchina.com/file/"; //文件服务器地址
|
||||
|
||||
|
||||
public final static String APPID = "wx9199de454d31b016";
|
||||
public final static String SECRET = "183cdcac380e1f98f00c793491e27d88";
|
||||
public static final String XCX_MCH_ID = "1607757714";
|
||||
public static final String XCX_KEY = "zhuoyunkeji88888zhuoyunkeji88888";
|
||||
|
||||
public final static String OA_APPID = "wx69f7e25b3760001c";//公众号
|
||||
public final static String OA_SECRET = "087fe91f660300df63d0ef16fd162124";//公众号
|
||||
public static final String CORP_TRAINTYPE = "CORP_TRAINTYPE"; //当前用户所属企业的培训行业类型
|
||||
|
||||
|
||||
public static final String ALI_ACCESSKEY = "LTAI5tK134ZzXPEwykAdpVn2"; // 阿里云视频点播ak
|
||||
public static final String ALI_ACCESSKEY_SECRET = "XCEMY8FG52cXImFMeIiH4tDJ9BIN3N"; //阿里云视频点播sk
|
||||
//public static final String ALI_TEMPLATEGROUPID = "8666384eef7d52b290ba661d5e2684ab"; //阿里云视频转码模板id
|
||||
public static final String ALI_TEMPLATEGROUPID = "eda7780b4706ec92ea47a79b6e6bcad1"; // 阿里云视频转码模板id
|
||||
public static final String ALIYUN_REGIONID = "cn-beijing"; // 点播服务接入地域
|
||||
public static final String ENDPOINT = "vod.cn-beijing.aliyuncs.com";// 访问的域名
|
||||
|
||||
// 试题导入模板地址
|
||||
public static final String QUESTION_EXCEL_URL = "https://file.zcloudchina.com/busTripFile/template/questionExcelTemplate.xls";
|
||||
// 平台课件默认封面地址
|
||||
public static final String COURSEWARE_URL = "https://file.zcloudchina.com/knowledgeFile/template/courseware.png";
|
||||
|
||||
public static final String FILE_URL = "http://60.2.209.238:8991/file/";
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
package com.zcloud.common.utils;
|
||||
|
||||
import com.zcloud.common.validator.group.AliyunGroup;
|
||||
import com.zcloud.common.validator.group.QcloudGroup;
|
||||
import com.zcloud.common.validator.group.QiniuGroup;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 常量
|
||||
*/
|
||||
public class Constant {
|
||||
/**
|
||||
* 当前页码
|
||||
*/
|
||||
public static final String PAGE = "curPage";
|
||||
/**
|
||||
* 每页显示记录数
|
||||
*/
|
||||
public static final String LIMIT = "limit";
|
||||
/**
|
||||
* 排序字段
|
||||
*/
|
||||
public static final String ORDER_FIELD = "sidx";
|
||||
/**
|
||||
* 排序方式
|
||||
*/
|
||||
public static final String ORDER = "order";
|
||||
/**
|
||||
* 升序
|
||||
*/
|
||||
public static final String ASC = "asc";
|
||||
|
||||
/**
|
||||
* 菜单类型
|
||||
*
|
||||
* @author chenshun
|
||||
* @email sunlightcs@gmail.com
|
||||
* @date 2016年11月15日 下午1:24:29
|
||||
*/
|
||||
public enum MenuType {
|
||||
/**
|
||||
* 目录
|
||||
*/
|
||||
CATALOG(0),
|
||||
/**
|
||||
* 菜单
|
||||
*/
|
||||
MENU(1),
|
||||
/**
|
||||
* 按钮
|
||||
*/
|
||||
BUTTON(2);
|
||||
|
||||
private int value;
|
||||
|
||||
MenuType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时任务状态
|
||||
*
|
||||
* @author chenshun
|
||||
* @email sunlightcs@gmail.com
|
||||
* @date 2016年12月3日 上午12:07:22
|
||||
*/
|
||||
public enum ScheduleStatus {
|
||||
/**
|
||||
* 正常
|
||||
*/
|
||||
NORMAL(0),
|
||||
/**
|
||||
* 暂停
|
||||
*/
|
||||
PAUSE(1);
|
||||
|
||||
private int value;
|
||||
|
||||
ScheduleStatus(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 云服务商
|
||||
*/
|
||||
public enum CloudService {
|
||||
/**
|
||||
* 七牛云
|
||||
*/
|
||||
QINIU(1, QiniuGroup.class),
|
||||
/**
|
||||
* 阿里云
|
||||
*/
|
||||
ALIYUN(2, AliyunGroup.class),
|
||||
/**
|
||||
* 腾讯云
|
||||
*/
|
||||
QCLOUD(3, QcloudGroup.class);
|
||||
|
||||
private int value;
|
||||
|
||||
private Class<?> validatorGroupClass;
|
||||
|
||||
CloudService(int value, Class<?> validatorGroupClass) {
|
||||
this.value = value;
|
||||
this.validatorGroupClass = validatorGroupClass;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Class<?> getValidatorGroupClass() {
|
||||
return this.validatorGroupClass;
|
||||
}
|
||||
|
||||
public static CloudService getByValue(Integer value) {
|
||||
Optional<CloudService> first = Stream.of(CloudService.values()).filter(cs -> value.equals(cs.value)).findFirst();
|
||||
if (!first.isPresent()) {
|
||||
throw new IllegalArgumentException("非法的枚举值:" + value);
|
||||
}
|
||||
return first.get();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,444 @@
|
|||
package com.zcloud.common.utils;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 说明:日期处理
|
||||
* 作者:luoxiaobao
|
||||
* 官网:www.qdkjchina.com
|
||||
*/
|
||||
public class DateUtil {
|
||||
|
||||
private final static SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy");
|
||||
private final static SimpleDateFormat sdfDay = new SimpleDateFormat("yyyy-MM-dd");
|
||||
private final static SimpleDateFormat sdfYearMonth = new SimpleDateFormat("yyyy-MM");
|
||||
private final static SimpleDateFormat sdfDays = new SimpleDateFormat("yyyyMMdd");
|
||||
private final static SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
private final static SimpleDateFormat sdfTimes = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
|
||||
/**
|
||||
* 获取YYYY格式
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getSdfTimes() {
|
||||
return sdfTimes.format(new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取YYYY格式
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getYear() {
|
||||
return sdfYear.format(new Date());
|
||||
}
|
||||
|
||||
public static String getYear(Date date) {
|
||||
return sdfYear.format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取YYYY-MM-DD格式
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getDay() {
|
||||
return sdfDay.format(new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取YYYY-MM格式
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getYearMonth(Date date) {
|
||||
return sdfYearMonth.format(date);
|
||||
}
|
||||
|
||||
// 获取季度数字
|
||||
public static int getYearQuarter(Date date) {
|
||||
return Integer.parseInt(sdfYearMonth.format(date).substring(5, 7)) / 3 + 1;
|
||||
}
|
||||
|
||||
//获取月份数字
|
||||
public static int getMonth(Date date) {
|
||||
return Integer.parseInt(sdfDay.format(date).substring(5, 7));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取YYYYMMDD格式
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getDays() {
|
||||
return sdfDays.format(new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取YYYY-MM-DD HH:mm:ss格式
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getTime() {
|
||||
return sdfTime.format(new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param s
|
||||
* @param e
|
||||
* @return boolean
|
||||
* @throws
|
||||
* @Title: compareDate
|
||||
* @Description: TODO(日期比较 , 如果s > = e 返回true 否则返回false)
|
||||
* @author fh
|
||||
*/
|
||||
public static boolean compareDate(String s, String e) {
|
||||
if (fomatDate(s) == null || fomatDate(e) == null) {
|
||||
return false;
|
||||
}
|
||||
return fomatDate(s).getTime() >= fomatDate(e).getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化日期
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Date fomatDate(String date) {
|
||||
DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
|
||||
try {
|
||||
return fmt.parse(date);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验日期是否合法
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static boolean isValidDate(String s) {
|
||||
DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
|
||||
try {
|
||||
fmt.parse(s);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false; // 如果throw java.text.ParseException或者NullPointerException,就说明格式不对
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
public static int getDiffYear(String startTime, String endTime) {
|
||||
DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
|
||||
try {
|
||||
int years = (int) (((fmt.parse(endTime).getTime() - fmt.parse(startTime).getTime()) / (1000 * 60 * 60 * 24)) / 365);
|
||||
return years;
|
||||
} catch (Exception e) {
|
||||
return 0; // 如果throw java.text.ParseException或者NullPointerException,就说明格式不对
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <li>功能描述:时间相减得到天数
|
||||
*
|
||||
* @param beginDateStr
|
||||
* @param endDateStr
|
||||
* @return long
|
||||
* @author Administrator
|
||||
*/
|
||||
public static long getDaySub(String beginDateStr, String endDateStr) {
|
||||
long day = 0;
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date beginDate = null;
|
||||
Date endDate = null;
|
||||
try {
|
||||
beginDate = format.parse(beginDateStr);
|
||||
endDate = format.parse(endDateStr);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
day = (endDate.getTime() - beginDate.getTime()) / (24 * 60 * 60 * 1000);
|
||||
//System.out.println("相隔的天数="+day);
|
||||
return day;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到n天之后的日期
|
||||
*
|
||||
* @param days
|
||||
* @return
|
||||
*/
|
||||
public static String getAfterDayDate(String days) {
|
||||
int daysInt = Integer.parseInt(days);
|
||||
Calendar canlendar = Calendar.getInstance(); // java.util包
|
||||
canlendar.add(Calendar.DATE, daysInt); // 日期减 如果不够减会将月变动
|
||||
Date date = canlendar.getTime();
|
||||
SimpleDateFormat sdfd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String dateStr = sdfd.format(date);
|
||||
return dateStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到n天之后是周几
|
||||
*
|
||||
* @param days
|
||||
* @return
|
||||
*/
|
||||
public static String getAfterDayWeek(String days) {
|
||||
int daysInt = Integer.parseInt(days);
|
||||
Calendar canlendar = Calendar.getInstance(); // java.util包
|
||||
canlendar.add(Calendar.DATE, daysInt); // 日期减 如果不够减会将月变动
|
||||
Date date = canlendar.getTime();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("E");
|
||||
String dateStr = sdf.format(date);
|
||||
return dateStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按照yyyy-MM-dd HH:mm:ss的格式,日期转字符串
|
||||
*
|
||||
* @param date
|
||||
* @return yyyy-MM-dd HH:mm:ss
|
||||
*/
|
||||
public static String date2Str(Date date) {
|
||||
return date2Str(date, "yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
|
||||
/**
|
||||
* 按照yyyy-MM-dd HH:mm:ss的格式,字符串转日期
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
public static Date str2Date(String date) {
|
||||
if (StringUtils.isNotBlank(date)) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
try {
|
||||
return sdf.parse(date);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new Date();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 把时间根据时、分、秒转换为时间段
|
||||
*
|
||||
* @param StrDate
|
||||
*/
|
||||
public static String getTimes(String StrDate) {
|
||||
String resultTimes = "";
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date now;
|
||||
try {
|
||||
now = new Date();
|
||||
Date date = df.parse(StrDate);
|
||||
long times = now.getTime() - date.getTime();
|
||||
long day = times / (24 * 60 * 60 * 1000);
|
||||
long hour = (times / (60 * 60 * 1000) - day * 24);
|
||||
long min = ((times / (60 * 1000)) - day * 24 * 60 - hour * 60);
|
||||
long sec = (times / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60);
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
//sb.append("发表于:");
|
||||
if (hour > 0) {
|
||||
sb.append(hour + "小时前");
|
||||
} else if (min > 0) {
|
||||
sb.append(min + "分钟前");
|
||||
} else {
|
||||
sb.append(sec + "秒前");
|
||||
}
|
||||
resultTimes = sb.toString();
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return resultTimes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按照参数format的格式,日期转字符串
|
||||
*
|
||||
* @param date
|
||||
* @param format
|
||||
* @return
|
||||
*/
|
||||
public static String date2Str(Date date, String format) {
|
||||
if (date != null) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(format);
|
||||
return sdf.format(date);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当年的第一天
|
||||
*
|
||||
* @param year
|
||||
* @return
|
||||
* @author zhangyue
|
||||
*/
|
||||
public static String getCurrYearFirst() {
|
||||
Calendar currCal = Calendar.getInstance();
|
||||
int currentYear = currCal.get(Calendar.YEAR);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.clear();
|
||||
calendar.set(Calendar.YEAR, currentYear);
|
||||
Date currYearFirst = calendar.getTime();
|
||||
return sdfDay.format(currYearFirst);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当年的最后一天
|
||||
*
|
||||
* @param year
|
||||
* @return
|
||||
* @author zhangyue
|
||||
*/
|
||||
public static String getCurrYearLast() {
|
||||
Calendar currCal = Calendar.getInstance();
|
||||
int currentYear = currCal.get(Calendar.YEAR);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.clear();
|
||||
calendar.set(Calendar.YEAR, currentYear);
|
||||
calendar.roll(Calendar.DAY_OF_YEAR, -1);
|
||||
Date currYearLast = calendar.getTime();
|
||||
return sdfDay.format(currYearLast);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取当前季度第一天
|
||||
*
|
||||
* @return
|
||||
* @author zhangyue
|
||||
*/
|
||||
public static String quarterStart() {
|
||||
Date dBegin = new Date();
|
||||
Calendar calBegin = Calendar.getInstance();
|
||||
calBegin.setTime(dBegin);
|
||||
int remainder = calBegin.get(Calendar.MONTH) % 3;
|
||||
int month = remainder != 0 ? calBegin.get(Calendar.MONTH) - remainder : calBegin.get(Calendar.MONTH);
|
||||
|
||||
calBegin.set(Calendar.MONTH, month);
|
||||
calBegin.set(Calendar.DAY_OF_MONTH, calBegin.getActualMinimum(Calendar.DAY_OF_MONTH));
|
||||
|
||||
calBegin.setTime(calBegin.getTime());
|
||||
return sdfDay.format(calBegin.getTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前季度最后一天
|
||||
*
|
||||
* @return
|
||||
* @author zhangyue
|
||||
*/
|
||||
public static String quarterEnd() {
|
||||
Date dEnd = new Date();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(dEnd);
|
||||
int remainder = (calendar.get(Calendar.MONTH) + 1) % 3;
|
||||
int month = remainder != 0 ? calendar.get(Calendar.MONTH) + (3 - remainder) : calendar.get(Calendar.MONTH);
|
||||
calendar.set(Calendar.MONTH, month);
|
||||
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
|
||||
calendar.setTime(calendar.getTime());
|
||||
return sdfDay.format(calendar.getTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取本月第一天日期
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getMonthFirstDay() {
|
||||
Calendar thisMonthFirstDateCal = Calendar.getInstance();
|
||||
thisMonthFirstDateCal.set(Calendar.DAY_OF_MONTH, 1);
|
||||
String thisMonthFirstTime = sdfDay.format(thisMonthFirstDateCal.getTime());
|
||||
return thisMonthFirstTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取本月最后一天日期
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getMonthEndDay() {
|
||||
Calendar thisMonthEndDateCal = Calendar.getInstance();
|
||||
thisMonthEndDateCal.set(Calendar.DAY_OF_MONTH, thisMonthEndDateCal.getActualMaximum(Calendar.DAY_OF_MONTH));
|
||||
String thisMonthEndTime = sdfDay.format(thisMonthEndDateCal.getTime());
|
||||
return thisMonthEndTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断两个日期字符串是否相差半年或半年的倍数。
|
||||
*
|
||||
* @param dateStr1 第一个日期字符串
|
||||
* @param dateStr2 第二个日期字符串
|
||||
* @param formatter 日期格式
|
||||
* @return 如果两个日期相差半年或半年的倍数,返回true,否则返回false。
|
||||
*/
|
||||
public static boolean isHalfYearApart(String dateStr1, String dateStr2, DateTimeFormatter formatter) {
|
||||
LocalDate date1 = LocalDate.parse(dateStr1, formatter);
|
||||
LocalDate date2 = LocalDate.parse(dateStr2, formatter);
|
||||
|
||||
long monthsBetween = ChronoUnit.MONTHS.between(date1, date2);
|
||||
return monthsBetween % 6 == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 给定一个日期,增加半年。
|
||||
*
|
||||
* @param dateStr 需要增加半年的日期
|
||||
* @param formatter 日期格式
|
||||
* @return 增加半年后的日期
|
||||
*/
|
||||
public static String addHalfYear(String dateStr, DateTimeFormatter formatter) {
|
||||
LocalDate date = LocalDate.parse(dateStr, formatter);
|
||||
LocalDate newDate = date.plus(Period.ofMonths(6));
|
||||
return newDate.format(formatter);
|
||||
}
|
||||
|
||||
/**
|
||||
* 给定一个日期,减n个月。
|
||||
*
|
||||
* @param date 需要计算的日期
|
||||
* @param n 月数
|
||||
* @return 增加半年后的日期
|
||||
*/
|
||||
public static Date getLastMonth(Date date,int n) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.MONTH, -n);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
String dateStr1 = "2023-09-01";
|
||||
String dateStr2 = "2024-03-01";
|
||||
Date newDateStr = getLastMonth(fomatDate(dateStr1), 12);
|
||||
System.out.println(newDateStr);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,160 @@
|
|||
|
||||
|
||||
package com.zcloud.common.utils;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.joda.time.format.DateTimeFormat;
|
||||
import org.joda.time.format.DateTimeFormatter;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 日期处理
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class DateUtils {
|
||||
/** 时间格式(yyyy-MM-dd) */
|
||||
public final static String DATE_PATTERN = "yyyy-MM-dd";
|
||||
/** 时间格式(yyyy-MM-dd HH:mm:ss) */
|
||||
public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
/**
|
||||
* 日期格式化 日期格式为:yyyy-MM-dd
|
||||
* @param date 日期
|
||||
* @return 返回yyyy-MM-dd格式日期
|
||||
*/
|
||||
public static String format(Date date) {
|
||||
return format(date, DATE_PATTERN);
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期格式化 日期格式为:yyyy-MM-dd
|
||||
* @param date 日期
|
||||
* @param pattern 格式,如:DateUtils.DATE_TIME_PATTERN
|
||||
* @return 返回yyyy-MM-dd格式日期
|
||||
*/
|
||||
public static String format(Date date, String pattern) {
|
||||
if(date != null){
|
||||
SimpleDateFormat df = new SimpleDateFormat(pattern);
|
||||
return df.format(date);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转换成日期
|
||||
* @param strDate 日期字符串
|
||||
* @param pattern 日期的格式,如:DateUtils.DATE_TIME_PATTERN
|
||||
*/
|
||||
public static Date stringToDate(String strDate, String pattern) {
|
||||
if (StringUtils.isBlank(strDate)){
|
||||
return null;
|
||||
}
|
||||
|
||||
DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern);
|
||||
return fmt.parseLocalDateTime(strDate).toDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据周数,获取开始日期、结束日期
|
||||
* @param week 周期 0本周,-1上周,-2上上周,1下周,2下下周
|
||||
* @return 返回date[0]开始日期、date[1]结束日期
|
||||
*/
|
||||
public static Date[] getWeekStartAndEnd(int week) {
|
||||
DateTime dateTime = new DateTime();
|
||||
LocalDate date = new LocalDate(dateTime.plusWeeks(week));
|
||||
|
||||
date = date.dayOfWeek().withMinimumValue();
|
||||
Date beginDate = date.toDate();
|
||||
Date endDate = date.plusDays(6).toDate();
|
||||
return new Date[]{beginDate, endDate};
|
||||
}
|
||||
|
||||
/**
|
||||
* 对日期的【秒】进行加/减
|
||||
*
|
||||
* @param date 日期
|
||||
* @param seconds 秒数,负数为减
|
||||
* @return 加/减几秒后的日期
|
||||
*/
|
||||
public static Date addDateSeconds(Date date, int seconds) {
|
||||
DateTime dateTime = new DateTime(date);
|
||||
return dateTime.plusSeconds(seconds).toDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对日期的【分钟】进行加/减
|
||||
*
|
||||
* @param date 日期
|
||||
* @param minutes 分钟数,负数为减
|
||||
* @return 加/减几分钟后的日期
|
||||
*/
|
||||
public static Date addDateMinutes(Date date, int minutes) {
|
||||
DateTime dateTime = new DateTime(date);
|
||||
return dateTime.plusMinutes(minutes).toDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对日期的【小时】进行加/减
|
||||
*
|
||||
* @param date 日期
|
||||
* @param hours 小时数,负数为减
|
||||
* @return 加/减几小时后的日期
|
||||
*/
|
||||
public static Date addDateHours(Date date, int hours) {
|
||||
DateTime dateTime = new DateTime(date);
|
||||
return dateTime.plusHours(hours).toDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对日期的【天】进行加/减
|
||||
*
|
||||
* @param date 日期
|
||||
* @param days 天数,负数为减
|
||||
* @return 加/减几天后的日期
|
||||
*/
|
||||
public static Date addDateDays(Date date, int days) {
|
||||
DateTime dateTime = new DateTime(date);
|
||||
return dateTime.plusDays(days).toDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对日期的【周】进行加/减
|
||||
*
|
||||
* @param date 日期
|
||||
* @param weeks 周数,负数为减
|
||||
* @return 加/减几周后的日期
|
||||
*/
|
||||
public static Date addDateWeeks(Date date, int weeks) {
|
||||
DateTime dateTime = new DateTime(date);
|
||||
return dateTime.plusWeeks(weeks).toDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对日期的【月】进行加/减
|
||||
*
|
||||
* @param date 日期
|
||||
* @param months 月数,负数为减
|
||||
* @return 加/减几月后的日期
|
||||
*/
|
||||
public static Date addDateMonths(Date date, int months) {
|
||||
DateTime dateTime = new DateTime(date);
|
||||
return dateTime.plusMonths(months).toDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对日期的【年】进行加/减
|
||||
*
|
||||
* @param date 日期
|
||||
* @param years 年数,负数为减
|
||||
* @return 加/减几年后的日期
|
||||
*/
|
||||
public static Date addDateYears(Date date, int years) {
|
||||
DateTime dateTime = new DateTime(date);
|
||||
return dateTime.plusYears(years).toDate();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
package com.zcloud.common.utils;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* 说明:上传文件
|
||||
|
||||
|
||||
*/
|
||||
public class FileUpload {
|
||||
|
||||
/**上传文件
|
||||
* @param file //文件对象
|
||||
* @param filePath //上传路径
|
||||
* @param fileName //文件名
|
||||
* @return 文件名
|
||||
*/
|
||||
public static String fileUp(MultipartFile file, String filePath, String fileName){
|
||||
String extName = ""; // 扩展名格式:
|
||||
try {
|
||||
if (file.getOriginalFilename().lastIndexOf(".") >= 0){
|
||||
extName = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
||||
}
|
||||
copyFile(file.getInputStream(), filePath, fileName+extName).replaceAll("-", "");
|
||||
} catch (IOException e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
return fileName+extName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 写文件到当前目录的upload目录中
|
||||
* @param in
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String copyFile(InputStream in, String dir, String realName)
|
||||
throws IOException {
|
||||
File file = mkdirsmy(dir,realName);
|
||||
FileUtils.copyInputStreamToFile(in, file);
|
||||
in.close();
|
||||
return realName;
|
||||
}
|
||||
|
||||
|
||||
/**判断路径是否存在,否:创建此路径
|
||||
* @param dir 文件路径
|
||||
* @param realName 文件名
|
||||
* @throws IOException
|
||||
*/
|
||||
public static File mkdirsmy(String dir, String realName) throws IOException{
|
||||
File file = new File(dir, realName);
|
||||
if (!file.exists()) {
|
||||
if (!file.getParentFile().exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
}
|
||||
file.createNewFile();
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
/**下载网络图片上传到服务器上
|
||||
* @param httpUrl 图片网络地址
|
||||
* @param filePath 图片保存路径
|
||||
* @param myFileName 图片文件名(null时用网络图片原名)
|
||||
* @return 返回图片名称
|
||||
*/
|
||||
public static String getHtmlPicture(String httpUrl, String filePath , String myFileName) {
|
||||
|
||||
URL url; //定义URL对象url
|
||||
BufferedInputStream in; //定义输入字节缓冲流对象in
|
||||
FileOutputStream file; //定义文件输出流对象file
|
||||
try {
|
||||
String fileName = null == myFileName?httpUrl.substring(httpUrl.lastIndexOf("/")).replace("/", ""):myFileName; //图片文件名(null时用网络图片原名)
|
||||
url = new URL(httpUrl); //初始化url对象
|
||||
in = new BufferedInputStream(url.openStream()); //初始化in对象,也就是获得url字节流
|
||||
//file = new FileOutputStream(new File(filePath +"\\"+ fileName));
|
||||
file = new FileOutputStream(mkdirsmy(filePath,fileName));
|
||||
int t;
|
||||
while ((t = in.read()) != -1) {
|
||||
file.write(t);
|
||||
}
|
||||
file.close();
|
||||
in.close();
|
||||
return fileName;
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
package com.zcloud.common.utils;
|
||||
|
||||
import com.aliyun.oss.ClientException;
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
import com.aliyun.oss.OSSException;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@Component
|
||||
public class FileUploadUtil {
|
||||
|
||||
private static String endpoint = "https://oss-cn-zhangjiakou.aliyuncs.com";
|
||||
// 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。
|
||||
private static String accessKeyId = "LTAI5tK134ZzXPEwykAdpVn2";
|
||||
private static String accessKeySecret = "XCEMY8FG52cXImFMeIiH4tDJ9BIN3N";
|
||||
// 填写Bucket名称。
|
||||
private static String bucketName = "qyag";
|
||||
|
||||
public static void sshSftp(MultipartFile file, String fileName, String path){
|
||||
String objectName = "reviewReportFile" + path + "/" + fileName;
|
||||
// 填写本地文件的完整路径。如果未指定本地路径,则默认从示例程序所属项目对应本地路径中上传文件。
|
||||
// 创建OSSClient实例。
|
||||
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
||||
|
||||
try {
|
||||
|
||||
// 创建PutObject请求。
|
||||
ossClient.putObject(bucketName, objectName, file.getInputStream());
|
||||
|
||||
// 创建PutObjectRequest对象。
|
||||
// 如果需要上传时设置存储类型和访问权限,请参考以下示例代码。
|
||||
// ObjectMetadata metadata = new ObjectMetadata();
|
||||
// metadata.setHeader(OSSHeaders.OSS_STORAGE_CLASS, StorageClass.Standard.toString());
|
||||
// metadata.setObjectAcl(CannedAccessControlList.Private);
|
||||
// putObjectRequest.setMetadata(metadata);
|
||||
|
||||
// 上传文件。
|
||||
} catch (OSSException oe) {
|
||||
System.out.println("Caught an OSSException, which means your request made it to OSS, "
|
||||
+ "but was rejected with an error response for some reason.");
|
||||
System.out.println("Error Message:" + oe.getErrorMessage());
|
||||
System.out.println("Error Code:" + oe.getErrorCode());
|
||||
System.out.println("Request ID:" + oe.getRequestId());
|
||||
System.out.println("Host ID:" + oe.getHostId());
|
||||
} catch (ClientException ce) {
|
||||
System.out.println("Caught an ClientException, which means the client encountered "
|
||||
+ "a serious internal problem while trying to communicate with OSS, "
|
||||
+ "such as not being able to access the network.");
|
||||
System.out.println("Error Message:" + ce.getMessage());
|
||||
} catch (IOException e) {
|
||||
System.out.println("Error Message:" + e.getMessage());
|
||||
} finally {
|
||||
if (ossClient != null) {
|
||||
ossClient.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
*/
|
||||
public static void deleteFile(String directoryFile) {
|
||||
|
||||
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
||||
|
||||
try {
|
||||
// 删除文件或目录。如果要删除目录,目录必须为空。
|
||||
ossClient.deleteObject(bucketName, "busTripFile" + directoryFile);
|
||||
} catch (OSSException oe) {
|
||||
System.out.println("Caught an OSSException, which means your request made it to OSS, "
|
||||
+ "but was rejected with an error response for some reason.");
|
||||
System.out.println("Error Message:" + oe.getErrorMessage());
|
||||
System.out.println("Error Code:" + oe.getErrorCode());
|
||||
System.out.println("Request ID:" + oe.getRequestId());
|
||||
System.out.println("Host ID:" + oe.getHostId());
|
||||
} catch (ClientException ce) {
|
||||
System.out.println("Caught an ClientException, which means the client encountered "
|
||||
+ "a serious internal problem while trying to communicate with OSS, "
|
||||
+ "such as not being able to access the network.");
|
||||
System.out.println("Error Message:" + ce.getMessage());
|
||||
} finally {
|
||||
if (ossClient != null) {
|
||||
ossClient.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.zcloud.common.utils;
|
||||
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
public class HttpContextUtils {
|
||||
|
||||
public static HttpServletRequest getHttpServletRequest() {
|
||||
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
}
|
||||
|
||||
public static String getDomain(){
|
||||
HttpServletRequest request = getHttpServletRequest();
|
||||
StringBuffer url = request.getRequestURL();
|
||||
return url.delete(url.length() - request.getRequestURI().length(), url.length()).toString();
|
||||
}
|
||||
|
||||
public static String getOrigin(){
|
||||
HttpServletRequest request = getHttpServletRequest();
|
||||
return request.getHeader("Origin");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,223 @@
|
|||
package com.zcloud.common.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
/**
|
||||
* description: http请求工具类
|
||||
*
|
||||
* @date 2022-07-01
|
||||
*/
|
||||
public class HttpRequestUtil {
|
||||
|
||||
public static String sendRequest(String urlParam) throws Exception {
|
||||
InputStream inputStream = null;
|
||||
BufferedReader buffer = null;
|
||||
try {
|
||||
URL url = new URL(urlParam);
|
||||
URLConnection con = url.openConnection();
|
||||
//设置请求需要返回的数据类型和字符集类型
|
||||
con.setRequestProperty("Content-Type", "application/json;charset=GBK");
|
||||
//允许写出
|
||||
con.setDoOutput(true);
|
||||
//允许读入
|
||||
con.setDoInput(true);
|
||||
//不使用缓存
|
||||
con.setUseCaches(false);
|
||||
//得到响应流
|
||||
inputStream = con.getInputStream();
|
||||
//将响应流转换成字符串
|
||||
StringBuffer resultBuffer = new StringBuffer();
|
||||
String line;
|
||||
buffer = new BufferedReader(new InputStreamReader(inputStream, "GBK"));
|
||||
while ((line = buffer.readLine()) != null) {
|
||||
resultBuffer.append(line);
|
||||
}
|
||||
return resultBuffer.toString();
|
||||
} catch (Exception e) {
|
||||
buffer.close();
|
||||
inputStream.close();
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String getRestInformation(HttpServletRequest request) throws Exception {
|
||||
return getRestInformation(request,String.class);
|
||||
}
|
||||
|
||||
public static <T> T getRestInformation(HttpServletRequest request, Class<T> clazz) throws Exception {
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
|
||||
StringBuffer data = new StringBuffer();
|
||||
String line = null;
|
||||
reader = request.getReader();
|
||||
while (null != (line = reader.readLine())) data.append(line);
|
||||
reader.close();
|
||||
T result = JSONObject.parseObject(data.toString(), clazz);
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("解析请求报文出错");
|
||||
} finally {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Http get请求
|
||||
* @param httpUrl 连接
|
||||
* @return 响应数据
|
||||
*/
|
||||
public static String doGet(String httpUrl) throws Exception{
|
||||
//链接
|
||||
HttpURLConnection connection = null;
|
||||
InputStream is = null;
|
||||
BufferedReader br = null;
|
||||
StringBuffer result = new StringBuffer();
|
||||
try {
|
||||
//创建连接
|
||||
URL url = new URL(httpUrl);
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
//设置请求方式
|
||||
connection.setRequestMethod("GET");
|
||||
//设置连接超时时间
|
||||
connection.setReadTimeout(15000);
|
||||
//开始连接
|
||||
connection.connect();
|
||||
//获取响应数据
|
||||
if (connection.getResponseCode() == 200) {
|
||||
//获取返回的数据
|
||||
is = connection.getInputStream();
|
||||
if (null != is) {
|
||||
br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
||||
String temp = null;
|
||||
while (null != (temp = br.readLine())) {
|
||||
result.append(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (null != br) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (null != is) {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
//关闭远程连接
|
||||
connection.disconnect();
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Http post请求
|
||||
* @param httpUrl 连接
|
||||
* @param param 参数
|
||||
* @return
|
||||
*/
|
||||
public static String doPost(String httpUrl, @Nullable String param) {
|
||||
StringBuffer result = new StringBuffer();
|
||||
//连接
|
||||
HttpURLConnection connection = null;
|
||||
OutputStream os = null;
|
||||
InputStream is = null;
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
//创建连接对象
|
||||
URL url = new URL(httpUrl);
|
||||
//创建连接
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
//设置请求方法
|
||||
connection.setRequestMethod("POST");
|
||||
//设置连接超时时间
|
||||
connection.setConnectTimeout(15000);
|
||||
//设置读取超时时间
|
||||
connection.setReadTimeout(15000);
|
||||
//DoOutput设置是否向httpUrlConnection输出,DoInput设置是否从httpUrlConnection读入,此外发送post请求必须设置这两个
|
||||
//设置是否可读取
|
||||
connection.setDoOutput(true);
|
||||
connection.setDoInput(true);
|
||||
//设置通用的请求属性
|
||||
// connection.setRequestProperty("accept", "*/*");
|
||||
// connection.setRequestProperty("connection", "Keep-Alive");
|
||||
// connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
|
||||
connection.setRequestProperty("Content-Type", "application/json;charset=utf-8");
|
||||
System.out.println(param);
|
||||
//拼装参数
|
||||
if (null != param && !param.equals("")) {
|
||||
//设置参数
|
||||
os = connection.getOutputStream();
|
||||
//拼装参数
|
||||
os.write(param.getBytes());
|
||||
}
|
||||
//设置权限
|
||||
//设置请求头等
|
||||
//开启连接
|
||||
//connection.connect();
|
||||
//读取响应
|
||||
if (connection.getResponseCode() == 200) {
|
||||
is = connection.getInputStream();
|
||||
if (null != is) {
|
||||
br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
||||
String temp = null;
|
||||
while (null != (temp = br.readLine())) {
|
||||
result.append(temp);
|
||||
result.append("\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
//关闭连接
|
||||
if(br!=null){
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if(os!=null){
|
||||
try {
|
||||
os.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if(is!=null){
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
//关闭连接
|
||||
connection.disconnect();
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
|
||||
|
||||
package com.zcloud.common.utils;
|
||||
|
||||
import com.alibaba.druid.util.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* IP地址
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class IPUtils {
|
||||
private static Logger logger = LoggerFactory.getLogger(IPUtils.class);
|
||||
|
||||
/**
|
||||
* 获取IP地址
|
||||
*
|
||||
* 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址
|
||||
* 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址
|
||||
*/
|
||||
public static String getIpAddr(HttpServletRequest request) {
|
||||
String ip = null;
|
||||
try {
|
||||
ip = request.getHeader("x-forwarded-for");
|
||||
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (StringUtils.isEmpty(ip) || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("HTTP_CLIENT_IP");
|
||||
}
|
||||
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
|
||||
}
|
||||
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("IPUtils ERROR ", e);
|
||||
}
|
||||
|
||||
// //使用代理,则获取第一个IP地址
|
||||
// if(StringUtils.isEmpty(ip) && ip.length() > 15) {
|
||||
// if(ip.indexOf(",") > 0) {
|
||||
// ip = ip.substring(0, ip.indexOf(","));
|
||||
// }
|
||||
// }
|
||||
|
||||
return ip;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.zcloud.common.utils;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
/**
|
||||
* 说明:MD5处理
|
||||
|
||||
|
||||
*/
|
||||
public class MD5 {
|
||||
|
||||
public static String md5(String str) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
md.update(str.getBytes());
|
||||
byte b[] = md.digest();
|
||||
|
||||
int i;
|
||||
|
||||
StringBuffer buf = new StringBuffer("");
|
||||
for (int offset = 0; offset < b.length; offset++) {
|
||||
i = b[offset];
|
||||
if (i < 0)
|
||||
i += 256;
|
||||
if (i < 16)
|
||||
buf.append("0");
|
||||
buf.append(Integer.toHexString(i));
|
||||
}
|
||||
str = buf.toString();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
return str;
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
System.out.println(md5("313596790@qq.com"+"123456"));
|
||||
System.out.println(md5("mj1"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.zcloud.common.utils;
|
||||
|
||||
import ws.schild.jave.MultimediaInfo;
|
||||
import ws.schild.jave.MultimediaObject;
|
||||
import ws.schild.jave.VideoInfo;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
/**
|
||||
* @author fangjiakai
|
||||
* @date 2023/10/20 10:10
|
||||
*/
|
||||
public class MP4Util {
|
||||
public static String getMP4Time(File video) {
|
||||
// 视频时长
|
||||
String time = "0";
|
||||
try {
|
||||
MultimediaObject media = new MultimediaObject(video);
|
||||
MultimediaInfo info = media.getInfo();
|
||||
// 时长,毫秒级
|
||||
long duration = info.getDuration();
|
||||
// 毫秒级时长转化为秒
|
||||
BigDecimal bigDecimal1 = new BigDecimal(duration);
|
||||
BigDecimal bigDecimal2 = new BigDecimal(1000);
|
||||
// 四舍五入,只保留整数
|
||||
time = bigDecimal1.divide(bigDecimal2, 0, RoundingMode.HALF_UP).toString();
|
||||
// // 获取媒体视频对象
|
||||
// VideoInfo video = info.getVideo();
|
||||
// // 码率
|
||||
// int bitRate = video.getBitRate();
|
||||
// // 帧率
|
||||
// float frameRate = video.getFrameRate();
|
||||
// // 分辨率-高
|
||||
// int height = video.getSize().getHeight();
|
||||
// // 分辨率-宽
|
||||
// int width = video.getSize().getWidth();
|
||||
// // 视频解码器名称
|
||||
// String decoder = video.getDecoder();
|
||||
} catch (Exception e) {
|
||||
e.getMessage();
|
||||
}
|
||||
return time;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
|
||||
package com.zcloud.common.utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
/**
|
||||
* Map工具类
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class MapUtils extends HashMap<String, Object> {
|
||||
|
||||
@Override
|
||||
public MapUtils put(String key, Object value) {
|
||||
super.put(key, value);
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.zcloud.common.utils;
|
||||
|
||||
import com.zcloud.modules.sys.entity.PageData;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 说明:从EXCEL导入到系统
|
||||
|
||||
|
||||
*/
|
||||
public class ObjectExcelRead {
|
||||
|
||||
/**
|
||||
* @param filepath //文件路径
|
||||
* @param filename //文件名
|
||||
* @param startrow //开始行号
|
||||
* @param startcol //开始列号
|
||||
* @param sheetnum //sheet
|
||||
* @return list
|
||||
*/
|
||||
public static List<Object> readExcel(String filepath, String filename, int startrow, int startcol, int sheetnum) {
|
||||
List<Object> varList = new ArrayList<Object>();
|
||||
|
||||
try {
|
||||
File target = new File(filepath, filename);
|
||||
FileInputStream fi = new FileInputStream(target);
|
||||
HSSFWorkbook wb = new HSSFWorkbook(fi);
|
||||
HSSFSheet sheet = wb.getSheetAt(sheetnum); //sheet 从0开始
|
||||
int rowNum = sheet.getLastRowNum() + 1; //取得最后一行的行号
|
||||
|
||||
for (int i = startrow; i < rowNum; i++) { //行循环开始
|
||||
|
||||
PageData varpd = new PageData();
|
||||
HSSFRow row = sheet.getRow(i); //行
|
||||
int cellNum = row.getLastCellNum(); //每行的最后一个单元格位置
|
||||
|
||||
for (int j = startcol; j < cellNum; j++) { //列循环开始
|
||||
|
||||
HSSFCell cell = row.getCell(Short.parseShort(j + ""));
|
||||
if(cell != null){
|
||||
varpd.put("var"+j, cell.toString());
|
||||
}
|
||||
|
||||
}
|
||||
varList.add(varpd);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
return varList;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
|
||||
|
||||
package com.zcloud.common.utils;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分页工具类
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class PageUtils implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 总记录数
|
||||
*/
|
||||
private int totalCount;
|
||||
/**
|
||||
* 每页记录数
|
||||
*/
|
||||
private int pageSize;
|
||||
/**
|
||||
* 总页数
|
||||
*/
|
||||
private int totalPage;
|
||||
/**
|
||||
* 当前页数
|
||||
*/
|
||||
private int currPage;
|
||||
/**
|
||||
* 列表数据
|
||||
*/
|
||||
private List<?> list;
|
||||
|
||||
/**
|
||||
* 分页
|
||||
* @param list 列表数据
|
||||
* @param totalCount 总记录数
|
||||
* @param pageSize 每页记录数
|
||||
* @param currPage 当前页数
|
||||
*/
|
||||
public PageUtils(List<?> list, int totalCount, int pageSize, int currPage) {
|
||||
this.list = list;
|
||||
this.totalCount = totalCount;
|
||||
this.pageSize = pageSize;
|
||||
this.currPage = currPage;
|
||||
this.totalPage = (int)Math.ceil((double)totalCount/pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
public PageUtils(IPage<?> page) {
|
||||
this.list = page.getRecords();
|
||||
this.totalCount = (int)page.getTotal();
|
||||
this.pageSize = (int)page.getSize();
|
||||
this.currPage = (int)page.getCurrent();
|
||||
this.totalPage = (int)page.getPages();
|
||||
}
|
||||
|
||||
public int getTotalCount() {
|
||||
return totalCount;
|
||||
}
|
||||
|
||||
public void setTotalCount(int totalCount) {
|
||||
this.totalCount = totalCount;
|
||||
}
|
||||
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public void setPageSize(int pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public int getTotalPage() {
|
||||
return totalPage;
|
||||
}
|
||||
|
||||
public void setTotalPage(int totalPage) {
|
||||
this.totalPage = totalPage;
|
||||
}
|
||||
|
||||
public int getCurrPage() {
|
||||
return currPage;
|
||||
}
|
||||
|
||||
public void setCurrPage(int currPage) {
|
||||
this.currPage = currPage;
|
||||
}
|
||||
|
||||
public List<?> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setList(List<?> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package com.zcloud.common.utils;
|
||||
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* 说明:路径工具类
|
||||
|
||||
|
||||
*/
|
||||
public class PathUtil {
|
||||
|
||||
/**获取Projectpath
|
||||
* @return
|
||||
*/
|
||||
public static String getProjectpath(){
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
String path = request.getServletContext().getRealPath("/").replaceAll("%20", " ").replaceAll("file:/", "").trim();
|
||||
return path;
|
||||
}
|
||||
|
||||
/**获取Classpath
|
||||
* @return
|
||||
*/
|
||||
public static String getClasspath(){
|
||||
String path = (String.valueOf(Thread.currentThread().getContextClassLoader().getResource(""))).replaceAll("file:/", "").replaceAll("%20", " ").trim();
|
||||
if(path.indexOf(":") != 1){
|
||||
path = File.separator + path;
|
||||
|
||||
}
|
||||
//path = "H:\\"; //当项目以jar、war包运行时,路径改成实际硬盘位置
|
||||
return path;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package com.zcloud.common.utils;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zcloud.common.xss.SQLFilter;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 查询参数
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class Query<T> {
|
||||
|
||||
public IPage<T> getPage(Map<String, Object> params) {
|
||||
return this.getPage(params, null, false);
|
||||
}
|
||||
|
||||
public IPage<T> getPage(Map<String, Object> params, String defaultOrderField, boolean isAsc) {
|
||||
//分页参数
|
||||
long curPage = 1;
|
||||
long limit = 10;
|
||||
|
||||
if(params.get(Constant.PAGE) != null){
|
||||
curPage = Long.parseLong(params.get(Constant.PAGE).toString());
|
||||
}
|
||||
if(params.get(Constant.LIMIT) != null){
|
||||
limit = Long.parseLong(params.get(Constant.LIMIT).toString());
|
||||
}
|
||||
|
||||
//分页对象
|
||||
Page<T> page = new Page<>(curPage, limit);
|
||||
|
||||
//分页参数
|
||||
params.put(Constant.PAGE, page);
|
||||
|
||||
//排序字段
|
||||
//防止SQL注入(因为sidx、order是通过拼接SQL实现排序的,会有SQL注入风险)
|
||||
String orderField = SQLFilter.sqlInject((String)params.get(Constant.ORDER_FIELD));
|
||||
String order = (String)params.get(Constant.ORDER);
|
||||
|
||||
|
||||
//前端字段排序
|
||||
if(StringUtils.isNotEmpty(orderField) && StringUtils.isNotEmpty(order)){
|
||||
if(Constant.ASC.equalsIgnoreCase(order)) {
|
||||
return page.addOrder(OrderItem.asc(orderField));
|
||||
}else {
|
||||
return page.addOrder(OrderItem.desc(orderField));
|
||||
}
|
||||
}
|
||||
|
||||
//没有排序字段,则不排序
|
||||
if(StringUtils.isBlank(defaultOrderField)){
|
||||
return page;
|
||||
}
|
||||
|
||||
//默认排序
|
||||
if(isAsc) {
|
||||
page.addOrder(OrderItem.asc(defaultOrderField));
|
||||
}else {
|
||||
page.addOrder(OrderItem.desc(defaultOrderField));
|
||||
}
|
||||
|
||||
return page;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
|
||||
|
||||
package com.zcloud.common.utils;
|
||||
|
||||
import org.apache.http.HttpStatus;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 返回数据
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class R extends HashMap<String, Object> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public R() {
|
||||
put("code", 200);
|
||||
put("result", "success");
|
||||
}
|
||||
|
||||
public static R error() {
|
||||
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员");
|
||||
}
|
||||
|
||||
public static R error(String msg) {
|
||||
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
|
||||
}
|
||||
|
||||
public static R error(int code, String msg) {
|
||||
R r = new R();
|
||||
r.put("code", code);
|
||||
r.put("result", "failed");
|
||||
r.put("msg", msg);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static R ok(String msg) {
|
||||
R r = new R();
|
||||
r.put("msg", msg);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static R ok(Map<String, Object> map) {
|
||||
R r = new R();
|
||||
r.putAll(map);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static R ok() {
|
||||
return new R();
|
||||
}
|
||||
|
||||
public R put(String key, Object value) {
|
||||
super.put(key, value);
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,404 @@
|
|||
package com.zcloud.common.utils;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.security.*;
|
||||
import java.security.interfaces.RSAPrivateKey;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
import java.security.spec.PKCS8EncodedKeySpec;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* RSA公钥/私钥/签名工具包
|
||||
* <p>
|
||||
* 字符串格式的密钥在未在特殊说明情况下都为BASE64编码格式<br/>
|
||||
* 由于非对称加密速度极其缓慢,一般文件不使用它来加密而是使用对称加密,<br/>
|
||||
* 非对称加密算法可以用来对对称加密的密钥加密,这样保证密钥的安全也就保证了数据的安全
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public class RSAUtils {
|
||||
|
||||
/** */
|
||||
/**
|
||||
* 加密算法RSA
|
||||
*/
|
||||
public static final String KEY_ALGORITHM = "RSA";
|
||||
|
||||
/** */
|
||||
/**
|
||||
* 签名算法
|
||||
*/
|
||||
public static final String SIGNATURE_ALGORITHM = "MD5withRSA";
|
||||
|
||||
/** */
|
||||
/**
|
||||
* 获取公钥的key
|
||||
*/
|
||||
private static final String PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDUoHAavCikaZxjlDM6Km8cX+ye78F4oF39AcEfnE1p2Yn9pJ9WFxYZ4Vkh6F8SKMi7k4nYsKceqB1RwG996SvHQ5C3pM3nbXCP4K15ad6QhN4a7lzlbLhiJcyIKszvvK8ncUDw8mVQ0j/2mwxv05yH6LN9OKU6Hzm1ninpWeE+awIDAQAB\n";
|
||||
|
||||
/** */
|
||||
/**
|
||||
* 获取私钥的key
|
||||
*/
|
||||
private static final String PRIVATE_KEY = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBANSgcBq8KKRpnGOUMzoqbxxf7J7vwXigXf0BwR+cTWnZif2kn1YXFhnhWSHoXxIoyLuTidiwpx6oHVHAb33pK8dDkLekzedtcI/grXlp3pCE3hruXOVsuGIlzIgqzO+8rydxQPDyZVDSP/abDG/TnIfos304pTofObWeKelZ4T5rAgMBAAECgYEAt2Dvjn885h+Xm2JTlBTI40Xvw1uwFqLorK54qxSYx3OwySrTqOIcU5HA17ebVwQJq40hU9t3Jr+DGeDHx2X0NEJ0LXuDMzeWxUwUMbdxxM7OXS6Zuhy73C99DyAweLP9K1H2J/y1+eJ4Zx/0mTiAgCKJFNWAQBZwGl5Zu2zoHOECQQDw0UlrOUfloxK3hfVSWlfL7+onP+z/qa9bzemSg676sAJqA8d5ao8V532OBOtZxfPSlh4igC0lpY2vnCRHrwJZAkEA4ggpMS4o+rfFmNslNzI0m3VFDiLYmghYIqTLHtLYqAbY8QVfFd8bl920t5LQAlTsI3q9Spsu8y7AnAWmYydGYwJAN+tBMya/7TDqvbbbel4EGRUCuE59x/gtAhJUdHMjhI6uYNOz1BvMUffJDdtSkywGLBYztSsyUJWayvZk7khTMQJAALM7xW46LESjdQzAucILDaw4UYnkF94Mv9a41lia2TJkO6Ljn4K4aCkEpUjsIgW3UYjQy0ldxN0RNaqC0G3PtwJAFafiLzcls6qzyAlh5PqM5cJrs+Xa0rHR322/AlSyuxW6wRzUX/zSoorP34JCjRPT5DzUeHMVvr6S2BE8k/8XYg==";
|
||||
|
||||
/** */
|
||||
/**
|
||||
* RSA最大加密明文大小
|
||||
*/
|
||||
private static final int MAX_ENCRYPT_BLOCK = 117;
|
||||
|
||||
/** */
|
||||
/**
|
||||
* RSA最大解密密文大小
|
||||
*/
|
||||
private static final int MAX_DECRYPT_BLOCK = 128;
|
||||
|
||||
/** */
|
||||
/**
|
||||
* <p>
|
||||
* 生成密钥对(公钥和私钥)
|
||||
* </p>
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static Map<String, Object> genKeyPair() throws Exception {
|
||||
KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance(KEY_ALGORITHM);
|
||||
keyPairGen.initialize(1024);
|
||||
KeyPair keyPair = keyPairGen.generateKeyPair();
|
||||
RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();
|
||||
RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate();
|
||||
Map<String, Object> keyMap = new HashMap<String, Object>(2);
|
||||
keyMap.put(PUBLIC_KEY, publicKey);
|
||||
keyMap.put(PRIVATE_KEY, privateKey);
|
||||
return keyMap;
|
||||
}
|
||||
|
||||
/** */
|
||||
/**
|
||||
* <p>
|
||||
* 用私钥对信息生成数字签名
|
||||
* </p>
|
||||
*
|
||||
* @param data
|
||||
* 已加密数据
|
||||
* @param privateKey
|
||||
* 私钥(BASE64编码)
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String sign(byte[] data, String privateKey) throws Exception {
|
||||
byte[] keyBytes = Base64Utils.decode(privateKey);
|
||||
PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
|
||||
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
|
||||
PrivateKey privateK = keyFactory.generatePrivate(pkcs8KeySpec);
|
||||
Signature signature = Signature.getInstance(SIGNATURE_ALGORITHM);
|
||||
signature.initSign(privateK);
|
||||
signature.update(data);
|
||||
return Base64Utils.encode(signature.sign());
|
||||
}
|
||||
|
||||
/** */
|
||||
/**
|
||||
* <p>
|
||||
* 校验数字签名
|
||||
* </p>
|
||||
*
|
||||
* @param data
|
||||
* 已加密数据
|
||||
* @param publicKey
|
||||
* 公钥(BASE64编码)
|
||||
* @param sign
|
||||
* 数字签名
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*
|
||||
*/
|
||||
public static boolean verify(byte[] data, String publicKey, String sign) throws Exception {
|
||||
byte[] keyBytes = Base64Utils.decode(publicKey);
|
||||
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes);
|
||||
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
|
||||
PublicKey publicK = keyFactory.generatePublic(keySpec);
|
||||
Signature signature = Signature.getInstance(SIGNATURE_ALGORITHM);
|
||||
signature.initVerify(publicK);
|
||||
signature.update(data);
|
||||
return signature.verify(Base64Utils.decode(sign));
|
||||
}
|
||||
|
||||
/** */
|
||||
/**
|
||||
* <P>
|
||||
* 私钥解密
|
||||
* </p>
|
||||
*
|
||||
* @param encryptedData
|
||||
* 已加密数据
|
||||
* @param privateKey
|
||||
* 私钥(BASE64编码)
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static byte[] decryptByPrivateKey(byte[] encryptedData, String privateKey) throws Exception {
|
||||
byte[] keyBytes = Base64Utils.decode(privateKey);
|
||||
PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
|
||||
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
|
||||
Key privateK = keyFactory.generatePrivate(pkcs8KeySpec);
|
||||
Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
|
||||
cipher.init(Cipher.DECRYPT_MODE, privateK);
|
||||
int inputLen = encryptedData.length;
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
int offSet = 0;
|
||||
byte[] cache;
|
||||
int i = 0;
|
||||
// 对数据分段解密
|
||||
while (inputLen - offSet > 0) {
|
||||
if (inputLen - offSet > MAX_DECRYPT_BLOCK) {
|
||||
cache = cipher.doFinal(encryptedData, offSet, MAX_DECRYPT_BLOCK);
|
||||
} else {
|
||||
cache = cipher.doFinal(encryptedData, offSet, inputLen - offSet);
|
||||
}
|
||||
out.write(cache, 0, cache.length);
|
||||
i++;
|
||||
offSet = i * MAX_DECRYPT_BLOCK;
|
||||
}
|
||||
byte[] decryptedData = out.toByteArray();
|
||||
out.close();
|
||||
return decryptedData;
|
||||
}
|
||||
|
||||
/** */
|
||||
/**
|
||||
* <p>
|
||||
* 公钥解密
|
||||
* </p>
|
||||
*
|
||||
* @param encryptedData
|
||||
* 已加密数据
|
||||
* @param publicKey
|
||||
* 公钥(BASE64编码)
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static byte[] decryptByPublicKey(byte[] encryptedData, String publicKey) throws Exception {
|
||||
byte[] keyBytes = Base64Utils.decode(publicKey);
|
||||
X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes);
|
||||
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
|
||||
Key publicK = keyFactory.generatePublic(x509KeySpec);
|
||||
Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
|
||||
cipher.init(Cipher.DECRYPT_MODE, publicK);
|
||||
int inputLen = encryptedData.length;
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
int offSet = 0;
|
||||
byte[] cache;
|
||||
int i = 0;
|
||||
// 对数据分段解密
|
||||
while (inputLen - offSet > 0) {
|
||||
if (inputLen - offSet > MAX_DECRYPT_BLOCK) {
|
||||
cache = cipher.doFinal(encryptedData, offSet, MAX_DECRYPT_BLOCK);
|
||||
} else {
|
||||
cache = cipher.doFinal(encryptedData, offSet, inputLen - offSet);
|
||||
}
|
||||
out.write(cache, 0, cache.length);
|
||||
i++;
|
||||
offSet = i * MAX_DECRYPT_BLOCK;
|
||||
}
|
||||
byte[] decryptedData = out.toByteArray();
|
||||
out.close();
|
||||
return decryptedData;
|
||||
}
|
||||
|
||||
/** */
|
||||
/**
|
||||
* <p>
|
||||
* 公钥加密
|
||||
* </p>
|
||||
*
|
||||
* @param data
|
||||
* 源数据
|
||||
* @param publicKey
|
||||
* 公钥(BASE64编码)
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static byte[] encryptByPublicKey(byte[] data, String publicKey) throws Exception {
|
||||
byte[] keyBytes = Base64Utils.decode(publicKey);
|
||||
X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes);
|
||||
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
|
||||
Key publicK = keyFactory.generatePublic(x509KeySpec);
|
||||
// 对数据加密
|
||||
Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
|
||||
cipher.init(Cipher.ENCRYPT_MODE, publicK);
|
||||
int inputLen = data.length;
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
int offSet = 0;
|
||||
byte[] cache;
|
||||
int i = 0;
|
||||
// 对数据分段加密
|
||||
while (inputLen - offSet > 0) {
|
||||
if (inputLen - offSet > MAX_ENCRYPT_BLOCK) {
|
||||
cache = cipher.doFinal(data, offSet, MAX_ENCRYPT_BLOCK);
|
||||
} else {
|
||||
cache = cipher.doFinal(data, offSet, inputLen - offSet);
|
||||
}
|
||||
out.write(cache, 0, cache.length);
|
||||
i++;
|
||||
offSet = i * MAX_ENCRYPT_BLOCK;
|
||||
}
|
||||
byte[] encryptedData = out.toByteArray();
|
||||
out.close();
|
||||
return encryptedData;
|
||||
}
|
||||
|
||||
/** */
|
||||
/**
|
||||
* <p>
|
||||
* 私钥加密
|
||||
* </p>
|
||||
*
|
||||
* @param data
|
||||
* 源数据
|
||||
* @param privateKey
|
||||
* 私钥(BASE64编码)
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static byte[] encryptByPrivateKey(byte[] data, String privateKey) throws Exception {
|
||||
byte[] keyBytes = Base64Utils.decode(privateKey);
|
||||
PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
|
||||
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
|
||||
Key privateK = keyFactory.generatePrivate(pkcs8KeySpec);
|
||||
Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
|
||||
cipher.init(Cipher.ENCRYPT_MODE, privateK);
|
||||
int inputLen = data.length;
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
int offSet = 0;
|
||||
byte[] cache;
|
||||
int i = 0;
|
||||
// 对数据分段加密
|
||||
while (inputLen - offSet > 0) {
|
||||
if (inputLen - offSet > MAX_ENCRYPT_BLOCK) {
|
||||
cache = cipher.doFinal(data, offSet, MAX_ENCRYPT_BLOCK);
|
||||
} else {
|
||||
cache = cipher.doFinal(data, offSet, inputLen - offSet);
|
||||
}
|
||||
out.write(cache, 0, cache.length);
|
||||
i++;
|
||||
offSet = i * MAX_ENCRYPT_BLOCK;
|
||||
}
|
||||
byte[] encryptedData = out.toByteArray();
|
||||
out.close();
|
||||
return encryptedData;
|
||||
}
|
||||
|
||||
/** */
|
||||
/**
|
||||
* <p>
|
||||
* 获取私钥
|
||||
* </p>
|
||||
*
|
||||
* @param keyMap
|
||||
* 密钥对
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String getPrivateKey(Map<String, Object> keyMap) throws Exception {
|
||||
Key key = (Key) keyMap.get(PRIVATE_KEY);
|
||||
return Base64Utils.encode(key.getEncoded());
|
||||
}
|
||||
|
||||
/** */
|
||||
/**
|
||||
* <p>
|
||||
* 获取私钥
|
||||
* </p>
|
||||
*
|
||||
* @param keyMap
|
||||
* 密钥对
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String getPrivateKey() {
|
||||
return PRIVATE_KEY;
|
||||
}
|
||||
|
||||
/** */
|
||||
/**
|
||||
* <p>
|
||||
* 获取公钥
|
||||
* </p>
|
||||
*
|
||||
* @param keyMap
|
||||
* 密钥对
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String getPublicKey(Map<String, Object> keyMap) throws Exception {
|
||||
Key key = (Key) keyMap.get(PUBLIC_KEY);
|
||||
return Base64Utils.encode(key.getEncoded());
|
||||
}
|
||||
|
||||
/** */
|
||||
/**
|
||||
* <p>
|
||||
* 获取公钥
|
||||
* </p>
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String getPublicKey() throws Exception {
|
||||
return PUBLIC_KEY;
|
||||
}
|
||||
|
||||
/**
|
||||
* java端公钥加密
|
||||
*/
|
||||
public static String encryptedDataOnJava(String data, String PUBLICKEY) {
|
||||
try {
|
||||
data = Base64Utils.encode(encryptByPublicKey(data.getBytes(), PUBLICKEY));
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* java端私钥解密
|
||||
*/
|
||||
public static String decryptDataOnJava(String data, String PRIVATEKEY) {
|
||||
String temp = "";
|
||||
try {
|
||||
byte[] rs = Base64Utils.decode(data);
|
||||
temp = new String(RSAUtils.decryptByPrivateKey(rs, PRIVATEKEY),"UTF-8"); //以utf-8的方式生成字符串
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Map<String, Object> keyMap = null;
|
||||
try {
|
||||
keyMap = RSAUtils.genKeyPair();
|
||||
String publicKey = RSAUtils.getPublicKey(keyMap);
|
||||
String privateKey = RSAUtils.getPrivateKey(keyMap);
|
||||
System.err.println("公钥: \n\r" + publicKey);
|
||||
System.err.println("私钥: \n\r" + privateKey);
|
||||
// 公钥:
|
||||
// MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDE8aNkz3X5f96bW2EJ3fRQsEmtgrIzLSCSJZLf1WBay0ihEideK45md5UZIFB6HSWwBaKD4z1uAMdt5esn0AIvrQS8+nlnB+Fohzxg7yY2ooDLP2az0WVKzepbeg8igq+jflUh7/+rvndiJAnv+mnMbibFqhYsDAJ3Zq82FkOeXQIDAQAB
|
||||
// 私钥:
|
||||
// MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAMTxo2TPdfl/3ptbYQnd9FCwSa2CsjMtIJIlkt/VYFrLSKESJ14rjmZ3lRkgUHodJbAFooPjPW4Ax23l6yfQAi+tBLz6eWcH4WiHPGDvJjaigMs/ZrPRZUrN6lt6DyKCr6N+VSHv/6u+d2IkCe/6acxuJsWqFiwMAndmrzYWQ55dAgMBAAECgYB1gfPKz5oFjw0ERyaEG6GNj1G2rFek/1UCvlZ/JTJDmi0wpcNFhdmGO+2DO2upIMD+4K3R4YEipGZZpSiE7bCPM1uIerVAi0efTQMZKSrreud29Z/6xN0166GthAj30AjrwxfNAhoUNQXcG2NQJmfUpPlV95Cjh2b6tTlLdU9foQJBAO2zrzYeLiBrhEOZqr5JC8zUdseGSKCwIvZDwQ+s8GuuSVpm1q9mHOL3TODNlawfst78o9QBkk2MyKP7Voe6C6UCQQDUGr/A7XTvV39fqO4V+BcSLDCpxTHJ8UUWiRovXhDMn0TjqeRnDiRC9YuMf5XCXwDkYnK/u3O2maZugrcgUqpZAkBgd4zC9MqZg6jg2mtN4E02qn8uCFRPSkxWDzc5ymCkAs5oLtYvxswwXFbJ4QU+Hns0Pemq75xVdq4yxpzeZmW1AkEAvOi+FJTpaypg9dA9jS+TTMoy5WIOgC/1OqcNvVZoW/cWojZ0iRzdSw3rJk2UErQO1VqhnQbVfrLGuvKNK6q0sQJATbmrgK1KDaAS3Ns8MI6pDKWWHaAy8Vrnwz4nRIX2C0FKLTYwbNPrvVHdpD0ItZ8p9wiAL6HVn5ipxbz6v0l1uA==
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
|
||||
package com.zcloud.common.utils;
|
||||
|
||||
/**
|
||||
* Redis所有Keys
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class RedisKeys {
|
||||
|
||||
public static String getSysConfigKey(String key){
|
||||
return "sys:config:" + key;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
|
||||
|
||||
package com.zcloud.common.utils;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Redis工具类
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class RedisUtils {
|
||||
@Autowired
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
@Autowired
|
||||
private ValueOperations<String, String> valueOperations;
|
||||
@Autowired
|
||||
private HashOperations<String, String, Object> hashOperations;
|
||||
@Autowired
|
||||
private ListOperations<String, Object> listOperations;
|
||||
@Autowired
|
||||
private SetOperations<String, Object> setOperations;
|
||||
@Autowired
|
||||
private ZSetOperations<String, Object> zSetOperations;
|
||||
/** 默认过期时长,单位:秒 */
|
||||
public final static long DEFAULT_EXPIRE = 60 * 60 * 24;
|
||||
/** 不设置过期时长 */
|
||||
public final static long NOT_EXPIRE = -1;
|
||||
private final static Gson gson = new Gson();
|
||||
|
||||
public void set(String key, Object value, long expire){
|
||||
valueOperations.set(key, toJson(value));
|
||||
if(expire != NOT_EXPIRE){
|
||||
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
public void set(String key, Object value){
|
||||
set(key, value, DEFAULT_EXPIRE);
|
||||
}
|
||||
|
||||
public <T> T get(String key, Class<T> clazz, long expire) {
|
||||
String value = valueOperations.get(key);
|
||||
if(expire != NOT_EXPIRE){
|
||||
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
|
||||
}
|
||||
return value == null ? null : fromJson(value, clazz);
|
||||
}
|
||||
|
||||
public <T> T get(String key, Class<T> clazz) {
|
||||
return get(key, clazz, NOT_EXPIRE);
|
||||
}
|
||||
|
||||
public String get(String key, long expire) {
|
||||
String value = valueOperations.get(key);
|
||||
if(expire != NOT_EXPIRE){
|
||||
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public String get(String key) {
|
||||
return get(key, NOT_EXPIRE);
|
||||
}
|
||||
|
||||
public void delete(String key) {
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Object转成JSON数据
|
||||
*/
|
||||
private String toJson(Object object){
|
||||
if(object instanceof Integer || object instanceof Long || object instanceof Float ||
|
||||
object instanceof Double || object instanceof Boolean || object instanceof String){
|
||||
return String.valueOf(object);
|
||||
}
|
||||
return gson.toJson(object);
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON数据,转成Object
|
||||
*/
|
||||
private <T> T fromJson(String json, Class<T> clazz){
|
||||
return gson.fromJson(json, clazz);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package com.zcloud.common.utils;
|
||||
|
||||
import com.zcloud.common.exception.ZException;
|
||||
import com.zcloud.modules.sys.entity.SysUserEntity;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.session.Session;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
|
||||
/**
|
||||
* Shiro工具类
|
||||
*/
|
||||
public class ShiroUtils {
|
||||
|
||||
public static Session getSession() {
|
||||
return SecurityUtils.getSubject().getSession();
|
||||
}
|
||||
|
||||
public static Subject getSubject() {
|
||||
return SecurityUtils.getSubject();
|
||||
}
|
||||
|
||||
public static SysUserEntity getUserEntity() {
|
||||
return (SysUserEntity)SecurityUtils.getSubject().getPrincipal();
|
||||
}
|
||||
|
||||
public static String getUserId() {
|
||||
return getUserEntity().getUserId();
|
||||
}
|
||||
|
||||
public static void setSessionAttribute(Object key, Object value) {
|
||||
getSession().setAttribute(key, value);
|
||||
}
|
||||
|
||||
public static Object getSessionAttribute(Object key) {
|
||||
return getSession().getAttribute(key);
|
||||
}
|
||||
|
||||
public static boolean isLogin() {
|
||||
return SecurityUtils.getSubject().getPrincipal() != null;
|
||||
}
|
||||
|
||||
public static String getKaptcha(String key) {
|
||||
Object kaptcha = getSessionAttribute(key);
|
||||
if(kaptcha == null){
|
||||
throw new ZException("验证码已失效");
|
||||
}
|
||||
getSession().removeAttribute(key);
|
||||
return kaptcha.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
|
||||
|
||||
package com.zcloud.common.utils;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Spring Context 工具类
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class SpringContextUtils implements ApplicationContextAware {
|
||||
public static ApplicationContext applicationContext;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext)
|
||||
throws BeansException {
|
||||
SpringContextUtils.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
public static Object getBean(String name) {
|
||||
return applicationContext.getBean(name);
|
||||
}
|
||||
|
||||
public static <T> T getBean(String name, Class<T> requiredType) {
|
||||
return applicationContext.getBean(name, requiredType);
|
||||
}
|
||||
|
||||
public static boolean containsBean(String name) {
|
||||
return applicationContext.containsBean(name);
|
||||
}
|
||||
|
||||
public static boolean isSingleton(String name) {
|
||||
return applicationContext.isSingleton(name);
|
||||
}
|
||||
|
||||
public static Class<? extends Object> getType(String name) {
|
||||
return applicationContext.getType(name);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,311 @@
|
|||
package com.zcloud.common.utils;
|
||||
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
/**
|
||||
* 说明:常用工具
|
||||
* 作者:luoxiaobao
|
||||
* 官网:www.qdkjchina.com
|
||||
*/
|
||||
public class Tools {
|
||||
|
||||
/**
|
||||
* 随机生成六位数验证码
|
||||
* @return
|
||||
*/
|
||||
public static int getRandomNum(){
|
||||
Random r = new Random();
|
||||
return r.nextInt(900000)+100000;//(Math.random()*(999999-100000)+100000)
|
||||
}
|
||||
|
||||
/**
|
||||
* 随机生成四位数验证码
|
||||
* @return
|
||||
*/
|
||||
public static int getRandomNum4(){
|
||||
Random r = new Random();
|
||||
return r.nextInt(9000)+1000;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测字符串是否不为空(null,"","null")
|
||||
* @param s
|
||||
* @return 不为空则返回true,否则返回false
|
||||
*/
|
||||
public static boolean notEmpty(String s){
|
||||
return s!=null && !"".equals(s) && !"null".equals(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测字符串是否为空(null,"","null")
|
||||
* @param s
|
||||
* @return 为空则返回true,不否则返回false
|
||||
*/
|
||||
public static boolean isEmpty(String s){
|
||||
return s==null || "".equals(s) || "null".equals(s);
|
||||
}
|
||||
public static boolean isEmpty (Object obj) {
|
||||
return obj ==null || "".equals(obj);
|
||||
}
|
||||
/**
|
||||
* 字符串转换为字符串数组
|
||||
* @param str 字符串
|
||||
* @param splitRegex 分隔符
|
||||
* @return
|
||||
*/
|
||||
public static String[] str2StrArray(String str,String splitRegex){
|
||||
if(isEmpty(str)){
|
||||
return null;
|
||||
}
|
||||
return str.split(splitRegex);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用默认的分隔符(,)将字符串转换为字符串数组
|
||||
* @param str 字符串
|
||||
* @return
|
||||
*/
|
||||
public static String[] str2StrArray(String str){
|
||||
return str2StrArray(str,",\\s*");
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证邮箱
|
||||
* @param email
|
||||
* @return
|
||||
*/
|
||||
public static boolean checkEmail(String email){
|
||||
boolean flag = false;
|
||||
try{
|
||||
String check = "^([a-z0-9A-Z]+[-|_|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
|
||||
Pattern regex = Pattern.compile(check);
|
||||
Matcher matcher = regex.matcher(email);
|
||||
flag = matcher.matches();
|
||||
}catch(Exception e){
|
||||
flag = false;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证手机号码
|
||||
* @param mobileNumber
|
||||
* @return
|
||||
*/
|
||||
public static boolean checkMobileNumber(String mobileNumber){
|
||||
boolean flag = false;
|
||||
try{
|
||||
Pattern regex = Pattern.compile("^(((13[0-9])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8})|(0\\d{2}-\\d{8})|(0\\d{3}-\\d{7})$");
|
||||
Matcher matcher = regex.matcher(mobileNumber);
|
||||
flag = matcher.matches();
|
||||
}catch(Exception e){
|
||||
flag = false;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测KEY是否正确
|
||||
* @param paraname 传入参数
|
||||
* @param FKEY 接收的 KEY
|
||||
* @return 为空则返回true,不否则返回false
|
||||
*/
|
||||
public static boolean checkKey(String paraname, String FKEY){
|
||||
paraname = (null == paraname)? "":paraname;
|
||||
return MD5.md5(paraname+DateUtil.getDays()+",fh,").equals(FKEY);
|
||||
}
|
||||
/**
|
||||
转半角的函数(DBC case)<br/><br/>
|
||||
全角空格为12288,半角空格为32
|
||||
其他字符半角(33-126)与全角(65281-65374)的对应关系是:均相差65248
|
||||
* @param input 任意字符串
|
||||
* @return 半角字符串
|
||||
*
|
||||
*/
|
||||
public static String ToDBC(String input) {
|
||||
char[] c = input.toCharArray();
|
||||
for (int i = 0; i < c.length; i++) {
|
||||
if (c[i] == 12288) {
|
||||
//全角空格为12288,半角空格为32
|
||||
c[i] = (char) 32;
|
||||
continue;
|
||||
}
|
||||
if (c[i] > 65280 && c[i] < 65375)
|
||||
//其他字符半角(33-126)与全角(65281-65374)的对应关系是:均相差65248
|
||||
c[i] = (char) (c[i] - 65248);
|
||||
}
|
||||
return new String(c);
|
||||
}
|
||||
|
||||
public static String replaceBlank(String str) {
|
||||
String dest = "";
|
||||
if (str != null) {
|
||||
Pattern p = Pattern.compile("\\s*|\t|\r|\n");
|
||||
Matcher m = p.matcher(str);
|
||||
dest = m.replaceAll("");
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
public static String excelHandle (String string) {
|
||||
String aString = string.replaceAll(" ", "");
|
||||
aString = ToDBC(aString);
|
||||
aString = replaceBlank(aString);
|
||||
return aString;
|
||||
}
|
||||
public static String excelHandle (Object object) {
|
||||
String aString = object.toString().replaceAll(" ", "");
|
||||
aString = ToDBC(aString);
|
||||
aString = replaceBlank(aString);
|
||||
return aString;
|
||||
}
|
||||
public static String get32UUID() {
|
||||
String uuid = UUID.randomUUID().toString().trim().replaceAll("-", "");
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public static String uploadFile(MultipartFile file, String folder) {
|
||||
String ffile = DateUtil.getDays();
|
||||
String fileName = get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
||||
String path = "/uploadFiles/" + folder + "/" + ffile;
|
||||
FileUploadUtil.sshSftp(file, fileName, path);
|
||||
return "/uploadFiles/" + folder + "/" + ffile +"/" + fileName;
|
||||
}
|
||||
|
||||
public static boolean isNotBlank(Object obj){
|
||||
return obj!=null &&!"".equals(obj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 构建树形结构
|
||||
*
|
||||
* @param entities 实体集合
|
||||
* idFieldName id字段名称
|
||||
* parentIdFieldName parentId字段名称
|
||||
* childrenFieldName children字段名称
|
||||
**/
|
||||
public static <T> List<T> buildEntityTree(List<T> entities, String idFieldName, String parentIdFieldName, String childrenFieldName) {
|
||||
if (entities == null || entities.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
List<T> result = new ArrayList<>();
|
||||
|
||||
try {
|
||||
Field idField = getField(entities.get(0).getClass(), idFieldName);
|
||||
Field parentIdField = getField(entities.get(0).getClass(), parentIdFieldName);
|
||||
Field childrenField = getField(entities.get(0).getClass(), childrenFieldName);
|
||||
|
||||
if (idField == null || parentIdField == null) {
|
||||
throw new IllegalArgumentException("Invalid idFieldName or parentIdFieldName or childrenField");
|
||||
}
|
||||
|
||||
Map<Object, T> entityMap = new HashMap<>();
|
||||
for (T entity : entities) {
|
||||
idField.setAccessible(true);
|
||||
Object id = idField.get(entity);
|
||||
entityMap.put(id, entity);
|
||||
}
|
||||
|
||||
for (T entity : entities) {
|
||||
parentIdField.setAccessible(true);
|
||||
Object parentId = parentIdField.get(entity);
|
||||
if(parentId == null || parentId.equals("0") || parentId.equals("-1")){
|
||||
result.add(entity); // 根节点
|
||||
|
||||
}else{
|
||||
T parentEntity = entityMap.get(parentId);
|
||||
if (parentEntity != null) {
|
||||
if (childrenField != null) {
|
||||
childrenField.setAccessible(true);
|
||||
List<T> children = (List<T>) childrenField.get(parentEntity);
|
||||
if (children == null) {
|
||||
children = new ArrayList<>();
|
||||
}
|
||||
children.add(entity);
|
||||
childrenField.set(parentEntity, children);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private static Field getField(Class<?> clazz, String fieldName) {
|
||||
try {
|
||||
return clazz.getDeclaredField(fieldName);
|
||||
} catch (NoSuchFieldException e) {
|
||||
// 若当前类不存在指定字段,则尝试从父类中获取
|
||||
Class<?> superClass = clazz.getSuperclass();
|
||||
if (superClass != null && superClass != Object.class) {
|
||||
return getField(superClass, fieldName);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件的后缀名
|
||||
*
|
||||
* @param fileName 文件名
|
||||
* @return 文件后缀名,如果没有后缀名则返回空字符串
|
||||
*/
|
||||
public static String getFileExtension(String fileName) {
|
||||
if (fileName == null || fileName.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
int lastDotIndex = fileName.lastIndexOf('.');
|
||||
if (lastDotIndex == -1) {
|
||||
return ""; // 没有后缀名
|
||||
}
|
||||
|
||||
return fileName.substring(lastDotIndex + 1).toLowerCase();
|
||||
}
|
||||
|
||||
public static String toString(Object obj) {
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
return obj.toString();
|
||||
}
|
||||
|
||||
public static Integer toInteger(Object obj) {
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
return Integer.valueOf(obj.toString());
|
||||
}
|
||||
|
||||
public static Double toDouble(Object obj) {
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
return Double.valueOf(obj.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算给定年份属于第几个周期。
|
||||
* @param startYear 起始年份
|
||||
* @param year 给定的年份
|
||||
* @param cycle 周期数
|
||||
* @return 返回周期编号
|
||||
*/
|
||||
public static int calculateCycle(int startYear,int year,int cycle) {
|
||||
int yearsDifference = year - startYear;
|
||||
return yearsDifference / cycle + 1;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,259 @@
|
|||
package com.zcloud.common.utils;
|
||||
|
||||
import org.apache.logging.log4j.util.Base64Util;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
|
||||
public class VerifyCodeUtil {
|
||||
//使用到Algerian字体,系统里没有的话需要安装字体,字体只显示大写,去掉了1,0,i,o几个容易混淆的字符
|
||||
public static final String VERIFY_CODES = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ";
|
||||
private static Random random = new Random();
|
||||
|
||||
/**
|
||||
* 使用系统默认字符源生成验证码
|
||||
*
|
||||
* @param verifySize 验证码长度
|
||||
* @return
|
||||
*/
|
||||
public static String generateVerifyCode(int verifySize) {
|
||||
return generateVerifyCode(verifySize, VERIFY_CODES);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用指定源生成验证码
|
||||
*
|
||||
* @param verifySize 验证码长度
|
||||
* @param sources 验证码字符源
|
||||
* @return
|
||||
*/
|
||||
public static String generateVerifyCode(int verifySize, String sources) {
|
||||
if (sources == null || sources.length() == 0) {
|
||||
sources = VERIFY_CODES;
|
||||
}
|
||||
int codesLen = sources.length();
|
||||
Random rand = new Random(System.currentTimeMillis());
|
||||
StringBuilder verifyCode = new StringBuilder(verifySize);
|
||||
for (int i = 0; i < verifySize; i++) {
|
||||
verifyCode.append(sources.charAt(rand.nextInt(codesLen - 1)));
|
||||
}
|
||||
return verifyCode.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成指定数据的验证码并以Base64编码一字符串形式返回,用于前后分离
|
||||
* @param w
|
||||
* @param h
|
||||
* @param code
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String outputImage(int w, int h, String code) throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
||||
VerifyCodeUtil.outputImage(100, 39, baos, code);
|
||||
final String BASE64_IMAGE = "data:image/jpeg;base64,%s";
|
||||
String base64Img = String.format(BASE64_IMAGE, Base64Util.encode(Arrays.toString(baos.toByteArray())));
|
||||
return base64Img;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成指定验证码图像文件
|
||||
*
|
||||
* @param w
|
||||
* @param h
|
||||
* @param outputFile
|
||||
* @param code
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void outputImage(int w, int h, File outputFile, String code) throws IOException {
|
||||
if (outputFile == null) {
|
||||
return;
|
||||
}
|
||||
File dir = outputFile.getParentFile();
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
try {
|
||||
outputFile.createNewFile();
|
||||
FileOutputStream fos = new FileOutputStream(outputFile);
|
||||
outputImage(w, h, fos, code);
|
||||
fos.close();
|
||||
} catch (IOException e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出指定验证码图片流
|
||||
*
|
||||
* @param w
|
||||
* @param h
|
||||
* @param os
|
||||
* @param code
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void outputImage(int w, int h, OutputStream os, String code) throws IOException {
|
||||
int verifySize = code.length();
|
||||
BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
|
||||
Random rand = new Random();
|
||||
Graphics2D g2 = image.createGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
Color[] colors = new Color[5];
|
||||
Color[] colorSpaces = new Color[]{Color.WHITE, Color.CYAN,
|
||||
Color.GRAY, Color.LIGHT_GRAY, Color.MAGENTA, Color.ORANGE,
|
||||
Color.PINK, Color.YELLOW};
|
||||
float[] fractions = new float[colors.length];
|
||||
for (int i = 0; i < colors.length; i++) {
|
||||
colors[i] = colorSpaces[rand.nextInt(colorSpaces.length)];
|
||||
fractions[i] = rand.nextFloat();
|
||||
}
|
||||
Arrays.sort(fractions);
|
||||
|
||||
g2.setColor(Color.GRAY);// 设置边框色
|
||||
g2.fillRect(0, 0, w, h);
|
||||
|
||||
Color c = getRandColor(200, 250);
|
||||
g2.setColor(c);// 设置背景色
|
||||
g2.fillRect(0, 2, w, h - 4);
|
||||
|
||||
//绘制干扰线
|
||||
Random random = new Random();
|
||||
g2.setColor(getRandColor(160, 200));// 设置线条的颜色
|
||||
for (int i = 0; i < 20; i++) {
|
||||
int x = random.nextInt(w - 1);
|
||||
int y = random.nextInt(h - 1);
|
||||
int xl = random.nextInt(6) + 1;
|
||||
int yl = random.nextInt(12) + 1;
|
||||
g2.drawLine(x, y, x + xl + 40, y + yl + 20);
|
||||
}
|
||||
|
||||
// 添加噪点
|
||||
float yawpRate = 0.05f;// 噪声率
|
||||
int area = (int) (yawpRate * w * h);
|
||||
for (int i = 0; i < area; i++) {
|
||||
int x = random.nextInt(w);
|
||||
int y = random.nextInt(h);
|
||||
int rgb = getRandomIntColor();
|
||||
image.setRGB(x, y, rgb);
|
||||
}
|
||||
|
||||
shear(g2, w, h, c);// 使图片扭曲
|
||||
|
||||
g2.setColor(getRandColor(100, 160));
|
||||
int fontSize = h - 6;
|
||||
Font font = new Font("Algerian", Font.ITALIC, fontSize);
|
||||
g2.setFont(font);
|
||||
char[] chars = code.toCharArray();
|
||||
for (int i = 0; i < verifySize; i++) {
|
||||
AffineTransform affine = new AffineTransform();
|
||||
affine.setToRotation(Math.PI / 4 * rand.nextDouble() * (rand.nextBoolean() ? 1 : -1), (w / verifySize) * i + fontSize / 2, h / 2);
|
||||
g2.setTransform(affine);
|
||||
g2.drawChars(chars, i, 1, ((w - 10) / verifySize) * i + 5, h / 2 + fontSize / 2 - 10);
|
||||
}
|
||||
|
||||
g2.dispose();
|
||||
ImageIO.write(image, "jpg", os);
|
||||
}
|
||||
|
||||
|
||||
private static Color getRandColor(int fc, int bc) {
|
||||
if (fc > 255) {
|
||||
fc = 255;
|
||||
}
|
||||
if (bc > 255) {
|
||||
bc = 255;
|
||||
}
|
||||
int r = fc + random.nextInt(bc - fc);
|
||||
int g = fc + random.nextInt(bc - fc);
|
||||
int b = fc + random.nextInt(bc - fc);
|
||||
return new Color(r, g, b);
|
||||
}
|
||||
|
||||
private static int getRandomIntColor() {
|
||||
int[] rgb = getRandomRgb();
|
||||
int color = 0;
|
||||
for (int c : rgb) {
|
||||
color = color << 8;
|
||||
color = color | c;
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
private static int[] getRandomRgb() {
|
||||
int[] rgb = new int[3];
|
||||
for (int i = 0; i < 3; i++) {
|
||||
rgb[i] = random.nextInt(255);
|
||||
}
|
||||
return rgb;
|
||||
}
|
||||
|
||||
private static void shear(Graphics g, int w1, int h1, Color color) {
|
||||
shearX(g, w1, h1, color);
|
||||
shearY(g, w1, h1, color);
|
||||
}
|
||||
|
||||
private static void shearX(Graphics g, int w1, int h1, Color color) {
|
||||
int period = random.nextInt(2);
|
||||
|
||||
boolean borderGap = true;
|
||||
int frames = 1;
|
||||
int phase = random.nextInt(2);
|
||||
|
||||
for (int i = 0; i < h1; i++) {
|
||||
double d = (double) (period >> 1)
|
||||
* Math.sin((double) i / (double) period
|
||||
+ (6.2831853071795862D * (double) phase)
|
||||
/ (double) frames);
|
||||
g.copyArea(0, i, w1, 1, (int) d, 0);
|
||||
if (borderGap) {
|
||||
g.setColor(color);
|
||||
g.drawLine((int) d, i, 0, i);
|
||||
g.drawLine((int) d + w1, i, w1, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void shearY(Graphics g, int w1, int h1, Color color) {
|
||||
int period = random.nextInt(40) + 10; // 50;
|
||||
boolean borderGap = true;
|
||||
int frames = 20;
|
||||
int phase = 7;
|
||||
for (int i = 0; i < w1; i++) {
|
||||
double d = (double) (period >> 1)
|
||||
* Math.sin((double) i / (double) period
|
||||
+ (6.2831853071795862D * (double) phase)
|
||||
/ (double) frames);
|
||||
g.copyArea(i, 0, 1, h1, 0, (int) d);
|
||||
if (borderGap) {
|
||||
g.setColor(color);
|
||||
g.drawLine(i, (int) d, i, 0);
|
||||
g.drawLine(i, (int) d + h1, i, h1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
File dir = new File("D:/upload/verifyCode");
|
||||
int w = 200, h = 80;
|
||||
for (int i = 0; i < 50; i++) {
|
||||
String verifyCode = generateVerifyCode(4);
|
||||
File file = new File(dir, verifyCode + ".jpg");
|
||||
outputImage(w, h, file, verifyCode);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
|
||||
package com.zcloud.common.validator;
|
||||
|
||||
import com.zcloud.common.exception.ZException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* 数据校验
|
||||
*
|
||||
*
|
||||
*/
|
||||
public abstract class Assert {
|
||||
|
||||
public static void isBlank(String str, String message) {
|
||||
if (StringUtils.isBlank(str)) {
|
||||
throw new ZException(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void isNull(Object object, String message) {
|
||||
if (object == null) {
|
||||
throw new ZException(message);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.zcloud.common.validator;
|
||||
|
||||
import com.zcloud.common.exception.ZException;
|
||||
import com.zcloud.common.utils.Constant;
|
||||
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.Validation;
|
||||
import javax.validation.Validator;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* hibernate-validator校验工具类
|
||||
*
|
||||
* 参考文档:http://docs.jboss.org/hibernate/validator/5.4/reference/en-US/html_single/
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ValidatorUtils {
|
||||
private static Validator validator;
|
||||
|
||||
static {
|
||||
validator = Validation.buildDefaultValidatorFactory().getValidator();
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验对象
|
||||
* @param object 待校验对象
|
||||
* @param groups 待校验的组
|
||||
* @throws ZException 校验不通过,则报RRException异常
|
||||
*/
|
||||
public static void validateEntity(Object object, Class<?>... groups)
|
||||
throws ZException {
|
||||
Set<ConstraintViolation<Object>> constraintViolations = validator.validate(object, groups);
|
||||
if (!constraintViolations.isEmpty()) {
|
||||
StringBuilder msg = new StringBuilder();
|
||||
for (ConstraintViolation<Object> constraint : constraintViolations) {
|
||||
msg.append(constraint.getMessage()).append("<br>");
|
||||
}
|
||||
throw new ZException(msg.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static void validateEntity(Object object, Constant.CloudService type) {
|
||||
validateEntity(object, type.getValidatorGroupClass());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
|
||||
package com.zcloud.common.validator.group;
|
||||
|
||||
/**
|
||||
* 新增数据 Group
|
||||
*
|
||||
*
|
||||
*/
|
||||
public interface AddGroup {
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
|
||||
package com.zcloud.common.validator.group;
|
||||
|
||||
/**
|
||||
* 阿里云
|
||||
*
|
||||
*
|
||||
*/
|
||||
public interface AliyunGroup {
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
|
||||
package com.zcloud.common.validator.group;
|
||||
|
||||
import javax.validation.GroupSequence;
|
||||
|
||||
/**
|
||||
* 定义校验顺序,如果AddGroup组失败,则UpdateGroup组不会再校验
|
||||
*
|
||||
*
|
||||
*/
|
||||
@GroupSequence({AddGroup.class, UpdateGroup.class})
|
||||
public interface Group {
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
|
||||
package com.zcloud.common.validator.group;
|
||||
|
||||
/**
|
||||
* 腾讯云
|
||||
*
|
||||
*
|
||||
*/
|
||||
public interface QcloudGroup {
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
|
||||
package com.zcloud.common.validator.group;
|
||||
|
||||
/**
|
||||
* 七牛
|
||||
*
|
||||
*
|
||||
*/
|
||||
public interface QiniuGroup {
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.zcloud.common.validator.group;
|
||||
|
||||
/**
|
||||
* 更新数据 Group
|
||||
*/
|
||||
|
||||
public interface UpdateGroup {
|
||||
|
||||
}
|
|
@ -0,0 +1,530 @@
|
|||
package com.zcloud.common.xss;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
*
|
||||
* HTML filtering utility for protecting against XSS (Cross Site Scripting).
|
||||
*
|
||||
* This code is licensed LGPLv3
|
||||
*
|
||||
* This code is a Java port of the original work in PHP by Cal Hendersen.
|
||||
* http://code.iamcal.com/php/lib_filter/
|
||||
*
|
||||
* The trickiest part of the translation was handling the differences in regex handling
|
||||
* between PHP and Java. These resources were helpful in the process:
|
||||
*
|
||||
* http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html
|
||||
* http://us2.php.net/manual/en/reference.pcre.pattern.modifiers.php
|
||||
* http://www.regular-expressions.info/modifiers.html
|
||||
*
|
||||
* A note on naming conventions: instance variables are prefixed with a "v"; global
|
||||
* constants are in all caps.
|
||||
*
|
||||
* Sample use:
|
||||
* String input = ...
|
||||
* String clean = new HTMLFilter().filter( input );
|
||||
*
|
||||
* The class is not thread safe. Create a new instance if in doubt.
|
||||
*
|
||||
* If you find bugs or have suggestions on improvement (especially regarding
|
||||
* performance), please contact us. The latest version of this
|
||||
* source, and our contact details, can be found at http://xss-html-filter.sf.net
|
||||
*
|
||||
* @author Joseph O'Connell
|
||||
* @author Cal Hendersen
|
||||
* @author Michael Semb Wever
|
||||
*/
|
||||
public final class HTMLFilter {
|
||||
|
||||
/** regex flag union representing /si modifiers in php **/
|
||||
private static final int REGEX_FLAGS_SI = Pattern.CASE_INSENSITIVE | Pattern.DOTALL;
|
||||
private static final Pattern P_COMMENTS = Pattern.compile("<!--(.*?)-->", Pattern.DOTALL);
|
||||
private static final Pattern P_COMMENT = Pattern.compile("^!--(.*)--$", REGEX_FLAGS_SI);
|
||||
private static final Pattern P_TAGS = Pattern.compile("<(.*?)>", Pattern.DOTALL);
|
||||
private static final Pattern P_END_TAG = Pattern.compile("^/([a-z0-9]+)", REGEX_FLAGS_SI);
|
||||
private static final Pattern P_START_TAG = Pattern.compile("^([a-z0-9]+)(.*?)(/?)$", REGEX_FLAGS_SI);
|
||||
private static final Pattern P_QUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)=([\"'])(.*?)\\2", REGEX_FLAGS_SI);
|
||||
private static final Pattern P_UNQUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)(=)([^\"\\s']+)", REGEX_FLAGS_SI);
|
||||
private static final Pattern P_PROTOCOL = Pattern.compile("^([^:]+):", REGEX_FLAGS_SI);
|
||||
private static final Pattern P_ENTITY = Pattern.compile("&#(\\d+);?");
|
||||
private static final Pattern P_ENTITY_UNICODE = Pattern.compile("&#x([0-9a-f]+);?");
|
||||
private static final Pattern P_ENCODE = Pattern.compile("%([0-9a-f]{2});?");
|
||||
private static final Pattern P_VALID_ENTITIES = Pattern.compile("&([^&;]*)(?=(;|&|$))");
|
||||
private static final Pattern P_VALID_QUOTES = Pattern.compile("(>|^)([^<]+?)(<|$)", Pattern.DOTALL);
|
||||
private static final Pattern P_END_ARROW = Pattern.compile("^>");
|
||||
private static final Pattern P_BODY_TO_END = Pattern.compile("<([^>]*?)(?=<|$)");
|
||||
private static final Pattern P_XML_CONTENT = Pattern.compile("(^|>)([^<]*?)(?=>)");
|
||||
private static final Pattern P_STRAY_LEFT_ARROW = Pattern.compile("<([^>]*?)(?=<|$)");
|
||||
private static final Pattern P_STRAY_RIGHT_ARROW = Pattern.compile("(^|>)([^<]*?)(?=>)");
|
||||
private static final Pattern P_AMP = Pattern.compile("&");
|
||||
private static final Pattern P_QUOTE = Pattern.compile("<");
|
||||
private static final Pattern P_LEFT_ARROW = Pattern.compile("<");
|
||||
private static final Pattern P_RIGHT_ARROW = Pattern.compile(">");
|
||||
private static final Pattern P_BOTH_ARROWS = Pattern.compile("<>");
|
||||
|
||||
// @xxx could grow large... maybe use sesat's ReferenceMap
|
||||
private static final ConcurrentMap<String,Pattern> P_REMOVE_PAIR_BLANKS = new ConcurrentHashMap<String, Pattern>();
|
||||
private static final ConcurrentMap<String,Pattern> P_REMOVE_SELF_BLANKS = new ConcurrentHashMap<String, Pattern>();
|
||||
|
||||
/** set of allowed html elements, along with allowed attributes for each element **/
|
||||
private final Map<String, List<String>> vAllowed;
|
||||
/** counts of open tags for each (allowable) html element **/
|
||||
private final Map<String, Integer> vTagCounts = new HashMap<String, Integer>();
|
||||
|
||||
/** html elements which must always be self-closing (e.g. "<img />") **/
|
||||
private final String[] vSelfClosingTags;
|
||||
/** html elements which must always have separate opening and closing tags (e.g. "<b></b>") **/
|
||||
private final String[] vNeedClosingTags;
|
||||
/** set of disallowed html elements **/
|
||||
private final String[] vDisallowed;
|
||||
/** attributes which should be checked for valid protocols **/
|
||||
private final String[] vProtocolAtts;
|
||||
/** allowed protocols **/
|
||||
private final String[] vAllowedProtocols;
|
||||
/** tags which should be removed if they contain no content (e.g. "<b></b>" or "<b />") **/
|
||||
private final String[] vRemoveBlanks;
|
||||
/** entities allowed within html markup **/
|
||||
private final String[] vAllowedEntities;
|
||||
/** flag determining whether comments are allowed in input String. */
|
||||
private final boolean stripComment;
|
||||
private final boolean encodeQuotes;
|
||||
private boolean vDebug = false;
|
||||
/**
|
||||
* flag determining whether to try to make tags when presented with "unbalanced"
|
||||
* angle brackets (e.g. "<b text </b>" becomes "<b> text </b>"). If set to false,
|
||||
* unbalanced angle brackets will be html escaped.
|
||||
*/
|
||||
private final boolean alwaysMakeTags;
|
||||
|
||||
/** Default constructor.
|
||||
*
|
||||
*/
|
||||
public HTMLFilter() {
|
||||
vAllowed = new HashMap<>();
|
||||
|
||||
final ArrayList<String> a_atts = new ArrayList<String>();
|
||||
a_atts.add("href");
|
||||
a_atts.add("target");
|
||||
vAllowed.put("a", a_atts);
|
||||
|
||||
final ArrayList<String> img_atts = new ArrayList<String>();
|
||||
img_atts.add("src");
|
||||
img_atts.add("width");
|
||||
img_atts.add("height");
|
||||
img_atts.add("alt");
|
||||
vAllowed.put("img", img_atts);
|
||||
|
||||
final ArrayList<String> no_atts = new ArrayList<String>();
|
||||
vAllowed.put("b", no_atts);
|
||||
vAllowed.put("strong", no_atts);
|
||||
vAllowed.put("i", no_atts);
|
||||
vAllowed.put("em", no_atts);
|
||||
|
||||
vSelfClosingTags = new String[]{"img"};
|
||||
vNeedClosingTags = new String[]{"a", "b", "strong", "i", "em"};
|
||||
vDisallowed = new String[]{};
|
||||
vAllowedProtocols = new String[]{"http", "mailto", "https"}; // no ftp.
|
||||
vProtocolAtts = new String[]{"src", "href"};
|
||||
vRemoveBlanks = new String[]{"a", "b", "strong", "i", "em"};
|
||||
vAllowedEntities = new String[]{"amp", "gt", "lt", "quot"};
|
||||
stripComment = true;
|
||||
encodeQuotes = true;
|
||||
alwaysMakeTags = true;
|
||||
}
|
||||
|
||||
/** Set debug flag to true. Otherwise use default settings. See the default constructor.
|
||||
*
|
||||
* @param debug turn debug on with a true argument
|
||||
*/
|
||||
public HTMLFilter(final boolean debug) {
|
||||
this();
|
||||
vDebug = debug;
|
||||
|
||||
}
|
||||
|
||||
/** Map-parameter configurable constructor.
|
||||
*
|
||||
* @param conf map containing configuration. keys match field names.
|
||||
*/
|
||||
public HTMLFilter(final Map<String,Object> conf) {
|
||||
|
||||
assert conf.containsKey("vAllowed") : "configuration requires vAllowed";
|
||||
assert conf.containsKey("vSelfClosingTags") : "configuration requires vSelfClosingTags";
|
||||
assert conf.containsKey("vNeedClosingTags") : "configuration requires vNeedClosingTags";
|
||||
assert conf.containsKey("vDisallowed") : "configuration requires vDisallowed";
|
||||
assert conf.containsKey("vAllowedProtocols") : "configuration requires vAllowedProtocols";
|
||||
assert conf.containsKey("vProtocolAtts") : "configuration requires vProtocolAtts";
|
||||
assert conf.containsKey("vRemoveBlanks") : "configuration requires vRemoveBlanks";
|
||||
assert conf.containsKey("vAllowedEntities") : "configuration requires vAllowedEntities";
|
||||
|
||||
vAllowed = Collections.unmodifiableMap((HashMap<String, List<String>>) conf.get("vAllowed"));
|
||||
vSelfClosingTags = (String[]) conf.get("vSelfClosingTags");
|
||||
vNeedClosingTags = (String[]) conf.get("vNeedClosingTags");
|
||||
vDisallowed = (String[]) conf.get("vDisallowed");
|
||||
vAllowedProtocols = (String[]) conf.get("vAllowedProtocols");
|
||||
vProtocolAtts = (String[]) conf.get("vProtocolAtts");
|
||||
vRemoveBlanks = (String[]) conf.get("vRemoveBlanks");
|
||||
vAllowedEntities = (String[]) conf.get("vAllowedEntities");
|
||||
stripComment = conf.containsKey("stripComment") ? (Boolean) conf.get("stripComment") : true;
|
||||
encodeQuotes = conf.containsKey("encodeQuotes") ? (Boolean) conf.get("encodeQuotes") : true;
|
||||
alwaysMakeTags = conf.containsKey("alwaysMakeTags") ? (Boolean) conf.get("alwaysMakeTags") : true;
|
||||
}
|
||||
|
||||
private void reset() {
|
||||
vTagCounts.clear();
|
||||
}
|
||||
|
||||
private void debug(final String msg) {
|
||||
if (vDebug) {
|
||||
Logger.getAnonymousLogger().info(msg);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// my versions of some PHP library functions
|
||||
public static String chr(final int decimal) {
|
||||
return String.valueOf((char) decimal);
|
||||
}
|
||||
|
||||
public static String htmlSpecialChars(final String s) {
|
||||
String result = s;
|
||||
result = regexReplace(P_AMP, "&", result);
|
||||
result = regexReplace(P_QUOTE, """, result);
|
||||
result = regexReplace(P_LEFT_ARROW, "<", result);
|
||||
result = regexReplace(P_RIGHT_ARROW, ">", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
/**
|
||||
* given a user submitted input String, filter out any invalid or restricted
|
||||
* html.
|
||||
*
|
||||
* @param input text (i.e. submitted by a user) than may contain html
|
||||
* @return "clean" version of input, with only valid, whitelisted html elements allowed
|
||||
*/
|
||||
public String filter(final String input) {
|
||||
reset();
|
||||
String s = input;
|
||||
|
||||
debug("************************************************");
|
||||
debug(" INPUT: " + input);
|
||||
|
||||
s = escapeComments(s);
|
||||
debug(" escapeComments: " + s);
|
||||
|
||||
s = balanceHTML(s);
|
||||
debug(" balanceHTML: " + s);
|
||||
|
||||
s = checkTags(s);
|
||||
debug(" checkTags: " + s);
|
||||
|
||||
s = processRemoveBlanks(s);
|
||||
debug("processRemoveBlanks: " + s);
|
||||
|
||||
s = validateEntities(s);
|
||||
debug(" validateEntites: " + s);
|
||||
|
||||
debug("************************************************\n\n");
|
||||
return s;
|
||||
}
|
||||
|
||||
public boolean isAlwaysMakeTags(){
|
||||
return alwaysMakeTags;
|
||||
}
|
||||
|
||||
public boolean isStripComments(){
|
||||
return stripComment;
|
||||
}
|
||||
|
||||
private String escapeComments(final String s) {
|
||||
final Matcher m = P_COMMENTS.matcher(s);
|
||||
final StringBuffer buf = new StringBuffer();
|
||||
if (m.find()) {
|
||||
final String match = m.group(1); //(.*?)
|
||||
m.appendReplacement(buf, Matcher.quoteReplacement("<!--" + htmlSpecialChars(match) + "-->"));
|
||||
}
|
||||
m.appendTail(buf);
|
||||
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
private String balanceHTML(String s) {
|
||||
if (alwaysMakeTags) {
|
||||
//
|
||||
// try and form html
|
||||
//
|
||||
s = regexReplace(P_END_ARROW, "", s);
|
||||
s = regexReplace(P_BODY_TO_END, "<$1>", s);
|
||||
s = regexReplace(P_XML_CONTENT, "$1<$2", s);
|
||||
|
||||
} else {
|
||||
//
|
||||
// escape stray brackets
|
||||
//
|
||||
s = regexReplace(P_STRAY_LEFT_ARROW, "<$1", s);
|
||||
s = regexReplace(P_STRAY_RIGHT_ARROW, "$1$2><", s);
|
||||
|
||||
//
|
||||
// the last regexp causes '<>' entities to appear
|
||||
// (we need to do a lookahead assertion so that the last bracket can
|
||||
// be used in the next pass of the regexp)
|
||||
//
|
||||
s = regexReplace(P_BOTH_ARROWS, "", s);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
private String checkTags(String s) {
|
||||
Matcher m = P_TAGS.matcher(s);
|
||||
|
||||
final StringBuffer buf = new StringBuffer();
|
||||
while (m.find()) {
|
||||
String replaceStr = m.group(1);
|
||||
replaceStr = processTag(replaceStr);
|
||||
m.appendReplacement(buf, Matcher.quoteReplacement(replaceStr));
|
||||
}
|
||||
m.appendTail(buf);
|
||||
|
||||
s = buf.toString();
|
||||
|
||||
// these get tallied in processTag
|
||||
// (remember to reset before subsequent calls to filter method)
|
||||
for (String key : vTagCounts.keySet()) {
|
||||
for (int ii = 0; ii < vTagCounts.get(key); ii++) {
|
||||
s += "</" + key + ">";
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
private String processRemoveBlanks(final String s) {
|
||||
String result = s;
|
||||
for (String tag : vRemoveBlanks) {
|
||||
if(!P_REMOVE_PAIR_BLANKS.containsKey(tag)){
|
||||
P_REMOVE_PAIR_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?></" + tag + ">"));
|
||||
}
|
||||
result = regexReplace(P_REMOVE_PAIR_BLANKS.get(tag), "", result);
|
||||
if(!P_REMOVE_SELF_BLANKS.containsKey(tag)){
|
||||
P_REMOVE_SELF_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?/>"));
|
||||
}
|
||||
result = regexReplace(P_REMOVE_SELF_BLANKS.get(tag), "", result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static String regexReplace(final Pattern regex_pattern, final String replacement, final String s) {
|
||||
Matcher m = regex_pattern.matcher(s);
|
||||
return m.replaceAll(replacement);
|
||||
}
|
||||
|
||||
private String processTag(final String s) {
|
||||
// ending tags
|
||||
Matcher m = P_END_TAG.matcher(s);
|
||||
if (m.find()) {
|
||||
final String name = m.group(1).toLowerCase();
|
||||
if (allowed(name)) {
|
||||
if (!inArray(name, vSelfClosingTags)) {
|
||||
if (vTagCounts.containsKey(name)) {
|
||||
vTagCounts.put(name, vTagCounts.get(name) - 1);
|
||||
return "</" + name + ">";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// starting tags
|
||||
m = P_START_TAG.matcher(s);
|
||||
if (m.find()) {
|
||||
final String name = m.group(1).toLowerCase();
|
||||
final String body = m.group(2);
|
||||
String ending = m.group(3);
|
||||
|
||||
//debug( "in a starting tag, name='" + name + "'; body='" + body + "'; ending='" + ending + "'" );
|
||||
if (allowed(name)) {
|
||||
String params = "";
|
||||
|
||||
final Matcher m2 = P_QUOTED_ATTRIBUTES.matcher(body);
|
||||
final Matcher m3 = P_UNQUOTED_ATTRIBUTES.matcher(body);
|
||||
final List<String> paramNames = new ArrayList<String>();
|
||||
final List<String> paramValues = new ArrayList<String>();
|
||||
while (m2.find()) {
|
||||
paramNames.add(m2.group(1)); //([a-z0-9]+)
|
||||
paramValues.add(m2.group(3)); //(.*?)
|
||||
}
|
||||
while (m3.find()) {
|
||||
paramNames.add(m3.group(1)); //([a-z0-9]+)
|
||||
paramValues.add(m3.group(3)); //([^\"\\s']+)
|
||||
}
|
||||
|
||||
String paramName, paramValue;
|
||||
for (int ii = 0; ii < paramNames.size(); ii++) {
|
||||
paramName = paramNames.get(ii).toLowerCase();
|
||||
paramValue = paramValues.get(ii);
|
||||
|
||||
// debug( "paramName='" + paramName + "'" );
|
||||
// debug( "paramValue='" + paramValue + "'" );
|
||||
// debug( "allowed? " + vAllowed.get( name ).contains( paramName ) );
|
||||
|
||||
if (allowedAttribute(name, paramName)) {
|
||||
if (inArray(paramName, vProtocolAtts)) {
|
||||
paramValue = processParamProtocol(paramValue);
|
||||
}
|
||||
params += " " + paramName + "=\"" + paramValue + "\"";
|
||||
}
|
||||
}
|
||||
|
||||
if (inArray(name, vSelfClosingTags)) {
|
||||
ending = " /";
|
||||
}
|
||||
|
||||
if (inArray(name, vNeedClosingTags)) {
|
||||
ending = "";
|
||||
}
|
||||
|
||||
if (ending == null || ending.length() < 1) {
|
||||
if (vTagCounts.containsKey(name)) {
|
||||
vTagCounts.put(name, vTagCounts.get(name) + 1);
|
||||
} else {
|
||||
vTagCounts.put(name, 1);
|
||||
}
|
||||
} else {
|
||||
ending = " /";
|
||||
}
|
||||
return "<" + name + params + ending + ">";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// comments
|
||||
m = P_COMMENT.matcher(s);
|
||||
if (!stripComment && m.find()) {
|
||||
return "<" + m.group() + ">";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
private String processParamProtocol(String s) {
|
||||
s = decodeEntities(s);
|
||||
final Matcher m = P_PROTOCOL.matcher(s);
|
||||
if (m.find()) {
|
||||
final String protocol = m.group(1);
|
||||
if (!inArray(protocol, vAllowedProtocols)) {
|
||||
// bad protocol, turn into local anchor link instead
|
||||
s = "#" + s.substring(protocol.length() + 1, s.length());
|
||||
if (s.startsWith("#//")) {
|
||||
s = "#" + s.substring(3, s.length());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
private String decodeEntities(String s) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
Matcher m = P_ENTITY.matcher(s);
|
||||
while (m.find()) {
|
||||
final String match = m.group(1);
|
||||
final int decimal = Integer.decode(match).intValue();
|
||||
m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
|
||||
}
|
||||
m.appendTail(buf);
|
||||
s = buf.toString();
|
||||
|
||||
buf = new StringBuffer();
|
||||
m = P_ENTITY_UNICODE.matcher(s);
|
||||
while (m.find()) {
|
||||
final String match = m.group(1);
|
||||
final int decimal = Integer.valueOf(match, 16).intValue();
|
||||
m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
|
||||
}
|
||||
m.appendTail(buf);
|
||||
s = buf.toString();
|
||||
|
||||
buf = new StringBuffer();
|
||||
m = P_ENCODE.matcher(s);
|
||||
while (m.find()) {
|
||||
final String match = m.group(1);
|
||||
final int decimal = Integer.valueOf(match, 16).intValue();
|
||||
m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
|
||||
}
|
||||
m.appendTail(buf);
|
||||
s = buf.toString();
|
||||
|
||||
s = validateEntities(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
private String validateEntities(final String s) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
// validate entities throughout the string
|
||||
Matcher m = P_VALID_ENTITIES.matcher(s);
|
||||
while (m.find()) {
|
||||
final String one = m.group(1); //([^&;]*)
|
||||
final String two = m.group(2); //(?=(;|&|$))
|
||||
m.appendReplacement(buf, Matcher.quoteReplacement(checkEntity(one, two)));
|
||||
}
|
||||
m.appendTail(buf);
|
||||
|
||||
return encodeQuotes(buf.toString());
|
||||
}
|
||||
|
||||
private String encodeQuotes(final String s){
|
||||
if(encodeQuotes){
|
||||
StringBuffer buf = new StringBuffer();
|
||||
Matcher m = P_VALID_QUOTES.matcher(s);
|
||||
while (m.find()) {
|
||||
final String one = m.group(1); //(>|^)
|
||||
final String two = m.group(2); //([^<]+?)
|
||||
final String three = m.group(3); //(<|$)
|
||||
m.appendReplacement(buf, Matcher.quoteReplacement(one + regexReplace(P_QUOTE, """, two) + three));
|
||||
}
|
||||
m.appendTail(buf);
|
||||
return buf.toString();
|
||||
}else{
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
private String checkEntity(final String preamble, final String term) {
|
||||
|
||||
return ";".equals(term) && isValidEntity(preamble)
|
||||
? '&' + preamble
|
||||
: "&" + preamble;
|
||||
}
|
||||
|
||||
private boolean isValidEntity(final String entity) {
|
||||
return inArray(entity, vAllowedEntities);
|
||||
}
|
||||
|
||||
private static boolean inArray(final String s, final String[] array) {
|
||||
for (String item : array) {
|
||||
if (item != null && item.equals(s)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean allowed(final String name) {
|
||||
return (vAllowed.isEmpty() || vAllowed.containsKey(name)) && !inArray(name, vDisallowed);
|
||||
}
|
||||
|
||||
private boolean allowedAttribute(final String name, final String paramName) {
|
||||
return allowed(name) && (vAllowed.isEmpty() || vAllowed.get(name).contains(paramName));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
|
||||
|
||||
package com.zcloud.common.xss;
|
||||
|
||||
import com.zcloud.common.exception.ZException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* SQL过滤
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class SQLFilter {
|
||||
|
||||
/**
|
||||
* SQL注入过滤
|
||||
* @param str 待验证的字符串
|
||||
*/
|
||||
public static String sqlInject(String str){
|
||||
if(StringUtils.isBlank(str)){
|
||||
return null;
|
||||
}
|
||||
//去掉'|"|;|\字符
|
||||
str = StringUtils.replace(str, "'", "");
|
||||
str = StringUtils.replace(str, "\"", "");
|
||||
str = StringUtils.replace(str, ";", "");
|
||||
str = StringUtils.replace(str, "\\", "");
|
||||
|
||||
//转换成小写
|
||||
str = str.toLowerCase();
|
||||
|
||||
//非法字符
|
||||
String[] keywords = {"master", "truncate", "insert", "select", "delete", "update", "declare", "alter", "drop"};
|
||||
|
||||
//判断是否包含非法字符
|
||||
for(String keyword : keywords){
|
||||
if(str.indexOf(keyword) != -1){
|
||||
throw new ZException("包含非法字符");
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
|
||||
package com.zcloud.common.xss;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* XSS过滤
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class XssFilter implements Filter {
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig config) throws ServletException {
|
||||
}
|
||||
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper(
|
||||
(HttpServletRequest) request);
|
||||
chain.doFilter(xssRequest, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
|
||||
|
||||
package com.zcloud.common.xss;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
import javax.servlet.ReadListener;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* XSS过滤处理
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
//没被包装过的HttpServletRequest(特殊场景,需要自己过滤)
|
||||
HttpServletRequest orgRequest;
|
||||
//html过滤
|
||||
private final static HTMLFilter htmlFilter = new HTMLFilter();
|
||||
|
||||
public XssHttpServletRequestWrapper(HttpServletRequest request) {
|
||||
super(request);
|
||||
orgRequest = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletInputStream getInputStream() throws IOException {
|
||||
//非json类型,直接返回
|
||||
if(!MediaType.APPLICATION_JSON_VALUE.equalsIgnoreCase(super.getHeader(HttpHeaders.CONTENT_TYPE))){
|
||||
return super.getInputStream();
|
||||
}
|
||||
|
||||
//为空,直接返回
|
||||
String json = IOUtils.toString(super.getInputStream(), "utf-8");
|
||||
if (StringUtils.isBlank(json)) {
|
||||
return super.getInputStream();
|
||||
}
|
||||
|
||||
//xss过滤
|
||||
json = xssEncode(json);
|
||||
final ByteArrayInputStream bis = new ByteArrayInputStream(json.getBytes("utf-8"));
|
||||
return new ServletInputStream() {
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadListener(ReadListener readListener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
return bis.read();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParameter(String name) {
|
||||
String value = super.getParameter(xssEncode(name));
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
value = xssEncode(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getParameterValues(String name) {
|
||||
String[] parameters = super.getParameterValues(name);
|
||||
if (parameters == null || parameters.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
parameters[i] = xssEncode(parameters[i]);
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,String[]> getParameterMap() {
|
||||
Map<String,String[]> map = new LinkedHashMap<>();
|
||||
Map<String,String[]> parameters = super.getParameterMap();
|
||||
for (String key : parameters.keySet()) {
|
||||
String[] values = parameters.get(key);
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
values[i] = xssEncode(values[i]);
|
||||
}
|
||||
map.put(key, values);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHeader(String name) {
|
||||
String value = super.getHeader(xssEncode(name));
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
value = xssEncode(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private String xssEncode(String input) {
|
||||
return htmlFilter.filter(input);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最原始的request
|
||||
*/
|
||||
public HttpServletRequest getOrgRequest() {
|
||||
return orgRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最原始的request
|
||||
*/
|
||||
public static HttpServletRequest getOrgRequest(HttpServletRequest request) {
|
||||
if (request instanceof XssHttpServletRequestWrapper) {
|
||||
return ((XssHttpServletRequestWrapper) request).getOrgRequest();
|
||||
}
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
|
||||
package com.zcloud.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class CorsConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
.allowedOriginPatterns("*")
|
||||
.allowCredentials(true)
|
||||
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
|
||||
.maxAge(3600);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
|
||||
|
||||
package com.zcloud.config;
|
||||
|
||||
import com.zcloud.common.xss.XssFilter;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.filter.DelegatingFilterProxy;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
|
||||
/**
|
||||
* Filter配置
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class FilterConfig {
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean shiroFilterRegistration() {
|
||||
FilterRegistrationBean registration = new FilterRegistrationBean();
|
||||
registration.setFilter(new DelegatingFilterProxy("shiroFilter"));
|
||||
//该值缺省为false,表示生命周期由SpringApplicationContext管理,设置为true则表示由ServletContainer管理
|
||||
registration.addInitParameter("targetFilterLifecycle", "true");
|
||||
registration.setEnabled(true);
|
||||
registration.setOrder(Integer.MAX_VALUE - 1);
|
||||
registration.addUrlPatterns("/*");
|
||||
return registration;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean xssFilterRegistration() {
|
||||
FilterRegistrationBean registration = new FilterRegistrationBean();
|
||||
registration.setDispatcherTypes(DispatcherType.REQUEST);
|
||||
registration.setFilter(new XssFilter());
|
||||
registration.addUrlPatterns("/*");
|
||||
registration.setName("xssFilter");
|
||||
registration.setOrder(Integer.MAX_VALUE);
|
||||
return registration;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
|
||||
|
||||
package com.zcloud.config;
|
||||
|
||||
import com.google.code.kaptcha.impl.DefaultKaptcha;
|
||||
import com.google.code.kaptcha.util.Config;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
/**
|
||||
* 生成验证码配置
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class KaptchaConfig {
|
||||
|
||||
@Bean
|
||||
public DefaultKaptcha producer() {
|
||||
Properties properties = new Properties();
|
||||
properties.put("kaptcha.border", "no");
|
||||
properties.put("kaptcha.textproducer.font.color", "black");
|
||||
properties.put("kaptcha.textproducer.char.space", "5");
|
||||
properties.put("kaptcha.textproducer.font.names", "Arial,Courier,cmr10,宋体,楷体,微软雅黑");
|
||||
Config config = new Config(properties);
|
||||
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
|
||||
defaultKaptcha.setConfig(config);
|
||||
return defaultKaptcha;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.zcloud.config;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* mybatis-plus配置
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
/**
|
||||
* 分页插件
|
||||
*/
|
||||
@Bean
|
||||
public PaginationInnerInterceptor paginationInterceptor() {
|
||||
return new PaginationInnerInterceptor();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
|
||||
|
||||
package com.zcloud.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.*;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
/**
|
||||
* Redis配置
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class RedisConfig {
|
||||
@Autowired
|
||||
private RedisConnectionFactory factory;
|
||||
|
||||
@Bean
|
||||
public RedisTemplate<String, Object> redisTemplate() {
|
||||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
||||
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
|
||||
redisTemplate.setHashValueSerializer(new StringRedisSerializer());
|
||||
redisTemplate.setValueSerializer(new StringRedisSerializer());
|
||||
redisTemplate.setConnectionFactory(factory);
|
||||
return redisTemplate;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public HashOperations<String, String, Object> hashOperations(RedisTemplate<String, Object> redisTemplate) {
|
||||
return redisTemplate.opsForHash();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ValueOperations<String, String> valueOperations(RedisTemplate<String, String> redisTemplate) {
|
||||
return redisTemplate.opsForValue();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ListOperations<String, Object> listOperations(RedisTemplate<String, Object> redisTemplate) {
|
||||
return redisTemplate.opsForList();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SetOperations<String, Object> setOperations(RedisTemplate<String, Object> redisTemplate) {
|
||||
return redisTemplate.opsForSet();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ZSetOperations<String, Object> zSetOperations(RedisTemplate<String, Object> redisTemplate) {
|
||||
return redisTemplate.opsForZSet();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.zcloud.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@Configuration
|
||||
public class RestTemplateConfig {
|
||||
//启动时需要实例化该类的一个实例
|
||||
@Autowired
|
||||
private RestTemplateBuilder builder;
|
||||
//使用RestTemplateBuilder来实例化RestTemplate对象,Spring已经默认注入了RestTemplateBuilder实例
|
||||
@Bean
|
||||
public RestTemplate restTemplate(){
|
||||
return builder.build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package com.zcloud.config;
|
||||
|
||||
import com.zcloud.modules.sys.oauth2.OAuth2Filter;
|
||||
import com.zcloud.modules.sys.oauth2.OAuth2Realm;
|
||||
import org.apache.shiro.mgt.SecurityManager;
|
||||
import org.apache.shiro.spring.LifecycleBeanPostProcessor;
|
||||
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
|
||||
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
|
||||
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Shiro配置
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class ShiroConfig {
|
||||
|
||||
@Bean("securityManager")
|
||||
public SecurityManager securityManager(OAuth2Realm oAuth2Realm) {
|
||||
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
|
||||
securityManager.setRealm(oAuth2Realm);
|
||||
securityManager.setRememberMeManager(null);
|
||||
return securityManager;
|
||||
}
|
||||
|
||||
@Bean("shiroFilter")
|
||||
public ShiroFilterFactoryBean shiroFilter(SecurityManager securityManager) {
|
||||
ShiroFilterFactoryBean shiroFilter = new ShiroFilterFactoryBean();
|
||||
shiroFilter.setSecurityManager(securityManager);
|
||||
|
||||
//oauth过滤
|
||||
Map<String, Filter> filters = new HashMap<>();
|
||||
filters.put("oauth2", new OAuth2Filter());
|
||||
shiroFilter.setFilters(filters);
|
||||
|
||||
Map<String, String> filterMap = new LinkedHashMap<>();
|
||||
filterMap.put("/webjars/**", "anon");
|
||||
filterMap.put("/druid/**", "anon");
|
||||
filterMap.put("/app/**", "anon");
|
||||
filterMap.put("/busExercises/downExcel", "anon");
|
||||
filterMap.put("/busStudyTask/downExamExcel", "anon");
|
||||
filterMap.put("/sys/login", "anon");
|
||||
filterMap.put("/busVisitor/**", "anon");
|
||||
filterMap.put("/fireCheckList/**", "anon");
|
||||
filterMap.put("/sys/dictionaries/**", "anon");
|
||||
filterMap.put("/map/**/**", "anon");
|
||||
// filterMap.put("/swagger/**", "anon");
|
||||
// filterMap.put("/v2/api-docs", "anon");
|
||||
// filterMap.put("/swagger-ui.html", "anon");
|
||||
// filterMap.put("/swagger-resources/**", "anon");
|
||||
filterMap.put("/captcha.jpg", "anon");
|
||||
// filterMap.put("/aaa.txt", "anon");
|
||||
filterMap.put("/**", "oauth2");
|
||||
shiroFilter.setFilterChainDefinitionMap(filterMap);
|
||||
|
||||
return shiroFilter;
|
||||
}
|
||||
|
||||
@Bean("lifecycleBeanPostProcessor")
|
||||
public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() {
|
||||
return new LifecycleBeanPostProcessor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) {
|
||||
AuthorizationAttributeSourceAdvisor advisor = new AuthorizationAttributeSourceAdvisor();
|
||||
advisor.setSecurityManager(securityManager);
|
||||
return advisor;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
|
||||
|
||||
package com.zcloud.config;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.ApiKey;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
@Configuration
|
||||
//@EnableSwagger2
|
||||
public class SwaggerConfig implements WebMvcConfigurer {
|
||||
|
||||
@Bean
|
||||
public Docket createRestApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
//加了ApiOperation注解的类,才生成接口文档
|
||||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
||||
//包下的类,才生成接口文档
|
||||
// .apis(Predicates.or(
|
||||
// RequestHandlerSelectors.basePackage("com.zcloud.modules.app.controller"),
|
||||
// RequestHandlerSelectors.basePackage("com.zcloud.modules.sys.controller")
|
||||
// ))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
.securitySchemes(security());
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("教育")
|
||||
.description("文档")
|
||||
.version("1.0.0")
|
||||
.build();
|
||||
}
|
||||
|
||||
private List<ApiKey> security() {
|
||||
return newArrayList(
|
||||
new ApiKey("token", "token", "header")
|
||||
);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Docket web_api_app() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.any())
|
||||
.paths(PathSelectors.ant("/app/**"))
|
||||
.build()
|
||||
.groupName("APP")
|
||||
.pathMapping("/");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.zcloud.datasource.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 多数据源注解
|
||||
*
|
||||
*/
|
||||
@Target({ElementType.METHOD, ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Inherited
|
||||
public @interface DataSource {
|
||||
String value() default "";
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.zcloud.datasource.aspect;
|
||||
|
||||
|
||||
import com.zcloud.datasource.annotation.DataSource;
|
||||
import com.zcloud.datasource.config.DynamicContextHolder;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* 多数据源,切面处理类
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
public class DataSourceAspect {
|
||||
protected Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Pointcut("@annotation(com.zcloud.datasource.annotation.DataSource) " +
|
||||
"|| @within(com.zcloud.datasource.annotation.DataSource)")
|
||||
public void dataSourcePointCut() {
|
||||
|
||||
}
|
||||
|
||||
@Around("dataSourcePointCut()")
|
||||
public Object around(ProceedingJoinPoint point) throws Throwable {
|
||||
MethodSignature signature = (MethodSignature) point.getSignature();
|
||||
Class targetClass = point.getTarget().getClass();
|
||||
Method method = signature.getMethod();
|
||||
|
||||
DataSource targetDataSource = (DataSource)targetClass.getAnnotation(DataSource.class);
|
||||
DataSource methodDataSource = method.getAnnotation(DataSource.class);
|
||||
if(targetDataSource != null || methodDataSource != null){
|
||||
String value;
|
||||
if(methodDataSource != null){
|
||||
value = methodDataSource.value();
|
||||
}else {
|
||||
value = targetDataSource.value();
|
||||
}
|
||||
|
||||
DynamicContextHolder.push(value);
|
||||
logger.debug("set datasource is {}", value);
|
||||
}
|
||||
|
||||
try {
|
||||
return point.proceed();
|
||||
} finally {
|
||||
DynamicContextHolder.poll();
|
||||
logger.debug("clean datasource");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.zcloud.datasource.config;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
|
||||
/**
|
||||
* 多数据源上下文
|
||||
*/
|
||||
public class DynamicContextHolder {
|
||||
@SuppressWarnings("unchecked")
|
||||
private static final ThreadLocal<Deque<String>> CONTEXT_HOLDER = new ThreadLocal() {
|
||||
@Override
|
||||
protected Object initialValue() {
|
||||
return new ArrayDeque();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 获得当前线程数据源
|
||||
*
|
||||
* @return 数据源名称
|
||||
*/
|
||||
public static String peek() {
|
||||
return CONTEXT_HOLDER.get().peek();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前线程数据源
|
||||
*
|
||||
* @param dataSource 数据源名称
|
||||
*/
|
||||
public static void push(String dataSource) {
|
||||
CONTEXT_HOLDER.get().push(dataSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空当前线程数据源
|
||||
*/
|
||||
public static void poll() {
|
||||
Deque<String> deque = CONTEXT_HOLDER.get();
|
||||
deque.poll();
|
||||
if (deque.isEmpty()) {
|
||||
CONTEXT_HOLDER.remove();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.zcloud.datasource.config;
|
||||
|
||||
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
|
||||
|
||||
/**
|
||||
* 多数据源
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class DynamicDataSource extends AbstractRoutingDataSource {
|
||||
|
||||
@Override
|
||||
protected Object determineCurrentLookupKey() {
|
||||
return DynamicContextHolder.peek();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.zcloud.datasource.config;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.zcloud.datasource.properties.DataSourceProperties;
|
||||
import com.zcloud.datasource.properties.DynamicDataSourceProperties;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 配置多数据源
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(DynamicDataSourceProperties.class)
|
||||
public class DynamicDataSourceConfig {
|
||||
@Autowired
|
||||
private DynamicDataSourceProperties properties;
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "spring.datasource.druid")
|
||||
public DataSourceProperties dataSourceProperties() {
|
||||
return new DataSourceProperties();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DynamicDataSource dynamicDataSource(DataSourceProperties dataSourceProperties) {
|
||||
DynamicDataSource dynamicDataSource = new DynamicDataSource();
|
||||
dynamicDataSource.setTargetDataSources(getDynamicDataSource());
|
||||
|
||||
//默认数据源
|
||||
DruidDataSource defaultDataSource = DynamicDataSourceFactory.buildDruidDataSource(dataSourceProperties);
|
||||
dynamicDataSource.setDefaultTargetDataSource(defaultDataSource);
|
||||
|
||||
return dynamicDataSource;
|
||||
}
|
||||
|
||||
private Map<Object, Object> getDynamicDataSource(){
|
||||
Map<String, DataSourceProperties> dataSourcePropertiesMap = properties.getDatasource();
|
||||
Map<Object, Object> targetDataSources = new HashMap<>(dataSourcePropertiesMap.size());
|
||||
dataSourcePropertiesMap.forEach((k, v) -> {
|
||||
DruidDataSource druidDataSource = DynamicDataSourceFactory.buildDruidDataSource(v);
|
||||
targetDataSources.put(k, druidDataSource);
|
||||
});
|
||||
|
||||
return targetDataSources;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.zcloud.datasource.config;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.zcloud.datasource.properties.DataSourceProperties;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* DruidDataSource
|
||||
*
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class DynamicDataSourceFactory {
|
||||
|
||||
public static DruidDataSource buildDruidDataSource(DataSourceProperties properties) {
|
||||
DruidDataSource druidDataSource = new DruidDataSource();
|
||||
druidDataSource.setDriverClassName(properties.getDriverClassName());
|
||||
druidDataSource.setUrl(properties.getUrl());
|
||||
druidDataSource.setUsername(properties.getUsername());
|
||||
druidDataSource.setPassword(properties.getPassword());
|
||||
|
||||
druidDataSource.setInitialSize(properties.getInitialSize());
|
||||
druidDataSource.setMaxActive(properties.getMaxActive());
|
||||
druidDataSource.setMinIdle(properties.getMinIdle());
|
||||
druidDataSource.setMaxWait(properties.getMaxWait());
|
||||
druidDataSource.setTimeBetweenEvictionRunsMillis(properties.getTimeBetweenEvictionRunsMillis());
|
||||
druidDataSource.setMinEvictableIdleTimeMillis(properties.getMinEvictableIdleTimeMillis());
|
||||
druidDataSource.setMaxEvictableIdleTimeMillis(properties.getMaxEvictableIdleTimeMillis());
|
||||
druidDataSource.setValidationQuery(properties.getValidationQuery());
|
||||
druidDataSource.setValidationQueryTimeout(properties.getValidationQueryTimeout());
|
||||
druidDataSource.setTestOnBorrow(properties.isTestOnBorrow());
|
||||
druidDataSource.setTestOnReturn(properties.isTestOnReturn());
|
||||
druidDataSource.setPoolPreparedStatements(properties.isPoolPreparedStatements());
|
||||
druidDataSource.setMaxOpenPreparedStatements(properties.getMaxOpenPreparedStatements());
|
||||
druidDataSource.setSharePreparedStatements(properties.isSharePreparedStatements());
|
||||
|
||||
try {
|
||||
druidDataSource.setFilters(properties.getFilters());
|
||||
druidDataSource.init();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return druidDataSource;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,194 @@
|
|||
package com.zcloud.datasource.properties;
|
||||
|
||||
/**
|
||||
* 多数据源属性
|
||||
*
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class DataSourceProperties {
|
||||
private String driverClassName;
|
||||
private String url;
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* Druid默认参数
|
||||
*/
|
||||
private int initialSize = 2;
|
||||
private int maxActive = 10;
|
||||
private int minIdle = -1;
|
||||
private long maxWait = 60 * 1000L;
|
||||
private long timeBetweenEvictionRunsMillis = 60 * 1000L;
|
||||
private long minEvictableIdleTimeMillis = 1000L * 60L * 30L;
|
||||
private long maxEvictableIdleTimeMillis = 1000L * 60L * 60L * 7;
|
||||
private String validationQuery = "select 1";
|
||||
private int validationQueryTimeout = -1;
|
||||
private boolean testOnBorrow = false;
|
||||
private boolean testOnReturn = false;
|
||||
private boolean testWhileIdle = true;
|
||||
private boolean poolPreparedStatements = false;
|
||||
private int maxOpenPreparedStatements = -1;
|
||||
private boolean sharePreparedStatements = false;
|
||||
private String filters = "stat,wall";
|
||||
|
||||
public String getDriverClassName() {
|
||||
return driverClassName;
|
||||
}
|
||||
|
||||
public void setDriverClassName(String driverClassName) {
|
||||
this.driverClassName = driverClassName;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public int getInitialSize() {
|
||||
return initialSize;
|
||||
}
|
||||
|
||||
public void setInitialSize(int initialSize) {
|
||||
this.initialSize = initialSize;
|
||||
}
|
||||
|
||||
public int getMaxActive() {
|
||||
return maxActive;
|
||||
}
|
||||
|
||||
public void setMaxActive(int maxActive) {
|
||||
this.maxActive = maxActive;
|
||||
}
|
||||
|
||||
public int getMinIdle() {
|
||||
return minIdle;
|
||||
}
|
||||
|
||||
public void setMinIdle(int minIdle) {
|
||||
this.minIdle = minIdle;
|
||||
}
|
||||
|
||||
public long getMaxWait() {
|
||||
return maxWait;
|
||||
}
|
||||
|
||||
public void setMaxWait(long maxWait) {
|
||||
this.maxWait = maxWait;
|
||||
}
|
||||
|
||||
public long getTimeBetweenEvictionRunsMillis() {
|
||||
return timeBetweenEvictionRunsMillis;
|
||||
}
|
||||
|
||||
public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) {
|
||||
this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
|
||||
}
|
||||
|
||||
public long getMinEvictableIdleTimeMillis() {
|
||||
return minEvictableIdleTimeMillis;
|
||||
}
|
||||
|
||||
public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) {
|
||||
this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
|
||||
}
|
||||
|
||||
public long getMaxEvictableIdleTimeMillis() {
|
||||
return maxEvictableIdleTimeMillis;
|
||||
}
|
||||
|
||||
public void setMaxEvictableIdleTimeMillis(long maxEvictableIdleTimeMillis) {
|
||||
this.maxEvictableIdleTimeMillis = maxEvictableIdleTimeMillis;
|
||||
}
|
||||
|
||||
public String getValidationQuery() {
|
||||
return validationQuery;
|
||||
}
|
||||
|
||||
public void setValidationQuery(String validationQuery) {
|
||||
this.validationQuery = validationQuery;
|
||||
}
|
||||
|
||||
public int getValidationQueryTimeout() {
|
||||
return validationQueryTimeout;
|
||||
}
|
||||
|
||||
public void setValidationQueryTimeout(int validationQueryTimeout) {
|
||||
this.validationQueryTimeout = validationQueryTimeout;
|
||||
}
|
||||
|
||||
public boolean isTestOnBorrow() {
|
||||
return testOnBorrow;
|
||||
}
|
||||
|
||||
public void setTestOnBorrow(boolean testOnBorrow) {
|
||||
this.testOnBorrow = testOnBorrow;
|
||||
}
|
||||
|
||||
public boolean isTestOnReturn() {
|
||||
return testOnReturn;
|
||||
}
|
||||
|
||||
public void setTestOnReturn(boolean testOnReturn) {
|
||||
this.testOnReturn = testOnReturn;
|
||||
}
|
||||
|
||||
public boolean isTestWhileIdle() {
|
||||
return testWhileIdle;
|
||||
}
|
||||
|
||||
public void setTestWhileIdle(boolean testWhileIdle) {
|
||||
this.testWhileIdle = testWhileIdle;
|
||||
}
|
||||
|
||||
public boolean isPoolPreparedStatements() {
|
||||
return poolPreparedStatements;
|
||||
}
|
||||
|
||||
public void setPoolPreparedStatements(boolean poolPreparedStatements) {
|
||||
this.poolPreparedStatements = poolPreparedStatements;
|
||||
}
|
||||
|
||||
public int getMaxOpenPreparedStatements() {
|
||||
return maxOpenPreparedStatements;
|
||||
}
|
||||
|
||||
public void setMaxOpenPreparedStatements(int maxOpenPreparedStatements) {
|
||||
this.maxOpenPreparedStatements = maxOpenPreparedStatements;
|
||||
}
|
||||
|
||||
public boolean isSharePreparedStatements() {
|
||||
return sharePreparedStatements;
|
||||
}
|
||||
|
||||
public void setSharePreparedStatements(boolean sharePreparedStatements) {
|
||||
this.sharePreparedStatements = sharePreparedStatements;
|
||||
}
|
||||
|
||||
public String getFilters() {
|
||||
return filters;
|
||||
}
|
||||
|
||||
public void setFilters(String filters) {
|
||||
this.filters = filters;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.zcloud.datasource.properties;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 多数据源属性
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "dynamic")
|
||||
public class DynamicDataSourceProperties {
|
||||
private Map<String, DataSourceProperties> datasource = new LinkedHashMap<>();
|
||||
|
||||
public Map<String, DataSourceProperties> getDatasource() {
|
||||
return datasource;
|
||||
}
|
||||
|
||||
public void setDatasource(Map<String, DataSourceProperties> datasource) {
|
||||
this.datasource = datasource;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.zcloud.modules.RyCheck.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("ry_check_hidden_push")
|
||||
public class CheckHiddenPushEntity {
|
||||
@TableId(type = IdType.NONE)
|
||||
private String PUSH_ID;
|
||||
|
||||
private String HIDDEN_ID;
|
||||
private String PUSH_TIME;
|
||||
private String DATA;
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.zcloud.modules.RyCheck.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("bus_hiddencheck")
|
||||
public class HiddenCheckUserEntity {
|
||||
@TableId(type = IdType.NONE)
|
||||
private String HIDDENCHECK_ID;
|
||||
|
||||
private String HIDDEN_ID;
|
||||
|
||||
private String DEPARTMENT_ID;
|
||||
|
||||
private String USER_ID;
|
||||
|
||||
private String STATUS;
|
||||
|
||||
private String CHECK_TIME;
|
||||
private String CHECKDESCR;
|
||||
|
||||
public HiddenCheckUserEntity() {
|
||||
}
|
||||
|
||||
public HiddenCheckUserEntity(String HIDDENCHECK_ID, String HIDDEN_ID, String DEPARTMENT_ID, String USER_ID, String STATUS, String CHECK_TIME, String CHECKDESCR) {
|
||||
this.HIDDENCHECK_ID = HIDDENCHECK_ID;
|
||||
this.HIDDEN_ID = HIDDEN_ID;
|
||||
this.DEPARTMENT_ID = DEPARTMENT_ID;
|
||||
this.USER_ID = USER_ID;
|
||||
this.STATUS = STATUS;
|
||||
this.CHECK_TIME = CHECK_TIME;
|
||||
this.CHECKDESCR = CHECKDESCR;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
package com.zcloud.modules.RyCheck.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("bus_hidden")
|
||||
public class HiddenEntity {
|
||||
@TableId(type = IdType.NONE)
|
||||
private String HIDDEN_ID;
|
||||
|
||||
private String SOURCE;
|
||||
|
||||
private String RISK_UNIT;
|
||||
|
||||
private String IDENTIFICATION;
|
||||
|
||||
private String RISK_DESCR;
|
||||
|
||||
private String RISK_POSITION;
|
||||
|
||||
private String LEVEL;
|
||||
|
||||
private String CHECK_CONTENT;
|
||||
|
||||
private String HIDDENDESCR;
|
||||
|
||||
private String HIDDENPART;
|
||||
|
||||
private String CREATOR;
|
||||
|
||||
private String CREATTIME;
|
||||
|
||||
private String RECTIFYDESCR;
|
||||
|
||||
private String RECTIFICATIONTYPE;
|
||||
|
||||
private String RECTIFICATIONDEPT;
|
||||
|
||||
private String RECTIFICATIONOR;
|
||||
|
||||
private String RECTIFICATIONDEADLINE;
|
||||
|
||||
private String RECTIFICATIONTIME;
|
||||
|
||||
private String HIDDENLEVEL;
|
||||
|
||||
private String STATE;
|
||||
|
||||
private String CHECKDEPT;
|
||||
|
||||
private String CHECKOR;
|
||||
|
||||
private String CHECKTIME;
|
||||
|
||||
private String CHECKDESCR;
|
||||
|
||||
private String ISQUALIFIED;
|
||||
|
||||
private String ISDELETE;
|
||||
|
||||
private String CORPINFO_ID;
|
||||
|
||||
private String HIDDENFINDDEPT;
|
||||
|
||||
private String CHECKRECORD_ID;
|
||||
|
||||
private String RECORDITEM_ID;
|
||||
|
||||
private String RISKITEM_ID;
|
||||
|
||||
private String REJECTREASON;
|
||||
|
||||
private String REVIEWOR;
|
||||
|
||||
private String REVIEWTIME;
|
||||
|
||||
private String REVIEWDEPT;
|
||||
|
||||
private String HAVESCHEME;
|
||||
|
||||
private String LONGITUDE;
|
||||
|
||||
private String LATITUDE;
|
||||
|
||||
private String LISTMANAGER_ID;
|
||||
|
||||
private String HIDDENTYPE;
|
||||
|
||||
private String ISCONFIRM = "0";
|
||||
|
||||
private String CONFIRM_USER;
|
||||
|
||||
private String CONFIRM_TIME;
|
||||
|
||||
private String DISCOVERYTIME;
|
||||
|
||||
private String INVESTMENT_FUNDS;
|
||||
|
||||
private String HIDDENTYPE2;
|
||||
|
||||
private String FOREIGN_ID;
|
||||
|
||||
private String FINAL_CHECK;
|
||||
|
||||
private String FINAL_CHECKOR;
|
||||
|
||||
private String finalCheckTime;
|
||||
|
||||
private String FINAL_CHECKDESCR;
|
||||
|
||||
private String POSITIONDESC;
|
||||
|
||||
private String ISRELEVANT = "0";
|
||||
|
||||
private String ISEXPIREREPAIR = "0";
|
||||
|
||||
private String EVALUATE_STAGE_START_TIME;
|
||||
|
||||
/**
|
||||
* 隐患照片
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String HIDDEN_PICTURE;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.zcloud.modules.RyCheck.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("bus_hidden_user")
|
||||
public class HiddenUserEntity {
|
||||
@TableId(type = IdType.NONE)
|
||||
private String HIDDENUSER_ID;
|
||||
|
||||
private String HIDDEN_ID;
|
||||
|
||||
private String USER_ID;
|
||||
|
||||
private String TYPE;
|
||||
|
||||
private String IS_MAIN;
|
||||
|
||||
private String DEPARTMENT_ID;
|
||||
|
||||
public HiddenUserEntity() {
|
||||
}
|
||||
|
||||
public HiddenUserEntity(String HIDDENUSER_ID, String HIDDEN_ID, String USER_ID, String TYPE, String IS_MAIN) {
|
||||
this.HIDDENUSER_ID = HIDDENUSER_ID;
|
||||
this.HIDDEN_ID = HIDDEN_ID;
|
||||
this.USER_ID = USER_ID;
|
||||
this.TYPE = TYPE;
|
||||
this.IS_MAIN = IS_MAIN;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.zcloud.modules.RyCheck.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("bus_imgfiles")
|
||||
public class ImgFilesEntity {
|
||||
@TableId(type = IdType.NONE)
|
||||
private String IMGFILES_ID;
|
||||
private String FILEPATH;
|
||||
private String TYPE;
|
||||
private String FOREIGN_KEY;
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.zcloud.modules.RyCheck.entity.rycheck;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
// 点检计划
|
||||
@Data
|
||||
@TableName("ry_check_jh")
|
||||
public class RyCheckJhEntity {
|
||||
@TableId(type = IdType.NONE)
|
||||
private Long fid;// 主键fid
|
||||
private String fjhname;// 计划名称
|
||||
private String ftypestr;//计划类型
|
||||
private String fbc;// 班次中文名称
|
||||
private String froleidstr;// 角色名称
|
||||
private String fadddate;//计划生成时间
|
||||
private String freason;// 未点检原因
|
||||
private String fdelReason;// 删除原因
|
||||
private String fstatestr;// 点检状态
|
||||
private String fspstatusstr;// 审批状态
|
||||
private String fspTypeStr;// 审批类型
|
||||
private String fsumitUserStr;// 提交人
|
||||
private String fsubmitDate;//提交时间
|
||||
private String fspUserStr;// 审批人
|
||||
private String fspDate;// 审批时间
|
||||
private String fuserstr;// 接单人
|
||||
private String fuserdate;// 接单时间
|
||||
private String fcurrentdeptstr;// 当前部门
|
||||
private String fmodiuserstr;// 修改人
|
||||
private String fmodidate;//修改时间
|
||||
private String childList;// 检查项
|
||||
}
|
|
@ -0,0 +1,148 @@
|
|||
package com.zcloud.modules.RyCheck.entity.rycheck;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
// 点检记录
|
||||
@Data
|
||||
@TableName("ry_check_jl")
|
||||
public class RyCheckJlEntity {
|
||||
@TableId(type = IdType.NONE)
|
||||
private Long fid;//自增id,
|
||||
private Long tempId; // 临时主键id
|
||||
private Long fdjjhfid;//点检计划id,
|
||||
private Long fsbid;//已绑定设备id,
|
||||
private Long fdjbzid;//对应的点检标准id,
|
||||
private Integer fdjstate;//是否发现问题(0 否 1 是),
|
||||
private String fnote;//发现的问题及描述,
|
||||
private Long fuser;//点检人员,
|
||||
private String fdate;//点检时间,
|
||||
private Integer fstate;//处理结果(0 忽略 1 待观察 2 转维修 3 维修完成(工单验收)),
|
||||
private String fclnote;//处理意见,
|
||||
private Integer fpj;//评价打分(1-5),
|
||||
private Long fcluser;//处理操作人,
|
||||
private String fcldate;//处理时间,
|
||||
private Long zxid;//对应自修id,
|
||||
private String dgcfid;//待观察主键id,
|
||||
private String fzgyq;//整改要求,
|
||||
private String longitude;//经度,
|
||||
private String latitude;//纬度,
|
||||
private String fdjstateStr;//是否发现问题(中文),
|
||||
private String fuserStr;//点检人姓名,
|
||||
private Long fuserDept;//点检人部门id,
|
||||
private String fuserDeptStr;//点检人部门名称,
|
||||
private String fuserPhone;//点检人联系电话,
|
||||
private String fstateStr;//处理结果(中文),
|
||||
private String fcluserStr;//操作人姓名,
|
||||
private Long fcluserDept;//操作人部门id,
|
||||
private String fcluserDeptStr;//操作人部门名称,
|
||||
private String fcluserPhone;//操作人联系电话,
|
||||
private String fbc;//班次,
|
||||
private Integer ftype;//计划类型,
|
||||
private String bzsFtype;//类型,
|
||||
private String ftypeStr;//计划类型(中文),
|
||||
private String fjhname;//计划名称,
|
||||
private Long jhJduser;//计划接单人,
|
||||
private String jhJduserStr;//计划接单人姓名,
|
||||
private Long jhJduserDept;//计划接单人部门id,
|
||||
private String jhJduserDeptStr;//计划接单人部门名称,
|
||||
private String jhJduserPhone;//计划接单人联系电话,
|
||||
private String jhJdsj;//计划接单时间,
|
||||
private String freason;//未点检原因,
|
||||
private String fsbidStr;//所绑定设备名称,
|
||||
private String fcheckNote;//点检内容,
|
||||
private String fmethodsNote;//检查方法,
|
||||
private String toolname;//检查工具,
|
||||
private String fcheckproject;//检查项目,
|
||||
private String djbzName;//点检标准(中文),
|
||||
// ---------------隐患------------------
|
||||
private String fgdno;//工单编号 ----- 维修,
|
||||
private String fqfdept;//签发部门 --》CREATOR -》发现部门,
|
||||
private String fqfdeptStr;//签发部门(中文),
|
||||
private String fqfuser;//签发人id,
|
||||
private String fqfuserStr;//签发人(中文) CREATOR -》发现人,
|
||||
private Long fqfuserDept;//签发人部门id,
|
||||
private String fqfuserDeptStr;//签发人部门(中文),
|
||||
private String fqfuserPhone;//签发人联系电话,
|
||||
private String fqfdate;//签发日期 CREATTIME -》发现时间,
|
||||
private String fsbcode;//设备编号,
|
||||
private String fsbcodeStr;//设备编号(中文),
|
||||
private String fsbjg;//设备机构,
|
||||
private String fsbjgStr;//设备机构(中文),
|
||||
private String fsbzjg;//设备子机构,
|
||||
private String fsbzjgStr;//设备子机构(中文),
|
||||
private String fsbbj;//设备部件,
|
||||
private String fsbbjStr;//设备部件(中文),
|
||||
private String fsbyj;//设备元件fcode,
|
||||
private String fsbyjStr;//设备元件字符串(中文),
|
||||
private String zxNote;//发现问题及描述, ->HIDDENDESCR 隐患描述
|
||||
private String fwzbjcode;//设备部件代码,
|
||||
private String fwzno;//物资编码,
|
||||
private Integer zxState;//自修状态(1 正常;2 新装;3 替换;4 拆卸),
|
||||
private String zxFstateStr;//自修状态(中文),
|
||||
private String fstrdateJh;//计划开始时间,
|
||||
private String fenddateJh;//计划结束时间,
|
||||
private String fwxgyCode;//维修工艺代码,
|
||||
private String fwxgyName;//维修工艺名称,
|
||||
private String fwxgyFilename;//维修工艺文件名称,
|
||||
private String fwxgyFilepath;//维修工艺文件路径,
|
||||
private Integer fpattern;//派单模式(0 指派;1 抢单;2 技术员自修),
|
||||
private String fpatternStr;//派单模式(中文),
|
||||
private String fwwdw;//外委单位代码,
|
||||
private String fwwdwStr;//外委单位名称,
|
||||
private BigDecimal fwxry;//维修人数,
|
||||
private String fwxfzr;//维修负责人 -》整改人,
|
||||
private String fwxfzrTel;//维修负责人联系电话,
|
||||
private String ys_user;//验收人,
|
||||
private String fys_date;//验收时间,
|
||||
private String fys_note;//验收说明,
|
||||
private String fysDept; // 验收部门
|
||||
private String fysPhone; // 验收手机号
|
||||
private String fsbdl;//设备大类,
|
||||
private String fsbdlStr;//设备大类(中文),
|
||||
private BigDecimal fwzsl;//物资数量,
|
||||
private BigDecimal fwzghsl;//物资归还数量,
|
||||
private BigInteger fgdxh;//工单序号,
|
||||
private String fsx;//时限,
|
||||
private String fstrdateSj;//实际开始时间,
|
||||
private String fenddateSj;//实际结束时间,
|
||||
private String fckcode;//仓库代码(替换、拆卸模式下),
|
||||
private String fckcodeStr;//仓库(中文;替换拆卸模式下),
|
||||
private String fhwcode;//货位代码(替换、拆卸模式下),
|
||||
private String fhwcodeStr;//货位(中文;替换拆卸模式下),
|
||||
private String fcjcode;//层级代码,
|
||||
private String fcjcodeStr;//层级(中文;替换拆卸模式下),
|
||||
private Integer breakfire;//动火(0 否;1 是),
|
||||
private String breakfireStr;//动火(中文),
|
||||
private Integer highaltitude;//高空(0 否; 1 是),
|
||||
private String highaltitudeStr;//高空(中文),
|
||||
private Integer closed;//密闭(0 否;1 是),
|
||||
private String closedStr;//密闭(中文),
|
||||
private String fzdnote;//重点工作安排(中文),
|
||||
private Integer fworkordertype;//工单类型(1 保养类;2 故障停机类;3 环保设施类),
|
||||
private String fworkordertypeStr;//工单类型(中文),
|
||||
private String fnodewzcode;//在线大件的物资id,
|
||||
private Integer electricity;//停送电(0 否; 1 是),
|
||||
private String electricityStr;//停送电(中文),
|
||||
private String fphone;//联系电话(中文),
|
||||
private Integer fcolor;//人员颜色(0 黄 1 橙 2 红),
|
||||
private String fcolorStr;//人员颜色(中文),
|
||||
private Integer fdz;//吊装(0 否; 1 是),
|
||||
private String fdzStr;//吊装(中文),
|
||||
private Integer flsyd;//临时用电(0 否; 1 是),
|
||||
private String flsydStr;//临时用电(中文),
|
||||
private Integer fdt;//动土(0 否; 1 是),
|
||||
private String fdtStr;//动土(中文),
|
||||
private Integer fdl;//断路(0 否; 1 是),
|
||||
private String fdlStr;//断路(中文)
|
||||
@TableField(exist = false)
|
||||
private List<HashMap> fileList;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.zcloud.modules.RyCheck.entity.rycheck;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("ry_check_mb")
|
||||
public class RyCheckMbEntity {
|
||||
private Long fid; // 主键fid
|
||||
private String fjhname;// 计划名称
|
||||
private String ftypestr;// 计划类型
|
||||
private String fdaytypeStr;// 计划周期
|
||||
private String froleidstr;// 角色名称
|
||||
private String fstatestr;// 启停状态
|
||||
private String isBusinessSystemStr;// 是否上传商务系统
|
||||
private String ftimestr;// 首次执行时间
|
||||
private String ftimenewstr;// 最新执行时间
|
||||
private String fadduserstr;// 添加人
|
||||
private String fadddatestr;// 添加时间
|
||||
private String fmodiuserstr;// 修改人
|
||||
private String fmodidatestr;// 修改时间
|
||||
private String childList; // 检查项信息
|
||||
}
|
|
@ -0,0 +1,168 @@
|
|||
package com.zcloud.modules.RyCheck.entity.system;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 说明:组织机构
|
||||
* 作者:luoxiaobao
|
||||
* 官网:www.qdkjchina.com
|
||||
*/
|
||||
public class Department {
|
||||
|
||||
private String NAME; //名称
|
||||
private String NAME_EN; //英文名称
|
||||
private String BIANMA; //编码
|
||||
private String PARENT_ID; //上级ID
|
||||
private String HEADMAN; //负责人
|
||||
private String TEL; //电话
|
||||
private String FUNCTIONS; //部门职能
|
||||
private String BZ; //备注
|
||||
private String ADDRESS; //地址
|
||||
private String DEPARTMENT_ID; //主键
|
||||
private String PROVINCE; //省
|
||||
private String CITY; //市
|
||||
private String COUNTRY; //区
|
||||
private String VILLAGE; //县
|
||||
private String TYPE; //类型
|
||||
private String LEVEL; //级别
|
||||
private String target;
|
||||
private Department department;
|
||||
private List<Department> subDepartment;
|
||||
private boolean hasDepartment = false;
|
||||
private String treeurl;
|
||||
private String icon;
|
||||
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
public void setIcon(String icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
public String getNAME() {
|
||||
return NAME;
|
||||
}
|
||||
public void setNAME(String nAME) {
|
||||
NAME = nAME;
|
||||
}
|
||||
public String getNAME_EN() {
|
||||
return NAME_EN;
|
||||
}
|
||||
public void setNAME_EN(String nAME_EN) {
|
||||
NAME_EN = nAME_EN;
|
||||
}
|
||||
public String getBIANMA() {
|
||||
return BIANMA;
|
||||
}
|
||||
public void setBIANMA(String bIANMA) {
|
||||
BIANMA = bIANMA;
|
||||
}
|
||||
public String getPARENT_ID() {
|
||||
return PARENT_ID;
|
||||
}
|
||||
public void setPARENT_ID(String pARENT_ID) {
|
||||
PARENT_ID = pARENT_ID;
|
||||
}
|
||||
public String getHEADMAN() {
|
||||
return HEADMAN;
|
||||
}
|
||||
public void setHEADMAN(String hEADMAN) {
|
||||
HEADMAN = hEADMAN;
|
||||
}
|
||||
public String getTEL() {
|
||||
return TEL;
|
||||
}
|
||||
public void setTEL(String tEL) {
|
||||
TEL = tEL;
|
||||
}
|
||||
public String getFUNCTIONS() {
|
||||
return FUNCTIONS;
|
||||
}
|
||||
public void setFUNCTIONS(String fUNCTIONS) {
|
||||
FUNCTIONS = fUNCTIONS;
|
||||
}
|
||||
public String getBZ() {
|
||||
return BZ;
|
||||
}
|
||||
public void setBZ(String bZ) {
|
||||
BZ = bZ;
|
||||
}
|
||||
public String getADDRESS() {
|
||||
return ADDRESS;
|
||||
}
|
||||
public void setADDRESS(String aDDRESS) {
|
||||
ADDRESS = aDDRESS;
|
||||
}
|
||||
public String getDEPARTMENT_ID() {
|
||||
return DEPARTMENT_ID;
|
||||
}
|
||||
public void setDEPARTMENT_ID(String dEPARTMENT_ID) {
|
||||
DEPARTMENT_ID = dEPARTMENT_ID;
|
||||
}
|
||||
public String getTarget() {
|
||||
return target;
|
||||
}
|
||||
public void setTarget(String target) {
|
||||
this.target = target;
|
||||
}
|
||||
public Department getDepartment() {
|
||||
return department;
|
||||
}
|
||||
public void setDepartment(Department department) {
|
||||
this.department = department;
|
||||
}
|
||||
public List<Department> getSubDepartment() {
|
||||
return subDepartment;
|
||||
}
|
||||
public void setSubDepartment(List<Department> subDepartment) {
|
||||
this.subDepartment = subDepartment;
|
||||
}
|
||||
public boolean isHasDepartment() {
|
||||
return hasDepartment;
|
||||
}
|
||||
public void setHasDepartment(boolean hasDepartment) {
|
||||
this.hasDepartment = hasDepartment;
|
||||
}
|
||||
public String getTreeurl() {
|
||||
return treeurl;
|
||||
}
|
||||
public void setTreeurl(String treeurl) {
|
||||
this.treeurl = treeurl;
|
||||
}
|
||||
public String getPROVINCE() {
|
||||
return PROVINCE;
|
||||
}
|
||||
public void setPROVINCE(String pROVINCE) {
|
||||
PROVINCE = pROVINCE;
|
||||
}
|
||||
public String getCITY() {
|
||||
return CITY;
|
||||
}
|
||||
public void setCITY(String cITY) {
|
||||
CITY = cITY;
|
||||
}
|
||||
public String getCOUNTRY() {
|
||||
return COUNTRY;
|
||||
}
|
||||
public void setCOUNTRY(String cOUNTRY) {
|
||||
COUNTRY = cOUNTRY;
|
||||
}
|
||||
public String getVILLAGE() {
|
||||
return VILLAGE;
|
||||
}
|
||||
public void setVILLAGE(String vILLAGE) {
|
||||
VILLAGE = vILLAGE;
|
||||
}
|
||||
public String getTYPE() {
|
||||
return TYPE;
|
||||
}
|
||||
public void setTYPE(String tYPE) {
|
||||
TYPE = tYPE;
|
||||
}
|
||||
public String getLEVEL() {
|
||||
return LEVEL;
|
||||
}
|
||||
public void setLEVEL(String lEVEL) {
|
||||
LEVEL = lEVEL;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,156 @@
|
|||
package com.zcloud.modules.RyCheck.entity.system;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HiddenRegion {
|
||||
private String HIDDENREGION_ID; //隐患区域ID
|
||||
private String HIDDENREGION; //隐患区域
|
||||
private String PARENT_ID; //父级ID
|
||||
|
||||
public String getHIDDENREGION_ID() {
|
||||
return HIDDENREGION_ID;
|
||||
}
|
||||
|
||||
public void setHIDDENREGION_ID(String HIDDENREGION_ID) {
|
||||
this.HIDDENREGION_ID = HIDDENREGION_ID;
|
||||
}
|
||||
|
||||
public void setChildhg(List<HiddenRegion> childhg) {
|
||||
this.childhg = childhg;
|
||||
}
|
||||
|
||||
private String PERSON_CHARGE; //负责人
|
||||
private int SORTINDEX; //排序
|
||||
private String COMMENTS; //备注
|
||||
private int ISDELETE; //是否删除
|
||||
private String CREATOR; //创建人
|
||||
private String CREATTIME; //创建时间
|
||||
private String OPERATOR; //修改人
|
||||
private String OPERATTIME; //修改时间
|
||||
private String HIDDENREGION_URL; //URL
|
||||
private List<HiddenRegion> subhiddenRegion;
|
||||
private boolean hashiddenRegion = false;
|
||||
|
||||
public String getCORPINFO_ID() {
|
||||
return CORPINFO_ID;
|
||||
}
|
||||
|
||||
public void setCORPINFO_ID(String CORPINFO_ID) {
|
||||
this.CORPINFO_ID = CORPINFO_ID;
|
||||
}
|
||||
|
||||
private String CORPINFO_ID;
|
||||
|
||||
private List<HiddenRegion> childhg = new ArrayList<>();
|
||||
|
||||
|
||||
|
||||
public String getHIDDENREGION() {
|
||||
return HIDDENREGION;
|
||||
}
|
||||
|
||||
public void setHIDDENREGION(String HIDDENREGION) {
|
||||
this.HIDDENREGION = HIDDENREGION;
|
||||
}
|
||||
|
||||
public String getPARENT_ID() {
|
||||
return PARENT_ID;
|
||||
}
|
||||
|
||||
public void setPARENT_ID(String PARENT_ID) {
|
||||
this.PARENT_ID = PARENT_ID;
|
||||
}
|
||||
|
||||
public String getPERSON_CHARGE() {
|
||||
return PERSON_CHARGE;
|
||||
}
|
||||
|
||||
public void setPERSON_CHARGE(String PERSON_CHARGE) {
|
||||
this.PERSON_CHARGE = PERSON_CHARGE;
|
||||
}
|
||||
|
||||
public int getSORTINDEX() {
|
||||
return SORTINDEX;
|
||||
}
|
||||
|
||||
public void setSORTINDEX(int SORTINDEX) {
|
||||
this.SORTINDEX = SORTINDEX;
|
||||
}
|
||||
|
||||
public String getCOMMENTS() {
|
||||
return COMMENTS;
|
||||
}
|
||||
|
||||
public void setCOMMENTS(String COMMENTS) {
|
||||
this.COMMENTS = COMMENTS;
|
||||
}
|
||||
|
||||
public int getISDELETE() {
|
||||
return ISDELETE;
|
||||
}
|
||||
|
||||
public void setISDELETE(int ISDELETE) {
|
||||
this.ISDELETE = ISDELETE;
|
||||
}
|
||||
|
||||
public String getCREATOR() {
|
||||
return CREATOR;
|
||||
}
|
||||
|
||||
public void setCREATOR(String CREATOR) {
|
||||
this.CREATOR = CREATOR;
|
||||
}
|
||||
|
||||
public String getCREATTIME() {
|
||||
return CREATTIME;
|
||||
}
|
||||
|
||||
public void setCREATTIME(String CREATTIME) {
|
||||
this.CREATTIME = CREATTIME;
|
||||
}
|
||||
|
||||
public String getOPERATOR() {
|
||||
return OPERATOR;
|
||||
}
|
||||
|
||||
public void setOPERATOR(String OPERATOR) {
|
||||
this.OPERATOR = OPERATOR;
|
||||
}
|
||||
|
||||
public String getOPERATTIME() {
|
||||
return OPERATTIME;
|
||||
}
|
||||
|
||||
public void setOPERATTIME(String OPERATTIME) {
|
||||
this.OPERATTIME = OPERATTIME;
|
||||
}
|
||||
|
||||
public List<HiddenRegion> getChildhg() {
|
||||
return childhg;
|
||||
}
|
||||
|
||||
public String getHIDDENREGION_URL() {
|
||||
return HIDDENREGION_URL;
|
||||
}
|
||||
|
||||
public void setHIDDENREGION_URL(String HIDDENREGION_URL) {
|
||||
this.HIDDENREGION_URL = HIDDENREGION_URL;
|
||||
}
|
||||
|
||||
public List<HiddenRegion> getSubhiddenRegion() {
|
||||
return subhiddenRegion;
|
||||
}
|
||||
|
||||
public void setSubhiddenRegion(List<HiddenRegion> subhiddenRegion) {
|
||||
this.subhiddenRegion = subhiddenRegion;
|
||||
}
|
||||
|
||||
public boolean isHashiddenRegion() {
|
||||
return hashiddenRegion;
|
||||
}
|
||||
|
||||
public void setHashiddenRegion(boolean hashiddenRegion) {
|
||||
this.hashiddenRegion = hashiddenRegion;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
package com.zcloud.modules.RyCheck.entity.system;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 说明:菜单实体类
|
||||
* 作者:luoxiaobao
|
||||
* 官网:www.qdkjchina.com
|
||||
*/
|
||||
public class Menu implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String MENU_ID; //菜单ID
|
||||
private String MENU_NAME; //菜单名称
|
||||
private String MENU_URL; //链接
|
||||
private String PARENT_ID; //上级菜单ID
|
||||
private String MENU_ORDER; //排序
|
||||
private String MENU_ICON; //图标
|
||||
private String MENU_TYPE; //类型
|
||||
private String MENU_STATE; //菜单状态
|
||||
private String SHIRO_KEY; //权限标识
|
||||
private String SHOW_MODEL; //显示模式
|
||||
private String COMPONENT; //组件路径
|
||||
|
||||
private String target;
|
||||
private Menu parentMenu;
|
||||
private List<Menu> subMenu;
|
||||
private boolean hasMenu = false;
|
||||
|
||||
public String getMENU_ID() {
|
||||
return MENU_ID;
|
||||
}
|
||||
public void setMENU_ID(String mENU_ID) {
|
||||
MENU_ID = mENU_ID;
|
||||
}
|
||||
public String getMENU_NAME() {
|
||||
return MENU_NAME;
|
||||
}
|
||||
public void setMENU_NAME(String mENU_NAME) {
|
||||
MENU_NAME = mENU_NAME;
|
||||
}
|
||||
public String getMENU_URL() {
|
||||
return MENU_URL;
|
||||
}
|
||||
public void setMENU_URL(String mENU_URL) {
|
||||
MENU_URL = mENU_URL;
|
||||
}
|
||||
public String getPARENT_ID() {
|
||||
return PARENT_ID;
|
||||
}
|
||||
public void setPARENT_ID(String pARENT_ID) {
|
||||
PARENT_ID = pARENT_ID;
|
||||
}
|
||||
public String getMENU_ORDER() {
|
||||
return MENU_ORDER;
|
||||
}
|
||||
public void setMENU_ORDER(String mENU_ORDER) {
|
||||
MENU_ORDER = mENU_ORDER;
|
||||
}
|
||||
public Menu getParentMenu() {
|
||||
return parentMenu;
|
||||
}
|
||||
public void setParentMenu(Menu parentMenu) {
|
||||
this.parentMenu = parentMenu;
|
||||
}
|
||||
public List<Menu> getSubMenu() {
|
||||
return subMenu;
|
||||
}
|
||||
public void setSubMenu(List<Menu> subMenu) {
|
||||
this.subMenu = subMenu;
|
||||
}
|
||||
public boolean isHasMenu() {
|
||||
return hasMenu;
|
||||
}
|
||||
public void setHasMenu(boolean hasMenu) {
|
||||
this.hasMenu = hasMenu;
|
||||
}
|
||||
public String getTarget() {
|
||||
return target;
|
||||
}
|
||||
public void setTarget(String target) {
|
||||
this.target = target;
|
||||
}
|
||||
public String getMENU_ICON() {
|
||||
return MENU_ICON;
|
||||
}
|
||||
public void setMENU_ICON(String mENU_ICON) {
|
||||
MENU_ICON = mENU_ICON;
|
||||
}
|
||||
public String getMENU_TYPE() {
|
||||
return MENU_TYPE;
|
||||
}
|
||||
public void setMENU_TYPE(String mENU_TYPE) {
|
||||
MENU_TYPE = mENU_TYPE;
|
||||
}
|
||||
|
||||
public String getSHIRO_KEY() {
|
||||
return SHIRO_KEY;
|
||||
}
|
||||
public void setSHIRO_KEY(String sHIRO_KEY) {
|
||||
SHIRO_KEY = sHIRO_KEY;
|
||||
}
|
||||
|
||||
public String getCOMPONENT() {
|
||||
return COMPONENT;
|
||||
}
|
||||
public void setCOMPONENT(String cOMPONENT) {
|
||||
COMPONENT = cOMPONENT;
|
||||
}
|
||||
|
||||
public String getMENU_STATE() {
|
||||
return MENU_STATE;
|
||||
}
|
||||
public void setMENU_STATE(String mENU_STATE) {
|
||||
MENU_STATE = mENU_STATE;
|
||||
}
|
||||
public String getSHOW_MODEL() {
|
||||
return SHOW_MODEL;
|
||||
}
|
||||
public void setSHOW_MODEL(String sHOW_MODEL) {
|
||||
SHOW_MODEL = sHOW_MODEL;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package com.zcloud.modules.RyCheck.entity.system;
|
||||
|
||||
/**
|
||||
* 说明:角色实体类
|
||||
* 作者:luoxiaobao
|
||||
* 官网:www.qdkjchina.com
|
||||
*/
|
||||
public class Role {
|
||||
private String ROLE_ID; //ID
|
||||
private String ROLE_NAME; //名称
|
||||
private String RIGHTS; //权限(存放的除权后的菜单ID)控制菜单显示
|
||||
private String PARENT_ID; //上级ID
|
||||
private String ADD_QX; //新增权限(存放的除权后的菜单ID)有新增权限的菜单ID
|
||||
private String DEL_QX; //删除权限(存放的除权后的菜单ID)有删除权限的菜单ID
|
||||
private String EDIT_QX; //修改权限(存放的除权后的菜单ID)有修改权限的菜单ID
|
||||
private String CHA_QX; //查看权限(存放的除权后的菜单ID)有查看权限的菜单ID
|
||||
private String RNUMBER; //编号(在处理类中新增的时候自动生成)
|
||||
|
||||
public String getROLE_ID() {
|
||||
return ROLE_ID;
|
||||
}
|
||||
public void setROLE_ID(String rOLE_ID) {
|
||||
ROLE_ID = rOLE_ID;
|
||||
}
|
||||
public String getROLE_NAME() {
|
||||
return ROLE_NAME;
|
||||
}
|
||||
public void setROLE_NAME(String rOLE_NAME) {
|
||||
ROLE_NAME = rOLE_NAME;
|
||||
}
|
||||
public String getRIGHTS() {
|
||||
return RIGHTS;
|
||||
}
|
||||
public void setRIGHTS(String rIGHTS) {
|
||||
RIGHTS = rIGHTS;
|
||||
}
|
||||
public String getPARENT_ID() {
|
||||
return PARENT_ID;
|
||||
}
|
||||
public void setPARENT_ID(String pARENT_ID) {
|
||||
PARENT_ID = pARENT_ID;
|
||||
}
|
||||
public String getADD_QX() {
|
||||
return ADD_QX;
|
||||
}
|
||||
public void setADD_QX(String aDD_QX) {
|
||||
ADD_QX = aDD_QX;
|
||||
}
|
||||
public String getDEL_QX() {
|
||||
return DEL_QX;
|
||||
}
|
||||
public void setDEL_QX(String dEL_QX) {
|
||||
DEL_QX = dEL_QX;
|
||||
}
|
||||
public String getEDIT_QX() {
|
||||
return EDIT_QX;
|
||||
}
|
||||
public void setEDIT_QX(String eDIT_QX) {
|
||||
EDIT_QX = eDIT_QX;
|
||||
}
|
||||
public String getCHA_QX() {
|
||||
return CHA_QX;
|
||||
}
|
||||
public void setCHA_QX(String cHA_QX) {
|
||||
CHA_QX = cHA_QX;
|
||||
}
|
||||
public String getRNUMBER() {
|
||||
return RNUMBER;
|
||||
}
|
||||
public void setRNUMBER(String rNUMBER) {
|
||||
RNUMBER = rNUMBER;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package com.zcloud.modules.RyCheck.entity.system;
|
||||
|
||||
|
||||
/**
|
||||
* 说明:用户实体类
|
||||
* 作者:luoxiaobao
|
||||
* 官网:www.qdkjchina.com
|
||||
*/
|
||||
public class User {
|
||||
private String USER_ID; //用户id
|
||||
private String USERNAME; //用户名
|
||||
private String PASSWORD; //密码
|
||||
private String NAME; //姓名
|
||||
private String ROLE_ID; //角色id
|
||||
private String ROLE_IDS; //副职角色id
|
||||
private String CREATTIME; //创建时间
|
||||
private String LAST_LOGIN; //最后登录时间
|
||||
private String IP; //用户登录ip地址
|
||||
private String STATUS; //状态
|
||||
private Role role; //角色对象
|
||||
private String SKIN; //皮肤
|
||||
|
||||
public String getSKIN() {
|
||||
return SKIN;
|
||||
}
|
||||
public void setSKIN(String sKIN) {
|
||||
SKIN = sKIN;
|
||||
}
|
||||
|
||||
public String getUSER_ID() {
|
||||
return USER_ID;
|
||||
}
|
||||
public void setUSER_ID(String uSER_ID) {
|
||||
USER_ID = uSER_ID;
|
||||
}
|
||||
public String getUSERNAME() {
|
||||
return USERNAME;
|
||||
}
|
||||
public void setUSERNAME(String uSERNAME) {
|
||||
USERNAME = uSERNAME;
|
||||
}
|
||||
public String getPASSWORD() {
|
||||
return PASSWORD;
|
||||
}
|
||||
public void setPASSWORD(String pASSWORD) {
|
||||
PASSWORD = pASSWORD;
|
||||
}
|
||||
public String getNAME() {
|
||||
return NAME;
|
||||
}
|
||||
public void setNAME(String nAME) {
|
||||
NAME = nAME;
|
||||
}
|
||||
public String getROLE_ID() {
|
||||
return ROLE_ID;
|
||||
}
|
||||
public void setROLE_ID(String rOLE_ID) {
|
||||
ROLE_ID = rOLE_ID;
|
||||
}
|
||||
public String getROLE_IDS() {
|
||||
return ROLE_IDS;
|
||||
}
|
||||
public void setROLE_IDS(String rOLE_IDS) {
|
||||
ROLE_IDS = rOLE_IDS;
|
||||
}
|
||||
public String getLAST_LOGIN() {
|
||||
return LAST_LOGIN;
|
||||
}
|
||||
public void setLAST_LOGIN(String lAST_LOGIN) {
|
||||
LAST_LOGIN = lAST_LOGIN;
|
||||
}
|
||||
public String getIP() {
|
||||
return IP;
|
||||
}
|
||||
public void setIP(String iP) {
|
||||
IP = iP;
|
||||
}
|
||||
public String getSTATUS() {
|
||||
return STATUS;
|
||||
}
|
||||
public void setSTATUS(String sTATUS) {
|
||||
STATUS = sTATUS;
|
||||
}
|
||||
|
||||
public Role getRole() {
|
||||
return role;
|
||||
}
|
||||
public void setRole(Role role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public String getCREATTIME() {
|
||||
return CREATTIME;
|
||||
}
|
||||
|
||||
public void setCREATTIME(String CREATTIME) {
|
||||
this.CREATTIME = CREATTIME;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.zcloud.modules.RyCheck.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zcloud.modules.RyCheck.entity.CheckHiddenPushEntity;
|
||||
import com.zcloud.modules.sys.entity.PageData;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface CheckHiddenPushMapper extends BaseMapper<CheckHiddenPushEntity> {
|
||||
List<PageData> getWaitPushHidden();
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.zcloud.modules.RyCheck.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zcloud.modules.RyCheck.entity.HiddenCheckUserEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface HiddenCheckUserMapper extends BaseMapper<HiddenCheckUserEntity> {
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.zcloud.modules.RyCheck.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zcloud.modules.RyCheck.entity.HiddenEntity;
|
||||
import com.zcloud.modules.sys.entity.PageData;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface HiddenMapper extends BaseMapper<HiddenEntity> {
|
||||
|
||||
List<PageData> getAllUserList(PageData pd);
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.zcloud.modules.RyCheck.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zcloud.modules.RyCheck.entity.HiddenUserEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface HiddenUserMapper extends BaseMapper<HiddenUserEntity> {
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.zcloud.modules.RyCheck.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zcloud.modules.RyCheck.entity.ImgFilesEntity;
|
||||
import com.zcloud.modules.sys.entity.PageData;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ImgfilesMapper extends BaseMapper<ImgFilesEntity> {
|
||||
List<PageData> getAllImgList(PageData pd);
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.zcloud.modules.RyCheck.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zcloud.modules.RyCheck.entity.rycheck.RyCheckJhEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface RyCheckJhMapper extends BaseMapper<RyCheckJhEntity> {
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.zcloud.modules.RyCheck.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zcloud.modules.RyCheck.entity.rycheck.RyCheckJlEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface RyCheckJlMapper extends BaseMapper<RyCheckJlEntity> {
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.zcloud.modules.RyCheck.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zcloud.modules.RyCheck.entity.rycheck.RyCheckMbEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface RyCheckMbMapper extends BaseMapper<RyCheckMbEntity> {
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.zcloud.modules.RyCheck.mapper;
|
||||
|
||||
|
||||
import com.zcloud.modules.sys.entity.PageData;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface UserMapper{
|
||||
|
||||
List<PageData> getAllUserList(PageData pd);
|
||||
|
||||
List<PageData> getAllUsers(PageData pd);
|
||||
|
||||
List<PageData> getAllDeptList(PageData pd);
|
||||
|
||||
List<PageData> getAllDepts(PageData pd);
|
||||
|
||||
void addDept(PageData pageData);
|
||||
|
||||
void saveUser(PageData pageData);
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.zcloud.modules.RyCheck.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zcloud.modules.RyCheck.entity.HiddenCheckUserEntity;
|
||||
|
||||
public interface HiddenCheckUserService extends IService<HiddenCheckUserEntity> {
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.zcloud.modules.RyCheck.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zcloud.modules.RyCheck.entity.CheckHiddenPushEntity;
|
||||
|
||||
public interface HiddenPushService extends IService<CheckHiddenPushEntity> {
|
||||
void pushHidden();
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.zcloud.modules.RyCheck.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zcloud.modules.RyCheck.entity.HiddenEntity;
|
||||
import com.zcloud.modules.sys.entity.PageData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface HiddenService extends IService<HiddenEntity> {
|
||||
List<PageData> getAllUserList(PageData pd);
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.zcloud.modules.RyCheck.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zcloud.modules.RyCheck.entity.HiddenUserEntity;
|
||||
|
||||
public interface HiddenUserService extends IService<HiddenUserEntity> {
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.zcloud.modules.RyCheck.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zcloud.modules.RyCheck.entity.rycheck.RyCheckJhEntity;
|
||||
|
||||
public interface RyCheckJhService extends IService<RyCheckJhEntity> {
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.zcloud.modules.RyCheck.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zcloud.modules.RyCheck.entity.rycheck.RyCheckJlEntity;
|
||||
|
||||
public interface RyCheckJlService extends IService<RyCheckJlEntity> {
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.zcloud.modules.RyCheck.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zcloud.modules.RyCheck.entity.rycheck.RyCheckMbEntity;
|
||||
|
||||
public interface RyCheckMbService extends IService<RyCheckMbEntity> {
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.zcloud.modules.RyCheck.service;
|
||||
|
||||
|
||||
import com.zcloud.modules.sys.entity.PageData;
|
||||
|
||||
public interface RyCheckService {
|
||||
|
||||
void getRyCheckJlList();
|
||||
void getRyCheckJhList();
|
||||
|
||||
void getRyCheckRyMbList();
|
||||
|
||||
void pushedHiddenList();
|
||||
void getAllUser();
|
||||
void getAllDept();
|
||||
void getAllHidden(PageData pd);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.zcloud.modules.RyCheck.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zcloud.modules.RyCheck.entity.HiddenCheckUserEntity;
|
||||
import com.zcloud.modules.RyCheck.mapper.HiddenCheckUserMapper;
|
||||
import com.zcloud.modules.RyCheck.service.HiddenCheckUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class HiddenCheckUserServiceImpl extends ServiceImpl<HiddenCheckUserMapper, HiddenCheckUserEntity> implements HiddenCheckUserService {
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.zcloud.modules.RyCheck.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zcloud.modules.RyCheck.entity.CheckHiddenPushEntity;
|
||||
import com.zcloud.modules.RyCheck.mapper.CheckHiddenPushMapper;
|
||||
import com.zcloud.modules.RyCheck.service.HiddenPushService;
|
||||
import com.zcloud.modules.sys.entity.PageData;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class HiddenPushServiceImpl extends ServiceImpl<CheckHiddenPushMapper, CheckHiddenPushEntity> implements HiddenPushService {
|
||||
|
||||
|
||||
@Override
|
||||
public void pushHidden() {
|
||||
List<PageData> waitHiddenList = baseMapper.getWaitPushHidden();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.zcloud.modules.RyCheck.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zcloud.modules.RyCheck.entity.HiddenEntity;
|
||||
import com.zcloud.modules.RyCheck.mapper.HiddenMapper;
|
||||
import com.zcloud.modules.RyCheck.service.HiddenService;
|
||||
import com.zcloud.modules.sys.entity.PageData;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class HiddenServiceImpl extends ServiceImpl<HiddenMapper, HiddenEntity> implements HiddenService {
|
||||
|
||||
|
||||
@Override
|
||||
public List<PageData> getAllUserList(PageData pd) {
|
||||
return baseMapper.getAllUserList(pd);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.zcloud.modules.RyCheck.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zcloud.modules.RyCheck.entity.HiddenUserEntity;
|
||||
import com.zcloud.modules.RyCheck.mapper.HiddenUserMapper;
|
||||
import com.zcloud.modules.RyCheck.service.HiddenUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class HiddenUserServiceImpl extends ServiceImpl<HiddenUserMapper, HiddenUserEntity> implements HiddenUserService {
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue