浏览代码

feat(gift): 添加礼品类型子类查询功能和商品扩展字段

- 新增 selectGiftTypeChildList 接口用于查询父类下的子类
- 在 Items 实体中添加 effectiveType、expireTime、effectiveDay 等扩展字段
- 更新 ItemsMapper.xml 中的 SQL 查询语句以包含新增字段
- 实现 Items 列表查询时关联显示礼品类型的父子类名称
- 完善 ItemsVo 数据传输对象以支持新的业务字段
fugui001 1 周之前
父节点
当前提交
feed003f08

+ 13 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/controller/GiftTypeController.java

@@ -109,4 +109,17 @@ public class GiftTypeController extends BaseController {
         return R.ok(giftTypeService.selectGiftTypeParentList());
     }
 
+
+    /**
+     * 查询父类下面的子类
+     * @param id
+     * @return
+     */
+    @GetMapping("/selectGiftTypeChildList/{id}")
+    public R<List<GiftTypeVo>> selectGiftTypeChildList(@NotNull(message = "ID不能为空")
+                                 @PathVariable Long id) {
+        return R.ok(giftTypeService.selectGiftTypeChildList(id));
+    }
+
+
     }

+ 16 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/domain/Items.java

@@ -60,4 +60,20 @@ public class Items extends BaseEntity {
 
     private String itemTypeCode;
 
+    private Long effectiveType;
+
+    private Date expireTime;
+
+    private Long effectiveDay;
+
+    private Long giftTypeParentId;
+
+    private Long giftTypeChildId;
+
+    private String itemUrl;
+
+    private Long isGiveAway;
+
+    private Long itemCount;
+
 }

+ 15 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/domain/bo/ItemsBo.java

@@ -70,5 +70,20 @@ public class ItemsBo extends BaseEntity {
 
     private String itemTypeCode;
 
+    private Long effectiveType;
+
+    private Date expireTime;
+
+    private Long effectiveDay;
+
+    private Long giftTypeParentId;
+
+    private Long giftTypeChildId;
+
+    private String itemUrl;
+
+    private Long isGiveAway;
+
+    private Long itemCount;
 
 }

+ 20 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/domain/vo/ItemsVo.java

@@ -76,4 +76,24 @@ public class ItemsVo implements Serializable {
 
     private List<ItemsPrizeDto> itemsPrizeList;
 
+    private Long effectiveType;
+
+    private Date expireTime;
+
+    private Long effectiveDay;
+
+    private Long giftTypeParentId;
+
+    private Long giftTypeChildId;
+
+    private String itemUrl;
+
+    private Long isGiveAway;
+
+    private Long itemCount;
+
+    private String giftTypeParentName;
+
+    private String giftTypeChildName;
+
 }

+ 2 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/mapper/GiftTypeMapper.java

@@ -44,5 +44,7 @@ public interface GiftTypeMapper extends BaseMapperPlus<GiftType, GiftTypeVo> {
     @InterceptorIgnore(tenantLine = "true")
     int selectGiftTypeChildCount(@Param("parentId") Long parentId);
 
+    @InterceptorIgnore(tenantLine = "true")
+    List<GiftTypeVo> selectGiftTypeChildList(@Param("parentId") Long parentId);
 
 }

+ 3 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/IGiftTypeService.java

@@ -67,4 +67,7 @@ public interface IGiftTypeService {
     Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
 
     List<GiftTypeVo> selectGiftTypeParentList();
+
+    List<GiftTypeVo> selectGiftTypeChildList(Long parentId);
+
 }

+ 7 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/impl/GiftTypeServiceImpl.java

