fix notify fail
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
ALTER TABLE `notify`
|
||||
CHANGE COLUMN `biz_reminded_id` `biz_reminded_key` VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '业务提醒查重键',
|
||||
ADD COLUMN `biz_reminded_active_key` TINYINT(1) GENERATED ALWAYS AS (IF(`deleted_at` IS NULL, 1, NULL)) STORED COMMENT '未删除查重键' INVISIBLE AFTER `deleted_at`,
|
||||
DROP INDEX `idx_biz_reminded_created`,
|
||||
ADD INDEX `idx_biz_reminded_key_created`(`biz_type` ASC, `biz_reminded_type` ASC, `biz_reminded_key` ASC, `created_at` ASC) USING BTREE;
|
||||
|
||||
UPDATE `notify` target
|
||||
INNER JOIN (
|
||||
SELECT
|
||||
id,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY biz_type, biz_reminded_type, biz_reminded_key
|
||||
ORDER BY created_at DESC, id DESC
|
||||
) AS rn
|
||||
FROM `notify`
|
||||
WHERE deleted_at IS NULL
|
||||
AND biz_type IS NOT NULL
|
||||
AND biz_reminded_type IS NOT NULL
|
||||
AND biz_reminded_key IS NOT NULL
|
||||
) duplicate ON duplicate.id = target.id
|
||||
SET target.deleted_at = UNIX_TIMESTAMP() * 1000
|
||||
WHERE duplicate.rn > 1;
|
||||
|
||||
ALTER TABLE `notify`
|
||||
ADD UNIQUE INDEX `uk_biz_reminded_key_active`(`biz_type` ASC, `biz_reminded_type` ASC, `biz_reminded_key` ASC, `biz_reminded_active_key` ASC) USING BTREE;
|
||||
@@ -1,6 +1,31 @@
|
||||
<?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="com.imyeyu.api.modules.common.mapper.NotifyMapper">
|
||||
<insert id="insertIfAbsent">
|
||||
INSERT INTO `notify` (
|
||||
`id`,
|
||||
`biz_type`,
|
||||
`biz_reminded_type`,
|
||||
`biz_reminded_key`,
|
||||
`args`,
|
||||
`created_by`,
|
||||
`created_at`,
|
||||
`updated_at`,
|
||||
`deleted_at`
|
||||
) VALUES (
|
||||
#{id},
|
||||
#{bizType},
|
||||
#{bizRemindedType},
|
||||
#{bizRemindedKey},
|
||||
#{args},
|
||||
#{createdBy},
|
||||
#{createdAt},
|
||||
#{updatedAt},
|
||||
#{deletedAt}
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE `id` = `id`
|
||||
</insert>
|
||||
|
||||
<select id="selectManagementPage" resultType="com.imyeyu.api.modules.common.vo.NotifyManagementItem">
|
||||
SELECT
|
||||
n.`id`,
|
||||
|
||||
Reference in New Issue
Block a user