water-design-const-service/water-design-const/src/main/resources/mapper/ModelMapper.xml

101 lines
3.8 KiB
XML
Raw Normal View History

2025-07-11 13:29:48 +08:00
<?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.bonus.waterdesign.mapper.ModelMapper">
<insert id="addModel" useGeneratedKeys="true" keyProperty="id">
insert into tb_model(
<if test="projectId != null and projectId != 0">project_id,</if>
<if test="modelName != null and modelName != ''">model_name,</if>
<if test="modelUrl != null and modelUrl != ''">model_url,</if>
<if test="fileName != null and fileName != ''">file_name,</if>
<if test="version != null and version != ''">version,</if>
<if test="designer != null and designer != ''">designer,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="modelType != null and modelType != ''">model_type,</if>
<if test="modelIds != null and modelIds != ''">model_ids,</if>
<if test="createBy != null and createBy != ''">create_user,</if>
create_time
)values(
<if test="projectId != null and projectId != 0">#{projectId},</if>
<if test="modelName != null and modelName != ''">#{modelName},</if>
<if test="modelUrl != null and modelUrl != ''">#{modelUrl},</if>
<if test="fileName != null and fileName != ''">#{fileName},</if>
<if test="version != null and version != ''">#{version},</if>
<if test="designer != null and designer != ''">#{designer},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="modelType != null and modelType != ''">#{modelType},</if>
<if test="modelIds != null and modelIds != ''">#{modelIds},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)
</insert>
2025-07-15 13:05:18 +08:00
<insert id="insert" >
INSERT INTO project_node
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="projectId != null and projectId != 0">project_id,</if>
<if test="proName != null and proName != ''">node_name,</if>
<if test="level != null and level != ''">level,</if>
<if test="nodeCount != null and nodeCount != ''">node_count,</if>
</trim>
VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="projectId != null and projectId != 0">#{projectId},</if>
<if test="proName != null and proName != ''">#{proName},</if>
<if test="level != null and level != ''">#{level},</if>
<if test="nodeCount != null and nodeCount != ''">#{nodeCount},</if>
</trim>
</insert>
<update id="deleteById">
update from project_node set del_flag = 1
where id = #{id}
</update>
<update id="update">
update project_node
<set>
<if test="projectId != null and projectId != 0">project_id = #{projectId},</if>
<if test="proName != null and proName != ''">node_name = #{proName},</if>
<if test="level != null and level != ''">level = #{level},</if>
<if test="nodeCount != null and nodeCount != ''">node_count = #{nodeCount},</if>
</set>
</update>
<resultMap type="ProjectVo" id="SysProjectVoResult">
<id property="projectId" column="id" />
<result property="id" column="id" />
<result property="proName" column="pro_name" />
<result property="level" column="level" />
<!-- 子表节点信息 -->
<collection property="nodes" ofType="PeojectNodes"
select="selectNodesByConfigId" column="id"/>
</resultMap>
<select id="selectNodesByConfigId" resultType="PeojectNodes">
SELECT
id,
node_name AS proName,
level,
project_id as projectId,
node_count as nodeCount
FROM
project_node
WHERE
project_id = #{id} and del_flag = 0
</select>
<select id="list" resultMap="SysProjectVoResult">
SELECT
p.id,
p.pro_name,
(
SELECT COUNT(*)
FROM sys_level_node n
WHERE n.config_id = c.config_id
) AS nodeCount
FROM tb_project p
LEFT JOIN sys_level_config c ON p.level = c.config_id
WHERE p.del_flag = '0'
2025-07-11 13:29:48 +08:00
</select>
</mapper>