CoachInfoMapper.xml 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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.miaxis.coach.mapper.CoachInfoMapper">
  6. <resultMap type="CoachInfo" id="CoachInfoResult">
  7. <result property="id" column="id" />
  8. <result property="coachnum" column="coachnum" />
  9. <result property="name" column="name" />
  10. <result property="sex" column="sex" />
  11. <result property="inscode" column="inscode" />
  12. <result property="idcard" column="idcard" />
  13. <result property="mobile" column="mobile" />
  14. <result property="address" column="address" />
  15. <result property="photo" column="photo" />
  16. <result property="dripermitted" column="dripermitted" />
  17. <result property="teachpermitted" column="teachpermitted" />
  18. <result property="district" column="district" />
  19. <result property="employstatus" column="employstatus" />
  20. <result property="stopTrain" column="stop_train" />
  21. <result property="wechar" column="wechar" />
  22. <result property="openid" column="openid" />
  23. <result property="createTime" column="create_time" />
  24. <result property="updateTime" column="update_time" />
  25. <result property="fabulous" column="fabulous" />
  26. <result property="password" column="password" />
  27. <result property="status" column="status" />
  28. </resultMap>
  29. <select id="selectCoachInfoUrlList" parameterType="com.miaxis.coach.dto.CoachInfoDTO" resultType="com.miaxis.coach.dto.CoachInfoVO">
  30. SELECT c.*,ci.file_url,ce.totel_stars,
  31. (2 * 6378.137 * ASIN(SQRT(POW( SIN( PI( ) * ( #{lon}- s.poi_lon ) / 360 ), 2 ) + COS( PI( ) * #{lat} / 180 ) * COS( s.poi_lat * PI( ) / 180 ) * POW( SIN( PI( ) * ( #{lat}- s.poi_lat ) / 360 ), 2 )) ) ) AS distance FROM coach_info c
  32. join school_info s
  33. on c.inscode = s.inscode
  34. LEFT JOIN coach_images ci
  35. ON c.photo = ci.id
  36. left join coach_evaluate ce
  37. on c.coachnum = ce.coachnum
  38. <where>
  39. <if test="teachpermitted != null and teachpermitted != ''"> and teachpermitted = #{teachpermitted}</if>
  40. <if test="sex != null and sex != ''"> and sex = #{sex}</if>
  41. </where>
  42. <if test="orderName!=null and orderType!=null">
  43. order by ${orderName} ${orderType}
  44. </if>
  45. </select>
  46. <sql id="selectCoachInfoVo">
  47. select id,coachnum, name, sex, inscode, idcard, mobile, address, photo, dripermitted, teachpermitted, district, employstatus, stop_train, wechar, openid, create_time, update_time, fabulous,password,status from coach_info
  48. </sql>
  49. <select id="selectCoachInfoList" parameterType="CoachInfo" resultMap="CoachInfoResult">
  50. <include refid="selectCoachInfoVo"/>
  51. <where>
  52. <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
  53. <if test="sex != null "> and sex = #{sex}</if>
  54. <if test="inscode != null and inscode != ''"> and inscode = #{inscode}</if>
  55. <if test="idcard != null and idcard != ''"> and idcard = #{idcard}</if>
  56. <if test="mobile != null and mobile != ''"> and mobile = #{mobile}</if>
  57. <if test="address != null and address != ''"> and address = #{address}</if>
  58. <if test="photo != null "> and photo = #{photo}</if>
  59. <if test="dripermitted != null and dripermitted != ''"> and dripermitted = #{dripermitted}</if>
  60. <if test="teachpermitted != null and teachpermitted != ''"> and teachpermitted = #{teachpermitted}</if>
  61. <if test="district != null and district != ''"> and district = #{district}</if>
  62. <if test="employstatus != null "> and employstatus = #{employstatus}</if>
  63. <if test="stopTrain != null "> and stop_train = #{stopTrain}</if>
  64. <if test="wechar != null and wechar != ''"> and wechar = #{wechar}</if>
  65. <if test="openid != null and openid != ''"> and openid = #{openid}</if>
  66. <if test="fabulous != null "> and fabulous = #{fabulous}</if>
  67. </where>
  68. </select>
  69. <select id="selectCoachInfoById" parameterType="String" resultMap="CoachInfoResult">
  70. <include refid="selectCoachInfoVo"/>
  71. where coachnum = #{coachnum}
  72. </select>
  73. <insert id="insertCoachInfo" parameterType="CoachInfo">
  74. insert into coach_info
  75. <trim prefix="(" suffix=")" suffixOverrides=",">
  76. <if test="coachnum != null">coachnum,</if>
  77. <if test="name != null">name,</if>
  78. <if test="sex != null">sex,</if>
  79. <if test="inscode != null">inscode,</if>
  80. <if test="idcard != null">idcard,</if>
  81. <if test="mobile != null">mobile,</if>
  82. <if test="address != null">address,</if>
  83. <if test="photo != null">photo,</if>
  84. <if test="dripermitted != null">dripermitted,</if>
  85. <if test="teachpermitted != null">teachpermitted,</if>
  86. <if test="district != null">district,</if>
  87. <if test="employstatus != null">employstatus,</if>
  88. <if test="stopTrain != null">stop_train,</if>
  89. <if test="wechar != null">wechar,</if>
  90. <if test="openid != null">openid,</if>
  91. <if test="createTime != null">create_time,</if>
  92. <if test="updateTime != null">update_time,</if>
  93. <if test="fabulous != null">fabulous,</if>
  94. </trim>
  95. <trim prefix="values (" suffix=")" suffixOverrides=",">
  96. <if test="coachnum != null">#{coachnum},</if>
  97. <if test="name != null">#{name},</if>
  98. <if test="sex != null">#{sex},</if>
  99. <if test="inscode != null">#{inscode},</if>
  100. <if test="idcard != null">#{idcard},</if>
  101. <if test="mobile != null">#{mobile},</if>
  102. <if test="address != null">#{address},</if>
  103. <if test="photo != null">#{photo},</if>
  104. <if test="dripermitted != null">#{dripermitted},</if>
  105. <if test="teachpermitted != null">#{teachpermitted},</if>
  106. <if test="district != null">#{district},</if>
  107. <if test="employstatus != null">#{employstatus},</if>
  108. <if test="stopTrain != null">#{stopTrain},</if>
  109. <if test="wechar != null">#{wechar},</if>
  110. <if test="openid != null">#{openid},</if>
  111. <if test="createTime != null">#{createTime},</if>
  112. <if test="updateTime != null">#{updateTime},</if>
  113. <if test="fabulous != null">#{fabulous},</if>
  114. </trim>
  115. </insert>
  116. <update id="updateCoachInfo" parameterType="CoachInfo">
  117. update coach_info
  118. <trim prefix="SET" suffixOverrides=",">
  119. <if test="name != null">name = #{name},</if>
  120. <if test="sex != null">sex = #{sex},</if>
  121. <if test="inscode != null">inscode = #{inscode},</if>
  122. <if test="idcard != null">idcard = #{idcard},</if>
  123. <if test="mobile != null">mobile = #{mobile},</if>
  124. <if test="address != null">address = #{address},</if>
  125. <if test="photo != null">photo = #{photo},</if>
  126. <if test="dripermitted != null">dripermitted = #{dripermitted},</if>
  127. <if test="teachpermitted != null">teachpermitted = #{teachpermitted},</if>
  128. <if test="district != null">district = #{district},</if>
  129. <if test="employstatus != null">employstatus = #{employstatus},</if>
  130. <if test="stopTrain != null">stop_train = #{stopTrain},</if>
  131. <if test="wechar != null">wechar = #{wechar},</if>
  132. <if test="openid != null">openid = #{openid},</if>
  133. <if test="createTime != null">create_time = #{createTime},</if>
  134. <if test="updateTime != null">update_time = #{updateTime},</if>
  135. <if test="fabulous != null">fabulous = #{fabulous},</if>
  136. </trim>
  137. where coachnum = #{coachnum}
  138. </update>
  139. <delete id="deleteCoachInfoByIds" parameterType="String">
  140. delete from coach_info where coachnum in
  141. <foreach item="coachnum" collection="array" open="(" separator="," close=")">
  142. #{coachnum}
  143. </foreach>
  144. </delete>
  145. <select id="queryList" resultType="com.miaxis.coach.vo.CoachInfoPcVO">
  146. SELECT
  147. ci.`id`,
  148. ci.`coachnum`,
  149. ci.`name`,
  150. ci.`sex`,
  151. ci.`inscode`,
  152. ci.`idcard`,
  153. ci.`status`,
  154. ci.`mobile`
  155. FROM
  156. coach_info ci
  157. join school_info d on ci.inscode= d.inscode
  158. <where>
  159. ci.`status` = '0'
  160. <if test="name != null and name != ''"> and ci.`name` like concat('%', #{name}, '%')</if>
  161. <if test="coachnum != null and coachnum != ''"> and ci.coachnum = #{coachnum}</if>
  162. <if test="mobile != null and mobile != ''"> and ci.mobile = #{mobile}</if>
  163. </where>
  164. <!-- 数据范围过滤 -->
  165. ${params.dataScope}
  166. </select>
  167. <!--密码重置-->
  168. <update id="resetPassword">
  169. UPDATE
  170. coach_info ci
  171. SET password = #{password}
  172. <where>
  173. and ci.id in
  174. <foreach collection="ids" item="id" open="(" close=")" separator=",">
  175. (#{id})
  176. </foreach>
  177. </where>
  178. </update>
  179. <!--pc删除教练(逻辑删除)-->
  180. <update id="removeCoach">
  181. UPDATE
  182. coach_info ci
  183. SET ci.status = '1'
  184. <where>
  185. and ci.id in
  186. <foreach collection="ids" item="id" open="(" close=")" separator=",">
  187. (#{id})
  188. </foreach>
  189. </where>
  190. </update>
  191. </mapper>