Browse Source
Conflicts: epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteStatisticalServiceImpl.javafeature/evaluate
686 changed files with 25006 additions and 2566 deletions
@ -1,95 +0,0 @@ |
|||||
/** |
|
||||
* Copyright (c) 2018 人人开源 All rights reserved. |
|
||||
* |
|
||||
* https://www.renren.io
|
|
||||
* |
|
||||
* 版权所有,侵权必究! |
|
||||
*/ |
|
||||
|
|
||||
package com.epmet.log; |
|
||||
|
|
||||
import com.epmet.commons.tools.exception.ExceptionUtils; |
|
||||
import com.epmet.commons.tools.log.BaseLog; |
|
||||
import com.epmet.commons.tools.log.enums.LogTypeEnum; |
|
||||
import com.epmet.commons.tools.redis.RedisKeys; |
|
||||
import com.epmet.commons.tools.redis.RedisUtils; |
|
||||
import com.epmet.commons.tools.utils.ConvertUtils; |
|
||||
import com.epmet.entity.SysLogErrorEntity; |
|
||||
import com.epmet.entity.SysLogLoginEntity; |
|
||||
import com.epmet.entity.SysLogOperationEntity; |
|
||||
import com.epmet.service.SysLogErrorService; |
|
||||
import com.epmet.service.SysLogLoginService; |
|
||||
import com.epmet.service.SysLogOperationService; |
|
||||
import lombok.extern.slf4j.Slf4j; |
|
||||
import org.apache.commons.lang3.concurrent.BasicThreadFactory; |
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
|
||||
import org.springframework.boot.CommandLineRunner; |
|
||||
import org.springframework.stereotype.Component; |
|
||||
|
|
||||
import java.util.concurrent.ScheduledExecutorService; |
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor; |
|
||||
import java.util.concurrent.TimeUnit; |
|
||||
|
|
||||
/** |
|
||||
* 从Redis队列中获取Log,保存到DB |
|
||||
* |
|
||||
* @author Mark sunlightcs@gmail.com |
|
||||
* @since 1.0.0 |
|
||||
*/ |
|
||||
@Slf4j |
|
||||
@Component |
|
||||
public class LogConsumer implements CommandLineRunner { |
|
||||
@Autowired |
|
||||
private RedisUtils redisUtils; |
|
||||
@Autowired |
|
||||
private SysLogErrorService sysLogErrorService; |
|
||||
@Autowired |
|
||||
private SysLogLoginService sysLogLoginService; |
|
||||
@Autowired |
|
||||
private SysLogOperationService sysLogOperationService; |
|
||||
private ScheduledExecutorService scheduledService = new ScheduledThreadPoolExecutor(1, |
|
||||
new BasicThreadFactory.Builder().namingPattern("log-consumer-schedule-pool-%d").daemon(true).build()); |
|
||||
|
|
||||
@Override |
|
||||
public void run(String... args) { |
|
||||
//上次任务结束后,等待10秒钟,再执行下次任务
|
|
||||
scheduledService.scheduleWithFixedDelay(() -> { |
|
||||
try { |
|
||||
receiveQueue(); |
|
||||
}catch (Exception e){ |
|
||||
log.error("LogConsumer Error:"+ ExceptionUtils.getErrorStackTrace(e)); |
|
||||
} |
|
||||
}, 1, 10, TimeUnit.SECONDS); |
|
||||
} |
|
||||
|
|
||||
private void receiveQueue() { |
|
||||
String key = RedisKeys.getSysLogKey(); |
|
||||
//每次插入100条
|
|
||||
int count = 100; |
|
||||
for(int i = 0; i < count; i++){ |
|
||||
BaseLog log = (BaseLog) redisUtils.rightPop(key); |
|
||||
if(log == null){ |
|
||||
return; |
|
||||
} |
|
||||
|
|
||||
//登录日志
|
|
||||
if(log.getType() == LogTypeEnum.LOGIN.value()){ |
|
||||
SysLogLoginEntity entity = ConvertUtils.sourceToTarget(log, SysLogLoginEntity.class); |
|
||||
sysLogLoginService.save(entity); |
|
||||
} |
|
||||
|
|
||||
//操作日志
|
|
||||
if(log.getType() == LogTypeEnum.OPERATION.value()){ |
|
||||
SysLogOperationEntity entity = ConvertUtils.sourceToTarget(log, SysLogOperationEntity.class); |
|
||||
sysLogOperationService.save(entity); |
|
||||
} |
|
||||
|
|
||||
//异常日志
|
|
||||
if(log.getType() == LogTypeEnum.ERROR.value()){ |
|
||||
SysLogErrorEntity entity = ConvertUtils.sourceToTarget(log, SysLogErrorEntity.class); |
|
||||
sysLogErrorService.save(entity); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -0,0 +1,42 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @Author zxc |
||||
|
* @DateTime 2021/1/18 下午4:43 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class SsoWorkLoginFormDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = -6543952487970013031L; |
||||
|
|
||||
|
public interface SsoLoginForm{} |
||||
|
|
||||
|
/** |
||||
|
* sso票据,有效期为300秒 |
||||
|
*/ |
||||
|
@NotBlank(message = "ssotoken不能为空",groups = SsoLoginForm.class) |
||||
|
private String token; |
||||
|
|
||||
|
/** |
||||
|
* 三方平台应用AppId |
||||
|
*/ |
||||
|
@NotBlank(message = "三方平台应用AppId不能为空",groups = SsoLoginForm.class) |
||||
|
private String appId; |
||||
|
|
||||
|
/** |
||||
|
* app类型 resi;居民段,gov:工作端 |
||||
|
*/ |
||||
|
@NotBlank(message = "app不能为空",groups = SsoLoginForm.class) |
||||
|
private String app; |
||||
|
|
||||
|
/** |
||||
|
* app;居民段,app:工作端 |
||||
|
*/ |
||||
|
@NotBlank(message = "client不能为空",groups = SsoLoginForm.class) |
||||
|
private String client; |
||||
|
} |
||||
@ -0,0 +1,25 @@ |
|||||
|
package com.epmet.commons.thirdplat.dto.result.jcet; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
public class JcetGUserInfoResultDTO { |
||||
|
private String uid; |
||||
|
/** |
||||
|
* 手机号码 |
||||
|
*/ |
||||
|
private String mobile; |
||||
|
/** |
||||
|
* 姓名 |
||||
|
*/ |
||||
|
private String name; |
||||
|
/** |
||||
|
* 账号 |
||||
|
*/ |
||||
|
private String account; |
||||
|
|
||||
|
/** |
||||
|
* 用户编码 |
||||
|
*/ |
||||
|
private String code; |
||||
|
} |
||||
@ -1,24 +0,0 @@ |
|||||
/** |
|
||||
* Copyright (c) 2018 人人开源 All rights reserved. |
|
||||
* |
|
||||
* https://www.renren.io
|
|
||||
* |
|
||||
* 版权所有,侵权必究! |
|
||||
*/ |
|
||||
|
|
||||
package com.epmet.commons.tools.annotation; |
|
||||
|
|
||||
import java.lang.annotation.*; |
|
||||
|
|
||||
/** |
|
||||
* 操作日志注解 |
|
||||
* |
|
||||
* @author Mark sunlightcs@gmail.com |
|
||||
* @since 1.0.0 |
|
||||
*/ |
|
||||
@Target(ElementType.METHOD) |
|
||||
@Retention(RetentionPolicy.RUNTIME) |
|
||||
@Documented |
|
||||
public @interface LogOperation { |
|
||||
String value() default ""; |
|
||||
} |
|
||||
@ -0,0 +1,84 @@ |
|||||
|
/** |
||||
|
* Copyright (c) 2018 人人开源 All rights reserved. |
||||
|
* <p> |
||||
|
* https://www.renren.io
|
||||
|
* <p> |
||||
|
* 版权所有,侵权必究! |
||||
|
*/ |
||||
|
|
||||
|
package com.epmet.commons.tools.aspect; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSON; |
||||
|
import com.dingtalk.api.DefaultDingTalkClient; |
||||
|
import com.dingtalk.api.DingTalkClient; |
||||
|
import com.dingtalk.api.request.OapiRobotSendRequest; |
||||
|
import com.dingtalk.api.response.OapiRobotSendResponse; |
||||
|
import com.epmet.commons.tools.enums.EnvEnum; |
||||
|
import com.epmet.commons.tools.utils.SpringContextUtils; |
||||
|
import com.taobao.api.ApiException; |
||||
|
import org.apache.logging.log4j.LogManager; |
||||
|
import org.apache.logging.log4j.Logger; |
||||
|
import org.springframework.beans.factory.annotation.Value; |
||||
|
import org.springframework.boot.context.event.ApplicationFailedEvent; |
||||
|
import org.springframework.cloud.commons.util.InetUtils; |
||||
|
import org.springframework.context.ApplicationListener; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* 应用 启动健康检查 通知类 |
||||
|
* CustomerApplicationRunner |
||||
|
* |
||||
|
* @author Mark sunlightcs@gmail.com |
||||
|
* @since 1.0.0 |
||||
|
*/ |
||||
|
@Component |
||||
|
public class ApplicationFailedEventListener implements ApplicationListener<ApplicationFailedEvent> { |
||||
|
private static Logger logger = LogManager.getLogger(ApplicationFailedEventListener.class); |
||||
|
@Value("${spring.application.name}") |
||||
|
private String appName; |
||||
|
@Value("${server.version}") |
||||
|
private String version; |
||||
|
|
||||
|
@Override |
||||
|
public void onApplicationEvent(ApplicationFailedEvent applicationFailedEvent) { |
||||
|
Throwable exception = applicationFailedEvent.getException(); |
||||
|
EnvEnum currentEnv = EnvEnum.getCurrentEnv(); |
||||
|
logger.info(currentEnv); |
||||
|
if (!EnvEnum.DEV.getCode().equals(currentEnv.getCode()) && !EnvEnum.LOCAL.getCode().equals(currentEnv.getCode())) { |
||||
|
sendDingMarkDownMsg(exception); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
private String getServerIp() { |
||||
|
InetUtils inetUtils = SpringContextUtils.getBean(InetUtils.class); |
||||
|
return inetUtils.findFirstNonLoopbackHostInfo().getIpAddress(); |
||||
|
} |
||||
|
|
||||
|
private void sendDingMarkDownMsg(Throwable exception) { |
||||
|
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/robot/send?access_token=ffd7c972b0525e249283df1a16b65a8b9d0012601f3a458dfc588c2eac497bb5"); |
||||
|
OapiRobotSendRequest request = new OapiRobotSendRequest(); |
||||
|
request.setMsgtype("markdown"); |
||||
|
OapiRobotSendRequest.Markdown markdown = new OapiRobotSendRequest.Markdown(); |
||||
|
markdown.setTitle("部署失败通知"); |
||||
|
|
||||
|
markdown.setText("部署失败通知 \n" + |
||||
|
"> 服务:" + appName + "\n\n" + |
||||
|
"> 版本:" + version + "\n\n" + |
||||
|
"> 环境:" + EnvEnum.getCurrentEnv().getName() + "\n\n" + |
||||
|
"> IP: " + getServerIp() + "\n\n" + |
||||
|
"> 异常:" + exception.getMessage() + "\n\n" |
||||
|
); |
||||
|
request.setMarkdown(markdown); |
||||
|
OapiRobotSendRequest.At at = new OapiRobotSendRequest.At(); |
||||
|
at.setIsAtAll(true); |
||||
|
request.setAt(at); |
||||
|
try { |
||||
|
OapiRobotSendResponse execute = client.execute(request); |
||||
|
logger.info("=====通知结果===>" + JSON.toJSONString(execute)); |
||||
|
} catch (ApiException e) { |
||||
|
logger.error("sendDingMarkDownMsg exception", e); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,109 @@ |
|||||
|
/** |
||||
|
* Copyright (c) 2018 人人开源 All rights reserved. |
||||
|
* <p> |
||||
|
* https://www.renren.io
|
||||
|
* <p> |
||||
|
* 版权所有,侵权必究! |
||||
|
*/ |
||||
|
|
||||
|
package com.epmet.commons.tools.aspect; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSON; |
||||
|
import com.dingtalk.api.DefaultDingTalkClient; |
||||
|
import com.dingtalk.api.DingTalkClient; |
||||
|
import com.dingtalk.api.request.OapiRobotSendRequest; |
||||
|
import com.dingtalk.api.response.OapiRobotSendResponse; |
||||
|
import com.epmet.commons.tools.dto.form.DingTalkTextMsg; |
||||
|
import com.epmet.commons.tools.enums.EnvEnum; |
||||
|
import com.epmet.commons.tools.utils.HttpClientManager; |
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.commons.tools.utils.SpringContextUtils; |
||||
|
import com.taobao.api.ApiException; |
||||
|
import org.apache.logging.log4j.LogManager; |
||||
|
import org.apache.logging.log4j.Logger; |
||||
|
import org.springframework.beans.factory.annotation.Value; |
||||
|
import org.springframework.boot.context.event.ApplicationReadyEvent; |
||||
|
import org.springframework.cloud.commons.util.InetUtils; |
||||
|
import org.springframework.context.ApplicationListener; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* 应用 启动健康检查 通知类 |
||||
|
* CustomerApplicationRunner |
||||
|
* |
||||
|
* @author Mark sunlightcs@gmail.com |
||||
|
* @since 1.0.0 |
||||
|
*/ |
||||
|
@Component |
||||
|
public class ApplicationReadyEventListener implements ApplicationListener<ApplicationReadyEvent> { |
||||
|
private static Logger logger = LogManager.getLogger(ApplicationReadyEventListener.class); |
||||
|
@Value("${spring.application.name}") |
||||
|
private String appName; |
||||
|
@Value("${server.version}") |
||||
|
private String version; |
||||
|
|
||||
|
@Override |
||||
|
public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { |
||||
|
EnvEnum currentEnv = EnvEnum.getCurrentEnv(); |
||||
|
logger.info(currentEnv); |
||||
|
if (!EnvEnum.DEV.getCode().equals(currentEnv.getCode()) && !EnvEnum.LOCAL.getCode().equals(currentEnv.getCode())) { |
||||
|
//sendDingTextMsg();
|
||||
|
sendDingMarkDownMsg(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void sendDingTextMsg() { |
||||
|
//发送启动成功消息
|
||||
|
InetUtils inetUtils = SpringContextUtils.getBean(InetUtils.class); |
||||
|
String serverIp = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress(); |
||||
|
|
||||
|
//开发小组 群机器人地址
|
||||
|
String url = "https://oapi.dingtalk.com/robot/send?access_token=ffd7c972b0525e249283df1a16b65a8b9d0012601f3a458dfc588c2eac497bb5"; |
||||
|
StringBuilder stringBuilder = new StringBuilder(); |
||||
|
stringBuilder.append(EnvEnum.getCurrentEnv().getName()) |
||||
|
.append("【") |
||||
|
.append(appName) |
||||
|
.append("】") |
||||
|
.append("ip地址: ") |
||||
|
.append(serverIp) |
||||
|
.append("部署完毕!"); |
||||
|
DingTalkTextMsg msg = new DingTalkTextMsg(); |
||||
|
msg.setWebHook(url); |
||||
|
msg.setAtAll(true); |
||||
|
msg.setContent(stringBuilder.toString()); |
||||
|
Result<String> stringResult = HttpClientManager.getInstance().sendPostByJSON(url, msg.getMsgContent()); |
||||
|
logger.info(stringResult); |
||||
|
} |
||||
|
|
||||
|
private String getServerIp() { |
||||
|
InetUtils inetUtils = SpringContextUtils.getBean(InetUtils.class); |
||||
|
return inetUtils.findFirstNonLoopbackHostInfo().getIpAddress(); |
||||
|
} |
||||
|
|
||||
|
private void sendDingMarkDownMsg() { |
||||
|
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/robot/send?access_token=ffd7c972b0525e249283df1a16b65a8b9d0012601f3a458dfc588c2eac497bb5"); |
||||
|
OapiRobotSendRequest request = new OapiRobotSendRequest(); |
||||
|
request.setMsgtype("markdown"); |
||||
|
OapiRobotSendRequest.Markdown markdown = new OapiRobotSendRequest.Markdown(); |
||||
|
markdown.setTitle("部署成功通知"); |
||||
|
|
||||
|
markdown.setText("部署成功通知 \n" + |
||||
|
"> 服务:" + appName + "\n\n" + |
||||
|
"> 版本:" + version + "\n\n" + |
||||
|
"> 环境:" + EnvEnum.getCurrentEnv().getName() + "\n\n" + |
||||
|
"> IP: " + getServerIp() + "\n\n" |
||||
|
); |
||||
|
request.setMarkdown(markdown); |
||||
|
OapiRobotSendRequest.At at = new OapiRobotSendRequest.At(); |
||||
|
at.setIsAtAll(true); |
||||
|
request.setAt(at); |
||||
|
try { |
||||
|
OapiRobotSendResponse execute = client.execute(request); |
||||
|
logger.info("=====通知结果===>" + JSON.toJSONString(execute)); |
||||
|
} catch (ApiException e) { |
||||
|
logger.error("sendDingMarkDownMsg exception", e); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -1,67 +0,0 @@ |
|||||
/** |
|
||||
* Copyright (c) 2018 人人开源 All rights reserved. |
|
||||
* <p> |
|
||||
* https://www.renren.io
|
|
||||
* <p> |
|
||||
* 版权所有,侵权必究! |
|
||||
*/ |
|
||||
|
|
||||
package com.epmet.commons.tools.aspect; |
|
||||
|
|
||||
import com.epmet.commons.tools.dto.form.DingTalkTextMsg; |
|
||||
import com.epmet.commons.tools.enums.EnvEnum; |
|
||||
import com.epmet.commons.tools.utils.HttpClientManager; |
|
||||
import com.epmet.commons.tools.utils.Result; |
|
||||
import com.epmet.commons.tools.utils.SpringContextUtils; |
|
||||
import org.apache.logging.log4j.LogManager; |
|
||||
import org.apache.logging.log4j.Logger; |
|
||||
import org.springframework.beans.factory.annotation.Value; |
|
||||
import org.springframework.boot.ApplicationArguments; |
|
||||
import org.springframework.boot.ApplicationRunner; |
|
||||
import org.springframework.cloud.commons.util.InetUtils; |
|
||||
import org.springframework.core.annotation.Order; |
|
||||
import org.springframework.stereotype.Component; |
|
||||
|
|
||||
/** |
|
||||
* 应用 启动健康检查 通知类 |
|
||||
* CustomerApplicationRunner |
|
||||
* |
|
||||
* @author Mark sunlightcs@gmail.com |
|
||||
* @since 1.0.0 |
|
||||
*/ |
|
||||
@Component |
|
||||
@Order(value = 99) |
|
||||
public class CustomerApplicationRunner implements ApplicationRunner { |
|
||||
private static Logger logger = LogManager.getLogger(CustomerApplicationRunner.class); |
|
||||
@Value("${spring.application.name}") |
|
||||
private String appName; |
|
||||
|
|
||||
@Override |
|
||||
public void run(ApplicationArguments args) { |
|
||||
//发送启动成功消息
|
|
||||
EnvEnum currentEnv = EnvEnum.getCurrentEnv(); |
|
||||
logger.info(currentEnv); |
|
||||
if (!EnvEnum.DEV.getCode().equals(currentEnv.getCode()) && !EnvEnum.LOCAL.getCode().equals(currentEnv.getCode())) { |
|
||||
InetUtils inetUtils = SpringContextUtils.getBean(InetUtils.class); |
|
||||
String serverIp = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress(); |
|
||||
|
|
||||
//开发小组 群机器人地址
|
|
||||
String url = "https://oapi.dingtalk.com/robot/send?access_token=ffd7c972b0525e249283df1a16b65a8b9d0012601f3a458dfc588c2eac497bb5"; |
|
||||
StringBuilder stringBuilder = new StringBuilder(); |
|
||||
stringBuilder.append(EnvEnum.getCurrentEnv().getName()) |
|
||||
.append("【") |
|
||||
.append(appName) |
|
||||
.append("】") |
|
||||
.append("ip地址: ") |
|
||||
.append(serverIp) |
|
||||
.append("部署完毕!"); |
|
||||
DingTalkTextMsg msg = new DingTalkTextMsg(); |
|
||||
msg.setWebHook(url); |
|
||||
msg.setAtAll(true); |
|
||||
msg.setContent(stringBuilder.toString()); |
|
||||
Result<String> stringResult = HttpClientManager.getInstance().sendPostByJSON(url, msg.getMsgContent()); |
|
||||
logger.info(stringResult); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -1,121 +0,0 @@ |
|||||
/** |
|
||||
* Copyright (c) 2018 人人开源 All rights reserved. |
|
||||
* |
|
||||
* https://www.renren.io
|
|
||||
* |
|
||||
* 版权所有,侵权必究! |
|
||||
*/ |
|
||||
|
|
||||
package com.epmet.commons.tools.aspect; |
|
||||
|
|
||||
import com.alibaba.fastjson.JSON; |
|
||||
import com.epmet.commons.tools.annotation.LogOperation; |
|
||||
import com.epmet.commons.tools.config.ModuleConfig; |
|
||||
import com.epmet.commons.tools.security.user.SecurityUser; |
|
||||
import com.epmet.commons.tools.log.SysLogOperation; |
|
||||
import com.epmet.commons.tools.log.enums.LogTypeEnum; |
|
||||
import com.epmet.commons.tools.log.enums.OperationStatusEnum; |
|
||||
import com.epmet.commons.tools.log.producer.LogProducer; |
|
||||
import com.epmet.commons.tools.security.user.UserDetail; |
|
||||
import com.epmet.commons.tools.utils.HttpContextUtils; |
|
||||
import com.epmet.commons.tools.utils.IpUtils; |
|
||||
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.http.HttpHeaders; |
|
||||
import org.springframework.stereotype.Component; |
|
||||
|
|
||||
import javax.servlet.http.HttpServletRequest; |
|
||||
import java.lang.reflect.Method; |
|
||||
import java.util.Date; |
|
||||
|
|
||||
/** |
|
||||
* 操作日志,切面处理类 |
|
||||
* |
|
||||
* @author Mark sunlightcs@gmail.com |
|
||||
* @since 1.0.0 |
|
||||
*/ |
|
||||
@Aspect |
|
||||
@Component |
|
||||
public class LogOperationAspect { |
|
||||
@Autowired |
|
||||
private ModuleConfig moduleConfig; |
|
||||
@Autowired |
|
||||
private LogProducer logProducer; |
|
||||
|
|
||||
@Pointcut("@annotation(com.epmet.commons.tools.annotation.LogOperation)") |
|
||||
public void logPointCut() { |
|
||||
|
|
||||
} |
|
||||
|
|
||||
@Around("logPointCut()") |
|
||||
public Object around(ProceedingJoinPoint point) throws Throwable { |
|
||||
long beginTime = System.currentTimeMillis(); |
|
||||
try { |
|
||||
//执行方法
|
|
||||
Object result = point.proceed(); |
|
||||
|
|
||||
//执行时长(毫秒)
|
|
||||
long time = System.currentTimeMillis() - beginTime; |
|
||||
//保存日志
|
|
||||
saveLog(point, time, OperationStatusEnum.SUCCESS.value()); |
|
||||
|
|
||||
return result; |
|
||||
}catch(Exception e) { |
|
||||
//执行时长(毫秒)
|
|
||||
long time = System.currentTimeMillis() - beginTime; |
|
||||
//保存日志
|
|
||||
saveLog(point, time, OperationStatusEnum.FAIL.value()); |
|
||||
|
|
||||
throw e; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
|
|
||||
private void saveLog(ProceedingJoinPoint joinPoint, long time, Integer status) { |
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature(); |
|
||||
Method method = signature.getMethod(); |
|
||||
|
|
||||
SysLogOperation log = new SysLogOperation(); |
|
||||
LogOperation annotation = method.getAnnotation(LogOperation.class); |
|
||||
if(annotation != null){ |
|
||||
//注解上的描述
|
|
||||
log.setOperation(annotation.value()); |
|
||||
} |
|
||||
|
|
||||
//登录用户信息
|
|
||||
UserDetail user = SecurityUser.getUser(); |
|
||||
if(user != null){ |
|
||||
log.setCreator(user.getId()); |
|
||||
log.setCreatorName(user.getUsername()); |
|
||||
} |
|
||||
|
|
||||
log.setType(LogTypeEnum.OPERATION.value()); |
|
||||
log.setModule(moduleConfig.getName()); |
|
||||
log.setStatus(status); |
|
||||
log.setRequestTime((int)time); |
|
||||
log.setCreateDate(new Date()); |
|
||||
|
|
||||
//请求相关信息
|
|
||||
HttpServletRequest request = HttpContextUtils.getHttpServletRequest(); |
|
||||
log.setIp(IpUtils.getIpAddr(request)); |
|
||||
log.setUserAgent(request.getHeader(HttpHeaders.USER_AGENT)); |
|
||||
log.setRequestUri(request.getRequestURI()); |
|
||||
log.setRequestMethod(request.getMethod()); |
|
||||
|
|
||||
//请求参数
|
|
||||
Object[] args = joinPoint.getArgs(); |
|
||||
try{ |
|
||||
String params = JSON.toJSONString(args[0]); |
|
||||
log.setRequestParams(params); |
|
||||
}catch (Exception e){ |
|
||||
|
|
||||
} |
|
||||
|
|
||||
//保存到Redis队列里
|
|
||||
logProducer.saveLog(log); |
|
||||
} |
|
||||
} |
|
||||
@ -1,153 +0,0 @@ |
|||||
/** |
|
||||
* Copyright (c) 2018 人人开源 All rights reserved. |
|
||||
* |
|
||||
* https://www.renren.io
|
|
||||
* |
|
||||
* 版权所有,侵权必究! |
|
||||
*/ |
|
||||
|
|
||||
package com.epmet.commons.tools.exception; |
|
||||
|
|
||||
import cn.hutool.core.map.MapUtil; |
|
||||
import com.alibaba.fastjson.JSON; |
|
||||
import com.epmet.commons.tools.config.ModuleConfig; |
|
||||
import com.epmet.commons.tools.log.SysLogError; |
|
||||
import com.epmet.commons.tools.log.enums.LogTypeEnum; |
|
||||
import com.epmet.commons.tools.log.producer.LogProducer; |
|
||||
import com.epmet.commons.tools.security.user.LoginUserUtil; |
|
||||
import com.epmet.commons.tools.utils.HttpContextUtils; |
|
||||
import com.epmet.commons.tools.utils.IpUtils; |
|
||||
import com.epmet.commons.tools.utils.Result; |
|
||||
import org.slf4j.Logger; |
|
||||
import org.slf4j.LoggerFactory; |
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
|
||||
import org.springframework.dao.DuplicateKeyException; |
|
||||
import org.springframework.http.HttpHeaders; |
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler; |
|
||||
|
|
||||
import javax.servlet.http.HttpServletRequest; |
|
||||
import java.util.Date; |
|
||||
import java.util.Map; |
|
||||
|
|
||||
|
|
||||
/** |
|
||||
* 异常处理器 |
|
||||
* 暂停使用,改用BaseRequestLogAspect |
|
||||
* @author Mark sunlightcs@gmail.com |
|
||||
* @since 1.0.0 |
|
||||
*/ |
|
||||
//@RestControllerAdvice
|
|
||||
public class RenExceptionHandler { |
|
||||
private static final Logger logger = LoggerFactory.getLogger(RenExceptionHandler.class); |
|
||||
@Autowired |
|
||||
private ModuleConfig moduleConfig; |
|
||||
@Autowired |
|
||||
private LogProducer logProducer; |
|
||||
@Autowired |
|
||||
private LoginUserUtil loginUserUtil; |
|
||||
|
|
||||
/** |
|
||||
* 处理自定义异常 |
|
||||
* "code": 8000, |
|
||||
* "msg": "服务器开小差了...", |
|
||||
*/ |
|
||||
@ExceptionHandler(RenException.class) |
|
||||
public Result handleRRException(RenException ex){ |
|
||||
if (ex.getCode() > 8000) { |
|
||||
Result result=new Result().error(ex.getCode()); |
|
||||
result.setData(ex.getInternalMsg()); |
|
||||
return result; |
|
||||
} |
|
||||
logger.error(ExceptionUtils.getErrorStackTrace(ex)); |
|
||||
Result result=new Result().error(); |
|
||||
result.setData(ex.getInternalMsg()); |
|
||||
return result; |
|
||||
// return new Result().error();
|
|
||||
} |
|
||||
|
|
||||
|
|
||||
/** |
|
||||
* 处理自定义异常 |
|
||||
* "code": 8000, |
|
||||
* "msg": "服务器开小差了...", |
|
||||
*/ |
|
||||
@ExceptionHandler(ValidateException.class) |
|
||||
public Result handleVException(ValidateException ex){ |
|
||||
logger.error(ExceptionUtils.getErrorStackTrace(ex)); |
|
||||
Result result=new Result(); |
|
||||
result.setCode(ex.getCode()); |
|
||||
result.setMsg(ex.getMsg()); |
|
||||
return result; |
|
||||
// return new Result().error();
|
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 运行时异常拦截 |
|
||||
* "code": 8000, |
|
||||
* "msg": "服务器开小差了...", |
|
||||
*/ |
|
||||
@ExceptionHandler(RuntimeException.class) |
|
||||
public Result handleRuntimeException(RuntimeException ex){ |
|
||||
logger.error(ExceptionUtils.getErrorStackTrace(ex)); |
|
||||
Result result=new Result().error(); |
|
||||
result.setData(ex.getMessage()); |
|
||||
return result; |
|
||||
// return new Result().error();
|
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 处理自定义异常 |
|
||||
* "code": 10002, |
|
||||
* "msg": "数据库中已存在该记录", |
|
||||
*/ |
|
||||
@ExceptionHandler(DuplicateKeyException.class) |
|
||||
public Result handleDuplicateKeyException(DuplicateKeyException ex){ |
|
||||
logger.error(ExceptionUtils.getErrorStackTrace(ex)); |
|
||||
return new Result().error(ErrorCode.DB_RECORD_EXISTS); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 异常 |
|
||||
* "code": 8000, |
|
||||
* "msg": "服务器开小差了...", |
|
||||
*/ |
|
||||
@ExceptionHandler(Exception.class) |
|
||||
public Result handleException(Exception ex){ |
|
||||
logger.error(ExceptionUtils.getErrorStackTrace(ex)); |
|
||||
// saveLog(ex);
|
|
||||
Result result=new Result().error(); |
|
||||
result.setData(ex.getMessage()); |
|
||||
return result; |
|
||||
// return new Result().error();
|
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 保存异常日志 |
|
||||
*/ |
|
||||
private void saveLog(Exception ex){ |
|
||||
SysLogError log = new SysLogError(); |
|
||||
log.setType(LogTypeEnum.ERROR.value()); |
|
||||
log.setModule(moduleConfig.getName()); |
|
||||
|
|
||||
//请求相关信息
|
|
||||
HttpServletRequest request = HttpContextUtils.getHttpServletRequest(); |
|
||||
log.setUserAgent(request.getHeader(HttpHeaders.USER_AGENT)); |
|
||||
log.setRequestUri(request.getRequestURI()); |
|
||||
log.setRequestMethod(request.getMethod()); |
|
||||
log.setIp(IpUtils.getIpAddr(request)); |
|
||||
Map<String, String> params = HttpContextUtils.getParameterMap(request); |
|
||||
if(MapUtil.isNotEmpty(params)){ |
|
||||
log.setRequestParams(JSON.toJSONString(params)); |
|
||||
} |
|
||||
|
|
||||
//登录用户ID
|
|
||||
|
|
||||
log.setCreator(loginUserUtil.getLoginUserId()); |
|
||||
//异常信息
|
|
||||
log.setErrorInfo(ExceptionUtils.getErrorStackTrace(ex)); |
|
||||
|
|
||||
//保存到Redis队列里
|
|
||||
log.setCreateDate(new Date()); |
|
||||
logProducer.saveLog(log); |
|
||||
} |
|
||||
} |
|
||||
@ -1,43 +0,0 @@ |
|||||
/** |
|
||||
* Copyright (c) 2018 人人开源 All rights reserved. |
|
||||
* |
|
||||
* https://www.renren.io
|
|
||||
* |
|
||||
* 版权所有,侵权必究! |
|
||||
*/ |
|
||||
|
|
||||
package com.epmet.commons.tools.log.producer; |
|
||||
|
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder; |
|
||||
import com.epmet.commons.tools.log.BaseLog; |
|
||||
import com.epmet.commons.tools.redis.RedisKeys; |
|
||||
import com.epmet.commons.tools.redis.RedisUtils; |
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
|
||||
import org.springframework.stereotype.Component; |
|
||||
|
|
||||
import java.util.concurrent.*; |
|
||||
|
|
||||
/** |
|
||||
* 日志通过redis队列,异步保存到数据库 |
|
||||
* |
|
||||
* @author Mark sunlightcs@gmail.com |
|
||||
* @since 1.0.0 |
|
||||
*/ |
|
||||
@Component |
|
||||
public class LogProducer { |
|
||||
@Autowired |
|
||||
private RedisUtils redisUtils; |
|
||||
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("log-producer-pool-%d").build(); |
|
||||
ExecutorService pool = new ThreadPoolExecutor(5, 200, 0L,TimeUnit.MILLISECONDS, |
|
||||
new LinkedBlockingQueue<>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); |
|
||||
|
|
||||
/** |
|
||||
* 保存Log到Redis消息队列 |
|
||||
*/ |
|
||||
public void saveLog(BaseLog log){ |
|
||||
String key = RedisKeys.getSysLogKey(); |
|
||||
|
|
||||
//异步保存到队列
|
|
||||
pool.execute(() -> redisUtils.leftPush(key, log, RedisUtils.NOT_EXPIRE)); |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,251 @@ |
|||||
|
package com.epmet.commons.tools.utils; |
||||
|
|
||||
|
import javax.crypto.Cipher; |
||||
|
import java.security.*; |
||||
|
import java.security.spec.PKCS8EncodedKeySpec; |
||||
|
import java.security.spec.X509EncodedKeySpec; |
||||
|
import java.util.Base64; |
||||
|
|
||||
|
/** |
||||
|
* @author jianjun liu |
||||
|
* @date 2020-06-05 16:48 |
||||
|
**/ |
||||
|
|
||||
|
public class RSASignature { |
||||
|
|
||||
|
|
||||
|
//非对称密钥算法
|
||||
|
private static final String KEY_ALGORITHM = "RSA"; |
||||
|
//密钥长度,在512到65536位之间,建议不要太长,否则速度很慢,生成的加密数据很长
|
||||
|
private static final int KEY_SIZE = 512; |
||||
|
//字符编码
|
||||
|
private static final String CHARSET = "UTF-8"; |
||||
|
|
||||
|
/** |
||||
|
* 生成密钥对 |
||||
|
* |
||||
|
* @return KeyPair 密钥对 |
||||
|
*/ |
||||
|
public static KeyPair getKeyPair() throws Exception { |
||||
|
return getKeyPair(null); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 生成密钥对 |
||||
|
* |
||||
|
* @param password 生成密钥对的密码 |
||||
|
* @return |
||||
|
* @throws Exception |
||||
|
*/ |
||||
|
public static KeyPair getKeyPair(String password) throws Exception { |
||||
|
//实例化密钥生成器
|
||||
|
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(KEY_ALGORITHM); |
||||
|
//初始化密钥生成器
|
||||
|
if (password == null) { |
||||
|
keyPairGenerator.initialize(KEY_SIZE); |
||||
|
} else { |
||||
|
SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG"); |
||||
|
secureRandom.setSeed(password.getBytes(CHARSET)); |
||||
|
keyPairGenerator.initialize(KEY_SIZE, secureRandom); |
||||
|
} |
||||
|
//生成密钥对
|
||||
|
return keyPairGenerator.generateKeyPair(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 取得私钥 |
||||
|
* |
||||
|
* @param keyPair 密钥对 |
||||
|
* @return byte[] 私钥 |
||||
|
*/ |
||||
|
public static byte[] getPrivateKeyBytes(KeyPair keyPair) { |
||||
|
return keyPair.getPrivate().getEncoded(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 取得Base64编码的私钥 |
||||
|
* |
||||
|
* @param keyPair 密钥对 |
||||
|
* @return String Base64编码的私钥 |
||||
|
*/ |
||||
|
public static String getPrivateKey(KeyPair keyPair) { |
||||
|
return Base64.getEncoder().encodeToString(getPrivateKeyBytes(keyPair)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 取得公钥 |
||||
|
* |
||||
|
* @param keyPair 密钥对 |
||||
|
* @return byte[] 公钥 |
||||
|
*/ |
||||
|
public static byte[] getPublicKeyBytes(KeyPair keyPair) { |
||||
|
return keyPair.getPublic().getEncoded(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 取得Base64编码的公钥 |
||||
|
* |
||||
|
* @param keyPair 密钥对 |
||||
|
* @return String Base64编码的公钥 |
||||
|
*/ |
||||
|
public static String getPublicKey(KeyPair keyPair) { |
||||
|
return Base64.getEncoder().encodeToString(getPublicKeyBytes(keyPair)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 私钥加密 |
||||
|
* |
||||
|
* @param data 待加密数据 |
||||
|
* @param privateKey 私钥字节数组 |
||||
|
* @return byte[] 加密数据 |
||||
|
*/ |
||||
|
public static byte[] encryptByPrivateKey(byte[] data, byte[] privateKey) throws Exception { |
||||
|
//实例化密钥工厂
|
||||
|
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM); |
||||
|
//生成私钥
|
||||
|
PrivateKey key = keyFactory.generatePrivate(new PKCS8EncodedKeySpec(privateKey)); |
||||
|
//数据加密
|
||||
|
Cipher cipher = Cipher.getInstance(KEY_ALGORITHM); |
||||
|
cipher.init(Cipher.ENCRYPT_MODE, key); |
||||
|
return cipher.doFinal(data); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 私钥加密 |
||||
|
* |
||||
|
* @param data 待加密数据 |
||||
|
* @param privateKey Base64编码的私钥 |
||||
|
* @return String Base64编码的加密数据 |
||||
|
*/ |
||||
|
public static String encryptByPrivateKey(String data, String privateKey) throws Exception { |
||||
|
byte[] key = Base64.getDecoder().decode(privateKey); |
||||
|
return Base64.getEncoder().encodeToString(encryptByPrivateKey(data.getBytes(CHARSET), key)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 公钥加密 |
||||
|
* |
||||
|
* @param data 待加密数据 |
||||
|
* @param publicKey 公钥字节数组 |
||||
|
* @return byte[] 加密数据 |
||||
|
*/ |
||||
|
public static byte[] encryptByPublicKey(byte[] data, byte[] publicKey) throws Exception { |
||||
|
//实例化密钥工厂
|
||||
|
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM); |
||||
|
//生成公钥
|
||||
|
PublicKey key = keyFactory.generatePublic(new X509EncodedKeySpec(publicKey)); |
||||
|
//数据加密
|
||||
|
Cipher cipher = Cipher.getInstance(KEY_ALGORITHM); |
||||
|
cipher.init(Cipher.ENCRYPT_MODE, key); |
||||
|
return cipher.doFinal(data); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 公钥加密 |
||||
|
* |
||||
|
* @param data 待加密数据 |
||||
|
* @param publicKey Base64编码的公钥 |
||||
|
* @return String Base64编码的加密数据 |
||||
|
*/ |
||||
|
public static String encryptByPublicKey(String data, String publicKey) throws Exception { |
||||
|
byte[] key = Base64.getDecoder().decode(publicKey); |
||||
|
return Base64.getEncoder().encodeToString(encryptByPublicKey(data.getBytes(CHARSET), key)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 私钥解密 |
||||
|
* |
||||
|
* @param data 待解密数据 |
||||
|
* @param privateKey 私钥字节数组 |
||||
|
* @return byte[] 解密数据 |
||||
|
*/ |
||||
|
public static byte[] decryptByPrivateKey(byte[] data, byte[] privateKey) throws Exception { |
||||
|
//实例化密钥工厂
|
||||
|
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM); |
||||
|
//生成私钥
|
||||
|
PrivateKey key = keyFactory.generatePrivate(new PKCS8EncodedKeySpec(privateKey)); |
||||
|
//数据解密
|
||||
|
Cipher cipher = Cipher.getInstance(KEY_ALGORITHM); |
||||
|
cipher.init(Cipher.DECRYPT_MODE, key); |
||||
|
return cipher.doFinal(data); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 私钥解密 |
||||
|
* |
||||
|
* @param data Base64编码的待解密数据 |
||||
|
* @param privateKey Base64编码的私钥 |
||||
|
* @return String 解密数据 |
||||
|
*/ |
||||
|
public static String decryptByPrivateKey(String data, String privateKey) throws Exception { |
||||
|
byte[] key = Base64.getDecoder().decode(privateKey); |
||||
|
return new String(decryptByPrivateKey(Base64.getDecoder().decode(data), key), CHARSET); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 公钥解密 |
||||
|
* |
||||
|
* @param data 待解密数据 |
||||
|
* @param publicKey 公钥字节数组 |
||||
|
* @return byte[] 解密数据 |
||||
|
*/ |
||||
|
public static byte[] decryptByPublicKey(byte[] data, byte[] publicKey) throws Exception { |
||||
|
//实例化密钥工厂
|
||||
|
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM); |
||||
|
//产生公钥
|
||||
|
PublicKey key = keyFactory.generatePublic(new X509EncodedKeySpec(publicKey)); |
||||
|
//数据解密
|
||||
|
Cipher cipher = Cipher.getInstance(KEY_ALGORITHM); |
||||
|
cipher.init(Cipher.DECRYPT_MODE, key); |
||||
|
return cipher.doFinal(data); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 公钥解密 |
||||
|
* |
||||
|
* @param data Base64编码的待解密数据 |
||||
|
* @param publicKey Base64编码的公钥 |
||||
|
* @return String 解密数据 |
||||
|
*/ |
||||
|
public static String decryptByPublicKey(String data, String publicKey) throws Exception { |
||||
|
byte[] key = Base64.getDecoder().decode(publicKey); |
||||
|
return new String(decryptByPublicKey(Base64.getDecoder().decode(data), key), CHARSET); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 测试加解密方法 |
||||
|
* |
||||
|
* @param args |
||||
|
* @throws Exception |
||||
|
*/ |
||||
|
public static void main(String[] args) throws Exception { |
||||
|
//生成密钥对,一般生成之后可以放到配置文件中
|
||||
|
KeyPair keyPair = RSASignature.getKeyPair(); |
||||
|
//公钥
|
||||
|
String publicKey = RSASignature.getPublicKey(keyPair); |
||||
|
//私钥
|
||||
|
String privateKey = RSASignature.getPrivateKey(keyPair); |
||||
|
|
||||
|
System.out.println("公钥:\n" + publicKey); |
||||
|
System.out.println("私钥:\n" + privateKey); |
||||
|
|
||||
|
String data = "RSA 加解密测试!"; |
||||
|
{ |
||||
|
System.out.println("\n===========私钥加密,公钥解密=============="); |
||||
|
String s1 = RSASignature.encryptByPrivateKey(data, privateKey); |
||||
|
System.out.println("加密后的数据:" + s1); |
||||
|
String s2 = RSASignature.decryptByPublicKey(s1, publicKey); |
||||
|
System.out.println("解密后的数据:" + s2 + "\n\n"); |
||||
|
} |
||||
|
//=====
|
||||
|
{ |
||||
|
System.out.println("\n===========公钥加密,私钥解密=============="); |
||||
|
String s1 = RSASignature.encryptByPublicKey(data, publicKey); |
||||
|
System.out.println("加密后的数据:" + s1); |
||||
|
String s2 = RSASignature.decryptByPrivateKey(s1, privateKey); |
||||
|
System.out.println("解密后的数据:" + s2 + "\n\n"); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,21 @@ |
|||||
|
package com.epmet.dataaggre.dto.epmetuser.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @Author zxc |
||||
|
* @DateTime 2021/3/30 上午11:04 |
||||
|
* @DESC |
||||
|
*/ |
||||
|
@Data |
||||
|
public class UserInfosResultDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 7129564173128153335L; |
||||
|
|
||||
|
private String userId; |
||||
|
private String userShowName; |
||||
|
private String headPhoto; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,35 @@ |
|||||
|
package com.epmet.dataaggre.dto.resigroup.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import javax.validation.constraints.NotNull; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @Author zxc |
||||
|
* @DateTime 2021/3/30 上午9:34 |
||||
|
* @DESC |
||||
|
*/ |
||||
|
@Data |
||||
|
public class CandidateListFormDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 6184071611057671961L; |
||||
|
|
||||
|
public interface CandidateListForm{} |
||||
|
|
||||
|
/** |
||||
|
* 小组ID |
||||
|
*/ |
||||
|
@NotBlank(message = "小组ID不能为空",groups = CandidateListForm.class) |
||||
|
private String groupId; |
||||
|
|
||||
|
@NotNull(message = "pageNo不能为空",groups = CandidateListForm.class) |
||||
|
private Integer pageNo; |
||||
|
|
||||
|
@NotNull(message = "pageSize不能为空",groups = CandidateListForm.class) |
||||
|
private Integer pageSize; |
||||
|
|
||||
|
private String customerId; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,57 @@ |
|||||
|
package com.epmet.dataaggre.dto.resigroup.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Author zxc |
||||
|
* @DateTime 2021/3/30 上午9:15 |
||||
|
* @DESC |
||||
|
*/ |
||||
|
@Data |
||||
|
public class CandidateListResultDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 4720936429310456924L; |
||||
|
|
||||
|
/** |
||||
|
* resi_group_member.id: 成员id |
||||
|
*/ |
||||
|
private String memberId; |
||||
|
|
||||
|
/** |
||||
|
* 组员的用户id |
||||
|
*/ |
||||
|
private String userId; |
||||
|
|
||||
|
/** |
||||
|
* 成员头像 |
||||
|
*/ |
||||
|
private String headPhoto; |
||||
|
|
||||
|
/** |
||||
|
* 成员的显示名称 |
||||
|
*/ |
||||
|
private String userShowName; |
||||
|
|
||||
|
/** |
||||
|
* 徽章Url集合 |
||||
|
*/ |
||||
|
private String leaderFlag; |
||||
|
|
||||
|
/** |
||||
|
* leader群主,member成员 |
||||
|
*/ |
||||
|
private List<String> badgeList; |
||||
|
|
||||
|
public CandidateListResultDTO() { |
||||
|
this.memberId = ""; |
||||
|
this.userId = ""; |
||||
|
this.headPhoto = ""; |
||||
|
this.userShowName = ""; |
||||
|
this.leaderFlag = ""; |
||||
|
this.badgeList = new ArrayList<>(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,47 @@ |
|||||
|
package com.epmet.dataaggre.redis; |
||||
|
|
||||
|
import com.epmet.commons.tools.redis.RedisUtils; |
||||
|
import com.epmet.dataaggre.constant.GroupConstant; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
import org.springframework.util.CollectionUtils; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* @Author zxc |
||||
|
* @DateTime 2021/3/30 下午1:39 |
||||
|
* @DESC |
||||
|
*/ |
||||
|
@Component |
||||
|
@Slf4j |
||||
|
public class ResiGroupRedis { |
||||
|
|
||||
|
@Autowired |
||||
|
private RedisUtils redisUtils; |
||||
|
|
||||
|
/** |
||||
|
* @Description 获取用户徽章 |
||||
|
* @Param customerId |
||||
|
* @Param userId |
||||
|
* @author zxc |
||||
|
* @date 2021/3/30 下午3:33 |
||||
|
*/ |
||||
|
public List<String> getBadgeInfoByUserId(String customerId,String userId){ |
||||
|
String key = GroupConstant.BADGE_KEY+customerId+":"+userId; |
||||
|
List<Object> result = redisUtils.getListLrange(key); |
||||
|
if (!CollectionUtils.isEmpty(result)){ |
||||
|
List<String> icons = new ArrayList<>(); |
||||
|
for (Object o : result) { |
||||
|
Map<String,String> map = (Map<String, String>) o; |
||||
|
icons.add(map.get(GroupConstant.BADGE_ICON)); |
||||
|
} |
||||
|
return icons; |
||||
|
} |
||||
|
return new ArrayList<>(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -1,8 +1,29 @@ |
|||||
package com.epmet.dataaggre.service.epmetuser; |
package com.epmet.dataaggre.service.epmetuser; |
||||
|
|
||||
|
import com.epmet.dataaggre.dto.epmetuser.result.UserInfosResultDTO; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
/** |
/** |
||||
* @Author zxc |
* @Author zxc |
||||
* @DateTime 2020/12/25 上午9:20 |
* @DateTime 2020/12/25 上午9:20 |
||||
*/ |
*/ |
||||
public interface EpmetUserService { |
public interface EpmetUserService { |
||||
|
|
||||
|
/** |
||||
|
* @Description 根据UserIds查询 |
||||
|
* @Param userIds |
||||
|
* @author zxc |
||||
|
* @date 2021/3/30 上午11:07 |
||||
|
*/ |
||||
|
List<UserInfosResultDTO> selectUserInfosByUserIds(List<String> userIds); |
||||
|
|
||||
|
/** |
||||
|
* @Description 查询是党员/热心居民的userId |
||||
|
* @Param userIds |
||||
|
* @author zxc |
||||
|
* @date 2021/4/1 上午9:08 |
||||
|
*/ |
||||
|
List<String> selectUserIdByCustomerId(List<String> userIds); |
||||
|
|
||||
} |
} |
||||
|
|||||
@ -0,0 +1,43 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.epmet.project.dto; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.math.BigDecimal; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
@Data |
||||
|
public class CustomerCategoryDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 父id |
||||
|
* pid = 0 查询一级分类 |
||||
|
* pid != 0 查询二级分类 |
||||
|
*/ |
||||
|
private String pid; |
||||
|
|
||||
|
/** |
||||
|
* 客户Id |
||||
|
*/ |
||||
|
private String customerId; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,41 @@ |
|||||
|
package com.epmet.project.dto.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Author zhangyong |
||||
|
* @Description 002、项目分类字典查询 |
||||
|
**/ |
||||
|
@Data |
||||
|
public class ProjectCategoryDictResultDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 8529179932504931368L; |
||||
|
|
||||
|
/** |
||||
|
* 一级分类编码 |
||||
|
*/ |
||||
|
private String categoryCode; |
||||
|
|
||||
|
/** |
||||
|
* 一级分类名称 |
||||
|
*/ |
||||
|
private String categoryName; |
||||
|
|
||||
|
/** |
||||
|
* 二级分类列表 |
||||
|
*/ |
||||
|
private List<ProjectCategoryDictResultDTO> children; |
||||
|
|
||||
|
/** |
||||
|
* 主键 |
||||
|
**/ |
||||
|
private String id; |
||||
|
|
||||
|
/** |
||||
|
* 上级分类ID 顶级此列存储0 |
||||
|
**/ |
||||
|
private String pid; |
||||
|
} |
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue