Просмотр исходного кода

feat(business): 增加配牌工具功能

- 新增配牌工具相关接口和实现类
- 添加整副牌内容字段和相关方法
- 实现删除配牌记录功能
- 优化 Redis 操作,支持 Hash 类型
- 修复盲注结构相关问题
fugui001 3 месяцев назад
Родитель
Сommit
b089d4b67a
16 измененных файлов с 382 добавлено и 14 удалено
  1. 18 0
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/controller/BusinessCardToolsController.java
  2. 1 0
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/controller/HandHistoryController.java
  3. 47 0
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/domain/BusinessCardTools.java
  4. 48 0
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/domain/bo/BusinessCardToolsBo.java
  5. 47 0
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/domain/vo/BusinessCardToolsVo.java
  6. 6 0
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/mapper/BlindLevelsMapper.java
  7. 2 0
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/mapper/BusinessCardToolsMapper.java
  8. 1 0
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/IBlindLevelsService.java
  9. 11 0
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/IBusinessCardToolsService.java
  10. 5 0
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/impl/BlindLevelsServiceImpl.java
  11. 1 0
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/impl/BlindStructuresServiceImpl.java
  12. 23 1
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/impl/BusinessCardToolsServiceImpl.java
  13. 8 1
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/impl/TournamentsServiceImpl.java
  14. 76 0
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/utils/RedisUtil.java
  15. 4 0
      ruoyi-modules/ruoyi-system/src/main/resources/mapper/business/BlindLevelsMapper.xml
  16. 84 12
      ruoyi-modules/ruoyi-system/src/main/resources/mapper/business/BusinessCardToolsMapper.xml

+ 18 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/controller/BusinessCardToolsController.java

@@ -9,6 +9,9 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
 import org.dromara.business.domain.bo.BusinessCardToolsBo;
 import org.dromara.business.domain.vo.BusinessCardToolsVo;
 import org.dromara.business.service.IBusinessCardToolsService;
+import org.dromara.business.utils.RedisKeys;
+import org.dromara.business.utils.RedisUtil;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.validation.annotation.Validated;
 import org.dromara.common.idempotent.annotation.RepeatSubmit;
@@ -36,6 +39,11 @@ public class BusinessCardToolsController extends BaseController {
 
     private final IBusinessCardToolsService businessCardToolsService;
 
+
+    @Autowired
+    RedisUtil redisUtil;
+
+
     /**
      * 查询配牌记录列表
      */
@@ -112,4 +120,14 @@ public class BusinessCardToolsController extends BaseController {
         return R.ok(businessCardToolsService.selectBusinessCardToolsMaxNew());
     }
 
+    @SaCheckPermission("business:cardTools:removeRedisPokerHands")
+    @Log(title = "【请填写功能名称】")
+    @RepeatSubmit()
+    @GetMapping("removeRedisPokerHands")
+    public R<Void> updateDelStatus() {
+        return toAjax(businessCardToolsService.updateDelStatus());
+    }
+
+
+
 }

+ 1 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/controller/HandHistoryController.java

@@ -129,4 +129,5 @@ public class HandHistoryController extends BaseController {
        return handHistoryService.getPlayHistoryInfo(bo,pageQuery);
     }
 
+
 }

+ 47 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/domain/BusinessCardTools.java

@@ -45,4 +45,51 @@ public class BusinessCardTools {
     private Date updateAt;
 
 
+    /**
+     * 整副牌内容
+     */
+    private String contentTwo;
+
+
+
+    /**
+     * 整副牌内容
+     */
+    private String contentThree;
+
+    /**
+     * 整副牌内容
+     */
+    private String contentFour;
+
+    /**
+     * 整副牌内容
+     */
+    private String contentFive;
+
+    /**
+     * 整副牌内容
+     */
+    private String contentSex;
+
+    /**
+     * 整副牌内容
+     */
+    private String contentSeven;
+
+
+    /**
+     * 整副牌内容
+     */
+    private String contentEight;
+
+
+    /**
+     * 整副牌内容
+     */
+    private String contentNine;
+
+    private Integer isDelete;
+
+
 }

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

@@ -47,4 +47,52 @@ public class BusinessCardToolsBo extends BaseEntity {
     private Date updateAt;
 
 
+    /**
+     * 整副牌内容
+     */
+    private String contentTwo;
+
+
+
+    /**
+     * 整副牌内容
+     */
+    private String contentThree;
+
+    /**
+     * 整副牌内容
+     */
+    private String contentFour;
+
+    /**
+     * 整副牌内容
+     */
+    private String contentFive;
+
+    /**
+     * 整副牌内容
+     */
+    private String contentSex;
+
+    /**
+     * 整副牌内容
+     */
+    private String contentSeven;
+
+
+    /**
+     * 整副牌内容
+     */
+    private String contentEight;
+
+
+    /**
+     * 整副牌内容
+     */
+    private String contentNine;
+
+
+
+
+
 }

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

