|
@@ -0,0 +1,154 @@
|
|
|
+<?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.nngkxxdp.program.dao.SRepairDao">
|
|
|
+
|
|
|
+ <resultMap type="com.example.nngkxxdp.program.entity.SDict" id="SDictMap">
|
|
|
+ <result property="id" column="id" jdbcType="INTEGER"/>
|
|
|
+ <result property="type" column="type" jdbcType="VARCHAR"/>
|
|
|
+ <result property="typeName" column="type_name" jdbcType="VARCHAR"/>
|
|
|
+ <result property="code" column="code" jdbcType="VARCHAR"/>
|
|
|
+ <result property="codeValue" column="code_value" jdbcType="VARCHAR"/>
|
|
|
+ <result property="status" column="status" jdbcType="INTEGER"/>
|
|
|
+
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <!--查询单个-->
|
|
|
+ <select id="queryById" resultMap="SDictMap">
|
|
|
+ select
|
|
|
+ id, type, type_name, code, code_value, status
|
|
|
+ from s_dict
|
|
|
+ where id = #{id}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!--查询指定行数据-->
|
|
|
+ <select id="queryAllByLimit" resultMap="SDictMap">
|
|
|
+ select
|
|
|
+ id, type, type_name, code, code_value, status
|
|
|
+ from s_dict
|
|
|
+ <where>
|
|
|
+ <if test="id != null">
|
|
|
+ and id = #{id}
|
|
|
+ </if>
|
|
|
+ <if test="type != null and type != ''">
|
|
|
+ and type = #{type}
|
|
|
+ </if>
|
|
|
+ <if test="typeName != null and typeName != ''">
|
|
|
+ and type_name = #{typeName}
|
|
|
+ </if>
|
|
|
+ <if test="code != null and code != ''">
|
|
|
+ and code = #{code}
|
|
|
+ </if>
|
|
|
+ <if test="codeValue != null and codeValue != ''">
|
|
|
+ and code_value = #{codeValue}
|
|
|
+ </if>
|
|
|
+ <if test="status != null">
|
|
|
+ and status = #{status}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ limit #{pageable.offset}, #{pageable.pageSize}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!--统计总行数-->
|
|
|
+ <select id="count" resultType="java.lang.Long">
|
|
|
+ select count(1)
|
|
|
+ from s_dict
|
|
|
+ <where>
|
|
|
+ <if test="id != null">
|
|
|
+ and id = #{id}
|
|
|
+ </if>
|
|
|
+ <if test="type != null and type != ''">
|
|
|
+ and type = #{type}
|
|
|
+ </if>
|
|
|
+ <if test="typeName != null and typeName != ''">
|
|
|
+ and type_name = #{typeName}
|
|
|
+ </if>
|
|
|
+ <if test="code != null and code != ''">
|
|
|
+ and code = #{code}
|
|
|
+ </if>
|
|
|
+ <if test="codeValue != null and codeValue != ''">
|
|
|
+ and code_value = #{codeValue}
|
|
|
+ </if>
|
|
|
+ <if test="status != null">
|
|
|
+ and status = #{status}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!--新增所有列-->
|
|
|
+ <insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
|
|
+ INSERT INTO s_dict(type, type_name, code, code_value, status)
|
|
|
+ VALUES (#{type}, #{typeName}, #{code}, #{codeValue}, #{status})
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
|
|
+ INSERT INTO s_dict(type, type_name, code, code_value, status)
|
|
|
+ values
|
|
|
+ <foreach collection="entities" item="entity" separator=",">
|
|
|
+ (#{type}, #{typeName}, #{code}, #{codeValue}, #{status})
|
|
|
+ </foreach>
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
|
|
+ INSERT INTO s_dict(type, type_name, code, code_value, status)
|
|
|
+ values
|
|
|
+ <foreach collection="entities" item="entity" separator=",">
|
|
|
+ (#{type}, #{typeName}, #{code}, #{codeValue}, #{status})
|
|
|
+ </foreach>
|
|
|
+ on duplicate key update
|
|
|
+ type = values(type),
|
|
|
+ type_name = values(type_name),
|
|
|
+ code = values(code),
|
|
|
+ code_value = values(code_value),
|
|
|
+ status = values(status)
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <!--通过主键修改数据-->
|
|
|
+ <update id="update">
|
|
|
+ update s_dict
|
|
|
+ <set>
|
|
|
+ <if test="type != null and type != ''">
|
|
|
+ type = #{type},
|
|
|
+ </if>
|
|
|
+ <if test="typeName != null and typeName != ''">
|
|
|
+ type_name = #{typeName},
|
|
|
+ </if>
|
|
|
+ <if test="code != null and code != ''">
|
|
|
+ code = #{code},
|
|
|
+ </if>
|
|
|
+ <if test="codeValue != null and codeValue != ''">
|
|
|
+ code_value = #{codeValue},
|
|
|
+ </if>
|
|
|
+ <if test="status != null">
|
|
|
+ status = #{status},
|
|
|
+ </if>
|
|
|
+ </set>
|
|
|
+ where id = #{id}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <!--通过主键删除-->
|
|
|
+ <delete id="deleteById">
|
|
|
+ delete from s_dict where id = #{id}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+
|
|
|
+ <select id="getDictByType" resultMap="SDictMap">
|
|
|
+ select
|
|
|
+ type, type_name, code, code_value
|
|
|
+ from s_dict
|
|
|
+ where status = 1
|
|
|
+ <if test="types != null and types.size > 0">
|
|
|
+ AND type_name in
|
|
|
+ <foreach collection="types" item="s" index="index" open="(" close=")" separator=",">
|
|
|
+ #{s}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="codes != null and codes.size > 0">
|
|
|
+ AND type_name in
|
|
|
+ <foreach collection="codes" item="s" index="index" open="(" close=")" separator=",">
|
|
|
+ #{s}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+</mapper>
|
|
|
+
|