Files
student-Management-system/sms-auth/sms-auth-infra/src/main/resources/mapper/PermissionDao.xml
2024-03-05 18:04:58 +08:00

223 lines
9.0 KiB
XML

<?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.landaiqing.infra.basic.dao.PermissionDao">
<resultMap type="com.landaiqing.infra.basic.entity.Permission" id="PermissionMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="parentId" column="parent_id" jdbcType="INTEGER"/>
<result property="type" column="type" jdbcType="INTEGER"/>
<result property="menuUrl" column="menu_url" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="INTEGER"/>
<result property="show" column="show" jdbcType="INTEGER"/>
<result property="icon" column="icon" jdbcType="VARCHAR"/>
<result property="permissionKey" column="permission_key" jdbcType="VARCHAR"/>
<result property="createdBy" column="created_by" jdbcType="VARCHAR"/>
<result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="isDeleted" column="is_deleted" jdbcType="INTEGER"/>
</resultMap>
<!--查询单个-->
<select id="queryById" resultMap="PermissionMap">
select id,name,parent_id,`type`,menu_url,status,`show`,icon,permission_key,created_by,created_time,update_by,update_time,is_deleted
from permission
where id = #{id}
</select>
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="PermissionMap">
select id,name,parent_id,`type`,menu_url,status,`show`,icon,permission_key,created_by,created_time,update_by,update_time,is_deleted
from permission
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="name != null and name != ''">
and name = #{name}
</if>
<if test="parentId != null">
and parent_id = #{parentId}
</if>
<if test="type != null">
and `type` = #{type}
</if>
<if test="menuUrl != null and menuUrl != ''">
and menu_url = #{menuUrl}
</if>
<if test="status != null">
and `status` = #{status}
</if>
<if test="show != null">
and `show` = #{show}
</if>
<if test="icon != null and icon != ''">
and icon = #{icon}
</if>
<if test="permissionKey != null and permissionKey != ''">
and permission_key = #{permissionKey}
</if>
<if test="createdBy != null and createdBy != ''">
and created_by = #{createdBy}
</if>
<if test="createdTime != null">
and created_time = #{createdTime}
</if>
<if test="updateBy != null and updateBy != ''">
and update_by = #{updateBy}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="isDeleted != null">
and is_deleted = #{isDeleted}
</if>
</where>
limit #{pageable.offset}, #{pageable.pageSize}
</select>
<!--统计总行数-->
<select id="count" resultType="java.lang.Long">
select count(1)
from permission
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="name != null and name != ''">
and name = #{name}
</if>
<if test="parentId != null">
and parent_id = #{parentId}
</if>
<if test="type != null">
and `type` = #{type}
</if>
<if test="menuUrl != null and menuUrl != ''">
and menu_url = #{menuUrl}
</if>
<if test="status != null">
and `status` = #{status}
</if>
<if test="show != null">
and `show` = #{show}
</if>
<if test="icon != null and icon != ''">
and icon = #{icon}
</if>
<if test="permissionKey != null and permissionKey != ''">
and permission_key = #{permissionKey}
</if>
<if test="createdBy != null and createdBy != ''">
and created_by = #{createdBy}
</if>
<if test="createdTime != null">
and created_time = #{createdTime}
</if>
<if test="updateBy != null and updateBy != ''">
and update_by = #{updateBy}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="isDeleted != null">
and is_deleted = #{isDeleted}
</if>
</where>
</select>
<select id="queryPermission" resultMap="PermissionMap">
select *
from permission
where id in
<foreach open="(" close=")" collection="list" item="id" separator=",">
#{id}
</foreach>
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into permission(name,parent_id,`type`,menu_url,status,`show`,icon,permission_key,created_by,created_time,update_by,update_time,is_deleted)
values (#{name},#{parentId},#{type},#{menuUrl},#{status},#{show},#{icon},#{permissionKey},#{createdBy},#{createdTime},#{updateBy},#{updateTime},#{isDeleted})
</insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into
permission(name,parent_id,`type`,menu_url,status,`show`,icon,permission_key,created_by,created_time,update_by,update_time,is_deleted)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.name},#{entity.parentId},#{entity.type},#{entity.menuUrl},#{entity.status},#{entity.show},#{entity.icon},#{entity.permissionKey},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted})
</foreach>
</insert>
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
insert into
permission(name,parent_id,`type`,menu_url,status,`show`,icon,permission_key,created_by,created_time,update_by,update_time,is_deleted)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.name},#{entity.parentId},#{entity.type},#{entity.menuUrl},#{entity.status},#{entity.show},#{entity.icon},#{entity.permissionKey},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted})
</foreach>
on duplicate key update
name = values(name)parent_id = values(parent_id)type = values(type)menu_url = values(menu_url)status =
values(status)show = values(show)icon = values(icon)permission_key = values(permission_key)created_by =
values(created_by)created_time = values(created_time)update_by = values(update_by)update_time =
values(update_time)is_deleted = values(is_deleted)
</insert>
<!--通过主键修改数据-->
<update id="update">
update permission
<set>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="parentId != null">
parent_id = #{parentId},
</if>
<if test="type != null">
`type` = #{type},
</if>
<if test="menuUrl != null and menuUrl != ''">
menu_url = #{menuUrl},
</if>
<if test="status != null">
status = #{status},
</if>
<if test="show != null">
show = #{show},
</if>
<if test="icon != null and icon != ''">
icon = #{icon},
</if>
<if test="permissionKey != null and permissionKey != ''">
permission_key = #{permissionKey},
</if>
<if test="createdBy != null and createdBy != ''">
created_by = #{createdBy},
</if>
<if test="createdTime != null">
created_time = #{createdTime},
</if>
<if test="updateBy != null and updateBy != ''">
update_by = #{updateBy},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
<if test="isDeleted != null">
is_deleted = #{isDeleted},
</if>
</set>
where id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete
from permission
where id = #{id}
</delete>
</mapper>