@@ -55,5 +55,52 @@ public class BusinessCardToolsVo implements Serializable {
     @ExcelProperty(value = "更新时间")
     private Date updateAt;
 
+    /**
+     * 是否删除
+     */
+    private Integer isDelete;
+    /**
+     * 整副牌内容
+     */
+    private String contentTwo;
+
+
+
+    /**
+     * 整副牌内容
+     */
+    private String contentThree;
+
+    /**
+     * 整副牌内容
+     */
+    private String contentFour;
+
+    /**
+     * 整副牌内容
+     */
+    private String contentFive;
+
+    /**
+     * 整副牌内容
+     */
+    private String contentSex;
+
+    /**
+     * 整副牌内容
+     */
+    private String contentSeven;
+
+
+    /**
+     * 整副牌内容
+     */
+    private String contentEight;
+
+
+    /**
+     * 整副牌内容
+     */
+    private String contentNine;
 
 }

+ 6 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/mapper/BlindLevelsMapper.java

@@ -52,4 +52,10 @@ public interface BlindLevelsMapper extends BaseMapperPlus<BlindLevels, BlindLeve
     @InterceptorIgnore(tenantLine = "true")
     BlindLevelsVo selectBlindLevelsInfo(Long blindStructureId, Long blindLevel);
 
+    @InterceptorIgnore(tenantLine = "true")
+    List<BlindLevelsVo> selectBlindLevelsInfoObj(Long tournamentId);
+
+
+
+
 }

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

@@ -21,6 +21,8 @@ public interface BusinessCardToolsMapper extends BaseMapperPlus<BusinessCardTool
     @InterceptorIgnore(tenantLine = "true")
     BusinessCardToolsVo selectBusinessCardToolsMaxById();
 
+    @InterceptorIgnore(tenantLine = "true")
+    int updateDelStatus();
 
 
 }

+ 1 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/IBlindLevelsService.java

@@ -82,6 +82,7 @@ public interface IBlindLevelsService {
 
     List<BlindLevelsVo> selectBlindLevelsByTournament(Long tournamentId);
 
+    List<BlindLevelsVo> selectBlindLevelsInfoObj(Long tournamentId);
 
 
 }

+ 11 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/IBusinessCardToolsService.java

@@ -1,5 +1,7 @@
 package org.dromara.business.service;
 
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
+import org.dromara.business.domain.BlindLevels;
 import org.dromara.business.domain.bo.BusinessCardToolsBo;
 import org.dromara.business.domain.vo.BusinessCardToolsVo;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
@@ -75,4 +77,13 @@ public interface IBusinessCardToolsService {
      */
     BusinessCardToolsVo selectBusinessCardToolsMaxNew();
 
+    /**
+     * 删除配牌记录
+     *
+     * @param id 主键
+     * @return 是否删除成功
+     */
+    Boolean updateDelStatus();
+
+
 }

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

@@ -151,4 +151,9 @@ public class BlindLevelsServiceImpl implements IBlindLevelsService {
         return baseMapper.selectBlindLevelsByTournament(tournamentId);
     }
 
+    @Override
+    public List<BlindLevelsVo> selectBlindLevelsInfoObj(Long tournamentId) {
+        return baseMapper.selectBlindLevelsInfoObj(tournamentId);
+    }
+
 }

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

