package com.qy.worksheetsystem.controller;

import com.qy.worksheetsystem.model.MessageResult;
import com.qy.worksheetsystem.util.JWTUtil;
import com.qy.worksheetsystem.vo.InsertJobWorkingVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/work/project/")
@Api(value = "项目管理、项目人员管理",tags="项目管理、项目人员管理")
public class ProjectController {

    @ApiOperation(value = "获取员工有效项目列表", notes = "获取员工有效项目列表")
    @RequestMapping(value = "/getProjectList", method = RequestMethod.GET)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
            @ApiImplicitParam(name = "projectName", value = "项目名称", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "state", value = "项目状态",  paramType = "query", dataType = "String"),
    })
    public MessageResult getProjectList(@RequestHeader("token") String token, String projectName,String state) {

        String number = JWTUtil.getCacheNumber(token);
        if (StringUtils.isEmpty(number)) {
            return MessageResult.error("token异常");
        }

        return MessageResult.success().add("projectName",projectName).add("state",state);
    }

    @ApiOperation(value = "获取员工时间范围内项目列表", notes = "获取员工时间范围内项目列表")
    @RequestMapping(value = "/getProjectByTimeList", method = RequestMethod.GET)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
            @ApiImplicitParam(name = "beginTime", value = "开始时间yyyy-MM-dd", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "endTime", value = "结束时间yyyy-MM-dd", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "state", value = "项目状态",  paramType = "query", dataType = "String"),
    })
    public MessageResult getProjectByTimeList(@RequestHeader("token") String token, String beginTime,String endTime,String state) {

        String number = JWTUtil.getCacheNumber(token);
        if (StringUtils.isEmpty(number)) {
            return MessageResult.error("token异常");
        }

        return MessageResult.success().add("beginTime",beginTime).add("endTime",endTime).add("state",state);
    }

    @ApiOperation(value = "获取项目里面员工详情", notes = "获取项目里面员工详情")
    @RequestMapping(value = "/getPersonListByProject", method = RequestMethod.GET)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
            @ApiImplicitParam(name = "id", value = "项目id", required = true, paramType = "query", dataType = "String"),
    })
    public MessageResult getPersonListByProject(@RequestHeader("token") String token, String id) {

        String number = JWTUtil.getCacheNumber(token);
        if (StringUtils.isEmpty(number)) {
            return MessageResult.error("token异常");
        }
        return MessageResult.success().add("id",id);
    }

    @ApiOperation(value = "获取项目里员工启用或禁用", notes = "获取项目里员工启用或禁用")
    @RequestMapping(value = "/enableDisablePerson", method = RequestMethod.POST)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
            @ApiImplicitParam(name = "personID", value = "员工ID", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "projectID", value = "项目ID", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "state", value = "true启用，false禁用", required = true, paramType = "query", dataType = "Boolean"),
    })
    public MessageResult enableDisablePerson(@RequestHeader("token") String token, String personID, String projectID, Boolean state) {

        String number = JWTUtil.getCacheNumber(token);
        if (StringUtils.isEmpty(number)) {
            return MessageResult.error("token异常");
        }
        return MessageResult.success().add("personID",personID).add("projectID",projectID).add("state",state);
    }

    @ApiOperation(value = "项目里员工添加员工", notes = "项目里员工添加员工")
    @RequestMapping(value = "/addProjectPerson", method = RequestMethod.POST)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
            @ApiImplicitParam(name = "personID", value = "员工ID", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "projectID", value = "项目ID", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "projectRoleID", value = "项目角色", required = true, paramType = "query", dataType = "String"),
    })
    public MessageResult addProjectPerson(@RequestHeader("token") String token, String personID, String projectID, String projectRoleID) {

        String number = JWTUtil.getCacheNumber(token);
        if (StringUtils.isEmpty(number)) {
            return MessageResult.error("token异常");
        }
        return MessageResult.success().add("personID",personID).add("projectID",projectID).add("String",projectRoleID);
    }

    @ApiOperation(value = "选择员工列表", notes = "选择员工列表")
    @RequestMapping(value = "/getPersonList", method = RequestMethod.GET)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
            @ApiImplicitParam(name = "projectID", value = "项目ID", required = true, paramType = "query", dataType = "String"),
    })
    public MessageResult getPersonList(@RequestHeader("token") String token, String projectID) {

        String number = JWTUtil.getCacheNumber(token);
        if (StringUtils.isEmpty(number)) {
            return MessageResult.error("token异常");
        }
        return MessageResult.success().add("projectID",projectID);
    }

    @ApiOperation(value = "选择项目角色列表", notes = "选择项目角色列表")
    @RequestMapping(value = "/getProjectRoleList", method = RequestMethod.GET)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
            @ApiImplicitParam(name = "projectID", value = "项目ID", required = true, paramType = "query", dataType = "String"),
    })
    public MessageResult getProjectRoleList(@RequestHeader("token") String token, String projectID) {

        String number = JWTUtil.getCacheNumber(token);
        if (StringUtils.isEmpty(number)) {
            return MessageResult.error("token异常");
        }
        return MessageResult.success().add("projectID",projectID);
    }

}