TeamController.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. package com.xintong.visualinspection.controller;
  2. import java.util.List;
  3. import javax.servlet.http.HttpServletRequest;
  4. import javax.validation.Valid;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.http.HttpRequest;
  7. import org.springframework.web.bind.annotation.PathVariable;
  8. import org.springframework.web.bind.annotation.RequestBody;
  9. import org.springframework.web.bind.annotation.RequestMapping;
  10. import org.springframework.web.bind.annotation.RestController;
  11. import com.github.pagehelper.PageHelper;
  12. import com.github.pagehelper.PageInfo;
  13. import com.xintong.system.err.BusinessException;
  14. import com.xintong.visualinspection.bean.Team;
  15. import com.xintong.visualinspection.bean.User;
  16. import com.xintong.visualinspection.service.TeamService;
  17. /**
  18. * 文件名:TestController
  19. * 版本信息:日期:2017/3/30 Copyright 江苏省交通规划设计院 Corporation 2017 版权所有.
  20. */
  21. @RestController
  22. @RequestMapping("/team")
  23. public class TeamController extends BaseController {
  24. @Autowired
  25. private TeamService teamService;
  26. /**
  27. * 添加班组
  28. * @return
  29. * String
  30. * @exception
  31. * @since 1.0.0
  32. */
  33. @RequestMapping(value = "/add")
  34. public String add(@Valid @RequestBody Team team){
  35. teamService.insert(team);
  36. return super.returnSuccessResult("添加成功");
  37. }
  38. /**
  39. * 修改班组
  40. * @return
  41. * String
  42. * @exception
  43. * @since 1.0.0
  44. */
  45. @RequestMapping(value = "/update")
  46. public String update(@Valid @RequestBody Team team){
  47. teamService.update(team);
  48. return super.returnSuccessResult("修改成功");
  49. }
  50. /**
  51. * 删除班组
  52. * @return
  53. * String
  54. * @exception
  55. * @since 1.0.0
  56. */
  57. @RequestMapping(value = "/delete")
  58. public String delete(@RequestBody Team team){
  59. teamService.delete(team.getId());
  60. return super.returnSuccessResult("删除成功");
  61. }
  62. /**
  63. * 通过id获取班组
  64. * @return
  65. * String
  66. * @exception
  67. * @since 1.0.0
  68. */
  69. @RequestMapping(value = "/getTeamById")
  70. public String getTeamById(@RequestBody Team team){
  71. if(team.getId()==null){
  72. throw new BusinessException(20002);
  73. }
  74. Team t = teamService.getById(team.getId());
  75. return super.returnSuccessResult(t);
  76. }
  77. /**
  78. * 通过部门id获取班组
  79. * @return
  80. * String
  81. * @exception
  82. * @since 1.0.0
  83. */
  84. @RequestMapping(value = "/getTeamByDeptId/{page}/{size}")
  85. public String getTeamByDeptId(@RequestBody Team team,@PathVariable Integer page,@PathVariable Integer size,HttpServletRequest request ){
  86. if(team.getDept_id()==null){
  87. User u = getCurrentUser(request);
  88. team.setDept_id(u.getOrganid()+0L);
  89. }
  90. PageHelper.startPage(page, size);
  91. List<Team> teamList = teamService.getList(team) ;
  92. return super.returnSuccessResult(new PageInfo(teamList));
  93. }
  94. @RequestMapping(value = "/getTeamByName/{page}/{size}")
  95. public String getTeamByName(@RequestBody Team team,@PathVariable Integer page,@PathVariable Integer size){
  96. PageHelper.startPage(page, size);
  97. List<Team> teamList = teamService.getTeamByName(team);
  98. return super.returnSuccessResult(new PageInfo(teamList));
  99. }
  100. }