package cn.hanghui.outapi.platform.tenant.controller;

import cn.hanghui.outapi.platform.common.entity.rest.RestResponse;
import cn.hanghui.outapi.platform.common.entity.rest.RestResult;
import cn.hanghui.outapi.platform.common.utils.Preconditions;
import cn.hanghui.outapi.platform.tenant.entity.dto.open.RecurrentPopulationRequestDto;
import cn.hanghui.outapi.platform.tenant.entity.dto.open.UserInfoRequest;
import cn.hanghui.outapi.platform.tenant.service.OpenApiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author shisl
 * @package cn.hanghui.outapi.platform.tenant.controller
 * @class OpenApiController
 * @date 2024/2/29 下午1:56
 * @description
 */
@Api(tags = "第三方开放接口")
@RestController
@RequestMapping("/api/v1/open")
public class OpenApiController {

    @Autowired
    private OpenApiService openApiService;

    @ApiOperation(value = "流动人口自主申报接口")
    @PostMapping("/recurrent/population/push")
    public RestResult population(@RequestBody RecurrentPopulationRequestDto dto) {
        if (Preconditions.isBlank(dto.getAppId())) {
            return RestResponse.error("参数有误");
        }
        return openApiService.recurrentPopulation(dto);
    }

    @ApiOperation(value = "查询用户基本信息 加密")
    @PostMapping("/user/sync/query")
    public RestResult queryUserInfo(@RequestBody UserInfoRequest req) {
        return openApiService.queryUserInfo(req);
    }

    @ApiOperation(value = "查询用户基本信息 加密 异步")
    @PostMapping("/user/async/query")
    public RestResult asyncQueryUserInfo(@RequestBody UserInfoRequest req) {

        return openApiService.queryUserInfoAsync(req);
    }





}
