<?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.platform.mapper.DevEnvironmentDao">

    <resultMap type="com.ruoyi.platform.domain.DevEnvironment" id="DevEnvironmentMap">
        <result property="id" column="id" jdbcType="INTEGER"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="status" column="status" jdbcType="VARCHAR"/>
        <result property="computingResource" column="computing_resource" jdbcType="VARCHAR"/>
        <result property="standard" column="standard" jdbcType="VARCHAR"/>
        <result property="envVariable" column="env_variable" jdbcType="VARCHAR"/>
        <result property="image" column="image" jdbcType="VARCHAR"/>
        <result property="dataset" column="dataset" jdbcType="VARCHAR"/>
        <result property="model" column="model" jdbcType="VARCHAR"/>
        <result property="url" column="url" jdbcType="VARCHAR"/>
        <result property="altField2" column="alt_field2" jdbcType="VARCHAR"/>
        <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
        <result property="state" column="state" jdbcType="INTEGER"/>
    </resultMap>

    <!--查询单个-->
    <select id="queryById" resultMap="DevEnvironmentMap">
        select
        id,name,status,computing_resource,standard,env_variable,image,dataset,model,url,alt_field2,create_by,create_time,update_by,update_time,state
        from dev_environment
        where id = #{id} and state = 1
    </select>

    <!--查询指定行数据-->
    <select id="queryAllByLimit" resultMap="DevEnvironmentMap">
        select
        id,name,status,computing_resource,standard,env_variable,image,dataset,model,url,alt_field2,create_by,create_time,update_by,update_time,state
        from dev_environment
        <where>
            state = 1
            <if test="devEnvironment.id != null">
                and id = #{devEnvironment.id}
            </if>
            <if test="devEnvironment.name != null and devEnvironment.name != ''">
                and name = #{devEnvironment.name}
            </if>
            <if test="devEnvironment.status != null and devEnvironment.status != ''">
                and status = #{devEnvironment.status}
            </if>
            <if test="devEnvironment.computingResource != null and devEnvironment.computingResource != ''">
                and computing_resource = #{devEnvironment.computingResource}
            </if>
            <if test="devEnvironment.standard != null and devEnvironment.standard != ''">
                and standard = #{devEnvironment.standard}
            </if>
            <if test="devEnvironment.envVariable != null and devEnvironment.envVariable != ''">
                and env_variable = #{devEnvironment.envVariable}
            </if>
            <if test="devEnvironment.image != null and devEnvironment.image != ''">
                and image = #{devEnvironment.image}
            </if>
            <if test="devEnvironment.dataset != null and devEnvironment.dataset != ''">
                and dataset = #{devEnvironment.dataset}
            </if>
            <if test="devEnvironment.model != null and devEnvironment.model != ''">
                and model = #{devEnvironment.model}
            </if>
            <if test="devEnvironment.url != null and devEnvironment.url != ''">
                and url = #{devEnvironment.url}
            </if>
            <if test="devEnvironment.altField2 != null and devEnvironment.altField2 != ''">
                and alt_field2 = #{devEnvironment.altField2}
            </if>
            <if test="devEnvironment.createBy != null and devEnvironment.createBy != ''">
                and create_by = #{devEnvironment.createBy}
            </if>
            <if test="devEnvironment.createTime != null">
                and create_time = #{devEnvironment.createTime}
            </if>
            <if test="devEnvironment.updateBy != null and devEnvironment.updateBy != ''">
                and update_by = #{devEnvironment.updateBy}
            </if>
            <if test="devEnvironment.updateTime != null">
                and update_time = #{devEnvironment.updateTime}
            </if>
            <if test="devEnvironment.state != null">
                and state = #{devEnvironment.state}
            </if>
        </where>
        limit #{pageable.offset}, #{pageable.pageSize}
    </select>


    <!--统计总行数-->
    <select id="count" resultType="java.lang.Long">
        select count(1)
        from dev_environment
        <where>
            state = 1
            <if test="devEnvironment.id != null">
                and id = #{devEnvironment.id}
            </if>
            <if test="devEnvironment.name != null and devEnvironment.name != ''">
                and name = #{devEnvironment.name}
            </if>
            <if test="devEnvironment.status != null and devEnvironment.status != ''">
                and status = #{devEnvironment.status}
            </if>
            <if test="devEnvironment.computingResource != null and devEnvironment.computingResource != ''">
                and computing_resource = #{devEnvironment.computingResource}
            </if>
            <if test="devEnvironment.standard != null and devEnvironment.standard != ''">
                and standard = #{devEnvironment.standard}
            </if>
            <if test="devEnvironment.envVariable != null and devEnvironment.envVariable != ''">
                and env_variable = #{devEnvironment.envVariable}
            </if>
            <if test="devEnvironment.image != null and devEnvironment.image != ''">
                and image = #{devEnvironment.image}
            </if>
            <if test="devEnvironment.dataset != null and devEnvironment.dataset != ''">
                and dataset = #{devEnvironment.dataset}
            </if>
            <if test="devEnvironment.model != null and devEnvironment.model != ''">
                and model = #{devEnvironment.model}
            </if>
            <if test="devEnvironment.url != null and devEnvironment.url != ''">
                and url = #{devEnvironment.url}
            </if>
            <if test="devEnvironment.altField2 != null and devEnvironment.altField2 != ''">
                and alt_field2 = #{devEnvironment.altField2}
            </if>
            <if test="devEnvironment.createBy != null and devEnvironment.createBy != ''">
                and create_by = #{devEnvironment.createBy}
            </if>
            <if test="devEnvironment.createTime != null">
                and create_time = #{devEnvironment.createTime}
            </if>
            <if test="devEnvironment.updateBy != null and devEnvironment.updateBy != ''">
                and update_by = #{devEnvironment.updateBy}
            </if>
            <if test="devEnvironment.updateTime != null">
                and update_time = #{devEnvironment.updateTime}
            </if>
            <if test="devEnvironment.state != null">
                and state = #{devEnvironment.state}
            </if>
        </where>
    </select>

    <!--新增所有列-->
    <insert id="insert" keyProperty="id" useGeneratedKeys="true">
        insert into dev_environment(name,status,computing_resource,standard,env_variable,image,dataset,model,url,alt_field2,create_by,create_time,update_by,update_time,state)
        values (#{devEnvironment.name},
                #{devEnvironment.status},
                #{devEnvironment.computingResource},
                #{devEnvironment.standard},
                #{devEnvironment.envVariable},
                #{devEnvironment.image},
                #{devEnvironment.dataset},
                #{devEnvironment.model},
                #{devEnvironment.url},
                #{devEnvironment.altField2},
                #{devEnvironment.createBy},
                #{devEnvironment.createTime},
                #{devEnvironment.updateBy},
                #{devEnvironment.updateTime},
                #{devEnvironment.state}
                )
    </insert>

    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
        insert into dev_environment(name,status,computing_resource,standard,env_variable,image,dataset,model,url,alt_field2,create_by,create_time,update_by,update_time,state  )
        values
        <foreach collection="entities" item="entity" separator=",">
        (#{entity.name},#{entity.status},#{entity.computingResource},#{entity.standard},#{entity.envVariable},#{entity.image},#{entity.dataset},#{entity.model},#{entity.url},#{entity.altField2},#{entity.createBy},#{entity.createTime},#{entity.updateBy},#{entity.updateTime},#{entity.state})
        </foreach>
    </insert>

    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
        insert into dev_environment(name,status,computing_resource,standard,env_variable,image,dataset,model,url,alt_field2,create_by,create_time,update_by,update_time,state)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.name}#{entity.status}#{entity.computingResource}#{entity.standard}#{entity.envVariable}#{entity.image}#{entity.dataset}#{entity.model}#{entity.url}#{entity.altField2}#{entity.createBy}#{entity.createTime}#{entity.updateBy}#{entity.updateTime}#{entity.state})
        </foreach>
        on duplicate key update
