AccountMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  4. <mapper namespace="com.zhyc.xps.sys.mapper.AccountMapper">
  5. <resultMap id="BaseResultMap" type="com.zhyc.xps.sys.entity.Account">
  6. <result column="oc_id" property="ocId" jdbcType="BIGINT" /><!--公司或组织ID-->
  7. <result column="account_id" property="accountId" jdbcType="BIGINT" /><!--帐号ID-->
  8. <result column="account_name" property="accountName" jdbcType="VARCHAR" />
  9. <result column="password" property="password" jdbcType="VARCHAR" />
  10. <result column="account_type" property="accountType" jdbcType="BIGINT" />
  11. <result column="account_staff_no" property="accountStaffNo" jdbcType="VARCHAR" />
  12. <result column="account_phone" property="accountPhone" jdbcType="VARCHAR" />
  13. <result column="account_last_ip" property="accountLastIp" jdbcType="VARCHAR" />
  14. <result column="account_loc" property="accountLoc" jdbcType="VARCHAR" />
  15. <result column="status" property="status" jdbcType="BIGINT" />
  16. <result column="account_avatar" property="accountAvatar" jdbcType="VARCHAR" />
  17. <result column="account_photo" property="accountPhoto" jdbcType="VARCHAR" />
  18. <result column="account_real_name" property="accountRealName" jdbcType="VARCHAR" />
  19. <result column="account_email" property="accountMail" jdbcType="VARCHAR" />
  20. <result column="account_intro" property="accountIntro" jdbcType="VARCHAR" />
  21. <result column="is_fixed" property="isFixed" jdbcType="BIGINT" />
  22. </resultMap>
  23. <!--AccountDto-->
  24. <resultMap id="AccountDtoResultMap" type="com.zhyc.xps.sys.dto.AccountDto" extends="BaseResultMap">
  25. <result column="oc_type_id" property="ocTypeId" jdbcType="VARCHAR" />
  26. <result column="oc_name" property="ocName" jdbcType="VARCHAR" /><!--公司或组织ID-->
  27. <result column="wx_id" property="wxId" jdbcType="VARCHAR" />
  28. <result column="group_id" property="groupId" jdbcType="BIGINT" />
  29. <result column="position_id" property="positionId" jdbcType="BIGINT" />
  30. </resultMap>
  31. <sql id="Ext_Column_List">
  32. A.oc_id,
  33. B.oc_type_id,
  34. B.oc_name,
  35. A.account_id,
  36. A.account_name,
  37. A.account_real_name,
  38. A.password,
  39. A.account_type,
  40. A.account_staff_no,
  41. A.account_phone,
  42. A.account_last_ip,
  43. A.account_loc,
  44. A.status,
  45. A.account_avatar,
  46. A.account_photo,
  47. A.account_real_name,
  48. A.account_intro,
  49. A.wx_id,
  50. A.is_fixed
  51. </sql>
  52. <!--通过ID 获取账号信息-->
  53. <select id="getById" resultMap="AccountDtoResultMap">
  54. SELECT
  55. <include refid="Ext_Column_List"/>
  56. FROM account AS A
  57. LEFT JOIN oc AS B ON (A.oc_id = B.oc_id )
  58. WHERE A.deleted_flag = 0
  59. <if test="ocId != null">
  60. AND A.oc_id = #{ocId ,jdbcType = BIGINT}
  61. </if>
  62. <if test="accountId != null">
  63. AND A.account_id = #{accountId ,jdbcType = BIGINT}
  64. </if>
  65. </select>
  66. <!--根据用户名或手机号或工号获取账号信息 -->
  67. <select id="getAccountByCode" resultMap="AccountDtoResultMap">
  68. SELECT
  69. <include refid="Ext_Column_List"/>
  70. FROM account AS A
  71. LEFT JOIN oc AS B ON (A.oc_id = B.oc_id )
  72. WHERE A.deleted_flag = 0
  73. AND (A.account_name = #{code, jdbcType=VARCHAR}
  74. OR A.account_phone = #{code, jdbcType=VARCHAR}
  75. OR A.account_mail = #{code, jdbcType=VARCHAR}
  76. OR A.account_staff_no = #{code, jdbcType=VARCHAR})
  77. </select>
  78. <!--根据名字获取账号信息 -->
  79. <select id="getAccountById" resultMap="AccountDtoResultMap">
  80. SELECT
  81. <include refid="Ext_Column_List"/>
  82. FROM account AS A
  83. LEFT JOIN oc AS B ON (A.oc_id = B.oc_id )
  84. WHERE A.deleted_flag = 0
  85. AND A.account_id = #{accountId ,jdbcType = BIGINT}
  86. </select>
  87. <!--根据查询条件获取账号信息-->
  88. <select id="getByPage" parameterType="java.util.Map" resultMap="AccountDtoResultMap">
  89. SELECT
  90. <include refid="Ext_Column_List"/>
  91. FROM account AS A
  92. LEFT JOIN oc AS B ON (A.oc_id = B.oc_id )
  93. WHERE A.deleted_flag = 0
  94. <if test="keywords != null and keywords != ''">
  95. AND ( A.account_real_name LIKE "%"#{keywords}"%"
  96. OR A.account_name LIKE "%"#{keywords}"%"
  97. OR A.account_phone LIKE "%"#{keywords}"%")
  98. </if>
  99. <if test="ocId != null and ocId != ''">
  100. AND A.oc_id = #{ocId ,jdbcType = BIGINT}
  101. </if>
  102. <if test="orderBy != null and orderBy != ''">
  103. ORDER BY A.${orderBy}
  104. </if>
  105. </select>
  106. <!--根据查询条件获取账号信息-->
  107. <select id="getByList" parameterType="java.util.Map" resultMap="AccountDtoResultMap">
  108. SELECT
  109. <include refid="Ext_Column_List"/>,C.group_id,C.position_id
  110. FROM account AS A
  111. LEFT JOIN oc AS B ON (A.oc_id = B.oc_id )
  112. LEFT JOIN s_group_member_position AS C ON (A.oc_id = C.oc_id and C.account_id = A.account_id )
  113. WHERE A.deleted_flag = 0
  114. <if test="keywords != null and keywords != ''">
  115. AND ( A.account_real_name LIKE "%"#{keywords}"%"
  116. OR A.account_name LIKE "%"#{keywords}"%"
  117. OR A.account_phone LIKE "%"#{keywords}"%")
  118. </if>
  119. <if test="ocId != null">
  120. AND A.oc_id = #{ocId ,jdbcType = BIGINT}
  121. </if>
  122. <if test="orderBy != null and orderBy != ''">
  123. ORDER BY A.${orderBy}
  124. </if>
  125. </select>
  126. <!--新增-->
  127. <insert id="create" useGeneratedKeys="true" keyProperty="accountId" parameterType="com.zhyc.xps.sys.entity.Account">
  128. insert into account
  129. <trim prefix="(" suffix=")" suffixOverrides=",">
  130. <if test="ocId != null">
  131. oc_id,
  132. </if>
  133. <if test="accountId != null">
  134. account_id,
  135. </if>
  136. <if test="accountName != null and accountName != ''">
  137. account_name,
  138. </if>
  139. <if test="password != null and password != ''">
  140. password,
  141. </if>
  142. <if test="accountType != null">
  143. account_type,
  144. </if>
  145. <if test="accountStaffNo != null and accountStaffNo != ''">
  146. account_staff_no,
  147. </if>
  148. <if test="accountPhone != null and accountPhone != ''">
  149. account_phone,
  150. </if>
  151. <if test="accountLastIp != null and accountLastIp!= ''">
  152. account_last_ip,
  153. </if>
  154. <if test="accountLoc != null and accountLoc != ''">
  155. account_loc,
  156. </if>
  157. <if test="status != null">
  158. status,
  159. </if>
  160. <if test="accountAvatar != null and accountAvatar != ''">
  161. account_avatar,
  162. </if>
  163. <if test="accountPhoto != null and accountPhoto !=''">
  164. account_photo,
  165. </if>
  166. <if test="accountRealName != null and accountRealName != ''">
  167. account_real_name,
  168. </if>
  169. <if test="accountMail != null and accountMail != ''">
  170. account_mail,
  171. </if>
  172. <if test="accountIntro != null and accountIntro != ''">
  173. account_intro,
  174. </if>
  175. <if test="isFixed != null">
  176. is_fixed,
  177. </if>
  178. <if test="createdAt != null">
  179. created_at,
  180. </if>
  181. <if test="createdBy != null">
  182. created_by,
  183. </if>
  184. </trim>
  185. <trim prefix="values (" suffix=")" suffixOverrides=",">
  186. <if test="ocId != null">
  187. #{ocId, jdbcType=BIGINT},
  188. </if>
  189. <if test="accountId != null">
  190. #{accountId, jdbcType=BIGINT},
  191. </if>
  192. <if test="accountName != null and accountName !=''">
  193. #{accountName, jdbcType=VARCHAR},
  194. </if>
  195. <if test="password != null and password != ''">
  196. #{password, jdbcType=VARCHAR},
  197. </if>
  198. <if test="accountType != null">
  199. #{accountType, jdbcType=BIGINT},
  200. </if>
  201. <if test="accountStaffNo != null and accountStaffNo != ''">
  202. #{accountStaffNo, jdbcType=VARCHAR},
  203. </if>
  204. <if test="accountPhone != null and accountPhone!= ''">
  205. #{accountPhone, jdbcType=VARCHAR},
  206. </if>
  207. <if test="accountLastIp != null and accountLastIp != ''">
  208. #{accountLastIp, jdbcType=VARCHAR},
  209. </if>
  210. <if test="accountLoc != null and accountLoc != ''">
  211. #{accountLoc, jdbcType=VARCHAR},
  212. </if>
  213. <if test="status != null">
  214. #{status, jdbcType=BIGINT},
  215. </if>
  216. <if test="accountAvatar != null and accountAvatar !=''">
  217. #{accountAvatar, jdbcType=VARCHAR},
  218. </if>
  219. <if test="accountPhoto != null and accountPhoto !=''">
  220. #{accountPhoto, jdbcType=VARCHAR},
  221. </if>
  222. <if test="accountRealName != null and accountRealName != ''">
  223. #{accountRealName, jdbcType=VARCHAR},
  224. </if>
  225. <if test="accountMail != null and accountMail != ''">
  226. #{accountMail, jdbcType=VARCHAR},
  227. </if>
  228. <if test="accountIntro != null and accountIntro != ''">
  229. #{accountIntro, jdbcType=VARCHAR},
  230. </if>
  231. <if test="isFixed != null">
  232. #{isFixed, jdbcType=BIGINT},
  233. </if>
  234. <if test="createdAt != null">
  235. #{createdAt, jdbcType=DATE},
  236. </if>
  237. <if test="createdBy != null">
  238. #{createdBy, jdbcType=BIGINT},
  239. </if>
  240. </trim>
  241. </insert>
  242. <!--Update-->
  243. <update id="update" parameterType="com.zhyc.xps.sys.entity.Account">
  244. UPDATE account
  245. <trim suffixOverrides=",">
  246. <set>
  247. <if test="accountName != null and accountName != ''">
  248. account_name = #{accountName,jdbcType=VARCHAR},
  249. </if>
  250. <if test="accountRealName != null and accountRealName !=''">
  251. account_real_name = #{accountRealName,jdbcType=VARCHAR},
  252. </if>
  253. <if test="password != null and password !=''">
  254. password = #{password,jdbcType=VARCHAR},
  255. </if>
  256. <if test="accountIntro != null">
  257. account_intro = #{accountIntro,jdbcType=VARCHAR},
  258. </if>
  259. <if test="isFixed != null">
  260. is_fixed = #{isFixed,jdbcType=BIGINT},
  261. </if>
  262. <if test="accountStaffNo != null">
  263. account_staff_no = #{accountStaffNo,jdbcType=VARCHAR},
  264. </if>
  265. <if test="accountPhone != null and accountPhone != ''">
  266. account_phone = #{accountPhone,jdbcType=VARCHAR},
  267. </if>
  268. <if test="wxId != null">
  269. wx_id = #{wxId,jdbcType=VARCHAR},
  270. </if>
  271. <if test="status != null">
  272. status = #{status,jdbcType=BIGINT},
  273. </if>
  274. <if test="accountAvatar != null">
  275. account_avatar = #{accountAvatar,jdbcType=VARCHAR},
  276. </if>
  277. <if test="accountPhoto != null">
  278. account_photo = #{accountPhoto,jdbcType=VARCHAR},
  279. </if>
  280. <if test="accountMail != null">
  281. account_mail = #{accountMail, jdbcType=VARCHAR},
  282. </if>
  283. <if test="updatedAt != null">
  284. updated_at = #{updatedAt,jdbcType=DATE},
  285. </if>
  286. <if test="updatedBy != null">
  287. updated_by = #{updatedBy,jdbcType=BIGINT},
  288. </if>
  289. </set>
  290. </trim>
  291. WHERE oc_id = #{ocId, jdbcType=BIGINT} AND account_id = #{accountId ,jdbcType=BIGINT}
  292. </update>
  293. <!--更新密码-->
  294. <update id="updatePassword" parameterType="java.util.Map">
  295. UPDATE account
  296. SET password = #{password ,jdbcType=VARCHAR}
  297. WHERE deleted_flag = 0
  298. AND oc_id = #{ocId, jdbcType=BIGINT}
  299. AND account_id = #{accountId,jdbcType=BIGINT}
  300. </update>
  301. <!--删除-->
  302. <update id="delete" parameterType="java.util.Map">
  303. UPDATE account
  304. <trim suffixOverrides=",">
  305. <set>
  306. <if test="deletedFlag != null">
  307. deleted_flag = #{deletedFlag,jdbcType=BIGINT},
  308. </if>
  309. <if test="deletedTime != null">
  310. deleted_time = #{deletedTime,jdbcType=VARCHAR},
  311. </if>
  312. <if test="deletedBy != null">
  313. deleted_by = #{deletedBy,jdbcType=BIGINT},
  314. </if>
  315. </set>
  316. </trim>
  317. WHERE 1 = 1
  318. <if test="ocId != null">
  319. AND oc_id = #{ocId, jdbcType=BIGINT}
  320. </if>
  321. <if test="accountId != null">
  322. AND account_id = #{accountId ,jdbcType = BIGINT}
  323. </if>
  324. </update>
  325. <!--检查用户名及电话是否存在-->
  326. <select id="isAccountInfoExist" parameterType="java.util.Map" resultType="java.lang.Long">
  327. SELECT count(*)
  328. FROM account
  329. <where>
  330. deleted_flag = 0
  331. <if test="ocId != null">
  332. AND oc_id = #{ocId, jdbcType=BIGINT}
  333. </if>
  334. <if test="accountName != null and accountName != ''">
  335. AND account_name = #{accountName,jdbcType=VARCHAR}
  336. </if>
  337. <if test="accountPhone != null and accountPhone != ''">
  338. AND account_phone = #{accountPhone ,jdbcType=VARCHAR}
  339. </if>
  340. <if test="accountStaffNo != null and accountStaffNo != ''">
  341. AND account_staff_no = #{accountStaffNo, jdbcType=VARCHAR}
  342. </if>
  343. <if test="accountId != null">
  344. AND account_id != #{accountId, jdbcType=BIGINT}
  345. </if>
  346. </where>
  347. </select>
  348. <!--检查微信ID是否存在-->
  349. <select id="isWxIdExist" resultType="java.lang.Long">
  350. SELECT 1
  351. FROM account AS A
  352. WHERE A.deleted_flag = 0
  353. AND A.wx_id = #{wxId,jdbcType=VARCHAR}
  354. Limit 1
  355. </select>
  356. <!--检查帐号名称是否存在-->
  357. <select id="isAccountNameExist" resultType="java.lang.Long">
  358. SELECT 1
  359. FROM account AS A
  360. WHERE A.deleted_flag = 0
  361. AND A.account_name = #{accountName, jdbcType=VARCHAR}
  362. LIMIT 1
  363. </select>
  364. <!--检查电话号码是否存在-->
  365. <select id="isAccountPhoneExist" resultType="java.lang.Long">
  366. SELECT 1
  367. FROM account AS A
  368. WHERE A.deleted_flag = 0
  369. AND A.account_phone = #{accountPhone, jdbcType=VARCHAR}
  370. LIMIT 1
  371. </select>
  372. <!--检查电话号码是否存在-->
  373. <select id="isAccountStaffNoExist" resultType="java.lang.Long">
  374. SELECT 1
  375. FROM account AS A
  376. WHERE A.deleted_flag = 0
  377. AND A.oc_id = #{ocId, jdbcType=BIGINT}
  378. AND A.account_staff_no = #{accountStaffNo, jdbcType=VARCHAR}
  379. LIMIT 1
  380. </select>
  381. <!--检查EMAIL是否存在-->
  382. <select id="isAccountMailExist" resultType="java.lang.Long">
  383. SELECT 1
  384. FROM account AS A
  385. WHERE A.deleted_flag = 0
  386. AND A.account_mail = #{accountMail, jdbcType=VARCHAR}
  387. LIMIT 1
  388. </select>
  389. </mapper>