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.

102 lines
3.5 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.coin.PermissionMapper">
<insert id="addPermission" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
insert into admin(admin_name, machine_id, account, password, market, postiton, remark, admin_status, role_id)
values (#{adminName}, #{machineId}, #{account}, #{password}, #{market[0]}, #{postiton}, #{remark}, 1 ,#{roleId})
</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
<set>
<if test="roleId!=null">
role_id= #{roleId},
</if>
</set>
where id= #{adminId}
</update>
<update id="updateAdmin">
update admin
<set>
<if test="adminName!=null">
admin_name= #{adminName},
</if>
<if test="machineId!=null">
machine_id= #{machineId},
</if>
<if test="postiton!=null">
postiton= #{postiton},
</if>
<if test="remark!=null">
remark= #{remark},
</if>
<if test="roleId!=null">
role_id= #{roleId},
</if>
market= #{market[0]}
</set>
where account= #{account}
</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.coin.Permission">
select admin.id as id,admin.machine_id,admin.admin_name as
name,admin.account,admin.market,admin.postiton,admin.remark,admin.admin_status as adminStatus,admin.role_id,role.role_name
from admin
LEFT JOIN role on admin.role_id=role.id
<where>
<if test="account!=null and account.length>0">
and admin.account=#{account}
</if>
<if test="market!=null and market.length>0">
and admin.market LIKE CONCAT('%', #{market}, '%')
</if>
<if test="postiton!=null and postiton.length>0">
and admin.postiton=#{postiton}
</if>
<if test="markets != null and markets.size() > 0 and '1' not in markets">
AND (
<foreach collection="markets" item="market" open="" close="" separator=" OR ">
admin.market LIKE CONCAT('%', #{market}, '%')
</foreach>
)
</if>
</where>
order by admin.admin_status desc ,admin.update_time desc
</select>
<select id="getRole" resultType="com.example.demo.domain.entity.Role">
select *
from role
</select>
</mapper>