package com.lyms.cm.controller.sys; 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.cm.entity.sys.SysRoles; import com.lyms.cm.service.sys.SysRolesService; import com.lyms.constants.OperationName; 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 SysRolesService sysRolesService; @RequestMapping("/toList") public String list() { return "/role/role_list"; } @RequestMapping(value = "/getRoleList", method = { RequestMethod.POST }) @ResponseBody public java.util.Map getRoleList() { Page page = getPage(); EntityWrapper ew = new EntityWrapper(); ew.where("ifDel=0"); return toGridData(sysRolesService.selectPage(page,ew)); } /** * 跳转到编辑页面 * * @return */ @RequestMapping(value = { "/{id}/toEdit" }, method = RequestMethod.GET) public String toEdit(@PathVariable String id, Model model) { if (!StringUtils.isBlank(id) && !"0".equals(id)) { SysRoles role = sysRolesService.selectById(id); model.addAttribute("role", role); } return "/role/role_edit"; } /** * 创建用户 *

* TODO * * @param user * @return */ @RequestMapping(value = "/create", method = RequestMethod.POST) @ResponseBody public AjaxResult create(SysRoles role, AjaxResult ajaxResult) { role.setId(StrUtils.uuid()); role.setIfdel(0); boolean tag = sysRolesService.insert(role); return handleAjaxResult(ajaxResult, tag, OperationName.CREATE); } /** * 修改信息 */ @RequestMapping(value = "/update", method = { RequestMethod.POST }) @ResponseBody public AjaxResult update(SysRoles role, AjaxResult ajaxResult) { boolean tag = sysRolesService.updateById(role); 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); } }