From 09b8120630dfaa78b7a46f06532f7b4acef00a38 Mon Sep 17 00:00:00 2001 From: bunny <1319900154@qq.com> Date: Sat, 16 Dec 2023 09:56:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=B1=BB=E5=93=81=E7=89=8C=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/bunny/controller/BranController.java | 10 ++++++ .../controller/CategoryBrandController.java | 33 +++++++++++++++++++ .../java/cn/bunny/mapper/BrandMapper.java | 3 ++ .../cn/bunny/mapper/CategoryBrandMapper.java | 13 ++++++++ .../java/cn/bunny/service/BrandService.java | 5 +++ .../bunny/service/CategoryBrandService.java | 10 ++++++ .../bunny/service/impl/BrandServiceImpl.java | 7 ++++ .../impl/CategoryBrandServiceImpl.java | 28 ++++++++++++++++ .../service/impl/SysUserServiceImpl.java | 2 +- .../impl/ValidateCodeServiceIImpl.java | 2 +- .../resources/mapper/brand/BrandMapper.xml | 8 +++++ .../mapper/brand/CategoryBrandMapper.xml | 29 ++++++++++++++++ .../model/dto/product/CategoryBrandDto.java | 1 - 13 files changed, 148 insertions(+), 3 deletions(-) create mode 100644 spzx-manager/src/main/java/cn/bunny/controller/CategoryBrandController.java create mode 100644 spzx-manager/src/main/java/cn/bunny/mapper/CategoryBrandMapper.java create mode 100644 spzx-manager/src/main/java/cn/bunny/service/CategoryBrandService.java create mode 100644 spzx-manager/src/main/java/cn/bunny/service/impl/CategoryBrandServiceImpl.java create mode 100644 spzx-manager/src/main/resources/mapper/brand/CategoryBrandMapper.xml diff --git a/spzx-manager/src/main/java/cn/bunny/controller/BranController.java b/spzx-manager/src/main/java/cn/bunny/controller/BranController.java index 3deefce..31ad346 100644 --- a/spzx-manager/src/main/java/cn/bunny/controller/BranController.java +++ b/spzx-manager/src/main/java/cn/bunny/controller/BranController.java @@ -11,6 +11,8 @@ import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.List; + @Tag(name = "商品分类") @RequestMapping("/admin/product/brand") @RestController @@ -19,9 +21,17 @@ public class BranController { @Autowired private BrandService brandService; + @Operation(summary = "查询所有品牌", description = "查询所有品牌") + @GetMapping("findAll") + public Result findAll() { + List brandList= brandService.findAll(); + return Result.build(brandList, ResultCodeEnum.SUCCESS); + } + @Operation(summary = "获取品牌列表", description = "获取品牌全部列表") @GetMapping("{page}/{limit}") public Result list(@PathVariable("page") Integer page, @PathVariable("limit") Integer limit) { + PageInfo pageInfo = brandService.findByPage(page, limit); return Result.build(pageInfo, ResultCodeEnum.SUCCESS); diff --git a/spzx-manager/src/main/java/cn/bunny/controller/CategoryBrandController.java b/spzx-manager/src/main/java/cn/bunny/controller/CategoryBrandController.java new file mode 100644 index 0000000..862e4b0 --- /dev/null +++ b/spzx-manager/src/main/java/cn/bunny/controller/CategoryBrandController.java @@ -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 categoryBrandPageInfo = categoryBrandService.findByPage(page, limit,categoryBrandDto); + return Result.build(categoryBrandPageInfo, ResultCodeEnum.SUCCESS); + } +} diff --git a/spzx-manager/src/main/java/cn/bunny/mapper/BrandMapper.java b/spzx-manager/src/main/java/cn/bunny/mapper/BrandMapper.java index 0d66aab..e34fbeb 100644 --- a/spzx-manager/src/main/java/cn/bunny/mapper/BrandMapper.java +++ b/spzx-manager/src/main/java/cn/bunny/mapper/BrandMapper.java @@ -17,4 +17,7 @@ public interface BrandMapper { // 删除品牌 void deleteById(Integer id); + + // 查询所有品牌 + List findAll(); } diff --git a/spzx-manager/src/main/java/cn/bunny/mapper/CategoryBrandMapper.java b/spzx-manager/src/main/java/cn/bunny/mapper/CategoryBrandMapper.java new file mode 100644 index 0000000..bb1c41c --- /dev/null +++ b/spzx-manager/src/main/java/cn/bunny/mapper/CategoryBrandMapper.java @@ -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 findByPage(CategoryBrandDto categoryBrandDto); +} diff --git a/spzx-manager/src/main/java/cn/bunny/service/BrandService.java b/spzx-manager/src/main/java/cn/bunny/service/BrandService.java index 896cc79..377541b 100644 --- a/spzx-manager/src/main/java/cn/bunny/service/BrandService.java +++ b/spzx-manager/src/main/java/cn/bunny/service/BrandService.java @@ -4,6 +4,8 @@ import cn.bunny.common.spzx.model.entity.product.Brand; import com.github.pagehelper.PageInfo; import org.springframework.stereotype.Service; +import java.util.List; + public interface BrandService { PageInfo findByPage(Integer page, Integer limit); @@ -15,4 +17,7 @@ public interface BrandService { // 删除品牌 void deleteById(Integer id); + + // 查询所有品牌 + List findAll(); } diff --git a/spzx-manager/src/main/java/cn/bunny/service/CategoryBrandService.java b/spzx-manager/src/main/java/cn/bunny/service/CategoryBrandService.java new file mode 100644 index 0000000..febc00e --- /dev/null +++ b/spzx-manager/src/main/java/cn/bunny/service/CategoryBrandService.java @@ -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 findByPage(Integer page, Integer limit, CategoryBrandDto categoryBrandDto); +} diff --git a/spzx-manager/src/main/java/cn/bunny/service/impl/BrandServiceImpl.java b/spzx-manager/src/main/java/cn/bunny/service/impl/BrandServiceImpl.java index 3c8dcb6..b01c1ee 100644 --- a/spzx-manager/src/main/java/cn/bunny/service/impl/BrandServiceImpl.java +++ b/spzx-manager/src/main/java/cn/bunny/service/impl/BrandServiceImpl.java @@ -41,4 +41,11 @@ public class BrandServiceImpl implements BrandService { public void deleteById(Integer id) { brandMapper.deleteById(id); } + + // 查询所有品牌 + @Override + public List findAll() { + + return brandMapper.findAll(); + } } diff --git a/spzx-manager/src/main/java/cn/bunny/service/impl/CategoryBrandServiceImpl.java b/spzx-manager/src/main/java/cn/bunny/service/impl/CategoryBrandServiceImpl.java new file mode 100644 index 0000000..ddd6c54 --- /dev/null +++ b/spzx-manager/src/main/java/cn/bunny/service/impl/CategoryBrandServiceImpl.java @@ -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 findByPage(Integer page, + Integer limit, + CategoryBrandDto categoryBrandDto) { + PageHelper.startPage(page, limit); + List categoryBrandDtoList = categoryBrandMapper.findByPage(categoryBrandDto); + + return new PageInfo(categoryBrandDtoList); + } +} diff --git a/spzx-manager/src/main/java/cn/bunny/service/impl/SysUserServiceImpl.java b/spzx-manager/src/main/java/cn/bunny/service/impl/SysUserServiceImpl.java index 5c7d64d..d96eb2a 100644 --- a/spzx-manager/src/main/java/cn/bunny/service/impl/SysUserServiceImpl.java +++ b/spzx-manager/src/main/java/cn/bunny/service/impl/SysUserServiceImpl.java @@ -47,7 +47,7 @@ public class SysUserServiceImpl implements SysUserService { // 比较验证码 if (StrUtil.isEmpty(redisCode) || !StrUtil.equalsIgnoreCase(redisCode, captcha)) { - redisTemplate.delete("user:validate" + codeKey); + // redisTemplate.delete("user:validate" + codeKey); throw new BunnyException(ResultCodeEnum.VALIDATECODE_ERROR); } // 如果一致,删除Redis中验证码 diff --git a/spzx-manager/src/main/java/cn/bunny/service/impl/ValidateCodeServiceIImpl.java b/spzx-manager/src/main/java/cn/bunny/service/impl/ValidateCodeServiceIImpl.java index 2c39c4c..68a520e 100644 --- a/spzx-manager/src/main/java/cn/bunny/service/impl/ValidateCodeServiceIImpl.java +++ b/spzx-manager/src/main/java/cn/bunny/service/impl/ValidateCodeServiceIImpl.java @@ -26,7 +26,7 @@ public class ValidateCodeServiceIImpl implements ValidateCodeService { // 放到Redis 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 = new ValidateCodeVo(); diff --git a/spzx-manager/src/main/resources/mapper/brand/BrandMapper.xml b/spzx-manager/src/main/resources/mapper/brand/BrandMapper.xml index 70c9e17..02f879d 100644 --- a/spzx-manager/src/main/resources/mapper/brand/BrandMapper.xml +++ b/spzx-manager/src/main/resources/mapper/brand/BrandMapper.xml @@ -43,4 +43,12 @@ from brand where is_deleted=0 order by id + + + diff --git a/spzx-manager/src/main/resources/mapper/brand/CategoryBrandMapper.xml b/spzx-manager/src/main/resources/mapper/brand/CategoryBrandMapper.xml new file mode 100644 index 0000000..25400e6 --- /dev/null +++ b/spzx-manager/src/main/resources/mapper/brand/CategoryBrandMapper.xml @@ -0,0 +1,29 @@ + + + + + + + + id,brand_id,category_id,create_time,update_time,is_deleted + + + + + + diff --git a/spzx-model/src/main/java/cn/bunny/common/spzx/model/dto/product/CategoryBrandDto.java b/spzx-model/src/main/java/cn/bunny/common/spzx/model/dto/product/CategoryBrandDto.java index f9e854d..4d065ff 100644 --- a/spzx-model/src/main/java/cn/bunny/common/spzx/model/dto/product/CategoryBrandDto.java +++ b/spzx-model/src/main/java/cn/bunny/common/spzx/model/dto/product/CategoryBrandDto.java @@ -10,5 +10,4 @@ public class CategoryBrandDto { private Long brandId; @Schema(description = "分类id") private Long categoryId; - } \ No newline at end of file