Преглед на файлове

style: 修改pom.xml格式,增加类注释

seamew преди 2 години
родител
ревизия
acdd4224bc
променени са 17 файла, в които са добавени 163 реда и са изтрити 40 реда
  1. 5 0
      lottery-domain/pom.xml
  2. 27 0
      lottery-domain/src/main/java/com/seamew/lottery/domain/strategy/model/vo/DrawAwardInfo.java
  3. 1 1
      lottery-domain/src/main/java/com/seamew/lottery/domain/strategy/repository/IStrategyRepository.java
  4. 1 1
      lottery-domain/src/main/java/com/seamew/lottery/domain/strategy/repository/impl/StrategyRepository.java
  5. 1 1
      lottery-domain/src/main/java/com/seamew/lottery/domain/strategy/service/algorithm/impl/SingleRateRandomDrawAlgorithm.java
  6. 1 1
      lottery-domain/src/main/java/com/seamew/lottery/domain/strategy/service/draw/IDrawExec.java
  7. 1 1
      lottery-domain/src/main/java/com/seamew/lottery/domain/strategy/service/draw/impl/DrawExecImpl.java
  8. 0 1
      lottery-infrastructure/pom.xml
  9. 20 1
      lottery-infrastructure/src/main/java/com/seamew/lottery/infrastructure/dao/IStrategyDetailDao.java
  10. 1 1
      lottery-infrastructure/src/main/java/com/seamew/lottery/infrastructure/po/Activity.java
  11. 27 8
      lottery-infrastructure/src/main/java/com/seamew/lottery/infrastructure/po/StrategyDetail.java
  12. 18 20
      lottery-interfaces/pom.xml
  13. 1 1
      lottery-interfaces/src/main/java/com/seamew/lottery/LotteryApplication.java
  14. 9 0
      lottery-interfaces/src/main/resources/mybatis/config/mybatis-config.xml
  15. 13 1
      lottery-interfaces/src/main/resources/mybatis/mapper/StrategyDetail_Mapper.xml
  16. 1 1
      lottery-rpc/src/main/java/com/seamew/lottery/rpc/IActivityBooth.java
  17. 36 1
      pom.xml

+ 5 - 0
lottery-domain/pom.xml

@@ -26,6 +26,11 @@
             <groupId>cn.hutool</groupId>
             <artifactId>hutool-all</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>com.seamew</groupId>
             <artifactId>lottery-infrastructure</artifactId>

+ 27 - 0
lottery-domain/src/main/java/com/seamew/lottery/domain/strategy/model/vo/DrawAwardInfo.java

@@ -0,0 +1,27 @@
+package com.seamew.lottery.domain.strategy.model.vo;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @Author: seamew
+ * @Title: DrawAwardInfo
+ * @CreateTime: 2023年02月14日 10:41:00
+ * @Description: 中奖奖品信息
+ * @Version: 1.0
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class DrawAwardInfo {
+    /**
+     * 奖品ID
+     */
+    private String rewardId;
+
+    /**
+     * 奖品名称
+     */
+    private String awardName;
+}

+ 1 - 1
lottery-domain/src/main/java/com/seamew/lottery/domain/strategy/repository/IStrategyRepository.java

@@ -7,7 +7,7 @@ import com.seamew.lottery.infrastructure.po.Award;
  * @Author: seamew
  * @Title: IStrategyRepository
  * @CreateTime: 2023年02月13日 21:02:00
