From 9c250566cf2f8dd0cd95704039a477953ec04358 Mon Sep 17 00:00:00 2001 From: chen-xin-zhi <3588068430@qq.com> Date: Tue, 29 Oct 2024 19:28:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BA=86=E5=9F=BA=E6=9C=AC?= =?UTF-8?q?=E7=9A=84=E5=95=86=E5=93=81=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operategood/CategoryController.java | 16 ++++++++ .../operategood/GoodController.java | 22 ++++++++++- .../heritage/mapper/CategoryMapper.java | 8 ++++ .../model/dto/CommonDelBatchRequest.java | 16 ++++++++ .../model/dto/good/GoodAddRequest.java | 5 +++ .../model/dto/good/GoodQueryRequest.java | 5 +++ .../model/dto/good/GoodUpdateRequest.java | 5 +++ .../heritage/model/entity/Category.java | 39 +++++++++++++++++++ .../cultural/heritage/model/entity/Good.java | 5 +++ .../service/operategood/CategoryService.java | 9 +++++ .../operategood/impl/CategoryServiceImpl.java | 11 ++++++ .../operategood/impl/GoodServiceImpl.java | 2 + src/main/resources/mapper/CategoryMapper.xml | 7 ++++ 13 files changed, 148 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/cultural/heritage/controller/operategood/CategoryController.java create mode 100644 src/main/java/com/cultural/heritage/mapper/CategoryMapper.java create mode 100644 src/main/java/com/cultural/heritage/model/dto/CommonDelBatchRequest.java create mode 100644 src/main/java/com/cultural/heritage/model/entity/Category.java create mode 100644 src/main/java/com/cultural/heritage/service/operategood/CategoryService.java create mode 100644 src/main/java/com/cultural/heritage/service/operategood/impl/CategoryServiceImpl.java create mode 100644 src/main/resources/mapper/CategoryMapper.xml diff --git a/src/main/java/com/cultural/heritage/controller/operategood/CategoryController.java b/src/main/java/com/cultural/heritage/controller/operategood/CategoryController.java new file mode 100644 index 0000000..9999486 --- /dev/null +++ b/src/main/java/com/cultural/heritage/controller/operategood/CategoryController.java @@ -0,0 +1,16 @@ +package com.cultural.heritage.controller.operategood; + + +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/category") +@Slf4j +@Tag(name = "商品类别接口") +public class CategoryController { + + +} diff --git a/src/main/java/com/cultural/heritage/controller/operategood/GoodController.java b/src/main/java/com/cultural/heritage/controller/operategood/GoodController.java index 9f16647..ddc15d9 100644 --- a/src/main/java/com/cultural/heritage/controller/operategood/GoodController.java +++ b/src/main/java/com/cultural/heritage/controller/operategood/GoodController.java @@ -3,11 +3,14 @@ package com.cultural.heritage.controller.operategood; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.cultural.heritage.annotation.AuthCheck; import com.cultural.heritage.common.BaseResponse; import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ResultUtils; +import com.cultural.heritage.constant.UserConstant; import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.ThrowUtils; +import com.cultural.heritage.model.dto.CommonDelBatchRequest; import com.cultural.heritage.model.dto.CommonRequest; import com.cultural.heritage.model.dto.good.GoodAddRequest; import com.cultural.heritage.model.dto.good.GoodQueryRequest; @@ -23,6 +26,8 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + /** * 商品接口 @@ -112,9 +117,22 @@ public class GoodController { } -// @PostMapping("/delBatch") + + /** + * 批量删除商品 + * @param commonDelBatchRequest 批量删除请求体 + * @return 是否批量删除成功 + */ + @PostMapping("/delBatch") // @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) -// public BaseResponse delBatchGoods(List ) + public BaseResponse delBatchGoods(@RequestBody CommonDelBatchRequest commonDelBatchRequest) { + List idList = commonDelBatchRequest.getIdList(); + boolean result = goodService.removeBatchByIds(idList); + ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR); + return ResultUtils.success(true); + } + + } diff --git a/src/main/java/com/cultural/heritage/mapper/CategoryMapper.java b/src/main/java/com/cultural/heritage/mapper/CategoryMapper.java new file mode 100644 index 0000000..251bd52 --- /dev/null +++ b/src/main/java/com/cultural/heritage/mapper/CategoryMapper.java @@ -0,0 +1,8 @@ +package com.cultural.heritage.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.cultural.heritage.model.entity.Category; + +public interface CategoryMapper extends BaseMapper { + +} diff --git a/src/main/java/com/cultural/heritage/model/dto/CommonDelBatchRequest.java b/src/main/java/com/cultural/heritage/model/dto/CommonDelBatchRequest.java new file mode 100644 index 0000000..83093cb --- /dev/null +++ b/src/main/java/com/cultural/heritage/model/dto/CommonDelBatchRequest.java @@ -0,0 +1,16 @@ +package com.cultural.heritage.model.dto; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.List; + +@Data +public class CommonDelBatchRequest implements Serializable { + + private List idList; + + @Serial + private static final long serialVersionUID = 1L; +} diff --git a/src/main/java/com/cultural/heritage/model/dto/good/GoodAddRequest.java b/src/main/java/com/cultural/heritage/model/dto/good/GoodAddRequest.java index 28f49c5..bc107ff 100644 --- a/src/main/java/com/cultural/heritage/model/dto/good/GoodAddRequest.java +++ b/src/main/java/com/cultural/heritage/model/dto/good/GoodAddRequest.java @@ -21,6 +21,11 @@ public class GoodAddRequest implements Serializable { */ private String type; + /** + * 商品价格 + */ + private Double price; + /** * 商品图片 */ diff --git a/src/main/java/com/cultural/heritage/model/dto/good/GoodQueryRequest.java b/src/main/java/com/cultural/heritage/model/dto/good/GoodQueryRequest.java index 323481c..c3b9075 100644 --- a/src/main/java/com/cultural/heritage/model/dto/good/GoodQueryRequest.java +++ b/src/main/java/com/cultural/heritage/model/dto/good/GoodQueryRequest.java @@ -29,6 +29,11 @@ public class GoodQueryRequest extends PageRequest implements Serializable { */ private Integer festivalOrder; + /** + * 是否上架 + */ + private Integer isShelves; + @TableField(exist = false) private static final long serialVersionUID = 1L; diff --git a/src/main/java/com/cultural/heritage/model/dto/good/GoodUpdateRequest.java b/src/main/java/com/cultural/heritage/model/dto/good/GoodUpdateRequest.java index 1e6b46a..a3a8235 100644 --- a/src/main/java/com/cultural/heritage/model/dto/good/GoodUpdateRequest.java +++ b/src/main/java/com/cultural/heritage/model/dto/good/GoodUpdateRequest.java @@ -23,6 +23,11 @@ public class GoodUpdateRequest implements Serializable { */ private String type; + /** + * 商品价格 + */ + private Double price; + /** * 商品图片 */ diff --git a/src/main/java/com/cultural/heritage/model/entity/Category.java b/src/main/java/com/cultural/heritage/model/entity/Category.java new file mode 100644 index 0000000..c3867bb --- /dev/null +++ b/src/main/java/com/cultural/heritage/model/entity/Category.java @@ -0,0 +1,39 @@ +package com.cultural.heritage.model.entity; + + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +@Data +public class Category implements Serializable { + + + /** + * id + */ + private Integer id; + + + /** + * 类别名称 + */ + private String typeName; + + + /** + * 类别图片 + */ + private String typeUrl; + + + /** + * 类别介绍 + */ + private String typeInfo; + + + @Serial + private static final long serialVersionUID = 1L; +} diff --git a/src/main/java/com/cultural/heritage/model/entity/Good.java b/src/main/java/com/cultural/heritage/model/entity/Good.java index 6259722..7077413 100644 --- a/src/main/java/com/cultural/heritage/model/entity/Good.java +++ b/src/main/java/com/cultural/heritage/model/entity/Good.java @@ -27,6 +27,11 @@ public class Good { */ private String type; + /** + * 商品价格 + */ + private Double price; + /** * 商品图片 */ diff --git a/src/main/java/com/cultural/heritage/service/operategood/CategoryService.java b/src/main/java/com/cultural/heritage/service/operategood/CategoryService.java new file mode 100644 index 0000000..25e0250 --- /dev/null +++ b/src/main/java/com/cultural/heritage/service/operategood/CategoryService.java @@ -0,0 +1,9 @@ +package com.cultural.heritage.service.operategood; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.cultural.heritage.model.entity.Category; + + +public interface CategoryService extends IService { + +} diff --git a/src/main/java/com/cultural/heritage/service/operategood/impl/CategoryServiceImpl.java b/src/main/java/com/cultural/heritage/service/operategood/impl/CategoryServiceImpl.java new file mode 100644 index 0000000..ff6cef5 --- /dev/null +++ b/src/main/java/com/cultural/heritage/service/operategood/impl/CategoryServiceImpl.java @@ -0,0 +1,11 @@ +package com.cultural.heritage.service.operategood.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.cultural.heritage.mapper.CategoryMapper; +import com.cultural.heritage.model.entity.Category; +import com.cultural.heritage.service.operategood.CategoryService; +import org.springframework.stereotype.Service; + +@Service +public class CategoryServiceImpl extends ServiceImpl implements CategoryService { +} diff --git a/src/main/java/com/cultural/heritage/service/operategood/impl/GoodServiceImpl.java b/src/main/java/com/cultural/heritage/service/operategood/impl/GoodServiceImpl.java index 2ebf2c5..f3492fc 100644 --- a/src/main/java/com/cultural/heritage/service/operategood/impl/GoodServiceImpl.java +++ b/src/main/java/com/cultural/heritage/service/operategood/impl/GoodServiceImpl.java @@ -26,6 +26,7 @@ public class GoodServiceImpl extends ServiceImpl implements Go String name = goodQueryRequest.getName(); String type = goodQueryRequest.getType(); Integer festivalOrder = goodQueryRequest.getFestivalOrder(); + Integer isShelves = goodQueryRequest.getIsShelves(); String sortField = goodQueryRequest.getSortField(); String sortOrder = goodQueryRequest.getSortOrder(); @@ -34,6 +35,7 @@ public class GoodServiceImpl extends ServiceImpl implements Go queryWrapper.eq(StringUtils.isNotBlank(name), "name", name); queryWrapper.eq(StringUtils.isNotBlank(type), "type", type); queryWrapper.eq(festivalOrder != null, "festivalOrder", festivalOrder); + queryWrapper.eq(isShelves != null, "isShelves", isShelves); queryWrapper.orderBy(SqlUtils.validSortField(sortField), sortOrder.equals(CommonConstant.SORT_ORDER_ASC), sortField); return queryWrapper; diff --git a/src/main/resources/mapper/CategoryMapper.xml b/src/main/resources/mapper/CategoryMapper.xml new file mode 100644 index 0000000..88ce537 --- /dev/null +++ b/src/main/resources/mapper/CategoryMapper.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file