package com.lyms.cm.controller.sys; import java.util.List; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.plugins.Page; import com.lyms.base.common.entity.role.Permissions; import com.lyms.base.common.entity.role.RolePermissionMaps; import com.lyms.base.common.entity.role.Roles; import com.lyms.base.common.service.role.PermissionsService; import com.lyms.base.common.service.role.RolePermissionMapsService; import com.lyms.base.common.service.role.RolesService; import com.lyms.constants.OperationName; import com.lyms.util.InstanceUtils; import com.lyms.util.StrUtils; import com.lyms.web.bean.AjaxResult; import com.lyms.web.controller.BaseController; /** *
* 角色表 前端控制器 *
* * @author maliang * @since 2017-03-02 */ @Controller @RequestMapping("/sysRoles") public class SysRolesController extends BaseController { @Autowired private RolesService sysRolesService; @Autowired private PermissionsService sysPermissionsService; @Autowired private RolePermissionMapsService sysRolePermissionMapsService; @RequestMapping("/toList") public String list() { return "/role/role_list"; } @RequestMapping(value = { "/treeTest" }, method = RequestMethod.GET) public String treeTest(Model model) { return "/role/tree_test"; } @RequestMapping(value = "/getRoleList", method = { RequestMethod.POST }) @ResponseBody public java.util.Map* TODO * * @param user * @return */ @RequestMapping(value = "/create", method = RequestMethod.POST) @ResponseBody public AjaxResult create(Roles role, AjaxResult ajaxResult) { boolean tag = false; String roleId = StrUtils.uuid(); role.setId(roleId); role.setIfdel(0); if (null == role.getEnable()) { role.setEnable(1); } tag = sysRolesService.createRole(role, getRolePermissionList(roleId, getParameter("resource"))); return handleAjaxResult(ajaxResult, tag, OperationName.CREATE); } /** * 修改信息 */ @RequestMapping(value = "/update", method = { RequestMethod.POST }) @ResponseBody public AjaxResult update(Roles role, AjaxResult ajaxResult) { boolean tag = false; if (null == role.getEnable()) { role.setEnable(1); } tag = sysRolesService.updateRole(role, getRolePermissionList(role.getId(), getParameter("resource"))); return handleAjaxResult(ajaxResult, tag, OperationName.UPDATE); } /** * 删除用户 * * @return */ @RequestMapping(value = "/{id}/delete", method = { RequestMethod.GET, RequestMethod.POST }) @ResponseBody public AjaxResult delete(@PathVariable String id, AjaxResult ajaxResult) { int tag = sysRolesService.deleteLogicById(id); return handleAjaxResult(ajaxResult, tag, OperationName.DELETE); } /** *