mcwl-ai/mcwl-resource/src/main/resources/mapper/resource/ModelMapper.xml

113 lines
4.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.mcwl.resource.mapper.ModelMapper">
<update id="updateModel">
update model
<set>
<if test="modelName != null and modelName != ''">
model_name = #{modelName},
</if>
<if test="versionDescription != null and versionDescription != ''">
version_description = #{versionDescription},
</if>
<if test="updateBy != null and updateBy != ''">
update_by = #{updateBy},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
<if test="modelTypeId != null">
model_type_id = #{modelTypeId},
</if>
<if test="category != null and category != ''">
category = #{category},
</if>
<if test="functions != null and functions != ''">
functions = #{functions},
</if>
<if test="tags != null and tags != ''">
tags = #{tags},
</if>
<if test="activityId != null and activityId != ''">
activity_id = #{activityId},
</if>
<if test="isOriginal != null">
is_original = #{isOriginal},
</if>
<if test="originalAuthorName != null and originalAuthorName != ''">
original_author_name = #{originalAuthorName},
</if>
<if test="reals != null">
reals = #{reals},
</if>
<if test="numbers != null">
numbers = #{numbers},
</if>
<if test="auditSatus != null">
audit_satus = #{auditSatus},
</if>
<if test="isRecommend != null">
is_recommend = #{isRecommend},
</if>
<if test="delFlag != null and delFlag != ''">
del_flag = #{delFlag},
</if>
<if test="remark != null and remark != ''">
remark = #{remark},
</if>
<if test="auditText != null and auditText != ''">
audit_text = #{auditText},
</if>
<if test="userId != null">
user_id = #{userId},
</if>
<if test="versionId != null">
version_id = #{versionId},
</if>
</set>
where id = #{id}
</update>
<update id="updateTopStatus">
update model set is_top = #{isTop} where id = #{id}
</update>
<select id="sumNumber" resultType="java.lang.Long">
SELECT COALESCE(sum(numbers), 0) sum FROM model where user_id = #{userId} ORDER BY(user_id);
</select>
<select id="sumLikeNumber" resultType="java.lang.Long">
SELECT COALESCE(sum(like_num), 0) sum FROM model where user_id = #{userId} ORDER BY(user_id);
</select>
<select id="sumRunNumber" resultType="java.lang.Long">
SELECT COALESCE(sum(reals), 0) sum FROM model where user_id = #{userId} ORDER BY(user_id);
</select>
<select id="selectAllModelsSortedByTopStatus" resultType="com.mcwl.resource.domain.ModelProduct">
SELECT is_top FROM model ORDER BY is_top DESC;
</select>
<select id="modelSquare" resultType="com.mcwl.resource.domain.response.ResponseModelProduct">
SELECT id,model_name,m.user_id,model_type,reals,surface_url,numbers,like_num,nick_name,avatar FROM model as m
LEFT JOIN sys_user as u
on m.user_id = u.user_id
WHERE m.del_flag = 0
and audit_status = 1
<if test="name != null and name != ''">
and m.model_name like CONCAT('%', #{name}, '%')
</if>
<if test="type != null and type != ''">
and m.model_type = #{type}
</if>
</select>
<select id="sumModelNumber" resultType="java.lang.Long">
SELECT COALESCE(count(*), 0)
FROM model
where user_id = #{userId}
and del_flag = 0
and audit_status in (1, 2)
</select>
</mapper>