package com.seer.teach.iot.controller.version;

import com.seer.teach.common.ResultBean;
import com.seer.teach.common.annotation.LogPrint;
import com.seer.teach.iot.common.resp.TvVersionResp;
import com.seer.teach.iot.service.IotVersionsService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import lombok.RequiredArgsConstructor;
import com.seer.teach.common.annotation.DecryptionAnnotation;
import com.seer.teach.common.annotation.EncryptionAnnotation;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;

/**
 * Tv版本
 * <p>
 * Tv版本控制器
 * </p>
 *
 * @author Captain
 * @version 1.0
 * @since 2025-07-15 20:05
 */
@RequestMapping("/device/version")
@RestController
@Tag(name = "Tv版本控制器")
@Validated
@EncryptionAnnotation
@DecryptionAnnotation
@RequiredArgsConstructor
public class VersionController {

    private final IotVersionsService iotVersionsService;

    @LogPrint
    @Operation(summary = "获取Tv版本更新数据")
    @GetMapping("/getVersion")
    public ResultBean<TvVersionResp> getVersion(@RequestHeader("unionId") @NotBlank(message = "设备ID不能为空") String unionId,
                                                @RequestHeader("versionCode") @NotNull(message = "版本号不能为空") Integer versionCode) {
        TvVersionResp result = iotVersionsService.getVersionByDevice(unionId,versionCode);
        return ResultBean.success(result);
    }

}
