FsTodoItemsMapper.xml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. <mapper namespace="com.fs.todo.mapper.FsTodoItemsMapper">
  4. <!-- 结果映射 -->
  5. <resultMap id="BaseResultMap" type="com.fs.todo.domain.FsTodoItems">
  6. <id column="id" property="id" jdbcType="BIGINT"/>
  7. <result column="title" property="title" jdbcType="VARCHAR"/>
  8. <result column="description" property="description" jdbcType="LONGVARCHAR"/>
  9. <result column="status" property="status" jdbcType="TINYINT"/>
  10. <result column="creator_id" property="creatorId" jdbcType="BIGINT"/>
  11. <result column="assignee_id" property="assigneeId" jdbcType="BIGINT"/>
  12. <result column="priority" property="priority" jdbcType="TINYINT"/>
  13. <result column="due_date" property="dueDate" jdbcType="TIMESTAMP"/>
  14. <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
  15. <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
  16. <result column="complete_time" property="completeTime" jdbcType="TIMESTAMP"/>
  17. </resultMap>
  18. <!-- 基础字段 -->
  19. <sql id="Base_Column_List">
  20. id, title, description, status, creator_id, assignee_id, priority,
  21. due_date, create_time, update_time, complete_time
  22. </sql>
  23. <!-- 根据ID查询 -->
  24. <select id="selectById" parameterType="java.lang.Long" resultMap="BaseResultMap">
  25. SELECT <include refid="Base_Column_List"/>
  26. FROM fs_todo_items
  27. WHERE id = #{id}
  28. </select>
  29. <!-- 查询所有 -->
  30. <select id="selectAll" resultMap="BaseResultMap">
  31. SELECT <include refid="Base_Column_List"/>
  32. FROM fs_todo_items
  33. ORDER BY create_time DESC
  34. </select>
  35. <!-- 根据创建者ID查询 -->
  36. <select id="selectByCreatorId" parameterType="java.lang.Long" resultMap="BaseResultMap">
  37. SELECT <include refid="Base_Column_List"/>
  38. FROM fs_todo_items
  39. WHERE creator_id = #{creatorId}
  40. ORDER BY create_time DESC
  41. </select>
  42. <!-- 根据负责人ID查询 -->
  43. <select id="selectByAssigneeId" parameterType="java.lang.Long" resultMap="BaseResultMap">
  44. SELECT <include refid="Base_Column_List"/>
  45. FROM fs_todo_items
  46. WHERE assignee_id = #{assigneeId}
  47. ORDER BY create_time DESC
  48. </select>
  49. <!-- 根据状态查询 -->
  50. <select id="selectByStatus" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  51. SELECT <include refid="Base_Column_List"/>
  52. FROM fs_todo_items
  53. WHERE status = #{status}
  54. ORDER BY create_time DESC
  55. </select>
  56. <select id="listPage" resultType="com.fs.todo.domain.FsTodoItems">
  57. SELECT <include refid="Base_Column_List"/>
  58. FROM fs_todo_items
  59. <where>
  60. <if test="id != null">
  61. AND id = #{id}
  62. </if>
  63. <if test="title != null and title != ''">
  64. AND title LIKE CONCAT('%', #{title}, '%')
  65. </if>
  66. <if test="description != null and description != ''">
  67. AND description LIKE CONCAT('%', #{description}, '%')
  68. </if>
  69. <if test="status != null">
  70. AND status = #{status}
  71. </if>
  72. <if test="creatorId != null">
  73. AND creator_id = #{creatorId}
  74. </if>
  75. <if test="assigneeId != null">
  76. AND assignee_id = #{assigneeId}
  77. </if>
  78. <if test="priority != null">
  79. AND priority = #{priority}
  80. </if>
  81. <if test="dueDate != null">
  82. AND DATE(due_date) = DATE(#{dueDate})
  83. </if>
  84. <if test="createTime != null">
  85. AND DATE(create_time) = DATE(#{createTime})
  86. </if>
  87. <if test="updateTime != null">
  88. AND DATE(update_time) = DATE(#{updateTime})
  89. </if>
  90. <if test="completeTime != null">
  91. AND DATE(complete_time) = DATE(#{completeTime})
  92. </if>
  93. <if test="cateId != null">
  94. AND cate_id = #{cateId}
  95. </if>
  96. </where>
  97. ORDER BY create_time DESC
  98. </select>
  99. </mapper>