- * @Description: 策略数据存储
+ * @Description: 策略表仓储服务
  * @Version: 1.0
  */
 public interface IStrategyRepository {

+ 1 - 1
lottery-domain/src/main/java/com/seamew/lottery/domain/strategy/repository/impl/StrategyRepository.java

@@ -17,7 +17,7 @@ import java.util.List;
  * @Author: seamew
  * @Title: StrategyRepository
  * @CreateTime: 2023年02月13日 21:02:00
- * @Description:
+ * @Description: 策略表仓储服务
  * @Version: 1.0
  */
 @Component

+ 1 - 1
lottery-domain/src/main/java/com/seamew/lottery/domain/strategy/service/algorithm/impl/SingleRateRandomDrawAlgorithm.java

@@ -15,7 +15,7 @@ import java.util.List;
  * @Author: seamew
  * @Title: SingleRateRandomDrawAlgorithm
  * @CreateTime: 2023年02月13日 17:03:00
- * @Description:
+ * @Description: 单项随机概率抽奖,抽到一个已经排掉的奖品则未中奖
  * @Version: 1.0
  */
 @Component

+ 1 - 1
lottery-domain/src/main/java/com/seamew/lottery/domain/strategy/service/draw/IDrawExec.java

@@ -7,7 +7,7 @@ import com.seamew.lottery.domain.strategy.model.res.DrawResult;
  * @Author: seamew
  * @Title: IDrawExec
  * @CreateTime: 2023年02月13日 20:39:00
- * @Description: 策略包装
+ * @Description: 抽奖执行接口
  * @Version: 1.0
  */
 public interface IDrawExec {

+ 1 - 1
lottery-domain/src/main/java/com/seamew/lottery/domain/strategy/service/draw/impl/DrawExecImpl.java

@@ -21,7 +21,7 @@ import java.util.List;
  * @Author: seamew
  * @Title: DrawExecImpl
  * @CreateTime: 2023年02月13日 21:00:00
- * @Description:
+ * @Description: 抽奖过程方法实现
  * @Version: 1.0
  */
 @Service("drawExec")

+ 0 - 1
lottery-infrastructure/pom.xml

@@ -21,7 +21,6 @@
         <dependency>
             <groupId>org.mybatis.spring.boot</groupId>
             <artifactId>mybatis-spring-boot-starter</artifactId>
-            <version>2.2.2</version>
         </dependency>
     </dependencies>
 

+ 20 - 1
lottery-infrastructure/src/main/java/com/seamew/lottery/infrastructure/dao/IStrategyDetailDao.java

@@ -9,12 +9,31 @@ import java.util.List;
  * @Author: seamew
  * @Title: IStrategyDetailDao
  * @CreateTime: 2023年02月13日 21:04:00
- * @Description:
+ * @Description: 策略表数据库操作
  * @Version: 1.0
  */
 @Mapper
 public interface IStrategyDetailDao {
 
+    /**
+     * 查询策略表详细配置
+     * @param strategyId 策略ID
+     * @return           返回结果
+     */
     List<StrategyDetail> queryStrategyDetailList(Long strategyId);
 
+    /**
+     * 查询无库存策略奖品ID
+     * @param strategyId 策略ID
+     * @return           返回结果
+     */
+    List<String> queryNoStockStrategyAwardList(Long strategyId);
+
+    /**
+     * 扣减库存
+     * @param strategyDetailReq 策略ID、奖品ID
+     * @return                  返回结果
+     */
+    int deductStock(StrategyDetail strategyDetailReq);
+
 }

+ 1 - 1
lottery-infrastructure/src/main/java/com/seamew/lottery/infrastructure/po/Activity.java

@@ -10,7 +10,7 @@ import java.util.Date;
  * @Author: seamew
  * @Title: Activity
  * @CreateTime: 2023年02月07日 13:55:00
- * @Description:
+ * @Description: 活动基础信息表
  * @Version: 1.0
  */
 @Data

+ 27 - 8
lottery-infrastructure/src/main/java/com/seamew/lottery/infrastructure/po/StrategyDetail.java

@@ -17,24 +17,43 @@ import java.math.BigDecimal;
 @NoArgsConstructor
 @AllArgsConstructor
 public class StrategyDetail {
-    // 自增ID
+    /**
+     * 自增ID
+     */
     private String id;
 
-    // 策略ID
+    /**
+     * 策略ID
+     */
     private Long strategyId;
 
-    // 奖品ID
+    /**
+     * 奖品ID
+     */
     private String awardId;
 
-    // 奖品数量
-    private String awardCount;
+    /**
+     * 奖品库存
+     */
+    private Integer awardCount;
 
-    // 中奖概率
+    /**
+     * 奖品剩余库存
+     */
+    private Integer awardSurplusCount;
+
+    /**
+     * 中奖概率
+     */
     private BigDecimal awardRate;
 
-    // 创建时间
+    /**
+     * 创建时间
+     */
     private String createTime;
 
-    // 修改时间
+    /**
+     * 修改时间
+     */
     private String updateTime;
 }

+ 18 - 20
lottery-interfaces/pom.xml

@@ -22,53 +22,51 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-test</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
+
         <dependency>
             <groupId>org.mybatis.spring.boot</groupId>
             <artifactId>mybatis-spring-boot-starter</artifactId>
-            <version>2.2.2</version>
         </dependency>
         <dependency>
             <groupId>mysql</groupId>
             <artifactId>mysql-connector-java</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-lang3</artifactId>
-        </dependency>
+
         <dependency>
             <groupId>org.apache.dubbo</groupId>
             <artifactId>dubbo</artifactId>
-            <version>2.7.21</version>
         </dependency>
         <dependency>
             <groupId>org.apache.dubbo</groupId>
             <artifactId>dubbo-spring-boot-starter</artifactId>
-            <version>2.7.21</version>
         </dependency>
         <dependency>
             <groupId>org.apache.curator</groupId>
             <artifactId>curator-framework</artifactId>
-            <version>4.2.0</version>
         </dependency>
         <dependency>
             <groupId>org.apache.curator</groupId>
             <artifactId>curator-recipes</artifactId>
-            <version>4.2.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
         </dependency>
         <dependency>
             <groupId>com.alibaba</groupId>
             <artifactId>fastjson</artifactId>
-            <version>2.0.23</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
         </dependency>
 
 

+ 1 - 1
lottery-interfaces/src/main/java/com/seamew/lottery/LotteryApplication.java

@@ -8,7 +8,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
  * @Author: seamew
  * @Title: LotteryApplication
  * @CreateTime: 2023年02月07日 14:18:00
- * @Description:
+ * @Description: LotteryApplication
  * @Version: 1.0
  */
 @SpringBootApplication

+ 9 - 0
lottery-interfaces/src/main/resources/mybatis/config/mybatis-config.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE configuration
+        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-config.dtd">
+<configuration>
+    <typeAliases>
+        <package name="com.seamew.lottery.infrastructure.po.Activity"/>
+    </typeAliases>
+</configuration>

+ 13 - 1
lottery-interfaces/src/main/resources/mybatis/mapper/StrategyDetail_Mapper.xml

@@ -3,9 +3,21 @@
 <mapper namespace="com.seamew.lottery.infrastructure.dao.IStrategyDetailDao">
 
     <select id="queryStrategyDetailList" parameterType="java.lang.Long" resultType="com.seamew.lottery.infrastructure.po.StrategyDetail">
-        SELECT id, strategyId, awardId, awardCount, awardRate, createTime, updateTime
+        SELECT id, strategyId, awardId, awardCount, awardSurplusCount,
+               awardRate, createTime, updateTime
         FROM strategy_detail
         WHERE strategyId = #{strategyId}
     </select>
 
+    <select id="queryNoStockStrategyAwardList" parameterType="java.lang.Long" resultType="java.lang.String">
+        SELECT awardId
+        FROM strategy_detail
+        WHERE strategyId = #{strategyId} AND awardSurplusCount = 0
+    </select>
+
+    <update id="deductStock" parameterType="com.seamew.lottery.infrastructure.po.StrategyDetail">
+        UPDATE strategy_detail SET awardSurplusCount = awardSurplusCount - 1
+        WHERE strategyId = #{strategyId} AND awardId = #{awardId} AND awardSurplusCount > 0
+    </update>
+
 </mapper>

+ 1 - 1
lottery-rpc/src/main/java/com/seamew/lottery/rpc/IActivityBooth.java

@@ -7,7 +7,7 @@ import com.seamew.lottery.rpc.res.ActivityRes;
  * @Author: seamew
  * @Title: IActivityBooth
  * @CreateTime: 2023年02月07日 11:17:00
- * @Description:
+ * @Description: 活动展台 1. 创建活动 2. 更新活动 3. 查询活动
  * @Version: 1.0
  */
 public interface IActivityBooth {

+ 36 - 1
pom.xml

@@ -41,10 +41,45 @@
 
     <dependencyManagement>
         <dependencies>
+            <!-- mybatis -->
+            <dependency>
+                <groupId>org.mybatis.spring.boot</groupId>
+                <artifactId>mybatis-spring-boot-starter</artifactId>
+                <version>2.2.2</version>
+            </dependency>
+
+            <!-- dubbo -->
+            <dependency>
+                <groupId>org.apache.dubbo</groupId>
+                <artifactId>dubbo</artifactId>
+                <version>2.7.21</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.dubbo</groupId>
+                <artifactId>dubbo-spring-boot-starter</artifactId>
+                <version>2.7.21</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.curator</groupId>
+                <artifactId>curator-framework</artifactId>
+                <version>4.2.0</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.curator</groupId>
+                <artifactId>curator-recipes</artifactId>
+                <version>4.2.0</version>
+            </dependency>
+
+            <!-- 三方工具包 -->
             <dependency>
                 <groupId>cn.hutool</groupId>
                 <artifactId>hutool-all</artifactId>
-                <version>5.5.0</version>
+                <version>5.8.11</version>
+            </dependency>
+            <dependency>
+                <groupId>com.alibaba</groupId>
+                <artifactId>fastjson</artifactId>
+                <version>2.0.23</version>
             </dependency>
         </dependencies>
     </dependencyManagement>