diff --git a/src/main/java/com/corewing/app/config/Knife4jConfiguration.java b/src/main/java/com/corewing/app/config/Knife4jConfiguration.java index 612b071..8a467df 100644 --- a/src/main/java/com/corewing/app/config/Knife4jConfiguration.java +++ b/src/main/java/com/corewing/app/config/Knife4jConfiguration.java @@ -27,7 +27,7 @@ public class Knife4jConfiguration { .groupName("1.1.0版本") .select() //这里指定Controller扫描包路径 - .apis(RequestHandlerSelectors.basePackage("com.corewing.app.modules.app")) + .apis(RequestHandlerSelectors.basePackage("com.corewing.app.modules")) .paths(PathSelectors.any()) .build(); } diff --git a/src/main/java/com/corewing/app/config/SaTokenConfig.java b/src/main/java/com/corewing/app/config/SaTokenConfig.java index 19dcd46..07caadb 100644 --- a/src/main/java/com/corewing/app/config/SaTokenConfig.java +++ b/src/main/java/com/corewing/app/config/SaTokenConfig.java @@ -55,6 +55,7 @@ public class SaTokenConfig implements WebMvcConfigurer { .excludePathPatterns("/app_version/**") // 排除获取最新app接口 .excludePathPatterns("/api/app", "/api/app/getAppVersion") + .excludePathPatterns("/api/website/**") // 排除模型接口 .excludePathPatterns("/model/page", "/model/list", "/model/detail/**", "/model/category/**") // 排除咨询接口 diff --git a/src/main/java/com/corewing/app/dto/website/ProductCategoryRequest.java b/src/main/java/com/corewing/app/dto/website/ProductCategoryRequest.java new file mode 100644 index 0000000..725b58c --- /dev/null +++ b/src/main/java/com/corewing/app/dto/website/ProductCategoryRequest.java @@ -0,0 +1,13 @@ +package com.corewing.app.dto.website; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + + +@Data +public class ProductCategoryRequest { + + @ApiModelProperty(value = "产品名称") + private String searchKey; + +} diff --git a/src/main/java/com/corewing/app/dto/website/ProductPageRequest.java b/src/main/java/com/corewing/app/dto/website/ProductPageRequest.java new file mode 100644 index 0000000..8e37157 --- /dev/null +++ b/src/main/java/com/corewing/app/dto/website/ProductPageRequest.java @@ -0,0 +1,16 @@ +package com.corewing.app.dto.website; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + + +@Data +public class ProductPageRequest { + + @ApiModelProperty(value = "产品名称") + private String searchKey; + + @ApiModelProperty(value = "产品分类") + private String categoryId; + +} diff --git a/src/main/java/com/corewing/app/entity/BizProduct.java b/src/main/java/com/corewing/app/entity/BizProduct.java new file mode 100644 index 0000000..ec732cc --- /dev/null +++ b/src/main/java/com/corewing/app/entity/BizProduct.java @@ -0,0 +1,47 @@ +package com.corewing.app.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.corewing.app.common.base.CommonEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; + +@EqualsAndHashCode(callSuper = true) +@Data +@TableName("biz_product") +public class BizProduct extends CommonEntity { + + @TableId + private String id; + + private String title; + + private String description; + + private String thumbnail; + + private String hotStatus; + + private String content; + + private String detailUrl; + + private BigDecimal amount; + + private String status; + + private int sortCode; + + private String remark; + + private String extJson; + + @TableField(exist = false) + private String categoryId; + + + +} diff --git a/src/main/java/com/corewing/app/entity/BizProductCategory.java b/src/main/java/com/corewing/app/entity/BizProductCategory.java new file mode 100644 index 0000000..6b441c4 --- /dev/null +++ b/src/main/java/com/corewing/app/entity/BizProductCategory.java @@ -0,0 +1,38 @@ +package com.corewing.app.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.corewing.app.common.base.CommonEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +@Data +@TableName("biz_product_category") +public class BizProductCategory extends CommonEntity { + + @TableId + private String id; + + private String parentId; + + private String thumbnail; + + private String categoryTitle; + + private String description; + + private String status; + + private Integer sortCode; + + private String remark; + + private String extJson; + + @TableField(exist = false) + Page productPage; + +} diff --git a/src/main/java/com/corewing/app/entity/BizProductCategoryRelation.java b/src/main/java/com/corewing/app/entity/BizProductCategoryRelation.java new file mode 100644 index 0000000..2fe3e3e --- /dev/null +++ b/src/main/java/com/corewing/app/entity/BizProductCategoryRelation.java @@ -0,0 +1,18 @@ +package com.corewing.app.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +@Data +@TableName("biz_product_category_relation") +public class BizProductCategoryRelation { + + @TableId + private String id; + + private String productId; + + private String categoryId; + +} diff --git a/src/main/java/com/corewing/app/mapper/BizProductCategoryMapper.java b/src/main/java/com/corewing/app/mapper/BizProductCategoryMapper.java new file mode 100644 index 0000000..ecd3c0c --- /dev/null +++ b/src/main/java/com/corewing/app/mapper/BizProductCategoryMapper.java @@ -0,0 +1,15 @@ +package com.corewing.app.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.corewing.app.dto.website.ProductCategoryRequest; +import com.corewing.app.entity.BizProductCategory; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface BizProductCategoryMapper extends BaseMapper { + + List list(@Param("productCategoryRequest") ProductCategoryRequest productCategoryRequest); +} diff --git a/src/main/java/com/corewing/app/mapper/BizProductMapper.java b/src/main/java/com/corewing/app/mapper/BizProductMapper.java new file mode 100644 index 0000000..a7d37c0 --- /dev/null +++ b/src/main/java/com/corewing/app/mapper/BizProductMapper.java @@ -0,0 +1,14 @@ +package com.corewing.app.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.corewing.app.dto.website.ProductPageRequest; +import com.corewing.app.entity.BizProduct; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +@Mapper +public interface BizProductMapper extends BaseMapper { + + Page page(Page page, @Param("productPageRequest") ProductPageRequest productPageRequest); +} diff --git a/src/main/java/com/corewing/app/modules/website/WebsiteProductController.java b/src/main/java/com/corewing/app/modules/website/WebsiteProductController.java new file mode 100644 index 0000000..1863a1f --- /dev/null +++ b/src/main/java/com/corewing/app/modules/website/WebsiteProductController.java @@ -0,0 +1,50 @@ +package com.corewing.app.modules.website; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.corewing.app.common.Result; +import com.corewing.app.dto.website.ProductCategoryRequest; +import com.corewing.app.dto.website.ProductPageRequest; +import com.corewing.app.entity.BizProduct; +import com.corewing.app.entity.BizProductCategory; +import com.corewing.app.service.BizProductCategoryService; +import com.corewing.app.service.BizProductService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 产品 + */ +@Api(tags = "官网产品列表") +@RestController +@RequestMapping("/api/website/product") +public class WebsiteProductController { + + @Resource + private BizProductService productService; + + + @Resource + private BizProductCategoryService productCategoryService; + + + @ApiOperation("获取产品分页") + @GetMapping("/page") + public Result> page(ProductPageRequest productPageRequest) { + return Result.success(productService.page(productPageRequest)); + } + + @ApiOperation("获取产品分类") + @GetMapping("/category/list") + public Result> categoryList(ProductCategoryRequest productCategoryRequest) { + return Result.success(productCategoryService.list(productCategoryRequest)); + } + + + +} diff --git a/src/main/java/com/corewing/app/service/BizProductCategoryService.java b/src/main/java/com/corewing/app/service/BizProductCategoryService.java new file mode 100644 index 0000000..25a90bc --- /dev/null +++ b/src/main/java/com/corewing/app/service/BizProductCategoryService.java @@ -0,0 +1,13 @@ +package com.corewing.app.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.corewing.app.dto.website.ProductCategoryRequest; +import com.corewing.app.entity.BizProductCategory; + +import java.util.List; + +public interface BizProductCategoryService extends IService { + + List list(ProductCategoryRequest productCategoryRequest); +} diff --git a/src/main/java/com/corewing/app/service/BizProductService.java b/src/main/java/com/corewing/app/service/BizProductService.java new file mode 100644 index 0000000..bab2982 --- /dev/null +++ b/src/main/java/com/corewing/app/service/BizProductService.java @@ -0,0 +1,12 @@ +package com.corewing.app.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.corewing.app.dto.website.ProductPageRequest; +import com.corewing.app.entity.BizProduct; + +public interface BizProductService extends IService { + + Page page(ProductPageRequest productPageRequest); + +} diff --git a/src/main/java/com/corewing/app/service/impl/BizProductCategroyServiceImpl.java b/src/main/java/com/corewing/app/service/impl/BizProductCategroyServiceImpl.java new file mode 100644 index 0000000..9255c64 --- /dev/null +++ b/src/main/java/com/corewing/app/service/impl/BizProductCategroyServiceImpl.java @@ -0,0 +1,39 @@ +package com.corewing.app.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.corewing.app.dto.website.ProductCategoryRequest; +import com.corewing.app.dto.website.ProductPageRequest; +import com.corewing.app.entity.BizProduct; +import com.corewing.app.entity.BizProductCategory; +import com.corewing.app.mapper.BizProductCategoryMapper; +import com.corewing.app.service.BizProductCategoryService; +import com.corewing.app.service.BizProductService; +import com.google.gson.internal.LinkedTreeMap; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +@Service +public class BizProductCategroyServiceImpl extends ServiceImpl implements BizProductCategoryService { + + @Resource + private BizProductCategoryMapper bizProductCategoryMapper; + + @Resource + private BizProductService bizProductService; + + @Override + public List list(ProductCategoryRequest productCategoryRequest) { + List bizProductCategory = bizProductCategoryMapper.list(productCategoryRequest); + bizProductCategory.forEach(item -> { + ProductPageRequest query = new ProductPageRequest(); + query.setCategoryId(item.getId()); + Page page = bizProductService.page(query); + item.setProductPage(page); + }); + return bizProductCategory; + } +} diff --git a/src/main/java/com/corewing/app/service/impl/BizProductServiceImpl.java b/src/main/java/com/corewing/app/service/impl/BizProductServiceImpl.java new file mode 100644 index 0000000..1087128 --- /dev/null +++ b/src/main/java/com/corewing/app/service/impl/BizProductServiceImpl.java @@ -0,0 +1,26 @@ +package com.corewing.app.service.impl; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.corewing.app.common.page.PageContext; +import com.corewing.app.dto.website.ProductPageRequest; +import com.corewing.app.entity.AppModel; +import com.corewing.app.entity.BizProduct; +import com.corewing.app.mapper.BizProductMapper; +import com.corewing.app.service.BizProductService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +@Service +public class BizProductServiceImpl extends ServiceImpl implements BizProductService { + + @Resource + private BizProductMapper bizProductMapper; + + @Override + public Page page(ProductPageRequest productPageRequest) { + Page page = PageContext.getPage(BizProduct.class); + return bizProductMapper.page(page, productPageRequest); + } +} diff --git a/src/main/resources/mapper/BizProductCategoryMapper.xml b/src/main/resources/mapper/BizProductCategoryMapper.xml new file mode 100644 index 0000000..b52aec3 --- /dev/null +++ b/src/main/resources/mapper/BizProductCategoryMapper.xml @@ -0,0 +1,23 @@ + + + + + + + + SELECT pc.* + FROM biz_product_category pc + + + + + + + diff --git a/src/main/resources/mapper/BizProductMapper.xml b/src/main/resources/mapper/BizProductMapper.xml new file mode 100644 index 0000000..83ee398 --- /dev/null +++ b/src/main/resources/mapper/BizProductMapper.xml @@ -0,0 +1,28 @@ + + + + + + + + SELECT p.* + FROM biz_product p + LEFT JOIN biz_product_category_relation pcr on p.id = pcr.product_id + + + + + + +