根据品牌进行查询
This commit is contained in:
parent
e5d4d9daea
commit
57c9c5725e
|
@ -4,17 +4,18 @@
|
|||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="6ee93b58-a7e0-45a0-9e98-4c363b192afb" name="Changes" comment="搭建网关服务和nacos,将访问端口改为8500">
|
||||
<change afterPath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/config/RedisConfig.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" afterDir="false" />
|
||||
<list default="true" id="6ee93b58-a7e0-45a0-9e98-4c363b192afb" name="Changes" comment="将首页数据存放在redis中作为缓存">
|
||||
<change afterPath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/controller/BrandController.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/controller/ProductController.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/mapper/BrandMapper.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/service/BrandService.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/service/imp/BrandServiceImpl.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/spzx-service/service-product/src/main/resources/mapper/product/BrandMapper.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/spzx-service/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service/pom.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/ProductApplication.java" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/ProductApplication.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/mapper/ProductSkuMapper.java" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/mapper/ProductSkuMapper.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/service/ProductService.java" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/service/ProductService.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/service/imp/CategoryServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/service/imp/CategoryServiceImpl.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/service/imp/ProductServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service/service-product/src/main/java/cn/bunny/web/product/service/imp/ProductServiceImpl.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/spzx-service/service-product/src/main/resources/application-dev.yml" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service/service-product/src/main/resources/application-dev.yml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/spzx-service/service-product/src/main/resources/mapper/product/ProductSkuMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/spzx-service/service-product/src/main/resources/mapper/product/ProductSkuMapper.xml" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -24,9 +25,9 @@
|
|||
<component name="FileTemplateManagerImpl">
|
||||
<option name="RECENT_TEMPLATES">
|
||||
<list>
|
||||
<option value="Interface" />
|
||||
<option value="mybatis-mapper" />
|
||||
<option value="Class" />
|
||||
<option value="Interface" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
|
@ -79,7 +80,7 @@
|
|||
"project.structure.last.edited": "Project",
|
||||
"project.structure.proportion": "0.15",
|
||||
"project.structure.side.proportion": "0.2",
|
||||
"settings.editor.selected.configurable": "reference.projectsettings.compiler.javacompiler",
|
||||
"settings.editor.selected.configurable": "reference.settingsdialog.IDE.editor.colors.XML",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
},
|
||||
"keyToStringList": {
|
||||
|
@ -154,7 +155,7 @@
|
|||
<updated>1703487755445</updated>
|
||||
<workItem from="1703487757122" duration="903000" />
|
||||
<workItem from="1703488670206" duration="5932000" />
|
||||
<workItem from="1703549556395" duration="7669000" />
|
||||
<workItem from="1703549556395" duration="9451000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="前端接口初始化;显示商品页面">
|
||||
<option name="closed" value="true" />
|
||||
|
@ -188,7 +189,15 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1703552833275</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="5" />
|
||||
<task id="LOCAL-00005" summary="将首页数据存放在redis中作为缓存">
|
||||
<option name="closed" value="true" />
|
||||
<created>1703557481401</created>
|
||||
<option name="number" value="00005" />
|
||||
<option name="presentableId" value="LOCAL-00005" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1703557481401</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="6" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
|
@ -198,7 +207,8 @@
|
|||
<MESSAGE value="前端接口初始化;显示商品页面" />
|
||||
<MESSAGE value="解决跨域;修改MySQL语法错误;获取分类树形数据" />
|
||||
<MESSAGE value="搭建网关服务和nacos,将访问端口改为8500" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="搭建网关服务和nacos,将访问端口改为8500" />
|
||||
<MESSAGE value="将首页数据存放在redis中作为缓存" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="将首页数据存放在redis中作为缓存" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
|
@ -211,4 +221,8 @@
|
|||
</breakpoints>
|
||||
</breakpoint-manager>
|
||||
</component>
|
||||
<component name="XSLT-Support.FileAssociations.UIState">
|
||||
<expand />
|
||||
<select />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,27 @@
|
|||
package cn.bunny.web.product.controller;
|
||||
|
||||
import cn.bunny.common.spzx.model.entity.product.Brand;
|
||||
import cn.bunny.common.spzx.model.vo.common.Result;
|
||||
import cn.bunny.common.spzx.model.vo.common.ResultCodeEnum;
|
||||
import cn.bunny.web.product.service.BrandService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value="/api/product/brand")
|
||||
public class BrandController {
|
||||
@Resource
|
||||
private BrandService brandService;
|
||||
|
||||
@Operation(summary = "获取全部品牌")
|
||||
@GetMapping("findAll")
|
||||
public Result findAll() {
|
||||
List<Brand> brandList = brandService.findAll();
|
||||
return Result.build(brandList, ResultCodeEnum.SUCCESS);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package cn.bunny.web.product.controller;
|
||||
|
||||
import cn.bunny.common.spzx.model.dto.h5.ProductSkuDto;
|
||||
import cn.bunny.common.spzx.model.entity.product.ProductSku;
|
||||
import cn.bunny.common.spzx.model.vo.common.Result;
|
||||
import cn.bunny.common.spzx.model.vo.common.ResultCodeEnum;
|
||||
import cn.bunny.web.product.service.ProductService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/product")
|
||||
public class ProductController {
|
||||
@Resource
|
||||
private ProductService productService;
|
||||
|
||||
@Operation(summary = "分页查询")
|
||||
@GetMapping(value = "/{page}/{limit}")
|
||||
public Result findByPage(@PathVariable("page") Integer page,
|
||||
@PathVariable("limit") Integer limit,
|
||||
ProductSkuDto productSkuDto) {
|
||||
PageInfo<ProductSku> pageInfo = productService.findByPage(page, limit, productSkuDto);
|
||||
return Result.build(pageInfo, ResultCodeEnum.SUCCESS);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package cn.bunny.web.product.mapper;
|
||||
|
||||
import cn.bunny.common.spzx.model.entity.product.Brand;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface BrandMapper {
|
||||
// 获取全部品牌列表
|
||||
List<Brand> findAll();
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package cn.bunny.web.product.mapper;
|
||||
|
||||
import cn.bunny.common.spzx.model.dto.h5.ProductSkuDto;
|
||||
import cn.bunny.common.spzx.model.entity.product.Category;
|
||||
import cn.bunny.common.spzx.model.entity.product.ProductSku;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
@ -10,4 +11,6 @@ import java.util.List;
|
|||
public interface ProductSkuMapper {
|
||||
|
||||
List<ProductSku> selectProductSkuBySale();
|
||||
// 分页查询
|
||||
List<ProductSku> findByPage(ProductSkuDto productSkuDto);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package cn.bunny.web.product.service;
|
||||
|
||||
import cn.bunny.common.spzx.model.entity.product.Brand;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface BrandService {
|
||||
// 获取全部品牌
|
||||
List<Brand> findAll();
|
||||
}
|
|
@ -1,11 +1,15 @@
|
|||
package cn.bunny.web.product.service;
|
||||
|
||||
import cn.bunny.common.spzx.model.dto.h5.ProductSkuDto;
|
||||
import cn.bunny.common.spzx.model.entity.product.Category;
|
||||
import cn.bunny.common.spzx.model.entity.product.ProductSku;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ProductService {
|
||||
// 根据销量排序,获取前十条激励
|
||||
List<ProductSku> selectProductSkuBySal();
|
||||
// 分页查询
|
||||
PageInfo<ProductSku> findByPage(Integer page, Integer limit, ProductSkuDto productSkuDto);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package cn.bunny.web.product.service.imp;
|
||||
|
||||
import cn.bunny.common.spzx.model.entity.product.Brand;
|
||||
import cn.bunny.web.product.mapper.BrandMapper;
|
||||
import cn.bunny.web.product.service.BrandService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class BrandServiceImpl implements BrandService {
|
||||
@Resource
|
||||
private BrandMapper brandMapper;
|
||||
|
||||
/***
|
||||
* 获取全部品牌
|
||||
* @return 获取全部品牌列表
|
||||
*/
|
||||
@Override
|
||||
public List<Brand> findAll() {
|
||||
return brandMapper.findAll();
|
||||
}
|
||||
}
|
|
@ -1,10 +1,13 @@
|
|||
package cn.bunny.web.product.service.imp;
|
||||
|
||||
import cn.bunny.common.spzx.model.dto.h5.ProductSkuDto;
|
||||
import cn.bunny.common.spzx.model.entity.product.ProductSku;
|
||||
import cn.bunny.web.product.mapper.ProductSkuMapper;
|
||||
import cn.bunny.web.product.service.ProductService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.nacos.common.utils.StringUtils;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
|
@ -44,4 +47,12 @@ public class ProductServiceImpl implements ProductService {
|
|||
}
|
||||
return productSkuMapper.selectProductSkuBySale();
|
||||
}
|
||||
|
||||
// 分页查询
|
||||
@Override
|
||||
public PageInfo<ProductSku> findByPage(Integer page, Integer limit, ProductSkuDto productSkuDto) {
|
||||
PageHelper.startPage(page, page);
|
||||
List<ProductSku> productSkuList = productSkuMapper.findByPage(productSkuDto);
|
||||
return new PageInfo<>(productSkuList);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="cn.bunny.web.product.mapper.BrandMapper">
|
||||
|
||||
<!-- 获取全部品牌列表 -->
|
||||
<select id="findAll" resultType="cn.bunny.common.spzx.model.entity.product.Brand">
|
||||
select *
|
||||
from brand
|
||||
where is_deleted = 0
|
||||
order by id desc </select>
|
||||
</mapper>
|
|
@ -20,4 +20,41 @@
|
|||
order by sku.sale_num desc
|
||||
limit 10
|
||||
</select>
|
||||
<!-- 分页查询 -->
|
||||
<select id="findByPage" resultMap="productSkuMap">
|
||||
select
|
||||
sku.id,sku.sku_code,sku.sku_name,sku.product_id,sku.thumb_img,sku.sale_price,sku.market_price,sku.cost_price,sku.stock_num,sku.sale_num,sku.sku_spec,sku.weight,sku.volume,sku.status,sku.create_time,sku.update_time,sku.is_deleted
|
||||
from product_sku sku
|
||||
left join product p on p.id = sku.product_id
|
||||
<where>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
and sku.sku_name like CONCAT('%',#{keyword},'%')
|
||||
</if>
|
||||
<if test="brandId != null">
|
||||
and p.brand_id = #{brandId}
|
||||
</if>
|
||||
<if test="category1Id != null">
|
||||
and p.category1_id = #{category1Id}
|
||||
</if>
|
||||
<if test="category2Id != null">
|
||||
and p.category2_id = #{category2Id}
|
||||
</if>
|
||||
<if test="category3Id != null">
|
||||
and p.category3_id = #{category3Id}
|
||||
</if>
|
||||
and p.status = 1
|
||||
and p.audit_status = 1
|
||||
and sku.is_deleted = 0
|
||||
and p.is_deleted = 0
|
||||
</where>
|
||||
<if test="order == 1">
|
||||
order by sku.sale_num desc
|
||||
</if>
|
||||
<if test="order == 2">
|
||||
order by sku.sale_price asc
|
||||
</if>
|
||||
<if test="order == 3">
|
||||
order by sku.sale_price desc
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue