| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?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.tld.mapper.DepartmentMapper">
- <sql id="field">
- id,code,name,create_time
- </sql>
- <!-- 查询部门 -->
- <select id="getDepartment" resultType="com.tld.model.Department">
- select
- <include refid="field"/>
- from tld_department
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="code != null and code != ''">
- and code like CONCAT(CONCAT('%', #{code}), '%')
- </if>
- <if test="name != null and name != ''">
- and name like CONCAT(CONCAT('%', #{name}), '%')
- </if>
- <if test="id != null and id != ''">
- and id = #{id}
- </if>
- </trim>
- </select>
- <!-- 新增部门 -->
- <insert id="addDepartment">
- <selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
- select LAST_INSERT_ID()
- </selectKey>
- insert into tld_department(name,create_time) values(#{name},DATE_FORMAT(NOW(), '%Y-%m-%d'))
- </insert>
- <!-- 修改部门 -->
- <update id="updateDepartment">
- update tld_department
- <set>
- <trim suffixOverrides=",">
- <if test="code != null">
- code = #{code},
- </if>
- <if test="name != null">
- name = #{name},
- </if>
- </trim>
- </set>
- where id = #{id}
- </update>
- <!-- 删除角色 -->
- <delete id="delDepartment">
- delete from tld_department where id = #{id}
- </delete>
- <!-- 查询导出内容 -->
- <select id="export" resultType="java.util.LinkedHashMap">
- select
- code,name,create_time
- from tld_department
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="code != null and code != ''">
- and code = #{code}
- </if>
- <if test="name != null and name != ''">
- and name like CONCAT(CONCAT('%', #{name}), '%')
- </if>
- </trim>
- </select>
- </mapper>
|