SysUsersController.java 2.8 KB
   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
package com.lyms.cm.controller.sys;

import java.util.Map;

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.plugins.Page;
import com.lyms.cm.entity.sys.SysUsers;
import com.lyms.cm.service.sys.SysUsersService;
import com.lyms.constants.OperationName;
import com.lyms.web.bean.AjaxResult;
import com.lyms.web.controller.BaseController;

/**
* <p>
* 用户表 前端控制器
* </p>
*
* @author maliang
* @since 2017-03-02
*/
@Controller
@RequestMapping("/sysUsers")
public class SysUsersController extends BaseController {

@Autowired
private SysUsersService userService;

/**
* 创建用户
* <p>
* TODO
*
* @param user
* @return
*/
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public AjaxResult create(SysUsers user, AjaxResult ajaxResult) {
boolean tag = userService.updateUser(user);
return handleAjaxResult(ajaxResult, tag, OperationName.UPDATE);
}

/**
* 跳转到用户列表页面
*
* @return
*/
@RequestMapping(value = "/toList", method = { RequestMethod.GET })
public String toList() {
return "/user/user_list";
}

/**
* 用户列表
*
* @param page
* @param model
* @return
*/
@RequestMapping(value = "/list", method = { RequestMethod.POST, RequestMethod.GET })
@ResponseBody
public Map<String, Object> list(Model model) {
Page<SysUsers> page = getPage();
page = userService.getUserByPage(page);
return toGridData(page);
}

/**
* 跳转到编辑页面
*
* @return
*/
@RequestMapping(value = { "/{id}/toEdit" }, method = RequestMethod.GET)
public String toEdit(@PathVariable String id, Model model) {
SysUsers user = userService.getUserById(id);
model.addAttribute("user", user);
return "/user/user_edit";
}

/**
* 修改信息
*/
@RequestMapping(value = "/edit", method = { RequestMethod.POST })
@ResponseBody
public AjaxResult update(SysUsers user, AjaxResult ajaxResult) {
boolean tag = userService.updateUser(user);
return handleAjaxResult(ajaxResult, tag, OperationName.UPDATE);

}

/**
* 删除用户
*
* @return
*/
@RequestMapping(value = "/{id}/delete", method = { RequestMethod.GET, RequestMethod.POST })
@ResponseBody
public AjaxResult del(@PathVariable String id, AjaxResult ajaxResult) {
boolean tag = userService.delete(id);
return handleAjaxResult(ajaxResult, tag, OperationName.DELETE);
}

}