From 4e131e51182d0c51755deefb85c10d07310a0ca6 Mon Sep 17 00:00:00 2001 From: 623756217 <623756217@qq.com> Date: Mon, 6 Mar 2023 16:43:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0getContentsLikeNameAndFunc?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=90=8D=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/market/MarketController.java | 15 +++--- .../service/market/IMarketService.java | 2 +- .../service/market/impl/MarketService.java | 27 +++++++--- .../gitlink/softbot/vo/MarketBotPagesVO1.java | 27 ++++++++++ .../com/gitlink/softbot/vo/MarketBotVO1.java | 49 +++++++++++++++++++ 5 files changed, 105 insertions(+), 15 deletions(-) create mode 100644 src/main/java/com/gitlink/softbot/vo/MarketBotPagesVO1.java create mode 100644 src/main/java/com/gitlink/softbot/vo/MarketBotVO1.java diff --git a/src/main/java/com/gitlink/softbot/controller/market/MarketController.java b/src/main/java/com/gitlink/softbot/controller/market/MarketController.java index ecffd00..fd9673a 100644 --- a/src/main/java/com/gitlink/softbot/controller/market/MarketController.java +++ b/src/main/java/com/gitlink/softbot/controller/market/MarketController.java @@ -7,6 +7,7 @@ import com.gitlink.softbot.service.market.IMarketService; import com.gitlink.softbot.vo.GetAllBotCategory; import com.gitlink.softbot.vo.GetBotDetailResponse; import com.gitlink.softbot.vo.MarketBotPagesVO; +import com.gitlink.softbot.vo.MarketBotPagesVO1; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -96,13 +97,13 @@ public class MarketController { * @throws BotException */ @GetMapping("/getContentsLikeNameAndFunc") - public Result getContentsLikeNameAndFunc(@RequestParam(value = "name",required = false) String keyword, - @RequestParam(value= "func", required = false) String func, - @RequestParam(value = "page_no",defaultValue = "1",required = false) Integer pageIndex, - @RequestParam(value = "page_size",defaultValue = "12",required = false) Integer pageSize) throws BotException{ - MarketBotPagesVO marketBotPagesVO = marketService.getContentsLikeNameAndFunc(keyword,func,pageIndex,pageSize); - Result result = new Result<>(); - return result.build(marketBotPagesVO).build(200).build("success!"); + public Result getContentsLikeNameAndFunc(@RequestParam(value = "name",required = false) String keyword, + @RequestParam(value= "func", required = false) String func, + @RequestParam(value = "page_no",defaultValue = "1",required = false) Integer pageIndex, + @RequestParam(value = "page_size",defaultValue = "12",required = false) Integer pageSize) throws BotException{ + MarketBotPagesVO1 marketBotPagesVO1 = marketService.getContentsLikeNameAndFunc(keyword,func,pageIndex,pageSize); + Result result = new Result<>(); + return result.build(marketBotPagesVO1).build(200).build("success!"); } diff --git a/src/main/java/com/gitlink/softbot/service/market/IMarketService.java b/src/main/java/com/gitlink/softbot/service/market/IMarketService.java index 738f14d..bda4e3d 100644 --- a/src/main/java/com/gitlink/softbot/service/market/IMarketService.java +++ b/src/main/java/com/gitlink/softbot/service/market/IMarketService.java @@ -13,5 +13,5 @@ public interface IMarketService { GetAllBotCategory getAllBotCategory(); - MarketBotPagesVO getContentsLikeNameAndFunc(String name,String fun,Integer pageNo,Integer pageSize); + MarketBotPagesVO1 getContentsLikeNameAndFunc(String name,String fun,Integer pageNo,Integer pageSize); } diff --git a/src/main/java/com/gitlink/softbot/service/market/impl/MarketService.java b/src/main/java/com/gitlink/softbot/service/market/impl/MarketService.java index 57b32e5..671168a 100644 --- a/src/main/java/com/gitlink/softbot/service/market/impl/MarketService.java +++ b/src/main/java/com/gitlink/softbot/service/market/impl/MarketService.java @@ -24,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.ObjectUtils; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Objects; @@ -256,7 +257,7 @@ public class MarketService implements IMarketService { * @return */ @Override - public MarketBotPagesVO getContentsLikeNameAndFunc(String name, String fun, Integer pageNo, Integer pageSize) { + public MarketBotPagesVO1 getContentsLikeNameAndFunc(String name, String fun, Integer pageNo, Integer pageSize) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); if(StringUtils.isNotBlank(fun)){ lambdaQueryWrapper.and(wrapper->{ @@ -268,13 +269,25 @@ public class MarketService implements IMarketService { lambdaQueryWrapper.like(StringUtils.isNotBlank(name),MarketBot::getMarketName,name); } lambdaQueryWrapper.orderByDesc(MarketBot::getInstallNum); + IPage page = marketBotMapper.selectPage(new Page(pageNo,pageSize),lambdaQueryWrapper); - MarketBotPagesVO marketBotPagesVO = new MarketBotPagesVO(); - marketBotPagesVO.setBotList(page.getRecords()); - marketBotPagesVO.setTotal(page.getTotal()); - marketBotPagesVO.setPageIndex(pageNo); - marketBotPagesVO.setPageSize(pageSize); - return marketBotPagesVO; + MarketBotPagesVO1 marketBotPagesVO1 = new MarketBotPagesVO1(); + List marketBotVO1s = new ArrayList<>(); + page.getRecords().forEach(MarketBot ->{ + Integer botId = MarketBot.getBotId(); + RegisterBot registerBot = registerMapper.selectOne(Wrappers.lambdaQuery() + .eq(RegisterBot::getBotId,botId)); + MarketBotVO1 marketBotVO1 = new MarketBotVO1(); + BeanUtils.copyProperties(MarketBot,marketBotVO1); + BeanUtils.copyProperties(registerBot,marketBotVO1); + marketBotVO1.setDeveloperName(api.getUserNameByUid(registerBot.getDeveloperId().toString())); + marketBotVO1s.add(marketBotVO1); + }); + marketBotPagesVO1.setBotList(marketBotVO1s); + marketBotPagesVO1.setTotal(page.getTotal()); + marketBotPagesVO1.setPageIndex(pageNo); + marketBotPagesVO1.setPageSize(pageSize); + return marketBotPagesVO1; } private LimitVO getLimitFromLimitEvents(List botLimitEvents){ diff --git a/src/main/java/com/gitlink/softbot/vo/MarketBotPagesVO1.java b/src/main/java/com/gitlink/softbot/vo/MarketBotPagesVO1.java new file mode 100644 index 0000000..f1726aa --- /dev/null +++ b/src/main/java/com/gitlink/softbot/vo/MarketBotPagesVO1.java @@ -0,0 +1,27 @@ +package com.gitlink.softbot.vo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import com.gitlink.softbot.entity.db.MarketBot; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +@AllArgsConstructor +@NoArgsConstructor +@Data +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class MarketBotPagesVO1 implements Serializable { + private int pageIndex; + private int pageSize; + private long total; + private List botList; + +} diff --git a/src/main/java/com/gitlink/softbot/vo/MarketBotVO1.java b/src/main/java/com/gitlink/softbot/vo/MarketBotVO1.java new file mode 100644 index 0000000..fa3195f --- /dev/null +++ b/src/main/java/com/gitlink/softbot/vo/MarketBotVO1.java @@ -0,0 +1,49 @@ +package com.gitlink.softbot.vo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.Date; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class MarketBotVO1 implements Serializable { + + private Integer botId; + + private String marketName; + + private String marketDesc; + + private String firstFunc; + + private String secondFunc; + + private Date marketTime; + + private String logo; + + private Integer installNum; + + private String category; + + private String marketIntro; + + private String webhook; + + private Integer developerId; + + private String developerLogin; + + private String developerName; +}