NutzCN Logo
问答 cnd.and(),查询条件字段名重用怎么办?
发布于 2410天前 作者 Nooft 1678 次浏览 复制 上一个帖子 下一个帖子
标签:
AND fc.facility_type NOT IN (
	'停车场',
	'旅客服务中心',
	'购物场所',
	'旅游厕所'
)
AND fc.facility_type='酒店'
6 回复

还能怎么办?你传的条件就这样

这个是我单独写的sql,我需求是这样。
我写的代码中,字段名相同会覆盖,难道是我代码原因?

覆盖是啥意思?没懂

params.put("fc.facility_type", FunctionUtils.Cond("not in", facilityTypeList));
params.put("fc.facility_type", FunctionUtils.Cond("=", facilityTyp));

public static Cnd MapToCnd(Map<String, CndType> map) {
		Cnd result = Cnd.where("1", "=", 1);
		map.forEach((k, v) -> {
			if (v.getType().equals("likeRight")) {
				result.and(k, "like", v.getDate() + "%");
			}else if (v.getType().equals("like")) {
				result.and(k, "like", "%" + v.getDate() + "%");
			} else if (v.getType().equals("desc")) {
				result.desc(k);
			} else if (v.getType().equals("asc")) {
				result.asc(k);
			} else if (v.getType().equals("in")) {
				result.and(k, "in", v.getDate());
			} else if (v.getType().equals("or")) {
				result.or(k, "=", v.getDate());
			} else if (v.getType().equals("between")) {
				result.and(k, ">=", "1").and(k, "<=", v.getDate());
			} else if (v.getType().equals("lessThan")) {
				result.and(k, "<=", v.getDate());
			} else if (v.getType().equals("not in")) {
				result.and(k, "not in", v.getDate());
			} else {
				result.and(k, v.getType(), v.getDate());
			}
		});
		return result;
	}

我知道了,糗大了

添加回复
请先登陆
回到顶部