分类品牌查询完成
This commit is contained in:
parent
0b4fe3df34
commit
09b8120630
|
@ -11,6 +11,8 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Tag(name = "商品分类")
|
@Tag(name = "商品分类")
|
||||||
@RequestMapping("/admin/product/brand")
|
@RequestMapping("/admin/product/brand")
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -19,9 +21,17 @@ public class BranController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private BrandService brandService;
|
private BrandService brandService;
|
||||||
|
|
||||||
|
@Operation(summary = "查询所有品牌", description = "查询所有品牌")
|
||||||
|
@GetMapping("findAll")
|
||||||
|
public Result findAll() {
|
||||||
|
List<Brand> brandList= brandService.findAll();
|
||||||
|
return Result.build(brandList, ResultCodeEnum.SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "获取品牌列表", description = "获取品牌全部列表")
|
@Operation(summary = "获取品牌列表", description = "获取品牌全部列表")
|
||||||
@GetMapping("{page}/{limit}")
|
@GetMapping("{page}/{limit}")
|
||||||
public Result list(@PathVariable("page") Integer page, @PathVariable("limit") Integer limit) {
|
public Result list(@PathVariable("page") Integer page, @PathVariable("limit") Integer limit) {
|
||||||
|
|
||||||
PageInfo<Brand> pageInfo = brandService.findByPage(page, limit);
|
PageInfo<Brand> pageInfo = brandService.findByPage(page, limit);
|
||||||
|
|
||||||
return Result.build(pageInfo, ResultCodeEnum.SUCCESS);
|
return Result.build(pageInfo, ResultCodeEnum.SUCCESS);
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
package cn.bunny.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.bunny.common.spzx.model.dto.product.CategoryBrandDto;
|
||||||
|
import cn.bunny.common.spzx.model.entity.product.CategoryBrand;
|
||||||
|
import cn.bunny.common.spzx.model.vo.common.Result;
|
||||||
|
import cn.bunny.common.spzx.model.vo.common.ResultCodeEnum;
|
||||||
|
import cn.bunny.service.CategoryBrandService;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@Tag(name = "分类品牌列表接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/admin/product/categoryBrand")
|
||||||
|
public class CategoryBrandController {
|
||||||
|
@Autowired
|
||||||
|
private CategoryBrandService categoryBrandService;
|
||||||
|
|
||||||
|
@Operation(summary = "分类品牌条件分页查询", description = "分类品牌条件分页查询")
|
||||||
|
@GetMapping("/{page}/{limit}")
|
||||||
|
public Result findByPage(@PathVariable("page") Integer page,
|
||||||
|
@PathVariable("limit") Integer limit,
|
||||||
|
CategoryBrandDto categoryBrandDto) {
|
||||||
|
PageInfo<CategoryBrand> categoryBrandPageInfo = categoryBrandService.findByPage(page, limit,categoryBrandDto);
|
||||||
|
return Result.build(categoryBrandPageInfo, ResultCodeEnum.SUCCESS);
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,4 +17,7 @@ public interface BrandMapper {
|
||||||
|
|
||||||
// 删除品牌
|
// 删除品牌
|
||||||
void deleteById(Integer id);
|
void deleteById(Integer id);
|
||||||
|
|
||||||
|
// 查询所有品牌
|
||||||
|
List<Brand> findAll();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package cn.bunny.mapper;
|
||||||
|
|
||||||
|
import cn.bunny.common.spzx.model.dto.product.CategoryBrandDto;
|
||||||
|
import cn.bunny.common.spzx.model.entity.product.CategoryBrand;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface CategoryBrandMapper {
|
||||||
|
// 分类品牌条件分页查询
|
||||||
|
public List<CategoryBrand> findByPage(CategoryBrandDto categoryBrandDto);
|
||||||
|
}
|
|
@ -4,6 +4,8 @@ import cn.bunny.common.spzx.model.entity.product.Brand;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface BrandService {
|
public interface BrandService {
|
||||||
PageInfo<Brand> findByPage(Integer page, Integer limit);
|
PageInfo<Brand> findByPage(Integer page, Integer limit);
|
||||||
|
|
||||||
|
@ -15,4 +17,7 @@ public interface BrandService {
|
||||||
|
|
||||||
// 删除品牌
|
// 删除品牌
|
||||||
void deleteById(Integer id);
|
void deleteById(Integer id);
|
||||||
|
|
||||||
|
// 查询所有品牌
|
||||||
|
List<Brand> findAll();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package cn.bunny.service;
|
||||||
|
|
||||||
|
import cn.bunny.common.spzx.model.dto.product.CategoryBrandDto;
|
||||||
|
import cn.bunny.common.spzx.model.entity.product.CategoryBrand;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
|
||||||
|
public interface CategoryBrandService {
|
||||||
|
// 分类品牌条件分页查询
|
||||||
|
PageInfo<CategoryBrand> findByPage(Integer page, Integer limit, CategoryBrandDto categoryBrandDto);
|
||||||
|
}
|
|
@ -41,4 +41,11 @@ public class BrandServiceImpl implements BrandService {
|
||||||
public void deleteById(Integer id) {
|
public void deleteById(Integer id) {
|
||||||
brandMapper.deleteById(id);
|
brandMapper.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询所有品牌
|
||||||
|
@Override
|
||||||
|
public List<Brand> findAll() {
|
||||||
|
|
||||||
|
return brandMapper.findAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package cn.bunny.service.impl;
|
||||||
|
|
||||||
|
import cn.bunny.common.spzx.model.dto.product.CategoryBrandDto;
|
||||||
|
import cn.bunny.common.spzx.model.entity.product.CategoryBrand;
|
||||||
|
import cn.bunny.mapper.CategoryBrandMapper;
|
||||||
|
import cn.bunny.service.CategoryBrandService;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CategoryBrandServiceImpl implements CategoryBrandService {
|
||||||
|
@Autowired
|
||||||
|
private CategoryBrandMapper categoryBrandMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageInfo<CategoryBrand> findByPage(Integer page,
|
||||||
|
Integer limit,
|
||||||
|
CategoryBrandDto categoryBrandDto) {
|
||||||
|
PageHelper.startPage(page, limit);
|
||||||
|
List<CategoryBrand> categoryBrandDtoList = categoryBrandMapper.findByPage(categoryBrandDto);
|
||||||
|
|
||||||
|
return new PageInfo<CategoryBrand>(categoryBrandDtoList);
|
||||||
|
}
|
||||||
|
}
|
|
@ -47,7 +47,7 @@ public class SysUserServiceImpl implements SysUserService {
|
||||||
|
|
||||||
// 比较验证码
|
// 比较验证码
|
||||||
if (StrUtil.isEmpty(redisCode) || !StrUtil.equalsIgnoreCase(redisCode, captcha)) {
|
if (StrUtil.isEmpty(redisCode) || !StrUtil.equalsIgnoreCase(redisCode, captcha)) {
|
||||||
redisTemplate.delete("user:validate" + codeKey);
|
// redisTemplate.delete("user:validate" + codeKey);
|
||||||
throw new BunnyException(ResultCodeEnum.VALIDATECODE_ERROR);
|
throw new BunnyException(ResultCodeEnum.VALIDATECODE_ERROR);
|
||||||
}
|
}
|
||||||
// 如果一致,删除Redis中验证码
|
// 如果一致,删除Redis中验证码
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class ValidateCodeServiceIImpl implements ValidateCodeService {
|
||||||
|
|
||||||
// 放到Redis
|
// 放到Redis
|
||||||
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
||||||
redisTemplate.opsForValue().set("user:validate" + uuid, code, 5, TimeUnit.MINUTES);
|
redisTemplate.opsForValue().set("user:validate" + uuid, code, 50, TimeUnit.MINUTES);
|
||||||
|
|
||||||
// 返回 validateCodeVo
|
// 返回 validateCodeVo
|
||||||
ValidateCodeVo validateCodeVo = new ValidateCodeVo();
|
ValidateCodeVo validateCodeVo = new ValidateCodeVo();
|
||||||
|
|
|
@ -43,4 +43,12 @@
|
||||||
<include refid="columns"/>
|
<include refid="columns"/>
|
||||||
from brand where is_deleted=0 order by id
|
from brand where is_deleted=0 order by id
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 查询所有品牌 -->
|
||||||
|
<select id="findAll" resultMap="brandMap">
|
||||||
|
select <include refid="columns" />
|
||||||
|
from brand
|
||||||
|
where is_deleted = 0
|
||||||
|
order by id desc
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?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.mapper.CategoryBrandMapper">
|
||||||
|
<resultMap id="categoryBrandMap" type="cn.bunny.common.spzx.model.entity.product.CategoryBrand" autoMapping="true"/>
|
||||||
|
|
||||||
|
<!-- 用于select查询公用抽取的列 -->
|
||||||
|
<sql id="columns">
|
||||||
|
id,brand_id,category_id,create_time,update_time,is_deleted
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- 分类品牌条件分页查询 -->
|
||||||
|
<select id="findByPage" resultType="cn.bunny.common.spzx.model.entity.product.CategoryBrand">
|
||||||
|
select cb.*,c.name as categoryName,b.name as brandName,b.logo
|
||||||
|
from category_brand cb
|
||||||
|
inner join category c on c.id = cb.category_id
|
||||||
|
inner join brand b on b.id = cb.brand_id
|
||||||
|
<where>
|
||||||
|
<if test="brandId != null and brandId !=''">
|
||||||
|
and cb.brand_id=#{brandId}
|
||||||
|
</if>
|
||||||
|
<if test="categoryId != null and categoryId !=''">
|
||||||
|
and cb.category_id=#{categoryId}
|
||||||
|
</if>
|
||||||
|
and cb.is_deleted=0
|
||||||
|
</where>
|
||||||
|
order by cb.id desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -10,5 +10,4 @@ public class CategoryBrandDto {
|
||||||
private Long brandId;
|
private Long brandId;
|
||||||
@Schema(description = "分类id")
|
@Schema(description = "分类id")
|
||||||
private Long categoryId;
|
private Long categoryId;
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue