package com.zcloud.primeport.web;


import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.jjb.saas.framework.auth.model.SSOUser;
import com.jjb.saas.framework.auth.utils.AuthContext;
import com.zcloud.primeport.api.VideoServiceI;
import com.zcloud.primeport.dto.VideoAddCmd;
import com.zcloud.primeport.dto.VideoPageQry;
import com.zcloud.primeport.dto.VideoUpdateCmd;
import com.zcloud.primeport.dto.clientobject.VideoCO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

/**
 * web-adapter
 *
 * @Author makejava
 * @Date 2026-03-05 11:33:30
 */
@Api(tags = "摄像头表")
@RequestMapping("/${application.gateway}/video")
@RestController
@AllArgsConstructor
public class VideoController {
    private final VideoServiceI videoService;

    @ApiOperation("新增")
    @PostMapping("/save")
    public SingleResponse<VideoCO> add(@Validated @RequestBody VideoAddCmd cmd) {
        return videoService.add(cmd);
    }

    @ApiOperation("分页")
    @PostMapping("/list")
    public PageResponse<VideoCO> page(@RequestBody VideoPageQry qry) {
        return videoService.listPage(qry);
    }

    @ApiOperation("详情")
    @GetMapping("/{id}")
    public SingleResponse<VideoCO> getInfoById(@PathVariable("id") Long id) {
        return SingleResponse.of(videoService.getInfoById(id));
    }

    @ApiOperation("删除")
    @DeleteMapping("/{id}")
    public Response remove(@PathVariable("id") Long id) {
        videoService.remove(id);
        return SingleResponse.buildSuccess();
    }

    @ApiOperation("修改")
    @PutMapping("/edit")
    public SingleResponse edit(@Validated @RequestBody VideoUpdateCmd videoUpdateCmd) {
        videoService.edit(videoUpdateCmd);
        return SingleResponse.buildSuccess();
    }
}