name = values(name)status = values(status)computing_resource = values(computing_resource)standard = values(standard)env_variable = values(env_variable)image = values(image)dataset = values(dataset)model = values(model)url = values(url)alt_field2 = values(alt_field2)create_by = values(create_by)create_time = values(create_time)update_by = values(update_by)update_time = values(update_time)state = values(state)
    </insert>

    <!--通过主键修改数据-->
    <update id="update">
        update dev_environment
        <set>
            <if test="devEnvironment.name != null and devEnvironment.name != ''">
                name = #{devEnvironment.name},
            </if>
            <if test="devEnvironment.status != null and devEnvironment.status != ''">
                status = #{devEnvironment.status},
            </if>
            <if test="devEnvironment.computingResource != null and devEnvironment.computingResource != ''">
                computing_resource = #{devEnvironment.computingResource},
            </if>
            <if test="devEnvironment.standard != null and devEnvironment.standard != ''">
                standard = #{devEnvironment.standard},
            </if>
            <if test="devEnvironment.envVariable != null and devEnvironment.envVariable != ''">
                env_variable = #{devEnvironment.envVariable},
            </if>
            <if test="devEnvironment.image != null and devEnvironment.image != ''">
                image = #{devEnvironment.image},
            </if>
            <if test="devEnvironment.dataset != null and devEnvironment.dataset != ''">
                dataset = #{devEnvironment.dataset},
            </if>
            <if test="devEnvironment.model != null and devEnvironment.model != ''">
                model = #{devEnvironment.model},
            </if>
            <if test="devEnvironment.url != null and devEnvironment.url != ''">
                url = #{devEnvironment.url},
            </if>
            <if test="devEnvironment.altField2 != null and devEnvironment.altField2 != ''">
                alt_field2 = #{devEnvironment.altField2},
            </if>
            <if test="devEnvironment.createBy != null and devEnvironment.createBy != ''">
                create_by = #{devEnvironment.createBy},
            </if>
            <if test="devEnvironment.createTime != null">
                create_time = #{devEnvironment.createTime},
            </if>
            <if test="devEnvironment.updateBy != null and devEnvironment.updateBy != ''">
                update_by = #{devEnvironment.updateBy},
            </if>
            <if test="devEnvironment.updateTime != null">
                update_time = #{devEnvironment.updateTime},
            </if>
            <if test="devEnvironment.state != null">
                state = #{devEnvironment.state},
            </if>
        </set>
        where id = #{devEnvironment.id}
    </update>


    <!--通过主键删除-->
    <delete id="deleteById">
        delete from dev_environment where id = #{id}
    </delete>

</mapper>

