WorkContractClientDao.xml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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.contractclient.dao.WorkContractClientDao">
  4. <sql id="workContractClientColumns">
  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.contract_id AS "contractId",
  13. a.client_id AS "clientId"
  14. </sql>
  15. <sql id="workContractClientJoins">
  16. </sql>
  17. <select id="get" resultType="WorkContractClient" >
  18. SELECT
  19. <include refid="workContractClientColumns"/>
  20. FROM work_contract_client a
  21. <include refid="workContractClientJoins"/>
  22. WHERE a.id = #{id}
  23. </select>
  24. <select id="findList" resultType="WorkContractClient" >
  25. SELECT
  26. <include refid="workContractClientColumns"/>
  27. FROM work_contract_client a
  28. <include refid="workContractClientJoins"/>
  29. <where>
  30. a.del_flag = #{DEL_FLAG_NORMAL}
  31. <if test="contractId != null and contractId != ''">
  32. AND a.contract_id = #{contractId}
  33. </if>
  34. <if test="clientId != null and clientId != ''">
  35. AND a.client_id = #{clientId}
  36. </if>
  37. </where>
  38. <choose>
  39. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  40. ORDER BY ${page.orderBy}
  41. </when>
  42. <otherwise>
  43. ORDER BY a.update_date DESC
  44. </otherwise>
  45. </choose>
  46. </select>
  47. <select id="findAllList" resultType="WorkContractClient" >
  48. SELECT
  49. <include refid="workContractClientColumns"/>
  50. FROM work_contract_client a
  51. <include refid="workContractClientJoins"/>
  52. <where>
  53. a.del_flag = #{DEL_FLAG_NORMAL}
  54. </where>
  55. <choose>
  56. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  57. ORDER BY ${page.orderBy}
  58. </when>
  59. <otherwise>
  60. ORDER BY a.update_date DESC
  61. </otherwise>
  62. </choose>
  63. </select>
  64. <insert id="insert">
  65. INSERT INTO work_contract_client(
  66. id,
  67. create_by,
  68. create_date,
  69. update_by,
  70. update_date,
  71. remarks,
  72. del_flag,
  73. contract_id,
  74. client_id
  75. ) VALUES (
  76. #{id},
  77. #{createBy.id},
  78. #{createDate},
  79. #{updateBy.id},
  80. #{updateDate},
  81. #{remarks},
  82. #{delFlag},
  83. #{contractId},
  84. #{clientId}
  85. )
  86. </insert>
  87. <update id="update">
  88. UPDATE work_contract_client SET
  89. update_by = #{updateBy.id},
  90. update_date = #{updateDate},
  91. remarks = #{remarks},
  92. contract_id = #{contractId},
  93. client_id = #{clientId}
  94. WHERE id = #{id}
  95. </update>
  96. <!--物理删除-->
  97. <update id="delete">
  98. DELETE FROM work_contract_client
  99. WHERE id = #{id}
  100. </update>
  101. <!--逻辑删除-->
  102. <update id="deleteByLogic">
  103. UPDATE work_contract_client SET
  104. del_flag = #{DEL_FLAG_DELETE}
  105. WHERE id = #{id}
  106. </update>
  107. <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
  108. <select id="findUniqueByProperty" resultType="WorkContractClient" statementType="STATEMENT">
  109. select * FROM work_contract_client where ${propertyName} = '${value}'
  110. </select>
  111. </mapper>