package com.backendsys.modules.crt.controller;

import com.backendsys.modules.common.config.security.utils.SecurityUtil;
import com.backendsys.modules.common.utils.Result;
import com.backendsys.modules.crt.entity.CrtLoraStyle;
import com.backendsys.modules.crt.entity.CrtLoraStyleCollect;
import com.backendsys.modules.crt.service.CrtLoraStyleService;
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.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Validated
@RestController
@Tag(name = "短剧创作-风格LoRA")
public class CrtLoraStyleController {

    @Autowired
    private CrtLoraStyleService crtLoraStyleService;

    @Operation(summary = "获取短剧创作-风格LoRA列表")
    @GetMapping("/api/crt/drama/getLoraStyleList")
    public Result getLoraStyleList(@Validated CrtLoraStyle crtLoraStyle) {
        return Result.success().put("data", crtLoraStyleService.selectCrtLoraStyleList(crtLoraStyle));
    }

    @Operation(summary = "获取短剧创作-风格分类列表")
    @GetMapping("/api/crt/drama/getLoraStyleCategoryList")
    public Result getLoraStyleCategoryList() {
        return Result.success().put("data", crtLoraStyleService.selectCrtLoraStyleCategoryList());
    }

    @Operation(summary = "获取短剧创作-风格LoRA列表-我收藏的")
    @GetMapping("/api/crt/drama/getLoraStyleListByCollect")
    public Result getLoraStyleListByCollect(@Validated CrtLoraStyle crtLoraStyle) {
        crtLoraStyle.setUser_id(SecurityUtil.getUserId());
        return Result.success().put("data", crtLoraStyleService.selectCrtLoraStyleListByCollect(crtLoraStyle));
    }

    @Operation(summary = "获取短剧创作-风格LoRA列表-加入/取消收藏")
    @PostMapping("/api/crt/drama/setLoraStyleCollect")
    public Result setLoraStyleCollect(@Validated(CrtLoraStyleCollect.Collect.class) @RequestBody CrtLoraStyleCollect crtLoraStyleCollect) {
        crtLoraStyleCollect.setUser_id(SecurityUtil.getUserId());
        return Result.success().put("data", crtLoraStyleService.setLoraStyleCollect(crtLoraStyleCollect));
    }

}
