tsurumure преди 1 месец
родител
ревизия
245e6190c2
променени са 17 файла, в които са добавени 701 реда и са изтрити 234 реда
  1. 56 56
      src/main/java/com/backendsys/controller/B2c/B2cGoodCategoryController.java
  2. 16 16
      src/main/java/com/backendsys/mapper/B2c/B2cGoodCategoryMapper.java
  3. 73 73
      src/main/java/com/backendsys/mapper/B2c/B2cGoodCategoryMapper.xml
  4. 58 0
      src/main/java/com/backendsys/modules/b2c/good/controller/GoodCategoryController.java
  5. 1 0
      src/main/java/com/backendsys/modules/b2c/good/controller/GoodController.java
  6. 18 0
      src/main/java/com/backendsys/modules/b2c/good/dao/GoodCategoryDao.java
  7. 16 0
      src/main/java/com/backendsys/modules/b2c/good/dao/GoodCategoryI18nDao.java
  8. 48 0
      src/main/java/com/backendsys/modules/b2c/good/entity/GoodCategory.java
  9. 36 0
      src/main/java/com/backendsys/modules/b2c/good/entity/GoodCategoryI18n.java
  10. 0 1
      src/main/java/com/backendsys/modules/b2c/good/entity/GoodI18n.java
  11. 21 0
      src/main/java/com/backendsys/modules/b2c/good/service/GoodCategoryService.java
  12. 113 0
      src/main/java/com/backendsys/modules/b2c/good/service/impl/GoodCategoryServiceImpl.java
  13. 0 3
      src/main/java/com/backendsys/modules/b2c/good/service/impl/GoodServiceImpl.java
  14. 13 13
      src/main/java/com/backendsys/service/B2c/B2cGoodCategoryService.java
  15. 72 72
      src/main/java/com/backendsys/service/B2c/B2cGoodCategoryServiceImpl.java
  16. 124 0
      src/main/resources/mapper/b2c/good/GoodCategoryDao.xml
  17. 36 0
      src/main/resources/mapper/b2c/good/GoodCategoryI18nDao.xml

+ 56 - 56
src/main/java/com/backendsys/controller/B2c/B2cGoodCategoryController.java

@@ -1,56 +1,56 @@
-package com.backendsys.controller.B2c;
-
-import com.backendsys.aspect.QueryNullCheck;
-import com.backendsys.aspect.QueryNullCheckAspect;
-import com.backendsys.entity.B2c.B2cGoodCategoryDTO;
-import com.backendsys.entity.PageDTO;
-import com.backendsys.service.B2c.B2cGoodCategoryService;
-import com.backendsys.utils.response.Result;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-/**
- * 商品分类
- */
-@Validated
-@RestController
-public class B2cGoodCategoryController {
-
-    @Autowired
-    private B2cGoodCategoryService b2cGoodCategoryService;
-
-    @PreAuthorize("@sr.hasPermission('11.2')")
-    @GetMapping("/api/b2c/good/getGoodCategory")
-    public Result getGoodCategory(@Validated PageDTO pageDTO, @Validated B2cGoodCategoryDTO b2cGoodCategoryDTO) {
-        return Result.success(b2cGoodCategoryService.queryGoodCategoryList(pageDTO.getPage_num(), pageDTO.getPage_size(), b2cGoodCategoryDTO));
-    }
-
-    @PreAuthorize("@sr.hasPermission('11.2.1')")
-    @QueryNullCheck(serviceClass = B2cGoodCategoryService.class, serviceMethod = "queryGoodCategoryDetail", argField = "good_category_id", message = "商品分类不存在")
-    @GetMapping("/api/b2c/good/getGoodCategoryDetail")
-    public Result getGoodCategoryDetail(@Validated(B2cGoodCategoryDTO.Detail.class) B2cGoodCategoryDTO b2cGoodCategoryDTO) {
-        return Result.success(QueryNullCheckAspect.getQueryResult());
-    }
-
-    @PreAuthorize("@sr.hasPermission('11.2.2')")
-    @PostMapping("/api/b2c/good/createGoodCategory")
-    public Result createGoodCategory(@Validated(B2cGoodCategoryDTO.Create.class) @RequestBody B2cGoodCategoryDTO b2cGoodCategoryDTO) {
-        return Result.success(b2cGoodCategoryService.insertGoodCategory(b2cGoodCategoryDTO), "创建成功");
-    }
-
-    @PreAuthorize("@sr.hasPermission('11.2.3')")
-    @QueryNullCheck(serviceClass = B2cGoodCategoryService.class, serviceMethod = "queryGoodCategoryDetail", argField = "good_category_id", message = "商品分类不存在")
-    @PutMapping("/api/b2c/good/updateGoodCategory")
-    public Result updateGoodCategory(@Validated(B2cGoodCategoryDTO.Update.class) @RequestBody B2cGoodCategoryDTO b2cGoodCategoryDTO) {
-        return Result.success(b2cGoodCategoryService.updateGoodCategory(b2cGoodCategoryDTO), "更新成功");
-    }
-
-    @PreAuthorize("@sr.hasPermission('11.2.4')")
-    @QueryNullCheck(serviceClass = B2cGoodCategoryService.class, serviceMethod = "queryGoodCategoryDetail", argField = "good_category_id", message = "商品分类不存在")
-    @DeleteMapping("/api/b2c/good/deleteGoodCategory")
-    public Result deleteGoodCategory(@Validated(B2cGoodCategoryDTO.Delete.class) @RequestBody B2cGoodCategoryDTO b2cGoodCategoryDTO) {
-        return Result.success(b2cGoodCategoryService.deleteGoodCategory(b2cGoodCategoryDTO), "删除成功");
-    }
-}
+//package com.backendsys.controller.B2c;
+//
+//import com.backendsys.aspect.QueryNullCheck;
+//import com.backendsys.aspect.QueryNullCheckAspect;
+//import com.backendsys.entity.B2c.B2cGoodCategoryDTO;
+//import com.backendsys.entity.PageDTO;
+//import com.backendsys.service.B2c.B2cGoodCategoryService;
+//import com.backendsys.utils.response.Result;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.security.access.prepost.PreAuthorize;
+//import org.springframework.validation.annotation.Validated;
+//import org.springframework.web.bind.annotation.*;
+//
+///**
+// * 商品分类
+// */
+//@Validated
+//@RestController
+//public class B2cGoodCategoryController {
+//
+//    @Autowired
+//    private B2cGoodCategoryService b2cGoodCategoryService;
+//
+//    @PreAuthorize("@sr.hasPermission('11.2')")
+//    @GetMapping("/api/b2c/good/getGoodCategory")
+//    public Result getGoodCategory(@Validated PageDTO pageDTO, @Validated B2cGoodCategoryDTO b2cGoodCategoryDTO) {
+//        return Result.success(b2cGoodCategoryService.queryGoodCategoryList(pageDTO.getPage_num(), pageDTO.getPage_size(), b2cGoodCategoryDTO));
+//    }
+//
+//    @PreAuthorize("@sr.hasPermission('11.2.1')")
+//    @QueryNullCheck(serviceClass = B2cGoodCategoryService.class, serviceMethod = "queryGoodCategoryDetail", argField = "good_category_id", message = "商品分类不存在")
+//    @GetMapping("/api/b2c/good/getGoodCategoryDetail")
+//    public Result getGoodCategoryDetail(@Validated(B2cGoodCategoryDTO.Detail.class) B2cGoodCategoryDTO b2cGoodCategoryDTO) {
+//        return Result.success(QueryNullCheckAspect.getQueryResult());
+//    }
+//
+//    @PreAuthorize("@sr.hasPermission('11.2.2')")
+//    @PostMapping("/api/b2c/good/createGoodCategory")
+//    public Result createGoodCategory(@Validated(B2cGoodCategoryDTO.Create.class) @RequestBody B2cGoodCategoryDTO b2cGoodCategoryDTO) {
+//        return Result.success(b2cGoodCategoryService.insertGoodCategory(b2cGoodCategoryDTO), "创建成功");
+//    }
+//
+//    @PreAuthorize("@sr.hasPermission('11.2.3')")
+//    @QueryNullCheck(serviceClass = B2cGoodCategoryService.class, serviceMethod = "queryGoodCategoryDetail", argField = "good_category_id", message = "商品分类不存在")
+//    @PutMapping("/api/b2c/good/updateGoodCategory")
+//    public Result updateGoodCategory(@Validated(B2cGoodCategoryDTO.Update.class) @RequestBody B2cGoodCategoryDTO b2cGoodCategoryDTO) {
+//        return Result.success(b2cGoodCategoryService.updateGoodCategory(b2cGoodCategoryDTO), "更新成功");
+//    }
+//
+//    @PreAuthorize("@sr.hasPermission('11.2.4')")
+//    @QueryNullCheck(serviceClass = B2cGoodCategoryService.class, serviceMethod = "queryGoodCategoryDetail", argField = "good_category_id", message = "商品分类不存在")
+//    @DeleteMapping("/api/b2c/good/deleteGoodCategory")
+//    public Result deleteGoodCategory(@Validated(B2cGoodCategoryDTO.Delete.class) @RequestBody B2cGoodCategoryDTO b2cGoodCategoryDTO) {
+//        return Result.success(b2cGoodCategoryService.deleteGoodCategory(b2cGoodCategoryDTO), "删除成功");
+//    }
+//}

