TeamController.java 2.5 KB

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