147 lines
5.3 KiB
XML
147 lines
5.3 KiB
XML
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.caliverse.admin.domain.dao.admin.MenuMapper">
|
|
<resultMap id="MenuResultMap" type="com.caliverse.admin.domain.entity.MenuBanner">
|
|
<id property="id" column="id"/>
|
|
<result property="rowNum" column="row_num"/>
|
|
<result property="title" column="title"/>
|
|
<result property="isLink" column="is_link"/>
|
|
<result property="status" column="status"/>
|
|
<result property="startDt" column="start_dt"/>
|
|
<result property="endDt" column="end_dt"/>
|
|
<result property="createBy" column="create_by"/>
|
|
<result property="createDt" column="create_dt"/>
|
|
<result property="updateBy" column="update_by"/>
|
|
<result property="updateDt" column="update_dt"/>
|
|
</resultMap>
|
|
<resultMap id="MessageResultMap" type="com.caliverse.admin.domain.entity.Message">
|
|
<result property="title" column="title"/>
|
|
<result property="language" column="language"/>
|
|
<result property="content" column="content"/>
|
|
</resultMap>
|
|
|
|
<!--리스트 조회-->
|
|
<select id="getBannerList" resultMap="MenuResultMap" parameterType="map">
|
|
SELECT (@row_number:=@row_number + 1) AS row_num , c.*
|
|
FROM (
|
|
SELECT
|
|
a.id
|
|
, a.title
|
|
, a.is_link
|
|
, a.status
|
|
, a.start_dt
|
|
, a.end_dt
|
|
, (SELECT email FROM admin WHERE id = a.create_by ) AS create_by
|
|
, a.create_dt
|
|
, (SELECT email FROM admin WHERE id = a.update_by ) AS update_by
|
|
, a.update_dt
|
|
FROM menu_banner a
|
|
WHERE 1 = 1
|
|
AND a.deleted = 0
|
|
|
|
<if test="search_data != null and search_data != ''">
|
|
AND a.title LIKE CONCAT('%',#{search_data},'%')
|
|
</if>
|
|
|
|
<if test="status != null and status != ''">
|
|
<choose>
|
|
<when test="status != 'ALL' ">
|
|
AND a.status = #{status}
|
|
</when>
|
|
</choose>
|
|
</if>
|
|
|
|
<if test="start_dt != null and start_dt != '' and end_dt !=null and end_dt!= ''">
|
|
AND a.start_dt >= #{start_dt, jdbcType=TIMESTAMP}
|
|
AND a.end_dt <= #{end_dt, jdbcType=TIMESTAMP}
|
|
</if>
|
|
|
|
ORDER BY a.create_dt
|
|
)c
|
|
, (SELECT @row_number:=0) AS t
|
|
<if test="orderby != null and orderby != ''">
|
|
ORDER BY row_num ${orderby}
|
|
</if>
|
|
<if test="pageSize != null and pageSize != ''">
|
|
LIMIT ${pageSize} OFFSET ${offset}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="getTotal" resultType="java.lang.Integer" parameterType="map">
|
|
SELECT count(*) FROM menu_banner WHERE deleted = 0
|
|
</select>
|
|
|
|
<select id="getBannerDetail" parameterType="java.lang.Long" resultMap="MenuResultMap" >
|
|
SELECT
|
|
a.id
|
|
, a.title
|
|
, a.is_link
|
|
, a.start_dt
|
|
, a.end_dt
|
|
, a.status
|
|
, (SELECT email FROM admin WHERE id = a.create_by ) AS create_by
|
|
, a.create_dt
|
|
, (SELECT email FROM admin WHERE id = a.update_by ) AS update_by
|
|
, a.update_dt
|
|
FROM menu_banner a
|
|
WHERE a.id = #{id}
|
|
AND deleted = 0
|
|
</select>
|
|
|
|
<select id="getMessage" parameterType="java.lang.Long" resultMap="MessageResultMap" >
|
|
SELECT
|
|
*
|
|
FROM message
|
|
WHERE target_id = #{id}
|
|
AND type = 'BANNER'
|
|
</select>
|
|
|
|
<insert id="insertBanner" parameterType="com.caliverse.admin.domain.request.MenuRequest" useGeneratedKeys="true" keyProperty="id">
|
|
INSERT INTO menu_banner (title, is_link, start_dt, end_dt)
|
|
VALUES (#{title}, #{isLink}, #{startDt}, #{endDt})
|
|
</insert>
|
|
|
|
<insert id="insertMessage" parameterType="map">
|
|
INSERT INTO message (target_id, type, title, content, language)
|
|
VALUES (#{id}, 'BANNER', #{title}, #{content}, #{language})
|
|
</insert>
|
|
|
|
<update id="updateBanner" parameterType="com.caliverse.admin.domain.request.MenuRequest">
|
|
UPDATE menu_banner SET target = #{target}
|
|
, is_reserve = #{isReserve}
|
|
, receive_type = #{receiveType}
|
|
, send_type =#{sendType}
|
|
, mail_type = #{mailType}
|
|
, send_dt = #{sendDt}
|
|
, update_by = #{updateBy}
|
|
, update_dt = NOW()
|
|
WHERE id = #{id}
|
|
</update>
|
|
|
|
<update id="deleteMessage" parameterType="map">
|
|
DELETE FROM message
|
|
WHERE target_id = #{mailId}
|
|
</update>
|
|
|
|
<update id="deleteBanner" parameterType="map">
|
|
UPDATE menu_banner SET deleted = 1
|
|
WHERE id = #{id}
|
|
</update>
|
|
|
|
<select id="getScheduleBannerList" resultMap="MenuResultMap">
|
|
SELECT id,
|
|
, a.title
|
|
, a.is_link
|
|
, a.start_dt
|
|
, a.end_dt
|
|
FROM menu_banner
|
|
WHERE send_status = 'WAIT'
|
|
AND deleted = false
|
|
</select>
|
|
|
|
<update id="updateBannerStatus" parameterType="map">
|
|
UPDATE menu_banner SET status = #{status}
|
|
where id = #{id}
|
|
</update>
|
|
|
|
</mapper>
|