代码
Cnd cnd = Cnd.where("delFlag", "=", 0);
if (!Strings.isBlank(categoryId)){
cnd.and("categoryId", "=", categoryId);
}else{
List<String> categroyIds = aclService.findCategoryIdsByUserId(userId);
cnd.and("categoryId", "in", categroyIds);
}
if("audit".equals(type)){
if(!Lang.isEmpty(isAudit)){
cnd.and("isAudit","=",isAudit);
}
if(!Lang.isEmpty(auditStatus)){
cnd.and("auditStatus","=",auditStatus);
}
cnd.and("auditorId", "=", userId);
}else if("me".equals(type)){
//查询自己发布的或者审核人为自己的,不关心审核状态
cnd.and("publisherId", "=", userId).or("auditorId", "=", userId);
}
打印出的语句是
SELECT * FROM cms_content WHERE delFlag=0 AND categoryId='874dd4c5d0184710bbdfc6d72a45c4fe' AND publisherId='c629a5d1eb3748289dfeb325a5fe8e5c' OR auditorId='c629a5d1eb3748289dfeb325a5fe8e5c'
我想要的是
SELECT * FROM cms_content WHERE delFlag=0 AND categoryId='874dd4c5d0184710bbdfc6d72a45c4fe' AND (publisherId='c629a5d1eb3748289dfeb325a5fe8e5c' OR auditorId='c629a5d1eb3748289dfeb325a5fe8e5c')
不然结果不正确。