数据库更新防止字段为负
update t_topic t set t.follow_time=case when
(if(isNull(t.follow_time),0,t.follow_time)-1)<0
then 0 else (if(isNull(t.follow_time),0,t.follow_time)-1) end where id=#{0}
if(isNull(t.follow_time),0,t.follow_time)-1 字段初始为0 null 同样可以做-1操作

浙公网安备 33010602011771号