package com.securitycontrol.background.controller;

import com.securitycontrol.background.service.TeamService;
import com.securitycontrol.common.core.web.controller.BaseController;
import com.securitycontrol.common.core.web.domain.AjaxResult;
import com.securitycontrol.common.core.web.page.TableDataInfo;
import com.securitycontrol.common.log.annotation.Log;
import com.securitycontrol.common.log.enums.OperationType;
import com.securitycontrol.entity.background.dto.ParamDto;
import com.securitycontrol.entity.background.vo.HumanManageVo;
import com.securitycontrol.entity.background.vo.TeamManageVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 人员管理
 *
 * @author jsk
 */
@RequestMapping(value = "/back/workTeam/")
@RestController
public class TeamManageController extends BaseController {

    @Resource(name = "TeamService")
    private TeamService service;

    @ApiOperation(value = "获取班组列表")
    @GetMapping("getTeamLists")
    @Log(title = "人员管理", menu = "人员管理->班组管理", grade = OperationType.QUERY_BUSINESS, details = "查询班组", type = "业务日志")
    public TableDataInfo getTeamLists(ParamDto dto) {
        startPage();
        List<TeamManageVo> list = service.getTeamLists(dto);
        return getDataTable(list);
    }

    @ApiOperation(value = "新增班组")
    @PostMapping("addTeam")
    @Log(title = "人员管理", menu = "人车管理->班组管理", grade = OperationType.ADD_BUSINESS, details = "新增班组", type = "业务日志")
    public AjaxResult addTeam(@RequestBody TeamManageVo vo) {
        return service.addOrUpdateTeam(vo);
    }

    @ApiOperation(value = "修改班组")
    @PostMapping("editTeam")
    @Log(title = "人员管理", menu = "人车管理->班组管理", grade = OperationType.UPDATE_BUSINESS, details = "修改班组", type = "业务日志")
    public AjaxResult editTeam(@RequestBody TeamManageVo vo) {
        return service.addOrUpdateTeam(vo);
    }

    @ApiOperation(value = "班组详情")
    @GetMapping("getTeamDetailById")
    public AjaxResult getTeamDetailById(ParamDto dto) {
        return service.getTeamDetailById(dto);
    }

    @ApiOperation(value = "删除班组")
    @PostMapping("delTeam")
    @Log(title = "人员管理", menu = "人车管理->班组管理", grade = OperationType.DELETE_BUSINESS, details = "删除班组", type = "业务日志")
    public AjaxResult delTeam(@RequestBody ParamDto dto) {
        return service.delTeam(dto);
    }

    @ApiOperation(value = "获取班组人员列表")
    @GetMapping("getTeamUserLists")
    @Log(title = "人员管理", menu = "人员管理->班组管理", grade = OperationType.QUERY_BUSINESS, details = "查询班组人员", type = "业务日志")
    public TableDataInfo getTeamUserLists(ParamDto dto) {
        startPage();
        List<HumanManageVo> list = service.getTeamUserLists(dto);
        return getDataTable(list);
    }

    @ApiOperation(value = "移出班组人员")
    @PostMapping("removeTeamUser")
    @Log(title = "人员管理", menu = "人员管理->班组管理", grade = OperationType.UPDATE_BUSINESS, details = "移出班组人员", type = "业务日志")
    public AjaxResult removeTeamUser(@RequestBody ParamDto dto) {
        return service.removeTeamUser(dto);
    }

    @ApiOperation(value = "获取班组组员和未加入班组人员")
    @GetMapping("getTeamUserAndNoBandingUser")
    public AjaxResult getTeamUserAndNoBandingUser(ParamDto dto) {
        return service.getTeamUserAndNoBandingUser(dto);
    }

    @ApiOperation(value = "添加班组人员")
    @PostMapping("addTeamUser")
    @Log(title = "人员管理", menu = "人员管理->班组管理", grade = OperationType.ADD_BUSINESS, details = "添加班组人员", type = "业务日志")
    public AjaxResult addTeamUser(@RequestBody ParamDto dto) {
        return service.addTeamUser(dto);
    }
}
