use of com.cdeledu.core.annotation.SystemLog in project wechat by dllwh.
the class RoleOperateController method updateRoleUser.
@ResponseBody
@RequestMapping("updateRoleUser")
@SystemLog(desc = "角色用户管理", opType = SysOpType.UPDATE, tableName = "sys_user_role")
public AjaxJson updateRoleUser(SysUserRole sysUserRole, @RequestParam(name = "opType", required = true, defaultValue = "0") int opType) {
AjaxJson resultMsg = new AjaxJson();
int userCode = sysUserRole.getUserId();
boolean result = false;
String msg = "";
SysRole sysRole = new SysRole(sysUserRole.getRoleId());
SysRole sysRole2 = null;
try {
sysRole2 = roleService.findOneForJdbc(sysRole);
} catch (Exception e) {
}
if (sysRole2 != null && sysRole2.getIfVisible() == 1) {
if ((opType == 1 || opType == -1) && (userCode > 0)) {
if (opType == 1) {
if (roleService.saveRoleUser(sysUserRole)) {
result = true;
msg = MessageConstant.MSG_OPERATION_SUCCESS;
} else {
msg = MessageConstant.MSG_OPERATION_FAILED;
}
} else {
if (sysUserRole.getRoleId() == 1 && sysUserRole.getUserId() == 1) {
msg = "错误提示:超级管理员账号不能删除";
} else {
if (roleService.delRoleUser(sysUserRole)) {
result = true;
msg = MessageConstant.MSG_OPERATION_SUCCESS;
} else {
msg = MessageConstant.MSG_OPERATION_FAILED;
}
}
}
}
} else {
msg = "错误提示:该角色尚未使用,无法操作";
}
resultMsg.setSuccess(result);
resultMsg.setMsg(msg);
return resultMsg;
}
use of com.cdeledu.core.annotation.SystemLog in project wechat by dllwh.
the class RoleOperateController method saveRole.
@ResponseBody
@RequestMapping(value = "saveRole")
@SystemLog(desc = "角色更新", opType = SysOpType.UPDATE, tableName = "sys_role")
public AjaxJson saveRole(HttpServletRequest request, HttpServletResponse response, SysRole role) {
AjaxJson resultMsg = new AjaxJson();
String msg = "";
try {
if (null != role) {
String roleCode = role.getRoleCode();
SysRole seacherRole = roleService.getRoleById(role.getId());
if (seacherRole != null && seacherRole.getAllowEdit() == 1) {
// 角色允许编辑
if (seacherRole.getRoleCode().equalsIgnoreCase(roleCode)) {
if (seacherRole.getId() == 1) {
// 超级管理员不允许更新角色代码
role.setRoleCode("");
}
roleService.update(role);
} else {
if (roleService.existRoleWithRoleCode(roleCode)) {
resultMsg.setSuccess(false);
msg = MessageConstant.EXISTED;
} else {
roleService.update(role);
}
}
} else {
resultMsg.setSuccess(false);
resultMsg.setResultCode(201);
resultMsg.setMsg("该角色不允许更新");
}
}
} catch (Exception e) {
resultMsg.setSuccess(false);
resultMsg.setResultCode(500);
msg = MessageConstant.MSG_OPERATION_FAILED;
}
resultMsg.setMsg(msg);
return resultMsg;
}
use of com.cdeledu.core.annotation.SystemLog in project wechat by dllwh.
the class SysUserOperateController method updateUserEnable.
@ResponseBody
@RequestMapping("enable")
@SystemLog(desc = " 启用账户", opType = SysOpType.UPDATE, tableName = { "sys_user" })
public AjaxJson updateUserEnable(int userId) {
AjaxJson resultMsg = new AjaxJson();
SysUser user = new SysUser();
user.setId(userId);
try {
SysUser sysUser = manageruserService.findOneForJdbc(user);
// 超级管理员不能操作
if (sysUser != null && sysUser.getUserType() != -1 && WebUtilHelper.getCurrentUserId() != userId) {
sysUser.setIfVisible(1);
manageruserService.update(sysUser);
}
resultMsg.setMsg(MessageConstant.MSG_OPERATION_SUCCESS);
} catch (Exception e) {
e.printStackTrace();
resultMsg.setSuccess(false);
resultMsg.setResultCode(500);
resultMsg.setMsg(MessageConstant.MSG_OPERATION_FAILED);
}
return resultMsg;
}
use of com.cdeledu.core.annotation.SystemLog in project wechat by dllwh.
the class SysUserOperateController method saveRoleUser.
/**
* @方法描述: 用户-角色录入
* @创建者: 皇族灬战狼
* @创建时间: 2016年9月27日 下午4:51:27
* @param managerUser
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "roleAssign", params = "saveRoleUser")
@SystemLog(desc = "用户-角色录入(授权)", opType = SysOpType.INSERT, tableName = "sys_user_role")
public AjaxJson saveRoleUser(@RequestParam(value = "userCode", required = true) int id, @RequestParam(value = "roleID", defaultValue = "1", required = false) int roleID) {
AjaxJson resultMsg = new AjaxJson();
SysUser user = new SysUser();
user.setId(id);
try {
if (roleID == 1) {
// 超级管理员不参与分配
resultMsg.setSuccess(false);
resultMsg.setMsg("无法授予权限");
}
SysUser tSUser = manageruserService.findOneForJdbc(user);
if (null == tSUser) {
resultMsg.setMsg("不存在");
resultMsg.setSuccess(false);
} else {
SysUserRole managerUserRole = new SysUserRole();
managerUserRole.setUserId(tSUser.getId());
managerUserRole.setRoleId(roleID);
manageruserService.saveRoleUser(managerUserRole);
}
} catch (Exception e) {
resultMsg.setResultCode(500);
resultMsg.setMsg("分配角色时出现异常");
resultMsg.setSuccess(false);
}
return resultMsg;
}
use of com.cdeledu.core.annotation.SystemLog in project wechat by dllwh.
the class SysUserOperateController method clearRoleByUserIds.
/**
* @方法描述: 根据用户id清空角色
* @return
*/
@ResponseBody
@RequestMapping(value = "roleAssign", params = "clearRoleUser")
@SystemLog(desc = "用户-角色(解除授权)", opType = SysOpType.INSERT, tableName = "sys_user")
public AjaxJson clearRoleByUserIds(SysUserRole sysUserRole) {
AjaxJson resultMsg = new AjaxJson();
if (sysUserRole.getUserId() != null) {
if (WebUtilHelper.getCurrentUserId() != sysUserRole.getUserId()) {
try {
manageruserService.deleteUserRole(sysUserRole);
} catch (Exception e) {
e.printStackTrace();
resultMsg.setSuccess(false);
resultMsg.setResultCode(500);
resultMsg.setMsg(MessageConstant.MSG_OPERATION_FAILED);
}
} else {
resultMsg.setSuccess(false);
resultMsg.setResultCode(500);
resultMsg.setMsg("不能解除当前用户权限");
}
}
// 超级管理员不能删除
return resultMsg;
}
Aggregations