package com.ningdatech.pmapi.irs.controller;

import com.ningdatech.log.annotation.WebLog;
import com.ningdatech.pmapi.projectdeclared.manage.IrsManage;
import com.ningdatech.pmapi.projectdeclared.model.vo.IrsApplicationVO;
import com.ningdatech.pmapi.projectdeclared.model.vo.PiotTasksVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
import java.util.List;

/**
 * @Classname IrsController
 * @Description irs 一些下拉框信息
 * @Date 2023/3/13 9:53
 * @Author PoffyZhang
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/api/v1/irs")
@Api(value = "irs", tags = "irs-信息查询")
@RequiredArgsConstructor
public class IrsController {

    private final IrsManage irsManage;

    @ApiOperation(value = "irs应用列表", notes = "irs应用列表")
    @WebLog("irs应用列表")
    @GetMapping("/application-list")
    public List<IrsApplicationVO> applicationList(@RequestParam(required = false) String areaCode) {
        return irsManage.applicationList(areaCode);
    }

    @ApiOperation(value = "试点任务列表", notes = "试点任务列表")
    @WebLog("试点任务列表")
    @GetMapping("/piot-tasks")
    public List<PiotTasksVO> piotTasks() {
        return irsManage.listPiotTasks();
    }

    @ApiOperation(value = "获取企业社会信用编码", notes = "获取企业社会信用编码")
    @GetMapping("/get-credit-code")
    public String getCreditCode() throws NoSuchAlgorithmException, UnsupportedEncodingException {
        return irsManage.getCreditCode();
    }
}
