package pwc.taxtech.atms.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.taxadmin.ProjectStatusManageDto;
import pwc.taxtech.atms.entity.ProjectStatusManage;
import pwc.taxtech.atms.service.impl.IdentityServiceImpl;
import pwc.taxtech.atms.service.impl.ProjectStatusManageServiceImpl;

@RestController
@RequestMapping("/api/v1/ProjectStatusManage")
public class ProjectStatusManageController {

    @Autowired
    private ProjectStatusManageServiceImpl projectStatusManageService;

    @Autowired
    private IdentityServiceImpl identityService;

//    @ApiOperation(value = "setProjectStatus", notes = "")
    @RequestMapping(value = {"/setProjectStatus/{projectId}/{periodId}/{status}"}, method = RequestMethod.GET,
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public OperationResultDto<ProjectStatusManageDto> setProjectStatus(@PathVariable("projectId") String projectId,
                                                                       @PathVariable("periodId") Integer periodId,
                                                                       @PathVariable("status") Integer status) {
        return projectStatusManageService.setProjectStatus(projectId, periodId, status, identityService.getIdentityUser().getId());
    }


//    @ApiOperation(value = "getProjectStatus", notes = "")
    @RequestMapping(value = {"getProjectStatus/{projectId}/{periodId}"}, method = RequestMethod.GET,
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public OperationResultDto<ProjectStatusManageDto> getProjectStatus(@PathVariable String projectId,
                                                                       @PathVariable Integer periodId) {
        return projectStatusManageService.getProjectStatus(projectId, periodId);
    }

    @RequestMapping(value = {"isProjectStatusExisted/{projectId}/{periodId}"}, method = RequestMethod.GET,
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public OperationResultDto<ProjectStatusManage> isProjectStatusExisted(@PathVariable String projectId,
                                                                          @PathVariable int periodId) {
        return projectStatusManageService.isProjectStatusExisted(projectId, periodId);
    }
}