smallhouduan/resources/mapper/system/DepartmentsMapper.xml

66 lines
2.6 KiB
XML
Raw Permalink Normal View History

2024-12-01 15:23:17 +00:00
<?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.ruoyi.system.mapper.DepartmentsMapper">
<resultMap type="Departments" id="DepartmentsResult">
<result property="id" column="id" />
<result property="department" column="department" />
<result property="number" column="number" />
<result property="picture" column="picture" />
</resultMap>
<sql id="selectDepartmentsVo">
select id, department, number, picture from departments
</sql>
<select id="selectDepartmentsList" parameterType="Departments" resultMap="DepartmentsResult">
<include refid="selectDepartmentsVo"/>
<where>
<if test="department != null and department != ''"> and department = #{department}</if>
<if test="number != null and number != ''"> and number = #{number}</if>
<if test="picture != null and picture != ''"> and picture = #{picture}</if>
</where>
</select>
<select id="selectDepartmentsById" parameterType="Long" resultMap="DepartmentsResult">
<include refid="selectDepartmentsVo"/>
where id = #{id}
</select>
<insert id="insertDepartments" parameterType="Departments" useGeneratedKeys="true" keyProperty="id">
insert into departments
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="department != null">department,</if>
<if test="number != null">number,</if>
<if test="picture != null">picture,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="department != null">#{department},</if>
<if test="number != null">#{number},</if>
<if test="picture != null">#{picture},</if>
</trim>
</insert>
<update id="updateDepartments" parameterType="Departments">
update departments
<trim prefix="SET" suffixOverrides=",">
<if test="department != null">department = #{department},</if>
<if test="number != null">number = #{number},</if>
<if test="picture != null">picture = #{picture},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDepartmentsById" parameterType="Long">
delete from departments where id = #{id}
</delete>
<delete id="deleteDepartmentsByIds" parameterType="String">
delete from departments where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>