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

107 lines
6.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.wuhansaga.server.mapper.CaseStudyMapper">
<resultMap id="caseStudyResult" type="com.wuhansaga.server.entity.CaseStudy">
<id property="caseStudyId" column="case_study_id"/>
<result property="categoryId" column="category_id"/>
<result property="clientNameZh" column="client_name_zh"/>
<result property="clientNameEn" column="client_name_en"/>
<result property="projectNameZh" column="project_name_zh"/>
<result property="projectNameEn" column="project_name_en"/>
<result property="location" column="location"/>
<result property="descriptionZh" column="description_zh"/>
<result property="descriptionEn" column="description_en"/>
<result property="scopeZh" column="scope_zh"/>
<result property="scopeEn" column="scope_en"/>
<result property="achievementZh" column="achievement_zh"/>
<result property="achievementEn" column="achievement_en"/>
<result property="isOverseas" column="is_overseas"/>
<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="caseStudyResult">
SELECT cs.*, cc.name_zh AS category_name_zh, cc.name_en AS category_name_en
FROM f_case_study cs
LEFT JOIN f_case_category cc ON cs.category_id = cc.case_category_id
WHERE cs.del_flag = 0
<if test="categoryId != null">AND cs.category_id = #{categoryId}</if>
<if test="isOverseas != null">AND cs.is_overseas = #{isOverseas}</if>
<if test="isFeatured != null">AND cs.is_featured = #{isFeatured}</if>
<if test="keyword != null and keyword != ''">
AND (cs.client_name_zh LIKE CONCAT('%',#{keyword},'%') OR cs.client_name_en LIKE CONCAT('%',#{keyword},'%')
OR cs.project_name_zh LIKE CONCAT('%',#{keyword},'%') OR cs.project_name_en LIKE CONCAT('%',#{keyword},'%'))
</if>
ORDER BY cs.sort_order ASC
</select>
<select id="selectCount" resultType="long">
SELECT COUNT(*) FROM f_case_study WHERE del_flag = 0
<if test="categoryId != null">AND category_id = #{categoryId}</if>
<if test="isOverseas != null">AND is_overseas = #{isOverseas}</if>
<if test="isFeatured != null">AND is_featured = #{isFeatured}</if>
<if test="keyword != null and keyword != ''">
AND (client_name_zh LIKE CONCAT('%',#{keyword},'%') OR client_name_en LIKE CONCAT('%',#{keyword},'%'))
</if>
</select>
<select id="selectPublished" resultMap="caseStudyResult">
SELECT cs.*, cc.name_zh AS category_name_zh, cc.name_en AS category_name_en
FROM f_case_study cs
LEFT JOIN f_case_category cc ON cs.category_id = cc.case_category_id
WHERE cs.del_flag = 0 AND cs.is_published = 1
<if test="categoryId != null">AND cs.category_id = #{categoryId}</if>
<if test="isFeatured != null">AND cs.is_featured = #{isFeatured}</if>
ORDER BY cs.sort_order ASC
</select>
<select id="selectById" resultMap="caseStudyResult">
SELECT cs.*, cc.name_zh AS category_name_zh, cc.name_en AS category_name_en
FROM f_case_study cs
LEFT JOIN f_case_category cc ON cs.category_id = cc.case_category_id
WHERE cs.case_study_id = #{id} AND cs.del_flag = 0
</select>
<insert id="insert" useGeneratedKeys="true" keyProperty="caseStudyId">
INSERT INTO f_case_study (category_id, client_name_zh, client_name_en, project_name_zh, project_name_en,
location, description_zh, description_en, scope_zh, scope_en, achievement_zh,
achievement_en, is_overseas, is_featured, is_published, sort_order, create_by, remark)
VALUES (#{categoryId}, #{clientNameZh}, #{clientNameEn}, #{projectNameZh}, #{projectNameEn},
#{location}, #{descriptionZh}, #{descriptionEn}, #{scopeZh}, #{scopeEn}, #{achievementZh},
#{achievementEn}, #{isOverseas}, #{isFeatured}, #{isPublished}, #{sortOrder}, #{createBy}, #{remark})
</insert>
<update id="update" parameterType="com.wuhansaga.server.entity.CaseStudy">
UPDATE f_case_study
<set>
<if test="categoryId != null">category_id = #{categoryId},</if>
<if test="clientNameZh != null">client_name_zh = #{clientNameZh},</if>
<if test="clientNameEn != null">client_name_en = #{clientNameEn},</if>
<if test="projectNameZh != null">project_name_zh = #{projectNameZh},</if>
<if test="projectNameEn != null">project_name_en = #{projectNameEn},</if>
<if test="location != null">location = #{location},</if>
<if test="descriptionZh != null">description_zh = #{descriptionZh},</if>
<if test="descriptionEn != null">description_en = #{descriptionEn},</if>
<if test="scopeZh != null">scope_zh = #{scopeZh},</if>
<if test="scopeEn != null">scope_en = #{scopeEn},</if>
<if test="achievementZh != null">achievement_zh = #{achievementZh},</if>
<if test="achievementEn != null">achievement_en = #{achievementEn},</if>
<if test="isOverseas != null">is_overseas = #{isOverseas},</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 case_study_id = #{caseStudyId} AND del_flag = 0
</update>
<update id="deleteById">
UPDATE f_case_study SET del_flag = 1 WHERE case_study_id = #{id}
</update>
</mapper>