Spring Boot MyBatis-Plus setSql() 方法用法
MyBatis-Plus Spring Boot About 736 words自定义 SQL 片段
setSql(String setSql, Object... params)
boolean success = pointsService.lambdaUpdate()
.eq(Points::getUserId, uid)
.setSql("balance = balance - {0}", points)
.setSql("expiring = expiring - {0}", points)
.update(new Points());
setSql(boolean condition, String setSql, Object... params)
boolean condition = mpUser.getTotalSignDate() == null;
boolean success = mpUserService.lambdaUpdate()
.eq(MpUser::getId, userId)
.set(MpUser::getLastSignDate, date)
.setSql(condition, "total_sign_date = 1")
.setSql(!condition, "total_sign_date = total_sign_date + 1")
.update(new MpUser());
与 apply() 方法区别
setSql
仅用于update
语句。
apply
可用于select
、update
、delete
、where
等多个语句。
Views: 110 · Posted: 2025-09-28
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓

Loading...