RestrictProjectMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.goafanti.common.dao.RestrictProjectMapper">
  6. <resultMap id="BaseResultMap" type="com.goafanti.common.model.RestrictProject">
  7. <id property="id" column="id" jdbcType="INTEGER"/>
  8. <result property="pid" column="pid" jdbcType="VARCHAR"/>
  9. <result property="uid" column="uid" jdbcType="VARCHAR"/>
  10. <result property="aid" column="aid" jdbcType="VARCHAR"/>
  11. <result property="type" column="type" jdbcType="INTEGER"/>
  12. <result property="lockTime" column="lock_time" jdbcType="TIMESTAMP"/>
  13. <result property="releaseTime" column="release_time" jdbcType="TIMESTAMP"/>
  14. <result property="lastFollowTime" column="last_follow_time" jdbcType="TIMESTAMP"/>
  15. <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
  16. </resultMap>
  17. <sql id="Base_Column_List">
  18. id,pid,uid,
  19. aid,type,lock_time,
  20. release_time,last_follow_time,create_time
  21. </sql>
  22. <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  23. select
  24. <include refid="Base_Column_List" />
  25. from restrict_project
  26. where id = #{id,jdbcType=INTEGER}
  27. </select>
  28. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  29. delete from restrict_project
  30. where id = #{id,jdbcType=INTEGER}
  31. </delete>
  32. <delete id="deleteByPram">
  33. delete from restrict_project
  34. where uid = #{uid}
  35. and pid = #{pid}
  36. </delete>
  37. <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.RestrictProject" useGeneratedKeys="true">
  38. insert into restrict_project
  39. ( id,pid,uid
  40. ,aid,type,lock_time
  41. ,release_time,last_follow_time,create_time
  42. )
  43. values (#{id,jdbcType=INTEGER},#{pid,jdbcType=VARCHAR},#{uid,jdbcType=VARCHAR}
  44. ,#{aid,jdbcType=VARCHAR},#{type,jdbcType=INTEGER},#{lockTime,jdbcType=TIMESTAMP}
  45. ,#{releaseTime,jdbcType=TIMESTAMP},#{lastFollowTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP}
  46. )
  47. </insert>
  48. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.RestrictProject" useGeneratedKeys="true">
  49. insert into restrict_project
  50. <trim prefix="(" suffix=")" suffixOverrides=",">
  51. <if test="id != null">id,</if>
  52. <if test="pid != null">pid,</if>
  53. <if test="uid != null">uid,</if>
  54. <if test="aid != null">aid,</if>
  55. <if test="type != null">type,</if>
  56. <if test="lockTime != null">lock_time,</if>
  57. <if test="releaseTime != null">release_time,</if>
  58. <if test="lastFollowTime != null">last_follow_time,</if>
  59. <if test="createTime != null">create_time,</if>
  60. </trim>
  61. <trim prefix="values (" suffix=")" suffixOverrides=",">
  62. <if test="id != null">#{id,jdbcType=INTEGER},</if>
  63. <if test="pid != null">#{pid,jdbcType=VARCHAR},</if>
  64. <if test="uid != null">#{uid,jdbcType=VARCHAR},</if>
  65. <if test="aid != null">#{aid,jdbcType=VARCHAR},</if>
  66. <if test="type != null">#{type,jdbcType=INTEGER},</if>
  67. <if test="lockTime != null">#{lockTime,jdbcType=TIMESTAMP},</if>
  68. <if test="releaseTime != null">#{releaseTime,jdbcType=TIMESTAMP},</if>
  69. <if test="lastFollowTime != null">#{lastFollowTime,jdbcType=TIMESTAMP},</if>
  70. <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
  71. </trim>
  72. </insert>
  73. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.RestrictProject">
  74. update restrict_project
  75. <set>
  76. <if test="pid != null">
  77. pid = #{pid,jdbcType=VARCHAR},
  78. </if>
  79. <if test="uid != null">
  80. uid = #{uid,jdbcType=VARCHAR},
  81. </if>
  82. <if test="aid != null">
  83. aid = #{aid,jdbcType=VARCHAR},
  84. </if>
  85. <if test="type != null">
  86. type = #{type,jdbcType=INTEGER},
  87. </if>
  88. <if test="lockTime != null">
  89. lock_time = #{lockTime,jdbcType=TIMESTAMP},
  90. </if>
  91. <if test="releaseTime != null">
  92. release_time = #{releaseTime,jdbcType=TIMESTAMP},
  93. </if>
  94. <if test="lastFollowTime != null">
  95. last_follow_time = #{lastFollowTime,jdbcType=TIMESTAMP},
  96. </if>
  97. <if test="createTime != null">
  98. create_time = #{createTime,jdbcType=TIMESTAMP},
  99. </if>
  100. </set>
  101. where id = #{id,jdbcType=INTEGER}
  102. </update>
  103. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.RestrictProject">
  104. update restrict_project
  105. set
  106. pid = #{pid,jdbcType=VARCHAR},
  107. uid = #{uid,jdbcType=VARCHAR},
  108. aid = #{aid,jdbcType=VARCHAR},
  109. type = #{type,jdbcType=INTEGER},
  110. lock_time = #{lockTime,jdbcType=TIMESTAMP},
  111. release_time = #{releaseTime,jdbcType=TIMESTAMP},
  112. last_follow_time = #{lastFollowTime,jdbcType=TIMESTAMP},
  113. create_time = #{createTime,jdbcType=TIMESTAMP}
  114. where id = #{id,jdbcType=INTEGER}
  115. </update>
  116. <select id="selectByUidAndAid" resultType="com.goafanti.business.bo.OutRestrictProject">
  117. select a.id pid ,b.id,a.bname projectName,b.type,b.lock_time lockTime,b.release_time releaseTime ,
  118. c.nickname userName ,d.name adminName,b.create_time createTime,b.uid,b.aid
  119. from business_project a
  120. left join restrict_project b on a.id =b.pid and b.uid =#{uid,jdbcType=VARCHAR}
  121. left join user c on b.uid=c.id left join admin d on b.aid=d.id
  122. where a.restrict_status =1
  123. </select>
  124. <select id="RestrictProjectList" resultType="com.goafanti.business.bo.RestrictProjectPageList">
  125. select *
  126. from (select a.id,b.nickname name,c.bname projectName,a.`type` ,ad.name userAdmin,ad2.name adminName,a.lock_time lockTime,
  127. a.last_follow_time lastFollowTime,a.uid, b.society_tag societyTag,dg1.name as province, dg2.name as city,
  128. dg3.name as area,d.intended_project intendedProject, d.business_scope businessScope,a.pid,
  129. (if(a.type=1,30,270) -DATEDIFF(now(),if(a.last_follow_time>a.lock_time,a.last_follow_time,a.lock_time)))days
  130. from restrict_project a
  131. left join user b on a.uid =b.id left join business_project c on a.pid =c.id
  132. left join admin ad on b.aid =ad.id left join admin ad2 on a.aid =ad2.id
  133. left join organization_identity d on b.id = d.uid
  134. left join district_glossory dg1 on d.location_province = dg1.id
  135. left join district_glossory dg2 on d.location_city = dg2.id
  136. left join district_glossory dg3 on d.location_area = dg3.id
  137. where a.`type` >0
  138. <include refid="RestrictProjectSql"/>
  139. )x
  140. order by x.days
  141. <if test="page_sql != null">
  142. ${page_sql}
  143. </if>
  144. </select>
  145. <sql id="RestrictProjectSql">
  146. <if test="aid != null">
  147. and a.aid =#{aid}
  148. </if>
  149. <if test="userName !=null">
  150. and b.nickname like concat('%',#{userName},'%')
  151. </if>
  152. <if test="projectName !=null">
  153. and c.bname =#{projectName}
  154. </if>
  155. <if test="type !=null">
  156. and a.`type` =#{type}
  157. </if>
  158. <if test="startTime !=null and endTime !=null">
  159. and a.last_follow_time between #{startTime} and #{endTime}
  160. </if>
  161. </sql>
  162. <select id="RestrictProjectCount" resultType="java.lang.Integer">
  163. select count(*)
  164. from restrict_project a
  165. left join user b on a.uid =b.id left join business_project c on a.pid =c.id
  166. left join admin d on b.aid =d.id left join admin d2 on a.aid =d2.id
  167. where a.`type` >0
  168. <include refid="RestrictProjectSql"/>
  169. </select>
  170. <select id="selectByUid" resultType="com.goafanti.business.bo.OutRestrictProject">
  171. select b.id,b.type,b.lock_time lockTime,b.release_time releaseTime ,b.pid,a.bname projectName,
  172. c.nickname userName ,d.name adminName,b.create_time createTime,b.uid,b.aid
  173. from restrict_project b left join business_project a on b.pid =a.id
  174. left join user c on b.uid=c.id left join admin d on b.aid=d.id
  175. where b.aid= #{aid,jdbcType=VARCHAR}
  176. </select>
  177. <select id="selectByParam" resultMap="BaseResultMap">
  178. select
  179. <include refid="Base_Column_List" />
  180. from restrict_project
  181. where uid =#{uid,jdbcType=VARCHAR}
  182. <if test="aid != null">
  183. and aid = #{aid,jdbcType=VARCHAR}
  184. </if>
  185. <if test="pid != null">
  186. and pid = #{pid,jdbcType=VARCHAR}
  187. </if>
  188. </select>
  189. <select id="selectListByParam" resultType="com.goafanti.common.model.RestrictProject">
  190. select
  191. <include refid="Base_Column_List" />
  192. from restrict_project
  193. where type >0
  194. where uid =#{uid,jdbcType=VARCHAR}
  195. <if test="aid != null">
  196. and aid = #{aid,jdbcType=VARCHAR}
  197. </if>
  198. <if test="pid != null">
  199. and pid = #{pid,jdbcType=VARCHAR}
  200. </if>
  201. </select>
  202. <update id="updateRelease">
  203. update restrict_project set release_time = now(),type=0
  204. where id in
  205. <foreach collection="list" item="item" separator="," open="(" close=")">
  206. #{item}
  207. </foreach>
  208. </update>
  209. <update id="updateRefreshLockTime">
  210. update restrict_project set lock_time = now(),last_follow_time = now()
  211. where uid = #{uid,jdbcType=VARCHAR} and pid = #{pid,jdbcType=VARCHAR} and aid = #{aid,jdbcType=VARCHAR}
  212. </update>
  213. </mapper>