| <?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.matrix.system.common.dao.SystemDictionaryDao"> | 
|      | 
|     <resultMap type="SystemDictionary" id="SystemDictionaryMap"> | 
|         <id property="id" column="ID" /> | 
|         <result property="name" column="NAME" /> | 
|         <result property="type" column="TYPE" /> | 
|         <result property="code" column="code" /> | 
|     </resultMap> | 
|     <!--  插入方法   --> | 
|     <insert id="insert" parameterType="SystemDictionary" | 
|         useGeneratedKeys="true" keyProperty="id"> | 
|         INSERT INTO sys_data_dictionary ( | 
|             ID, | 
|             NAME, | 
|             TYPE, | 
|             code | 
|         ) | 
|     VALUES ( | 
|             #{id}, | 
|             #{name}, | 
|             #{type}, | 
|             #{code} | 
|     ) | 
|     </insert> | 
|      | 
|      | 
|     <!--  根据id更新 部分更新   --> | 
|     <update id="update" > | 
|         UPDATE sys_data_dictionary | 
|         <set> | 
|             <if test="name != null and name !='' "> | 
|                 NAME = #{name}, | 
|             </if> | 
|             <if test="type != null and type !='' "> | 
|                 TYPE = #{type}, | 
|             </if> | 
|             <if test="code != null and code !='' "> | 
|                 code = #{code}, | 
|             </if> | 
|   | 
|         </set> | 
|         WHERE id=#{id}  | 
|     </update> | 
|      | 
|      | 
|      | 
|     <!-- 批量删除 --> | 
|     <delete id="deleteByIds" parameterType="java.util.List"> | 
|         delete from sys_data_dictionary where  ID in | 
|         <foreach collection="list" index="index" item="item" open="(" | 
|             separator="," close=")"> | 
|             #{item} | 
|         </foreach> | 
|     </delete> | 
|          | 
|     <!-- 根据id删除--> | 
|     <delete id="deleteById" > | 
|         DELETE FROM sys_data_dictionary | 
|         where  ID=#{id}  | 
|     </delete> | 
|      | 
|      | 
|      | 
|     <!-- 分页查询 --> | 
|     <select id="selectInPage" resultMap="SystemDictionaryMap"> | 
|         select  | 
|             ID, | 
|             NAME, | 
|             TYPE, | 
|         code | 
|         from sys_data_dictionary | 
|         where 1=1 | 
|         <if test="record!=null"> | 
|             <if test="record.id != null and record.id !='' "> | 
|                 and ID  = #{id} | 
|             </if> | 
|             <if test="record.name != null and record.name !='' "> | 
|                 and NAME like CONCAT('%',#{record.name},'%') | 
|             </if> | 
|             <if test="record.type != null and record.type !='' "> | 
|                 and TYPE like CONCAT('%',#{record.type},'%') | 
|             </if> | 
|   | 
|             <if test="record.code != null and record.code !='' "> | 
|                 and code like CONCAT('%',#{record.code},'%') | 
|             </if> | 
|   | 
|         </if> | 
|         <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 --> | 
|             <if test="pageVo.sort !=null  and pageVo.order !=null"> | 
|                 order by | 
|                 ${pageVo.sort} ${pageVo.order} | 
|             </if> | 
|             <if test="pageVo.offset >=0  and pageVo.limit >0"> | 
|                 limit | 
|                 #{pageVo.offset},#{pageVo.limit} | 
|             </if> | 
|         </if> | 
|     </select> | 
|      | 
|     <!-- 查询总条数 --> | 
|     <select id="selectTotalRecord"    resultType="java.lang.Integer"> | 
|     select count(*) | 
|     from sys_data_dictionary | 
|         where 1=1 | 
|         <if test="record!=null"> | 
|             <if test="record.id != null and record.id !='' "> | 
|                 and ID  = #{id} | 
|             </if> | 
|             <if test="record.name != null and record.name !='' "> | 
|                 and NAME like CONCAT('%',#{record.name},'%') | 
|             </if> | 
|             <if test="record.type != null and record.type !='' "> | 
|                 and TYPE like CONCAT('%',#{record.type},'%') | 
|             </if> | 
|   | 
|         </if> | 
|     </select> | 
|   | 
|     <!-- 根据id查询--> | 
|     <select id="selectById" resultMap="SystemDictionaryMap"> | 
|         select  | 
|             ID, | 
|             NAME, | 
|             TYPE, | 
|             code | 
|         from sys_data_dictionary | 
|         where  id=#{id}  | 
|     </select>     | 
|      | 
|      | 
|     <!-- 根据对象查询--> | 
|     <select id="selectByModel" resultMap="SystemDictionaryMap"> | 
|         select | 
|             ID, | 
|             NAME, | 
|             TYPE, | 
|             code | 
|         from sys_data_dictionary | 
|         where 1=1 | 
|         <if test="record!=null"> | 
|             <if test="record.id != null and record.id !='' "> | 
|                 and ID  = #{record.id} | 
|             </if> | 
|             <if test="record.name != null and record.name !='' "> | 
|                 and NAME like CONCAT('%',#{record.name},'%') | 
|             </if> | 
|             <if test="record.type != null and record.type !='' "> | 
|                 and TYPE like CONCAT('%',#{record.type},'%') | 
|             </if> | 
|   | 
|         </if> | 
|     </select> | 
|      | 
|     <select id="getDictionaryType" resultType="java.lang.String"> | 
|     select DISTINCT type  from sys_data_dictionary | 
|     </select> | 
|   | 
|     <select id="selectByCode" resultMap="SystemDictionaryMap"> | 
|         select * from sys_data_dictionary where code=#{code} | 
|   | 
|     </select> | 
|   | 
| </mapper> |