+ 16 - 16
src/main/java/com/backendsys/mapper/B2c/B2cGoodCategoryMapper.java

@@ -1,16 +1,16 @@
-package com.backendsys.mapper.B2c;
-
-import com.backendsys.entity.B2c.B2cGoodCategoryDTO;
-import org.apache.ibatis.annotations.Mapper;
-
-import java.util.List;
-import java.util.Map;
-
-@Mapper
-public interface B2cGoodCategoryMapper {
-    List<Map<String, Object>> queryGoodCategoryList(B2cGoodCategoryDTO b2cGoodCategoryDTO);
-    Map<String, Object> queryGoodCategoryDetail(Long good_id);
-    long insertGoodCategory(B2cGoodCategoryDTO b2cGoodCategoryDTO);
-    long deleteGoodCategory(B2cGoodCategoryDTO b2cGoodCategoryDTO);
-    long updateGoodCategory(B2cGoodCategoryDTO b2cGoodCategoryDTO);
-}
+//package com.backendsys.mapper.B2c;
+//
+//import com.backendsys.entity.B2c.B2cGoodCategoryDTO;
+//import org.apache.ibatis.annotations.Mapper;
+//
+//import java.util.List;
+//import java.util.Map;
+//
+//@Mapper
+//public interface B2cGoodCategoryMapper {
+//    List<Map<String, Object>> queryGoodCategoryList(B2cGoodCategoryDTO b2cGoodCategoryDTO);
+//    Map<String, Object> queryGoodCategoryDetail(Long good_id);
+//    long insertGoodCategory(B2cGoodCategoryDTO b2cGoodCategoryDTO);
+//    long deleteGoodCategory(B2cGoodCategoryDTO b2cGoodCategoryDTO);
+//    long updateGoodCategory(B2cGoodCategoryDTO b2cGoodCategoryDTO);
+//}

+ 73 - 73
src/main/java/com/backendsys/mapper/B2c/B2cGoodCategoryMapper.xml

@@ -1,80 +1,80 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
-<mapper namespace="com.backendsys.mapper.B2c.B2cGoodCategoryMapper">
+<!--<?xml version="1.0" encoding="utf-8" ?>-->
+<!--<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >-->
+<!--<mapper namespace="com.backendsys.mapper.B2c.B2cGoodCategoryMapper">-->
 
