package com.ycwl.basic.integration.render.client;

import com.ycwl.basic.integration.common.response.CommonResponse;
import com.ycwl.basic.integration.common.response.PageResponse;
import com.ycwl.basic.integration.render.dto.template.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 渲染模板V2客户端
 */
@FeignClient(name = "zt-render-worker", contextId = "render-template-v2", path = "/api/render/template/v2")
public interface RenderTemplateV2Client {

    // ==================== Template CRUD Operations ====================

    /**
     * 创建模板
     */
    @PostMapping
    CommonResponse<TemplateV2DTO> createTemplate(@RequestBody CreateTemplateRequest request);

    /**
     * 获取模板列表
     */
    @GetMapping
    CommonResponse<PageResponse<TemplateV2DTO>> listTemplates(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer pageSize,
            @RequestParam(required = false) Long scenicId,
            @RequestParam(required = false) Integer status,
            @RequestParam(required = false) String name);

    /**
     * 获取模板详情
     */
    @GetMapping("/{id}")
    CommonResponse<TemplateV2DTO> getTemplate(@PathVariable("id") Long id);

    /**
     * 获取模板及其片段
     */
    @GetMapping("/{id}/with-segments")
    CommonResponse<TemplateV2WithSegmentsDTO> getTemplateWithSegments(@PathVariable("id") Long id);

    /**
     * 更新模板
     */
    @PutMapping("/{id}")
    CommonResponse<Void> updateTemplate(@PathVariable("id") Long id,
                                        @RequestBody UpdateTemplateRequest request);

    /**
     * 删除模板
     */
    @DeleteMapping("/{id}")
    CommonResponse<Void> deleteTemplate(@PathVariable("id") Long id);

    // ==================== Template Operations ====================

    /**
     * 发布模板
     */
    @PostMapping("/{id}/publish")
    CommonResponse<Void> publishTemplate(@PathVariable("id") Long id);

    /**
     * 创建新版本
     */
    @PostMapping("/{id}/version")
    CommonResponse<TemplateV2DTO> createTemplateVersion(@PathVariable("id") Long id);

    // ==================== Segment Management ====================

    /**
     * 获取模板片段列表
     */
    @GetMapping("/{id}/segments")
    CommonResponse<List<TemplateV2SegmentDTO>> getTemplateSegments(@PathVariable("id") Long id);

    /**
     * 创建片段
     */
    @PostMapping("/{id}/segments")
    CommonResponse<TemplateV2SegmentDTO> createSegment(@PathVariable("id") Long id,
                                                       @RequestBody CreateSegmentRequest request);

    /**
     * 更新片段
     */
    @PutMapping("/{id}/segments/{segmentId}")
    CommonResponse<Void> updateSegment(@PathVariable("id") Long id,
                                       @PathVariable("segmentId") Long segmentId,
                                       @RequestBody UpdateSegmentRequest request);

    /**
     * 删除片段
     */
    @DeleteMapping("/{id}/segments/{segmentId}")
    CommonResponse<Void> deleteSegment(@PathVariable("id") Long id,
                                       @PathVariable("segmentId") Long segmentId);

    /**
     * 替换所有片段
     */
    @PostMapping("/{id}/segments/replace")
    CommonResponse<Void> replaceSegments(@PathVariable("id") Long id,
                                         @RequestBody ReplaceSegmentsRequest request);
}
