package cn.reghao.tnb.content.app.vod.controller;

import cn.reghao.tnb.common.web.WebResult;
import cn.reghao.tnb.common.auth.UserContext;
import cn.reghao.tnb.content.api.dto.VideoRegion;
import cn.reghao.tnb.content.app.vod.service.CategoryService;
import cn.reghao.tnb.user.api.iface.UserService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author reghao
 * @date 2023-11-20 21:38:01
 */
@Tag(name = "视频分区接口")
@RestController
@RequestMapping("/api/content/video")
public class CategoryController {
    @DubboReference(check = false)
    private UserService userService;
    private final CategoryService categoryService;

    public CategoryController(CategoryService categoryService) {
        this.categoryService = categoryService;
    }

    @Operation(summary = "获取视频分区", description = "N")
    @GetMapping(value = "/categories", produces = MediaType.APPLICATION_JSON_VALUE)
    public String videoCategories() {
        long loginUser = UserContext.getUserId();
        boolean vip = userService.isVip(loginUser);
        List<VideoRegion> list1 = categoryService.getCategories(vip);
        return WebResult.success(list1);
    }
}
