以唯一约束为例:
try {
flag = operateMenuMapper.insert(po);
} catch (Exception e) {
Throwable cause = e.getCause();
if(cause instanceof java.sql.SQLIntegrityConstraintViolationException){
log.info("title 字段违反唯一约束条件");
return new Result(1,0,"添加的菜单已存在,请勿重复添加!",null);
}
e.printStackTrace();
}