/**
* 修改角色 (可以判断是否已经存在角色代码)
* @param role
* @return
*/
@PostMapping("updateByCond")
public String updateByCond(Role role) {
try {
Role roles = roleMapper.selectByPrimaryKey(role.getUuid()); //用id 查询该角色
String sss=role.getRoleCode();
String aaa=roles.getRoleCode();
if ( sss.equals(aaa)){ //如果传回来的编码等于已经拥有的编码则继续修改操作
role.setUpdateTime(DateUtils.getCurrentDateTime());
int result = roleMapper.updateByPrimaryKeySelective(role); //修改
if (result > 0) {
return JsonUtil.toJSON(new JKResponse(Constant.CODE_SUCCESS));修改成功
} else {
return JsonUtil.toJSON(new JKResponse(Constant.UPDATE_ERR_MSG));//操作失败
}
}else { //如果传回来的编码不等于已经拥有的编码则判断编码是否存在,
Role rse = roleMapper.selectByCond(role.getRoleCode());
if (!EmptyUtil.isEmpty(rse)) {
return JsonUtil.toJSON(new JKResponse(Constant.CODE_DATA_IS_EXIST)); //判断是否已经拥有值
如果存在返回611,
} else {不存在则进行修改
role.setUpdateTime(DateUtils.getCurrentDateTime());
int result = roleMapper.updateByPrimaryKeySelective(role);//修改
if (result > 0) {
return JsonUtil.toJSON(new JKResponse(Constant.CODE_SUCCESS)); 修改成功
} else {
return JsonUtil.toJSON(new JKResponse(Constant.UPDATE_ERR_MSG)); //操作失败
}
}
}
}catch (Exception e){
e.printStackTrace();
log.error(ExceptionUtil.detail(e));
return JsonUtil.toJSON(new JKResponse(Constant.CODE_SYSTEM_ERROR)); //系统异常
}
}
判断是否已经存在该数据
最新推荐文章于 2023-01-06 17:29:42 发布
1445

被折叠的 条评论
为什么被折叠?



