127 lines
7.2 KiB
XML
127 lines
7.2 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.SparePartMapper">
|
||
|
|
|
||
|
|
<resultMap id="sparePartResult" type="com.wuhansaga.server.entity.SparePart">
|
||
|
|
<id property="sparePartId" column="spare_part_id"/>
|
||
|
|
<result property="categoryId" column="category_id"/>
|
||
|
|
<result property="nameZh" column="name_zh"/>
|
||
|
|
<result property="nameEn" column="name_en"/>
|
||
|
|
<result property="model" column="model"/>
|
||
|
|
<result property="descriptionZh" column="description_zh"/>
|
||
|
|
<result property="descriptionEn" column="description_en"/>
|
||
|
|
<result property="material" column="material"/>
|
||
|
|
<result property="applications" column="applications"/>
|
||
|
|
<result property="coverImage" column="cover_image"/>
|
||
|
|
<result property="modelSpec" column="model_spec"/>
|
||
|
|
<result property="applicableLineModel" column="applicable_line_model"/>
|
||
|
|
<result property="materialZh" column="material_zh"/>
|
||
|
|
<result property="materialEn" column="material_en"/>
|
||
|
|
<result property="lifespan" column="lifespan"/>
|
||
|
|
<result property="productAdvantagesZh" column="product_advantages_zh"/>
|
||
|
|
<result property="productAdvantagesEn" column="product_advantages_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="specificationsZh" column="specifications_zh"/>
|
||
|
|
<result property="specificationsEn" column="specifications_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="sparePartResult">
|
||
|
|
SELECT sp.*, pc.name_zh AS category_name_zh, pc.name_en AS category_name_en
|
||
|
|
FROM f_spare_part sp
|
||
|
|
LEFT JOIN f_product_category pc ON sp.category_id = pc.product_category_id
|
||
|
|
WHERE sp.del_flag = 0
|
||
|
|
<if test="categoryId != null">AND sp.category_id = #{categoryId}</if>
|
||
|
|
<if test="keyword != null and keyword != ''">
|
||
|
|
AND (sp.name_zh LIKE CONCAT('%',#{keyword},'%') OR sp.name_en LIKE CONCAT('%',#{keyword},'%'))
|
||
|
|
</if>
|
||
|
|
ORDER BY sp.sort_order ASC
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="selectCount" resultType="long">
|
||
|
|
SELECT COUNT(*) FROM f_spare_part 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="sparePartResult">
|
||
|
|
SELECT sp.*, pc.name_zh AS category_name_zh, pc.name_en AS category_name_en
|
||
|
|
FROM f_spare_part sp
|
||
|
|
LEFT JOIN f_product_category pc ON sp.category_id = pc.product_category_id
|
||
|
|
WHERE sp.del_flag = 0 AND sp.is_published = 1
|
||
|
|
<if test="categoryId != null">AND sp.category_id = #{categoryId}</if>
|
||
|
|
ORDER BY sp.sort_order ASC
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="selectById" resultMap="sparePartResult">
|
||
|
|
SELECT sp.*, pc.name_zh AS category_name_zh, pc.name_en AS category_name_en
|
||
|
|
FROM f_spare_part sp
|
||
|
|
LEFT JOIN f_product_category pc ON sp.category_id = pc.product_category_id
|
||
|
|
WHERE sp.spare_part_id = #{id} AND sp.del_flag = 0
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<insert id="insert" useGeneratedKeys="true" keyProperty="sparePartId">
|
||
|
|
INSERT INTO f_spare_part (category_id, name_zh, name_en, model, description_zh, description_en,
|
||
|
|
material, applications, cover_image,
|
||
|
|
model_spec, applicable_line_model,
|
||
|
|
material_zh, material_en, lifespan,
|
||
|
|
product_advantages_zh, product_advantages_en,
|
||
|
|
excerpt_zh, excerpt_en, content_zh, content_en,
|
||
|
|
specifications_zh, specifications_en,
|
||
|
|
is_published, sort_order, create_by, remark)
|
||
|
|
VALUES (#{categoryId}, #{nameZh}, #{nameEn}, #{model}, #{descriptionZh}, #{descriptionEn},
|
||
|
|
#{material}, #{applications}, #{coverImage},
|
||
|
|
#{modelSpec}, #{applicableLineModel},
|
||
|
|
#{materialZh}, #{materialEn}, #{lifespan},
|
||
|
|
#{productAdvantagesZh}, #{productAdvantagesEn},
|
||
|
|
#{excerptZh}, #{excerptEn}, #{contentZh}, #{contentEn},
|
||
|
|
#{specificationsZh}, #{specificationsEn},
|
||
|
|
#{isPublished}, #{sortOrder}, #{createBy}, #{remark})
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<update id="update" parameterType="com.wuhansaga.server.entity.SparePart">
|
||
|
|
UPDATE f_spare_part
|
||
|
|
<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="model != null">model = #{model},</if>
|
||
|
|
<if test="descriptionZh != null">description_zh = #{descriptionZh},</if>
|
||
|
|
<if test="descriptionEn != null">description_en = #{descriptionEn},</if>
|
||
|
|
<if test="material != null">material = #{material},</if>
|
||
|
|
<if test="applications != null">applications = #{applications},</if>
|
||
|
|
<if test="coverImage != null">cover_image = #{coverImage},</if>
|
||
|
|
<if test="modelSpec != null">model_spec = #{modelSpec},</if>
|
||
|
|
<if test="applicableLineModel != null">applicable_line_model = #{applicableLineModel},</if>
|
||
|
|
<if test="materialZh != null">material_zh = #{materialZh},</if>
|
||
|
|
<if test="materialEn != null">material_en = #{materialEn},</if>
|
||
|
|
<if test="lifespan != null">lifespan = #{lifespan},</if>
|
||
|
|
<if test="productAdvantagesZh != null">product_advantages_zh = #{productAdvantagesZh},</if>
|
||
|
|
<if test="productAdvantagesEn != null">product_advantages_en = #{productAdvantagesEn},</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="specificationsZh != null">specifications_zh = #{specificationsZh},</if>
|
||
|
|
<if test="specificationsEn != null">specifications_en = #{specificationsEn},</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 spare_part_id = #{sparePartId} AND del_flag = 0
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<update id="deleteById">
|
||
|
|
UPDATE f_spare_part SET del_flag = 1 WHERE spare_part_id = #{id}
|
||
|
|
</update>
|
||
|
|
</mapper>
|