SysNewsInformationMapper.xml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.ym.mec.cms.dal.dao.SysNewsInformationDao">
  8. <resultMap type="com.ym.mec.cms.dal.entity.SysNewsInformation" id="SysNewsInformation">
  9. <result column="id_" property="id" />
  10. <result column="title_" property="title" />
  11. <result column="content_" property="content" />
  12. <result column="cover_image_" property="coverImage" />
  13. <result column="link_url_" property="linkUrl"/>
  14. <result column="type_" property="type"/>
  15. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler" />
  16. <result column="create_time_" property="createTime" />
  17. <result column="update_time_" property="updateTime" />
  18. <result column="del_flag_" property="delFlag" />
  19. </resultMap>
  20. <sql id="queryCondition">
  21. <where>
  22. del_flag_=0
  23. <if test="type != null">
  24. and type_ = #{type}
  25. </if>
  26. <if test="status != null">
  27. and status_ = #{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  28. </if>
  29. <if test="title != null">
  30. and title_ like '%' #{title} '%'
  31. </if>
  32. <if test="search != null">
  33. and title_ like '%' #{search} '%'
  34. </if>
  35. </where>
  36. </sql>
  37. <!-- 根据主键查询一条记录 -->
  38. <select id="get" resultMap="SysNewsInformation" >
  39. SELECT * FROM sys_news_information WHERE id_ = #{id} AND del_flag_=0
  40. </select>
  41. <!-- 全查询 -->
  42. <select id="findAll" resultMap="SysNewsInformation">
  43. SELECT * FROM sys_news_information WHERE del_flag_=0 ORDER BY id_
  44. </select>
  45. <!-- 向数据库增加一条记录 -->
  46. <insert id="insert" parameterType="com.ym.mec.cms.dal.entity.SysNewsInformation" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  47. INSERT INTO sys_news_information (id_,title_,content_,cover_image_,type_,status_,create_time_,update_time_,link_url_,href_target_,order_,del_flag_)
  48. VALUES(#{id},#{title},#{content},#{coverImage},#{type},#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},now(),now(),#{linkUrl},#{hrefTarget},#{order},0)
  49. </insert>
  50. <!-- 根据主键查询一条记录 -->
  51. <update id="update" parameterType="com.ym.mec.cms.dal.entity.SysNewsInformation">
  52. UPDATE sys_news_information
  53. <set>
  54. <if test="status != null">
  55. status_ = #{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  56. </if>
  57. <if test="title != null">
  58. title_ = #{title},
  59. </if>
  60. <if test="updateTime != null">
  61. update_time_ = NOW(),
  62. </if>
  63. <if test="content != null">
  64. content_ = #{content},
  65. </if>
  66. <if test="coverImage != null">
  67. cover_image_ = #{coverImage},
  68. </if>
  69. <if test="type != null">
  70. type_ = #{type},
  71. </if>
  72. <if test="linkUrl != null">
  73. link_url_ = #{linkUrl},
  74. </if>
  75. <if test="hrefTarget != null">
  76. href_target_ = #{hrefTarget},
  77. </if>
  78. <if test="order != null">
  79. order_ = #{order},
  80. </if>
  81. <if test="delFlag != null">
  82. del_flag_ = #{delFlag},
  83. </if>
  84. </set>
  85. WHERE id_ = #{id}
  86. </update>
  87. <!-- 根据主键删除一条记录 -->
  88. <delete id="delete" >
  89. DELETE FROM sys_news_information WHERE id_ = #{id}
  90. </delete>
  91. <!-- 分页查询 -->
  92. <select id="queryPage" resultMap="SysNewsInformation" parameterType="map">
  93. SELECT * FROM sys_news_information
  94. <include refid="queryCondition" />
  95. <include refid="global.orderby" />
  96. <include refid="global.limit"/>
  97. </select>
  98. <!-- 查询当前表的总记录数 -->
  99. <select id="queryCount" resultType="int">
  100. SELECT COUNT(*) FROM sys_news_information
  101. <include refid="queryCondition" />
  102. </select>
  103. <select id="queryByType" resultMap="SysNewsInformation" parameterType="java.lang.Integer">
  104. SELECT * FROM sys_news_information
  105. <where>
  106. del_flag_=0
  107. <if test="type != null">
  108. and type_ = #{type}
  109. </if>
  110. </where>
  111. </select>
  112. <update id="deleteWithLogical">
  113. UPDATE sys_news_information SET del_flag_ = 1,update_time_ = NOW() WHERE id_ = #{id}
  114. </update>
  115. </mapper>