手机h5端-惠民服务: (使用 EXISTS 代替 JOIN)修复因为人员范围userId重复导致的业务查询时数据膨胀问题(即一行变多行);
This commit is contained in:
+3
-4
@@ -14,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.nutz.dao.Cnd;
|
import org.nutz.dao.Cnd;
|
||||||
import org.nutz.dao.Sqls;
|
import org.nutz.dao.Sqls;
|
||||||
import org.nutz.dao.sql.Sql;
|
import org.nutz.dao.sql.Sql;
|
||||||
|
import org.nutz.dao.util.cri.Static;
|
||||||
import org.nutz.ioc.loader.annotation.Inject;
|
import org.nutz.ioc.loader.annotation.Inject;
|
||||||
import org.nutz.ioc.loader.annotation.IocBean;
|
import org.nutz.ioc.loader.annotation.IocBean;
|
||||||
import org.nutz.mvc.annotation.At;
|
import org.nutz.mvc.annotation.At;
|
||||||
@@ -50,8 +51,6 @@ public class HuiminMineController {
|
|||||||
t1.*
|
t1.*
|
||||||
FROM
|
FROM
|
||||||
huimin t1
|
huimin t1
|
||||||
LEFT JOIN activity_user_scope aus ON t1.groupId = aus.groupId
|
|
||||||
AND aus.userId = @userId
|
|
||||||
$condition
|
$condition
|
||||||
""");
|
""");
|
||||||
Cnd cnd = Cnd.NEW();
|
Cnd cnd = Cnd.NEW();
|
||||||
@@ -62,8 +61,8 @@ public class HuiminMineController {
|
|||||||
// 添加启用状态过滤(只显示启用的记录)
|
// 添加启用状态过滤(只显示启用的记录)
|
||||||
cnd.and("t1.enable", "=", true);
|
cnd.and("t1.enable", "=", true);
|
||||||
// 添加权限过滤
|
// 添加权限过滤
|
||||||
cnd.and(Cnd.exps("t1.groupId", "is", null).or("aus.groupId", "is not", null));
|
cnd.and(Cnd.exps("t1.groupId", "is", null)
|
||||||
sql.params().set("userId", SecurityUtil.getUserId());
|
.or(new Static("EXISTS (SELECT 1 FROM activity_user_scope aus WHERE aus.groupId = t1.groupId AND aus.userId = '%s')".formatted(SecurityUtil.getUserId()))));
|
||||||
sql.setCondition(cnd);
|
sql.setCondition(cnd);
|
||||||
Pagination pagination = huiminService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
Pagination pagination = huiminService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||||
return Result.success(pagination);
|
return Result.success(pagination);
|
||||||
|
|||||||
Reference in New Issue
Block a user