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.

65 lines
2.4 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.example.demo.mapper.PermissionMapper">
<insert id="addPermission" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
insert into admin(admin_name,machine_id,account,password,market,postiton,remark,admin_status)
values(#{adminName},#{machineId},#{account},#{password},#{market},#{postiton},#{remark},1)
</insert>
<insert id="addadminRole">
insert into admin_role(admin_id,role_id)
values(#{adminId},#{roleId})
</insert>
<update id="updatePermission">
update admin
<set>
<if test="adminStatus!=null">
admin_status= #{adminStatus},
</if>
</set>
where id=#{id}
</update>
<update id="updateAdminRole">
update admin_role
<set>
<if test="roleId!=null">
role_id= #{roleId},
</if>
</set>
where admin_id= #{id}
</update>
<delete id="deleteAdmin">
delete from admin where id=#{id}
</delete>
<delete id="deleteAdminRole">
delete from admin_role where admin_id= #{id}
</delete>
<select id="getposition" resultType="java.lang.String">
select distinct postiton from admin
</select>
<select id="getmarket" resultType="java.lang.String">
select distinct market from admin
</select>
<select id="getPermission" resultType="com.example.demo.domain.vo.Permission">
select admin.id as id,admin.admin_name as name,admin.account,admin.market,admin.postiton,admin.remark,admin.admin_status as adminStatus,role.role_name as roleName,role.id as roleId
from admin
left join admin_role on admin.id=admin_role.admin_id
left join role on admin_role.role_id=role.id
<where>
<if test="account!=null and account.length>0">
admin.account=#{account}
</if>
<if test="market!=null and market.length>0">
admin.market=#{market}
</if>
<if test="postiton!=null and postiton.length>0">
admin.postiton=#{postiton}
</if>
</where>
order by admin.admin_status desc
</select>
<select id="getRole" resultType="com.example.demo.domain.entity.Role">
select * from role
</select>
</mapper>