123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- <?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.caimei.modules.cmpage.dao.CmPageCentreDao">
-
- <sql id="cmPageCentreColumns">
- a.id AS "id",
- a.pageId AS "pageId",
- a.title AS "title",
- a.link AS "link",
- a.sort AS "sort",
- a.description AS "description",
- a.enabledStatus AS "enabledStatus",
- a.crmEnabledStatus AS "crmEnabledStatus",
- a.createBy AS "createBy.id",
- a.createDate AS "createDate",
- a.updateBy AS "updateBy.id",
- a.updateDate AS "updateDate",
- (SELECT count(1) FROM cm_page_centre_image a1 WHERE a1.centreId = a.id ) imageNum
- </sql>
-
- <sql id="cmPageCentreJoins">
- </sql>
-
- <select id="get" resultType="CmPageCentre">
- SELECT
- <include refid="cmPageCentreColumns"/>
- FROM cm_page_centre a
- <include refid="cmPageCentreJoins"/>
- WHERE a.id = #{id}
- </select>
-
- <select id="findList" resultType="CmPageCentre">
- SELECT
- <include refid="cmPageCentreColumns"/>
- FROM cm_page_centre a
- <include refid="cmPageCentreJoins"/>
- <where>
-
- <if test="pageId != null and pageId != ''">
- AND a.pageId = #{pageId}
- </if>
- <if test="title != null and title != ''">
- AND a.title LIKE
- <if test="dbName == 'oracle'">'%'||#{title}||'%'</if>
- <if test="dbName == 'mssql'">'%'+#{title}+'%'</if>
- <if test="dbName == 'mysql'">concat('%',#{title},'%')</if>
- </if>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- ORDER BY -a.sort DESC,a.createDate DESC
- </otherwise>
- </choose>
- </select>
-
- <select id="findAllList" resultType="CmPageCentre">
- SELECT
- <include refid="cmPageCentreColumns"/>
- FROM cm_page_centre a
- <include refid="cmPageCentreJoins"/>
- <where>
-
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
-
- <insert id="insert" parameterType="CmPageCentre" keyProperty="id" useGeneratedKeys="true">
- INSERT INTO cm_page_centre(
- pageId,
- title,
- link,
- sort,
- description,
- enabledStatus,
- crmEnabledStatus,
- createBy,
- createDate,
- updateBy,
- updateDate
- ) VALUES (
- #{pageId},
- #{title},
- #{link},
- #{sort},
- #{description},
- #{enabledStatus},
- #{crmEnabledStatus},
- #{createBy.id},
- #{createDate},
- #{updateBy.id},
- #{updateDate}
- )
- </insert>
-
- <update id="update">
- UPDATE cm_page_centre SET
- pageId = #{pageId},
- title = #{title},
- link = #{link},
- sort = #{sort},
- description = #{description},
- enabledStatus = #{enabledStatus},
- crmEnabledStatus = #{crmEnabledStatus},
- updateBy = #{updateBy.id},
- updateDate = #{updateDate}
- WHERE id = #{id}
- </update>
-
- <delete id="delete">
- DELETE FROM cm_page_centre
- WHERE id = #{id}
- </delete>
- <update id="updateEnabledStatusByIds">
- UPDATE cm_page_centre a SET a.enabledStatus = #{param1}
- WHERE a.id IN
- <foreach collection="param2" item="id" index="index" open="(" separator="," close=")">
- #{id}
- </foreach>
- </update>
- <delete id="deletePageCentreImage">
- DELETE FROM cm_page_centre_image
- WHERE centreId = #{param1}
- </delete>
- <insert id="insertPageCentreImage">
- INSERT INTO cm_page_centre_image(centreId, imageId)
- <foreach collection="param2" item="imageId" separator=" union all ">
- SELECT #{param1}, #{imageId}
- </foreach>
- </insert>
- <insert id="insetImageActivity">
- INSERT INTO cm_page_image_activity(actTypeId, imageId) VALUES(#{actTypeId},#{imageId})
- </insert>
- <delete id="deleteImageActivity">
- DELETE FROM cm_page_image_activity
- WHERE imageId = #{imageId}
- </delete>
- <update id="updateCrmEnabledStatusByIds">
- UPDATE cm_page_centre a SET a.crmEnabledStatus = #{param1}
- WHERE a.id IN
- <foreach collection="param2" item="id" index="index" open="(" separator="," close=")" >
- #{id}
- </foreach>
- </update>
- <update id="saveSort">
- UPDATE cm_page_centre SET
- sort = #{sort}
- WHERE id = #{id}
- </update>
- <select id="findFloorContentByCentreId" resultType="com.caimei.modules.newhome.entity.NewPageFloorContent">
- SELECT
- npfc.*,
- cpc.title AS floorTitle
- FROM
- cm_page_centre cpc
- LEFT JOIN new_page_floor_content npfc ON npfc.centreId = cpc.id
- WHERE
- cpc.id = #{centreId}
- </select>
- <select id="findFloorImage" resultType="com.caimei.modules.newhome.entity.NewPageFloorImage">
- SELECT
- id,
- floorId,
- centreId,
- productId,
- `name`,
- content,
- link,
- image,
- appletsImage,
- adsImage,
- `label`,
- pcStatus,
- appletsStatus,
- sort,
- DATE_FORMAT(createDate,'%Y-%m-%d %H:%i:%S') AS createDate
- FROM
- new_page_floor_image
- WHERE
- centreId = #{centreId}
- </select>
- <select id="findPageTitle" resultType="java.lang.String">
- select title from cm_page where id = #{pageId}
- </select>
- <delete id="deletePageImage">
- DELETE cpi,cpci FROM
- cm_page_image cpi,
- cm_page_centre_image cpci
- WHERE
- cpi.id = cpci.imageId
- AND cpci.centreId = #{centreId}
- </delete>
- </mapper>
|