整理依赖包

This commit is contained in:
easonzhu 2025-02-20 11:09:27 +08:00
parent a60a467694
commit 85b31b22f4
11 changed files with 147 additions and 74 deletions

13
pom.xml
View File

@ -43,6 +43,7 @@
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.31</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
@ -76,9 +77,9 @@
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>ma.glasnost.orika</groupId>
<artifactId>orika-core</artifactId>
<version>1.5.4</version>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.1.1-jre</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
@ -136,12 +137,6 @@
<version>2.7.4</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.66</version>
</dependency>
<!-- SLF4J API: 用于记录日志 -->
<dependency>
<groupId>org.slf4j</groupId>

View File

@ -1,24 +0,0 @@
package com.upchina.common.config;
import ma.glasnost.orika.MapperFacade;
import ma.glasnost.orika.MapperFactory;
import ma.glasnost.orika.impl.DefaultMapperFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class OrikaConfig {
@Bean
public MapperFactory mapperFactory() {
return new DefaultMapperFactory.Builder().build();
}
// https://mp.weixin.qq.com/s?__biz=MzUxMzQ0Njc1NQ==&mid=2247493097&idx=2&sn=b5b64d84b474ddee51e4ffa53159db25&chksm=f957a3e5ce202af38cee3169bf26895693c53e2efcb129b66acad37cef9a0b2505e4ed500ca4&mpshare=1&scene=1&srcid=0625QYwhk4AMpon2SOzyWDap&sharer_sharetime=1625023400860&sharer_shareid=daeff53cf02c0a24905e98788b17a15c&version=3.1.11.3009&platform=win#rd
// https://www.cnblogs.com/liang-chen-fly/p/14475283.html
@Bean
public MapperFacade mapperFacade() {
return mapperFactory().getMapperFacade();
}
}

View File

