use of com.cdeledu.common.base.AjaxJson in project wechat by dllwh.
the class MenuOperateController method delMenu.
/**
* @方法描述: 删除菜单,根据ID,但是删除权限的时候,需要查询是否有赋予给角色,如果有角色在使用,那么就不能删除。
* @param menu
* @return
*/
@ResponseBody
@RequestMapping(value = "del")
@SystemLog(desc = "删除权限菜单", opType = SysOpType.DEL, tableName = "sys_menu,sys_role_menu")
public AjaxJson delMenu(SysMenu sysMenu) {
AjaxJson ajaxJson = new AjaxJson();
try {
Integer id = sysMenu.getId();
SysMenu menu = sysMenuService.findOneById(id);
if (menu != null && menu.getAllowDelete() == 1) {
// 删除权限菜单时先删除权限菜单与角色之间关联表信息
if (sysMenuService.hasRole(id)) {
ajaxJson.setSuccess(false);
ajaxJson.setMsg(MessageConstant.MSG_HAS_CHILD);
} else {
if (sysMenuService.hasChildren(id)) {
// 子节点
ajaxJson.setSuccess(false);
ajaxJson.setMsg(MessageConstant.MSG_HAS_CHILD);
} else {
sysMenuService.delete(id);
ajaxJson.setMsg(MessageConstant.SUCCESS_DELETE_MESSAGE);
}
}
} else {
ajaxJson.setSuccess(false);
ajaxJson.setMsg(MessageConstant.SUCCESS_DELETE_MESSAGE);
}
} catch (Exception e) {
ajaxJson.setSuccess(false);
ajaxJson.setResultCode(500);
ajaxJson.setMsg(MessageConstant.FAILURE_DELETE_MESSAGE);
}
return ajaxJson;
}
use of com.cdeledu.common.base.AjaxJson in project wechat by dllwh.
the class RoleOperateController method addRole.
/**
* ----------------------------------------------------- Fields end
*/
/**
* @方法描述 : 角色创建的时候,必须要自动添加到管理员下,保证管理员的权限是最大最全的
* @param role
* @return
*/
@ResponseBody
@RequestMapping(value = "addRole", method = RequestMethod.POST)
@SystemLog(desc = "角色添加", opType = SysOpType.INSERT, tableName = "sys_role")
public AjaxJson addRole(SysRole role) {
AjaxJson resultMsg = new AjaxJson();
try {
if (roleService.existRoleWithRoleCode(role.getRoleCode())) {
resultMsg.setSuccess(false);
resultMsg.setMsg(MessageConstant.EXISTED);
resultMsg.setResultCode(201);
} else {
roleService.insert(role);
}
} catch (Exception e) {
e.printStackTrace();
resultMsg.setSuccess(false);
resultMsg.setMsg(MessageConstant.FAILURE_SAVE_MESSAGE);
resultMsg.setResultCode(500);
}
return resultMsg;
}
use of com.cdeledu.common.base.AjaxJson in project wechat by dllwh.
the class RoleOperateController method updateMenuByRole.
@ResponseBody
@RequestMapping(value = "updateMenuByRole")
@SystemLog(desc = "更新角色的权限", opType = SysOpType.UPDATE, tableName = "sys_role_menu")
public AjaxJson updateMenuByRole(Integer roleId, String ids) {
AjaxJson ajaxJson = new AjaxJson();
if (roleId != null && StringUtils.isNoneBlank(ids)) {
if (roleId != 1) {
roleService.delRoleAccess(roleId);
String[] str = ids.split(",");
for (int i = 0; i < str.length; i++) {
try {
roleService.saveRoleAccess(roleId, Integer.parseInt(str[i]));
} catch (Exception e) {
e.printStackTrace();
}
}
} else {
ajaxJson.setSuccess(false);
ajaxJson.setResultCode(10005);
ajaxJson.setMsg("该资源需要appkey拥有授权");
}
} else {
ajaxJson.setSuccess(false);
ajaxJson.setResultCode(10006);
ajaxJson.setMsg("缺少source (appkey) 参数");
}
return ajaxJson;
}
use of com.cdeledu.common.base.AjaxJson in project wechat by dllwh.
the class SysUserOperateController method delUser.
/**
* @方法描述: 用户删除
* @创建者: 皇族灬战狼
* @创建时间: 2016年9月27日 下午4:51:19
* @param managerUser
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "deleteUser")
public AjaxJson delUser(@RequestParam(value = "id", required = true, defaultValue = "-1") Integer id) {
AjaxJson resultMsg = new AjaxJson();
try {
if (id != 1) {
SysUser sysUser = new SysUser();
sysUser.setId(id);
List<SysUserRole> userRoleList = manageruserService.getUserRole(sysUser);
if (userRoleList == null || userRoleList.isEmpty() || userRoleList.size() == 0) {
manageruserService.delete(id);
resultMsg.setMsg(MessageConstant.MSG_OPERATION_SUCCESS);
} else {
resultMsg.setSuccess(false);
resultMsg.setMsg("删除失败,该用户已分配角色");
}
} else {
resultMsg.setSuccess(false);
resultMsg.setResultCode(403);
resultMsg.setMsg("无法删除超级管理员账号");
}
} catch (Exception e) {
resultMsg.setSuccess(false);
resultMsg.setResultCode(10001);
resultMsg.setMsg(MessageConstant.MSG_OPERATION_SUCCESS);
}
return resultMsg;
}
use of com.cdeledu.common.base.AjaxJson in project wechat by dllwh.
the class SysUserOperateController method updateUserDisable.
@ResponseBody
@RequestMapping("disable")
@SystemLog(desc = " 禁用账户", opType = SysOpType.UPDATE, tableName = { "sys_user" })
public AjaxJson updateUserDisable(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(0);
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;
}
Aggregations