117 lines
5.6 KiB
XML
117 lines
5.6 KiB
XML
<?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.solution.algo.mapper.AlgorithmMapper">
|
|
|
|
<resultMap type="Algorithm" id="AlgorithmResult">
|
|
<result property="id" column="id" />
|
|
<result property="name" column="name" />
|
|
<result property="type" column="type" />
|
|
<result property="codePath" column="code_path" />
|
|
<result property="description" column="description" />
|
|
<result property="algoConfig" column="algo_config" />
|
|
<result property="algoConfigList" column="algo_config_list" typeHandler="com.solution.algo.AlgorithmConfigTypeHandler" />
|
|
</resultMap>
|
|
|
|
<resultMap id="AlgorithmAlgorithmParamResult" type="Algorithm" extends="AlgorithmResult">
|
|
<collection property="algorithmParamList" ofType="AlgorithmParam" column="id" select="selectAlgorithmParamList" />
|
|
</resultMap>
|
|
|
|
<resultMap type="AlgorithmParam" id="AlgorithmParamResult">
|
|
<result property="id" column="id" />
|
|
<result property="algorithmId" column="algorithm_id" />
|
|
<result property="paramName" column="param_name" />
|
|
<result property="defaultValue" column="default_value" />
|
|
<result property="description" column="description" />
|
|
</resultMap>
|
|
|
|
<sql id="selectAlgorithmVo">
|
|
select id, name, type, code_path, description, algo_config, algo_config_list from algorithm
|
|
</sql>
|
|
|
|
<select id="selectAlgorithmList" parameterType="Algorithm" resultMap="AlgorithmAlgorithmParamResult">
|
|
<include refid="selectAlgorithmVo"/>
|
|
<where>
|
|
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
|
<if test="type != null and type != ''"> and type = #{type}</if>
|
|
<if test="codePath != null and codePath != ''"> and code_path = #{codePath}</if>
|
|
<if test="description != null and description != ''"> and description = #{description}</if>
|
|
<if test="algoConfig != null and algoConfig != ''"> and algo_config = #{algoConfig}</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="selectAlgorithmById" parameterType="Long" resultMap="AlgorithmAlgorithmParamResult">
|
|
select id, name, type, code_path, description, algo_config
|
|
from algorithm
|
|
where id = #{id}
|
|
</select>
|
|
|
|
<select id="selectAlgorithmParamList" resultMap="AlgorithmParamResult">
|
|
select id, algorithm_id, param_name, default_value, description
|
|
from algorithm_param
|
|
where algorithm_id = #{algorithm_id}
|
|
</select>
|
|
|
|
<insert id="insertAlgorithm" parameterType="Algorithm" useGeneratedKeys="true" keyProperty="id">
|
|
insert into algorithm
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="name != null and name != ''">name,</if>
|
|
<if test="type != null and type != ''">type,</if>
|
|
<if test="codePath != null">code_path,</if>
|
|
<if test="description != null">description,</if>
|
|
<if test="algoConfig != null">algo_config,</if>
|
|
<if test="algoConfigList != null">algo_config_list,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="name != null and name != ''">#{name},</if>
|
|
<if test="type != null and type != ''">#{type},</if>
|
|
<if test="codePath != null">#{codePath},</if>
|
|
<if test="description != null">#{description},</if>
|
|
<if test="algoConfig != null">#{algoConfig},</if>
|
|
<if test="algoConfigList != null">#{algoConfigList,typeHandler=com.solution.algo.AlgorithmConfigTypeHandler},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateAlgorithm" parameterType="Algorithm">
|
|
update algorithm
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="name != null and name != ''">name = #{name},</if>
|
|
<if test="type != null and type != ''">type = #{type},</if>
|
|
<if test="codePath != null">code_path = #{codePath},</if>
|
|
<if test="description != null">description = #{description},</if>
|
|
<if test="algoConfig != null">algo_config = #{algoConfig},</if>
|
|
<if test="algoConfigList != null">algo_config_list = #{algoConfigList,typeHandler=com.solution.algo.AlgorithmConfigTypeHandler},</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<delete id="deleteAlgorithmById" parameterType="Long">
|
|
delete from algorithm where id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteAlgorithmByIds" parameterType="String">
|
|
delete from algorithm where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<delete id="deleteAlgorithmParamByAlgorithmIds" parameterType="String">
|
|
delete from algorithm_param where algorithm_id in
|
|
<foreach item="algorithmId" collection="array" open="(" separator="," close=")">
|
|
#{algorithmId}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<delete id="deleteAlgorithmParamByAlgorithmId" parameterType="Long">
|
|
delete from algorithm_param where algorithm_id = #{algorithmId}
|
|
</delete>
|
|
|
|
<insert id="batchAlgorithmParam">
|
|
insert into algorithm_param( id, algorithm_id, param_name, default_value, description) values
|
|
<foreach item="item" index="index" collection="list" separator=",">
|
|
( #{item.id}, #{item.algorithmId}, #{item.paramName}, #{item.defaultValue}, #{item.description})
|
|
</foreach>
|
|
</insert>
|
|
</mapper> |