You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
146 lines
7.1 KiB
146 lines
7.1 KiB
<?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.mmxt.business.mapper.MmxtMeiyuTextbookActivateBatchMapper">
|
|
|
|
<resultMap type="com.mmxt.business.domain.MmxtMeiyuTextbookActivateBatch" id="MmxtMeiyuTextbookActivateBatchResult">
|
|
<result property="batchId" column="batch_id" />
|
|
<result property="textbookId" column="textbook_id" />
|
|
<result property="batchName" column="batch_name" />
|
|
<result property="regionId" column="region_id" />
|
|
<result property="activationCount" column="activation_count" />
|
|
<result property="unactivationCount" column="unactivation_count" />
|
|
<result property="createTime" column="create_time" />
|
|
<result property="createBy" column="create_by" />
|
|
<result property="updateTime" column="update_time" />
|
|
<result property="updateBy" column="update_by" />
|
|
<result property="delFlag" column="del_flag" />
|
|
</resultMap>
|
|
|
|
<sql id="selectMmxtMeiyuTextbookActivateBatchVo">
|
|
select batch_id, textbook_id, batch_name, region_id, activation_count, unactivation_count, create_time, create_by, update_time, update_by, del_flag from mmxt_meiyu_textbook_activate_batch
|
|
</sql>
|
|
|
|
<select id="selectMmxtMeiyuTextbookActivateBatchList" parameterType="com.mmxt.business.domain.MmxtMeiyuTextbookActivateBatch" resultMap="MmxtMeiyuTextbookActivateBatchResult">
|
|
WITH RECURSIVE region_tree AS (
|
|
-- 激活码表关联的最底层区域
|
|
SELECT
|
|
r.region_id,
|
|
r.region_name,
|
|
r.parent_id,
|
|
r.region_id AS leaf_region_id,
|
|
CAST(r.region_name AS CHAR(500)) AS full_path
|
|
FROM mmxt_meiyu_region r
|
|
WHERE r.region_id IN (
|
|
SELECT DISTINCT region_id FROM mmxt_meiyu_textbook_activate_batch
|
|
)
|
|
|
|
UNION ALL
|
|
|
|
-- 向上递归父级
|
|
SELECT
|
|
parent.region_id,
|
|
parent.region_name,
|
|
parent.parent_id,
|
|
child.leaf_region_id,
|
|
CONCAT(parent.region_name, '', child.full_path) AS full_path
|
|
FROM mmxt_meiyu_region parent
|
|
INNER JOIN region_tree child
|
|
ON child.parent_id = parent.region_id
|
|
)
|
|
|
|
SELECT
|
|
a.batch_id,
|
|
a.textbook_id,
|
|
a.batch_name,
|
|
a.region_id,
|
|
a.activation_count,
|
|
a.unactivation_count,
|
|
a.create_time,
|
|
a.create_by,
|
|
a.update_time,
|
|
a.update_by,
|
|
rt.full_path AS regionAddr
|
|
FROM mmxt_meiyu_textbook_activate_batch a
|
|
LEFT JOIN region_tree rt
|
|
ON a.region_id = rt.leaf_region_id
|
|
<where>
|
|
a.del_flag = 0 and (rt.parent_id = 0 OR rt.parent_id IS NULL)
|
|
<if test="textbookId != null and textbookId != ''"> and a.textbook_id = #{textbookId}</if>
|
|
<if test="batchName != null and batchName != ''"> and a.batch_name like concat('%', #{batchName}, '%')</if>
|
|
<if test="regionId != null "> and a.region_id = #{regionId}</if>
|
|
<if test="activationCount != null "> and a.activation_count = #{activationCount}</if>
|
|
<if test="unactivationCount != null "> and a.unactivation_count = #{unactivationCount}</if>
|
|
</where>
|
|
order by a.create_time desc,a.batch_id desc
|
|
</select>
|
|
|
|
<select id="selectMmxtMeiyuTextbookActivateBatchByBatchId" parameterType="Long" resultMap="MmxtMeiyuTextbookActivateBatchResult">
|
|
<include refid="selectMmxtMeiyuTextbookActivateBatchVo"/>
|
|
where batch_id = #{batchId} and del_flag = 0
|
|
</select>
|
|
|
|
<insert id="insertMmxtMeiyuTextbookActivateBatch" parameterType="com.mmxt.business.domain.MmxtMeiyuTextbookActivateBatch" useGeneratedKeys="true" keyProperty="batchId">
|
|
insert into mmxt_meiyu_textbook_activate_batch
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="textbookId != null and textbookId != ''">textbook_id,</if>
|
|
<if test="batchName != null">batch_name,</if>
|
|
<if test="regionId != null">region_id,</if>
|
|
<if test="activationCount != null">activation_count,</if>
|
|
<if test="unactivationCount != null">unactivation_count,</if>
|
|
<if test="createTime != null">create_time,</if>
|
|
<if test="createBy != null">create_by,</if>
|
|
<if test="updateTime != null">update_time,</if>
|
|
<if test="updateBy != null">update_by,</if>
|
|
<if test="delFlag != null">del_flag,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="textbookId != null and textbookId != ''">#{textbookId},</if>
|
|
<if test="batchName != null">#{batchName},</if>
|
|
<if test="regionId != null">#{regionId},</if>
|
|
<if test="activationCount != null">#{activationCount},</if>
|
|
<if test="unactivationCount != null">#{unactivationCount},</if>
|
|
<if test="createTime != null">#{createTime},</if>
|
|
<if test="createBy != null">#{createBy},</if>
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
<if test="delFlag != null">#{delFlag},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateMmxtMeiyuTextbookActivateBatch" parameterType="com.mmxt.business.domain.MmxtMeiyuTextbookActivateBatch">
|
|
update mmxt_meiyu_textbook_activate_batch
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="textbookId != null and textbookId != ''">textbook_id = #{textbookId},</if>
|
|
<if test="batchName != null">batch_name = #{batchName},</if>
|
|
<if test="regionId != null">region_id = #{regionId},</if>
|
|
<if test="activationCount != null">activation_count = #{activationCount},</if>
|
|
<if test="unactivationCount != null">unactivation_count = #{unactivationCount},</if>
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
<if test="createBy != null">create_by = #{createBy},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
|
</trim>
|
|
where batch_id = #{batchId}
|
|
</update>
|
|
|
|
<update id="updateBatchUnactivationCount" parameterType="com.mmxt.business.domain.MmxtMeiyuTextbookActivateBatch">
|
|
update mmxt_meiyu_textbook_activate_batch
|
|
set unactivation_count = unactivation_count - #{unactivationCount}
|
|
where batch_id = #{batchId}
|
|
and unactivation_count > 0
|
|
</update>
|
|
|
|
<update id="deleteMmxtMeiyuTextbookActivateBatchByBatchId" parameterType="Long">
|
|
update mmxt_meiyu_textbook_activate_batch set del_flag = 1 where batch_id = #{batchId}
|
|
</update>
|
|
|
|
<update id="deleteMmxtMeiyuTextbookActivateBatchByBatchIds" parameterType="String">
|
|
update mmxt_meiyu_textbook_activate_batch set del_flag = 1 where batch_id in
|
|
<foreach item="batchId" collection="array" open="(" separator="," close=")">
|
|
#{batchId}
|
|
</foreach>
|
|
</update>
|
|
</mapper>
|