package com.zhongshu.card.server.core.controller.openAPI.visitor;

import com.github.microservice.net.ResultContent;
import com.github.microservice.staticVariable.OpenApiMark;
import com.zhongshu.card.client.model.base.IDParam;
import com.zhongshu.card.client.model.visitor.VisitorMainModel;
import com.zhongshu.card.client.openApi.base.BusIdParam;
import com.zhongshu.card.client.openApi.model.visitor.VisitorMainOpenParam;
import com.zhongshu.card.client.openApi.model.visitor.VisitorMainOpenSearch;
import com.zhongshu.card.server.core.service.openAPI.visitor.VisitorOpenService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 访客开放接口
 * @author TRX
 * @date 2024/6/5
 */
@RestController
@RequestMapping("/" + OpenApiMark.fullCardOpenAPI + "/v1/visitor")
@Tag(name = "openAPI-访客功能")
public class VisitorOpenApiController {

    @Autowired
    private VisitorOpenService visitorOpenService;

    @Operation(summary = "添加访客信息", description = "添加访客信息")
    @RequestMapping(value = {"saveApplyVisitor"}, method = {RequestMethod.POST})
    public ResultContent saveApplyVisitor(@RequestBody VisitorMainOpenParam param) {
        return visitorOpenService.saveApplyVisitor(param);
    }

    @Operation(summary = "访客数据列表-分页查询(访客历史记录)", description = "访客数据列表-分页查询")
    @RequestMapping(value = {"page"}, method = {RequestMethod.POST})
    public ResultContent<Page<VisitorMainModel>> page(
            @RequestBody VisitorMainOpenSearch param) {
        return visitorOpenService.page(param);
    }

    @Operation(summary = "根据ID得到访客详情", description = "根据ID得到访客详情")
    @RequestMapping(value = {"detailById"}, method = {RequestMethod.POST})
    public ResultContent detailById(@RequestBody IDParam param) {
        return visitorOpenService.getVisitorDetail(param);
    }

    @Operation(summary = "根据busId得到访客详情", description = "根据busId得到访客详情")
    @RequestMapping(value = {"detailByBusId"}, method = {RequestMethod.POST})
    public ResultContent detailByBusId(@RequestBody BusIdParam param) {
        return visitorOpenService.detailByBusId(param);
    }

    @Operation(summary = "根据busId 删除访客信息", description = "根据busId 删除访客信息")
    @RequestMapping(value = {"deleteByBusId"}, method = {RequestMethod.POST})
    public ResultContent deleteByBusId(@RequestBody BusIdParam param) {
        return visitorOpenService.deleteByBusId(param);
    }
    

}