@@ -96,6 +96,7 @@ public class BlindStructuresServiceImpl implements IBlindStructuresService {
     /**
      * 查询符合条件的【请填写功能名称】列表
      *
+     *
      * @param bo 查询条件
      * @return 【请填写功能名称】列表
      */

+ 23 - 1
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/impl/BusinessCardToolsServiceImpl.java

@@ -19,6 +19,8 @@ import lombok.extern.slf4j.Slf4j;
 import org.dromara.common.satoken.utils.LoginHelper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Collection;
@@ -100,7 +102,20 @@ public class BusinessCardToolsServiceImpl implements IBusinessCardToolsService {
         add.setOperateName(StringUtils.isEmpty(LoginHelper.getLoginUser().getUsername())?LoginHelper.getLoginUser().getNickname() : LoginHelper.getLoginUser().getUsername());
         boolean flag = baseMapper.insertBusinessCardTools(add) > 0;
         if (flag) {
-            redisUtil.set(RedisKeys.GAME_POKER_TEST_HANDS, bo.getContent(), 48*60*60*30); // 5分钟过期时间
+           // redisUtil.set(RedisKeys.GAME_POKER_TEST_HANDS, bo.getContent(), 48*60*60*30); // 5分钟过期时间
+
+            // 使用 RedisUtil:
+            Map<String, String> map = new HashMap<>();
+            map.put("players:2", bo.getContentTwo());
+            map.put("players:3", bo.getContentThree());
+            map.put("players:4", bo.getContentFour());
+            map.put("players:5", bo.getContentFive());
+            map.put("players:6", bo.getContentSex());
+            map.put("players:7", bo.getContentSeven());
+            map.put("players:8", bo.getContentEight());
+            map.put("players:9", bo.getContentNine());
+            redisUtil.hPutAll(RedisKeys.GAME_POKER_TEST_HANDS, map);
+
             bo.setId(add.getId());
         }
         return flag;
@@ -145,4 +160,11 @@ public class BusinessCardToolsServiceImpl implements IBusinessCardToolsService {
     public BusinessCardToolsVo selectBusinessCardToolsMaxNew() {
         return baseMapper.selectBusinessCardToolsMaxById();
     }
+
+    @Override
+    public Boolean updateDelStatus() {
+        redisUtil.delete(RedisKeys.GAME_POKER_TEST_HANDS);
+        return baseMapper.updateDelStatus()>0?true:false;
+    }
+
 }

+ 8 - 1
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/impl/TournamentsServiceImpl.java

@@ -11,6 +11,7 @@ import org.dromara.business.domain.dto.TournamentsDto;
 import org.dromara.business.domain.enums.GameStatus;
 import org.dromara.business.domain.vo.*;
 import org.dromara.business.mapper.*;
+import org.dromara.business.service.IBlindLevelsService;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.common.mybatis.core.page.PageQuery;
@@ -67,6 +68,8 @@ public class TournamentsServiceImpl implements ITournamentsService {
 
     private final UserComplaintsMapper userComplaintsMapper;
 
+    private final IBlindLevelsService blindLevelsService;
+
     /**
      * 查询【请填写功能名称】
      *
@@ -283,6 +286,11 @@ public class TournamentsServiceImpl implements ITournamentsService {
             //比赛ID
             add.setTournamentsBiId(getCurrentDateTime()+bo.getGameType()+getRandomFourDigitNumber());
 
+            //取出对应盲注 本级别持续时间
+            List<BlindLevelsVo> blindLevelsVos = blindLevelsService.selectBlindLevelsInfoObj(bo.getBlindStructureId());
+            if(blindLevelsVos.size()>0){
+                add.setLevelDuration(blindLevelsVos.get(0).getDurationMinutes());
+            }
             // 插入赛事主表
             boolean flag = baseMapper.insertTournament(add) > 0;
             if (!flag) {
@@ -290,7 +298,6 @@ public class TournamentsServiceImpl implements ITournamentsService {
             }
 
             Long tournamentId = add.getId();
-
             // 绑定盲注结构
             bindBlindStructure(tournamentId, bo.getBlindStructureId());
 

+ 76 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/utils/RedisUtil.java

@@ -239,4 +239,80 @@ public class RedisUtil {
         }
     }
 
+
+
+    /**
+     * Hash 操作:设置单个字段(自动序列化 value 为 JSON)
+     */
+    public boolean hSet(String key, String field, Object value) {
+        try {
+            String jsonValue = value instanceof String ? (String) value : objectMapper.writeValueAsString(value);
+            redisTemplate.opsForHash().put(key, field, jsonValue);
+            return true;
+        } catch (JsonProcessingException e) {
+            return false;
+        }
+    }
+
+    /**
+     * Hash 操作:获取字段值,反序列化为指定类型
+     */
+    public <T> T hGet(String key, String field, Class<T> clazz) {
+        Object value = redisTemplate.opsForHash().get(key, field);
+        if (value == null) {
+            return null;
+        }
+        try {
+            return objectMapper.readValue(value.toString(), clazz);
+        } catch (JsonProcessingException e) {
+            return null;
+        }
+    }
+
+    /**
+     * Hash 操作:批量写入多个字段(Map<String, Object>)
+     */
+    public boolean hPutAll(String key, Map<String, ?> map) {
+        try {
+            Map<String, String> jsonMap = new HashMap<>();
+            for (Map.Entry<String, ?> entry : map.entrySet()) {
+                String jsonValue = entry.getValue() instanceof String
+                    ? (String) entry.getValue()
+                    : objectMapper.writeValueAsString(entry.getValue());
+                jsonMap.put(entry.getKey(), jsonValue);
+            }
+            redisTemplate.opsForHash().putAll(key, jsonMap);
+            return true;
+        } catch (JsonProcessingException e) {
+            return false;
+        }
+    }
+
+    /**
+     * Hash 操作:获取所有字段和值
+     */
+    public Map<String, String> hGetAll(String key) {
+        Map<Object, Object> entries = redisTemplate.opsForHash().entries(key);
+        Map<String, String> result = new HashMap<>();
+        for (Map.Entry<Object, Object> entry : entries.entrySet()) {
+            result.put(entry.getKey().toString(), entry.getValue().toString());
+        }
+        return result;
+    }
+
+    /**
+     * Hash 操作:判断字段是否存在
+     */
+    public boolean hHasKey(String key, String field) {
+        return Boolean.TRUE.equals(redisTemplate.opsForHash().hasKey(key, field));
+    }
+
+    /**
+     * Hash 操作:删除一个或多个字段
+     */
+    public void hDelete(String key, String... fields) {
+        redisTemplate.opsForHash().delete(key, (Object[]) fields);
+    }
+
+
 }

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

@@ -162,4 +162,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select * from blind_levels where blind_structure_id = #{blindStructureId} and level_number = #{blindLevel}
     </select>
 
+    <select id="selectBlindLevelsInfoObj" resultType="org.dromara.business.domain.vo.BlindLevelsVo">
+        select * from blind_levels where blind_structure_id = #{blindStructureId} order by level_number asc
+    </select>
+
 </mapper>

+ 84 - 12
ruoyi-modules/ruoyi-system/src/main/resources/mapper/business/BusinessCardToolsMapper.xml

@@ -11,29 +11,101 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             operate_name,
             content,
             create_at,
-            update_at
-        FROM business_card_tools  order by  create_at desc  limit 1
+            update_at,
+            is_delete,
+            content_two,
+            content_three,
+            content_four,
+            content_five,
+            content_sex,
+            content_seven,
+            content_eight,
+            content_nine
+        FROM business_card_tools where is_delete=0  order by  create_at desc  limit 1
     </select>
 
 
 
 
-    <insert id="insertBusinessCardTools" useGeneratedKeys="true" keyProperty="id">
+    <insert id="insertBusinessCardTools" parameterType="org.dromara.business.domain.BusinessCardTools">
         INSERT INTO business_card_tools
         <trim prefix="(" suffix=")" suffixOverrides=",">
-            <if test="id != null">id,</if>
-            <if test="operateName != null and operateName != ''">operate_name,</if>
-            <if test="content != null and content != ''">content,</if>
-            <!-- 强制插入时间 -->
+            <if test="operateName != null and operateName != ''">
+                operate_name,
+            </if>
+            <if test="content != null and content != ''">
+                content,
+            </if>
+            <if test="contentTwo != null and contentTwo != ''">
+                content_two,
+            </if>
+            <if test="contentThree != null and contentThree != ''">
+                content_three,
+            </if>
+            <if test="contentFour != null and contentFour != ''">
+                content_four,
+            </if>
+            <if test="contentFive != null and contentFive != ''">
+                content_five,
+            </if>
+            <if test="contentSex != null and contentSex != ''">
+                content_sex,
+            </if>
+            <if test="contentSeven != null and contentSeven != ''">
+                content_seven,
+            </if>
+            <if test="contentEight != null and contentEight != ''">
+                content_eight,
+            </if>
+            <if test="contentNine != null and contentNine != ''">
+                content_nine,
+            </if>
+            <if test="isDelete != null">
+                is_delete,
+            </if>
             create_at,
-            update_at
+            update_at,
         </trim>
         <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
-            <if test="id != null">#{id},</if>
-            <if test="operateName != null and operateName != ''">#{operateName},</if>
-            <if test="content != null and content != ''">#{content},</if>
-            NOW(), NOW()
+            <if test="operateName != null and operateName != ''">
+                #{operateName},
+            </if>
+            <if test="content != null and content != ''">
+                #{content},
+            </if>
+            <if test="contentTwo != null and contentTwo != ''">
+                #{contentTwo},
+            </if>
+            <if test="contentThree != null and contentThree != ''">
+                #{contentThree},
+            </if>
+            <if test="contentFour != null and contentFour != ''">
+                #{contentFour},
+            </if>
+            <if test="contentFive != null and contentFive != ''">
+                #{contentFive},
+            </if>
+            <if test="contentSex != null and contentSex != ''">
+                #{contentSex},
+            </if>
+            <if test="contentSeven != null and contentSeven != ''">
+                #{contentSeven},
+            </if>
+            <if test="contentEight != null and contentEight != ''">
+                #{contentEight},
+            </if>
+            <if test="contentNine != null and contentNine != ''">
+                #{contentNine},
+            </if>
+            <if test="isDelete != null">
+                #{isDelete},
+            </if>
+            NOW(),
+            NOW()
         </trim>
     </insert>
+    <update id="updateDelStatus">
+         update business_card_tools set is_delete=1
+    </update>
 
 </mapper>