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
85 lines
3.8 KiB
<?xml version="1.0" encoding="UTF-8" ?>
|
|
<!DOCTYPE mapper
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.iteaj.iboot.msn.core.mapper.IAdminDao">
|
|
|
|
<resultMap type="com.iteaj.iboot.msn.core.entity.Admin" id="OriMap">
|
|
<id property="id" column="id" />
|
|
<result property="sex" column="sex" />
|
|
<!-- <result property="sort" column="sort" />-->
|
|
<result property="email" column="email" />
|
|
<result property="phone" column="phone" />
|
|
<result property="name" column="name" />
|
|
<result property="avatar" column="avatar" />
|
|
<result property="status" column="status" />
|
|
<result property="remark" column="remark" />
|
|
<result property="orgId" column="org_id" />
|
|
<result property="account" column="account" />
|
|
<result property="loginIp" column="login_ip" />
|
|
<result property="loginDate" column="login_date" />
|
|
<result property="createTime" column="create_time" />
|
|
<result property="updateTime" column="update_time" />
|
|
</resultMap>
|
|
<resultMap id="JoinAdminRoleMap" type="com.iteaj.iboot.msn.core.dto.AdminDto" extends="OriMap">
|
|
<collection property="roleIds" ofType="long">
|
|
<result property="roleIds" column="rid" />
|
|
</collection>
|
|
</resultMap>
|
|
<insert id="createAdmin">
|
|
insert into sys_admin (name, org_id, account, email, phone, sex, avatar, password, status, login_ip,login_date, remark, create_time) value
|
|
(#{name},#{orgId},#{account},#{email},#{phone},#{sex},#{avatar},#{password},#{status},#{loginIp},#{loginDate},#{remark}, now());
|
|
set @lastId=LAST_INSERT_ID();
|
|
<if test="roleIds != null">
|
|
insert into sys_admin_role (aid, rid) values
|
|
<foreach collection="roleIds" item="item" separator=",">
|
|
(@lastId, #{item})
|
|
</foreach>
|
|
</if>
|
|
</insert>
|
|
<update id="updateAdminRole">
|
|
delete from sys_admin_role where aid=#{id};
|
|
<if test="roleIds != null and roleIds.size() > 0">
|
|
insert into sys_admin_role (aid, rid) values
|
|
<foreach collection="roleIds" item="item" separator=",">
|
|
(#{id}, #{item})
|
|
</foreach>
|
|
</if>
|
|
</update>
|
|
<update id="updatePwdById">
|
|
update sys_admin set password=#{password}, update_time=now() where id=#{id}
|
|
</update>
|
|
<delete id="deleteAllJoinByIds">
|
|
delete from sys_admin where id in (
|
|
<foreach collection="list" item="item" separator=",">
|
|
#{item}
|
|
</foreach>);
|
|
delete from sys_admin_role where aid in (
|
|
<foreach collection="list" item="item" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
);
|
|
</delete>
|
|
<select id="getAdminDetailById" resultMap="JoinAdminRoleMap">
|
|
select a.*, ar.aid aid, ar.rid rid from sys_admin a
|
|
left join sys_admin_role ar on a.id = ar.aid
|
|
where a.id=#{id}
|
|
</select>
|
|
<!--查询指定用户下拥有的权限-->
|
|
<select id="selectPermsById" resultType="java.lang.String">
|
|
select m.perms from sys_role_menu a
|
|
left join sys_menu m on a.mid = m.id
|
|
left join sys_admin_role ar on a.rid=ar.rid
|
|
where ar.aid=#{id}
|
|
</select>
|
|
<select id="getAdminCenter" resultType="com.iteaj.iboot.msn.core.dto.AdminDto">
|
|
select a.*, o.name deptName, group_concat(r.name) roleNames from sys_admin a
|
|
left join sys_admin_role ar on a.id = ar.aid
|
|
left join sys_role r on r.id=ar.rid
|
|
left join sys_org o on o.id=a.org_id
|
|
where a.id=#{id} group by a.id
|
|
</select>
|
|
<select id="getAdminPassword" resultType="java.lang.String">
|
|
select password from sys_admin where id=#{id}
|
|
</select>
|
|
</mapper>
|