| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- package com.cyksj.web.controller.group;
- 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.manage.views.GroupsRelationView;
- import com.cyksj.model.views.GroupsView;
- import com.ejlchina.searcher.BeanSearcher;
- import com.ejlchina.searcher.SearchResult;
- import com.ejlchina.searcher.util.MapUtils;
- import lombok.RequiredArgsConstructor;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import javax.servlet.http.HttpServletRequest;
- import java.util.List;
- /**
- * @author chan
- * @date 2022/9/26 6:31 PM
- */
- @Slf4j
- @RequestMapping("/applets/group")
- @RestController
- @RequiredArgsConstructor
- public class GroupController {
- private final HttpServletRequest request;
- private final BeanSearcher beanSearcher;
- private final GoodsDonSkuMapper goodsDonSkuMapper;
- @GetMapping("/get")
- 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()
- );
- 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());
- 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);
- }
- }
|