小白请教联合校验的写法
一个大好人 发布于67月前 4答/1494阅

举例:我希望字段A和字段B通过联合校验确定唯一性,录入过程中如果重复就提示。
希望能有完整的代码实例


[沙发] maapple
	public String addBefore(AopContext ac) throws Exception {
//这里可以做手机以及邮箱的验证 为了方便只做昵称唯一的处理

String A= ac.record.getStr("A");
String B= ac.record.getStr("B");
Record table = Db.findFirst("select * from table where A=? and B = ?",A,B);
if (table !=null) {
return Easy.error("禁止重复添加!");
}
return super.addBefore(ac);
}
最佳
[地板] maapple
@一个大好人 可以做保存校验,使用eova的拦截器实现
[地毯] 一个大好人
@maapple  谢谢 我等找机会使用下
[4楼] Jieven
@一个大好人 还可以用远程校验
提交评论
嘿,我来帮你!