Files
auto-solution/auto-solution-algo/src/main/resources/mapper/algo/AlgorithmMapper.xml

113 lines
5.1 KiB
XML
Raw Normal View History

<?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" />
2026-02-09 11:15:26 +08:00
<result property="algoConfig" column="algo_config" />
</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">
2026-02-09 11:15:26 +08:00
select id, name, type, code_path, description, algo_config 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>
2026-02-09 11:15:26 +08:00
<if test="algoConfig != null and algoConfig != ''"> and algo_config = #{algoConfig}</if>
</where>
</select>
<select id="selectAlgorithmById" parameterType="Long" resultMap="AlgorithmAlgorithmParamResult">
2026-02-09 11:15:26 +08:00
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>
2026-02-09 11:15:26 +08:00
<if test="algoConfig != null">algo_config,</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>
2026-02-09 11:15:26 +08:00
<if test="algoConfig != null">#{algoConfig},</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>
2026-02-09 11:15:26 +08:00
<if test="algoConfig != null">algo_config = #{algoConfig},</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>