ContractTemplateMapper.xml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. <!-- 这个文件是自动生成的。 不要修改此文件。所有改动将在下次重新自动生成时丢失。 -->
  4. <mapper namespace="com.yonge.cooleshow.biz.dal.dao.ContractTemplateDao">
  5. <resultMap type="com.yonge.cooleshow.biz.dal.entity.ContractTemplate"
  6. id="BaseResultMap">
  7. <result column="id_" property="id" />
  8. <result column="source_" property="source" />
  9. <result column="type_" property="type" />
  10. <result column="name_" property="name" />
  11. <result column="contract_template_content_" property="contractTemplateContent" />
  12. <result column="origanal_file_url_" property="origanalFileUrl" />
  13. <result column="contract_no_" property="contractNo" />
  14. <result column="status_" property="status" />
  15. <result column="version_" property="version" />
  16. <result column="modify_by_" property="modifyBy" />
  17. <result column="update_time_" property="updateTime" />
  18. <result column="create_time_" property="createTime" />
  19. <result column="owner_" property="owner" />
  20. </resultMap>
  21. <resultMap type="com.yonge.cooleshow.biz.dal.dto.ContractTemplateDto"
  22. id="ContractTemplateDto">
  23. <result column="latest_operator_" property="latestOperator" />
  24. </resultMap>
  25. <!-- 根据主键查询一条记录 -->
  26. <select id="get" resultMap="BaseResultMap">
  27. SELECT * FROM contract_template WHERE id_ = #{id}
  28. </select>
  29. <!-- 全查询 -->
  30. <select id="findAll" resultMap="BaseResultMap">
  31. SELECT * FROM contract_template ORDER BY id_
  32. </select>
  33. <!-- 向数据库增加一条记录 -->
  34. <insert id="insert" parameterType="com.yonge.cooleshow.biz.dal.entity.ContractTemplate"
  35. useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  36. INSERT INTO
  37. contract_template
  38. (id_,source_,name_,type_,contract_template_content_,origanal_file_url_,contract_no_,status_,version_,modify_by_,update_time_,create_time_,owner_)
  39. VALUES(#{id},#{source},#{name},#{type},#{contractTemplateContent},#{origanalFileUrl},#{contractNo},#{status},#{version},#{modifyBy},#{updateTime},#{createTime},#{owner})
  40. </insert>
  41. <!-- 根据主键查询一条记录 -->
  42. <update id="update" parameterType="com.yonge.cooleshow.biz.dal.entity.ContractTemplate">
  43. UPDATE contract_template
  44. <set>
  45. <if test="contractTemplateContent != null">
  46. contract_template_content_ = #{contractTemplateContent},
  47. </if>
  48. <if test="status != null">
  49. status_ = #{status},
  50. </if>
  51. <if test="origanalFileUrl != null">
  52. origanal_file_url_ = #{origanalFileUrl},
  53. </if>
  54. <if test="id != null">
  55. id_ = #{id},
  56. </if>
  57. <if test="owner != null">
  58. owner_ = #{owner},
  59. </if>
  60. <if test="updateTime != null">
  61. update_time_ = #{updateTime},
  62. </if>
  63. <if test="version != null">
  64. version_ = #{version},
  65. </if>
  66. <if test="modifyBy != null">
  67. modify_by_ = #{modifyBy},
  68. </if>
  69. <if test="type != null">
  70. type_ = #{type},
  71. </if>
  72. <if test="source != null">
  73. source_ = #{source},
  74. </if>
  75. <if test="contractNo != null">
  76. contract_no_ = #{contractNo},
  77. </if>
  78. <if test="name != null">
  79. name_ = #{name},
  80. </if>
  81. <if test="createTime != null">
  82. create_time_ = #{createTime},
  83. </if>
  84. </set>
  85. WHERE id_ = #{id}
  86. </update>
  87. <!-- 根据主键删除一条记录 -->
  88. <delete id="delete">
  89. DELETE FROM contract_template WHERE id_ = #{id}
  90. </delete>
  91. <!-- 分页查询 -->
  92. <select id="queryPage" resultMap="BaseResultMap" parameterType="map">
  93. SELECT tct.*,ifnull(u.real_name_,u.username_) latest_operator_ FROM contract_template tct left join sys_user u on tct.modify_by_ = u.id_
  94. <where>
  95. <if test="status != null">
  96. and tct.status_ = #{status}
  97. </if>
  98. <if test="source != null">
  99. and tct.source_ = #{source}
  100. </if>
  101. <if test="type != null">
  102. and tct.type_ = #{type}
  103. </if>
  104. <if test="owner != null">
  105. and tct.owner_ = #{owner}
  106. </if>
  107. </where>
  108. ORDER BY id_
  109. <include refid="global.limit" />
  110. </select>
  111. <!-- 分页查询 -->
  112. <select id="queryPageList" resultMap="ContractTemplateDto" parameterType="map">
  113. SELECT
  114. tct.*,ifnull(u.real_name_,u.username_) latest_operator_
  115. FROM contract_template tct
  116. left join sys_user u on tct.modify_by_ = u.id_
  117. <where>
  118. <if test="status != null">
  119. and tct.status_ = #{status}
  120. </if>
  121. <if test="source != null">
  122. and tct.source_ = #{source}
  123. </if>
  124. <if test="type != null">
  125. and tct.type_ = #{type}
  126. </if>
  127. <if test="owner != null">
  128. and tct.owner_ = #{owner}
  129. </if>
  130. </where>
  131. ORDER BY id_
  132. <include refid="global.limit" />
  133. </select>
  134. <!-- 查询当前表的总记录数 -->
  135. <select id="queryCount" resultType="int">
  136. SELECT COUNT(tct.id_) FROM contract_template tct
  137. <where>
  138. tct.source_ = 'PLATFORM'
  139. <if test="status != null">
  140. and tct.status_ = #{status}
  141. </if>
  142. <if test="source != null">
  143. and tct.source_ = #{source}
  144. </if>
  145. <if test="type != null">
  146. and tct.type_ = #{type}
  147. </if>
  148. <if test="owner != null">
  149. and tct.owner_ = #{owner}
  150. </if>
  151. </where>
  152. </select>
  153. <select id="queryMaxVersion" resultType="java.lang.Integer">
  154. SELECT max(a.version_) FROM contract_template a
  155. where a.source_ = #{contractSource} and a.type_ = #{type}
  156. </select>
  157. <select id="queryLatestContractTemplate" resultMap="BaseResultMap">
  158. SELECT a.* FROM (
  159. select
  160. source_,type_,MAX(version_) as version_
  161. from contract_template where status_ = 1 and source_ = #{contractSource} and type_ = #{type}
  162. group by source_ ,type_
  163. ) t
  164. left join contract_template a on t.source_ =a.source_ and t.type_ = a.type_ and t.version_ = a.version_
  165. where a.source_ = #{contractSource} and a.type_ = #{type}
  166. </select>
  167. <update id="disableContract">
  168. update contract_template set status_ = 0 where status_ = 1 and source_ = 'PLATFORM'
  169. and type_ = #{type}
  170. </update>
  171. </mapper>