add event option
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
CREATE TABLE IF NOT EXISTS `gao_event_option_group` (
|
||||
`id` VARCHAR(36) NOT NULL,
|
||||
`event_id` VARCHAR(36) NOT NULL COMMENT '登记事件 ID',
|
||||
`name` VARCHAR(64) NOT NULL COMMENT '选项组名称',
|
||||
`selection_mode` VARCHAR(16) NOT NULL COMMENT '选择模式,SINGLE 单选,MULTIPLE 多选',
|
||||
`required` BIT(1) NOT NULL DEFAULT b'0' COMMENT 'true 为登记时必须选择至少一个选项',
|
||||
`sort` INT NOT NULL DEFAULT 0 COMMENT '排序值',
|
||||
`created_at` BIGINT NOT NULL,
|
||||
`updated_at` BIGINT NULL,
|
||||
`deleted_at` BIGINT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_gao_event_option_group_event` (`event_id`, `deleted_at`, `sort`, `created_at`)
|
||||
) COMMENT='登记事件选项组';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `gao_event_option` (
|
||||
`id` VARCHAR(36) NOT NULL,
|
||||
`group_id` VARCHAR(36) NOT NULL COMMENT '选项组 ID',
|
||||
`label` VARCHAR(128) NOT NULL COMMENT '选项名称',
|
||||
`sort` INT NOT NULL DEFAULT 0 COMMENT '排序值',
|
||||
`created_at` BIGINT NOT NULL,
|
||||
`updated_at` BIGINT NULL,
|
||||
`deleted_at` BIGINT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_gao_event_option_group` (`group_id`, `deleted_at`, `sort`, `created_at`)
|
||||
) COMMENT='登记事件选项';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `gao_event_record_option` (
|
||||
`id` VARCHAR(36) NOT NULL,
|
||||
`event_record_id` VARCHAR(36) NOT NULL COMMENT '登记事件记录 ID',
|
||||
`group_id` VARCHAR(36) NOT NULL COMMENT '选项组 ID',
|
||||
`option_id` VARCHAR(36) NOT NULL COMMENT '选项 ID',
|
||||
`group_sort` INT NOT NULL DEFAULT 0 COMMENT '选项组排序快照',
|
||||
`option_sort` INT NOT NULL DEFAULT 0 COMMENT '选项排序快照',
|
||||
`group_name_snapshot` VARCHAR(64) NOT NULL COMMENT '选项组名称快照',
|
||||
`option_label_snapshot` VARCHAR(128) NOT NULL COMMENT '选项名称快照',
|
||||
`created_at` BIGINT NOT NULL,
|
||||
`updated_at` BIGINT NULL,
|
||||
`deleted_at` BIGINT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_gao_event_record_option` (`event_record_id`, `option_id`, `deleted_at`),
|
||||
KEY `idx_gao_event_record_option_option` (`option_id`, `deleted_at`, `event_record_id`),
|
||||
KEY `idx_gao_event_record_option_group` (`group_id`, `deleted_at`, `event_record_id`)
|
||||
) COMMENT='登记事件记录选项';
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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.gao.mapper.GaoEventOptionGroupMapper">
|
||||
<select id="selectAllByEventIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoEventOptionGroup">
|
||||
SELECT
|
||||
*
|
||||
FROM `gao_event_option_group`
|
||||
WHERE
|
||||
TRUE
|
||||
<if test="eventIdList != null and !eventIdList.isEmpty()">
|
||||
AND `event_id` IN
|
||||
<foreach collection="eventIdList" item="eventId" separator="," open="(" close=")">
|
||||
#{eventId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="eventIdList == null or eventIdList.isEmpty()">
|
||||
AND FALSE
|
||||
</if>
|
||||
AND `deleted_at` IS NULL
|
||||
ORDER BY `sort`, `created_at`
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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.gao.mapper.GaoEventOptionMapper">
|
||||
<select id="selectAllByGroupIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoEventOption">
|
||||
SELECT
|
||||
*
|
||||
FROM `gao_event_option`
|
||||
WHERE
|
||||
TRUE
|
||||
<if test="groupIdList != null and !groupIdList.isEmpty()">
|
||||
AND `group_id` IN
|
||||
<foreach collection="groupIdList" item="groupId" separator="," open="(" close=")">
|
||||
#{groupId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="groupIdList == null or groupIdList.isEmpty()">
|
||||
AND FALSE
|
||||
</if>
|
||||
AND `deleted_at` IS NULL
|
||||
ORDER BY `sort`, `created_at`
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -118,6 +118,17 @@
|
||||
#{eventId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="optionIdList != null and optionIdList.size() > 0">
|
||||
<foreach collection="optionIdList" item="optionId">
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM `gao_event_record_option` fro
|
||||
WHERE fro.`event_record_id` = r.`id`
|
||||
AND fro.`option_id` = #{optionId}
|
||||
AND fro.`deleted_at` IS NULL
|
||||
)
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="verificationStatus != null">
|
||||
AND r.`verification_status` = #{verificationStatus}
|
||||
</if>
|
||||
@@ -154,6 +165,27 @@
|
||||
<include refid="rangeWhere"/>
|
||||
AND r.`number_value` IS NOT NULL
|
||||
</select>
|
||||
<select id="selectOptionStatByRange" resultType="com.imyeyu.api.modules.gao.vo.GaoEventOptionStatView">
|
||||
SELECT
|
||||
ro.`group_id` AS `groupId`,
|
||||
ro.`group_name_snapshot` AS `groupName`,
|
||||
ro.`option_id` AS `optionId`,
|
||||
ro.`option_label_snapshot` AS `optionLabel`,
|
||||
COUNT(DISTINCT ro.`event_record_id`) AS `recordCount`
|
||||
FROM `gao_event_record` r
|
||||
INNER JOIN `gao_event_record_option` ro ON ro.`event_record_id` = r.`id`
|
||||
WHERE
|
||||
<include refid="rangeWhere"/>
|
||||
AND ro.`deleted_at` IS NULL
|
||||
GROUP BY
|
||||
ro.`group_id`,
|
||||
ro.`group_name_snapshot`,
|
||||
ro.`option_id`,
|
||||
ro.`option_label_snapshot`,
|
||||
ro.`group_sort`,
|
||||
ro.`option_sort`
|
||||
ORDER BY ro.`group_sort`, ro.`option_sort`
|
||||
</select>
|
||||
|
||||
<sql id="rankWhere">
|
||||
r.`deleted_at` IS NULL
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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.gao.mapper.GaoEventRecordOptionMapper">
|
||||
<select id="selectAllByEventRecordIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoEventRecordOption">
|
||||
SELECT
|
||||
*
|
||||
FROM `gao_event_record_option`
|
||||
WHERE
|
||||
TRUE
|
||||
<if test="eventRecordIdList != null and !eventRecordIdList.isEmpty()">
|
||||
AND `event_record_id` IN
|
||||
<foreach collection="eventRecordIdList" item="eventRecordId" separator="," open="(" close=")">
|
||||
#{eventRecordId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="eventRecordIdList == null or eventRecordIdList.isEmpty()">
|
||||
AND FALSE
|
||||
</if>
|
||||
AND `deleted_at` IS NULL
|
||||
ORDER BY `group_sort`, `option_sort`, `created_at`
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user