|
|
@@ -1,10 +1,9 @@
|
|
|
package com.cyksj.web.controller.group;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.cyksj.common.constant.Constant;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
import com.cyksj.mapper.GoodsDonSkuMapper;
|
|
|
-import com.cyksj.model.entity.GoodsDonSku;
|
|
|
import com.cyksj.model.manage.views.GroupsRelationView;
|
|
|
import com.cyksj.model.views.GroupsView;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
@@ -17,10 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
-import java.util.Set;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author chan
|
|
|
@@ -39,26 +35,55 @@ public class GroupController {
|
|
|
private final GoodsDonSkuMapper goodsDonSkuMapper;
|
|
|
|
|
|
@GetMapping("/get")
|
|
|
- public Result<SearchResult<GroupsView>> get(Long skuId) {
|
|
|
+ public Result<SearchResult<GroupsView>> get() {
|
|
|
SearchResult<GroupsView> search = beanSearcher.search(GroupsView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
.orderBy(GroupsView::getOrderBy).asc()
|
|
|
.orderBy(GroupsView::getId).desc().build()
|
|
|
);
|
|
|
- List<GoodsDonSku> goodsDonSkus = goodsDonSkuMapper.selectList(Wrappers.lambdaQuery(GoodsDonSku.class).eq(GoodsDonSku::getGoodsId, 18).select(GoodsDonSku::getId));
|
|
|
- Set<Long> skuIds = goodsDonSkus.stream().map(GoodsDonSku::getId).collect(Collectors.toSet());
|
|
|
- if (skuIds.contains(skuId)) {
|
|
|
- search.getDataList().forEach((groupsView)->{
|
|
|
- groupsView.setRelations(beanSearcher.searchAll(GroupsRelationView.class, MapUtils.builder()
|
|
|
+ search.getDataList().forEach((groupsView) -> {
|
|
|
+ if (Constant.CHAT_GPT_SKU_IDS.contains(groupsView.getSkuId())) {
|
|
|
+ List<GroupsRelationView> relationViewList = beanSearcher.searchAll(GroupsRelationView.class, MapUtils.builder()
|
|
|
.field(GroupsRelationView::getGroupsId, groupsView.getId())
|
|
|
.orderBy(GroupsRelationView::getUpdate_time).desc()
|
|
|
- .build()));
|
|
|
- });
|
|
|
- search.getDataList().sort(Comparator.comparing(GroupsView::getOrderBy));
|
|
|
- }else {
|
|
|
- search.getDataList().forEach((groupsView) -> {
|
|
|
+ .build());
|
|
|
+ List<GroupsRelationView> all = null;
|
|
|
+ //GPT 月付 暗改成20个 展示10个
|
|
|
+ if (groupsView.getSkuId().equals(Constant.CHAT_GPT_SKU_IDS.get(0))) {
|
|
|
+ all = relationViewList.subList(0, 5);
|
|
|
+ List<GroupsRelationView> after = relationViewList.subList(relationViewList.size() - 5, 20);
|
|
|
+ all.addAll(after);
|
|
|
+ }
|
|
|
+ //GPT 4人月付暗改成6个 展示4个
|
|
|
+ if (groupsView.getSkuId().equals(Constant.CHAT_GPT_SKU_IDS.get(1))) {
|
|
|
+ all = relationViewList.subList(0, 2);
|
|
|
+ List<GroupsRelationView> after = relationViewList.subList(relationViewList.size() - 2, 6);
|
|
|
+ all.addAll(after);
|
|
|
+ }
|
|
|
+ groupsView.setRelations(all);
|
|
|
+ } else if (Constant.MIDJOURNEY_SKU_IDS.contains(groupsView.getSkuId()) && groupsView.getNum() == 15) {
|
|
|
+ List<GroupsRelationView> relationViewList = beanSearcher.searchAll(GroupsRelationView.class, MapUtils.builder()
|
|
|
+ .field(GroupsRelationView::getGroupsId, groupsView.getId())
|
|
|
+ .orderBy(GroupsRelationView::getUpdate_time).desc()
|
|
|
+ .build());
|
|
|
+ List<GroupsRelationView> all = null;
|
|
|
+ //MIDJOURNEY 月付5个 暗改15个 展示5个
|
|
|
+ if (groupsView.getSkuId().equals(Constant.MIDJOURNEY_SKU_IDS.get(0))) {
|
|
|
+ all = relationViewList.subList(0, 5);
|
|
|
+ List<GroupsRelationView> after = relationViewList.subList(relationViewList.size() - 1, 15);
|
|
|
+ all.addAll(after);
|
|
|
+ }
|
|
|
+ //MIDJOURNEY 标准会员月付10个 暗改15个 展示10个
|
|
|
+ if (groupsView.getSkuId().equals(Constant.MIDJOURNEY_SKU_IDS.get(1)) || groupsView.getSkuId().equals(Constant.MIDJOURNEY_SKU_IDS.get(2))) {
|
|
|
+ all = relationViewList.subList(0, 5);
|
|
|
+ List<GroupsRelationView> after = relationViewList.subList(relationViewList.size() - 5, 15);
|
|
|
+ all.addAll(after);
|
|
|
+ }
|
|
|
+ groupsView.setRelations(all);
|
|
|
+ } else {
|
|
|
groupsView.setRelations(beanSearcher.searchAll(GroupsRelationView.class, MapUtils.builder().field(GroupsRelationView::getGroupsId, groupsView.getId()).build()));
|
|
|
- });
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
}
|
|
|
|