TestExpenseMapper.xml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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.test.activiti.mapper.TestExpenseMapper">
  4. <sql id="testExpenseColumns">
  5. a.id AS "id",
  6. a.name AS "tuser.id",
  7. a.office_id AS "office.id",
  8. a.cost AS "cost",
  9. a.reason AS "reason",
  10. a.create_by AS "createBy.id",
  11. a.create_date AS "createDate",
  12. a.update_by AS "updateBy.id",
  13. a.update_date AS "updateDate",
  14. a.remarks AS "remarks",
  15. a.del_flag AS "delFlag",
  16. a.proc_ins_id AS "procInsId",
  17. tuser.name AS "tuser.name",
  18. office.name AS "office.name"
  19. </sql>
  20. <sql id="testExpenseJoins">
  21. LEFT JOIN sys_user tuser ON tuser.id = a.name
  22. LEFT JOIN sys_office office ON office.id = a.office_id
  23. </sql>
  24. <select id="get" resultType="TestExpense" >
  25. SELECT
  26. <include refid="testExpenseColumns"/>
  27. FROM test_activiti_expense a
  28. <include refid="testExpenseJoins"/>
  29. WHERE a.id = #{id}
  30. </select>
  31. <select id="findList" resultType="TestExpense" >
  32. SELECT
  33. <include refid="testExpenseColumns"/>
  34. FROM test_activiti_expense a
  35. <include refid="testExpenseJoins"/>
  36. <where>
  37. a.del_flag = #{DEL_FLAG_NORMAL}
  38. ${dataScope}
  39. </where>
  40. <choose>
  41. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  42. ORDER BY ${page.orderBy}
  43. </when>
  44. <otherwise>
  45. ORDER BY a.update_date DESC
  46. </otherwise>
  47. </choose>
  48. </select>
  49. <select id="findAllList" resultType="TestExpense" >
  50. SELECT
  51. <include refid="testExpenseColumns"/>
  52. FROM test_activiti_expense a
  53. <include refid="testExpenseJoins"/>
  54. <where>
  55. a.del_flag = #{DEL_FLAG_NORMAL}
  56. ${dataScope}
  57. </where>
  58. <choose>
  59. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  60. ORDER BY ${page.orderBy}
  61. </when>
  62. <otherwise>
  63. ORDER BY a.update_date DESC
  64. </otherwise>
  65. </choose>
  66. </select>
  67. <insert id="insert">
  68. INSERT INTO test_activiti_expense(
  69. id,
  70. name,
  71. office_id,
  72. cost,
  73. reason,
  74. create_by,
  75. create_date,
  76. update_by,
  77. update_date,
  78. remarks,
  79. del_flag,
  80. proc_ins_id
  81. ) VALUES (
  82. #{id},
  83. #{tuser.id},
  84. #{office.id},
  85. #{cost},
  86. #{reason},
  87. #{createBy.id},
  88. #{createDate},
  89. #{updateBy.id},
  90. #{updateDate},
  91. #{remarks},
  92. #{delFlag},
  93. #{procInsId}
  94. )
  95. </insert>
  96. <update id="update">
  97. UPDATE test_activiti_expense SET
  98. name = #{tuser.id},
  99. office_id = #{office.id},
  100. cost = #{cost},
  101. reason = #{reason},
  102. update_by = #{updateBy.id},
  103. update_date = #{updateDate},
  104. remarks = #{remarks},
  105. proc_ins_id = #{procInsId}
  106. WHERE id = #{id}
  107. </update>
  108. <!--物理删除-->
  109. <update id="delete">
  110. DELETE FROM test_activiti_expense
  111. WHERE id = #{id}
  112. </update>
  113. <!--逻辑删除-->
  114. <update id="deleteByLogic">
  115. UPDATE test_activiti_expense SET
  116. del_flag = #{DEL_FLAG_DELETE}
  117. WHERE id = #{id}
  118. </update>
  119. <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
  120. <select id="findUniqueByProperty" resultType="TestExpense" statementType="STATEMENT">
  121. select * FROM test_activiti_expense where ${propertyName} = '${value}'
  122. </select>
  123. </mapper>