package com.changhu.controller;

import com.changhu.common.annotation.CheckOpenApi;
import com.changhu.common.annotation.JsonBody;
import com.changhu.common.enums.OpenApiType;
import com.changhu.common.pojo.vo.SelectNodeVo;
import com.changhu.pojo.dto.DataViewDTO;
import com.changhu.pojo.dto.EnterprisesUnitDetailDTO;
import com.changhu.service.OpenApiService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author 20252
 * @createTime 2024/10/9 下午5:02
 * @desc 可以给第三方对接的controller
 */
@Tag(name = "开放接口")
@JsonBody
@RequestMapping("/open")
public class OpenController {

    @Autowired
    private OpenApiService openApiService;

    @Operation(summary = "获取企事业单位列表")
    @CheckOpenApi(value = OpenApiType.Information_on_enterprises_and_institutions)
    @GetMapping("/getEnterprisesUnit")
    public List<SelectNodeVo<Long>> getEnterprisesUnit(@Schema(description = "公安单位机构代码") @RequestParam String policeCode) {
        return openApiService.getEnterprisesUnit(policeCode);
    }

    @Operation(summary = "企事业单位详情")
    @CheckOpenApi(value = OpenApiType.Information_on_enterprises_and_institutions)
    @GetMapping("/enterprisesUnitDetailById")
    public EnterprisesUnitDetailDTO enterprisesUnitDetailById(@Schema(description = "企事业单位id") @RequestParam Long enterprisesUnitId) {
        return openApiService.enterprisesUnitDetailById(enterprisesUnitId);
    }

    @Operation(summary = "数据总览")
    @CheckOpenApi(value = OpenApiType.data_view)
    @GetMapping("/dataView")
    public DataViewDTO dataView() {
        return openApiService.dataView();
    }
}
