feat(新增-商品管理): 添加功能
Signed-off-by: bunny <1319900154@qq.com>
This commit is contained in:
parent
3d69821e67
commit
a8ba62125f
|
@ -22,4 +22,5 @@ public class MessageConstant {
|
|||
public static final String MENU_IS_NOT_EXIST = "菜单不存在";
|
||||
public static final String SAVE_DTO_IS_NULL = "添加参数不能为空";
|
||||
public static final String UPDATE_DTO_IS_NULL = "修改参数不能为空";
|
||||
public static final String FIND_ID_IS_NOT_EMPTY = "查询ID不能为空";
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package com.atguigu.spzx.manger.controller;
|
||||
|
||||
import com.atguigu.spzx.manger.service.CategoryBrandService;
|
||||
import com.atguigu.spzx.manger.service.ProductService;
|
||||
import com.atguigu.spzx.model.dto.product.ProductDto;
|
||||
import com.atguigu.spzx.model.entity.product.Brand;
|
||||
import com.atguigu.spzx.model.entity.product.Product;
|
||||
import com.atguigu.spzx.model.vo.result.Result;
|
||||
import com.atguigu.spzx.model.vo.result.ResultCodeEnum;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
@ -13,12 +16,16 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "商品管理")
|
||||
@RestController
|
||||
@RequestMapping(value = "/admin/product/product")
|
||||
public class ProductController {
|
||||
@Autowired
|
||||
private ProductService productService;
|
||||
@Autowired
|
||||
private CategoryBrandService categoryBrandService;
|
||||
|
||||
@Operation(summary = "列表查询", description = "列表查询")
|
||||
@GetMapping("{page}/{limit}")
|
||||
|
@ -26,4 +33,11 @@ public class ProductController {
|
|||
PageInfo<Product> pageInfo = productService.findByPage(page, limit, dto);
|
||||
return Result.success(pageInfo);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加功能", description = "添加功能")
|
||||
@GetMapping("findBrandByCategoryId/{categoryId}")
|
||||
public Result<List<Brand>> findBrandByCategoryId(@PathVariable Long categoryId) {
|
||||
List<Brand> brandList = categoryBrandService.findBrandByCategoryId(categoryId);
|
||||
return Result.build(brandList, ResultCodeEnum.SUCCESS);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package com.atguigu.spzx.manger.mapper;
|
||||
|
||||
import com.atguigu.spzx.model.dto.product.CategoryBrandDto;
|
||||
import com.atguigu.spzx.model.entity.product.Brand;
|
||||
import com.atguigu.spzx.model.entity.product.CategoryBrand;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
@ -31,4 +32,12 @@ public interface CategoryBrandMapper {
|
|||
* @param id 删除的ID
|
||||
*/
|
||||
void deleteById(Long id);
|
||||
|
||||
/**
|
||||
* 添加功能
|
||||
*
|
||||
* @param categoryId 查询ID
|
||||
* @return List<Brand>
|
||||
*/
|
||||
List<Brand> findBrandByCategoryId(Long categoryId);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package com.atguigu.spzx.manger.service;
|
||||
|
||||
import com.atguigu.spzx.model.dto.product.CategoryBrandDto;
|
||||
import com.atguigu.spzx.model.entity.product.Brand;
|
||||
import com.atguigu.spzx.model.entity.product.CategoryBrand;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CategoryBrandService {
|
||||
/**
|
||||
* 分类品牌列表
|
||||
|
@ -35,4 +38,12 @@ public interface CategoryBrandService {
|
|||
* @param id 删除的ID
|
||||
*/
|
||||
void deleteById(Long id);
|
||||
|
||||
/**
|
||||
* 添加功能
|
||||
*
|
||||
* @param categoryId 查询ID
|
||||
* @return List<Brand>
|
||||
*/
|
||||
List<Brand> findBrandByCategoryId(Long categoryId);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.atguigu.exception.BunnyException;
|
|||
import com.atguigu.spzx.manger.mapper.CategoryBrandMapper;
|
||||
import com.atguigu.spzx.manger.service.CategoryBrandService;
|
||||
import com.atguigu.spzx.model.dto.product.CategoryBrandDto;
|
||||
import com.atguigu.spzx.model.entity.product.Brand;
|
||||
import com.atguigu.spzx.model.entity.product.CategoryBrand;
|
||||
import com.atguigu.utils.StringEmptyUtil;
|
||||
import com.github.pagehelper.Page;
|
||||
|
@ -76,4 +77,16 @@ public class CategoryBrandServiceImpl implements CategoryBrandService {
|
|||
emptyUtil.isEmpty(id, MessageConstant.DELETE_ID_IS_NOT_EMPTY);
|
||||
categoryBrandMapper.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加功能
|
||||
*
|
||||
* @param categoryId 查询ID
|
||||
* @return List<Brand>
|
||||
*/
|
||||
@Override
|
||||
public List<Brand> findBrandByCategoryId(Long categoryId) {
|
||||
emptyUtil.isEmpty(categoryId, MessageConstant.FIND_ID_IS_NOT_EMPTY);
|
||||
return categoryBrandMapper.findBrandByCategoryId(categoryId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,4 +53,14 @@
|
|||
</where>
|
||||
order by cb.id desc
|
||||
</select>
|
||||
|
||||
<!-- 添加功能 -->
|
||||
<select id="findBrandByCategoryId" resultType="com.atguigu.spzx.model.entity.product.Brand">
|
||||
select b.*
|
||||
from category_brand cb
|
||||
left join brand b on b.id = cb.brand_id
|
||||
where cb.category_id = #{categoryId}
|
||||
and cb.is_deleted = 0
|
||||
order by cb.id desc
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue