You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
3.8 KiB

3 years ago
  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.iteaj.iboot.msn.core.mapper.IAdminDao">
  6. <resultMap type="com.iteaj.iboot.msn.core.entity.Admin" id="OriMap">
  7. <id property="id" column="id" />
  8. <result property="sex" column="sex" />
  9. <!-- <result property="sort" column="sort" />-->
  10. <result property="email" column="email" />
  11. <result property="phone" column="phone" />
  12. <result property="name" column="name" />
  13. <result property="avatar" column="avatar" />
  14. <result property="status" column="status" />
  15. <result property="remark" column="remark" />
  16. <result property="orgId" column="org_id" />
  17. <result property="account" column="account" />
  18. <result property="loginIp" column="login_ip" />
  19. <result property="loginDate" column="login_date" />
  20. <result property="createTime" column="create_time" />
  21. <result property="updateTime" column="update_time" />
  22. </resultMap>
  23. <resultMap id="JoinAdminRoleMap" type="com.iteaj.iboot.msn.core.dto.AdminDto" extends="OriMap">
  24. <collection property="roleIds" ofType="long">
  25. <result property="roleIds" column="rid" />
  26. </collection>
  27. </resultMap>
  28. <insert id="createAdmin">
  29. insert into sys_admin (name, org_id, account, email, phone, sex, avatar, password, status, login_ip,login_date, remark, create_time) value
  30. (#{name},#{orgId},#{account},#{email},#{phone},#{sex},#{avatar},#{password},#{status},#{loginIp},#{loginDate},#{remark}, now());
  31. set @lastId=LAST_INSERT_ID();
  32. <if test="roleIds != null">
  33. insert into sys_admin_role (aid, rid) values
  34. <foreach collection="roleIds" item="item" separator=",">
  35. (@lastId, #{item})
  36. </foreach>
  37. </if>
  38. </insert>
  39. <update id="updateAdminRole">
  40. delete from sys_admin_role where aid=#{id};
  41. <if test="roleIds != null and roleIds.size() > 0">
  42. insert into sys_admin_role (aid, rid) values
  43. <foreach collection="roleIds" item="item" separator=",">
  44. (#{id}, #{item})
  45. </foreach>
  46. </if>
  47. </update>
  48. <update id="updatePwdById">
  49. update sys_admin set password=#{password}, update_time=now() where id=#{id}
  50. </update>
  51. <delete id="deleteAllJoinByIds">
  52. delete from sys_admin where id in (
  53. <foreach collection="list" item="item" separator=",">
  54. #{item}
  55. </foreach>);
  56. delete from sys_admin_role where aid in (
  57. <foreach collection="list" item="item" separator=",">
  58. #{item}
  59. </foreach>
  60. );
  61. </delete>
  62. <select id="getAdminDetailById" resultMap="JoinAdminRoleMap">
  63. select a.*, ar.aid aid, ar.rid rid from sys_admin a
  64. left join sys_admin_role ar on a.id = ar.aid
  65. where a.id=#{id}
  66. </select>
  67. <!--查询指定用户下拥有的权限-->
  68. <select id="selectPermsById" resultType="java.lang.String">
  69. select m.perms from sys_role_menu a
  70. left join sys_menu m on a.mid = m.id
  71. left join sys_admin_role ar on a.rid=ar.rid
  72. where ar.aid=#{id}
  73. </select>
  74. <select id="getAdminCenter" resultType="com.iteaj.iboot.msn.core.dto.AdminDto">
  75. select a.*, o.name deptName, group_concat(r.name) roleNames from sys_admin a
  76. left join sys_admin_role ar on a.id = ar.aid
  77. left join sys_role r on r.id=ar.rid
  78. left join sys_org o on o.id=a.org_id
  79. where a.id=#{id} group by a.id
  80. </select>
  81. <select id="getAdminPassword" resultType="java.lang.String">
  82. select password from sys_admin where id=#{id}
  83. </select>
  84. </mapper>