提交 a75995b6 编写于 作者: 鲸落和鲨掉's avatar 鲸落和鲨掉

基础层 持久化搭建

上级 4b7910e3
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="@localhost" uuid="89d79d04-f01a-429a-bc28-702ce779f991">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://localhost:13306</jdbc-url>
<jdbc-additional-properties>
<property name="com.intellij.clouds.kubernetes.db.host.port" />
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
<property name="com.intellij.clouds.kubernetes.db.container.port" />
</jdbc-additional-properties>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>
\ No newline at end of file
......@@ -8,5 +8,5 @@
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
</project>
\ No newline at end of file
......@@ -17,7 +17,7 @@ spring:
datasource:
username: root
password: 123456
url: jdbc:mysql://127.0.0.1:3306/xfg_frame_archetype?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&serverTimezone=UTC&useSSL=true
url: jdbc:mysql://127.0.0.1:13306/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
......@@ -29,10 +29,10 @@ spring:
connection-timeout: 30000 #数据库连接超时时间,默认30秒,即30000
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配置
mybatis:
mapper-locations: classpath:/mybatis/mapper/*.xml
config-location: classpath:/mybatis/config/mybatis-config.xml
# 日志
logging:
......
<?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="cn.bugstack.infrastructure.redis.dao.Xxx">
<mapper namespace="cn.bugstack.infrastructure.dao.IAwardDao">
<resultMap id="CaseMap" type="cn.bugstack.infrastructure.redis.po.A">
<resultMap id="dataMap" type="cn.bugstack.infrastructure.dao.po.Award">
<id column="id" property="id"/>
<result column="award_id" property="awardId"/>
<result column="award_key" property="awardKey"/>
<result column="award_config" property="awardConfig"/>
<result column="award_desc" property="awardDesc"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<insert id="insert" parameterType="cn.bugstack.infrastructure.redis.po.A">
INSERT INTO table(a,b,c) VALUES(#{a}, #{b}, #{c})
</insert>
<update id="update" parameterType="cn.bugstack.infrastructure.redis.po.A">
UPDATE table SET a = #{a} WHERE b = #{b}
</update>
</resultMap>
<select id="queryEmployeeByEmployNumber" parameterType="java.lang.String" resultMap="CaseMap">
SELECT a, b, c
FROM table
WHERE a = #{a}
<select id="queryAwardList" resultMap="dataMap">
select award_id, award_key, award_config, award_desc
from award
limit 10
</select>
</mapper>
<?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="cn.bugstack.infrastructure.dao.IStrategyAwardDao">
<resultMap id="dataMap" type="cn.bugstack.infrastructure.dao.po.StrategyAward">
<id column="id" property="id"/>
<result column="strategy_id" property="strategyId"/>
<result column="award_id" property="awardId"/>
<result column="award_title" property="awardTitle"/>
<result column="award_subtitle" property="awardSubtitle"/>
<result column="award_count" property="awardCount"/>
<result column="award_count_surplus" property="awardCountSurplus"/>
<result column="award_rate" property="awardRate"/>
<result column="rule_models" property="ruleModels"/>
<result column="sort" property="sort"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<select id="queryStrategyAwardList" resultMap="dataMap">
select strategy_id
from strategy_award
limit 10
</select>
</mapper>
<?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="cn.bugstack.infrastructure.dao.IStrategyDao">
<resultMap id="dataMap" type="cn.bugstack.infrastructure.dao.po.Strategy">
<id column="id" property="id"/>
<result column="strategy_id" property="strategyId"/>
<result column="strategy_desc" property="strategyDesc"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<select id="queryStrategyList" resultMap="dataMap">
select strategy_id
from strategy
limit 10
</select>
</mapper>
<?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="cn.bugstack.infrastructure.dao.IStrategyRuleDao">
<resultMap id="dataMap" type="cn.bugstack.infrastructure.dao.po.StrategyRule">
<id column="id" property="id"/>
<result column="strategy_id" property="strategyId"/>
<result column="award_id" property="awardId"/>
<result column="rule_type" property="ruleType"/>
<result column="rule_model" property="ruleModel"/>
<result column="rule_value" property="ruleValue"/>
<result column="rule_desc" property="ruleDesc"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<select id="queryStrategyRuleList" resultMap="dataMap">
select strategy_id
from strategy_rule
limit 10
</select>
</mapper>
package cn.bugstack.test.infrastructure;
import cn.bugstack.infrastructure.dao.IAwardDao;
import cn.bugstack.infrastructure.dao.po.Award;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.List;
/**
* @ClassName: AwardDaoTest
* @Description:
* @Author: zhaoyongfeng
* @Date: 2024/11/13 21:12
*/
@SpringBootTest
@Slf4j
@RunWith(SpringRunner.class)
public class AwardDaoTest {
@Resource
private IAwardDao awardDao;
@Test
public void Test_queryAwardList(){
List<Award> awards = awardDao.queryAwardList();
log.info("测试结果:{}",awards);
}
}
package cn.bugstack.infrastructure.dao;
import cn.bugstack.infrastructure.dao.po.Award;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface IAwardDao {
List<Award> queryAwardList();
}
package cn.bugstack.infrastructure.dao;
import cn.bugstack.infrastructure.dao.po.Award;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface IStrategyAwardDao {
List<Award> queryStrategyAwardList();
}
package cn.bugstack.infrastructure.dao;
import cn.bugstack.infrastructure.dao.po.Award;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface IStrategyDao {
List<Award> queryStrategyList();
}
package cn.bugstack.infrastructure.dao;
import cn.bugstack.infrastructure.dao.po.Award;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface IStrategyRuleDao {
List<Award> queryStrategyRuleList();
}
/**
* DAO 接口;IXxxDao
*/
package cn.bugstack.infrastructure.dao;
\ No newline at end of file
package cn.bugstack.infrastructure.dao.po;
import lombok.Data;
import java.util.Date;
/**
* @ClassName: Award
* @Description:
* @Author: zhaoyongfeng
* @Date: 2024/11/13 20:24
*/
@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;
}
package cn.bugstack.infrastructure.dao.po;
import lombok.Data;
import java.util.Date;
/**
* @ClassName: Strategy
* @Description:
* @Author: zhaoyongfeng
* @Date: 2024/11/13 20:26
*/
@Data
public class Strategy {
/* ID*/
private Long id;
/* 抽奖策略描述*/
private Long strategyId;
/* 抽奖策略ID*/
private String strategyDesc;
/* 创建时间*/
private Date createTime;
/* 更新时间*/
private Date updateTime;
}
package cn.bugstack.infrastructure.dao.po;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* @ClassName: StrategyAward
* @Description:
* @Author: zhaoyongfeng
* @Date: 2024/11/13 20:46
*/
@Data
public class StrategyAward {
/** 自增ID */
private Long id;
/** 抽奖策略ID */
private Long strategyId;
/** 抽奖奖品ID - 内部流转使用 */
private Integer awardId;
/** 抽奖奖品标题 */
private String awardTitle;
/** 抽奖奖品副标题 */
private String awardSubtitle;
/** 奖品库存总量 */
private Integer awardCount;
/** 奖品库存剩余 */
private Integer awardCountSurplus;
/** 奖品中奖概率 */
private BigDecimal awardRate;
/** 规则模型,rule配置的模型同步到此表,便于使用 */
private String ruleModels;
/** 排序 */
private Integer sort;
/** 创建时间 */
private Date createTime;
/** 修改时间 */
private Date updateTime;
}
package cn.bugstack.infrastructure.dao.po;
import lombok.Data;
import java.util.Date;
/**
* @ClassName: StrategyRule
* @Description:
* @Author: zhaoyongfeng
* @Date: 2024/11/13 20:47
*/
@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;
}
/**
* 持久化对象;XxxPO 最后的 PO 是大写,UserPO
*/
package cn.bugstack.infrastructure.dao.po;
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册