package com.ningdatech.pmapi.provincial.controller;

import com.ningdatech.pmapi.projectdeclared.manage.ReviewByProvincialDeptManage;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.provincial.model.res.SjApiResponse;
import com.ningdatech.pmapi.provincial.service.IJoinReviewProvincialBureauService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.io.IOException;
import java.io.InputStream;

/**
 * @Classname TestController
 * @Description
 * @Date 2023/3/2 15:08
 * @Author PoffyZhang
 */
@RestController
@RequestMapping("/api/v1/test")
@Api(tags = "测试省局接口")
public class TestController {

    @Autowired
    private IJoinReviewProvincialBureauService joinReviewProvincialBureauService;

    @Autowired
    private ReviewByProvincialDeptManage provincialDeptManage;

    @GetMapping("/push")
    @ApiOperation("测试推送")
    private Boolean push(@Valid @RequestParam Long projectId){
        Project project = new Project();
        project.setId(projectId);
        return provincialDeptManage.startTheProcess(project);
    }

    @GetMapping("/detail")
    @ApiOperation("测试获取详情")
    private SjApiResponse detail(@RequestParam String projectId){
        return joinReviewProvincialBureauService.processInfo(projectId);
    }

    @GetMapping("/path")
    @ApiOperation("测试获取详情")
    private String path() throws IOException {
//        String template = ResourceUtil.getResource("template").getPath();
//        return template;

        InputStream in = this.getClass().getResourceAsStream("/template/simsun.ttc");
        StringBuilder sb = new StringBuilder();
        int n;
        while ((n=in.read())!=-1){
            sb.append((char)n);
            System.out.print((char)n);
        }

        return sb.toString();
    }
}
