后台使用了 SQL 语句, 查出COUNT==0时,可以添加用户,否则抛出异常, 然后就不会写了,怎么关联到前台? 麻烦大神说的详细点,新手。结贴快。
public void check(Role role){
String role_code=role.getRole_code();
int count=roleDao.countCondition(role_code);
if(count<=0){
if(!role.getId().equals("")){
roleDao.update(role);
}
else{
roleDao.insert(role);
}
}
else{
throw new RoleException("角色代码已存在!");
}
}