标签:string ice online 条件 set dcl ret dna VID
1、注解
@UpdateProvider(type = ClassName.class,method = "methodName")//更新
@InsertProvider//插入
@SelectProvider//选择
@DeleteProvider//删除
2、写法
package net.xdclass.xdvidio.provider; /** * @Author Pandas * @Date 2020/3/31 21:03 * @Version 1.0 * @Descrition video构建动态sql语句 */ import net.xdclass.xdvidio.domain.Video; import org.apache.ibatis.jdbc.SQL; public class VideoProvider { /** * 更新vidio的动态SQL * @param video * @return */ public String updaeVideo(final Video video){ return new SQL(){{ UPDATE("video"); //条件写法 if(video.getTitle()!=null){ SET("title=#{title}"); } if(video.getSummary()!=null){ SET("summary=#{summary}"); } if(video.getCoverImg()!=null){ SET("cover_img=#{coverImg}"); } if(video.getViewNum()!=null){ SET("view_num=#{viewNum}"); } if(video.getPrice()!=null){ SET("price=#{price}"); } if(video.getOnline()!=null){ SET("online=#{online}"); } if(video.getPoint()!=null){ SET("point=#{point}"); } WHERE("id=#{id}"); }}.toString(); } }
然后在VideoMapper里面添加:
@UpdateProvider(type = VideoProvider.class,method = "updateVideo") Integer update(Video video);
标签:string ice online 条件 set dcl ret dna VID
原文地址:https://www.cnblogs.com/jwmdlm/p/12608953.html