修改了商品类别接口

This commit is contained in:
chen-xin-zhi 2024-11-05 22:38:56 +08:00
parent 8573181ba6
commit 358245a2bb
4 changed files with 54 additions and 4 deletions

View File

@ -10,6 +10,7 @@ import com.cultural.heritage.exception.BusinessException;
import com.cultural.heritage.exception.ThrowUtils;
import com.cultural.heritage.model.dto.CommonRequest;
import com.cultural.heritage.model.dto.category.CategoryAddRequest;
import com.cultural.heritage.model.dto.category.CategoryUpdateRequest;
import com.cultural.heritage.model.entity.Category;
import com.cultural.heritage.model.entity.Good;
import com.cultural.heritage.service.good.CategoryService;
@ -88,16 +89,18 @@ public class CategoryController {
/**
* 更新商品类别
* @param category 类别更新请求体
* @param categoryUpdateRequest 类别更新请求体
* @return 是否更新成功
*/
@PostMapping("/update")
@Operation(summary = "Web端管理员更新商品类别", description = "参数:类别更新请求体,权限:管理员(admin, boss)方法名updateCategory")
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<Boolean> updateCategory(@RequestBody Category category) {
if (category == null || category.getId() <= 0) {
public BaseResponse<Boolean> updateCategory(@RequestBody CategoryUpdateRequest categoryUpdateRequest) {
if (categoryUpdateRequest == null || categoryUpdateRequest.getId() <= 0) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
Category category = new Category();
BeanUtils.copyProperties(categoryUpdateRequest, category);
categoryService.validCategory(category, false);
boolean result = categoryService.updateById(category);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);

View File

@ -96,6 +96,7 @@ public class OrderController {
*/
@PostMapping("/add")
@Transactional(rollbackFor = Exception.class)
@Operation(summary = "小程序端创建用户订单", description = "参数订单创建请求体权限所有人方法名addOrder")
public BaseResponse<Boolean> addOrder(@RequestBody OrderAddRequest orderAddRequest) {
if (orderAddRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);

View File

@ -0,0 +1,46 @@
package com.cultural.heritage.model.dto.category;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
@Schema(description = "类别更新请求体", requiredProperties = {"id", "typeName", "typeUrl", "typeIntro"})
public class CategoryUpdateRequest implements Serializable {
/**
* id
*/
@Schema(description = "商品类别id(id > 0)", example = "2")
private Long id;
/**
* 类别名称
*/
@Schema(description = "商品类别名", example = "材料包")
private String typeName;
/**
* 类别图片
*/
@Schema(description = "商品类别图片地址", example = "https://xxx/xxx.jpg")
private String typeUrl;
/**
* 类别介绍
*/
@Schema(description = "商品类别简介", example = "非遗材料包,匠心传承")
private String typeIntro;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -8,7 +8,7 @@ import java.io.Serializable;
@Data
@Schema(description = "商品添加请求体", requiredProperties = {"name", "type", "price", "goodImg", "intro",
"introDetail, detailImg", "label", "inventory", "festivalOrder"})
"introDetail", "detailImg", "label", "inventory", "festivalOrder"})
public class GoodAddRequest implements Serializable {