-    <sql id="includeGoodsCategory">
-        gc.id,
-        gc.id good_category_id,
-        gc.category_name category_name,
-        COALESCE(gc.category_description, '') category_description,
-        COALESCE(gc.parent_id, '') parent_id,
-        COALESCE(gcp.category_name, '') parent_name,
-        gc.sort,
-        gc.status
-    </sql>
-    <resultMap id="resultMapGoodsCategory" type="java.util.LinkedHashMap">
-        <id property="id" column="id" jdbcType="BIGINT" />
-        <result property="good_category_id" column="good_category_id" javaType="java.lang.Long"/>
-        <result property="parent_id" column="parent_id"/>
-        <result property="category_name" column="category_name"/>
-        <result property="category_description" column="category_description"/>
-        <result property="sort" column="sort" javaType="java.lang.Integer" />
-        <result property="status" column="status" javaType="java.lang.Integer" />
-    </resultMap>
+<!--    <sql id="includeGoodsCategory">-->
+<!--        gc.id,-->
+<!--        gc.id good_category_id,-->
+<!--        gc.category_name category_name,-->
+<!--        COALESCE(gc.category_description, '') category_description,-->
+<!--        COALESCE(gc.parent_id, '') parent_id,-->
+<!--        COALESCE(gcp.category_name, '') parent_name,-->
+<!--        gc.sort,-->
+<!--        gc.status-->
+<!--    </sql>-->
+<!--    <resultMap id="resultMapGoodsCategory" type="java.util.LinkedHashMap">-->
+<!--        <id property="id" column="id" jdbcType="BIGINT" />-->
+<!--        <result property="good_category_id" column="good_category_id" javaType="java.lang.Long"/>-->
+<!--        <result property="parent_id" column="parent_id"/>-->
+<!--        <result property="category_name" column="category_name"/>-->
+<!--        <result property="category_description" column="category_description"/>-->
+<!--        <result property="sort" column="sort" javaType="java.lang.Integer" />-->
+<!--        <result property="status" column="status" javaType="java.lang.Integer" />-->
+<!--    </resultMap>-->
 
