Ver Fonte

Merge remote-tracking branch 'origin/liude' into V1.0.1

# Conflicts:
#	vehicle-api/src/main/java/com/chelvc/cloud/vehicle/api/param/CouponModifyParam.java
#	vehicle-api/src/main/java/com/chelvc/cloud/vehicle/api/param/CouponPagingParam.java
#	vehicle-api/src/main/java/com/chelvc/cloud/vehicle/api/service/CouponService.java
#	vehicle-server/src/main/java/com/chelvc/cloud/vehicle/server/copier/CouponCopier.java
#	vehicle-server/src/main/java/com/chelvc/cloud/vehicle/server/service/CouponService.java
#	vehicle-server/src/main/java/com/chelvc/cloud/vehicle/server/service/impl/CouponServiceImpl.java
qizai há 1 ano atrás
pai
commit
0cd590fa04

+ 0 - 1
vehicle-api/src/main/java/com/chelvc/cloud/vehicle/api/constant/FavoriteType.java

@@ -15,7 +15,6 @@ public enum FavoriteType implements Enumeration {
      * 商家
      */
     MERCHANT("商家");
-
     /**
      * 类型描述
      */

+ 0 - 9
vehicle-api/src/main/java/com/chelvc/cloud/vehicle/api/dto/GoodsDTO.java

@@ -93,13 +93,4 @@ public class GoodsDTO implements Serializable {
      */
     private GoodsStatus status;
 
-    /**
-     * 创建用户
-     */
-    private Long creator;
-
-    /**
-     * 创建时间
-     */
-    private Date createTime;
 }

+ 94 - 0
vehicle-api/src/main/java/com/chelvc/cloud/vehicle/api/param/GoodsModifyParam.java

@@ -0,0 +1,94 @@
+package com.chelvc.cloud.vehicle.api.param;
+import com.chelvc.cloud.vehicle.api.constant.CategoryType;
+import com.chelvc.cloud.vehicle.api.constant.GoodsStatus;
+import com.chelvc.framework.common.model.File;
+import lombok.*;
+import lombok.experimental.SuperBuilder;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.Size;
+import java.util.List;
+
+/**
+ * 商品数据模型
+ *
+ * @author liude
+ * @date 2023/8/30
+ */
+@Data
+@SuperBuilder
+@NoArgsConstructor
+@AllArgsConstructor
+@ToString(callSuper = true)
+public class GoodsModifyParam {
+
+    /**
+     * 分类类型
+     */
+    @NotEmpty(message = "分类类型不能为空")
+    @Size(max = 100, message = "分类类型长度不能大于50")
+    private CategoryType type;
+
+    /**
+     * 分类ID
+     */
+    @NotEmpty(message = "分类ID不能为空")
+    @Size(max = 100, message = "分类ID长度不能大于20")
+    private Long categoryId;
+
+    /**
+     * 商家ID
+     */
+    @NotEmpty(message = "商家ID不能为空")
+    private Long merchantId;
+
+    /**
+     * 商品名称
+     */
+    @NotEmpty(message = "商品名称不能为空")
+    @Size(max = 100, message = "商品名称长度不能大于100")
+    private String name;
+
+    /**
+     * 商品Logo
+     */
+    @Size(max = 200, message = "商品Logo长度不能大于200")
+    private String logo;
+
+    /**
+     * 轮播图列表
+     */
+    private List<File> banners;
+
+    /**
+     * 商品描述
+     */
+    @NotEmpty(message = "商品描述不能为空")
+    @Size(max = 100, message = "商品描述长度不能大于500")
+    private String description;
+
+    /**
+     * 商品原价
+     */
+    @NotEmpty(message = "商品原价不能为空")
+    @Size(max = 100, message = "商品原价长度不能大于10")
+    private Double originalPrice;
+
+    /**
+     * 优惠价格
+     */
+    @NotEmpty(message = "优惠价格不能为空")
+    @Size(max = 100, message = "优惠价格长度不能大于10")
+    private Double specialPrice;
+
+    /**
+     * 优惠券ID列表
+     */
+    private List<Long> couponIds;
+
+    /**
+     * 商品状态
+     */
+    @NotEmpty(message = "商品状态不能为空")
+    private GoodsStatus status;
+}

+ 4 - 0
vehicle-api/src/main/java/com/chelvc/cloud/vehicle/api/param/GoodsPagingParam.java

@@ -34,6 +34,10 @@ public class GoodsPagingParam implements Serializable {
     @Size(max = 100, message = "商品名称长度不能大于100")
     private String name;
 
+    /**
+     * 分类ID
+     */
+    private Long categoryId;
     /**
      * 商品状态
      */

+ 8 - 0
vehicle-api/src/main/java/com/chelvc/cloud/vehicle/api/service/CategoryService.java

@@ -52,4 +52,12 @@ public interface CategoryService {
      * @return 分类信息列表
      */
     List<CategoryDTO> listRecommendCategories(int size);
+
+
+    /**
+     * 删除分类
+     *
+     * @param id    分类主键
+     */
+    void deleteCategory(Long id);
 }

+ 34 - 3
vehicle-api/src/main/java/com/chelvc/cloud/vehicle/api/service/GoodsService.java

@@ -1,10 +1,9 @@
 package com.chelvc.cloud.vehicle.api.service;
-
 import java.util.List;
-
 import com.chelvc.cloud.vehicle.api.dto.GoodsDTO;
 import com.chelvc.cloud.vehicle.api.dto.GoodsDetailDTO;
-import com.chelvc.cloud.vehicle.api.param.GoodsQueryParam;
+import com.chelvc.cloud.vehicle.api.param.*;
+import com.chelvc.framework.common.model.Pagination;
 
 /**
  * 商品业务接口
@@ -29,4 +28,36 @@ public interface GoodsService {
      * @return 商品列表
      */
     List<GoodsDTO> listMerchantSimpleGoods(Long merchantId, GoodsQueryParam param);
+
+
+    /**
+     * 新增商品
+     *
+     * @param param 新增参数
+     * @return 商品主键
+     */
+    Long addGoods(GoodsModifyParam param);
+
+    /**
+     * 修改商品
+     *
+     * @param id    商品主键
+     * @param param 修改参数
+     */
+    void updateGoods(Long id, GoodsModifyParam param);
+
+    /**
+     * 删除商品
+     *
+     * @param id    商品主键
+     */
+    void deleteGoods(Long id);
+
+    /**
+     * 查询商品
+     *
+     * @param param 查询参数
+     * @return 商品分页信息
+     */
+    Pagination<GoodsDTO> getGoodsPaging(GoodsPagingParam param);
 }

+ 7 - 0
vehicle-api/src/main/java/com/chelvc/cloud/vehicle/api/service/MerchantService.java

@@ -76,6 +76,13 @@ public interface MerchantService {
      */
     void updateMerchant(Long id, MerchantModifyParam param);
 
+    /**
+     * 删除商家
+     *
+     * @param id    分类主键
+     */
+    void deleteMerchant(Long id);
+
     /**
      * 查询商家
      *

+ 34 - 1
vehicle-server/src/main/java/com/chelvc/cloud/vehicle/server/copier/GoodsCopier.java

@@ -1,11 +1,19 @@
 package com.chelvc.cloud.vehicle.server.copier;
 
+import com.chelvc.cloud.vehicle.api.dto.CouponDTO;
 import com.chelvc.cloud.vehicle.api.dto.GoodsDTO;
+import com.chelvc.cloud.vehicle.api.param.CouponModifyParam;
+import com.chelvc.cloud.vehicle.api.param.GoodsModifyParam;
+import com.chelvc.cloud.vehicle.server.entity.Coupon;
 import com.chelvc.cloud.vehicle.server.entity.Goods;
 import org.mapstruct.Builder;
 import org.mapstruct.Mapper;
+import org.mapstruct.MappingTarget;
 import org.mapstruct.factory.Mappers;
 
+import java.util.Collection;
+import java.util.List;
+
 /**
  * 商品信息拷贝接口
  *
@@ -22,8 +30,33 @@ public interface GoodsCopier {
     /**
      * 商品信息拷贝
      *
-     * @param detail 商品详情
+     * @param goods 商品详情
      * @return 商品信息
      */
     GoodsDTO copying(Goods goods);
+
+
+    /**
+     * 商品信息拷贝
+     *
+     * @param goods 商品信息集合
+     * @return 商品信息列表
+     */
+    List<GoodsDTO> copying(Collection<Goods> goods);
+
+    /**
+     * 商品信息拷贝
+     *
+     * @param param 商品更新参数
+     * @return 商品信息
+     */
+    Goods copying(GoodsModifyParam param);
+
+    /**
+     * 商品信息拷贝
+     *
+     * @param param    商品更新参数
+     * @param  goods 商品信息
+     */
+    void copying( GoodsModifyParam param, @MappingTarget Goods goods);
 }

+ 2 - 0
vehicle-server/src/main/java/com/chelvc/cloud/vehicle/server/entity/Category.java

@@ -3,6 +3,7 @@ package com.chelvc.cloud.vehicle.server.entity;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.chelvc.cloud.vehicle.api.constant.CategoryType;
+import com.chelvc.framework.database.annotation.Unique;
 import com.chelvc.framework.database.entity.ModifyEntity;
 import lombok.AllArgsConstructor;
 import lombok.Data;
@@ -38,6 +39,7 @@ public class Category extends ModifyEntity<Long> {
     /**
      * 分类名称
      */
+    @Unique(message = "分类名称已存在")
     private String name;
 
     /**

+ 4 - 0
vehicle-server/src/main/java/com/chelvc/cloud/vehicle/server/service/impl/CategoryServiceImpl.java

@@ -67,4 +67,8 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
         List<Category> categories = this.baseMapper.listRecommendCategories(size);
         return CategoryCopier.INSTANCE.copying(categories);
     }
+    @Override
+    public void deleteCategory(Long id){
+        this.baseMapper.deleteById(id);
+    }
 }

+ 44 - 2
vehicle-server/src/main/java/com/chelvc/cloud/vehicle/server/service/impl/GoodsServiceImpl.java

@@ -2,20 +2,29 @@ package com.chelvc.cloud.vehicle.server.service.impl;
 
 import java.util.List;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.chelvc.cloud.vehicle.api.constant.CategoryType;
+import com.chelvc.cloud.vehicle.api.constant.GoodsStatus;
+import com.chelvc.cloud.vehicle.api.constant.MerchantStatus;
+import com.chelvc.cloud.vehicle.api.dto.CouponDTO;
 import com.chelvc.cloud.vehicle.api.dto.GoodsDTO;
 import com.chelvc.cloud.vehicle.api.dto.GoodsDetailDTO;
-import com.chelvc.cloud.vehicle.api.param.CommentQueryParam;
-import com.chelvc.cloud.vehicle.api.param.GoodsQueryParam;
+import com.chelvc.cloud.vehicle.api.param.*;
+import com.chelvc.cloud.vehicle.server.copier.CouponCopier;
 import com.chelvc.cloud.vehicle.server.copier.GoodsCopier;
 import com.chelvc.cloud.vehicle.server.dao.GoodsMapper;
+import com.chelvc.cloud.vehicle.server.entity.Coupon;
 import com.chelvc.cloud.vehicle.server.entity.Goods;
 import com.chelvc.cloud.vehicle.server.service.CommentService;
 import com.chelvc.cloud.vehicle.server.service.CouponService;
 import com.chelvc.cloud.vehicle.server.service.GoodsService;
 import com.chelvc.framework.base.context.SessionContextHolder;
 import com.chelvc.framework.base.util.ResourceUtils;
+import com.chelvc.framework.common.model.Pagination;
+import com.chelvc.framework.common.util.StringUtils;
+import com.chelvc.framework.database.context.DatabaseContextHolder;
+import com.chelvc.framework.database.util.PagingUtils;
 import lombok.NonNull;
 import lombok.RequiredArgsConstructor;
 import org.apache.dubbo.config.annotation.DubboService;
@@ -68,4 +77,37 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
     public List<GoodsDTO> listMerchantSimpleGoods(@NonNull Long merchantId, @NonNull GoodsQueryParam param) {
         return this.baseMapper.listMerchantSimpleGoods(merchantId, param);
     }
+
+
+
+    @Override
+    public Long addGoods(GoodsModifyParam param){
+        Goods goods = GoodsCopier.INSTANCE.copying(param);
+        goods.setScore(0D);
+        goods.setSale(0);
+        goods.setStatus(GoodsStatus.ONLINE);
+        this.save(goods);
+        return goods.getId();
+    }
+
+    @Override
+    public void updateGoods(@NonNull Long id, @NonNull GoodsModifyParam param) {
+        Goods goods = ResourceUtils.required(this.getById(id), "商品不存在");
+        GoodsCopier.INSTANCE.copying(param, goods);
+        this.updateById(goods);
+    }
+
+    @Override
+    public void deleteGoods(@NonNull Long id) {
+        ResourceUtils.required(this.getById(id), "商品不存在");
+        this.baseMapper.deleteById(id);
+    }
+
+    @Override
+    public Pagination<GoodsDTO> getGoodsPaging(@NonNull GoodsPagingParam param) {
+        Page<Goods> page = this.lambdaQuery()
+                .like(StringUtils.nonEmpty(param.getName()), Goods::getName, param.getName())
+                .orderByAsc(Goods::getStatus).page(PagingUtils.convert(param.getPaging()));
+        return PagingUtils.convert(page, GoodsCopier.INSTANCE::copying);
+    }
 }

+ 6 - 0
vehicle-server/src/main/java/com/chelvc/cloud/vehicle/server/service/impl/MerchantServiceImpl.java

@@ -113,6 +113,12 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> i
         this.updateById(merchant);
     }
 
+    @Override
+    public void deleteMerchant(@NonNull Long id) {
+         ResourceUtils.required(this.getById(id), "商家不存在");
+        this.baseMapper.deleteById(id);
+    }
+
     @Override
     public Pagination<MerchantDTO> getMerchantPaging(@NonNull MerchantPagingParam param) {
         Page<Merchant> page = this.lambdaQuery()

+ 0 - 1
vehicle-server/src/main/resources/logback-spring.xml

@@ -34,7 +34,6 @@
 
 	<root level="info">
 		<appender-ref ref="CONSOLE_APPENDER"/>
-		<appender-ref ref="FILE_APPENDER"/>
 		<appender-ref ref="ASYNC_FILE_APPENDER"/>
 	</root>
 </configuration>