MyCalendarMapper.xml 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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.jeeplus.modules.iim.mapper.MyCalendarMapper">
  4. <sql id="myCalendarColumns">
  5. a.id AS "id",
  6. a.title AS "title",
  7. a.starttime AS "start",
  8. a.endtime AS "end",
  9. a.allday AS "adllDay",
  10. a.color AS "color",
  11. a.userid AS "user.id",
  12. tuser.name AS "user.name"
  13. </sql>
  14. <sql id="myCalendarJoins">
  15. LEFT JOIN sys_user tuser ON tuser.id = a.userid
  16. </sql>
  17. <select id="get" resultType="MyCalendar">
  18. SELECT
  19. <include refid="myCalendarColumns"/>
  20. FROM calendar a
  21. <include refid="myCalendarJoins"/>
  22. WHERE a.id = #{id}
  23. </select>
  24. <select id="findList" resultType="MyCalendar">
  25. SELECT
  26. <include refid="myCalendarColumns"/>
  27. FROM calendar a
  28. <include refid="myCalendarJoins"/>
  29. <where>
  30. <if test="user != null and user.id != null and user.id != ''">
  31. AND a.userid = #{user.id}
  32. </if>
  33. </where>
  34. <choose>
  35. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  36. ORDER BY ${page.orderBy}
  37. </when>
  38. <otherwise>
  39. </otherwise>
  40. </choose>
  41. </select>
  42. <select id="findAllList" resultType="MyCalendar">
  43. SELECT
  44. <include refid="myCalendarColumns"/>
  45. FROM calendar a
  46. <include refid="myCalendarJoins"/>
  47. <where>
  48. </where>
  49. <choose>
  50. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  51. ORDER BY ${page.orderBy}
  52. </when>
  53. <otherwise>
  54. </otherwise>
  55. </choose>
  56. </select>
  57. <insert id="insert">
  58. INSERT INTO calendar(
  59. id,
  60. title,
  61. starttime,
  62. endtime,
  63. allday,
  64. color,
  65. userid
  66. ) VALUES (
  67. #{id},
  68. #{title},
  69. #{start},
  70. #{end},
  71. #{adllDay},
  72. #{color},
  73. #{user.id}
  74. )
  75. </insert>
  76. <update id="update">
  77. UPDATE calendar SET
  78. title = #{title},
  79. starttime = #{start},
  80. endtime = #{end},
  81. allday = #{adllDay},
  82. color = #{color},
  83. userid = #{user.id}
  84. WHERE id = #{id}
  85. </update>
  86. <!--物理删除-->
  87. <update id="delete">
  88. DELETE FROM calendar
  89. WHERE id = #{id}
  90. </update>
  91. <!--逻辑删除-->
  92. <update id="deleteByLogic">
  93. UPDATE calendar SET
  94. del_flag = #{DEL_FLAG_DELETE}
  95. WHERE id = #{id}
  96. </update>
  97. <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
  98. <select id="findUniqueByProperty" resultType="MyCalendar" statementType="STATEMENT">
  99. select * FROM calendar where ${propertyName} = '${value}'
  100. </select>
  101. </mapper>