diff --git a/pom.xml b/pom.xml
index 5a6172d..1631b3d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -43,6 +43,7 @@
org.freemarker
freemarker
2.3.31
+ provided
com.baomidou
@@ -76,9 +77,9 @@
3.0.3
- ma.glasnost.orika
- orika-core
- 1.5.4
+ com.google.guava
+ guava
+ 30.1.1-jre
com.auth0
@@ -136,12 +137,6 @@
2.7.4
-
- org.bouncycastle
- bcprov-jdk15on
- 1.66
-
-
org.slf4j
diff --git a/src/main/java/com/upchina/common/config/OrikaConfig.java b/src/main/java/com/upchina/common/config/OrikaConfig.java
deleted file mode 100644
index 3e416af..0000000
--- a/src/main/java/com/upchina/common/config/OrikaConfig.java
+++ /dev/null
@@ -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();
- }
-
-}
diff --git a/src/main/java/com/upchina/common/query/AddCommentBlackQuery.java b/src/main/java/com/upchina/common/query/AddCommentBlackQuery.java
index 217b7bc..463f73f 100644
--- a/src/main/java/com/upchina/common/query/AddCommentBlackQuery.java
+++ b/src/main/java/com/upchina/common/query/AddCommentBlackQuery.java
@@ -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;
}
diff --git a/src/main/java/com/upchina/common/query/SaveCommentQuery.java b/src/main/java/com/upchina/common/query/SaveCommentQuery.java
index d1379eb..073a55d 100644
--- a/src/main/java/com/upchina/common/query/SaveCommentQuery.java
+++ b/src/main/java/com/upchina/common/query/SaveCommentQuery.java
@@ -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;
}
+
}
diff --git a/src/main/java/com/upchina/common/service/CommentBlackService.java b/src/main/java/com/upchina/common/service/CommentBlackService.java
index 1ff59dd..c3bf48e 100644
--- a/src/main/java/com/upchina/common/service/CommentBlackService.java
+++ b/src/main/java/com/upchina/common/service/CommentBlackService.java
@@ -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 productTable = mergeProductService.queryMergeProductInfo(baseProductQueryList);
Map userMap = userService.getUserMap();
Map deptMap = deptService.getDeptMap();
- List voList = list.stream().map(commentBlack -> mapperFacade.map(commentBlack, CommentBlackVO.class)).collect(Collectors.toList());
+ List voList = list.stream().map(CommentBlackVO::new).collect(Collectors.toList());
for (CommentBlackVO commentBlackVO : voList) {
// 查询产品信息
if (commentBlackVO.getProductId() != null && commentBlackVO.getProductType() != null) {
diff --git a/src/main/java/com/upchina/common/service/CommentService.java b/src/main/java/com/upchina/common/service/CommentService.java
index 491d5fe..ff3d751 100644
--- a/src/main/java/com/upchina/common/service/CommentService.java
+++ b/src/main/java/com/upchina/common/service/CommentService.java
@@ -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 deptMap = deptService.getDeptMap();
Map userIdAdvisorMap = advisorInfoService.getUserIdAdvisorMap();
List 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 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) {
diff --git a/src/main/java/com/upchina/common/service/OperationLogService.java b/src/main/java/com/upchina/common/service/OperationLogService.java
index 271a167..3fa176a 100644
--- a/src/main/java/com/upchina/common/service/OperationLogService.java
+++ b/src/main/java/com/upchina/common/service/OperationLogService.java
@@ -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 page = operationLogMapper.selectPage(query.toPage(), wrapper);
page.getRecords().forEach(this::getUserAdminVO);
- List result = mapperFacade.mapAsList(page.getRecords(), OperationLogVO.class);
+ List result = page.getRecords().stream().map(OperationLogVO::new).collect(Collectors.toList());
return CommonResult.success(new Pager<>(result, page.getTotal()));
}
diff --git a/src/main/java/com/upchina/common/vo/CommentAppVO.java b/src/main/java/com/upchina/common/vo/CommentAppVO.java
index 3d9e4e2..2f9654b 100644
--- a/src/main/java/com/upchina/common/vo/CommentAppVO.java
+++ b/src/main/java/com/upchina/common/vo/CommentAppVO.java
@@ -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;
}
diff --git a/src/main/java/com/upchina/common/vo/CommentBlackVO.java b/src/main/java/com/upchina/common/vo/CommentBlackVO.java
index 11aea47..e466aeb 100644
--- a/src/main/java/com/upchina/common/vo/CommentBlackVO.java
+++ b/src/main/java/com/upchina/common/vo/CommentBlackVO.java
@@ -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;
}
diff --git a/src/main/java/com/upchina/common/vo/CommentVO.java b/src/main/java/com/upchina/common/vo/CommentVO.java
index 2a0f526..1dbfc23 100644
--- a/src/main/java/com/upchina/common/vo/CommentVO.java
+++ b/src/main/java/com/upchina/common/vo/CommentVO.java
@@ -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;
}
diff --git a/src/main/java/com/upchina/common/vo/OperationLogVO.java b/src/main/java/com/upchina/common/vo/OperationLogVO.java
index 8b93582..0cdd6df 100644
--- a/src/main/java/com/upchina/common/vo/OperationLogVO.java
+++ b/src/main/java/com/upchina/common/vo/OperationLogVO.java
@@ -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;
}