提交修改
This commit is contained in:
parent
5520bbf470
commit
c6afc9558b
@ -10,13 +10,14 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author wutao
|
||||
* @description mq配置
|
||||
* @date 2020-12-25
|
||||
*/
|
||||
// @Configuration
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class RabbitConfig {
|
||||
|
||||
@ -67,6 +68,12 @@ public class RabbitConfig {
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public Queue urlStatisticQueue(@Value("${eb.config.rabbitQueue.urlStatisticQueue}") String queueName) {
|
||||
return new Queue(queueName);
|
||||
}
|
||||
|
||||
|
||||
@Bean(name = "accountLogNameQueueSimpleRabbitListenerContainerFactory")
|
||||
public SimpleRabbitListenerContainerFactory accountLogNameQueueSimpleRabbitListenerContainerFactory() {
|
||||
SimpleRabbitListenerContainerFactory listenerContainerFactory = new SimpleRabbitListenerContainerFactory();
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
package com.heyu.api.data.dao.vv;
|
||||
/**
|
||||
* <p>
|
||||
* 评论表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author quyixiao
|
||||
* @since 2025-10-19
|
||||
*/
|
||||
import com.heyu.api.data.entity.vv.VvRequestLogEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.lz.mybatis.plugin.annotations.Column;
|
||||
import com.lz.mybatis.plugin.annotations.DateFormat;
|
||||
import com.lz.mybatis.plugin.annotations.EQ;
|
||||
import com.lz.mybatis.plugin.utils.DF_Const;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface VvRequestLogDao extends BaseMapper<VvRequestLogEntity> {
|
||||
|
||||
|
||||
VvRequestLogEntity selectVvRequestLogById(@Param("id")Long id);
|
||||
|
||||
|
||||
Long insertVvRequestLog(VvRequestLogEntity vvRequestLog);
|
||||
|
||||
|
||||
Long insertOrUpdateVvRequestLog(VvRequestLogEntity vvRequestLog);
|
||||
|
||||
|
||||
int updateVvRequestLogById(VvRequestLogEntity vvRequestLog);
|
||||
|
||||
|
||||
int updateCoverVvRequestLogById(VvRequestLogEntity vvRequestLog);
|
||||
|
||||
|
||||
int deleteVvRequestLogById(@Param("id")Long id);
|
||||
|
||||
|
||||
|
||||
List<VvRequestLogEntity> selectVvRequestLogByCreateTime(@Column(VvRequestLogEntity.create_time) @EQ @DateFormat(DF_Const.y_m_d) String createTime);
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
|
||||
package com.heyu.api.data.dto;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Data
|
||||
public class VVRequestLogDTO extends BaseRabbitDTO {
|
||||
|
||||
/***
|
||||
* url
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/***
|
||||
* 执行时间
|
||||
*/
|
||||
private Long exet;
|
||||
|
||||
|
||||
/***
|
||||
* 请求参数
|
||||
*/
|
||||
private String params;
|
||||
|
||||
/**
|
||||
* 买家id
|
||||
*/
|
||||
private Long buyerId ;
|
||||
/***
|
||||
* 接口描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
public VVRequestLogDTO() {
|
||||
|
||||
}
|
||||
|
||||
public VVRequestLogDTO(String token,
|
||||
String userName,
|
||||
String traceId,
|
||||
long msgSendTime,
|
||||
String url,
|
||||
Long exet,
|
||||
String params,
|
||||
Long buyerId,
|
||||
String describe
|
||||
|
||||
) {
|
||||
this.token = token;
|
||||
this.userName = userName;
|
||||
this.url = url;
|
||||
this.traceId = traceId;
|
||||
this.msgSendTime = msgSendTime;
|
||||
this.exet = exet;
|
||||
this.params = params;
|
||||
this.buyerId = buyerId;
|
||||
this.description = describe;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,276 @@
|
||||
package com.heyu.api.data.entity.vv;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
/**
|
||||
*评论表
|
||||
* @author quyixiao
|
||||
* @since 2025-10-19
|
||||
*/
|
||||
|
||||
@Data
|
||||
@TableName("vv_request_log")
|
||||
public class VvRequestLogEntity implements java.io.Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public final static String CLASS_NAME ="com.heyu.api.data.entity.vv.VvRequestLogEntity:";
|
||||
|
||||
public final static String all = CLASS_NAME + "*";
|
||||
public final static String id_ = CLASS_NAME + "id"; //
|
||||
public final static String is_delete = CLASS_NAME + "is_delete"; // 是否删除:0 否 1 删除
|
||||
public final static String create_time = CLASS_NAME + "create_time"; // 创建时间
|
||||
public final static String modify_time = CLASS_NAME + "modify_time"; // 修改时间
|
||||
public final static String token_ = CLASS_NAME + "token"; // token
|
||||
public final static String user_name = CLASS_NAME + "user_name"; // 用户名
|
||||
public final static String uri_ = CLASS_NAME + "uri"; // uri
|
||||
public final static String trace_id = CLASS_NAME + "trace_id"; // 日志编号
|
||||
public final static String msg_send_time = CLASS_NAME + "msg_send_time"; // 消息发送时间
|
||||
public final static String exet_ = CLASS_NAME + "exet"; // 时间
|
||||
public final static String params_ = CLASS_NAME + "params"; // 参数
|
||||
public final static String buyer_id = CLASS_NAME + "buyer_id"; // 买家id
|
||||
public final static String description_ = CLASS_NAME + "description"; // 描述
|
||||
//
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
//是否删除:0 否 1 删除
|
||||
private Integer isDelete;
|
||||
//创建时间
|
||||
private Date createTime;
|
||||
//修改时间
|
||||
private Date modifyTime;
|
||||
//token
|
||||
private String token;
|
||||
//用户名
|
||||
private String userName;
|
||||
//uri
|
||||
private String uri;
|
||||
//日志编号
|
||||
private String traceId;
|
||||
//消息发送时间
|
||||
private Long msgSendTime;
|
||||
//时间
|
||||
private Long exet;
|
||||
//参数
|
||||
private String params;
|
||||
//买家id
|
||||
private Long buyerId;
|
||||
//描述
|
||||
private String description;
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否删除:0 否 1 删除
|
||||
* @return
|
||||
*/
|
||||
public Integer getIsDelete() {
|
||||
return isDelete;
|
||||
}
|
||||
/**
|
||||
* 是否删除:0 否 1 删除
|
||||
* @param isDelete
|
||||
*/
|
||||
public void setIsDelete(Integer isDelete) {
|
||||
this.isDelete = isDelete;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
* @return
|
||||
*/
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
/**
|
||||
* 创建时间
|
||||
* @param createTime
|
||||
*/
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
* @return
|
||||
*/
|
||||
public Date getModifyTime() {
|
||||
return modifyTime;
|
||||
}
|
||||
/**
|
||||
* 修改时间
|
||||
* @param modifyTime
|
||||
*/
|
||||
public void setModifyTime(Date modifyTime) {
|
||||
this.modifyTime = modifyTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* token
|
||||
* @return
|
||||
*/
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
/**
|
||||
* token
|
||||
* @param token
|
||||
*/
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
* @return
|
||||
*/
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
/**
|
||||
* 用户名
|
||||
* @param userName
|
||||
*/
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
/**
|
||||
* uri
|
||||
* @return
|
||||
*/
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
/**
|
||||
* uri
|
||||
* @param uri
|
||||
*/
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* 日志编号
|
||||
* @return
|
||||
*/
|
||||
public String getTraceId() {
|
||||
return traceId;
|
||||
}
|
||||
/**
|
||||
* 日志编号
|
||||
* @param traceId
|
||||
*/
|
||||
public void setTraceId(String traceId) {
|
||||
this.traceId = traceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息发送时间
|
||||
* @return
|
||||
*/
|
||||
public Long getMsgSendTime() {
|
||||
return msgSendTime;
|
||||
}
|
||||
/**
|
||||
* 消息发送时间
|
||||
* @param msgSendTime
|
||||
*/
|
||||
public void setMsgSendTime(Long msgSendTime) {
|
||||
this.msgSendTime = msgSendTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间
|
||||
* @return
|
||||
*/
|
||||
public Long getExet() {
|
||||
return exet;
|
||||
}
|
||||
/**
|
||||
* 时间
|
||||
* @param exet
|
||||
*/
|
||||
public void setExet(Long exet) {
|
||||
this.exet = exet;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数
|
||||
* @return
|
||||
*/
|
||||
public String getParams() {
|
||||
return params;
|
||||
}
|
||||
/**
|
||||
* 参数
|
||||
* @param params
|
||||
*/
|
||||
public void setParams(String params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 买家id
|
||||
* @return
|
||||
*/
|
||||
public Long getBuyerId() {
|
||||
return buyerId;
|
||||
}
|
||||
/**
|
||||
* 买家id
|
||||
* @param buyerId
|
||||
*/
|
||||
public void setBuyerId(Long buyerId) {
|
||||
this.buyerId = buyerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述
|
||||
* @return
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
/**
|
||||
* 描述
|
||||
* @param description
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "VvRequestLogEntity{" +
|
||||
",id=" + id +
|
||||
",isDelete=" + isDelete +
|
||||
",createTime=" + createTime +
|
||||
",modifyTime=" + modifyTime +
|
||||
",token=" + token +
|
||||
",userName=" + userName +
|
||||
",uri=" + uri +
|
||||
",traceId=" + traceId +
|
||||
",msgSendTime=" + msgSendTime +
|
||||
",exet=" + exet +
|
||||
",params=" + params +
|
||||
",buyerId=" + buyerId +
|
||||
",description=" + description +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
package com.heyu.api.data.service.impl.vv;
|
||||
/**
|
||||
* <p>
|
||||
* 评论表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author quyixiao
|
||||
* @since 2025-10-19
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.heyu.api.data.dao.vv.VvRequestLogDao;
|
||||
import com.heyu.api.data.entity.vv.VvRequestLogEntity;
|
||||
import com.heyu.api.data.service.vv.VvRequestLogService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class VvRequestLogServiceImpl extends ServiceImpl<VvRequestLogDao, VvRequestLogEntity> implements VvRequestLogService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private VvRequestLogDao vvRequestLogDao;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public VvRequestLogEntity selectVvRequestLogById(Long id){
|
||||
return vvRequestLogDao.selectVvRequestLogById(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Long insertVvRequestLog(VvRequestLogEntity vvRequestLog){
|
||||
return vvRequestLogDao.insertVvRequestLog(vvRequestLog);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Long insertOrUpdateVvRequestLog(VvRequestLogEntity vvRequestLog){
|
||||
return vvRequestLogDao.insertOrUpdateVvRequestLog(vvRequestLog);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int updateVvRequestLogById(VvRequestLogEntity vvRequestLog){
|
||||
return vvRequestLogDao.updateVvRequestLogById(vvRequestLog);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int updateCoverVvRequestLogById(VvRequestLogEntity vvRequestLog){
|
||||
return vvRequestLogDao.updateCoverVvRequestLogById(vvRequestLog);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int deleteVvRequestLogById(Long id){
|
||||
return vvRequestLogDao.deleteVvRequestLogById(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package com.heyu.api.data.service.vv;
|
||||
/**
|
||||
* <p>
|
||||
* 评论表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author quyixiao
|
||||
* @since 2025-10-19
|
||||
*/
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.heyu.api.data.entity.vv.VvRequestLogEntity;
|
||||
public interface VvRequestLogService extends IService<VvRequestLogEntity> {
|
||||
|
||||
|
||||
|
||||
VvRequestLogEntity selectVvRequestLogById(Long id);
|
||||
|
||||
|
||||
Long insertVvRequestLog(VvRequestLogEntity vvRequestLog);
|
||||
|
||||
|
||||
Long insertOrUpdateVvRequestLog(VvRequestLogEntity vvRequestLog);
|
||||
|
||||
|
||||
int updateVvRequestLogById(VvRequestLogEntity vvRequestLog);
|
||||
|
||||
|
||||
int updateCoverVvRequestLogById(VvRequestLogEntity vvRequestLog);
|
||||
|
||||
|
||||
int deleteVvRequestLogById(Long id);
|
||||
|
||||
|
||||
}
|
||||
@ -71,6 +71,25 @@ public class AnnotationUtils {
|
||||
}
|
||||
|
||||
|
||||
public static <T> T getAnnotationValueByMethod(Method method, String annotationName, String key) {
|
||||
Annotation annotation[] = method.getAnnotations();
|
||||
if (annotation != null && annotation.length > 0) {
|
||||
for (Annotation annotation1 : annotation) {
|
||||
|
||||
if (annotationName.equals(getAnnotationName(annotation1))) {
|
||||
return getAnnotationValue(annotation1, key);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static <T> T getAnnotationValue(Annotation annotation,String key) {
|
||||
try {
|
||||
|
||||
@ -202,6 +202,21 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
||||
return new Time(localTime.getHour(), localTime.getMinute(), localTime.getSecond());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 日期型字符串转化为日期 格式
|
||||
*/
|
||||
public static Date myParseDate(Object str) {
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return parseDate(str.toString(), parsePatterns);
|
||||
} catch (ParseException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get start of date.
|
||||
*
|
||||
|
||||
@ -0,0 +1,77 @@
|
||||
package com.heyu.api.data.utils;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class ExpressionParse {
|
||||
|
||||
public static <T> T getValue(String expression) {
|
||||
String className = "";
|
||||
String methodName = "";
|
||||
List<String> paramsList = new ArrayList<>();
|
||||
Object result = null;
|
||||
try {
|
||||
int index = expression.lastIndexOf(".");
|
||||
className = expression.substring(0, index);
|
||||
System.out.println();
|
||||
String methodNameParams = expression.substring(index + 1);
|
||||
|
||||
String methodNameParamArrays[] = methodNameParams.split("\\(");
|
||||
methodName = methodNameParamArrays[0];
|
||||
String params = methodNameParamArrays[1];
|
||||
System.out.println();
|
||||
String realParams[] = params.split("\\)");
|
||||
|
||||
if (realParams.length > 0) {
|
||||
String realParam = realParams[0];
|
||||
String[] ps = realParam.split(",");
|
||||
for (String p : ps) {
|
||||
paramsList.add(p);
|
||||
}
|
||||
}
|
||||
Class clazz = Class.forName(className);
|
||||
Method methods[] = clazz.getDeclaredMethods();
|
||||
|
||||
for (Method method : methods) {
|
||||
if (method.getName().equals(methodName)
|
||||
&& method.getParameterTypes().length == paramsList.size()) {
|
||||
method.setAccessible(true);
|
||||
Object pas[] = new Object[paramsList.size()];
|
||||
if (method.getParameterTypes().length > 0) {
|
||||
for (int i = 0; i < paramsList.size(); i++) {
|
||||
String paramValue = paramsList.get(i);
|
||||
if (paramValue.startsWith("'") && paramValue.endsWith("'")) {
|
||||
paramValue = paramValue.substring(1, paramValue.length() - 1);
|
||||
}
|
||||
pas[i] = BeanUtil.parseBasicTypeWrapper(method.getParameterTypes()[i], paramValue);
|
||||
}
|
||||
}
|
||||
if (Modifier.isStatic(method.getModifiers())) {
|
||||
result = method.invoke(null, pas);
|
||||
} else {
|
||||
result = method.invoke(clazz.newInstance(), pas);
|
||||
}
|
||||
return (T) BeanUtil.parseBasicTypeWrapper(method.getReturnType(), result);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
log.info("ExpressionParse.getValue className:{},methodName:{},paramsList:{},result:{},expression:{}",
|
||||
className, methodName, paramsList, result, expression);
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
String a = "com.heyu.api.data.utils.SqlDateParse.addDaysReturnTimestamp('yyyy-MM-dd 23:59:59',-1)";
|
||||
Long b = getValue(a);
|
||||
System.out.println(b.toString());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package com.heyu.api.data.utils;
|
||||
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class SqlDateParse {
|
||||
|
||||
|
||||
public static String addDays(String formate, Integer days) {
|
||||
Date date = DateUtils.addDays(new Date(), days);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(formate);
|
||||
return sdf.format(date);
|
||||
}
|
||||
|
||||
|
||||
public static Long addDaysReturnTimestamp(Integer days) {
|
||||
Date date = DateUtils.addDays(new Date(), days);
|
||||
return date.getTime();
|
||||
}
|
||||
|
||||
|
||||
public static Long addDaysReturnTimestamp(String formate, Integer days) {
|
||||
try {
|
||||
Date date = DateUtils.addDays(new Date(), days);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(formate);
|
||||
String dateStr = sdf.format(date);
|
||||
Date date1 = DateUtils.myParseDate(dateStr);
|
||||
return date1.getTime();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.heyu.api.data.dao.vv.VvRequestLogDao">
|
||||
|
||||
</mapper>
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.heyu.api.data.dao.vv.VvRequstLogDao">
|
||||
|
||||
</mapper>
|
||||
|
||||
@ -95,7 +95,7 @@ public class MysqlMain_insert {
|
||||
List<TablesBean> list = new ArrayList<TablesBean>();
|
||||
|
||||
|
||||
list.add(new TablesBean("vv_comment"));
|
||||
list.add(new TablesBean("vv_request_log"));
|
||||
|
||||
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ public class MysqlMain_update {
|
||||
List<TablesBean> list = new ArrayList<TablesBean>();
|
||||
|
||||
|
||||
String a = "vv_package";
|
||||
String a = "vv_request_log";
|
||||
for (String s : a.split(",")) {
|
||||
list.add(new TablesBean(s));
|
||||
}
|
||||
|
||||
@ -22,11 +22,7 @@ public class FieldBean {
|
||||
this.comment = comment;
|
||||
this.javaCode = MysqlUtil.field2JavaCode(this.field);
|
||||
this.javaTypeFull = MysqlUtil.type2JavaTypeFull(this.type);
|
||||
if (field.endsWith("_id")) {
|
||||
this.javaType = "Long";
|
||||
} else {
|
||||
this.javaType = MysqlUtil.type2JavaType(this.type);
|
||||
}
|
||||
this.javaType = MysqlUtil.type2JavaType(this.type);
|
||||
}
|
||||
|
||||
public String getJavaCodeForGet() {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package com.test.xxx.mysql;
|
||||
|
||||
import com.heyu.api.data.dao.vv.VvTradeOrderLineDao;
|
||||
import com.heyu.api.data.dao.vv.VvRequestLogDao;
|
||||
import com.lz.mybatis.plugin.utils.TestParseUtils;
|
||||
import com.lz.mybatis.plugin.utils.t.Tuple2;
|
||||
import org.junit.Test;
|
||||
@ -11,7 +11,7 @@ SqlParseUtilsTest {
|
||||
@Test
|
||||
public void test1() {
|
||||
|
||||
Tuple2<Boolean, String> tuple = TestParseUtils.testSql(VvTradeOrderLineDao::selectByAppCondition).getData();
|
||||
Tuple2<Boolean, String> tuple = TestParseUtils.testSql(VvRequestLogDao::selectVvRequestLogByCreateTime).getData();
|
||||
|
||||
System.out.println(tuple.getSecond());
|
||||
|
||||
|
||||
@ -4,8 +4,7 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.heyu.api.common.LogAspect;
|
||||
import com.heyu.api.data.dto.BuyerDTO;
|
||||
import com.heyu.api.data.entity.vv.VvReverseOrderEntity;
|
||||
import com.heyu.api.data.service.bussiness.RedisSettingService;
|
||||
import com.heyu.api.data.dto.VVRequestLogDTO;
|
||||
import com.heyu.api.data.utils.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
@ -14,7 +13,9 @@ 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.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
@ -45,8 +46,13 @@ public class ZhenZhenLogAop {
|
||||
private RedisUtils redisUtils;
|
||||
|
||||
|
||||
@Value("${eb.config.rabbitQueue.urlStatisticQueue}")
|
||||
private String urlStatisticQueue;
|
||||
|
||||
|
||||
@Autowired
|
||||
private RedisSettingService redisSettingService;
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
|
||||
@Pointcut(value = "(" + " @within(org.springframework.web.bind.annotation.RestController) || " + " @within(org.springframework.stereotype.Controller)" + ")")
|
||||
public void pointcut() {
|
||||
@ -67,15 +73,19 @@ public class ZhenZhenLogAop {
|
||||
if (StringUtils.isBlank(traceId)) {
|
||||
traceId = OrderUtil.getUserPoolOrder("on");
|
||||
}
|
||||
Long buyerId = null;
|
||||
Long startTime = System.currentTimeMillis();
|
||||
LogAspect.threadLocalNo.set(traceId);
|
||||
LogAspect.threadLocalTime.set(System.currentTimeMillis());
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
uri = attributes.getRequest().getRequestURI();
|
||||
|
||||
String describe = null;
|
||||
// 如果不是小程序的url ,则直接过滤掉
|
||||
if (!uri.startsWith("/mm/") && !uri.startsWith("/app/")) {
|
||||
return point.proceed();
|
||||
}
|
||||
String token = "";
|
||||
try {
|
||||
args = recordRequestLog(point.getArgs(), uri);
|
||||
Signature sig = point.getSignature();
|
||||
@ -83,21 +93,23 @@ public class ZhenZhenLogAop {
|
||||
if (sig instanceof MethodSignature) {
|
||||
methodName = ((MethodSignature) sig).getMethod().getName();
|
||||
}
|
||||
|
||||
describe = AnnotationUtils.getAnnotationValueByMethod(method, "Describe", "value");
|
||||
|
||||
|
||||
Class clazz = point.getTarget().getClass();
|
||||
className = clazz.getName();
|
||||
|
||||
String token = attributes.getRequest().getHeader("token");
|
||||
|
||||
token = attributes.getRequest().getHeader("token");
|
||||
if (uri.startsWith("/app/")) {
|
||||
Object [] argArrs= point.getArgs();
|
||||
Object[] argArrs = point.getArgs();
|
||||
if (argArrs != null && argArrs.length > 0) {
|
||||
/***
|
||||
*
|
||||
*/
|
||||
Long buyerId = null;
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
if (StringUtils.isNotBlank(token)) {
|
||||
Object tokenValue = redisUtils.get(token);
|
||||
if(tokenValue !=null){
|
||||
if (tokenValue != null) {
|
||||
String tokenStr = tokenValue.toString();
|
||||
BuyerDTO buyerDTO = JSONObject.parseObject(tokenStr, BuyerDTO.class);
|
||||
buyerId = buyerDTO.getBuyerId();
|
||||
@ -105,9 +117,25 @@ public class ZhenZhenLogAop {
|
||||
}
|
||||
for (Object argArr : argArrs) {
|
||||
argArr.getClass().getDeclaredMethods();
|
||||
|
||||
List<Method> methods = new ArrayList<>();
|
||||
|
||||
getClassDeclaredMethods(argArr.getClass(),methods);
|
||||
getClassDeclaredMethods(argArr.getClass(), methods);
|
||||
|
||||
for (Method m : methods) {
|
||||
if (m.getName().startsWith("get")) {
|
||||
String mName = m.getName().substring(3);
|
||||
if ("buyerId".equalsIgnoreCase(mName)) {
|
||||
m.setAccessible(true);
|
||||
|
||||
Object getBuyerId = m.invoke(argArr);
|
||||
if (buyerId == null && getBuyerId != null) {
|
||||
buyerId = NumberUtil.objToLongDefault(getBuyerId, -1L);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (Method m : methods) {
|
||||
if (m.getName().startsWith("set")) {
|
||||
@ -121,6 +149,8 @@ public class ZhenZhenLogAop {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else if (uri.startsWith("/mm/")) {
|
||||
// 登录不拦截
|
||||
if (!"/mm/admin/login".equals(uri)) {
|
||||
@ -132,16 +162,16 @@ public class ZhenZhenLogAop {
|
||||
}
|
||||
result = point.proceed();
|
||||
|
||||
if(result instanceof R){
|
||||
if (result instanceof R) {
|
||||
R r = (R) result;
|
||||
Object object = r.getData();
|
||||
Object object = r.getData();
|
||||
convertImage(object);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("LogAop set error " + sb.toString(), e);
|
||||
} finally {
|
||||
printLog(result, args, ip, className, methodName, uri);
|
||||
printLog(result, args, ip, className, methodName, uri, token, traceId, startTime, buyerId, describe);
|
||||
LogAspect.threadLocalNo.remove();
|
||||
LogAspect.threadLocalTime.remove();
|
||||
}
|
||||
@ -149,22 +179,22 @@ public class ZhenZhenLogAop {
|
||||
}
|
||||
|
||||
|
||||
public static void convertImage(Object object){
|
||||
if(object == null){
|
||||
return ;
|
||||
public static void convertImage(Object object) {
|
||||
if (object == null) {
|
||||
return;
|
||||
}
|
||||
if(object instanceof List){
|
||||
if (object instanceof List) {
|
||||
List list = (List) object;
|
||||
for (Object o : list) {
|
||||
convertImage(o);
|
||||
}
|
||||
}else if (object instanceof Map) {
|
||||
} else if (object instanceof Map) {
|
||||
Map map = (Map) object;
|
||||
for (Object key : map.keySet()) {
|
||||
Object value = map.get(key);
|
||||
convertImage(value);
|
||||
}
|
||||
}else if (object.getClass().isArray()) {
|
||||
} else if (object.getClass().isArray()) {
|
||||
Object[] array = (Object[]) object;
|
||||
for (Object o : array) {
|
||||
convertImage(o);
|
||||
@ -187,8 +217,8 @@ public class ZhenZhenLogAop {
|
||||
// 如果是基本数据类型
|
||||
if (SanUtils.isBasicDataTypes(method.getReturnType())) {
|
||||
if (method.getReturnType() == String.class) {
|
||||
String str = (String)image;
|
||||
if (str!=null
|
||||
String str = (String) image;
|
||||
if (str != null
|
||||
&& str.startsWith("http://heyuimage.ihzhy.com")) {
|
||||
String setMethodName = "set" + method.getName().substring(3);
|
||||
Method setMethod = methodMap.get(setMethodName);
|
||||
@ -207,21 +237,11 @@ public class ZhenZhenLogAop {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
VvReverseOrderEntity vvReverseOrderEntity = new VvReverseOrderEntity();
|
||||
vvReverseOrderEntity.setStatus("http://heyuimage.ihzhy.com/48a458c49f5e0b9c74eeb163b577a49d.mp4");
|
||||
|
||||
convertImage(vvReverseOrderEntity);
|
||||
System.out.println(JSON.toJSONString(vvReverseOrderEntity));
|
||||
}
|
||||
|
||||
public static void getClassDeclaredMethods( Class entityType, List<Method> methods){
|
||||
if(entityType == Object.class){
|
||||
return ;
|
||||
public static void getClassDeclaredMethods(Class entityType, List<Method> methods) {
|
||||
if (entityType == Object.class) {
|
||||
return;
|
||||
}
|
||||
Method method [] = entityType.getDeclaredMethods();
|
||||
Method method[] = entityType.getDeclaredMethods();
|
||||
for (Method method1 : method) {
|
||||
methods.add(method1);
|
||||
}
|
||||
@ -229,17 +249,36 @@ public class ZhenZhenLogAop {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void printLog(Object result, String args, String ip, String className, String methodName,
|
||||
String preUri) {
|
||||
String preUri, String token, String traceId, Long startTime, Long buyerId,
|
||||
String describe
|
||||
) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append("ZhenZhenLogAop args:").append(args).append(BLANK_SPACE)
|
||||
.append("ip:").append(ip).append(BLANK_SPACE)
|
||||
.append("class:").append(className).append("#").append(methodName).append(BLANK_SPACE)
|
||||
.append("uri:").append(preUri).append(BLANK_SPACE)
|
||||
.append("result:").append(JSON.toJSONString(result));
|
||||
log.info(sb.toString());
|
||||
|
||||
|
||||
if (preUri.startsWith("/app/")) {
|
||||
rabbitTemplate.convertAndSend(urlStatisticQueue,
|
||||
JSON.toJSONString(new VVRequestLogDTO(
|
||||
token, // token
|
||||
null,
|
||||
traceId,
|
||||
System.currentTimeMillis(), // 当前请求的接口
|
||||
preUri, //日志编号
|
||||
System.currentTimeMillis() - startTime,
|
||||
args,
|
||||
buyerId,
|
||||
describe
|
||||
)
|
||||
));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private String recordRequestLog(Object[] argArrs, String uri) {
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
package com.heyu.api.listener;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.heyu.api.data.dao.vv.VvRequestLogDao;
|
||||
import com.heyu.api.data.entity.vv.VvRequestLogEntity;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.amqp.support.AmqpHeaders;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.messaging.handler.annotation.Header;
|
||||
import org.springframework.messaging.handler.annotation.Payload;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class VVUrlQueueSimpleRabbitListener {
|
||||
|
||||
@Value("${eb.config.rabbitQueue.urlStatisticQueue}")
|
||||
private String urlStatisticQueue;
|
||||
|
||||
|
||||
@Autowired
|
||||
private VvRequestLogDao vvRequestLogDao;
|
||||
|
||||
|
||||
@RabbitHandler
|
||||
@RabbitListener(queues = "#{urlStatisticQueue.name}", containerFactory = "accountAmountQueueSimpleRabbitListenerContainerFactory")
|
||||
public void consumeMessage(@Payload String message, @Header(AmqpHeaders.DELIVERY_TAG) long delivertTag, Channel channel) {
|
||||
try {
|
||||
VvRequestLogEntity vvRequestLogEntity = JSONObject.parseObject(message, VvRequestLogEntity.class);
|
||||
vvRequestLogDao.insert(vvRequestLogEntity);
|
||||
} catch (Exception e) {
|
||||
log.error("urlStatisticQueue handle", e);
|
||||
} finally {
|
||||
try {
|
||||
log.info("urlStatisticQueue消息{},消息确认完成", message);
|
||||
channel.basicAck(delivertTag, true);
|
||||
} catch (IOException e) {
|
||||
log.error("urlStatisticQueue消息确认异常", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -57,6 +57,7 @@ eb:
|
||||
accountAmountQueue: ACCOUNT_AMOUNT_QUEUE_NAME
|
||||
accountLogName: ACCOUNT_LOG_NAME
|
||||
postCodeData: post_code_data
|
||||
urlStatisticQueue: URL_STATISTIC_QUEUE
|
||||
|
||||
|
||||
tencent:
|
||||
|
||||
@ -2,12 +2,15 @@ package com.api.test;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.heyu.api.data.entity.vv.VvResourceEntity;
|
||||
import org.apache.commons.lang3.text.StrSubstitutor;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@ -26,6 +29,29 @@ public class test2 {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testxx(){
|
||||
|
||||
Map valuesMap = new HashMap();
|
||||
valuesMap.put("yesterDay", "2025-10-18");
|
||||
String templateString = "\n" +
|
||||
"select x,name,y from (\n" +
|
||||
"select \n" +
|
||||
"date_format(create_time, '%Y-%m-%d') as x ,description as name,count(*) as y \n" +
|
||||
"from vv_request_log where DATE_FORMAT(create_time, '%Y-%m-%d') = DATE_FORMAT('${yesterDay}', '%Y-%m-%d') group by description\n" +
|
||||
") as all_data order by y desc limit 100 \n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"\n";
|
||||
|
||||
StrSubstitutor sub = new StrSubstitutor(valuesMap);
|
||||
String resolvedString = sub.replace(templateString);
|
||||
|
||||
|
||||
System.out.println(resolvedString);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test1() throws Exception{
|
||||
VvResourceEntity vvResourceEntity = new VvResourceEntity();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user