ItemMapper.xml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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.sg.project.mapper.ItemMapper">
  4. <sql id="infoColumns">
  5. a.id AS "id",
  6. a.create_by AS "createBy.id",
  7. a.create_date AS "createDate",
  8. a.update_by AS "updateBy.id",
  9. a.update_date AS "updateDate",
  10. a.remarks AS "remarks",
  11. a.del_flag AS "delFlag",
  12. a.item_name AS "itemName",
  13. a.unit AS "unit",
  14. a.project_id AS "projectId",
  15. a.parent_node AS "parentNode",
  16. a.type AS "type"
  17. </sql>
  18. <select id="get" resultType="WbsItem" >
  19. SELECT
  20. <include refid="infoColumns"/>
  21. FROM sg_wbs_item a
  22. WHERE a.id = #{id}
  23. </select>
  24. <select id="findList" resultType="WbsItem" parameterType="com.jeeplus.modules.sg.project.entity.WbsSelection">
  25. SELECT
  26. <include refid="infoColumns"/>
  27. FROM sg_wbs_item a
  28. <where>
  29. <if test="itemName != null and itemName != ''">
  30. AND a.item_name LIKE CONCAT(CONCAT('%',#{itemName},'%'))
  31. </if>
  32. <if test="type != null and type != ''">
  33. AND a.type LIKE CONCAT(CONCAT('%',#{type},'%'))
  34. </if>
  35. <if test="unit != null and unit != ''">
  36. AND a.unit LIKE CONCAT(CONCAT('%',#{unit},'%'))
  37. </if>
  38. <if test="itemStartDate != null and itemEndDate != ''">
  39. AND a.create_date &gt;= #{itemStartDate}
  40. </if>
  41. <if test="itemEndDate != null and itemEndDate != ''">
  42. AND a.create_date &lt;= #{itemEndDate}
  43. </if>
  44. <if test="projectId != null and projectId != ''">
  45. AND a.project_id = #{projectId}
  46. </if>
  47. </where>
  48. ORDER BY a.update_date DESC
  49. </select>
  50. <select id="findAllList" resultType="WbsItem" >
  51. SELECT
  52. <include refid="infoColumns"/>
  53. FROM sg_wbs_item a
  54. <where>
  55. a.del_flag = #{DEL_FLAG_NORMAL}
  56. </where>
  57. <choose>
  58. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  59. ORDER BY ${page.orderBy}
  60. </when>
  61. <otherwise>
  62. ORDER BY a.update_date DESC
  63. </otherwise>
  64. </choose>
  65. </select>
  66. <insert id="insert">
  67. INSERT INTO sg_wbs_item(
  68. id,
  69. create_by,
  70. create_date,
  71. update_by,
  72. update_date,
  73. remarks,
  74. del_flag,
  75. item_name,
  76. unit,
  77. type,
  78. project_id,
  79. parent_node
  80. ) VALUES (
  81. #{id},
  82. #{createBy.id},
  83. #{createDate},
  84. #{updateBy.id},
  85. #{updateDate},
  86. #{remarks},
  87. #{delFlag},
  88. #{itemName},
  89. #{unit},
  90. #{type},
  91. #{projectId},
  92. #{parentNode}
  93. )
  94. </insert>
  95. <update id="update">
  96. UPDATE sg_wbs_item SET
  97. item_name = #{itemName},
  98. unit = #{unit},
  99. type = #{type},
  100. update_by = #{updateBy.id},
  101. update_date = #{updateDate},
  102. remarks = #{remarks}
  103. WHERE id = #{id}
  104. </update>
  105. <!--物理删除-->
  106. <update id="delete">
  107. DELETE FROM sg_wbs_item
  108. WHERE id = #{id}
  109. </update>
  110. <!--逻辑删除-->
  111. <update id="deleteByLogic">
  112. UPDATE sg_wbs_item SET
  113. del_flag = #{DEL_FLAG_DELETE}
  114. WHERE id = #{id}
  115. </update>
  116. <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
  117. <select id="findUniqueByProperty" resultType="Goods" statementType="STATEMENT">
  118. select * FROM sg_wbs_item where ${propertyName} = '${value}'
  119. </select>
  120. </mapper>