|
@@ -0,0 +1,136 @@
|
|
|
|
|
+package com.xingxi.api.controller;
|
|
|
|
|
+
|
|
|
|
|
+import com.xingxi.api.common.BaseApiController;
|
|
|
|
|
+import com.xingxi.api.model.*;
|
|
|
|
|
+import com.xingxi.business.Banner.domain.Banner;
|
|
|
|
|
+import com.xingxi.business.Banner.service.IBannerService;
|
|
|
|
|
+import com.xingxi.business.NewProd.domain.NewProd;
|
|
|
|
|
+import com.xingxi.business.NewProd.service.INewProdService;
|
|
|
|
|
+import com.xingxi.business.PopularProd.domain.PopularProd;
|
|
|
|
|
+import com.xingxi.business.PopularProd.service.IPopularProdService;
|
|
|
|
|
+import com.xingxi.business.SuggestProd.domain.SuggestProd;
|
|
|
|
|
+import com.xingxi.business.SuggestProd.service.ISuggestProdService;
|
|
|
|
|
+import com.xingxi.common.enums.EDelFlag;
|
|
|
|
|
+import com.xingxi.master.ipInfo.domain.IpInfo;
|
|
|
|
|
+import com.xingxi.master.ipInfo.service.IIpInfoService;
|
|
|
|
|
+import com.xingxi.master.product.domain.Prod;
|
|
|
|
|
+import com.xingxi.master.product.domain.ProdClass;
|
|
|
|
|
+import com.xingxi.master.product.service.IProdClassService;
|
|
|
|
|
+import com.xingxi.master.product.service.IProdService;
|
|
|
|
|
+import com.xingxi.system.service.ISysConfigService;
|
|
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+
|
|
|
|
|
+import javax.validation.Valid;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+@RequiredArgsConstructor
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/api/homepage")
|
|
|
|
|
+public class HomepageApiController extends BaseApiController {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IBannerService bannerService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IIpInfoService ipInfoService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ISysConfigService configService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IProdClassService prodClassService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IPopularProdService leftProdService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ISuggestProdService middleProdService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private INewProdService rightProdService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IProdService prodService;
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/banners")
|
|
|
|
|
+ public BannerResponse getBanners(){
|
|
|
|
|
+ Banner cond = new Banner();
|
|
|
|
|
+ cond.setDelFlag(EDelFlag.NO.getVal());
|
|
|
|
|
+
|
|
|
|
|
+ return new BannerResponse(bannerService.selectBannerList(cond));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/ipInfos")
|
|
|
|
|
+ public IpInfoResponse getIpInfos(){
|
|
|
|
|
+
|
|
|
|
|
+ IpInfo cond = new IpInfo();
|
|
|
|
|
+ cond.setDelFlag(EDelFlag.NO.getVal());
|
|
|
|
|
+
|
|
|
|
|
+ return new IpInfoResponse(ipInfoService.selectIpInfoList(cond));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/titles")
|
|
|
|
|
+ public SysConfigResponse getTitles(){
|
|
|
|
|
+
|
|
|
|
|
+ List<String> rtn = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ // TODO title的key待确认,数据库中未创建数据
|
|
|
|
|
+ rtn.add(configService.selectConfigByKey("title.left"));
|
|
|
|
|
+ rtn.add(configService.selectConfigByKey("title.middle"));
|
|
|
|
|
+ rtn.add(configService.selectConfigByKey("title.right"));
|
|
|
|
|
+
|
|
|
|
|
+ return new SysConfigResponse(rtn);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/leftProds")
|
|
|
|
|
+ public LeftProdResponse getLeftProds(){
|
|
|
|
|
+
|
|
|
|
|
+ PopularProd cond = new PopularProd();
|
|
|
|
|
+ cond.setDelFlag(EDelFlag.NO.getVal());
|
|
|
|
|
+
|
|
|
|
|
+ return new LeftProdResponse(leftProdService.selectPopularProdList(cond));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/middleProds")
|
|
|
|
|
+ public MiddleProdResponse getMiddleProds(){
|
|
|
|
|
+
|
|
|
|
|
+ SuggestProd cond = new SuggestProd();
|
|
|
|
|
+ cond.setDelFlag(EDelFlag.NO.getVal());
|
|
|
|
|
+
|
|
|
|
|
+ return new MiddleProdResponse(middleProdService.selectSuggestProdList(cond));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/rightProds")
|
|
|
|
|
+ public RightProdResponse getRightProds(){
|
|
|
|
|
+
|
|
|
|
|
+ NewProd cond = new NewProd();
|
|
|
|
|
+ cond.setDelFlag(EDelFlag.NO.getVal());
|
|
|
|
|
+
|
|
|
|
|
+ return new RightProdResponse(rightProdService.selectNewProdList(cond));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/prodClasses")
|
|
|
|
|
+ public ProdClassResponse getProdClasses(){
|
|
|
|
|
+
|
|
|
|
|
+ ProdClass cond = new ProdClass();
|
|
|
|
|
+ cond.setDelFlag(EDelFlag.NO.getVal());
|
|
|
|
|
+
|
|
|
|
|
+ return new ProdClassResponse(prodClassService.selectProdClassList(cond));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/prods")
|
|
|
|
|
+ public ProdListResponse getProdList(@Valid @RequestBody ProdRequest request) {
|
|
|
|
|
+ Prod cond = new Prod();
|
|
|
|
|
+ cond.setId(request.getId());
|
|
|
|
|
+ cond.setIpId(request.getIpId());
|
|
|
|
|
+ cond.setProdClassId(request.getProdClassId());
|
|
|
|
|
+ cond.setProdName(request.getProdName());
|
|
|
|
|
+ cond.setDelFlag(EDelFlag.NO.getVal());
|
|
|
|
|
+
|
|
|
|
|
+ return new ProdListResponse(prodService.selectProdList(cond));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+}
|