Files
wuhan-saga/server/target/classes/mapper/SingleEquipmentMapper.xml

138 lines
8.4 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.wuhansaga.server.mapper.SingleEquipmentMapper">
<resultMap id="equipmentResult" type="com.wuhansaga.server.entity.SingleEquipment">
<id property="singleEquipmentId" column="single_equipment_id"/>
<result property="categoryId" column="category_id"/>
<result property="nameZh" column="name_zh"/>
<result property="nameEn" column="name_en"/>
<result property="descriptionZh" column="description_zh"/>
<result property="descriptionEn" column="description_en"/>
<result property="technicalHighlightsZh" column="technical_highlights_zh"/>
<result property="technicalHighlightsEn" column="technical_highlights_en"/>
<result property="coverImage" column="cover_image"/>
<result property="functionDescriptionZh" column="function_description_zh"/>
<result property="functionDescriptionEn" column="function_description_en"/>
<result property="specificationsZh" column="specifications_zh"/>
<result property="specificationsEn" column="specifications_en"/>
<result property="productAdvantagesZh" column="product_advantages_zh"/>
<result property="productAdvantagesEn" column="product_advantages_en"/>
<result property="applicableLinesZh" column="applicable_lines_zh"/>
<result property="applicableLinesEn" column="applicable_lines_en"/>
<result property="applicationCasesZh" column="application_cases_zh"/>
<result property="applicationCasesEn" column="application_cases_en"/>
<result property="excerptZh" column="excerpt_zh"/>
<result property="excerptEn" column="excerpt_en"/>
<result property="contentZh" column="content_zh"/>
<result property="contentEn" column="content_en"/>
<result property="isPublished" column="is_published"/>
<result property="sortOrder" column="sort_order"/>
<result property="categoryNameZh" column="category_name_zh"/>
<result property="categoryNameEn" column="category_name_en"/>
</resultMap>
<select id="selectList" resultMap="equipmentResult">
SELECT se.*, pc.name_zh AS category_name_zh, pc.name_en AS category_name_en
FROM f_single_equipment se
LEFT JOIN f_product_category pc ON se.category_id = pc.product_category_id
WHERE se.del_flag = 0
<if test="categoryId != null">AND se.category_id = #{categoryId}</if>
<if test="keyword != null and keyword != ''">
AND (se.name_zh LIKE CONCAT('%',#{keyword},'%') OR se.name_en LIKE CONCAT('%',#{keyword},'%'))
</if>
ORDER BY se.sort_order ASC
</select>
<select id="selectCount" resultType="long">
SELECT COUNT(*) FROM f_single_equipment WHERE del_flag = 0
<if test="categoryId != null">AND category_id = #{categoryId}</if>
<if test="keyword != null and keyword != ''">
AND (name_zh LIKE CONCAT('%',#{keyword},'%') OR name_en LIKE CONCAT('%',#{keyword},'%'))
</if>
</select>
<select id="selectPublished" resultMap="equipmentResult">
SELECT se.*, pc.name_zh AS category_name_zh, pc.name_en AS category_name_en
FROM f_single_equipment se
LEFT JOIN f_product_category pc ON se.category_id = pc.product_category_id
WHERE se.del_flag = 0 AND se.is_published = 1
<if test="categoryId != null">AND se.category_id = #{categoryId}</if>
ORDER BY se.sort_order ASC
</select>
<select id="selectById" resultMap="equipmentResult">
SELECT se.*, pc.name_zh AS category_name_zh, pc.name_en AS category_name_en
FROM f_single_equipment se
LEFT JOIN f_product_category pc ON se.category_id = pc.product_category_id
WHERE se.single_equipment_id = #{id} AND se.del_flag = 0
</select>
<select id="selectByProductLineId" resultMap="equipmentResult">
SELECT se.*, pc.name_zh AS category_name_zh, pc.name_en AS category_name_en
FROM f_single_equipment se
INNER JOIN f_product_line_equipment ple ON se.single_equipment_id = ple.equipment_id
LEFT JOIN f_product_category pc ON se.category_id = pc.product_category_id
WHERE ple.product_line_id = #{productLineId} AND se.del_flag = 0
ORDER BY ple.sort_order ASC
</select>
<insert id="insert" useGeneratedKeys="true" keyProperty="singleEquipmentId">
INSERT INTO f_single_equipment (category_id, name_zh, name_en, description_zh, description_en,
technical_highlights_zh, technical_highlights_en, cover_image,
function_description_zh, function_description_en,
specifications_zh, specifications_en,
product_advantages_zh, product_advantages_en,
applicable_lines_zh, applicable_lines_en,
application_cases_zh, application_cases_en,
excerpt_zh, excerpt_en, content_zh, content_en,
is_published, sort_order, create_by, remark)
VALUES (#{categoryId}, #{nameZh}, #{nameEn}, #{descriptionZh}, #{descriptionEn},
#{technicalHighlightsZh}, #{technicalHighlightsEn}, #{coverImage},
#{functionDescriptionZh}, #{functionDescriptionEn},
#{specificationsZh}, #{specificationsEn},
#{productAdvantagesZh}, #{productAdvantagesEn},
#{applicableLinesZh}, #{applicableLinesEn},
#{applicationCasesZh}, #{applicationCasesEn},
#{excerptZh}, #{excerptEn}, #{contentZh}, #{contentEn},
#{isPublished}, #{sortOrder}, #{createBy}, #{remark})
</insert>
<update id="update" parameterType="com.wuhansaga.server.entity.SingleEquipment">
UPDATE f_single_equipment
<set>
<if test="categoryId != null">category_id = #{categoryId},</if>
<if test="nameZh != null">name_zh = #{nameZh},</if>
<if test="nameEn != null">name_en = #{nameEn},</if>
<if test="descriptionZh != null">description_zh = #{descriptionZh},</if>
<if test="descriptionEn != null">description_en = #{descriptionEn},</if>
<if test="technicalHighlightsZh != null">technical_highlights_zh = #{technicalHighlightsZh},</if>
<if test="technicalHighlightsEn != null">technical_highlights_en = #{technicalHighlightsEn},</if>
<if test="coverImage != null">cover_image = #{coverImage},</if>
<if test="functionDescriptionZh != null">function_description_zh = #{functionDescriptionZh},</if>
<if test="functionDescriptionEn != null">function_description_en = #{functionDescriptionEn},</if>
<if test="specificationsZh != null">specifications_zh = #{specificationsZh},</if>
<if test="specificationsEn != null">specifications_en = #{specificationsEn},</if>
<if test="productAdvantagesZh != null">product_advantages_zh = #{productAdvantagesZh},</if>
<if test="productAdvantagesEn != null">product_advantages_en = #{productAdvantagesEn},</if>
<if test="applicableLinesZh != null">applicable_lines_zh = #{applicableLinesZh},</if>
<if test="applicableLinesEn != null">applicable_lines_en = #{applicableLinesEn},</if>
<if test="applicationCasesZh != null">application_cases_zh = #{applicationCasesZh},</if>
<if test="applicationCasesEn != null">application_cases_en = #{applicationCasesEn},</if>
<if test="excerptZh != null">excerpt_zh = #{excerptZh},</if>
<if test="excerptEn != null">excerpt_en = #{excerptEn},</if>
<if test="contentZh != null">content_zh = #{contentZh},</if>
<if test="contentEn != null">content_en = #{contentEn},</if>
<if test="isPublished != null">is_published = #{isPublished},</if>
<if test="sortOrder != null">sort_order = #{sortOrder},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
</set>
WHERE single_equipment_id = #{singleEquipmentId} AND del_flag = 0
</update>
<update id="deleteById">
UPDATE f_single_equipment SET del_flag = 1 WHERE single_equipment_id = #{id}
</update>
</mapper>