854 lines
33 KiB
XML
854 lines
33 KiB
XML
<?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.zhwl.cms.mapper.ZdyCmsArchivesMapper">
|
|
|
|
<resultMap type="ZdyCmsArchives" id="ZdyCmsArchivesResult">
|
|
<result property="id" column="id"/>
|
|
<result property="userId" column="user_id"/>
|
|
<result property="channelId" column="channel_id"/>
|
|
<result property="channelName" column="channel_name"/>
|
|
<result property="modelId" column="model_id"/>
|
|
<result property="title" column="title"/>
|
|
<result property="flag" column="flag"/>
|
|
<result property="style" column="style"/>
|
|
<result property="image" column="image"/>
|
|
<result property="keywords" column="keywords"/>
|
|
<result property="description" column="description"/>
|
|
<result property="tags" column="tags"/>
|
|
<result property="weigh" column="weigh"/>
|
|
<result property="views" column="views"/>
|
|
<result property="comments" column="comments"/>
|
|
<result property="likes" column="likes"/>
|
|
<result property="dislikes" column="dislikes"/>
|
|
<result property="diyname" column="diyname"/>
|
|
<result property="createtime" column="createtime"/>
|
|
<result property="updatetime" column="updatetime"/>
|
|
<result property="publishtime" column="publishtime"/>
|
|
<result property="deletetime" column="deletetime"/>
|
|
<result property="memo" column="memo"/>
|
|
<result property="status" column="status"/>
|
|
<result property="adminId" column="admin_id"/>
|
|
<result property="dataOrg" column="data_org"/>
|
|
<result property="subtitle" column="subtitle"/>
|
|
<result property="origin" column="origin"/>
|
|
<result property="imageList" column="image_list"/>
|
|
<result property="userName" column="user_name"/>
|
|
<result property="avatar" column="avatar"/>
|
|
<result property="channelKey" column="channelKey"/>
|
|
<result property="rejectionDesc" column="rejection_desc"/>
|
|
<result property="rejectionTime" column="rejection_time"/>
|
|
<result property="auditStatus" column="audit_status"/>
|
|
</resultMap>
|
|
|
|
<sql id="selectZdyCmsArchivesVo">
|
|
SELECT a.id,
|
|
a.user_id,
|
|
a.channel_id,
|
|
a.model_id,
|
|
a.title,
|
|
a.flag,
|
|
a.style,
|
|
a.image,
|
|
a.keywords,
|
|
a.description,
|
|
a.tags,
|
|
a.weigh,
|
|
a.views,
|
|
a.comments,
|
|
a.likes,
|
|
a.dislikes,
|
|
a.diyname,
|
|
a.createtime,
|
|
a.updatetime,
|
|
a.publishtime,
|
|
a.deletetime,
|
|
a.memo,
|
|
a.`status`,
|
|
a.admin_id,
|
|
a.data_org,
|
|
a.subtitle,
|
|
a.origin,
|
|
a.image_list,
|
|
a.rejection_desc,
|
|
a.rejection_time,
|
|
a.audit_status,
|
|
if(a.admin_id != 0, u.nick_name, zu.nickname) as user_name,
|
|
if(a.admin_id != 0, u.avatar, zu.avatar) as avatar
|
|
from zdy_cms_archives a
|
|
left join sys_user u on a.admin_id = u.user_id
|
|
left join zdy_user zu on a.user_id= zu.id
|
|
</sql>
|
|
<select id="selectZdyCmsArchivesList" parameterType="ZdyCmsArchives" resultMap="ZdyCmsArchivesResult">
|
|
<include refid="selectZdyCmsArchivesVo"/>
|
|
left join sys_dept d on u.dept_id = d.dept_id
|
|
left join zdy_cms_channel c on a.channel_id = c.id
|
|
<where>
|
|
ISNULL( deletetime )
|
|
<if test="ids != null and ids.size > 0">
|
|
and a.id in
|
|
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
<if test="title != null and title != ''">and a.title like concat('%',#{title},'%')</if>
|
|
<if test="status != null and status != ''">and a.status = #{status}</if>
|
|
<if test="auditStatus != null and auditStatus != ''">and a.audit_status = #{auditStatus}</if>
|
|
<if test="modelId != null">and a.model_id = #{modelId}</if>
|
|
<if test="userId != null">and a.user_id = #{userId}</if>
|
|
<choose>
|
|
<when test="channelId != null">and a.channel_id = #{channelId}</when>
|
|
<when test="channelIds != null and channelIds.size>0">
|
|
and a.channel_id in
|
|
<foreach item="id" collection="channelIds" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</when>
|
|
<when test="channelList != null">
|
|
and a.channel_id in
|
|
<foreach item="id" collection="channelList" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</when>
|
|
<otherwise>
|
|
and c.status = 'normal'
|
|
</otherwise>
|
|
</choose>
|
|
<if test="modelList != null">
|
|
and a.model_id in
|
|
<foreach item="id" collection="modelList" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
<if test="adminIds != null">and admin_id in
|
|
<foreach item="admin_id" collection="adminIds" open="(" separator="," close=")">
|
|
#{admin_id}
|
|
</foreach>
|
|
</if>
|
|
<if test="flag != null and flag != ''">
|
|
<foreach collection="flag.split(',') " item="item" index="index" open=" AND (" close=")"
|
|
separator=" AND ">
|
|
find_in_set(#{item}, flag)
|
|
</foreach>
|
|
</if>
|
|
<if test="params.publishTime != null ">
|
|
<if test="params.publishTime.start != null ">
|
|
and publishtime >= #{params.publishTime.start}
|
|
</if>
|
|
<if test="params.publishTime.end != null ">
|
|
and publishtime <= #{params.publishTime.end}
|
|
</if>
|
|
</if>
|
|
<if test="params.dataScope != null and params.dataScope != ''">
|
|
and ((admin_id != 0 ${params.dataScope}) OR (a.user_id != 0))
|
|
</if>
|
|
</where>
|
|
order by
|
|
<choose>
|
|
<when test="orderby == null or orderby == ''">
|
|
a.publishtime desc
|
|
</when>
|
|
<when test="orderby == 'flag'">
|
|
<if test="orderByValue != null and orderByValue != ''">
|
|
<foreach collection="orderByValue.split(',') " item="item" index="index" separator="," close=",">
|
|
find_in_set(#{item}, a.flag) desc
|
|
</foreach>
|
|
</if>
|
|
a.publishtime desc
|
|
</when>
|
|
<otherwise>
|
|
a.${orderby} ${orderway}
|
|
</otherwise>
|
|
</choose>
|
|
|
|
</select>
|
|
|
|
<select id="selectZdyCmsArchivesById" parameterType="Integer" resultMap="ZdyCmsArchivesResult">
|
|
<include refid="selectZdyCmsArchivesVo"/>
|
|
where a.id = #{id}
|
|
</select>
|
|
|
|
|
|
<insert id="insertZdyCmsArchives" parameterType="ZdyCmsArchives" useGeneratedKeys="true" keyProperty="id">
|
|
insert into zdy_cms_archives
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="userId != null">user_id,</if>
|
|
<if test="channelId != null">channel_id,</if>
|
|
<if test="modelId != null">model_id,</if>
|
|
<if test="title != null">title,</if>
|
|
<if test="flag != null">flag,</if>
|
|
<if test="style != null">style,</if>
|
|
<if test="image != null">image,</if>
|
|
<if test="keywords != null">keywords,</if>
|
|
<if test="description != null">description,</if>
|
|
<if test="tags != null">tags,</if>
|
|
<if test="weigh != null">weigh,</if>
|
|
<if test="views != null">views,</if>
|
|
<if test="comments != null">comments,</if>
|
|
<if test="likes != null">likes,</if>
|
|
<if test="dislikes != null">dislikes,</if>
|
|
<if test="diyname != null">diyname,</if>
|
|
<if test="createtime != null">createtime,</if>
|
|
<if test="updatetime != null">updatetime,</if>
|
|
<if test="publishtime != null">publishtime,</if>
|
|
<if test="deletetime != null">deletetime,</if>
|
|
<if test="memo != null">memo,</if>
|
|
<if test="status != null and status != ''">status,</if>
|
|
<if test="adminId != null">admin_id,</if>
|
|
<if test="subtitle != null and subtitle != ''">subtitle,</if>
|
|
<if test="origin != null and origin != ''">origin,</if>
|
|
<if test="imageList != null and imageList!=''">image_list,</if>
|
|
<if test="rejectionDesc != null and rejectionDesc!=''">rejection_desc,</if>
|
|
<if test="rejectionTime != null">rejection_time</if>
|
|
<if test="auditStatus != null and auditStatus!=''">audit_status,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="userId != null">#{userId},</if>
|
|
<if test="channelId != null">#{channelId},</if>
|
|
<if test="modelId != null">#{modelId},</if>
|
|
<if test="title != null">#{title},</if>
|
|
<if test="flag != null">#{flag},</if>
|
|
<if test="style != null">#{style},</if>
|
|
<if test="image != null">#{image},</if>
|
|
<if test="keywords != null">#{keywords},</if>
|
|
<if test="description != null">#{description},</if>
|
|
<if test="tags != null">#{tags},</if>
|
|
<if test="weigh != null">#{weigh},</if>
|
|
<if test="views != null">#{views},</if>
|
|
<if test="comments != null">#{comments},</if>
|
|
<if test="likes != null">#{likes},</if>
|
|
<if test="dislikes != null">#{dislikes},</if>
|
|
<if test="diyname != null">#{diyname},</if>
|
|
<if test="createtime != null">#{createtime},</if>
|
|
<if test="updatetime != null">#{updatetime},</if>
|
|
<if test="publishtime != null">#{publishtime},</if>
|
|
<if test="deletetime != null">#{deletetime},</if>
|
|
<if test="memo != null">#{memo},</if>
|
|
<if test="status != null and status != ''">#{status},</if>
|
|
<if test="adminId != null">#{adminId},</if>
|
|
<if test="subtitle != null and subtitle != ''">#{subtitle},</if>
|
|
<if test="origin != null and origin != ''">#{origin},</if>
|
|
<if test="imageList != null and imageList!=''">#{imageList},</if>
|
|
<if test="rejectionDesc != null and rejectionDesc!=''">#{rejectionDesc},</if>
|
|
<if test="rejectionTime != null">#{rejectionTime},</if>
|
|
<if test="auditStatus != null and auditStatus!=''">#{auditStatus},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateZdyCmsArchives" parameterType="ZdyCmsArchives">
|
|
update zdy_cms_archives
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="userId != null">user_id = #{userId},</if>
|
|
<if test="channelId != null">channel_id = #{channelId},</if>
|
|
<if test="modelId != null">model_id = #{modelId},</if>
|
|
<if test="title != null">title = #{title},</if>
|
|
<choose>
|
|
<when test="flag != null and flag != '' ">
|
|
flag = #{flag},
|
|
</when>
|
|
<otherwise>
|
|
flag = '',
|
|
</otherwise>
|
|
</choose>
|
|
<if test="style != null">style = #{style},</if>
|
|
<if test="image != null">image = #{image},</if>
|
|
<if test="keywords != null">keywords = #{keywords},</if>
|
|
<if test="description != null">description = #{description},</if>
|
|
<if test="tags != null">tags = #{tags},</if>
|
|
<if test="weigh != null">weigh = #{weigh},</if>
|
|
<if test="views != null">views = #{views},</if>
|
|
<if test="comments != null">comments = #{comments},</if>
|
|
<if test="likes != null">likes = #{likes},</if>
|
|
<if test="dislikes != null">dislikes = #{dislikes},</if>
|
|
<if test="diyname != null">diyname = #{diyname},</if>
|
|
<if test="createtime != null">createtime = #{createtime},</if>
|
|
<if test="updatetime != null">updatetime = #{updatetime},</if>
|
|
<if test="publishtime != null">publishtime = #{publishtime},</if>
|
|
<if test="deletetime != null">deletetime = #{deletetime},</if>
|
|
<if test="memo != null">memo = #{memo},</if>
|
|
<if test="status != null and status != ''">status = #{status},</if>
|
|
<if test="adminId != null">admin_id = #{adminId},</if>
|
|
<if test="subtitle != null">subtitle = #{subtitle},</if>
|
|
<if test="origin != null">origin = #{origin},</if>
|
|
<if test="imageList != null and imageList!=''">image_list = #{imageList},</if>
|
|
<if test="rejectionDesc != null and rejectionDesc!=''">rejection_desc = #{rejectionDesc},</if>
|
|
<if test="rejectionTime != null">rejection_time = #{rejectionTime},</if>
|
|
<if test="auditStatus != null and auditStatus!=''">audit_status = #{auditStatus},</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<delete id="deleteZdyCmsArchivesById" parameterType="Integer">
|
|
delete
|
|
from zdy_cms_archives
|
|
where id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteZdyCmsArchivesByIds" parameterType="String">
|
|
delete from zdy_cms_archives where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<update id="updateZdyCmsArchivesByIds" parameterType="String">
|
|
update zdy_cms_archives set deletetime = UNIX_TIMESTAMP(now())
|
|
where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</update>
|
|
|
|
<select id="selectArchivesListByCustom" resultType="java.util.Map">
|
|
select
|
|
<choose>
|
|
<when test="field != null and field != ''">a.${field}</when>
|
|
<otherwise>a.*
|
|
</otherwise>
|
|
</choose>
|
|
<choose>
|
|
<when test="addon == 'true'">
|
|
<foreach collection='params.fileds' item="key" open="," separator="," close="">b.${key} as B_${key}
|
|
</foreach>
|
|
from ${tableName} b left join zdy_cms_archives a on a.id = b.id
|
|
</when>
|
|
<otherwise>
|
|
from zdy_cms_archives a
|
|
</otherwise>
|
|
</choose>
|
|
<where>
|
|
ISNULL( a.deletetime )
|
|
<if test="addPageIds != null">
|
|
and a.id not in
|
|
<foreach item="pageId" collection="addPageIds" open="(" separator="," close=")">
|
|
#{pageId}
|
|
</foreach>
|
|
</if>
|
|
<if test="model != null and model != ''">and a.model_id = #{model}</if>
|
|
<if test="channel != null and channel != '' ">and a.channel_id = #{channel}</if>
|
|
<if test="channels != null and channels.length != 0">and a.channel_id in
|
|
<foreach item="channel_id" collection="channels" open="(" separator="," close=")">
|
|
#{channel_id}
|
|
</foreach>
|
|
</if>
|
|
<if test="params.user_id != null and params.user_id != ''">and a.user_id = #{params.user_id}</if>
|
|
<if test="tags != null and tags != ''">and FIND_IN_SET(#{tags},a.tags)</if>
|
|
<if test="tagArr != null and tagArr.length != 0">and a.tags in
|
|
<foreach item="tag" collection="tagArr" open="(" separator="," close=")">
|
|
#{tag}
|
|
</foreach>
|
|
</if>
|
|
<if test="status != null and status != ''">and a.status = #{status}</if>
|
|
<if test="title != null and title != ''">and a.title like concat('%',#{title},'%')</if>
|
|
<if test="noFlags != null and noFlags != ''">and
|
|
<foreach item="flag" collection="noFlags" open="(" separator=" and " close=")">
|
|
!FIND_IN_SET(#{flag},a.flag)
|
|
</foreach>
|
|
</if>
|
|
<if test="flags != null and flags != ''">and
|
|
<foreach item="flag" collection="flags" open="(" separator=" OR " close=")">
|
|
FIND_IN_SET(#{flag},a.flag)
|
|
</foreach>
|
|
</if>
|
|
<if test="content != null and content != ''">and b.content like concat('%',#{content},'%')</if>
|
|
<if test="conditionmap != null and conditionmap.size()!=0">and
|
|
<foreach collection="conditionmap.entrySet()" index="key" item="val" separator="and">
|
|
b.${key} = "${val}"
|
|
</foreach>
|
|
</if>
|
|
<if test="conditiontime != null and conditiontime != ''">and b.${conditiontime} > now()</if>
|
|
<if test="conditionArray != null and conditionArray.size()!=0">and
|
|
<foreach collection="conditionArray.entrySet()" index="key" item="val" open="(" separator="and"
|
|
close=")">
|
|
FIND_IN_SET(#{val},b.${key})
|
|
</foreach>
|
|
</if>
|
|
<if test="conditionList != null and conditionList.size()!=0">and
|
|
<foreach collection="conditionList.entrySet()" index="key" item="val" open="(" separator="and"
|
|
close=")">
|
|
<foreach collection="val" index="key0" item="val0" open="(" separator="or" close=")">
|
|
FIND_IN_SET(#{val0},b.${key})
|
|
</foreach>
|
|
</foreach>
|
|
</if>
|
|
and a.id is not null
|
|
<if test="params.orderby != null and params.orderway != null">
|
|
order by b.${params.orderby} ${params.orderway}
|
|
</if>
|
|
</where>
|
|
<if test="groupby != null and groupby != ''">group by a.${groupby}</if>
|
|
<if test="orderby != null and orderby != ''">order by a.${orderby} ${orderway}</if>
|
|
<if test="orderbyList != null and orderbyList.size != 0">order by
|
|
<foreach item="o" collection="orderbyList" open="" separator="," close="">
|
|
<choose>
|
|
<when test="o.orderby == 'flag'">
|
|
FIND_IN_SET(#{o.field},a.${o.orderby}) ${o.orderway}
|
|
</when>
|
|
<otherwise>
|
|
a.${o.orderby} ${o.orderway}
|
|
</otherwise>
|
|
</choose>
|
|
|
|
</foreach>
|
|
</if>
|
|
|
|
<if test="limit != null and limit != ''">limit ${limit}</if>
|
|
|
|
|
|
</select>
|
|
|
|
<select id="selectArchivesByCustomId" resultType="map">
|
|
select a.*
|
|
<if test="params.fileds != null">
|
|
<foreach collection='params.fileds' item="key" open="," separator="," close="">b.${key} as B_${key}
|
|
</foreach>
|
|
</if>
|
|
from zdy_cms_archives a
|
|
left join ${tableName} b on a.id = b.id
|
|
where a.id = #{id}
|
|
</select>
|
|
|
|
<select id="selectColumns" resultType="java.lang.String">
|
|
select COLUMN_NAME
|
|
from information_schema.COLUMNS
|
|
where table_name = #{tableName}
|
|
</select>
|
|
|
|
<select id="listJoinSubData" parameterType="com.zhwl.cms.domain.ZdyCmsArchives" resultType="java.util.Map">
|
|
SELECT
|
|
a.id,
|
|
a.user_id,
|
|
a.channel_id,
|
|
a.model_id,
|
|
a.title,
|
|
a.flag,
|
|
a.style,
|
|
a.image,
|
|
a.keywords,
|
|
a.description,
|
|
a.tags,
|
|
a.weigh,
|
|
a.views,
|
|
a.comments,
|
|
a.likes,
|
|
a.dislikes,
|
|
a.diyname,
|
|
a.createtime,
|
|
a.updatetime,
|
|
a.publishtime,
|
|
a.deletetime,
|
|
a.memo,
|
|
a.status,
|
|
a.subtitle,
|
|
a.data_org as dataOrg,
|
|
a.origin,
|
|
a.image_list,
|
|
a.rejection_desc,
|
|
a.audit_status
|
|
<if test="zdyCmsModel.fields != null and zdyCmsModel.fields != ''">
|
|
,
|
|
<foreach item="field" collection="zdyCmsModel.fields.split(',')" separator=",">
|
|
b.${field}
|
|
</foreach>
|
|
</if>
|
|
FROM
|
|
zdy_cms_archives a
|
|
LEFT JOIN ${zdyCmsModel.table} b on a.id = b.id
|
|
<where>
|
|
ISNULL( a.deletetime )
|
|
<if test="ids != null and ids.size > 0">
|
|
and a.id in
|
|
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
<if test="title != null and title != ''">and a.title like concat('%', #{title}, '%')</if>
|
|
<if test="tags != null and tags != ''">and FIND_IN_SET(#{tags}, a.tags)</if>
|
|
<if test="status != null and status != ''">and a.status = #{status}</if>
|
|
<if test="modelId != null">and a.model_id = #{modelId}</if>
|
|
<if test="channelId != null">and a.channel_id = #{channelId}</if>
|
|
<if test="flag != null">and FIND_IN_SET(#{flag}, a.flag)</if>
|
|
<if test="modelList != null">
|
|
and a.model_id in
|
|
<foreach item="id" collection="modelList" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
<if test="channelList != null">
|
|
and a.channel_id in
|
|
<foreach item="id" collection="channelList" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
<if test="params != null">
|
|
<if test="params.createTime != null ">
|
|
<if test="params.createTime.start != null ">
|
|
and createtime >= #{params.createTime.start}
|
|
</if>
|
|
<if test="params.createTime.end != null ">
|
|
and createtime <= #{params.createTime.end}
|
|
</if>
|
|
</if>
|
|
<if test="params.updateTime != null ">
|
|
<if test="params.updateTime.start != null ">
|
|
and updatetime >= #{params.updateTime.start}
|
|
</if>
|
|
<if test="params.updateTime.end != null ">
|
|
and updatetime <= #{params.updateTime.end}
|
|
</if>
|
|
</if>
|
|
<if test="params.publishTime != null ">
|
|
<if test="params.publishTime.start != null ">
|
|
and publishtime >= #{params.publishTime.start}
|
|
</if>
|
|
<if test="params.publishTime.end != null ">
|
|
and publishtime <= #{params.publishTime.end}
|
|
</if>
|
|
</if>
|
|
|
|
</if>
|
|
</where>
|
|
order by a.publishtime desc
|
|
</select>
|
|
|
|
<select id="joinSubDataById" parameterType="com.zhwl.cms.domain.ZdyCmsArchives" resultType="java.util.Map">
|
|
SELECT
|
|
a.id,
|
|
a.user_id,
|
|
a.channel_id,
|
|
a.model_id,
|
|
a.title,
|
|
a.flag,
|
|
a.style,
|
|
a.image,
|
|
a.keywords,
|
|
a.description,
|
|
a.tags,
|
|
a.weigh,
|
|
a.views,
|
|
a.comments,
|
|
a.likes,
|
|
a.dislikes,
|
|
a.diyname,
|
|
a.createtime,
|
|
a.updatetime,
|
|
a.publishtime,
|
|
a.deletetime,
|
|
a.memo,
|
|
a.status,
|
|
a.subtitle,
|
|
b.content,
|
|
a.origin,
|
|
a.image_list,
|
|
a.rejection_desc,
|
|
a.audit_status,
|
|
u.user_name as userName,
|
|
u.avatar
|
|
<if test="zdyCmsModel.fields != null and zdyCmsModel.fields != ''">
|
|
,
|
|
<foreach item="field" collection="zdyCmsModel.fields.split(',')" separator=",">
|
|
b.${field}
|
|
</foreach>
|
|
</if>
|
|
FROM
|
|
zdy_cms_archives a
|
|
LEFT JOIN ${zdyCmsModel.table} b on a.id = b.id
|
|
LEFT JOIN sys_user u on u.user_id = a.admin_id
|
|
where a.id = #{id}
|
|
and a.model_id = #{modelId}
|
|
</select>
|
|
|
|
<insert id="commonInsertOrUpdateSubData">
|
|
insert into ${tableName}
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<foreach collection="fieldData" index="key" item="value" separator=",">
|
|
${key}
|
|
</foreach>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<foreach collection="fieldData" index="key" item="value" separator=",">
|
|
#{value}
|
|
</foreach>
|
|
</trim>
|
|
on duplicate key update
|
|
<foreach collection="fieldData" index="key" item="value" separator=",">
|
|
${key} = values(${key})
|
|
</foreach>
|
|
</insert>
|
|
|
|
<select id="selectContentById" parameterType="com.zhwl.cms.domain.ZdyCmsArchives" resultType="java.lang.String">
|
|
select content
|
|
from ${zdyCmsModel.table}
|
|
where id = #{id}
|
|
</select>
|
|
|
|
<insert id="insertOrUpdateContentById" parameterType="com.zhwl.cms.domain.ZdyCmsArchives">
|
|
insert into ${zdyCmsModel.table} (id, content)
|
|
values (#{id}, #{content}) on duplicate key
|
|
update
|
|
content =
|
|
values (content)
|
|
</insert>
|
|
|
|
|
|
<select id="countByChannelIds" parameterType="com.zhwl.cms.domain.ZdyCmsArchives" resultType="java.lang.Long">
|
|
SELECT count(*)
|
|
FROM
|
|
`zdy_cms_archives` `a`
|
|
WHERE `a`.`status` = 'normal'
|
|
AND ISNULL(a.deletetime)
|
|
<if test="channelList != null">
|
|
and a.channel_id in
|
|
<foreach item="id" collection="channelList" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
</select>
|
|
|
|
|
|
<select id="countGroupByChannelId" parameterType="java.util.List" resultType="com.zhwl.cms.domain.ZdyCmsArchives">
|
|
SELECT
|
|
a.channel_id as channelId,
|
|
count(*) AS total
|
|
FROM
|
|
zdy_cms_archives a
|
|
WHERE
|
|
`a`.`status` = 'normal'
|
|
AND ISNULL( a.deletetime )
|
|
AND a.channel_id IN
|
|
<foreach item="id" collection="list" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
GROUP BY
|
|
a.channel_id
|
|
</select>
|
|
|
|
|
|
<select id="globalSearch" resultType="com.zhwl.cms.domain.ZdyCmsArchives">
|
|
select id, user_id, channel_id, model_id, title, flag, style, image, keywords, description, tags, weigh, views,
|
|
comments, likes, dislikes, diyname, memo, status,admin_id,data_org,subtitle,image_list from zdy_cms_archives
|
|
<where>
|
|
ISNULL(deletetime) and status = 'normal'
|
|
<if test="key != null and key != ''">
|
|
and (title like concat("%",#{key},"%")
|
|
or keywords like concat("%",#{key},"%")
|
|
or description like concat("%",#{key},"%"))
|
|
</if>
|
|
<if test="modelId != null and modelId != ''">
|
|
and model_id = #{modelId}
|
|
</if>
|
|
</where>
|
|
order by publishtime desc
|
|
</select>
|
|
|
|
<select id="querySubDataById" parameterType="com.zhwl.cms.domain.ZdyCmsArchives" resultType="java.util.Map">
|
|
SELECT
|
|
b.id,
|
|
b.content
|
|
<if test="zdyCmsModel.fields != null and zdyCmsModel.fields != ''">
|
|
,
|
|
<foreach item="field" collection="zdyCmsModel.fields.split(',')" separator=",">
|
|
b.${field}
|
|
</foreach>
|
|
</if>
|
|
FROM
|
|
${zdyCmsModel.table} b
|
|
where b.id = #{id}
|
|
</select>
|
|
|
|
|
|
<select id="getInfo" resultType="java.util.Map" parameterType="com.zhwl.cms.domain.ZdyCmsModel">
|
|
SELECT
|
|
<choose>
|
|
<when test="fields != null and fields != ''">
|
|
${fields}
|
|
</when>
|
|
<otherwise>
|
|
*
|
|
</otherwise>
|
|
</choose>
|
|
FROM
|
|
${table}
|
|
where id = #{id}
|
|
</select>
|
|
<select id="searchZdyCmsArchivesList" parameterType="ZdyCmsArchives" resultType="java.util.Map">
|
|
SELECT
|
|
b.id,
|
|
a.content,
|
|
b.model_id as modelId,
|
|
b.channel_id as channelId,
|
|
b.title,
|
|
b.image,
|
|
b.description,
|
|
b.weigh,
|
|
publishtime,
|
|
b.deletetime,
|
|
b.STATUS,
|
|
b.data_org as dataOrg
|
|
FROM
|
|
zdy_cms_archives b
|
|
LEFT JOIN
|
|
<if test="tables != null">
|
|
<foreach item="name" collection="tables" open="(" separator="UNION ALL" close=")">
|
|
SELECT
|
|
id,
|
|
content
|
|
FROM
|
|
${name}
|
|
</foreach>
|
|
</if>
|
|
a ON a.id = b.id
|
|
WHERE
|
|
b.STATUS = 'normal'
|
|
AND ISNULL( b.deletetime )
|
|
AND ( b.title LIKE concat('%',#{title},'%') OR a.content LIKE concat('%',#{title},'%') )
|
|
<if test="adminIds != null and adminIds.length != 0">and b.admin_id in
|
|
<foreach item="admin_id" collection="adminIds" open="(" separator="," close=")">
|
|
#{admin_id}
|
|
</foreach>
|
|
</if>
|
|
<if test="userIds != null and userIds.length != 0">and b.user_id in
|
|
<foreach item="user_id" collection="userIds" open="(" separator="," close=")">
|
|
#{user_id}
|
|
</foreach>
|
|
</if>
|
|
ORDER BY
|
|
b.publishtime DESC
|
|
|
|
</select>
|
|
|
|
<select id="selectZdyCmsArchivesListByChannelId" parameterType="Integer" resultMap="ZdyCmsArchivesResult">
|
|
SELECT
|
|
arc.id,
|
|
arc.model_id,
|
|
arc.channel_id,
|
|
arc.title,
|
|
arc.image,
|
|
arc.description,
|
|
arc.weigh,
|
|
arc.publishtime,
|
|
arc.deletetime,
|
|
arc.STATUS,
|
|
arc.flag,
|
|
arc.views,
|
|
arc.admin_id,
|
|
arc.user_id,
|
|
arc.keywords,
|
|
arc.image_list,
|
|
arc.subtitle,
|
|
arc.rejection_desc,
|
|
arc.audit_status,
|
|
u.user_name,
|
|
u.avatar,
|
|
ch.keywords AS channelKey
|
|
FROM
|
|
zdy_cms_archives arc
|
|
LEFT JOIN sys_user u ON u.user_id = arc.admin_id
|
|
LEFT JOIN zdy_cms_channel ch ON ch.id = arc.channel_id
|
|
WHERE
|
|
arc.channel_id = #{channelId} and ISNULL(arc.deletetime) and arc.status = 'normal'
|
|
<if test="flag != null and flag != ''">and FIND_IN_SET(#{flag},arc.flag)</if>
|
|
ORDER BY
|
|
arc.publishtime DESC
|
|
|
|
</select>
|
|
|
|
<select id="selectZdyUserCollect" parameterType="Long" resultMap="ZdyCmsArchivesResult">
|
|
SELECT a.id,
|
|
a.user_id,
|
|
a.channel_id,
|
|
c.name as channel_name,
|
|
a.model_id,
|
|
a.title,
|
|
a.flag,
|
|
a.style,
|
|
a.image,
|
|
a.keywords,
|
|
a.description,
|
|
a.tags,
|
|
a.weigh,
|
|
a.views,
|
|
a.comments,
|
|
a.likes,
|
|
a.dislikes,
|
|
a.diyname,
|
|
a.createtime,
|
|
a.updatetime,
|
|
a.publishtime,
|
|
a.deletetime,
|
|
a.memo,
|
|
a.`status`,
|
|
a.admin_id,
|
|
a.data_org,
|
|
a.subtitle,
|
|
a.origin,
|
|
a.image_list,
|
|
a.rejection_desc,
|
|
a.rejection_time,
|
|
a.audit_status,
|
|
if(a.admin_id != 0, u.nick_name, zu.nickname) as user_name,
|
|
if(a.admin_id != 0, u.avatar, zu.avatar) as avatar
|
|
from zdy_cms_archives a
|
|
inner join zdy_user_collect b on a.id = b.archives_id
|
|
left join sys_user u on a.admin_id = u.user_id
|
|
left join zdy_user zu on a.user_id= zu.id
|
|
left join zdy_cms_channel c on a.channel_id = c.id
|
|
<where>
|
|
b.user_id = #{userId}
|
|
<if test="zdyCmsArchives.flag != null and zdyCmsArchives.flag != ''">
|
|
<foreach collection="zdyCmsArchives.flag.split(',') " item="item" index="index" open=" AND (" close=")"
|
|
separator=" AND ">
|
|
find_in_set(#{item}, a.flag)
|
|
</foreach>
|
|
</if>
|
|
<choose>
|
|
<when test="zdyCmsArchives.channelId != null">and a.channel_id = #{zdyCmsArchives.channelId}</when>
|
|
<when test="zdyCmsArchives.channelIds != null and zdyCmsArchives.channelIds.size>0">
|
|
and a.channel_id in
|
|
<foreach item="id" collection="zdyCmsArchives.channelIds" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</when>
|
|
<when test="zdyCmsArchives.channelList != null">
|
|
and a.channel_id in
|
|
<foreach item="id" collection="zdyCmsArchives.channelList" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</when>
|
|
</choose>
|
|
</where>
|
|
order by b.create_time desc
|
|
</select>
|
|
|
|
<update id="addComments">
|
|
update zdy_cms_archives set comments = comments + #{comments} where id = #{id}
|
|
</update>
|
|
|
|
<select id="existsArchivesNotOwnedByOperator" resultType="Integer">
|
|
select exists(
|
|
select 1 from
|
|
zdy_cms_archives
|
|
where id in
|
|
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
and user_id != #{operatorId}
|
|
)
|
|
</select>
|
|
<select id="selectFoodRecommendList" resultType="java.util.Map">
|
|
SELECT
|
|
title,description
|
|
FROM
|
|
zdy_cms_archives
|
|
where channel_id in (17,22) and ISNULL(deletetime)
|
|
</select>
|
|
|
|
<update id="updateVisibility" parameterType="ZdyCmsArchives">
|
|
update zdy_cms_archives
|
|
set `status` = #{status}
|
|
where id = #{id}
|
|
</update>
|
|
|
|
</mapper>
|