@@ -32,6 +32,8 @@ public class GiftTypeServiceImpl implements IGiftTypeService {
 
     private final GiftTypeMapper baseMapper;
 
+
+
     /**
      * 查询权益类型树
      *
@@ -146,4 +148,9 @@ public class GiftTypeServiceImpl implements IGiftTypeService {
         return baseMapper.selectGiftTypeParentList();
     }
 
+    @Override
+    public List<GiftTypeVo> selectGiftTypeChildList(Long parentId) {
+        return baseMapper.selectGiftTypeChildList(parentId);
+    }
+
 }

+ 15 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/impl/ItemsServiceImpl.java

@@ -7,7 +7,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import org.dromara.business.domain.Items;
 import org.dromara.business.domain.bo.ItemsBo;
 import org.dromara.business.domain.dto.ItemsPrizeDto;
+import org.dromara.business.domain.vo.GiftTypeVo;
 import org.dromara.business.domain.vo.ItemsVo;
+import org.dromara.business.mapper.GiftTypeMapper;
 import org.dromara.business.mapper.ItemsMapper;
 import org.dromara.business.service.IItemsService;
 import org.dromara.business.utils.RedisKeys;
@@ -44,6 +46,8 @@ public class ItemsServiceImpl implements IItemsService {
 
     private final ItemsMapper baseMapper;
 
+    private final GiftTypeMapper giftTypeMapper;
+
     @Autowired
     RedisUtil redisUtil;
 
@@ -99,6 +103,17 @@ public class ItemsServiceImpl implements IItemsService {
     public TableDataInfo<ItemsVo> queryPageList(ItemsBo bo, PageQuery pageQuery) {
         LambdaQueryWrapper<Items> lqw = buildQueryWrapper(bo);
         Page<ItemsVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
+        List<ItemsVo> resultRecords = result.getRecords();
+        for (ItemsVo resultRecord : resultRecords) {
+            GiftTypeVo giftTypeVo = giftTypeMapper.selectGiftTypeById(resultRecord.getGiftTypeChildId());
+            if(giftTypeVo!=null){
+                resultRecord.setGiftTypeChildName(giftTypeVo.getName());
+            }
+            GiftTypeVo giftTypeVo2 = giftTypeMapper.selectGiftTypeById(resultRecord.getGiftTypeParentId());
+            if(giftTypeVo2!=null){
+                resultRecord.setGiftTypeParentName(giftTypeVo2.getName());
+            }
+        }
         return TableDataInfo.build(result);
     }
 

+ 4 - 0
ruoyi-modules/ruoyi-system/src/main/resources/mapper/business/GiftTypeMapper.xml

@@ -71,6 +71,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         SELECT id, name, type_code, type_value, parent_id, status, created_at, updated_at
         FROM gift_type where parent_id is null
     </select>
+    <select id="selectGiftTypeChildList" resultType="org.dromara.business.domain.vo.GiftTypeVo">
+        SELECT id, name, type_code, type_value, parent_id, status, created_at, updated_at
+        FROM gift_type where parent_id = #{parentId}
+    </select>
     <select id="selectGiftTypeChildCount" resultType="int">
         SELECT count(*)
         FROM gift_type where parent_id = #{parentId}

+ 53 - 4
ruoyi-modules/ruoyi-system/src/main/resources/mapper/business/ItemsMapper.xml

@@ -6,17 +6,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 
     <select id="selectVoPage" resultType="org.dromara.business.domain.vo.ItemsVo">
-        SELECT id, name, item_type,item_desc, created_at, updated_at,item_value,item_json,item_type_code
+        SELECT id, name, item_type,item_desc, created_at, updated_at,item_value,item_json,item_type_code,effective_type,expire_time, effective_day, gift_type_parent_id, gift_type_child_id, item_url, is_give_away, item_count
         FROM items ${ew.customSqlSegment}
     </select>
 
 
     <select id="selectItemsList" resultType="org.dromara.business.domain.vo.ItemsVo">
-        SELECT  id, name, item_type,item_desc, created_at, updated_at,item_value,item_json,item_type_code FROM items  ${ew.customSqlSegment}
+        SELECT  id, name, item_type,item_desc, created_at, updated_at,item_value,item_json,item_type_code,effective_type,expire_time, effective_day, gift_type_parent_id, gift_type_child_id, item_url, is_give_away, item_count FROM items  ${ew.customSqlSegment}
     </select>
 
     <select id="selectVoByIdInfo" resultType="org.dromara.business.domain.vo.ItemsVo">
-        SELECT  id, name, item_type,item_desc, created_at, updated_at,item_value,item_json,item_type_code FROM items WHERE id =  #{id}
+        SELECT  id, name, item_type,item_desc, created_at, updated_at,item_value,item_json,item_type_code,effective_type,expire_time, effective_day, gift_type_parent_id, gift_type_child_id, item_url, is_give_away, item_count FROM items WHERE id =  #{id}
     </select>
 
     <update id="updateItemsById">
@@ -38,6 +38,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="itemTypeCode != null and itemTypeCode != ''">
                 item_type_code = #{itemTypeCode},
             </if>
+            <if test="itemValue != null">
+                item_value = #{itemValue},
+            </if>
+            <if test="effectiveType != null">
+                effective_type = #{effectiveType},
+            </if>
+            <if test="expireTime != null">
+                expire_time = #{expireTime},
+            </if>
+            <if test="effectiveDay != null">
+                effective_day = #{effectiveDay},
+            </if>
+            <if test="giftTypeParentId != null">
+                gift_type_parent_id = #{giftTypeParentId},
+            </if>
+            <if test="giftTypeChildId != null">
+                gift_type_child_id = #{giftTypeChildId},
+            </if>
+            <if test="itemUrl != null">
+                item_url = #{itemUrl},
+            </if>
+            <if test="isGiveAway != null">
+                is_give_away = #{isGiveAway},
+            </if>
+            <if test="itemCount != null">
+                item_count = #{itemCount},
+            </if>
             updated_at = NOW()
         </set>
         WHERE id = #{id}
@@ -53,6 +80,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="itemValue != null">item_value,</if>
             <if test="itemJson != null and itemJson != ''">item_json,</if>
             <if test="itemTypeCode != null and itemTypeCode != ''">item_type_code,</if>
+            <if test="effectiveType != null">effective_type,</if>
+            <if test="expireTime != null">expire_time,</if>
+
+            <if test="effectiveDay != null">effective_day,</if>
+            <if test="giftTypeParentId != null">gift_type_parent_id,</if>
+
+            <if test="giftTypeChildId != null">gift_type_child_id,</if>
+            <if test="itemUrl != null">item_url,</if>
+
+            <if test="isGiveAway != null">is_give_away,</if>
+            <if test="itemCount != null">item_count,</if>
         </trim>
         <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
             <if test="name != null and name != ''">#{name},</if>
@@ -61,6 +99,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="itemValue != null">#{itemValue},</if>
             <if test="itemJson != null and itemJson != ''">#{itemJson},</if>
             <if test="itemTypeCode != null and itemTypeCode != ''">#{itemTypeCode},</if>
+            <if test="effectiveType != null">#{effectiveType},</if>
+            <if test="expireTime != null">#{expireTime},</if>
+
+            <if test="effectiveDay != null">#{effectiveDay},</if>
+            <if test="giftTypeParentId != null">#{giftTypeParentId},</if>
+
+            <if test="giftTypeChildId != null">#{giftTypeChildId},</if>
+            <if test="itemUrl != null">#{itemUrl},</if>
+
+            <if test="isGiveAway != null">#{isGiveAway},</if>
+            <if test="itemCount != null">#{itemCount},</if>
         </trim>
     </insert>
 
@@ -79,7 +128,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 
     <select id="selectItemsSelList" resultType="org.dromara.business.domain.vo.ItemsVo">
-        SELECT  id, name, item_type,item_desc, created_at, updated_at,item_value FROM items
+        SELECT  id, name, item_type,item_desc, created_at, updated_at,item_value,effective_type,expire_time, effective_day, gift_type_parent_id, gift_type_child_id, item_url, is_give_away, item_count FROM items
     </select>
 
 </mapper>