123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- <?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.ym.mec.cms.dal.dao.SysNewsInformationDao">
-
- <resultMap type="com.ym.mec.cms.dal.entity.SysNewsInformation" id="SysNewsInformation">
- <result column="id_" property="id" />
- <result column="title_" property="title" />
- <result column="content_" property="content" />
- <result column="cover_image_" property="coverImage" />
- <result column="video_cover_image_" property="videoCoverImage" />
- <result column="link_url_" property="linkUrl"/>
- <result column="type_" property="type"/>
- <result column="online_time_" property="onlineTime"/>
- <result column="offline_time_" property="offlineTime"/>
- <result column="sub_type_" property="subType"/>
- <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler" />
- <result column="create_time_" property="createTime" />
- <result column="update_time_" property="updateTime" />
- <result column="del_flag_" property="delFlag" />
- <result column="href_target_" property="hrefTarget" />
- <result column="order_" property="order" />
- <result column="memo_" property="memo" />
- <result column="tenant_id_" property="tenantId" />
- <result column="attribute1_" property="attribute1" />
- <result column="attribute2_" property="attribute2" />
- <result column="subject_id_list_" property="subjectIdList" />
- <result column="organ_id_list_" property="organIdList" />
- <result column="subject_name_" property="subjectName" />
- </resultMap>
-
- <resultMap type="com.ym.mec.cms.dto.SysNewsInformationDto" id="SysNewsInformationDto" extends="SysNewsInformation">
- <result column="typeName" property="typeName" />
- <result column="subTypeName" property="subTypeName" />
- </resultMap>
-
- <sql id="queryCondition">
- <where>
- sni.del_flag_=0
- <if test="type != null">
- and sni.type_ = #{type}
- </if>
- <if test="subType != null">
- and sni.sub_type_ = #{subType}
- </if>
- <if test="tenantId != null">
- and sni.tenant_id_ = #{tenantId}
- </if>
- <if test="status != null">
- and sni.status_ = #{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- <if test="title != null">
- and sni.title_ like '%' #{title} '%'
- </if>
- <if test="search != null">
- and sni.title_ like '%' #{search} '%'
- </if>
- <if test="subjectId != null">
- and find_in_set(#{subjectId},sni.subject_id_list_)
- </if>
- <if test="clientName != 'manage'">
- <choose>
- <when test="memo != null and memo != ''">
- and sni.memo_ = #{memo}
- </when>
- <otherwise>
- and (sni.memo_ is null or sni.memo_ = '')
- </otherwise>
- </choose>
- </if>
- </where>
- </sql>
-
- <!-- 根据主键查询一条记录 -->
- <select id="get" resultMap="SysNewsInformation" >
- SELECT * FROM sys_news_information WHERE id_ = #{id} AND del_flag_=0
- </select>
-
- <!-- 全查询 -->
- <select id="findAll" resultMap="SysNewsInformation">
- SELECT * FROM sys_news_information WHERE del_flag_=0 ORDER BY id_
- </select>
-
- <!-- 向数据库增加一条记录 -->
- <insert id="insert" parameterType="com.ym.mec.cms.dal.entity.SysNewsInformation" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
- INSERT INTO sys_news_information (id_,title_,content_,cover_image_,video_cover_image_,type_,online_time_,offline_time_,sub_type_,status_,create_time_,update_time_,link_url_,href_target_,order_,del_flag_,memo_,tenant_id_,attribute1_,attribute2_,subject_id_list_)
- VALUES(#{id},#{title},#{content},#{coverImage},#{videoCoverImage},#{type},#{onlineTime},#{offlineTime},#{subType},#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},now(),now(),#{linkUrl},#{hrefTarget},#{order},0,#{memo},#{tenantId},#{attribute1},#{attribute2},#{subjectIdList})
- </insert>
-
- <!-- 根据主键查询一条记录 -->
- <update id="update" parameterType="com.ym.mec.cms.dal.entity.SysNewsInformation">
- UPDATE sys_news_information
- <set>
- <if test="status != null">
- status_ = #{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="title != null">
- title_ = #{title},
- </if>
- <if test="tenantId != null">
- tenant_id_ = #{tenantId},
- </if>
- <if test="updateTime != null">
- update_time_ = NOW(),
- </if>
- <if test="content != null">
- content_ = #{content},
- </if>
- <if test="coverImage != null">
- cover_image_ = #{coverImage},
- </if>
- <if test="videoCoverImage != null">
- video_cover_image_ = #{videoCoverImage},
- </if>
- <if test="type != null">
- type_ = #{type},
- </if>
- <if test="onlineTime != null">
- online_time_ = #{onlineTime},
- </if>
- <if test="offlineTime != null">
- offline_time_ = #{offlineTime},
- </if>
- <if test="subType != null">
- sub_type_ = #{subType},
- </if>
- <if test="linkUrl != null">
- link_url_ = #{linkUrl},
- </if>
- <if test="hrefTarget != null">
- href_target_ = #{hrefTarget},
- </if>
- <if test="order != null">
- order_ = #{order},
- </if>
- <if test="memo != null">
- memo_ = #{memo},
- </if>
- <if test="delFlag != null">
- del_flag_ = #{delFlag},
- </if>
- <if test="attribute1 != null">
- attribute1_ = #{attribute1},
- </if>
- <if test="attribute2 != null">
- attribute2_ = #{attribute2},
- </if>
- <if test="subjectIdList != null">
- subject_id_list_ = #{subjectIdList},
- </if>
- </set>
- WHERE id_ = #{id}
- </update>
-
- <!-- 根据主键删除一条记录 -->
- <delete id="delete" >
- DELETE FROM sys_news_information WHERE id_ = #{id}
- </delete>
-
- <!-- 分页查询 -->
- <select id="queryPage" resultMap="SysNewsInformation" parameterType="map">
- SELECT sni.*,GROUP_CONCAT(s.name_) subject_name_ FROM sys_news_information sni left join subject s on find_in_set(s.id_,sni.subject_id_list_)
- <include refid="queryCondition" />
- group by sni.id_
- order by sni.status_ desc,sni.order_ desc,sni.update_time_ desc
- <include refid="global.limit"/>
- </select>
-
- <!-- 查询当前表的总记录数 -->
- <select id="queryCount" resultType="int">
- SELECT COUNT(sni.id_) FROM sys_news_information sni
- <include refid="queryCondition" />
- </select>
-
- <select id="queryByType" resultMap="SysNewsInformation" parameterType="java.lang.Integer">
- SELECT * FROM sys_news_information
- <where>
- del_flag_=0
- <if test="type != null">
- and type_ = #{type}
- </if>
- </where>
- </select>
-
- <update id="deleteWithLogical">
- UPDATE sys_news_information SET del_flag_ = 1,update_time_ = NOW() WHERE id_ = #{id}
- </update>
-
- <!-- 分页查询 -->
- <select id="queryHomePage" resultMap="SysNewsInformation"
- parameterType="map">
- SELECT sni.*,GROUP_CONCAT(s.name_) subject_name_ FROM sys_news_information sni left join subject s on find_in_set(s.id_,sni.subject_id_list_) where sni.del_flag_=0
- <if test="type != null">
- and sni.type_ = #{type}
- </if>
- <if test="subType != null">
- and sni.sub_type_ = #{subType}
- </if>
- <if test="status != null">
- and sni.status_ = #{status,
- typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- <if test="title != null">
- and sni.title_ like '%' #{title} '%'
- </if>
- <if test="search != null">
- and sni.title_ like '%' #{search} '%'
- </if>
- <if test="tenantId != null">
- and sni.tenant_id_ = #{tenantId}
- </if>
- <if test="subjectId != null">
- and find_in_set(#{subjectId},sni.subject_id_list_)
- </if>
- <if test="organId != null">
- and (find_in_set(#{organId},sni.organ_id_list_) or sni.organ_id_list_ is null)
- </if>
- <if test="clientName != 'manage'">
- <choose>
- <when test="memo != null and memo != ''">
- and sni.memo_ = #{memo}
- </when>
- <otherwise>
- and (sni.memo_ is null or sni.memo_ = '')
- </otherwise>
- </choose>
- </if>
- group by sni.id_
- order by sni.status_ desc,sni.order_ desc,sni.update_time_ desc
- <include refid="global.limit" />
- </select>
- <!-- 查询当前表的总记录数 -->
- <select id="queryHomeCount" resultType="int">
- SELECT COUNT(sni.id_) FROM sys_news_information sni where sni.del_flag_=0
- <if test="type != null">
- and sni.type_ = #{type}
- </if>
- <if test="subType != null">
- and sni.sub_type_ = #{subType}
- </if>
- <if test="status != null">
- and sni.status_ = #{status,
- typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- <if test="title != null">
- and sni.title_ like '%' #{title} '%'
- </if>
- <if test="search != null">
- and sni.title_ like '%' #{search} '%'
- </if>
- <if test="tenantId != null">
- and sni.tenant_id_ = #{tenantId}
- </if>
- <if test="subjectId != null">
- and find_in_set(#{subjectId},sni.subject_id_list_)
- </if>
- <if test="organId != null">
- and (find_in_set(#{organId},sni.organ_id_list_) or sni.organ_id_list_ is null)
- </if>
- <if test="clientName != 'manage'">
- <choose>
- <when test="memo != null and memo != ''">
- and sni.memo_ = #{memo}
- </when>
- <otherwise>
- and (sni.memo_ is null or sni.memo_ = '')
- </otherwise>
- </choose>
- </if>
- </select>
-
- <select id="queryNeedUpdateStatusList" resultMap="SysNewsInformation" >
- SELECT * FROM sys_news_information WHERE del_flag_ = 0 and (
- (online_time_ is not null and now() between online_time_ and offline_time_ and status_ = 0)
- or (offline_time_ is not null and offline_time_ <= now() and status_ = 1)
- or (online_time_ is not null and online_time_ >= now() and status_ = 1)
- )
- </select>
-
- <select id="queryById" resultMap="SysNewsInformationDto" >
- SELECT sni.*,sntp.name_ typeName,snts.name_ subTypeName FROM sys_news_information sni
- left join sys_news_type sntp on sni.type_ = sntp.id_
- left join sys_news_type snts on sni.sub_type_ = snts.id_
- where sni.id_ = #{id}
- </select>
- </mapper>
|