account.sql.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  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="accountSqlMapper">
  5. <!--mybatis ehcache缓存配置 -->
  6. <!-- 以下两个<cache>标签二选一,第一个可以输出日志,第二个不输出日志 <cache type="org.mybatis.caches.ehcache.LoggingEhcache"
  7. /> -->
  8. <!-- <cache type="org.mybatis.caches.ehcache.EhcacheCache"/> -->
  9. <!-- 以下与实体类的中字段一致 -->
  10. <sql id="selectId">
  11. id,
  12. name as accountName,
  13. (select group_concat(name) from t_ly_role
  14. where t_ly_role.id
  15. in (SELECT role_id FROM t_acc_role WHERE
  16. acc_id=t_account.id) ) roleName,
  17. password,
  18. description,
  19. state,
  20. create_time as createTime,
  21. real_name as realName,
  22. tel,
  23. type,
  24. operator_id as operatorId,
  25. agent_id as agentId,
  26. advertiser_id as advertiserId,
  27. sys_type as sysType
  28. </sql>
  29. <!--resultType="Account" 每返回一条结果封装到Account里 -->
  30. <select id="queryAll" resultType="com.cloudcross.ssp.model.Account" parameterType="com.cloudcross.ssp.model.Account">
  31. select
  32. <include refid="selectId" />
  33. from t_account
  34. <where>
  35. <if test="accountName != null and accountName != ''">
  36. name like '%${accountName}%'
  37. </if>
  38. </where>
  39. </select>
  40. <select id="selectByParams" parameterType="map" resultType="com.cloudcross.ssp.model.Account">
  41. select id,
  42. name as accountName,
  43. real_name as realName,tel,state,create_time as createTime
  44. from t_account
  45. where deletestatus != -1
  46. and operator_id = 0
  47. and agent_id = 0
  48. and advertiser_id = 0
  49. <if test="value!=null">
  50. and ( t_account.name like #{value}
  51. or t_account.real_name like #{value} )
  52. </if>
  53. and id != #{loginAccount.id}
  54. and sys_type = #{loginAccount.sysType}
  55. order by id desc
  56. limit #{pager.offset}, #{pager.limit}
  57. </select>
  58. <select id="selectByParamsOperator" parameterType="map" resultType="com.cloudcross.ssp.model.Account">
  59. select id,
  60. name as accountName,
  61. real_name as realName,tel,state,create_time as createTime
  62. from t_account
  63. where deletestatus != -1
  64. and operator_id = #{loginAccount.operatorId}
  65. and id != #{loginAccount.id}
  66. <if test="value!=null">
  67. and ( t_account.name like #{value}
  68. or t_account.real_name like #{value} )
  69. </if>
  70. and sys_type = #{loginAccount.sysType}
  71. order by id desc
  72. limit #{pager.offset}, #{pager.limit}
  73. </select>
  74. <select id="selectByParamsAdvertiser" parameterType="map" resultType="com.cloudcross.ssp.model.Account">
  75. select id,
  76. name as accountName,
  77. real_name as realName,tel,state,create_time as createTime
  78. from t_account
  79. where deletestatus != -1
  80. and agent_id = #{loginAccount.agentId}
  81. <if test="value!=null">
  82. and ( t_account.name like #{value}
  83. or t_account.real_name like #{value} )
  84. </if>
  85. and id != #{loginAccount.id}
  86. and sys_type = #{loginAccount.sysType}
  87. <if test="loginAccount.advertiserId != 0 ">
  88. and advertiser_id = #{loginAccount.advertiserId}
  89. </if>
  90. order by id desc
  91. limit #{pager.offset}, #{pager.limit}
  92. </select>
  93. <select id="countByParams" parameterType="map" resultType="int">
  94. select count(id)
  95. from t_account
  96. where deletestatus != -1
  97. and operator_id = 0
  98. and agent_id = 0
  99. and advertiser_id = 0
  100. <if test="value!=null">
  101. and ( t_account.name like #{value}
  102. or t_account.real_name like #{value} )
  103. </if>
  104. and id != #{loginAccount.id}
  105. and sys_type = #{loginAccount.sysType}
  106. </select>
  107. <select id="countByParamsOperator" parameterType="map" resultType="int">
  108. select count(id)
  109. from t_account
  110. where deletestatus != -1
  111. and operator_id = #{loginAccount.operatorId}
  112. <if test="value!=null">
  113. and ( t_account.name like #{value}
  114. or t_account.real_name like #{value} )
  115. </if>
  116. and id != #{loginAccount.id}
  117. and sys_type = #{loginAccount.sysType}
  118. </select>
  119. <select id="countByParamsAdvertiser" parameterType="map" resultType="int">
  120. select count(id)
  121. from t_account
  122. where deletestatus != -1
  123. and agent_id = #{loginAccount.agentId}
  124. <if test="value!=null">
  125. and ( t_account.name like #{value}
  126. or t_account.real_name like #{value} )
  127. </if>
  128. and id != #{loginAccount.id}
  129. and sys_type = #{loginAccount.sysType}
  130. <if test="loginAccount.advertiserId != 0 ">
  131. and advertiser_id = #{loginAccount.advertiserId}
  132. </if>
  133. </select>
  134. <select id="isExist" resultType="com.cloudcross.ssp.model.Account" parameterType="String">
  135. select
  136. <include refid="selectId" />
  137. from t_account
  138. where name = #{accountName}
  139. </select>
  140. <!--resultType="Account" 每返回一条结果封装到Account里 -->
  141. <select id="query" resultType="com.cloudcross.ssp.model.Account" parameterType="java.util.HashMap">
  142. select
  143. <include refid="selectId" />
  144. from t_account
  145. <where>
  146. <if test="t.accountName != null and t.accountName != ''">
  147. name like '%${t.accountName}%'
  148. </if>
  149. </where>
  150. </select>
  151. <select id="queryNoMatch" resultType="com.cloudcross.ssp.model.Account" parameterType="java.util.HashMap">
  152. select
  153. a.id,
  154. a.name,
  155. a.password,
  156. a.accountType,
  157. a.description,
  158. a.state,
  159. a.createTime,
  160. (SELECT dp.name from department dp where dp.id =
  161. d.subdep_id) depName
  162. from account a LEFT JOIN dep_account d on
  163. a.id=d.account_id
  164. <where>
  165. <if test="t.accountName != null and t.accountName != ''">
  166. name like '%${t.accountName}%'
  167. </if>
  168. </where>
  169. </select>
  170. <!-- 增加用户 -->
  171. <insert id="add" parameterType="com.cloudcross.ssp.model.Account">
  172. insert into t_account (
  173. name,
  174. password,
  175. description,
  176. state )
  177. values (#{accountName},
  178. #{password}, #{description},
  179. #{state})
  180. </insert>
  181. <!-- 增加用户 -->
  182. <insert id="addAccount" parameterType="com.cloudcross.ssp.model.Account" useGeneratedKeys="true" keyProperty="id">
  183. insert into t_account
  184. (name,
  185. password,
  186. real_name,
  187. tel,
  188. description,
  189. state,
  190. sys_type,
  191. type) values (#{accountName}, #{password},#{realName},
  192. #{tel},#{description},#{state},#{sysType},#{type})
  193. </insert>
  194. <!-- 增加用户 -->
  195. <insert id="addAccountOperator" parameterType="com.cloudcross.ssp.model.Account">
  196. insert into t_account
  197. (name,
  198. password,
  199. real_name,
  200. tel,
  201. operator_id,
  202. description,
  203. state,
  204. sys_type ) values (#{accountName}, #{password},#{realName},
  205. #{tel},#{operatorId},#{description},#{state},#{sysType})
  206. </insert>
  207. <!-- 增加用户 -->
  208. <insert id="addAccountAdvertiser" parameterType="com.cloudcross.ssp.model.Account" useGeneratedKeys="true" keyProperty="id">
  209. insert into t_account
  210. (name,
  211. password,
  212. real_name,
  213. tel,
  214. agent_id,
  215. advertiser_id,
  216. operator_id,
  217. description,
  218. state,
  219. sys_type ) values (#{accountName}, #{password},#{realName},
  220. #{tel},#{agentId},#{advertiserId},#{operatorId},#{description},#{state},#{sysType})
  221. </insert>
  222. <delete id="delete" parameterType="String">
  223. delete from t_account where
  224. id=#{id}
  225. </delete>
  226. <select id="getById" parameterType="String" resultType="com.cloudcross.ssp.model.Account">
  227. select
  228. id,
  229. name as accountName,
  230. (select group_concat(name) from t_ly_role
  231. where t_ly_role.id
  232. in (SELECT role_id FROM t_acc_role WHERE
  233. acc_id=t_account.id) ) roleName,
  234. password,
  235. real_name as realName,
  236. tel,
  237. description,
  238. state,
  239. create_time as createTime,
  240. type,
  241. operator_id as operatorId,
  242. agent_id as agentId,
  243. advertiser_id as advertiserId,
  244. sys_type as sysType
  245. from t_account where id=#{id}
  246. </select>
  247. <update id="updateAccountStatus" parameterType="HashMap">
  248. update t_account
  249. set state=#{state}
  250. where t_account.id in
  251. <foreach item="accountId" collection="accountIdList"
  252. open="(" separator="," close=")">
  253. #{accountId}
  254. </foreach>
  255. </update>
  256. <update id="editAccount" parameterType="com.cloudcross.ssp.model.Account">
  257. update t_account
  258. <set>
  259. <if test="accountName != null and accountName != ''">
  260. name=#{accountName},
  261. </if>
  262. <if test="password != null and password != ''">
  263. password=#{password},
  264. </if>
  265. <if test="description != null and description != ''">
  266. description=#{description},
  267. </if>
  268. <if test="state != null and state != ''">
  269. state=#{state},
  270. </if>
  271. <if test="createTime != null and createTime != ''">
  272. create_time=#{createTime},
  273. </if>
  274. <if test="realName != null and realName != ''">
  275. real_name=#{realName},
  276. </if>
  277. <if test="tel != null and tel != ''">
  278. tel=#{tel},
  279. </if>
  280. <if test="operatorId != null and operatorId != 0">
  281. operator_id=#{operatorId},
  282. </if>
  283. <if test="agentId != null and agentId !=0">
  284. agent_id=#{agentId},
  285. </if>
  286. <if test="advertiserId != null and advertiserId !=0">
  287. advertiser_id=#{advertiserId},
  288. </if>
  289. </set>
  290. where id=#{id}
  291. </update>
  292. <update id="editAccountOperator" parameterType="com.cloudcross.ssp.model.Account">
  293. update t_account
  294. <set>
  295. <if test="accountName != null and accountName != ''">
  296. name=#{accountName},
  297. </if>
  298. <if test="password != null and password != ''">
  299. password=#{password},
  300. </if>
  301. <if test="description != null and description != ''">
  302. description=#{description},
  303. </if>
  304. <if test="state != null and state != ''">
  305. state=#{state},
  306. </if>
  307. <if test="createTime != null and createTime != ''">
  308. createTime=#{createTime},
  309. </if>
  310. <if test="realName != null and realName != ''">
  311. real_name=#{realName},
  312. </if>
  313. <if test="tel != null and tel != ''">
  314. tel=#{tel}
  315. </if>
  316. </set>
  317. where id=#{id}
  318. </update>
  319. <update id="editAccountAdvertiser" parameterType="com.cloudcross.ssp.model.Account">
  320. update t_account
  321. <set>
  322. <if test="accountName != null and accountName != ''">
  323. name=#{accountName},
  324. </if>
  325. <if test="password != null and password != ''">
  326. password=#{password},
  327. </if>
  328. <if test="description != null and description != ''">
  329. description=#{description},
  330. </if>
  331. <if test="state != null and state != ''">
  332. state=#{state},
  333. </if>
  334. <if test="createTime != null and createTime != ''">
  335. createTime=#{createTime},
  336. </if>
  337. <if test="realName != null and realName != ''">
  338. real_name=#{realName},
  339. </if>
  340. <if test="tel != null and tel != ''">
  341. tel=#{tel},
  342. </if>
  343. <if test="advertiserId != null">
  344. advertiser_id=#{advertiserId}
  345. </if>
  346. </set>
  347. where id=#{id}
  348. </update>
  349. <update id="update" parameterType="com.cloudcross.ssp.model.Account">
  350. update t_account
  351. <set>
  352. <if test="accountName != null and accountName != ''">
  353. name=#{accountName},
  354. </if>
  355. <if test="password != null and password != ''">
  356. password=#{password},
  357. </if>
  358. <if test="description != null and description != ''">
  359. description=#{description},
  360. </if>
  361. <if test="state != null and state != ''">
  362. state=#{state},
  363. </if>
  364. <if test="createTime != null and createTime != ''">
  365. create_time=#{createTime},
  366. </if>
  367. <if test="realName != null and realName != ''">
  368. real_name=#{realName},
  369. </if>
  370. <if test="tel != null and tel != ''">
  371. tel=#{tel}
  372. </if>
  373. </set>
  374. where id=#{id}
  375. </update>
  376. <!-- 验证用户登陆 -->
  377. <select id="countAccount" parameterType="com.cloudcross.ssp.model.Account" resultType="com.cloudcross.ssp.model.Account">
  378. select
  379. <include refid="selectId" />
  380. from t_account where
  381. name=#{accountName} and password=#{password}
  382. </select>
  383. <!-- 根据用户名查出id -->
  384. <select id="querySingleAccount" parameterType="String"
  385. resultType="com.cloudcross.ssp.model.Account">
  386. select
  387. <include refid="selectId" />
  388. from t_account where name=#{accountName}
  389. </select>
  390. <select id="findExcelAccount" parameterType="map" resultType="com.cloudcross.ssp.model.Account">
  391. select id,
  392. name as accountName,
  393. real_name as realName,tel,state,create_time as createTime
  394. from t_account
  395. where deletestatus != -1
  396. and operator_id = 0
  397. and agent_id = 0
  398. and advertiser_id = 0
  399. <if test="value!=null">
  400. and ( t_account.name like #{value}
  401. or t_account.real_name like #{value} )
  402. </if>
  403. and id != #{loginAccount.id}
  404. and sys_type = #{loginAccount.sysType}
  405. order by id desc
  406. </select>
  407. <select id="findExcelAccountsOperator" parameterType="map" resultType="com.cloudcross.ssp.model.Account">
  408. select id,
  409. name as accountName,
  410. real_name as realName,tel,state,create_time as createTime
  411. from t_account
  412. where deletestatus != -1
  413. and operator_id = #{loginAccount.operatorId}
  414. and id != #{loginAccount.id}
  415. <if test="value!=null">
  416. and ( t_account.name like #{value}
  417. or t_account.real_name like #{value} )
  418. </if>
  419. and sys_type = #{loginAccount.sysType}
  420. order by id desc
  421. </select>
  422. <select id="findExcelAccountsAdvertiser" parameterType="map" resultType="com.cloudcross.ssp.model.Account">
  423. select id,
  424. name as accountName,
  425. real_name as realName,tel,state,create_time as createTime
  426. from t_account
  427. where deletestatus != -1
  428. and agent_id = #{loginAccount.agentId}
  429. and id != #{loginAccount.id}
  430. <if test="value!=null">
  431. and ( t_account.name like #{value}
  432. or t_account.real_name like #{value} )
  433. </if>
  434. and sys_type = #{loginAccount.sysType}
  435. <if test="loginAccount.advertiserId != 0 ">
  436. and advertiser_id = #{loginAccount.advertiserId}
  437. </if>
  438. order by id desc
  439. </select>
  440. </mapper>