package com.sptg.gateway.controller.videoCloud;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.PageBean;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.security.annotation.Security;
import com.sptg.common.security.enums.DataFormatEnum;
import com.sptg.video.cloud.api.constant.VideoCloudSecurityToken;
import com.sptg.video.cloud.api.dto.VCAccountDto;
import com.sptg.video.cloud.api.entity.VCAccount;
import com.sptg.video.cloud.api.feigns.VCAccountFeign;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author zwx
 * @create 2020/10/18 23:29
 * 视频云接口日志控制器
 */
@RestController
@AllArgsConstructor
@RequestMapping(value = "/videoCloud/account")
public class VCAccountController {

    private final VCAccountFeign vcAccountFeign;

    /**
     * 功能描述: 视频云接口日志界面
     * @return ModelAndView
     */
    @GetMapping(value = "/manage/index")
    @Security(token = VideoCloudSecurityToken.VIDEO_CLOUD_ACCOUNT_INFO_MANAGE, format = DataFormatEnum.VIEW)
    public ModelAndView accountManage(){
        return new ModelAndView("videoCloud/vc-account-manage");
    }

    /**
     * 功能描述: 视频云账号分页查询接口日志列表
     *
     * @param vcAccountDto      查询条件
     * @param pageBean 分页条件
     * @return ResultBean<Page>
     */
    @GetMapping(value = "/pagingQuery")
    @Security(token = VideoCloudSecurityToken.VIDEO_CLOUD_ACCOUNT_INFO_MANAGE, format = DataFormatEnum.JSON)
    public ResultBean<Page<VCAccount>> pagingQuery(VCAccountDto vcAccountDto, PageBean<VCAccount, VCAccountDto> pageBean) {
        pageBean.setDto(vcAccountDto);
        return this.vcAccountFeign.pagingQuery(pageBean);
    }

    /**
     * 功能描述: 视频云设备同步
     *
     * @param vcAccountDto
     * @return ResultBean<Page>
     */
    @PostMapping(value = "/login")
    @Security(token = VideoCloudSecurityToken.VIDEO_CLOUD_ACCOUNT_LOGIN, format = DataFormatEnum.JSON)
    public ResultBean<String> login(@RequestBody VCAccountDto vcAccountDto) {
        return this.vcAccountFeign.login(vcAccountDto);
    }
}
