ApiDataServiceMapper.xml 4.04 KB
<?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.lhcredit.project.business.apiDataService.mapper.ApiDataServiceMapper">

    <resultMap type="ApiDataService" id="ApiDataServiceResult">
        <result property="id"    column="id"    />
        <result property="parentId"    column="parent_id"    />
        <result property="dataName"    column="data_name"    />
        <result property="directory"    column="directory"    />
        <result property="dimension"    column="dimension"    />
        <result property="example"    column="example"    />
    </resultMap>

    <sql id="selectApiDataServiceVo">
        select id, parent_id, data_name, directory, dimension, example from api_data_service
    </sql>

    <select id="selectApiDataServiceList" parameterType="ApiDataService" resultMap="ApiDataServiceResult">
        <include refid="selectApiDataServiceVo"/>
        <where>
            <if test="id != null "> and id = #{id}</if>
            <if test="parentId != null "> and parent_id = #{parentId}</if>
            <if test="dataName != null  and dataName != '' "> and data_name = #{dataName}</if>
            <if test="directory != null  and directory != '' "> and directory = #{directory}</if>
            <if test="dimension != null  and dimension != '' "> and dimension = #{dimension}</if>
            <if test="example != null  and example != '' "> and example = #{example}</if>
        </where>
    </select>

    <select id="selectApiDataServiceById" parameterType="Integer" resultMap="ApiDataServiceResult">
        <include refid="selectApiDataServiceVo"/>
        where id = #{id}
    </select>
    <select id="selectApiDataServiceListAll"
            parameterType="ApiDataService" resultMap="ApiDataServiceResult">
        select * from api_data_service
    </select>

    <insert id="insertApiDataService" parameterType="ApiDataService" useGeneratedKeys="true" keyProperty="id">
        insert into api_data_service
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null  ">id,</if>
            <if test="parentId != null  ">parent_id,</if>
            <if test="dataName != null  and dataName != ''  ">data_name,</if>
            <if test="directory != null  and directory != ''  ">directory,</if>
            <if test="dimension != null  and dimension != ''  ">dimension,</if>
            <if test="example != null  and example != ''  ">example,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null  ">#{id},</if>
            <if test="parentId != null  ">#{parentId},</if>
            <if test="dataName != null  and dataName != ''  ">#{dataName},</if>
            <if test="directory != null  and directory != ''  ">#{directory},</if>
            <if test="dimension != null  and dimension != ''  ">#{dimension},</if>
            <if test="example != null  and example != ''  ">#{example},</if>
        </trim>
    </insert>

    <update id="updateApiDataService" parameterType="ApiDataService">
        update api_data_service
        <trim prefix="SET" suffixOverrides=",">
            <if test="parentId != null  ">parent_id = #{parentId},</if>
            <if test="dataName != null  and dataName != ''  ">data_name = #{dataName},</if>
            <if test="directory != null  and directory != ''  ">directory = #{directory},</if>
            <if test="dimension != null  and dimension != ''  ">dimension = #{dimension},</if>
            <if test="example != null  and example != ''  ">example = #{example},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteApiDataServiceById" parameterType="Integer">
        delete from api_data_service where id = #{id}
    </delete>

    <delete id="deleteApiDataServiceByIds" parameterType="String">
        delete from api_data_service where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

</mapper>