SysNoticeMapper.xml 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.weather.mapper.SysNoticeMapper">
  6. <resultMap type="SysNotice" id="SysNoticeResult">
  7. <result property="noticeId" column="notice_id" />
  8. <result property="noticeTitle" column="notice_title" />
  9. <result property="noticeType" column="notice_type" />
  10. <result property="noticeContent" column="notice_content" />
  11. <result property="status" column="status" />
  12. <result property="createBy" column="create_by" />
  13. <result property="createTime" column="create_time" />
  14. <result property="updateBy" column="update_by" />
  15. <result property="updateTime" column="update_time" />
  16. <result property="remark" column="remark" />
  17. </resultMap>
  18. <sql id="selectNoticeVo">
  19. select notice_id, notice_title, notice_type, notice_content as notice_content, status, create_by, create_time, update_by, update_time, remark
  20. from sys_notice
  21. </sql>
  22. <select id="selectNoticeById" parameterType="Long" resultMap="SysNoticeResult">
  23. <include refid="selectNoticeVo"/>
  24. where notice_id = #{noticeId}
  25. </select>
  26. <select id="selectNoticeList" parameterType="SysNotice" resultMap="SysNoticeResult">
  27. select notice_id, notice_title, notice_type, status, create_by, create_time, update_by, update_time, remark
  28. from sys_notice
  29. <where>
  30. <if test="noticeTitle != null and noticeTitle != ''">
  31. AND notice_title like concat('%', #{noticeTitle}, '%')
  32. </if>
  33. <if test="noticeType != null and noticeType != ''">
  34. AND notice_type = #{noticeType}
  35. </if>
  36. <if test="createBy != null and createBy != ''">
  37. AND create_by like concat('%', #{createBy}, '%')
  38. </if>
  39. </where>
  40. </select>
  41. <insert id="insertNotice" parameterType="SysNotice">
  42. insert into sys_notice (
  43. notice_id,
  44. <if test="noticeTitle != null and noticeTitle != '' ">notice_title, </if>
  45. <if test="noticeType != null and noticeType != '' ">notice_type, </if>
  46. <if test="noticeContent != null and noticeContent != '' ">notice_content, </if>
  47. <if test="status != null and status != '' ">status, </if>
  48. <if test="remark != null and remark != ''">remark,</if>
  49. <if test="createBy != null and createBy != ''">create_by,</if>
  50. create_time
  51. )values(
  52. #{noticeId},
  53. <if test="noticeTitle != null and noticeTitle != ''">#{noticeTitle}, </if>
  54. <if test="noticeType != null and noticeType != ''">#{noticeType}, </if>
  55. <if test="noticeContent != null and noticeContent != ''">#{noticeContent}, </if>
  56. <if test="status != null and status != ''">#{status}, </if>
  57. <if test="remark != null and remark != ''">#{remark},</if>
  58. <if test="createBy != null and createBy != ''">#{createBy},</if>
  59. NOW()
  60. )
  61. </insert>
  62. <update id="updateNotice" parameterType="SysNotice">
  63. update sys_notice
  64. <set>
  65. <if test="noticeTitle != null and noticeTitle != ''">notice_title = #{noticeTitle}, </if>
  66. <if test="noticeType != null and noticeType != ''">notice_type = #{noticeType}, </if>
  67. <if test="noticeContent != null">notice_content = #{noticeContent}, </if>
  68. <if test="status != null and status != ''">status = #{status}, </if>
  69. <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  70. update_time = NOW()
  71. </set>
  72. where notice_id = #{noticeId}
  73. </update>
  74. <delete id="deleteNoticeById" parameterType="Long">
  75. delete from sys_notice where notice_id = #{noticeId}
  76. </delete>
  77. <delete id="deleteNoticeByIds" parameterType="Long">
  78. delete from sys_notice where notice_id in
  79. <foreach item="noticeId" collection="array" open="(" separator="," close=")">
  80. #{noticeId}
  81. </foreach>
  82. </delete>
  83. </mapper>