@ -1,10 +1,12 @@
package com.upchina.common.query;
import com.upchina.common.entity.CommentBlack;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
public class AddCommentBlackQuery {
@ -46,11 +48,24 @@ public class AddCommentBlackQuery {
@Max(3)
private Integer scope;
public CommentBlack toPO() {
CommentBlack commentBlack = new CommentBlack();
commentBlack.setProductId(productId);
commentBlack.setProductType(productType);
commentBlack.setPhone(userPhone);
commentBlack.setUserName(userName);
commentBlack.setContent(content);
commentBlack.setReason(reason);
commentBlack.setAttachment(attachment);
commentBlack.setType(type);
commentBlack.setScope(scope);
return commentBlack;
}
public String getUserPhone() {
return userPhone;
}
public void setUserPhone(String userPhone) {
this.userPhone = userPhone;
}

View File

@ -1,5 +1,10 @@
package com.upchina.common.query;
import com.upchina.advisor.entity.AdvisorBasic;
import com.upchina.common.constant.CommentUserType;
import com.upchina.common.entity.Comment;
import com.upchina.common.vo.BackendUserVO;
import com.upchina.common.vo.FrontUserVO;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.Max;
@ -30,6 +35,38 @@ public class SaveCommentQuery {
@Max(9)
private Integer source = 0;
public Comment toPO(FrontUserVO frontUserVO) {
Comment comment = new Comment();
comment.setUserId(frontUserVO.getUserId());
comment.setUserName(frontUserVO.getUserName());
comment.setUserImgUrl(frontUserVO.getImgUrl());
comment.setProductId(this.productId);
comment.setProductType(this.productType);
comment.setCommentContent(this.commentContent);
comment.setSource(this.source);
return comment;
}
public Comment toPO(BackendUserVO backendUserVO, AdvisorBasic advisor) {
Comment comment = new Comment();
comment.setProductId(this.productId);
comment.setProductType(this.productType);
comment.setCommentContent(this.commentContent);
comment.setSource(this.source);
comment.setUserId(backendUserVO.getUserId().toString());
comment.setUserOrgNo(backendUserVO.getDeptId());
if (advisor != null) {
comment.setAdvisorId(advisor.getId());
comment.setUserType(CommentUserType.ADVISOR.getValue());
comment.setUserImgUrl(advisor.getAvatar());
comment.setUserName(advisor.getShowName());
} else {
comment.setUserType(CommentUserType.ASSISTANT.getValue());
comment.setUserName(backendUserVO.getUserName());
}
return comment;
}
public Integer getProductId() {
return productId;
}
@ -61,4 +98,5 @@ public class SaveCommentQuery {
public void setSource(Integer source) {
this.source = source;
}
}

View File

@ -28,7 +28,6 @@ import com.upchina.rbac.entity.Dept;
import com.upchina.rbac.entity.UserDept;
import com.upchina.rbac.service.DeptService;
import com.upchina.rbac.service.UserService;
import ma.glasnost.orika.MapperFacade;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@ -46,9 +45,6 @@ import static com.upchina.common.config.cache.CacheKey.CommentBlackKey.ALL_BLACK
@Service
public class CommentBlackService {
@Resource
private MapperFacade mapperFacade;
@Resource
private CommentBlackMapper commentBlackMapper;
@ -84,9 +80,7 @@ public class CommentBlackService {
if (validSize > 0) {
throw new BizException(ResponseStatus.REPETITIVE_ERROR);
}
CommentBlack commentBlack = mapperFacade.map(query, CommentBlack.class);
commentBlack.setUserName(query.getUserName());
commentBlack.setPhone(userPhone);
CommentBlack commentBlack = query.toPO();
commentBlack.setStartTime(now);
commentBlack.setStatus(CommentBlackStatus.EFFECT.value);
commentBlack.setOperatorId(backendUserVO.getUserId());
@ -181,7 +175,7 @@ public class CommentBlackService {
Table<Integer, Integer, MergeProductInfoVO> productTable = mergeProductService.queryMergeProductInfo(baseProductQueryList);
Map<Integer, UserDept> userMap = userService.getUserMap();
Map<String, Dept> deptMap = deptService.getDeptMap();
List<CommentBlackVO> voList = list.stream().map(commentBlack -> mapperFacade.map(commentBlack, CommentBlackVO.class)).collect(Collectors.toList());
List<CommentBlackVO> voList = list.stream().map(CommentBlackVO::new).collect(Collectors.toList());
for (CommentBlackVO commentBlackVO : voList) {
// 查询产品信息
if (commentBlackVO.getProductId() != null && commentBlackVO.getProductType() != null) {

View File

@ -28,7 +28,6 @@ import com.upchina.rbac.entity.Dept;
import com.upchina.rbac.entity.UserDept;
import com.upchina.rbac.service.DeptService;
import com.upchina.rbac.service.UserService;
import ma.glasnost.orika.MapperFacade;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@ -49,9 +48,6 @@ public class CommentService {
@Resource
private CommentMapper commentMapper;
@Resource
private MapperFacade mapperFacade;
@Resource
private CommentBlackService commentBlackService;
@ -86,11 +82,7 @@ public class CommentService {
if (commentBlackService.checkIsBlack(frontUserVO.getUserId(), query.getProductId(), query.getProductType())) {
throw new BizException(ResponseStatus.COMMENT_BLACK_USER_ERROR);
}
Comment comment = new Comment();
mapperFacade.map(frontUserVO, comment);
mapperFacade.map(query, comment);
//comment.setUserOrgNo(frontUserVO.getOrgNo());
comment.setUserImgUrl(frontUserVO.getImgUrl());
Comment comment = query.toPO(frontUserVO);
comment.setUserType(CommentUserType.CUSTOMER.getValue());
comment.setIsOpen(IsOrNot.NOT.value);
comment.setCommentTime(LocalDateTime.now());
@ -117,22 +109,8 @@ public class CommentService {
public CommentVO saveCommentAdmin(SaveCommentQuery query, BackendUserVO backendUserVO) {
// 敏感词判断
sensitiveWordService.check(query.getCommentContent());
Comment comment = new Comment();
comment.setUserId(backendUserVO.getUserId().toString());
comment.setUserOrgNo(backendUserVO.getDeptId());
if (backendUserVO.getAdvisorId() != null) {
comment.setAdvisorId(backendUserVO.getAdvisorId());
comment.setUserType(CommentUserType.ADVISOR.getValue());
AdvisorBasic advisor = advisorInfoService.getAdvisorMap().get(backendUserVO.getAdvisorId());
if (advisor != null) {
comment.setUserImgUrl(advisor.getAvatar());
comment.setUserName(advisor.getShowName());
}
} else {
comment.setUserType(CommentUserType.ASSISTANT.getValue());
comment.setUserName(backendUserVO.getUserName());
}
mapperFacade.map(query, comment);
AdvisorBasic advisor = backendUserVO.getAdvisorId() == null ? null : advisorInfoService.getAdvisorMap().get(backendUserVO.getAdvisorId());
Comment comment = query.toPO(backendUserVO, advisor);
comment.setIsOpen(IsOrNot.IS.value);
comment.setCommentTime(LocalDateTime.now());
comment.setUpdateTime(LocalDateTime.now());
@ -202,7 +180,7 @@ public class CommentService {
Map<String, Dept> deptMap = deptService.getDeptMap();
Map<Integer, AdvisorBasic> userIdAdvisorMap = advisorInfoService.getUserIdAdvisorMap();
List<CommentVO> result = list.stream().map(comment -> {
CommentVO commentVO = mapperFacade.map(comment, CommentVO.class);
CommentVO commentVO = new CommentVO(comment);
commentVO.setTaboo(commentBlackService.checkIsBlack(commentVO.getPhone(), commentVO.getProductId(), commentVO.getProductType()) ? IsOrNot.IS.value : IsOrNot.NOT.value);
if (commentVO.getReplyUserId() != null) {
UserDept user = userMap.get(commentVO.getReplyUserId());
@ -463,7 +441,7 @@ public class CommentService {
Map<Integer, AdvisorBasic> userIdAdvisorMap = advisorInfoService.getUserIdAdvisorMap();
return cacheService.get(cacheMap, APP_COMMENT_OBJ + id, () -> {
Comment comment = commentMapper.selectById(id);
CommentAppVO commentAppVO = mapperFacade.map(comment, CommentAppVO.class);
CommentAppVO commentAppVO = new CommentAppVO(comment);
// String phone = commentAppVO.getPhone().substring(0, 3) + "0000" + commentAppVO.getPhone().substring(7);
// commentAppVO.setPhone(phone);
if (commentAppVO.getReplyUserId() != null) {

View File

@ -12,7 +12,6 @@ import com.upchina.common.vo.OperationLogVO;
import com.upchina.rbac.service.UserService;
import com.upchina.rbac.vo.RoleBasicVO;
import com.upchina.rbac.vo.UserAdminVO;
import ma.glasnost.orika.MapperFacade;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@ -32,9 +31,6 @@ public class OperationLogService {
@Resource
private OperationLogMapper operationLogMapper;
@Resource
private MapperFacade mapperFacade;
@Transactional(rollbackFor = Exception.class)
public void saveOperationLog(OperationLog operationLog) {
UserAdminVO userAdminVO = getUserAdminVO(operationLog);
@ -60,7 +56,7 @@ public class OperationLogService {
wrapper.orderByDesc("create_time");
Page<OperationLog> page = operationLogMapper.selectPage(query.toPage(), wrapper);
page.getRecords().forEach(this::getUserAdminVO);
List<OperationLogVO> result = mapperFacade.mapAsList(page.getRecords(), OperationLogVO.class);
List<OperationLogVO> result = page.getRecords().stream().map(OperationLogVO::new).collect(Collectors.toList());
return CommonResult.success(new Pager<>(result, page.getTotal()));
}

View File

@ -1,5 +1,6 @@
package com.upchina.common.vo;
import com.upchina.common.entity.Comment;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
@ -57,6 +58,24 @@ public class CommentAppVO implements Serializable {
@ApiModelProperty("置顶权重")
private Integer weight;
public CommentAppVO() {}
public CommentAppVO(Comment comment) {
this.id = comment.getId();
this.userName = comment.getUserName();
this.phone = comment.getPhone();
this.userImgUrl = comment.getUserImgUrl();
this.userType = comment.getUserType();
this.productId = comment.getProductId();
this.productType = comment.getProductType();
this.commentContent = comment.getCommentContent();
this.commentTime = comment.getCommentTime();
this.replyContent = comment.getReplyContent();
this.replyTime = comment.getReplyTime();
this.replyUserId = comment.getReplyUserId();
this.weight = comment.getWeight();
}
public Integer getId() {
return id;
}

View File

@ -1,5 +1,6 @@
package com.upchina.common.vo;
import com.upchina.common.entity.CommentBlack;
import io.swagger.annotations.ApiModelProperty;
import java.time.LocalDateTime;
@ -57,6 +58,25 @@ public class CommentBlackVO extends CommonPhoneVO {
@ApiModelProperty("范围类型 1产品 2产品类型 3全局")
private Integer scope;
public CommentBlackVO() {
}
public CommentBlackVO(CommentBlack commentBlack) {
this.id = commentBlack.getId();
this.userName = commentBlack.getUserName();
this.productId = commentBlack.getProductId();
this.productType = commentBlack.getProductType();
this.content = commentBlack.getContent();
this.reason = commentBlack.getReason();
this.attachment = commentBlack.getAttachment();
this.operatorId = commentBlack.getOperatorId();
this.startTime = commentBlack.getStartTime();
this.endTime = commentBlack.getEndTime();
this.status = commentBlack.getStatus();
this.type = commentBlack.getType();
this.scope = commentBlack.getScope();
}
public String getContent() {
return content;
}

View File

@ -1,5 +1,6 @@
package com.upchina.common.vo;
import com.upchina.common.entity.Comment;
import io.swagger.annotations.ApiModelProperty;
import java.time.LocalDateTime;
@ -87,6 +88,32 @@ public class CommentVO extends CommonPhoneVO {
@ApiModelProperty("是否禁言1是 2否")
private Integer taboo;
public CommentVO() {
}
public CommentVO(Comment comment) {
this.id = comment.getId();
this.userId = comment.getUserId();
this.userName = comment.getUserName();
this.userOrgNo = comment.getUserOrgNo();
this.userImgUrl = comment.getUserImgUrl();
this.userType = comment.getUserType();
this.productId = comment.getProductId();
this.productType = comment.getProductType();
this.advisorId = comment.getAdvisorId();
this.commentContent = comment.getCommentContent();
this.commentTime = comment.getCommentTime();
this.isReply = comment.getIsReply();
this.replyContent = comment.getReplyContent();
this.replyTime = comment.getReplyTime();
this.replyUserId = comment.getReplyUserId();
this.source = comment.getSource();
this.isOpen = comment.getIsOpen();
this.isTop = comment.getIsTop();
this.weight = comment.getWeight();
this.isDelete = comment.getIsDelete();
}
public Integer getId() {
return id;
}

View File

@ -1,5 +1,6 @@
package com.upchina.common.vo;
import com.upchina.common.entity.OperationLog;
import io.swagger.annotations.ApiModelProperty;
import java.time.LocalDateTime;
@ -30,6 +31,20 @@ public class OperationLogVO {
@ApiModelProperty("备注")
private String remark;
public OperationLogVO() {
}
public OperationLogVO(OperationLog operationLog) {
this.id = operationLog.getId();
this.operateType = operationLog.getOperateType();
this.operatorId = operationLog.getOperatorId();
this.operatorName = operationLog.getOperatorName();
this.operatorRole = operationLog.getOperatorRole();
this.staffNo = operationLog.getStaffNo();
this.createTime = operationLog.getCreateTime();
this.remark = operationLog.getRemark();
}
public Integer getId() {
return id;
}