-    <select id="queryGoodCategoryList" resultMap="resultMapGoodsCategory">
-        SELECT
-        <include refid="includeGoodsCategory" />
-        FROM b2c_goods_category gc
-        LEFT JOIN b2c_goods_category gcp ON gc.parent_id = gcp.id
-        <where>
-            <if test="category_name != null and category_name != ''">
-                AND gc.category_name LIKE CONCAT('%', #{category_name}, '%')
-            </if>
-            <if test="status != null and status != ''">
-                AND gc.status = #{status}
-            </if>
-        </where>
-        ORDER BY gc.sort DESC
-    </select>
+<!--    <select id="queryGoodCategoryList" resultMap="resultMapGoodsCategory">-->
+<!--        SELECT-->
+<!--        <include refid="includeGoodsCategory" />-->
+<!--        FROM b2c_goods_category gc-->
+<!--        LEFT JOIN b2c_goods_category gcp ON gc.parent_id = gcp.id-->
+<!--        <where>-->
+<!--            <if test="category_name != null and category_name != ''">-->
+<!--                AND gc.category_name LIKE CONCAT('%', #{category_name}, '%')-->
+<!--            </if>-->
+<!--            <if test="status != null and status != ''">-->
+<!--                AND gc.status = #{status}-->
+<!--            </if>-->
+<!--        </where>-->
+<!--        ORDER BY gc.sort DESC-->
+<!--    </select>-->
 
-    <select id="queryGoodCategoryDetail" resultMap="resultMapGoodsCategory">
-        SELECT
-        <include refid="includeGoodsCategory" />
-        FROM b2c_goods_category gc
-        LEFT JOIN b2c_goods_category gcp ON gc.parent_id = gcp.id
-        WHERE gc.id = #{good_category_id}
-    </select>
+<!--    <select id="queryGoodCategoryDetail" resultMap="resultMapGoodsCategory">-->
+<!--        SELECT-->
+<!--        <include refid="includeGoodsCategory" />-->
+<!--        FROM b2c_goods_category gc-->
+<!--        LEFT JOIN b2c_goods_category gcp ON gc.parent_id = gcp.id-->
+<!--        WHERE gc.id = #{good_category_id}-->
+<!--    </select>-->
 
-    <insert id="insertGoodCategory" parameterType="com.backendsys.entity.B2c.B2cGoodCategoryDTO"
-        useGeneratedKeys="true" keyProperty="good_category_id">
-        INSERT INTO b2c_goods_category (category_name
-        <if test="parent_id != null and parent_id != ''">, parent_id</if>
-        <if test="category_description != null and category_description != ''">, category_description</if>
-        <if test="sort != null and sort != ''">, sort</if>
-        <if test="status != null and status != ''">, status</if>
-        )
-        VALUES (#{category_name}
-        <if test="parent_id != null and parent_id != ''">, #{parent_id}</if>
-        <if test="category_description != null and category_description != ''">, #{category_description}</if>
-        <if test="sort != null and sort != ''">, #{sort}</if>
-        <if test="status != null and status != ''">, #{status}</if>
-        )
-    </insert>
+<!--    <insert id="insertGoodCategory" parameterType="com.backendsys.entity.B2c.B2cGoodCategoryDTO"-->
+<!--        useGeneratedKeys="true" keyProperty="good_category_id">-->
+<!--        INSERT INTO b2c_goods_category (category_name-->
+<!--        <if test="parent_id != null and parent_id != ''">, parent_id</if>-->
+<!--        <if test="category_description != null and category_description != ''">, category_description</if>-->
+<!--        <if test="sort != null and sort != ''">, sort</if>-->
+<!--        <if test="status != null and status != ''">, status</if>-->
+<!--        )-->
+<!--        VALUES (#{category_name}-->
+<!--        <if test="parent_id != null and parent_id != ''">, #{parent_id}</if>-->
+<!--        <if test="category_description != null and category_description != ''">, #{category_description}</if>-->
+<!--        <if test="sort != null and sort != ''">, #{sort}</if>-->
+<!--        <if test="status != null and status != ''">, #{status}</if>-->
+<!--        )-->
+<!--    </insert>-->
 
-    <update id="updateGoodCategory" parameterType="com.backendsys.entity.B2c.B2cGoodCategoryDTO"
-        useGeneratedKeys="true" keyProperty="good_category_id">
-        UPDATE b2c_goods_category
-        SET category_name = #{category_name}
-            <if test="category_description != null and category_description != ''">, category_description = #{category_description}</if>
-            <if test="parent_id != null and parent_id != ''">, parent_id = #{parent_id}</if>
-            <if test="sort != null and sort != ''">, sort = #{sort}</if>
-            <if test="status != null and status != ''">, status = #{status}</if>
-        WHERE id = #{good_category_id}
-    </update>
+<!--    <update id="updateGoodCategory" parameterType="com.backendsys.entity.B2c.B2cGoodCategoryDTO"-->
+<!--        useGeneratedKeys="true" keyProperty="good_category_id">-->
+<!--        UPDATE b2c_goods_category-->
+<!--        SET category_name = #{category_name}-->
+<!--            <if test="category_description != null and category_description != ''">, category_description = #{category_description}</if>-->
+<!--            <if test="parent_id != null and parent_id != ''">, parent_id = #{parent_id}</if>-->
+<!--            <if test="sort != null and sort != ''">, sort = #{sort}</if>-->
+<!--            <if test="status != null and status != ''">, status = #{status}</if>-->
+<!--        WHERE id = #{good_category_id}-->
+<!--    </update>-->
 
-    <delete id="deleteGoodCategory">
-        DELETE FROM b2c_goods_category WHERE id = #{good_category_id}
-    </delete>
+<!--    <delete id="deleteGoodCategory">-->
+<!--        DELETE FROM b2c_goods_category WHERE id = #{good_category_id}-->
+<!--    </delete>-->
 
-</mapper>
+<!--</mapper>-->

+ 58 - 0
src/main/java/com/backendsys/modules/b2c/good/controller/GoodCategoryController.java

@@ -0,0 +1,58 @@
+package com.backendsys.modules.b2c.good.controller;
+
+import com.backendsys.modules.b2c.good.entity.Good;
+import com.backendsys.modules.b2c.good.entity.GoodCategory;
+import com.backendsys.modules.b2c.good.service.GoodCategoryService;
+import com.backendsys.modules.b2c.good.service.GoodService;
+import com.backendsys.modules.common.utils.Result;
+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.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+@Validated
+@RestController
+@Tag(name = "商品分类管理")
+public class GoodCategoryController {
+
+    @Autowired
+    private GoodCategoryService goodCategoryService;
+
+    @Operation(summary = "获取商品分类列表")
+    @PreAuthorize("@sr.hasPermission('11.2')")
+    @GetMapping("/api/b2c/good/getGoodCategoryList")
+    public Result getGoodCategory(@Validated GoodCategory goodCategory) {
+        return Result.success().put("data", goodCategoryService.selectGoodCategoryList(goodCategory));
+    }
+
+    @Operation(summary = "获取商品分类详情")
+    @PreAuthorize("@sr.hasPermission('11.2.1')")
+    @GetMapping("/api/b2c/good/getGoodCategoryDetail")
+    public Result getGoodCategoryDetail(@Validated(GoodCategory.Detail.class) GoodCategory goodCategory) {
+        return Result.success().put("data", goodCategoryService.selectGoodCategoryDetail(goodCategory));
+    }
+
+    @Operation(summary = "创建商品分类")
+    @PreAuthorize("@sr.hasPermission('11.2.2')")
+    @PostMapping("/api/b2c/good/createGoodCategory")
+    public Result createGoodCategory(@Validated(GoodCategory.Create.class) @RequestBody GoodCategory goodCategory) {
+        return Result.success().put("data", goodCategoryService.insertGoodCategory(goodCategory));
+    }
+
+    @Operation(summary = "编辑商品分类")
+    @PreAuthorize("@sr.hasPermission('11.2.3')")
+    @PutMapping("/api/b2c/good/updateGoodCategory")
+    public Result updateGoodCategory(@Validated(GoodCategory.Update.class) @RequestBody GoodCategory goodCategory) {
+        return Result.success().put("data", goodCategoryService.updateGoodCategory(goodCategory));
+    }
+
+    @Operation(summary = "删除商品分类")
+    @PreAuthorize("@sr.hasPermission('11.2.4')")
+    @DeleteMapping("/api/b2c/good/deleteGoodCategory")
+    public Result deleteGoodCategory(@Validated(GoodCategory.Delete.class) @RequestBody GoodCategory goodCategory) {
+        return Result.success().put("data", goodCategoryService.deleteGoodCategory(goodCategory));
+    }
+
+}

+ 1 - 0
src/main/java/com/backendsys/modules/b2c/good/controller/GoodController.java

@@ -52,4 +52,5 @@ public class GoodController {
     public Result deleteGood(@Validated(Good.Delete.class) @RequestBody Good good) {
         return Result.success().put("data", goodService.deleteGood(good));
     }
+
 }

+ 18 - 0
src/main/java/com/backendsys/modules/b2c/good/dao/GoodCategoryDao.java

@@ -0,0 +1,18 @@
+package com.backendsys.modules.b2c.good.dao;
+
+import com.backendsys.modules.b2c.good.entity.GoodCategory;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+import java.util.Map;
+
+@Mapper
+public interface GoodCategoryDao extends BaseMapper<GoodCategory> {
+
+    // 获取商品分类列表
+    List<Map<String, Object>> selectGoodCategoryList(GoodCategory goodCategory);
+    // 获取商品分类详情
+    Map<String, Object> selectGoodCategoryDetail(GoodCategory goodCategory);
+
+}

+ 16 - 0
src/main/java/com/backendsys/modules/b2c/good/dao/GoodCategoryI18nDao.java

@@ -0,0 +1,16 @@
+package com.backendsys.modules.b2c.good.dao;
+
+import com.backendsys.modules.b2c.good.entity.GoodCategoryI18n;
+import com.backendsys.modules.b2c.good.entity.GoodI18n;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+@Mapper
+public interface GoodCategoryI18nDao extends BaseMapper<GoodCategoryI18n> {
+
+    int insertBatch(List<GoodCategoryI18n> translations);
+    int updateBatch(List<GoodCategoryI18n> translations);
+
+}

+ 48 - 0
src/main/java/com/backendsys/modules/b2c/good/entity/GoodCategory.java

@@ -0,0 +1,48 @@
+package com.backendsys.modules.b2c.good.entity;
+
+import com.backendsys.entity.validator.RangeArray;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+import org.hibernate.validator.constraints.Range;
+
+import java.util.List;
+
+@Data
+@TableName("b2c_good_category")
+public class GoodCategory {
+    public static interface Detail{}
+    public static interface Create{}
+    public static interface Update{}
+    public static interface Delete{}
+
+    @TableField(exist = false)
+    private String lang;
+
+    @TableId(type = IdType.AUTO)
+    private Long id;
+    @NotNull(message = "分类ID不能为空", groups = { Detail.class, Update.class, Delete.class })
+    private Long good_category_id;
+
+    private Long parent_id;
+
+    @TableField(exist = false)
+    private String category_name;
+
+    @TableField(exist = false)
+    private String category_description;
+
+    @TableField(exist = false)
+    @NotEmpty(message="内容不能为空", groups = { Create.class, Update.class})
+    private List<GoodCategoryI18n> translations;
+
+    @Range(min = 1, max = 9999, message = "排序必须在 {min} 到 {max} 之间")
+    private Integer sort;
+
+    @RangeArray(message="商品分类状态取值有误,范围应是(-1禁用, 1启用)", value = {"-1", "1"}, groups = { Create.class, Update.class })
+    private Integer status;
+}

+ 36 - 0
src/main/java/com/backendsys/modules/b2c/good/entity/GoodCategoryI18n.java

@@ -0,0 +1,36 @@
+package com.backendsys.modules.b2c.good.entity;
+
+import com.backendsys.entity.validator.RangeArray;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Size;
+import lombok.Data;
+import org.hibernate.validator.constraints.Range;
+
+@Data
+@TableName("b2c_good_category_i18n")
+public class GoodCategoryI18n {
+    public static interface Detail{}
+    public static interface Create{}
+    public static interface Update{}
+    public static interface Delete{}
+
+    @TableId(type = IdType.AUTO)
+    private Long id;
+    private Long good_category_id;
+    @NotEmpty(message="语言不能为空", groups = { GoodI18n.Create.class, GoodI18n.Update.class })
+    private String language;
+
+    @Size(max = 50, message = "分类名称长度不超过 {max} 个字符", groups = { Create.class, Update.class })
+    @NotBlank(message = "分类名称不能为空", groups = { Create.class, Update.class })
+    private String category_name;
+
+    @Size(max = 200, message = "分类描述长度不超过 {max} 个字符", groups = { Create.class, Update.class })
+    private String category_description;
+
+}

+ 0 - 1
src/main/java/com/backendsys/modules/b2c/good/entity/GoodI18n.java

@@ -18,7 +18,6 @@ public class GoodI18n {
 
     @TableId(type = IdType.AUTO)
     private Long id;
-
     private Long good_id;
     @NotEmpty(message="语言不能为空", groups = { Create.class, Update.class })
     private String language;

+ 21 - 0
src/main/java/com/backendsys/modules/b2c/good/service/GoodCategoryService.java

@@ -0,0 +1,21 @@
+package com.backendsys.modules.b2c.good.service;
+
+import com.backendsys.modules.b2c.good.entity.GoodCategory;
+import com.backendsys.utils.response.PageEntity;
+
+import java.util.Map;
+
+public interface GoodCategoryService {
+
+    // 获取商品分类列表
+    PageEntity selectGoodCategoryList(GoodCategory goodCategory);
+    // 获取商品分类详情
+    Map<String, Object> selectGoodCategoryDetail(GoodCategory goodCategory);
+    // 创建商品分类
+    Map<String, Object> insertGoodCategory(GoodCategory goodCategory);
+    // 编辑商品分类
+    Map<String, Object> updateGoodCategory(GoodCategory goodCategory);
+    // 删除商品分类
+    Map<String, Object> deleteGoodCategory(GoodCategory goodCategory);
+    
+}

+ 113 - 0
src/main/java/com/backendsys/modules/b2c/good/service/impl/GoodCategoryServiceImpl.java

@@ -0,0 +1,113 @@
+package com.backendsys.modules.b2c.good.service.impl;
+
+import com.backendsys.exception.CustException;
+import com.backendsys.modules.b2c.good.dao.GoodCategoryDao;
+import com.backendsys.modules.b2c.good.dao.GoodCategoryI18nDao;
+import com.backendsys.modules.b2c.good.entity.GoodCategory;
+import com.backendsys.modules.b2c.good.entity.GoodCategoryI18n;
+import com.backendsys.modules.b2c.good.service.GoodCategoryService;
+import com.backendsys.modules.common.utils.ValidationUtil;
+import com.backendsys.utils.response.PageEntity;
+import com.backendsys.utils.response.PageInfoResult;
+import com.backendsys.utils.v2.PageUtils;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Service
+public class GoodCategoryServiceImpl implements GoodCategoryService {
+
+    @Autowired
+    private GoodCategoryDao goodCategoryDao;
+    @Autowired
+    private GoodCategoryI18nDao goodCategoryI18nDao;
+
+    /**
+     * 获取商品分类列表
+     */
+    @Override
+    public PageEntity selectGoodCategoryList(GoodCategory goodCategory) {
+        PageUtils.startPage();  // 分页
+        List<Map<String, Object>> list = goodCategoryDao.selectGoodCategoryList(goodCategory);
+        return new PageInfoResult(list).toEntity();
+    }
+
+    /**
+     * 获取商品分类详情
+     */
+    @Override
+    public Map<String, Object> selectGoodCategoryDetail(GoodCategory goodCategory) {
+        Map<String, Object> detail = goodCategoryDao.selectGoodCategoryDetail(goodCategory);
+        if (detail == null) throw new CustException("商品分类不存在");
+        return detail;
+    }
+
+    /**
+     * 创建商品分类
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Map<String, Object> insertGoodCategory(GoodCategory goodCategory) {
+
+        goodCategoryDao.insert(goodCategory);
+
+        // 批量插入 (翻译字段)
+        Long good_category_id = goodCategory.getId();
+        List<GoodCategoryI18n> translations = goodCategory.getTranslations().stream()
+                .peek(item -> { ValidationUtil.validateObject(item, GoodCategoryI18n.Create.class); })
+                .collect(Collectors.toList());
+        goodCategoryI18nDao.insertBatch(translations);
+
+        return Map.of("good_category_id", good_category_id);
+    }
+
+    /**
+     * 编辑商品分类
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Map<String, Object> updateGoodCategory(GoodCategory goodCategory) {
+
+        Long good_category_id = goodCategory.getGood_category_id();
+
+        GoodCategory goodCategoryDetail = goodCategoryDao.selectById(good_category_id);
+        if (goodCategoryDetail == null) throw new CustException("商品分类不存在");
+
+        // 更新
+        goodCategory.setId(good_category_id);
+        goodCategoryDao.updateById(goodCategory);
+
+        // 批量更新 (翻译字段)
+        List<GoodCategoryI18n> translations = goodCategory.getTranslations().stream()
+            .peek(item -> { ValidationUtil.validateObject(item, GoodCategoryI18n.Update.class); })
+            .collect(Collectors.toList());
+
+        goodCategoryI18nDao.updateBatch(translations);
+
+        return Map.of("good_category_id", good_category_id);
+    }
+
+    /**
+     * 删除商品分类
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Map<String, Object> deleteGoodCategory(GoodCategory goodCategory) {
+
+        Long good_category_id = goodCategory.getGood_category_id();
+
+        GoodCategory detail = goodCategoryDao.selectById(good_category_id);
+        if (detail == null) throw new CustException("商品分类不存在");
+
+        goodCategoryDao.deleteById(good_category_id);
+        goodCategoryI18nDao.delete(new QueryWrapper<GoodCategoryI18n>().eq("good_category_id", good_category_id));
+
+        return Map.of("good_category_id", good_category_id);
+    }
+
+}

+ 0 - 3
src/main/java/com/backendsys/modules/b2c/good/service/impl/GoodServiceImpl.java

@@ -92,9 +92,6 @@ public class GoodServiceImpl implements GoodService {
             .map(t -> { t.setGood_id(good_id); return t; })
             .collect(Collectors.toList());
 
-        System.out.println("translations:");
-        System.out.println(translations);
-
         goodI18nDao.updateBatch(translations);
 
         return Map.of("good_id", good_id);

+ 13 - 13
src/main/java/com/backendsys/service/B2c/B2cGoodCategoryService.java

@@ -1,13 +1,13 @@
-package com.backendsys.service.B2c;
-
-import com.backendsys.entity.B2c.B2cGoodCategoryDTO;
-
-import java.util.Map;
-
-public interface B2cGoodCategoryService {
-    Map<String, Object> queryGoodCategoryList(Integer pageNum, Integer pageSize, B2cGoodCategoryDTO b2cGoodCategoryDTO);
-    Map<String, Object> queryGoodCategoryDetail(Long good_id);
-    Map<String, Object> insertGoodCategory(B2cGoodCategoryDTO b2cGoodCategoryDTO);
-    Map<String, Object> updateGoodCategory(B2cGoodCategoryDTO b2cGoodCategoryDTO);
-    Map<String, Object> deleteGoodCategory(B2cGoodCategoryDTO b2cGoodCategoryDTO);
-}
+//package com.backendsys.service.B2c;
+//
+//import com.backendsys.entity.B2c.B2cGoodCategoryDTO;
+//
+//import java.util.Map;
+//
+//public interface B2cGoodCategoryService {
+//    Map<String, Object> queryGoodCategoryList(Integer pageNum, Integer pageSize, B2cGoodCategoryDTO b2cGoodCategoryDTO);
+//    Map<String, Object> queryGoodCategoryDetail(Long good_id);
+//    Map<String, Object> insertGoodCategory(B2cGoodCategoryDTO b2cGoodCategoryDTO);
+//    Map<String, Object> updateGoodCategory(B2cGoodCategoryDTO b2cGoodCategoryDTO);
+//    Map<String, Object> deleteGoodCategory(B2cGoodCategoryDTO b2cGoodCategoryDTO);
+//}

+ 72 - 72
src/main/java/com/backendsys/service/B2c/B2cGoodCategoryServiceImpl.java

@@ -1,72 +1,72 @@
-package com.backendsys.service.B2c;
-
-import com.backendsys.entity.B2c.B2cGoodCategoryDTO;
-import com.backendsys.mapper.B2c.B2cGoodCategoryMapper;
-import com.backendsys.utils.response.PageInfoResult;
-import com.github.pagehelper.PageHelper;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.List;
-import java.util.Map;
-
-@Service
-public class B2cGoodCategoryServiceImpl implements B2cGoodCategoryService {
-
-    @Autowired
-    private B2cGoodCategoryMapper b2cGoodCategoryMapper;
-
-    /**
-     * 查询 列表
-     */
-    public Map<String, Object> queryGoodCategoryList(Integer pageNum, Integer pageSize, B2cGoodCategoryDTO b2cGoodCategoryDTO) {
-        // 分页查询
-        if (pageNum != null && pageSize != null) {
-            PageHelper.startPage(pageNum, pageSize);
-            PageHelper.getLocalPage().setPageSizeZero(true);
-        }
-        // 分页输出 (自定义)
-        List<Map<String, Object>> list = b2cGoodCategoryMapper.queryGoodCategoryList(b2cGoodCategoryDTO);
-        PageInfoResult pageInfoResult = new PageInfoResult(list);
-        return pageInfoResult.toMap();
-    }
-
-    /**
-     * 查询 详情
-     */
-    @Override
-    public Map<String, Object> queryGoodCategoryDetail(Long good_category_id) {
-        return b2cGoodCategoryMapper.queryGoodCategoryDetail(good_category_id);
-    }
-
-    /**
-     * 创建
-     */
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public Map<String, Object> insertGoodCategory(B2cGoodCategoryDTO b2cGoodCategoryDTO) {
-        b2cGoodCategoryMapper.insertGoodCategory(b2cGoodCategoryDTO);
-        return Map.of("good_category_id", b2cGoodCategoryDTO.getGood_category_id());
-    }
-
-    /**
-     * 更新
-     */
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public Map<String, Object> updateGoodCategory(B2cGoodCategoryDTO b2cGoodCategoryDTO) {
-        b2cGoodCategoryMapper.updateGoodCategory(b2cGoodCategoryDTO);
-        return Map.of("good_category_id", b2cGoodCategoryDTO.getGood_category_id());
-    }
-
-    /**
-     * 删除
-     */
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public Map<String, Object> deleteGoodCategory(B2cGoodCategoryDTO b2cGoodCategoryDTO) {
-        b2cGoodCategoryMapper.deleteGoodCategory(b2cGoodCategoryDTO);
-        return Map.of("good_category_id", b2cGoodCategoryDTO.getGood_category_id());
-    }
-}
+//package com.backendsys.service.B2c;
+//
+//import com.backendsys.entity.B2c.B2cGoodCategoryDTO;
+//import com.backendsys.mapper.B2c.B2cGoodCategoryMapper;
+//import com.backendsys.utils.response.PageInfoResult;
+//import com.github.pagehelper.PageHelper;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Service;
+//import org.springframework.transaction.annotation.Transactional;
+//
+//import java.util.List;
+//import java.util.Map;
+//
+//@Service
+//public class B2cGoodCategoryServiceImpl implements B2cGoodCategoryService {
+//
+//    @Autowired
+//    private B2cGoodCategoryMapper b2cGoodCategoryMapper;
+//
+//    /**
+//     * 查询 列表
+//     */
+//    public Map<String, Object> queryGoodCategoryList(Integer pageNum, Integer pageSize, B2cGoodCategoryDTO b2cGoodCategoryDTO) {
+//        // 分页查询
+//        if (pageNum != null && pageSize != null) {
+//            PageHelper.startPage(pageNum, pageSize);
+//            PageHelper.getLocalPage().setPageSizeZero(true);
+//        }
+//        // 分页输出 (自定义)
+//        List<Map<String, Object>> list = b2cGoodCategoryMapper.queryGoodCategoryList(b2cGoodCategoryDTO);
+//        PageInfoResult pageInfoResult = new PageInfoResult(list);
+//        return pageInfoResult.toMap();
+//    }
+//
+//    /**
+//     * 查询 详情
+//     */
+//    @Override
+//    public Map<String, Object> queryGoodCategoryDetail(Long good_category_id) {
+//        return b2cGoodCategoryMapper.queryGoodCategoryDetail(good_category_id);
+//    }
+//
+//    /**
+//     * 创建
+//     */
+//    @Override
+//    @Transactional(rollbackFor = Exception.class)
+//    public Map<String, Object> insertGoodCategory(B2cGoodCategoryDTO b2cGoodCategoryDTO) {
+//        b2cGoodCategoryMapper.insertGoodCategory(b2cGoodCategoryDTO);
+//        return Map.of("good_category_id", b2cGoodCategoryDTO.getGood_category_id());
+//    }
+//
+//    /**
+//     * 更新
+//     */
+//    @Override
+//    @Transactional(rollbackFor = Exception.class)
+//    public Map<String, Object> updateGoodCategory(B2cGoodCategoryDTO b2cGoodCategoryDTO) {
+//        b2cGoodCategoryMapper.updateGoodCategory(b2cGoodCategoryDTO);
+//        return Map.of("good_category_id", b2cGoodCategoryDTO.getGood_category_id());
+//    }
+//
+//    /**
+//     * 删除
+//     */
+//    @Override
+//    @Transactional(rollbackFor = Exception.class)
+//    public Map<String, Object> deleteGoodCategory(B2cGoodCategoryDTO b2cGoodCategoryDTO) {
+//        b2cGoodCategoryMapper.deleteGoodCategory(b2cGoodCategoryDTO);
+//        return Map.of("good_category_id", b2cGoodCategoryDTO.getGood_category_id());
+//    }
+//}

+ 124 - 0
src/main/resources/mapper/b2c/good/GoodCategoryDao.xml

@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.backendsys.modules.b2c.good.dao.GoodCategoryDao">
+
+    <sql id="includeGoodCategory">
+        g.id id,
+        g.id good_category_id,
+        COALESCE(g.parent_id, -1) parent_id,
+        gt.category_name category_name,
+        COALESCE(gt.category_description, '') category_description,
+        g.sort sort,
+        g.status status
+    </sql>
+
+    <sql id="includeGoodCategoryDetail">
+        g.id id,
+        g.id good_category_id,
+        COALESCE(g.parent_id, -1) parent_id,
+        g.sort sort,
+        g.status status
+    </sql>
+
+    <sql id="includeGoodCategoryTranslation">
+        id,
+        good_category_id,
+        language,
+        category_name,
+        COALESCE(category_description, '') category_description
+    </sql>
+    <sql id="leftJoinTranslations">
+        LEFT JOIN b2c_good_category_i18n gt ON g.id = gt.good_category_id
+    </sql>
+
+    <sql id="includeGoodCategoryDetailFull">
+        g.id id,
+        g.id good_category_id,
+        COALESCE(g.parent_id, -1) parent_id,
+        gt.language,
+        gt.category_name category_name,
+        COALESCE(gt.category_description, '') category_description,
+        g.sort sort,
+        g.status status
+    </sql>
+
+    <resultMap id="resultMapGoodCategory" type="java.util.LinkedHashMap">
+        <id property="id" column="id" jdbcType="BIGINT" />
+        <result property="good_category_id" column="good_category_id" javaType="java.lang.Long" />
+        <result property="parent_id" column="parent_id" javaType="java.lang.Long" />
+        <result property="category_name" column="category_name" />
+        <result property="category_description" column="category_description" />
+        <result property="sort" column="sort" javaType="java.lang.Integer" />
+        <result property="status" column="status" javaType="java.lang.Integer" />
+    </resultMap>
+
+    <resultMap id="resultMapGoodCategoryDetail" type="java.util.LinkedHashMap">
+        <id property="id" column="id" jdbcType="BIGINT" />
+        <result property="good_category_id" column="good_category_id" javaType="java.lang.Long" />
+        <result property="parent_id" column="parent_id" javaType="java.lang.Long" />
+        <result property="sort" column="sort" javaType="java.lang.Integer" />
+        <result property="status" column="status" javaType="java.lang.Integer" />
+        <collection property="translations" javaType="java.util.List"
+            select="queryTranslationsById" column="id">
+            <id property="id" column="id" />
+            <result property="category_name" column="category_name" />
+            <result property="category_description" column="category_description" />
+        </collection>
+    </resultMap>
+
+    <resultMap id="resultMapGoodCategoryDetailFull" type="java.util.LinkedHashMap">
+        <id property="id" column="id" jdbcType="BIGINT" />
+        <result property="good_category_id" column="good_category_id" javaType="java.lang.Long" />
+        <result property="parent_id" column="parent_id" javaType="java.lang.Long" />
+        <result property="language" column="language" />
+        <result property="category_name" column="category_name" />
+        <result property="category_description" column="category_description" />
+        <result property="sort" column="sort" javaType="java.lang.Integer" />
+        <result property="status" column="status" javaType="java.lang.Integer" />
+    </resultMap>
+
+    <!-- 查 列表 -->
+    <select id="selectGoodCategoryList" resultMap="resultMapGoodCategory">
+        SELECT <include refid="includeGoodCategory" /> FROM b2c_good_category g
+        <include refid="leftJoinTranslations" />
+        <where>
+            gt.language = #{lang}
+            <if test="category_name != null and category_name != ''">
+                AND gt.category_name LIKE CONCAT('%', #{category_name}, '%')
+            </if>
+            <if test="status != null and status != ''">
+                AND g.status = #{status}
+            </if>
+        </where>
+        ORDER BY g.sort DESC
+    </select>
+
+    <!-- 查 详情 -->
+    <select id="selectGoodCategoryDetail" resultMap="resultMapGoodCategoryDetail">
+        SELECT <include refid="includeGoodCategoryDetail" />
+        FROM b2c_good_category g
+        <where>
+            <if test="good_category_id != null and good_category_id != ''">
+                AND g.id = #{good_category_id}
+            </if>
+        </where>
+    </select>
+
+    <!-- 查 详情 完整 -->
+    <select id="selectGoodCategoryDetailFull" resultMap="resultMapGoodCategoryDetailFull">
+        SELECT <include refid="includeGoodCategoryDetailFull" />
+        FROM b2c_good_category g
+        <include refid="leftJoinTranslations" />
+        WHERE
+            gt.language = #{lang}
+            AND g.status = #{status}
+    </select>
+
+    <!-- 查 翻译详情 (子查询) -->
+    <select id="queryTranslationsById" resultType="java.util.LinkedHashMap">
+        SELECT <include refid="includeGoodCategoryTranslation" />
+        FROM b2c_good_category_i18n
+        WHERE good_category_id = #{id}
+    </select>
+
+</mapper>

+ 36 - 0
src/main/resources/mapper/b2c/good/GoodCategoryI18nDao.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.backendsys.modules.b2c.good.dao.GoodCategoryI18nDao">
+
+    <!-- 批量插入 -->
+    <insert id="insertBatch" parameterType="java.util.List">
+        INSERT INTO b2c_good_category_i18n (
+            good_category_id, language,
+            category_name, category_description
+        )
+        VALUES
+        <foreach collection="translations" item="item" separator=",">
+        (
+            #{item.good_category_id}, #{item.language},
+            #{item.category_name}, #{item.category_description}
+        )
+        </foreach>
+    </insert>
+
+    <!-- 批量更新 -->
+    <update id="updateBatch" parameterType="com.backendsys.modules.b2c.good.entity.GoodI18n">
+        <foreach collection="translations" item="item" separator=";">
+            UPDATE b2c_good_category_i18n
+            <set>
+                <trim suffixOverrides="," suffix=" ">
+                    category_name = #{item.category_name},
+                    <if test="item.category_description != null and item.category_description != ''">
+                        category_description = #{item.category_description},
+                    </if>
+                </trim>
+            </set>
+            WHERE good_category_id = #{item.good_category_id} AND language = #{item.language}
+        </foreach>
+    </update>
+
+</mapper>