You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

157 lines
7.4 KiB

<?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.chenhai.vet.mapper.VetCommentsMapper">
<resultMap type="VetComments" id="VetCommentsResult">
<result property="id" column="id" />
<result property="consultationId" column="consultation_id" />
<result property="replyName" column="reply_name" />
<result property="content" column="content" />
<result property="images" column="images" />
<result property="isSensitive" column="is_sensitive" />
<result property="sensitiveWords" column="sensitive_words" />
<result property="createdAt" column="created_at" />
<result property="updatedAt" column="updated_at" />
<result property="userId" column="user_id" />
<result property="title" column="title" />
<result property="hospital" column="hospital" />
<result property="experience" column="experience" />
<result property="avatar" column="avatar" />
<!-- 新增字段映射 -->
<result property="expertType" column="expert_type" />
<result property="specialty" column="specialty" />
</resultMap>
<sql id="selectVetCommentsVo">
select
id,
consultation_id,
reply_name,
content,
images,
is_sensitive,
sensitive_words,
created_at,
updated_at,
user_id,
title,
hospital,
experience,
avatar,
expert_type,
specialty
from vet_comments
</sql>
<select id="selectVetCommentsList" parameterType="VetComments" resultMap="VetCommentsResult">
<include refid="selectVetCommentsVo"/>
<where>
<if test="consultationId != null "> and consultation_id = #{consultationId}</if>
<if test="replyName != null "> and reply_name like concat('%', #{replyName}, '%')</if>
<if test="content != null and content != ''"> and content = #{content}</if>
<if test="images != null and images != ''"> and images = #{images}</if>
<if test="isSensitive != null "> and is_sensitive = #{isSensitive}</if>
<if test="sensitiveWords != null and sensitiveWords != ''"> and sensitive_words = #{sensitiveWords}</if>
<if test="createdAt != null "> and created_at = #{createdAt}</if>
<if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="avatar != null and avatar != ''"> and cf.avatar = #{avatar}</if>
<if test="title != null and title != ''"> and title like concat('%', #{title}, '%')</if>
<if test="hospital != null and hospital != ''"> and hospital like concat('%', #{hospital}, '%')</if>
<if test="experience != null and experience != ''"> and experience like concat('%', #{experience}, '%')</if>
</where>
</select>
<select id="selectVetCommentsById" parameterType="Long" resultMap="VetCommentsResult">
<include refid="selectVetCommentsVo"/>
where id = #{id}
</select>
<insert id="insertVetComments" parameterType="VetComments" useGeneratedKeys="true" keyProperty="id">
insert into vet_comments
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="consultationId != null">consultation_id,</if>
<if test="replyName != null">reply_name,</if>
<if test="content != null">content,</if>
<if test="images != null">images,</if>
<if test="isSensitive != null">is_sensitive,</if>
<if test="sensitiveWords != null">sensitive_words,</if>
<if test="createdAt != null">created_at,</if>
<if test="updatedAt != null">updated_at,</if>
<if test="userId != null">user_id,</if>
<if test="title != null">title,</if>
<if test="hospital != null">hospital,</if>
<if test="experience != null">experience,</if>
<if test="avatar != null and avatar != ''">avatar,</if>
<!-- 新增字段 -->
<if test="expertType != null">expert_type,</if>
<if test="specialty != null">specialty,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="consultationId != null">#{consultationId},</if>
<if test="replyName != null">#{replyName},</if>
<if test="content != null">#{content},</if>
<if test="images != null">#{images},</if>
<if test="isSensitive != null">#{isSensitive},</if>
<if test="sensitiveWords != null">#{sensitiveWords},</if>
<if test="createdAt != null">#{createdAt},</if>
<if test="updatedAt != null">#{updatedAt},</if>
<if test="userId != null">#{userId},</if>
<if test="title != null">#{title},</if>
<if test="hospital != null">#{hospital},</if>
<if test="experience != null">#{experience},</if>
<if test="avatar != null and avatar != ''">#{avatar},</if>
<!-- 新增字段 -->
<if test="expertType != null">#{expertType},</if>
<if test="specialty != null">#{specialty},</if>
</trim>
</insert>
<update id="updateVetComments" parameterType="VetComments">
update vet_comments
<trim prefix="SET" suffixOverrides=",">
<if test="consultationId != null">consultation_id = #{consultationId},</if>
<if test="replyName != null">reply_name = #{replyName},</if>
<if test="content != null">content = #{content},</if>
<if test="images != null">images = #{images},</if>
<if test="isSensitive != null">is_sensitive = #{isSensitive},</if>
<if test="sensitiveWords != null">sensitive_words = #{sensitiveWords},</if>
<if test="createdAt != null">created_at = #{createdAt},</if>
<if test="updatedAt != null">updated_at = #{updatedAt},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="title != null">title = #{title},</if>
<if test="hospital != null">hospital = #{hospital},</if>
<if test="experience != null">experience = #{experience},</if>
<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
<!-- 新增字段 -->
<if test="expertType != null">expert_type = #{expertType},</if>
<if test="specialty != null">specialty = #{specialty},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteVetCommentsById" parameterType="Long">
delete from vet_comments where id = #{id}
</delete>
<delete id="deleteVetCommentsByIds" parameterType="String">
delete from vet_comments where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- 新增:更新用户专业信息的SQL -->
<update id="updateUserProfessionalInfo">
UPDATE sys_user
SET
title = #{title},
hospital = #{hospital},
experience = #{experience},
update_time = NOW()
WHERE user_id = #{userId}
</update>
</mapper>