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

150 lines
9.5 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.ProductLineMapper">
<resultMap id="productLineResult" type="com.wuhansaga.server.entity.ProductLine">
<id property="productLineId" column="product_line_id"/>
<result property="categoryId" column="category_id"/>
<result property="nameZh" column="name_zh"/>
<result property="nameEn" column="name_en"/>
<result property="shortName" column="short_name"/>
<result property="descriptionZh" column="description_zh"/>
<result property="descriptionEn" column="description_en"/>
<result property="specificationsZh" column="specifications_zh"/>
<result property="specificationsEn" column="specifications_en"/>
<result property="capacity" column="capacity"/>
<result property="applicationsZh" column="applications_zh"/>
<result property="applicationsEn" column="applications_en"/>
<result property="achievements" column="achievements"/>
<result property="coverImage" column="cover_image"/>
<result property="applicableMaterialsZh" column="applicable_materials_zh"/>
<result property="applicableMaterialsEn" column="applicable_materials_en"/>
<result property="thicknessRange" column="thickness_range"/>
<result property="widthRange" column="width_range"/>
<result property="runningSpeed" column="running_speed"/>
<result property="equipmentCompositionZh" column="equipment_composition_zh"/>
<result property="equipmentCompositionEn" column="equipment_composition_en"/>
<result property="technicalHighlightsZh" column="technical_highlights_zh"/>
<result property="technicalHighlightsEn" column="technical_highlights_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="isFeatured" column="is_featured"/>
<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="productLineResult">
SELECT pl.*, pc.name_zh AS category_name_zh, pc.name_en AS category_name_en
FROM f_product_line pl
LEFT JOIN f_product_category pc ON pl.category_id = pc.product_category_id
WHERE pl.del_flag = 0
<if test="categoryId != null">AND pl.category_id = #{categoryId}</if>
<if test="isFeatured != null">AND pl.is_featured = #{isFeatured}</if>
<if test="keyword != null and keyword != ''">
AND (pl.name_zh LIKE CONCAT('%',#{keyword},'%') OR pl.name_en LIKE CONCAT('%',#{keyword},'%'))
</if>
ORDER BY pl.sort_order ASC
</select>
<select id="selectCount" resultType="long">
SELECT COUNT(*) FROM f_product_line WHERE del_flag = 0
<if test="categoryId != null">AND category_id = #{categoryId}</if>
<if test="isFeatured != null">AND is_featured = #{isFeatured}</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="productLineResult">
SELECT pl.*, pc.name_zh AS category_name_zh, pc.name_en AS category_name_en
FROM f_product_line pl
LEFT JOIN f_product_category pc ON pl.category_id = pc.product_category_id
WHERE pl.del_flag = 0 AND pl.is_published = 1
<if test="categoryId != null">AND pl.category_id = #{categoryId}</if>
<if test="isFeatured != null">AND pl.is_featured = #{isFeatured}</if>
ORDER BY pl.sort_order ASC
</select>
<select id="selectById" resultMap="productLineResult">
SELECT pl.*, pc.name_zh AS category_name_zh, pc.name_en AS category_name_en
FROM f_product_line pl
LEFT JOIN f_product_category pc ON pl.category_id = pc.product_category_id
WHERE pl.product_line_id = #{id} AND pl.del_flag = 0
</select>
<insert id="insert" useGeneratedKeys="true" keyProperty="productLineId">
INSERT INTO f_product_line (category_id, name_zh, name_en, short_name, description_zh, description_en,
specifications_zh, specifications_en, capacity, applications_zh, applications_en,
achievements, cover_image,
applicable_materials_zh, applicable_materials_en,
thickness_range, width_range, running_speed,
equipment_composition_zh, equipment_composition_en,
technical_highlights_zh, technical_highlights_en,
application_cases_zh, application_cases_en,
excerpt_zh, excerpt_en, content_zh, content_en,
meta_title_zh, meta_title_en, meta_description_zh, meta_description_en,
meta_keywords, is_featured, is_published, sort_order, create_by, remark)
VALUES (#{categoryId}, #{nameZh}, #{nameEn}, #{shortName}, #{descriptionZh}, #{descriptionEn},
#{specificationsZh}, #{specificationsEn}, #{capacity}, #{applicationsZh}, #{applicationsEn},
#{achievements}, #{coverImage},
#{applicableMaterialsZh}, #{applicableMaterialsEn},
#{thicknessRange}, #{widthRange}, #{runningSpeed},
#{equipmentCompositionZh}, #{equipmentCompositionEn},
#{technicalHighlightsZh}, #{technicalHighlightsEn},
#{applicationCasesZh}, #{applicationCasesEn},
#{excerptZh}, #{excerptEn}, #{contentZh}, #{contentEn},
#{metaTitleZh}, #{metaTitleEn}, #{metaDescriptionZh}, #{metaDescriptionEn},
#{metaKeywords}, #{isFeatured}, #{isPublished}, #{sortOrder}, #{createBy}, #{remark})
</insert>
<update id="update" parameterType="com.wuhansaga.server.entity.ProductLine">
UPDATE f_product_line
<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="shortName != null">short_name = #{shortName},</if>
<if test="descriptionZh != null">description_zh = #{descriptionZh},</if>
<if test="descriptionEn != null">description_en = #{descriptionEn},</if>
<if test="specificationsZh != null">specifications_zh = #{specificationsZh},</if>
<if test="specificationsEn != null">specifications_en = #{specificationsEn},</if>
<if test="capacity != null">capacity = #{capacity},</if>
<if test="applicationsZh != null">applications_zh = #{applicationsZh},</if>
<if test="applicationsEn != null">applications_en = #{applicationsEn},</if>
<if test="achievements != null">achievements = #{achievements},</if>
<if test="coverImage != null">cover_image = #{coverImage},</if>
<if test="applicableMaterialsZh != null">applicable_materials_zh = #{applicableMaterialsZh},</if>
<if test="applicableMaterialsEn != null">applicable_materials_en = #{applicableMaterialsEn},</if>
<if test="thicknessRange != null">thickness_range = #{thicknessRange},</if>
<if test="widthRange != null">width_range = #{widthRange},</if>
<if test="runningSpeed != null">running_speed = #{runningSpeed},</if>
<if test="equipmentCompositionZh != null">equipment_composition_zh = #{equipmentCompositionZh},</if>
<if test="equipmentCompositionEn != null">equipment_composition_en = #{equipmentCompositionEn},</if>
<if test="technicalHighlightsZh != null">technical_highlights_zh = #{technicalHighlightsZh},</if>
<if test="technicalHighlightsEn != null">technical_highlights_en = #{technicalHighlightsEn},</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="isFeatured != null">is_featured = #{isFeatured},</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 product_line_id = #{productLineId} AND del_flag = 0
</update>
<update id="deleteById">
UPDATE f_product_line SET del_flag = 1 WHERE product_line_id = #{id}
</update>
</mapper>