文案处理mysql

update love_word set title = concat(title, ",", substring_index(content, CHAR(10), 1)) where locate(substring_index(content, CHAR(10), 1), title) = 0  and app_id = '1' and CHAR_LENGTH(concat(title, ",", substring_index(content, CHAR(10), 1))) <  90

UPDATE love_word set title = REPLACE(title, ",", ",")

UPDATE love_word set title = REPLACE(title, "?,", "?")
UPDATE love_word set title = REPLACE(title, "。,", "。")
UPDATE love_word set title = REPLACE(title, "!,", "!")
UPDATE love_word set title = substring(title, 2) WHERE substring(title, 1, 1) = ","


 

<!-- 获取列表 -->
    <select id="query" parameterType="java.util.Map" resultType="com.hi.hailiaowenan.affair.bean.LoveWord">
    	select id, f_id as fId, f_id_name as fIdName, state, active, content, app_id as appId, is_top as isTop,
    	user_id as userId, user_name as userName, avatar, title, image,
    	download_init_count as downloadInitCount, collect_init_count as collectInitCount, download_count as downloadCount, collect_count as collectCount, report_count as reportCount,
        <if test="fvs != null and fvs.size > 0">
           <foreach collection="fvs" open="(" close=")" separator="+" item="item">
               if(LOCATE(#{item},f_id_name),5,0) + if(LOCATE(#{item},title),5,0)
           </foreach>
           as title_matching_degree,
           <foreach collection="fvs" open="(" close=")" separator="+" item="item">
               if(LOCATE(#{item},content),1,0)
           </foreach>
           as content_matching_degree,
       </if>
    	create_time as createTime, update_time as updateTime
    	from
    	<include refid="table_name"></include>
        <trim prefix="WHERE" prefixOverrides="AND | OR">
        <!-- 有图 -->        
	      <if test="image != '' and image != null">
	    		and images != ''
	    	</if>
	    	<!-- 上架状态 -->        
	      <if test="state != null and state != '' or state == 0">
	    		and state = #{state}
	    	</if>
	    	<!-- 审核状态 -->        
	      <if test="active != null and active != '' or active == 0">
	    		and active = #{active}
	    	</if>
	    	<!-- 范畴 -->        
	      <if test="fId != null and fId != ''">
	    		and f_id like CONCAT('%',#{fId},'%')
	    	</if>
	    	<!-- 用户 -->        
	        <if test="userId != null">
	    		and user_id = #{userId}
	    	</if>
        <!-- 用户所分享 -->        
	      <if test="byUser != null and byUser != ''">
	    		and user_id != ''
	    	</if>
				<!-- 举报量 -->        
				<if test="reportCount != null and reportCount != '' or reportCount == 0">
						and report_count = #{reportCount}
				</if>
	    	<!-- 应用 -->        
	      <if test="appId != null and appId != ''">
	    		and app_id = #{appId}
	    	</if>
				<!--  <if test="keywords != null and keywords != ''">
				bind写法:预防SQL注入  通过关键词搜索
						and content like CONCAT('%',#{keywords},'%') or f_id_name like CONCAT('%',#{keywords},'%') or title like CONCAT('%',#{keywords},'%')
				</if> -->
				<if test="content != null and content != ''">
					<!-- bind写法:预防SQL注入  匹配词语内容匹配 -->
					<bind name="pattern" value="'%'+content+'%'" />
					and content like #{pattern}
				</if>
				<if test="fIdName != null and fIdName != ''">
					<!-- bind写法:预防SQL注入  匹配词语标题匹配 -->
					<bind name="pattern" value="'%'+fIdName+'%'" />
					and (f_id_name like #{pattern} or title like #{pattern})
				</if>
				<if test="fvs != null and fvs.size > 0">
					and (
						<foreach collection="fvs" open="(" close=")" separator="or" item="item">
							content like CONCAT('%',#{item},'%') or f_id_name like CONCAT('%',#{item},'%') or title like CONCAT('%',#{item},'%')
						</foreach>
						)
				</if>
			</trim>
    </select>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值