package thyyxxk.webserver.controller.ca;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.config.auth.PassToken;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.ca.CaReturn;
import thyyxxk.webserver.entity.ca.CaSingBizSnReturnData;
import thyyxxk.webserver.service.ca.CaServer;
import thyyxxk.webserver.utils.ResultVoUtil;

import java.util.List;

@RestController
@RequestMapping("/thyyca")
public class CaController {
    private final CaServer server;

    @Autowired
    public CaController(CaServer server) {
        this.server = server;
    }

    @PostMapping("/sendBatchByCode")
    public ResultVo<List<CaReturn.CaData>> sendBatchByCode(@RequestBody CaServer.Send send) {
        return ResultVoUtil.success(server.sendBatchByCode(send));
    }


    @PostMapping("/sendByCode")
    @PassToken
    public ResultVo<CaReturn.CaData> sendByCode(@RequestBody CaServer.Send send) {
        return ResultVoUtil.success(server.sendByCode(send));
    }

    @GetMapping("/getSignInfoByBizSn")
    @PassToken
    public ResultVo<CaSingBizSnReturnData> getSignInfoByBizSn(@RequestParam("bizSn") String bizSn) {
        return server.getSignInfoByBizSn(bizSn);
    }
}
