package com.changhu.controller;

import com.changhu.common.annotation.IsWhiteList;
import com.changhu.common.annotation.JsonBody;
import com.changhu.common.pojo.vo.SelectNodeVo;
import com.changhu.pojo.dto.DataViewDTO;
import com.changhu.pojo.dto.EnterprisesUnitDetailDTO;
import com.changhu.pojo.dto.SecurityUnitUseStatisticsDTO;
import com.changhu.pojo.dto.SecurityUserRosterDTO;
import com.changhu.pojo.params.EnterprisesUnitOrServiceProjectType;
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 org.springframework.web.bind.annotation.RestController;

import java.util.List;

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

    @Autowired
    private OpenApiService openApiService;

    @Operation(summary = "获取企事业单位列表")
    @GetMapping("/getEnterprisesUnit")
    public List<SelectNodeVo<Long>> getEnterprisesUnit(@Schema(description = "代码") @RequestParam String code,
                                                       @Schema(description = "等级") @RequestParam Integer level) {
        return openApiService.getEnterprisesUnit(code, level);
    }

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

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

    @Operation(summary = "保安单位使用情况统计")
    @GetMapping("/securityUnitUseStatistics")
    public List<SecurityUnitUseStatisticsDTO> securityUnitUseStatistics(@Schema(description = "代码") @RequestParam String code,
                                                                        @Schema(description = "等级") @RequestParam Integer level) {
        return openApiService.securityUnitUseStatistics(code, level);
    }

    @Operation(summary = "安保人员花名册")
    @GetMapping("/securityUserRoster")
    public List<SecurityUserRosterDTO> securityUserRoster(@Schema(description = "事业单位或服务项目id") Long id,
                                                          @Schema(description = "类型") EnterprisesUnitOrServiceProjectType type) {
        return openApiService.securityUserRoster(id, type);
    }

    @Operation(summary = "单位下的安保人员花名册")
    @GetMapping("/unitSecurityUserRoster")
    public List<SecurityUserRosterDTO> unitSecurityUserRoster(@Schema(description = "代码") @RequestParam String code,
                                                              @Schema(description = "等级") @RequestParam Integer level) {
        return openApiService.unitSecurityUserRoster(code, level);
    }

}
