From 41b321f5c2692ed83dcb6efcdd327f7608e1511d Mon Sep 17 00:00:00 2001
From: 90-nk <964587616@qq.com>
Date: Mon, 18 Mar 2024 21:50:08 +0800
Subject: [PATCH] =?UTF-8?q?=E9=81=87=E5=88=B0=E4=BA=86=E6=97=A0=E6=B3=95?=
=?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=9A=84=E6=8A=A5=E9=94=99=EF=BC=8C=E9=BA=BB?=
=?UTF-8?q?=E7=83=A6=E5=B0=8F=E5=82=85=E5=93=A5=E5=B8=AE=E5=BF=99=E7=9C=8B?=
=?UTF-8?q?=E4=B8=80=E4=B8=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 6 +--
.../main/java/cn/bugstack/Application.java | 4 ++
.../src/main/resources/application-dev.yml | 8 +--
.../mybatis/mapper/strategy_award_mapper.xml | 50 +++++++++++++++++++
.../mybatis/mapper/strategy_mapper.xml | 26 ++++++++++
.../mybatis/mapper/strategy_rule_mapper.xml | 37 ++++++++++++++
.../{ => infrastructure}/AwardDaoTest.java | 4 +-
.../persistent/dao/IAwardDao.java | 18 +++++++
.../persistent/dao/IStrategyAwardDao.java | 25 ++++++++++
.../persistent/dao/IStrategyDao.java | 20 ++++++++
.../persistent/dao/IStrategyRuleDao.java | 22 ++++++++
.../infrastructure/persistent/po/Award.java | 29 +++++++++++
.../persistent/po/StrategyRule.java | 33 ++++++++++++
13 files changed, 273 insertions(+), 9 deletions(-)
create mode 100644 xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/strategy_award_mapper.xml
create mode 100644 xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/strategy_mapper.xml
create mode 100644 xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/strategy_rule_mapper.xml
rename xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/{ => infrastructure}/AwardDaoTest.java (79%)
create mode 100644 xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/persistent/dao/IAwardDao.java
create mode 100644 xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/persistent/dao/IStrategyAwardDao.java
create mode 100644 xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/persistent/dao/IStrategyDao.java
create mode 100644 xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/persistent/dao/IStrategyRuleDao.java
create mode 100644 xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/persistent/po/Award.java
create mode 100644 xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/persistent/po/StrategyRule.java
diff --git a/pom.xml b/pom.xml
index bb8f0b0..25781bf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,10 +25,8 @@
- xiaofuge
- 184172133@qq.com
- fuzhengwei
- https://github.com/fuzhengwei
+ 郭雨
+ 964587616@qq.com
diff --git a/xfg-frame-archetype-lite-app/src/main/java/cn/bugstack/Application.java b/xfg-frame-archetype-lite-app/src/main/java/cn/bugstack/Application.java
index 178667e..cd00689 100644
--- a/xfg-frame-archetype-lite-app/src/main/java/cn/bugstack/Application.java
+++ b/xfg-frame-archetype-lite-app/src/main/java/cn/bugstack/Application.java
@@ -1,11 +1,15 @@
package cn.bugstack;
+import org.apache.ibatis.annotations.Mapper;
+import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@Configurable
+@EnableScheduling
public class Application {
public static void main(String[] args){
diff --git a/xfg-frame-archetype-lite-app/src/main/resources/application-dev.yml b/xfg-frame-archetype-lite-app/src/main/resources/application-dev.yml
index 0f3c50e..bc097bb 100644
--- a/xfg-frame-archetype-lite-app/src/main/resources/application-dev.yml
+++ b/xfg-frame-archetype-lite-app/src/main/resources/application-dev.yml
@@ -17,7 +17,7 @@ spring:
datasource:
username: root
password: root
- url: jdbc:mysql://192.168.119.130/big_market?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&serverTimezone=UTC&useSSL=true
+ url: jdbc:mysql://117.7.2:3306/big_market?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&serverTimezone=UTC&useSSL=true
driver-class-name: com.mysql.cj.jdbc.Driver
hikari:
pool-name: Retail_HikariCP
@@ -30,9 +30,9 @@ spring:
connection-test-query: SELECT 1
type: com.zaxxer.hikari.HikariDataSource
-#mybatis:
-# mapper-locations: classpath:/mybatis/mapper/*.xml
-# config-location: classpath:/mybatis/config/mybatis-config.xml
+mybatis:
+ mapper-locations: classpath:/mybatis/mapper/*.xml
+ config-location: classpath:/mybatis/config/mybatis-config.xml
# 日志
logging:
diff --git a/xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/strategy_award_mapper.xml b/xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/strategy_award_mapper.xml
new file mode 100644
index 0000000..4f9aea5
--- /dev/null
+++ b/xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/strategy_award_mapper.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ update strategy_award
+ set award_count_surplus = award_count_surplus - 1
+ where strategy_id = #{strategyId} and award_id = #{awardId} and award_count_surplus > 0
+
+
+
+
+
diff --git a/xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/strategy_mapper.xml b/xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/strategy_mapper.xml
new file mode 100644
index 0000000..e31d3e3
--- /dev/null
+++ b/xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/strategy_mapper.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/strategy_rule_mapper.xml b/xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/strategy_rule_mapper.xml
new file mode 100644
index 0000000..6c060bb
--- /dev/null
+++ b/xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/strategy_rule_mapper.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/AwardDaoTest.java b/xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/AwardDaoTest.java
similarity index 79%
rename from xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/AwardDaoTest.java
rename to xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/AwardDaoTest.java
index 57c9915..5f77ecb 100644
--- a/xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/AwardDaoTest.java
+++ b/xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/AwardDaoTest.java
@@ -1,4 +1,4 @@
-package cn.bugstack.test;
+package cn.bugstack.test.infrastructure;
import cn.bugstack.infrastructure.persistent.dao.IAwardDao;
import cn.bugstack.infrastructure.persistent.po.Award;
@@ -6,6 +6,8 @@ import com.alibaba.fastjson2.JSON;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
diff --git a/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/persistent/dao/IAwardDao.java b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/persistent/dao/IAwardDao.java
new file mode 100644
index 0000000..501ce67
--- /dev/null
+++ b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/persistent/dao/IAwardDao.java
@@ -0,0 +1,18 @@
+package cn.bugstack.infrastructure.persistent.dao;
+
+import cn.bugstack.infrastructure.persistent.po.Award;
+import org.apache.ibatis.annotations.Mapper;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * @author Hugohimself
+ * @description 奖品表DAO
+ */
+@Mapper
+public interface IAwardDao {
+
+ List queryAwardList();
+
+}
diff --git a/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/persistent/dao/IStrategyAwardDao.java b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/persistent/dao/IStrategyAwardDao.java
new file mode 100644
index 0000000..aee0dc8
--- /dev/null
+++ b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/persistent/dao/IStrategyAwardDao.java
@@ -0,0 +1,25 @@
+package cn.bugstack.infrastructure.persistent.dao;
+
+import cn.bugstack.infrastructure.persistent.po.StrategyAward;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ * @author Hugohimself
+ * @description 抽奖策略奖品明细配置 - 概率、规则 DAO
+ */
+@Mapper
+public interface IStrategyAwardDao {
+
+ List queryStrategyAwardList();
+
+ List queryStrategyAwardListByStrategyId(Long strategyId);
+
+ String queryStrategyAwardRuleModels(StrategyAward strategyAward);
+
+ void updateStrategyAwardStock(StrategyAward strategyAward);
+
+ StrategyAward queryStrategyAward(StrategyAward strategyAwardReq);
+
+}
diff --git a/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/persistent/dao/IStrategyDao.java b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/persistent/dao/IStrategyDao.java
new file mode 100644
index 0000000..c57cd3e
--- /dev/null
+++ b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/persistent/dao/IStrategyDao.java
@@ -0,0 +1,20 @@
+package cn.bugstack.infrastructure.persistent.dao;
+
+import cn.bugstack.infrastructure.persistent.po.Strategy;
+import cn.bugstack.infrastructure.persistent.po.StrategyAward;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ * @author Hugohimself
+ * @description 抽奖策略 DAO
+ */
+@Mapper
+public interface IStrategyDao {
+
+ List queryStrategyList();
+
+ Strategy queryStrategyByStrategyId(Long strategyId);
+
+}
diff --git a/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/persistent/dao/IStrategyRuleDao.java b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/persistent/dao/IStrategyRuleDao.java
new file mode 100644
index 0000000..5238fa7
--- /dev/null
+++ b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/persistent/dao/IStrategyRuleDao.java
@@ -0,0 +1,22 @@
+package cn.bugstack.infrastructure.persistent.dao;
+
+import cn.bugstack.infrastructure.persistent.po.StrategyRule;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Hugohimself
+ * @description 策略规则 DAO
+ */
+@Mapper
+public interface IStrategyRuleDao {
+
+ List queryStrategyRuleList();
+
+ StrategyRule queryStrategyRule(StrategyRule strategyRuleReq);
+
+ String queryStrategyRuleValue(StrategyRule strategyRule);
+
+}
diff --git a/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/persistent/po/Award.java b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/persistent/po/Award.java
new file mode 100644
index 0000000..4637150
--- /dev/null
+++ b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/persistent/po/Award.java
@@ -0,0 +1,29 @@
+package cn.bugstack.infrastructure.persistent.po;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author Hugohimself
+ * @description 奖品表
+ */
+@Data
+public class Award {
+
+ /** 自增ID */
+ private Long id;
+ /** 抽奖奖品ID - 内部流转使用 */
+ private Integer awardId;
+ /** 奖品对接标识 - 每一个都是一个对应的发奖策略 */
+ private String awardKey;
+ /** 奖品配置信息 */
+ private String awardConfig;
+ /** 奖品内容描述 */
+ private String awardDesc;
+ /** 创建时间 */
+ private Date createTime;
+ /** 更新时间 */
+ private Date updateTime;
+
+}
diff --git a/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/persistent/po/StrategyRule.java b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/persistent/po/StrategyRule.java
new file mode 100644
index 0000000..bf279df
--- /dev/null
+++ b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/persistent/po/StrategyRule.java
@@ -0,0 +1,33 @@
+package cn.bugstack.infrastructure.persistent.po;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author Hugohimself
+ * @description 策略规则
+ */
+@Data
+public class StrategyRule {
+
+ /** 自增ID */
+ private Long id;
+ /** 抽奖策略ID */
+ private Long strategyId;
+ /** 抽奖奖品ID【规则类型为策略,则不需要奖品ID】 */
+ private Integer awardId;
+ /** 抽象规则类型;1-策略规则、2-奖品规则 */
+ private Integer ruleType;
+ /** 抽奖规则类型【rule_random - 随机值计算、rule_lock - 抽奖几次后解锁、rule_luck_award - 幸运奖(兜底奖品)】 */
+ private String ruleModel;
+ /** 抽奖规则比值 */
+ private String ruleValue;
+ /** 抽奖规则描述 */
+ private String ruleDesc;
+ /** 创建时间 */
+ private Date createTime;
+ /** 更新时间 */
+ private Date updateTime;
+
+}
--
GitLab