提交 e4a175f4 authored 作者: 吴德鹏's avatar 吴德鹏

评论

上级 d906ccb6
...@@ -46,12 +46,12 @@ public class PaypalConfig { ...@@ -46,12 +46,12 @@ public class PaypalConfig {
return new OAuthTokenCredential(clientId, clientSecret, paypalSdkConfig()); return new OAuthTokenCredential(clientId, clientSecret, paypalSdkConfig());
} }
@Bean // @Bean
public APIContext apiContext() throws PayPalRESTException { // public APIContext apiContext() throws PayPalRESTException {
APIContext apiContext = new APIContext(authTokenCredential().getAccessToken()); // APIContext apiContext = new APIContext(authTokenCredential().getAccessToken());
apiContext.setConfigurationMap(paypalSdkConfig()); // apiContext.setConfigurationMap(paypalSdkConfig());
return apiContext; // return apiContext;
} // }
} }
...@@ -17,7 +17,6 @@ import org.springframework.data.domain.Sort; ...@@ -17,7 +17,6 @@ import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.springframework.data.domain.Sort.Order.*; import static org.springframework.data.domain.Sort.Order.*;
...@@ -36,11 +35,13 @@ public class ItemController { ...@@ -36,11 +35,13 @@ public class ItemController {
private final TbCfItemParamRepository itemParamRepository; private final TbCfItemParamRepository itemParamRepository;
private final TbCfRecommendRepository recommendRepository; private final TbCfRecommendRepository recommendRepository;
private final TbCfItemCommentRepository commentRepository; private final TbCfItemCommentRepository commentRepository;
private final VirtualUserRepository virtualUserRepository;
private final AuthenticationUser user; private final AuthenticationUser user;
private final RedisCache redisCache; private final RedisCache redisCache;
private final UserRepository userRepository;
private static Logger logger = LoggerFactory.getLogger(ItemController.class); private static Logger logger = LoggerFactory.getLogger(ItemController.class);
public ItemController(TbCfStationItemRepository repository, TbCfGoodstwotypeRepository goodstwotypeRepository, TbCfGoodstypeRepository goodstypeRepository, TbCfDescripitonRepository descriptionRepository, TbCfCategoryRepository categoryRepository, TbCfItemSkuRepository skuRepository, TbCfItemDescRepository descRepository, TbCfItemCollectionRepository collectionRepository, TbCfItemParamRepository itemParamRepository, TbCfRecommendRepository recommendRepository, TbCfItemCommentRepository commentRepository, AuthenticationUser user, RedisCache redisCache) { public ItemController(TbCfStationItemRepository repository, TbCfGoodstwotypeRepository goodstwotypeRepository, TbCfGoodstypeRepository goodstypeRepository, TbCfDescripitonRepository descriptionRepository, TbCfCategoryRepository categoryRepository, TbCfItemSkuRepository skuRepository, TbCfItemDescRepository descRepository, TbCfItemCollectionRepository collectionRepository, TbCfItemParamRepository itemParamRepository, TbCfRecommendRepository recommendRepository, TbCfItemCommentRepository commentRepository, VirtualUserRepository virtualUserRepository, AuthenticationUser user, RedisCache redisCache, UserRepository userRepository) {
this.repository = repository; this.repository = repository;
this.goodstwotypeRepository = goodstwotypeRepository; this.goodstwotypeRepository = goodstwotypeRepository;
this.goodstypeRepository = goodstypeRepository; this.goodstypeRepository = goodstypeRepository;
...@@ -52,8 +53,10 @@ public class ItemController { ...@@ -52,8 +53,10 @@ public class ItemController {
this.itemParamRepository = itemParamRepository; this.itemParamRepository = itemParamRepository;
this.recommendRepository = recommendRepository; this.recommendRepository = recommendRepository;
this.commentRepository = commentRepository; this.commentRepository = commentRepository;
this.virtualUserRepository = virtualUserRepository;
this.user = user; this.user = user;
this.redisCache = redisCache; this.redisCache = redisCache;
this.userRepository = userRepository;
} }
@GetMapping("/queryAll") @GetMapping("/queryAll")
...@@ -105,7 +108,7 @@ public class ItemController { ...@@ -105,7 +108,7 @@ public class ItemController {
try { try {
List<SearchModel> list = repository.searchAllItems(name, pageNum * pageSize, pageSize); List<SearchModel> list = repository.searchAllItems(name, pageNum * pageSize, pageSize);
list=list.stream().filter(i->"1".equals(i.getEnableFlag().toString())).collect(Collectors.toList()); list = list.stream().filter(i -> "1".equals(i.getEnableFlag().toString())).collect(Collectors.toList());
Long count = repository.countAllBySearchItems(name); Long count = repository.countAllBySearchItems(name);
long totalPage; long totalPage;
if (count % pageSize == 0) { if (count % pageSize == 0) {
...@@ -248,6 +251,7 @@ public class ItemController { ...@@ -248,6 +251,7 @@ public class ItemController {
String key = KeyConstant.ITEM_LIKE; String key = KeyConstant.ITEM_LIKE;
Page<TbCfItemComment> allByItemId = commentRepository.findAllByItemId(itemId, PageRequest.of(pageNum, pageSize, Sort.by(Sort.Order.desc("createTime")))); Page<TbCfItemComment> allByItemId = commentRepository.findAllByItemId(itemId, PageRequest.of(pageNum, pageSize, Sort.by(Sort.Order.desc("createTime"))));
// List<TbCfItemComment> list = new ArrayList<>();
List<TbCfItemComment> comments = allByItemId.toList(); List<TbCfItemComment> comments = allByItemId.toList();
AtomicDouble totalScore = new AtomicDouble(0d); AtomicDouble totalScore = new AtomicDouble(0d);
...@@ -257,6 +261,25 @@ public class ItemController { ...@@ -257,6 +261,25 @@ public class ItemController {
} }
comments.forEach(c -> { comments.forEach(c -> {
// if (!StringUtils.isBlank(c.getUserId())) {
// if ("0".equals(c.getReal().toString())) {
// Optional<VirtualUser> byId = virtualUserRepository.findById(c.getUserId());
// if (byId.isPresent()) {
// VirtualUser user = byId.get();
// c.setAvatar(user.getAvatar());
// c.setUserName(user.getNick());
// }
// } else {
// Optional<TbCfUserInfo> byId = userRepository.findById(c.getUserId());
// if (byId.isPresent()) {
// TbCfUserInfo user = byId.get();
// c.setAvatar(user.getAvatar());
// c.setUserName(user.getNick());
// }
// }
//
// }
if (!StringUtils.isBlank(userId)) { if (!StringUtils.isBlank(userId)) {
String liked = (String) redisCache.get(key + userId + "_" + c.getId()); String liked = (String) redisCache.get(key + userId + "_" + c.getId());
c.setLike(liked == null ? false : true); c.setLike(liked == null ? false : true);
...@@ -264,6 +287,7 @@ public class ItemController { ...@@ -264,6 +287,7 @@ public class ItemController {
Integer count = (Integer) redisCache.get(key + c.getId()); Integer count = (Integer) redisCache.get(key + c.getId());
c.setLikeCount(count == null ? 0 : count); c.setLikeCount(count == null ? 0 : count);
totalScore.addAndGet(c.getScore()); totalScore.addAndGet(c.getScore());
// list.add(c);
}); });
double v = totalScore.get() / comments.size(); double v = totalScore.get() / comments.size();
param.put("totalScore", Double.parseDouble(String.format("%.1f", v))); param.put("totalScore", Double.parseDouble(String.format("%.1f", v)));
......
...@@ -560,7 +560,7 @@ public class OrderController extends Controller { ...@@ -560,7 +560,7 @@ public class OrderController extends Controller {
@PostMapping("/add/comment") @PostMapping("/add/comment")
public Result addComment(TbCfItemComment comment/*, @RequestParam(value = "files", required = false) MultipartFile[] files*/) throws Exception { public Result addComment(TbCfItemComment comment, @RequestParam(value = "files", required = false) MultipartFile[] files) throws Exception {
TbCfUserInfo user = this.user.user(); TbCfUserInfo user = this.user.user();
...@@ -575,18 +575,18 @@ public class OrderController extends Controller { ...@@ -575,18 +575,18 @@ public class OrderController extends Controller {
return new Result(ResultCodeEnum.VALIDATE_ERROR.getCode(), "Already reviewed this product!"); return new Result(ResultCodeEnum.VALIDATE_ERROR.getCode(), "Already reviewed this product!");
} }
// List<String> urls = new ArrayList<>(); List<String> urls = new ArrayList<>();
// if (files != null) { if (files != null) {
// for (MultipartFile file : files) { for (MultipartFile file : files) {
// byte[] bytes = PicUtils.compressPicForScale(file.getBytes(), 120); byte[] bytes = PicUtils.compressPicForScale(file.getBytes(), 30);
//// ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes); // ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
// String urlName = UUID.randomUUID() + ".jpg"; String urlName = UUID.randomUUID() + ".jpg";
// String url = OssUtil.upload(bytes, urlName, "comment"); String url = OssUtil.upload(bytes, urlName, "comment");
// urls.add(url); urls.add(url);
// } }
// String strUrl = urls.stream().collect(Collectors.joining(";")); String strUrl = urls.stream().collect(Collectors.joining(";"));
// comment.setUrls(strUrl); comment.setUrls(strUrl);
// } }
comment.setItemId(itemId); comment.setItemId(itemId);
comment.setUser(user); comment.setUser(user);
...@@ -595,7 +595,7 @@ public class OrderController extends Controller { ...@@ -595,7 +595,7 @@ public class OrderController extends Controller {
// comment.setLikeNum(0L); // comment.setLikeNum(0L);
comment.setCreateTime(new Date()); comment.setCreateTime(new Date());
comment.setUpdateTime(new Date()); comment.setUpdateTime(new Date());
// comment.setReal(true); comment.setReal(1);
// comment.setType(0); // comment.setType(0);
// if (!StringUtils.isBlank(comment.getUrls())) { // if (!StringUtils.isBlank(comment.getUrls())) {
// comment.setType(1); // comment.setType(1);
......
...@@ -56,7 +56,7 @@ public class PaypalContoller extends Controller { ...@@ -56,7 +56,7 @@ public class PaypalContoller extends Controller {
@Value("${paypal.mode}") @Value("${paypal.mode}")
private String mode; private String mode;
private final APIContext oldApiContext; // private final APIContext oldApiContext;
private final TbCfOrderRepository orderRepository; private final TbCfOrderRepository orderRepository;
private final TbCfFinanceRepository financeRepository; private final TbCfFinanceRepository financeRepository;
private final NetworkRepository networkRepository; private final NetworkRepository networkRepository;
...@@ -66,8 +66,8 @@ public class PaypalContoller extends Controller { ...@@ -66,8 +66,8 @@ public class PaypalContoller extends Controller {
private final TokenRepository tokenRepository; private final TokenRepository tokenRepository;
public PaypalContoller(APIContext oldApiContext, TbCfOrderRepository orderRepository, TbCfFinanceRepository financeRepository, NetworkRepository networkRepository, BonusRepository bonusRepository, PostRepository postRepository, UserRepository userRepository, TokenRepository tokenRepository) { public PaypalContoller(/*APIContext oldApiContext,*/ TbCfOrderRepository orderRepository, TbCfFinanceRepository financeRepository, NetworkRepository networkRepository, BonusRepository bonusRepository, PostRepository postRepository, UserRepository userRepository, TokenRepository tokenRepository) {
this.oldApiContext = oldApiContext; // this.oldApiContext = oldApiContext;
this.orderRepository = orderRepository; this.orderRepository = orderRepository;
this.financeRepository = financeRepository; this.financeRepository = financeRepository;
this.networkRepository = networkRepository; this.networkRepository = networkRepository;
......
...@@ -91,7 +91,7 @@ public class TbCfItemComment { ...@@ -91,7 +91,7 @@ public class TbCfItemComment {
@JsonIgnore @JsonIgnore
@Transient @Transient
private Boolean real; private Integer real;
/** /**
* 更新时间 * 更新时间
*/ */
...@@ -117,6 +117,8 @@ public class TbCfItemComment { ...@@ -117,6 +117,8 @@ public class TbCfItemComment {
@Transient @Transient
private double totalScore; private double totalScore;
private String attributs; private String attributs;
public String getAttributs() { public String getAttributs() {
...@@ -204,10 +206,6 @@ public class TbCfItemComment { ...@@ -204,10 +206,6 @@ public class TbCfItemComment {
this.avatar = user == null ? "" : user.getAvatar(); this.avatar = user == null ? "" : user.getAvatar();
} }
/**
* 获取:评论人
*/
public String getUserId() { public String getUserId() {
return user != null ? user.getUserId() : null; return user != null ? user.getUserId() : null;
} }
...@@ -406,11 +404,11 @@ public class TbCfItemComment { ...@@ -406,11 +404,11 @@ public class TbCfItemComment {
return user; return user;
} }
public Boolean getReal() { public Integer getReal() {
return real; return real;
} }
public void setReal(Boolean real) { public void setReal(Integer real) {
this.real = real; this.real = real;
} }
......
package com.example.afrishop_v3.models;
import lombok.Data;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.io.Serializable;
import java.util.Date;
/**
* 实体
* 表名 virtual_user
*
* @author lipengjun
* @date 2021-01-27 10:21:45
*/
@Entity
@Data
public class VirtualUser implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 虚拟用户ID
*/
@Id
private String id;
/**
* 虚拟账号
*/
private String account;
/**
* 昵称
*/
private String nick;
/**
* 头像
*/
private String avatar;
/**
* 状态 0:已删除 1:正常
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 设置:虚拟用户ID
*/
public void setId(String id) {
this.id = id;
}
/**
* 获取:虚拟用户ID
*/
public String getId() {
return id;
}
/**
* 设置:虚拟账号
*/
public void setAccount(String account) {
this.account = account;
}
/**
* 获取:虚拟账号
*/
public String getAccount() {
return account;
}
/**
* 设置:昵称
*/
public void setNick(String nick) {
this.nick = nick;
}
/**
* 获取:昵称
*/
public String getNick() {
return nick;
}
/**
* 设置:头像
*/
public void setAvatar(String avatar) {
this.avatar = avatar;
}
/**
* 获取:头像
*/
public String getAvatar() {
return avatar;
}
/**
* 设置:状态 0:已删除 1:正常
*/
public void setStatus(Integer status) {
this.status = status;
}
/**
* 获取:状态 0:已删除 1:正常
*/
public Integer getStatus() {
return status;
}
/**
* 设置:创建时间
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* 获取:创建时间
*/
public Date getCreateTime() {
return createTime;
}
/**
* 设置:更新时间
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
/**
* 获取:更新时间
*/
public Date getUpdateTime() {
return updateTime;
}
}
...@@ -9,13 +9,14 @@ import org.springframework.data.jpa.repository.Query; ...@@ -9,13 +9,14 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import java.util.List;
public interface TbCfItemCommentRepository extends PagingAndSortingRepository<TbCfItemComment, String> { public interface TbCfItemCommentRepository extends PagingAndSortingRepository<TbCfItemComment, String> {
boolean existsByUserUserIdAndItemId(String userId, String itemId); boolean existsByUserUserIdAndItemId(String userId, String itemId);
Page<TbCfItemComment> findAllByItemId(String itemId, Pageable pageable); Page<TbCfItemComment> findAllByItemId(String itemId, Pageable pageable);
@Query(value = "select c from #{#entityName} c where itemId=:itemId ")
Page<TbCfItemComment> findByItemId(@Param("itemId") String itemId, Pageable pageable);
@Query("select a as itemComment, count(x) as commented from #{#entityName} a left join TbCfItemLike x on a=x.comment and x.user=:user where a.itemId=:itemId group by a") @Query("select a as itemComment, count(x) as commented from #{#entityName} a left join TbCfItemLike x on a=x.comment and x.user=:user where a.itemId=:itemId group by a")
Page<CommentCount> findAllByItemIdAndUser(@Param("itemId") String itemId, @Param("user") TbCfUserInfo user, Pageable pageable); Page<CommentCount> findAllByItemIdAndUser(@Param("itemId") String itemId, @Param("user") TbCfUserInfo user, Pageable pageable);
......
package com.example.afrishop_v3.repository;
import com.example.afrishop_v3.models.TbCfUserInfo;
import com.example.afrishop_v3.models.VirtualUser;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
* @Auther: wudepeng
* @Date: 2021/01/27
* @Description:
*/
public interface VirtualUserRepository extends PagingAndSortingRepository<VirtualUser,String> {
}
...@@ -71,7 +71,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -71,7 +71,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
"/goodsType/**", "/home/**", "/spider/**", "/store/**", "/shopify/**", "/community/**", "/version/**", "/goodsType/**", "/home/**", "/spider/**", "/store/**", "/shopify/**", "/community/**", "/version/**",
"/flutterwave/notify/**", "/dpo/notify/**", "/advertisement/**", "/website/**", "/paypal/**", "/discover/bonus/**", "/flutterwave/notify/**", "/dpo/notify/**", "/advertisement/**", "/website/**", "/paypal/**", "/discover/bonus/**",
"/problem/**", "/cube/**", "/activity/**", "/attributes/**", "/stripe/**", "/coupon/**", "/logistics/freeShippingThreshold", "/problem/**", "/cube/**", "/activity/**", "/attributes/**", "/stripe/**", "/coupon/**", "/logistics/freeShippingThreshold",
"/visit/**", "/search/**", "/country/**", "/term/**","/order/**").permitAll() "/visit/**", "/search/**", "/country/**", "/term/**","/order/**","/api/upload").permitAll()
.antMatchers("/api/test/**").permitAll() .antMatchers("/api/test/**").permitAll()
.anyRequest().authenticated(); .anyRequest().authenticated();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论