Commit c65aff9e authored by shiyu's avatar shiyu

用户浏览记录

parent 72be54da
package com.wwdz.ch.db.dao;
import com.wwdz.ch.db.domain.BrowseLog;
public interface BrowseLogDao {
boolean insert(BrowseLog browseLog);
}
package com.wwdz.ch.db.domain;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import com.xxdxxs.entity.Entity;
import lombok.Data;
/**
* @author shiyu
* @date 2024/06/07
*/
@Data
public class BrowseLog implements Entity {
private Long id;
/**
* 浏览描述
*/
private String desc;
/**
* 方法名
*/
private String methodName;
/**
* 用户id
*/
private Long userId;
/**
* 浏览时间
*/
private Date createTime;
/**
* 浏览对象id
*/
private String targetId;
/**
* 类型
*/
private Integer type;
private static final long serialVersionUID = 1L;
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", desc=").append(desc);
sb.append(", methodName=").append(methodName);
sb.append(", userId=").append(userId);
sb.append(", createTime=").append(createTime);
sb.append(", targetId=").append(targetId);
sb.append(", type=").append(type);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
BrowseLog other = (BrowseLog) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getDesc() == null ? other.getDesc() == null : this.getDesc().equals(other.getDesc()))
&& (this.getMethodName() == null ? other.getMethodName() == null : this.getMethodName().equals(other.getMethodName()))
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getTargetId() == null ? other.getTargetId() == null : this.getTargetId().equals(other.getTargetId()))
&& (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getDesc() == null) ? 0 : getDesc().hashCode());
result = prime * result + ((getMethodName() == null) ? 0 : getMethodName().hashCode());
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getTargetId() == null) ? 0 : getTargetId().hashCode());
result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
return result;
}
/**
* This enum was generated by MyBatis Generator.
* This enum corresponds to the database table browse_log
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public enum Column {
id("id", "id", "BIGINT", false),
desc("desc", "desc", "VARCHAR", true),
methodName("method_name", "methodName", "VARCHAR", false),
userId("user_id", "userId", "BIGINT", false),
createTime("create_time", "createTime", "TIMESTAMP", false),
targetId("target_id", "targetId", "VARCHAR", false),
type("type", "type", "INTEGER", true);
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table browse_log
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private static final String BEGINNING_DELIMITER = "`";
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table browse_log
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private static final String ENDING_DELIMITER = "`";
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table browse_log
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String column;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table browse_log
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final boolean isColumnNameDelimited;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table browse_log
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String javaProperty;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table browse_log
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String jdbcType;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table browse_log
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String value() {
return this.column;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table browse_log
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getValue() {
return this.column;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table browse_log
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getJavaProperty() {
return this.javaProperty;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table browse_log
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getJdbcType() {
return this.jdbcType;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table browse_log
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
Column(String column, String javaProperty, String jdbcType, boolean isColumnNameDelimited) {
this.column = column;
this.javaProperty = javaProperty;
this.jdbcType = jdbcType;
this.isColumnNameDelimited = isColumnNameDelimited;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table browse_log
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String desc() {
return this.getEscapedColumnName() + " DESC";
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table browse_log
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String asc() {
return this.getEscapedColumnName() + " ASC";
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table browse_log
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public static Column[] excludes(Column ... excludes) {
ArrayList<Column> columns = new ArrayList<>(Arrays.asList(Column.values()));
if (excludes != null && excludes.length > 0) {
columns.removeAll(new ArrayList<>(Arrays.asList(excludes)));
}
return columns.toArray(new Column[]{});
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table browse_log
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getEscapedColumnName() {
if (this.isColumnNameDelimited) {
return new StringBuilder().append(BEGINNING_DELIMITER).append(this.column).append(ENDING_DELIMITER).toString();
} else {
return this.column;
}
}
}
}
\ No newline at end of file
package com.wwdz.ch.db.impl;
import com.wwdz.ch.db.dao.BrowseLogDao;
import com.wwdz.ch.db.domain.BrowseLog;
import com.wwdz.ch.db.mapper.BrowseLogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
@Repository
public class BrowseLogDaoImpl implements BrowseLogDao {
@Autowired
BrowseLogMapper browseLogMapper;
@Override
public boolean insert(BrowseLog browseLog) {
return browseLogMapper.insert(browseLog) > 0;
}
}
package com.wwdz.ch.db.mapper;
import com.wwdz.ch.db.domain.BrowseLog;
import com.wwdz.ch.db.domain.BrowseLogExample;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface BrowseLogMapper {
long countByExample(BrowseLogExample example);
int deleteByExample(BrowseLogExample example);
int deleteByPrimaryKey(Long id);
int insert(BrowseLog record);
int insertSelective(BrowseLog record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table browse_log
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
BrowseLog selectOneByExample(BrowseLogExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table browse_log
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
BrowseLog selectOneByExampleSelective(@Param("example") BrowseLogExample example, @Param("selective") BrowseLog.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table browse_log
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
List<BrowseLog> selectByExampleSelective(@Param("example") BrowseLogExample example, @Param("selective") BrowseLog.Column ... selective);
List<BrowseLog> selectByExample(BrowseLogExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table browse_log
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
BrowseLog selectByPrimaryKeySelective(@Param("id") Long id, @Param("selective") BrowseLog.Column ... selective);
BrowseLog selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") BrowseLog record, @Param("example") BrowseLogExample example);
int updateByExample(@Param("record") BrowseLog record, @Param("example") BrowseLogExample example);
int updateByPrimaryKeySelective(BrowseLog record);
int updateByPrimaryKey(BrowseLog record);
}
\ No newline at end of file
......@@ -63,16 +63,16 @@
<!--生成Model类存放位置-->
<javaModelGenerator targetPackage="com.wwdz.ch.db.domain.distribution" targetProject="ch-dao/src/main/java">
<javaModelGenerator targetPackage="com.wwdz.ch.db.domain" targetProject="ch-dao/src/main/java">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<sqlMapGenerator targetPackage="com.wwdz.ch.db.mapper.distribution" targetProject="ch-dao/src/main/resources"/>
<javaClientGenerator type="XMLMAPPER" targetPackage="com.wwdz.ch.db.mapper.distribution"
<sqlMapGenerator targetPackage="com.wwdz.ch.db.mapper" targetProject="ch-dao/src/main/resources"/>
<javaClientGenerator type="XMLMAPPER" targetPackage="com.wwdz.ch.db.mapper"
targetProject="ch-dao/src/main/java"/>
<table tableName="special_performance" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<table tableName="user" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<generatedKey column="id" sqlStatement="Mysql" identity="true" />
</table>
......
......@@ -115,6 +115,12 @@
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.9.6</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.13</version>
</dependency>
</dependencies>
<build>
......
......@@ -4,6 +4,7 @@ import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
......@@ -19,6 +20,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableTransactionManagement
@EnableScheduling
@EnableDubbo(scanBasePackages = {"com.wwdz.ch.wx"})
@EnableAspectJAutoProxy
public class Application {
// 小程序后台服务启动类
public static void main(String[] args) {
......
package com.wwdz.ch.wx.aspect;
import com.wwdz.ch.core.consts.DistributionEnum;
import java.lang.annotation.*;
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface AddBrowseLog {
/**
* 操作具体某个功能的描述
* @return
*/
String desc() default "";
DistributionEnum.DistributionTypeEnum type();
}
package com.wwdz.ch.wx.aspect;
import com.wwdz.ch.db.dao.BrowseLogDao;
import com.wwdz.ch.db.domain.BrowseLog;
import com.xxdxxs.utils.EntityMapper;
import com.xxdxxs.utils.JsonUtils;
import com.xxdxxs.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.Map;
@Component
@Aspect
@Slf4j
public class BrowseLogAop {
private static final Logger logger = LoggerFactory.getLogger(BrowseLogAop.class);
@Autowired
BrowseLogDao browseLogDao;
@Pointcut("@annotation(com.wwdz.ch.wx.aspect.AddBrowseLog)")
public void pointcut() {
}
/**
* 返回通知
*
* @param joinPoint
* @retur
*/
@AfterReturning("pointcut()")
public void afterRuturn(JoinPoint joinPoint) {
try {
//执行目标方法
Object[] args = joinPoint.getArgs();
logger.info("入参为 : {}", JsonUtils.from(args[0]));
Map<String, Object> paramMap = JsonUtils.toMap(JsonUtils.from(args[0]));
long userId = Long.valueOf(String.valueOf(paramMap.get("userId")));
String id = String.valueOf(paramMap.get("id"));
String targetId = null;
if (StringUtils.hasLength(id)) {
targetId = id;
} else {
targetId = String.valueOf(paramMap.get("shareRecordId"));
}
//目标方法执行完成后,获取目标类、目标方法上的业务日志注解上的功能名称和功能描述
Object target = joinPoint.getTarget();
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
String methodName = signature.getMethod().getName();
AddBrowseLog browseLogAnno = signature.getMethod().getAnnotation(AddBrowseLog.class);
String logDesc = browseLogAnno.desc();
BrowseLog browseLog = new BrowseLog();
browseLog.setDesc(logDesc);
browseLog.setMethodName(methodName);
browseLog.setUserId(userId);
browseLog.setCreateTime(new Date());
browseLog.setTargetId(targetId);
browseLog.setType(browseLogAnno.type().getCode());
browseLogDao.insert(browseLog);
logger.info("===================== BrowseLogAop 执行完成 =====================");
} catch (Exception e) {
logger.error("保存用户浏览记录error : {}", e);
}
}
}
......@@ -49,7 +49,7 @@ public class WebMvcConfiguration implements WebMvcConfigurer {
,"/wx/specialPerformance/**"
, "/wx/supplierItem/**", "/wx/shareRecord/**", "/wx/distributionOrder/**", "/wx/selfPage/**", "/wx/auctionRecord/**",
"/wx/shareRecord/**","/wx/collectionBook/**", "/wx/collectedRecord/**", "/wx/collectionItemsRelation/**","/wx/collectionShareRecord/**"
,"/wx/logistics/**","/wx/follow/**"
,"/wx/logistics/**","/wx/follow/**","/wx/user/findById","/wx/user/updateQrCode"
// , "/wx/supplierItem/**", "/wx/shareRecord/**", "/wx/distributionOrder/**", "/wx/selfPage/**", "/wx/auctionRecord/**"
/* "/wx/officialAccount/**",
......
......@@ -625,14 +625,14 @@ public class UserServiceImpl implements UserService {
// 缓存用户信息
redisUtil.set(key, user, 2 * 60 * 60);
}
try {
/* try {
CloudServerResponse<CommunityUserAttributeDO> response = communityAttributeReadService.getCommunityUserAttributeByUserId(userId);
if (response.isSuccess()) {
user.setProfile(response.getResult() == null ? null : response.getResult().getSignature());
}
} catch (Exception e) {
logger.error(">>>>>>>>> 调用社区用户查询接口获取用户签名出错:{}", e);
}
}*/
logger.info("【请求结束】查询用户信息成功");
return Result.success(user);
......
......@@ -21,6 +21,7 @@ import com.wwdz.ch.db.domain.distribution.*;
import com.wwdz.ch.db.dto.request.FollowFansRecordRequestDto;
import com.wwdz.ch.db.dto.request.distribution.*;
import com.wwdz.ch.core.entity.SupplierItemVo;
import com.wwdz.ch.wx.aspect.AddBrowseLog;
import com.wwdz.ch.wx.constant.CollectionBookConstants;
import com.wwdz.ch.wx.entity.vo.distribution.AuctionDetailVo;
import com.wwdz.ch.wx.entity.vo.distribution.AuctionRecordRowVo;
......@@ -178,6 +179,9 @@ public class SupplierItemServiceImpl implements SupplierItemService {
return Result.failed();
}
@AddBrowseLog(desc = "查询平台商品详情", type = DistributionEnum.DistributionTypeEnum.FIXED_PRICE)
@Override
public Result findDetail(SupplierItemRequestDto dto) {
try {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment