IPeopleDao.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  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. <!-- 管理员持久化层XML配置继承IRoleDao -->
  4. <mapper namespace="net.mingsoft.people.dao.IPeopleDao">
  5. <!-- 表字段开始 -->
  6. <sql id="column_list">
  7. PEOPLE_PHONE,PEOPLE_NAME,PEOPLE_PASSWORD,PEOPLE_CODE,
  8. PEOPLE_DATETIME,PEOPLE_MAIL,PEOPLE_STATE,PEOPLE_CODESENDDATE,
  9. PEOPLE_PHONECHECK,PEOPLE_MAILLCHECK
  10. </sql>
  11. <sql id="user_column_list">
  12. people_id,PU_REAL_NAME,PU_ADDRESS,PU_LEVEL,PU_LEVEL_NAME,PU_ICON,PU_NICKNAME,PU_SEX,PU_BIRTHDAY,PU_CARD,
  13. PROVINCE_ID,PROVINCE_NAME,CITY_ID,CITY_NAME,COUNTY_ID,COUNTY_NAME
  14. </sql>
  15. <!-- 将实体属性与表字段对接开始 -->
  16. <resultMap id="resultMap" type="net.mingsoft.people.bean.PeopleBean">
  17. <id column="id" property="id"/><!-- 将实体的ID属性与表的ID字段对接 -->
  18. <result column="PEOPLE_PHONE" property="peoplePhone"/><!-- 将实体的peoplePhone属性与表的peoplePhone字段对接 -->
  19. <result column="PEOPLE_NAME" property="peopleName"/><!-- 将实体的peopleName属性与表的peopleName字段对接 -->
  20. <result column="PEOPLE_PASSWORD" property="peoplePassword"/><!--
  21. 将实体的PEOPLE_PASSWORD属性与表的peoplePwd字段对接 -->
  22. <result column="PEOPLE_DATETIME" property="peopleDateTime"/><!--
  23. 将实体的peopleDateTime属性与表的peopleDateTime字段对接 -->
  24. <result column="PEOPLE_MAIL" property="peopleMail"/><!-- 用户邮箱 -->
  25. <result column="PEOPLE_IP" property="peopleIp"/><!-- 用户ip -->
  26. <result column="PEOPLE_STATE" property="peopleState"/><!-- 用户状态 -->
  27. <result column="PEOPLE_CODE" property="peopleCode"/><!-- 用户随机码 -->
  28. <result column="PEOPLE_CODESENDDATE" property="peopleCodeSendDate"/><!--
  29. 用户随机码发送时间 -->
  30. <result column="PEOPLE_MAILLCHECK" property="peopleMailCheck"/><!--
  31. 用户是否通过邮箱验证 -->
  32. <result column="PEOPLE_PHONECHECK" property="peoplePhoneCheck"/><!--
  33. 用户是否通过电话验证 -->
  34. <result column="PU_REAL_NAME" property="puRealName"/><!--用户的真实名称 -->
  35. <result column="PU_ADDRESS" property="puAddress"/><!--用户地址 -->
  36. <result column="PU_ICON" property="puIcon"/><!-- 用户头像 -->
  37. <result column="PU_LEVEL" property="puLevel"/><!-- 用户等级 -->
  38. <result column="PU_LEVEL_NAME" property="puLevelName"/><!-- 等级名称 -->
  39. <result column="PU_ICON" property="puIcon"/><!-- 用户头像 -->
  40. <result column="PU_NICKNAME" property="puNickname"/><!--用户昵称 -->
  41. <result column="PU_SEX" property="puSex"/><!-- 用户性别0.未知;1.男;2.女 -->
  42. <result column="PU_BIRTHDAY" property="puBirthday"/><!--用户生日 -->
  43. <result column="PU_CARD" property="puCard"/><!-- 用户身份证号码 -->
  44. </resultMap>
  45. <!-- 将实体属性与表字段对接开始 -->
  46. <resultMap id="resultMap2" type="net.mingsoft.people.bean.PeopleBeanExtension">
  47. <id column="id" property="id"/><!-- 将实体的ID属性与表的ID字段对接 -->
  48. <result column="PEOPLE_PHONE" property="peoplePhone"/><!-- 将实体的peoplePhone属性与表的peoplePhone字段对接 -->
  49. <result column="PEOPLE_NAME" property="peopleName"/><!-- 将实体的peopleName属性与表的peopleName字段对接 -->
  50. <result column="PEOPLE_PASSWORD" property="peoplePassword"/><!--
  51. 将实体的PEOPLE_PASSWORD属性与表的peoplePwd字段对接 -->
  52. <result column="PEOPLE_DATETIME" property="peopleDateTime"/><!--
  53. 将实体的peopleDateTime属性与表的peopleDateTime字段对接 -->
  54. <result column="PEOPLE_MAIL" property="peopleMail"/><!-- 用户邮箱 -->
  55. <result column="PEOPLE_IP" property="peopleIp"/><!-- 用户ip -->
  56. <result column="PEOPLE_STATE" property="peopleState"/><!-- 用户状态 -->
  57. <result column="PEOPLE_CODE" property="peopleCode"/><!-- 用户随机码 -->
  58. <result column="PEOPLE_CODESENDDATE" property="peopleCodeSendDate"/><!--
  59. 用户随机码发送时间 -->
  60. <result column="PEOPLE_MAILLCHECK" property="peopleMailCheck"/><!--
  61. 用户是否通过邮箱验证 -->
  62. <result column="PEOPLE_PHONECHECK" property="peoplePhoneCheck"/><!--
  63. 用户是否通过电话验证 -->
  64. <result column="PU_REAL_NAME" property="puRealName"/><!--用户的真实名称 -->
  65. <result column="PU_ADDRESS" property="puAddress"/><!--用户地址 -->
  66. <result column="PU_ICON" property="puIcon"/><!-- 用户头像 -->
  67. <result column="PU_LEVEL" property="puLevel"/><!-- 用户等级 -->
  68. <result column="PU_LEVEL_NAME" property="puLevelName"/><!-- 等级名称 -->
  69. <result column="PU_ICON" property="puIcon"/><!-- 用户头像 -->
  70. <result column="PU_NICKNAME" property="puNickname"/><!--用户昵称 -->
  71. <result column="PU_SEX" property="puSex"/><!-- 用户性别0.未知;1.男;2.女 -->
  72. <result column="PU_BIRTHDAY" property="puBirthday"/><!--用户生日 -->
  73. <result column="PU_CARD" property="puCard"/><!-- 用户身份证号码 -->
  74. <result column="COMPANY_NAME" property="companyName" /><!--公司名称 -->
  75. <result column="POSITION" property="position" /><!--职位 -->
  76. <result column="INVITATION_CODE" property="invitationCode" /><!--展商邀请码 -->
  77. <result column="INVITATION_USER_ID" property="invitationUserId" /><!--邀请用户ID -->
  78. <result column="CHANNEL" property="channel" /><!--了解渠道 -->
  79. <result column="PURPOSE" property="purpose" /><!--参观目的 -->
  80. </resultMap>
  81. <!-- 将实体属性与表字段对接结束 -->
  82. <sql id="insertColumns">
  83. <if test="peoplePhone != null">PEOPLE_PHONE,</if>
  84. <if test="peopleName != null">PEOPLE_NAME,</if>
  85. <if test="peoplePassword != null">PEOPLE_PASSWORD,</if>
  86. <if test="peopleDateTime != null">PEOPLE_DATETIME,</if>
  87. <if test="peopleMail != null">PEOPLE_MAIL,</if>
  88. <if test="peopleIp != null">PEOPLE_IP,</if>
  89. <if test="peopleState != null">PEOPLE_STATE,</if>
  90. <if test="peopleCode != null">PEOPLE_CODE,</if>
  91. <if test="peopleCodeSendDate != null">PEOPLE_CODESENDDATE,</if>
  92. <if test="peopleMailCheck != null and peopleMailCheck &gt; -1">PEOPLE_MAILLCHECK,</if>
  93. <if test="peoplePhoneCheck != null and peoplePhoneCheck &gt; -1">PEOPLE_PHONECHECK,</if>
  94. </sql>
  95. <sql id="insertValues">
  96. <if test="peoplePhone != null">#{peoplePhone},</if>
  97. <if test="peopleName != null">#{peopleName},</if>
  98. <if test="peoplePassword != null">#{peoplePassword},</if>
  99. <if test="peopleDateTime != null">#{peopleDateTime},</if>
  100. <if test="peopleMail != null">#{peopleMail},</if>
  101. <if test="peopleIp != null">#{peopleIp},</if>
  102. <if test="peopleState != null">#{peopleState},</if>
  103. <if test="peopleCode != null">#{peopleCode},</if>
  104. <if test="peopleCodeSendDate != null">#{peopleCodeSendDate},</if>
  105. <if test="peopleMailCheck != null and peopleMailCheck &gt; -1">#{peopleMailCheck},</if>
  106. <if test="peoplePhoneCheck != null and peoplePhoneCheck &gt; -1">#{peoplePhoneCheck},</if>
  107. </sql>
  108. <insert id="saveEntity"
  109. parameterType="net.mingsoft.base.entity.BaseEntity">
  110. insert into people
  111. <trim prefix="(" suffix=")" suffixOverrides=",">
  112. <include refid="insertColumns"></include>
  113. </trim>
  114. <trim prefix="values (" suffix=")" suffixOverrides=",">
  115. <include refid="insertValues"></include>
  116. </trim>
  117. </insert>
  118. <!-- 查询用户开始 -->
  119. <select id="getEntity" resultMap="resultMap" parameterType="String">
  120. select
  121. <include refid="column_list" />
  122. ,p.id,PU_NICKNAME,PU_REAL_NAME
  123. from people p LEFT JOIN people_user ON
  124. (p.id = people_user.PEOPLE_ID)
  125. where
  126. p.id =
  127. #{id}
  128. </select>
  129. <!-- 查询用户结束 -->
  130. <!-- 查询用户开始 -->
  131. <select id="getByEntity" resultMap="resultMap" parameterType="net.mingsoft.people.entity.PeopleEntity">
  132. select
  133. <include refid="column_list" />
  134. ,PU_NICKNAME,PU_REAL_NAME,p.id
  135. from people p LEFT JOIN people_user ON
  136. (p.id = people_user.PEOPLE_ID)
  137. <where>
  138. <if test="id != null and id &gt; 0">and p.id=#{id}</if>
  139. <if test="peopleName != null and peopleName != ''">and PEOPLE_NAME=#{peopleName}</if>
  140. <if test="peopleMail != null and peopleMail != ''">and PEOPLE_MAIL=#{peopleMail}</if>
  141. <if test="peoplePhone != null and peoplePhone != ''">and PEOPLE_PHONE=#{peoplePhone}</if>
  142. <if test="peopleMailCheck != null and peopleMailCheck &gt; -1">and PEOPLE_MAILLCHECK=#{peopleMailCheck}</if>
  143. </where>
  144. </select>
  145. <!-- 查询用户结束 -->
  146. <sql id="updateEntitySet">
  147. <if test="peoplePhone != null">PEOPLE_PHONE=#{peoplePhone},</if>
  148. <if test="peopleName != null and peopleName != ''">PEOPLE_NAME=#{peopleName},</if>
  149. <if test="peoplePassword != null and peoplePassword != ''">PEOPLE_PASSWORD=#{peoplePassword},</if>
  150. <if test="peopleDateTime != null ">PEOPLE_DATETIME=#{peopleDateTime},</if>
  151. <if test="peopleMail != null">PEOPLE_MAIL=#{peopleMail},</if>
  152. <if test="peopleIp != null and peopleIp != ''">PEOPLE_IP=#{peopleIp},</if>
  153. <if test="peopleState != null">PEOPLE_STATE=#{peopleState},</if>
  154. <if test="peopleCode != null and peopleCode != ''">PEOPLE_CODE=#{peopleCode},</if>
  155. <if test="peopleCodeSendDate != null">PEOPLE_CODESENDDATE=#{peopleCodeSendDate},</if>
  156. <if test="peopleMailCheck != null and peopleMailCheck &gt; -1">PEOPLE_MAILLCHECK=#{peopleMailCheck},</if>
  157. <if test="peoplePhoneCheck != null and peoplePhoneCheck &gt; -1">PEOPLE_PHONECHECK=#{peoplePhoneCheck},</if>
  158. </sql>
  159. <!-- mysql和oracle更新用户开始 -->
  160. <update id="updateEntity" parameterType="net.mingsoft.base.entity.BaseEntity">
  161. update people
  162. <set>
  163. <include refid="updateEntitySet" />
  164. </set>
  165. where id = #{id}
  166. </update>
  167. <!-- 更新用户结束 -->
  168. <!-- 删除用户开始 -->
  169. <delete id="deleteEntity" parameterType="int">
  170. delete from people where
  171. id = #{id}
  172. </delete>
  173. <!-- 删除用户结束 -->
  174. <!-- 根据用户名(帐号,手机,邮箱)查询用户信息开始 -->
  175. <select id="getEntityByUserName" resultMap="resultMap">
  176. select
  177. <include refid="column_list" />
  178. ,people.id,<include refid="user_column_list" />
  179. from people LEFT JOIN people_user ON
  180. (people.id = people_user.PEOPLE_ID)
  181. where (people_name=#{userName} or
  182. (people_phone=#{userName} and PEOPLE_PHONECHECK=1) or
  183. people_mail=#{userName} and PEOPLE_MAILLCHECK=1)
  184. </select>
  185. <!-- 根据用户名(帐号,手机,邮箱)查询用户信息结束 -->
  186. <select id="getEntityByMailOrPhone" resultMap="resultMap">
  187. select
  188. <include refid="column_list" />
  189. ,people.id,<include refid="user_column_list" />
  190. from people LEFT JOIN people_user ON
  191. (people.id = people_user.PEOPLE_ID)
  192. where people_phone=#{userName} or
  193. people_mail=#{userName} and PEOPLE_MAILLCHECK=1
  194. </select>
  195. <select id="getByPeople" parameterType="net.mingsoft.people.entity.PeopleEntity"
  196. resultMap="resultMap">
  197. <if test="people != null">
  198. select
  199. <include refid="column_list" />
  200. ,people.id,<include refid="user_column_list" />
  201. from people LEFT JOIN people_user ON
  202. (people.id = people_user.PEOPLE_ID)
  203. <trim prefix="WHERE" prefixOverrides="AND|OR">
  204. <trim prefix="and (" prefixOverrides="AND|OR" suffix=")" >
  205. <if test="people.peopleName != null">
  206. or people_name = #{people.peopleName}
  207. </if>
  208. <if test="people.peopleMail != null and people.peopleMail != '' ">
  209. or (people_mail = #{people.peopleMail} and
  210. PEOPLE_MAILLCHECK=1
  211. )
  212. </if>
  213. <if test="people.peoplePhone !=null and people.peoplePhone != '' ">
  214. or (people_phone = #{people.peoplePhone} and
  215. PEOPLE_PHONECHECK=1)
  216. </if>
  217. </trim>
  218. </trim>
  219. </if>
  220. </select>
  221. <!-- 查询用户列表开始 -->
  222. <select id="query" resultMap="resultMap">
  223. select
  224. <include refid="column_list" />
  225. ,p.id,<include refid="user_column_list" />
  226. from people p left join people_user on
  227. p.id=PEOPLE_ID
  228. <where>
  229. <if test="where!=null">
  230. <if test="where.peopleName != null and where.peopleName!=''">
  231. and PEOPLE_NAME=#{where.peopleName}
  232. </if>
  233. <!-- 用户审核状态 -->
  234. <if test="where.peopleState!=null and where.peopleState &gt; -1">
  235. and PEOPLE_STATE=#{where.peopleState}
  236. </if>
  237. <!-- 根据用户注册时间 <if test="people.peopleDateStartTime !=null "> </if> -->
  238. <!-- 根据用户昵称 -->
  239. <if test="where.puNickname !=null and where.puNickname!=''">
  240. and PU_NICKNAME=#{where.puNickname}
  241. </if>
  242. <!-- 根据用户性别 -->
  243. <if
  244. test="where.puSex != null and where.puSex &gt; -1 ">
  245. and PU_SEX=#{where.puSex}
  246. </if>
  247. <!-- 根据用户真实姓名 -->
  248. <if
  249. test="where.puRealName != null and where.puRealName !=''">
  250. and PU_REAL_NAME=#{where.puRealName}
  251. </if>
  252. <if test="where.peopleDateStartTime != null and where.peopleDateEndTime !=null ">
  253. <if test="_databaseId == 'mysql'">
  254. and (PEOPLE_DATETIME between
  255. #{where.peopleDateStartTime} and #{where.peopleDateEndTime})
  256. </if>
  257. <if test="_databaseId == 'oracle'">
  258. and PEOPLE_DATETIME &gt; to_date(#{where.peopleDateStartTime}, 'yyyy-mm-dd hh24:mi:ss')
  259. and PEOPLE_DATETIME &lt; to_date(#{where.peopleDateEndTime}, 'yyyy-mm-dd hh24:mi:ss')
  260. </if>
  261. </if>
  262. <if test="where.peopleId != null and where.peopleId !=''">
  263. and p.id=#{where.peopleId}
  264. </if>
  265. <if test="where.peopleMail != null and where.peopleMail !=''">
  266. and p.PEOPLE_MAIL=#{where.peopleMail}
  267. </if>
  268. <if test="where.peoplePhone != null and where.peoplePhone !=''">
  269. and p.PEOPLE_PHONE=#{where.peoplePhone}
  270. </if>
  271. </if>
  272. </where>
  273. order by p.PEOPLE_DATETIME desc
  274. </select>
  275. <!-- 查询用户列表结束 -->
  276. <!-- 查询用户列表开始 -->
  277. <select id="query2" resultMap="resultMap2">
  278. select
  279. <include refid="column_list" />
  280. ,p.id,<include refid="user_column_list" />
  281. ,e.INVITATION_CODE,
  282. e.CHANNEL,
  283. e.INVITATION_USER_ID,
  284. e.POSITION,
  285. e.COMPANY_NAME,
  286. e.PURPOSE
  287. from people p left join people_user on p.id=PEOPLE_ID
  288. left join mdiy_model_people_info e on e.LINK_ID=p.id
  289. <where>
  290. <if test="where!=null">
  291. <if test="where.peopleName != null and where.peopleName!=''">
  292. and PEOPLE_NAME like CONCAT(CONCAT('%',#{where.peopleName}),'%')
  293. </if>
  294. <!-- 用户审核状态 -->
  295. <if test="where.peopleState!=null and where.peopleState &gt; -1">
  296. and PEOPLE_STATE=#{where.peopleState}
  297. </if>
  298. <!-- 根据用户注册时间 <if test="people.peopleDateStartTime !=null "> </if> -->
  299. <!-- 根据用户昵称 -->
  300. <if test="where.puNickname !=null and where.puNickname!=''">
  301. and PU_NICKNAME like CONCAT(CONCAT('%',#{where.puNickname}),'%')
  302. </if>
  303. <!-- 根据用户性别 -->
  304. <if
  305. test="where.puSex != null and where.puSex &gt; -1 ">
  306. and PU_SEX=#{where.puSex}
  307. </if>
  308. <!-- 根据用户真实姓名 -->
  309. <if
  310. test="where.puRealName != null and where.puRealName !=''">
  311. and PU_REAL_NAME like CONCAT(CONCAT('%',#{where.puRealName}),'%')
  312. </if>
  313. <if test="where.peopleDateStartTime != null and where.peopleDateEndTime !=null ">
  314. <if test="_databaseId == 'mysql'">
  315. and (PEOPLE_DATETIME between
  316. #{where.peopleDateStartTime} and #{where.peopleDateEndTime})
  317. </if>
  318. <if test="_databaseId == 'oracle'">
  319. and PEOPLE_DATETIME &gt; to_date(#{where.peopleDateStartTime}, 'yyyy-mm-dd hh24:mi:ss')
  320. and PEOPLE_DATETIME &lt; to_date(#{where.peopleDateEndTime}, 'yyyy-mm-dd hh24:mi:ss')
  321. </if>
  322. </if>
  323. <if test="where.peopleId != null and where.peopleId !=''">
  324. and p.id=#{where.peopleId}
  325. </if>
  326. <if test="where.peopleMail != null and where.peopleMail !=''">
  327. and p.PEOPLE_MAIL=#{where.peopleMail}
  328. </if>
  329. <if test="where.peoplePhone != null and where.peoplePhone !=''">
  330. and p.PEOPLE_PHONE=#{where.peoplePhone}
  331. </if>
  332. <if test="where.companyName != null and where.companyName !=''">
  333. and e.COMPANY_NAME like CONCAT(CONCAT('%',#{where.companyName}),'%')
  334. </if>
  335. <if test="where.position != null and where.position !=''">
  336. and e.POSITION like CONCAT(CONCAT('%',#{where.position}),'%')
  337. </if>
  338. <if test="where.channel != null and where.channel !=''">
  339. and e.CHANNEL=#{where.channel}
  340. </if>
  341. <if test="where.purpose != null and where.purpose !=''">
  342. and e.PURPOSE=#{where.purpose}
  343. </if>
  344. </if>
  345. </where>
  346. order by p.PEOPLE_DATETIME desc
  347. </select>
  348. <!-- 查询用户列表结束 -->
  349. <!-- 根据应用ID查询用户总数结束 -->
  350. <!-- 根据用户名(帐号,手机,邮箱)和验证码查询用户信息开始 -->
  351. <select id="getEntityByCode" resultMap="resultMap">
  352. select
  353. <include refid="column_list" />,p.id
  354. from people p
  355. where (people_name=#{userName} or
  356. people_phone=#{userName} or
  357. people_mail=#{userName}) and
  358. people_code=#{peopleCode}
  359. </select>
  360. <select id="getPeopleById" resultMap="resultMap">
  361. select
  362. <include refid="column_list" />
  363. ,p.id,<include refid="user_column_list" />
  364. from people p left join people_user on
  365. p.id=PEOPLE_ID where p.id = #{id}
  366. </select>
  367. <!-- 根据用户名(帐号,手机,邮箱)和验证码用户信息结束 -->
  368. <!-- 批量删除用户开始 -->
  369. <delete id="delete" parameterType="java.lang.String">
  370. delete from people
  371. <where>
  372. id in
  373. <foreach collection="ids" item="item" index="index"
  374. open="(" separator="," close=")">#{item}</foreach>
  375. </where>
  376. </delete>
  377. <!-- 批量删除用户结束 -->
  378. </mapper>