幸运25-雪花主键-mq-无锁化唯一主键插入

This commit is contained in:
2025-09-25 11:06:29 +08:00
parent e4e60e999f
commit 5118107ead
5 changed files with 93 additions and 68 deletions

View File

@@ -11,7 +11,7 @@ import java.util.Date;
@Data
public class Lucky25Record {
@TableId(type = IdType.AUTO)
@TableId(type = IdType.INPUT)
private Long id;
private Integer partitionId;
private Long uid;

View File

@@ -11,6 +11,11 @@ import java.util.List;
public interface Lucky25RecordMapper extends BaseMapper<Lucky25Record> {
/**
* 批量插入记录,使用 INSERT IGNORE 忽略重复记录
*/
int insertIgnore(@Param("record") Lucky25Record record);
List<Lucky25PlatformStat> listPlatform(@Param("partitionId") Integer partitionId, @Param("startTime") Date startTime, @Param("endTime") Date endTime,
@Param("zoneIdHour") long zoneIdHour);
@@ -19,4 +24,4 @@ public interface Lucky25RecordMapper extends BaseMapper<Lucky25Record> {
@Param("startTime") Date startTime, @Param("endTime") Date endTime,
@Param("zoneIdHour") long zoneIdHour);
}
}

View File

@@ -2,6 +2,43 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.accompany.sharding.mapper.Lucky25RecordMapper">
<insert id="insertIgnore">
INSERT IGNORE INTO lucky_25_record (
id,
partition_id,
uid,
receiver_uid,
room_uid,
gift_id,
gift_gold_price,
gift_num,
pool_id,
is_supplement,
draw_multiple,
after_multiple,
win_gold_num,
create_time,
mess_id
) VALUES
(
#{record.id},
#{record.partitionId},
#{record.uid},
#{record.receiverUid},
#{record.roomUid},
#{record.giftId},
#{record.giftGoldPrice},
#{record.giftNum},
#{record.poolId},
#{record.isSupplement},
#{record.drawMultiple},
#{record.afterMultiple},
#{record.winGoldNum},
#{record.createTime},
#{record.messId}
)
</insert>
<select id="listPlatform" resultType="com.accompany.sharding.vo.Lucky25PlatformStat">
select `date`, partition_id,
sum(`totalInput`) `totalInput`, sum(`totalOutput`) `totalOutput`,
@@ -43,4 +80,4 @@
group by `date`, r.uid
</select>
</mapper>
</mapper>