| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- package com.xintong.visualinspection.controller;
- import java.util.List;
- import javax.servlet.http.HttpServletRequest;
- import javax.validation.Valid;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.http.HttpRequest;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import com.xintong.system.err.BusinessException;
- import com.xintong.visualinspection.bean.Team;
- import com.xintong.visualinspection.bean.User;
- import com.xintong.visualinspection.service.TeamService;
- /**
- * 文件名:TestController
- * 版本信息:日期:2017/3/30 Copyright 江苏省交通规划设计院 Corporation 2017 版权所有.
- */
- @RestController
- @RequestMapping("/team")
- public class TeamController extends BaseController {
- @Autowired
- private TeamService teamService;
-
- /**
- * 添加班组
- * @return
- * String
- * @exception
- * @since 1.0.0
- */
- @RequestMapping(value = "/add")
- public String add(@Valid @RequestBody Team team){
- teamService.insert(team);
- return super.returnSuccessResult("添加成功");
- }
-
- /**
- * 修改班组
- * @return
- * String
- * @exception
- * @since 1.0.0
- */
- @RequestMapping(value = "/update")
- public String update(@Valid @RequestBody Team team){
- teamService.update(team);
- return super.returnSuccessResult("修改成功");
- }
-
- /**
- * 删除班组
- * @return
- * String
- * @exception
- * @since 1.0.0
- */
- @RequestMapping(value = "/delete")
- public String delete(@RequestBody Team team){
- teamService.delete(team.getId());
- return super.returnSuccessResult("删除成功");
- }
-
- /**
- * 通过id获取班组
- * @return
- * String
- * @exception
- * @since 1.0.0
- */
- @RequestMapping(value = "/getTeamById")
- public String getTeamById(@RequestBody Team team){
- if(team.getId()==null){
- throw new BusinessException(20002);
- }
- Team t = teamService.getById(team.getId());
- return super.returnSuccessResult(t);
- }
-
- /**
- * 通过部门id获取班组
- * @return
- * String
- * @exception
- * @since 1.0.0
- */
- @RequestMapping(value = "/getTeamByDeptId/{page}/{size}")
- public String getTeamByDeptId(@RequestBody Team team,@PathVariable Integer page,@PathVariable Integer size,HttpServletRequest request ){
- if(team.getDept_id()==null){
- User u = getCurrentUser(request);
- team.setDept_id(u.getOrganid()+0L);
- }
- PageHelper.startPage(page, size);
- List<Team> teamList = teamService.getList(team) ;
- return super.returnSuccessResult(new PageInfo(teamList));
- }
-
- @RequestMapping(value = "/getTeamByName/{page}/{size}")
- public String getTeamByName(@RequestBody Team team,@PathVariable Integer page,@PathVariable Integer size){
- PageHelper.startPage(page, size);
- List<Team> teamList = teamService.getTeamByName(team);
- return super.returnSuccessResult(new PageInfo(teamList));
- }
- }
|