package cn.axzo.msg.center.service.group.client;

import cn.axzo.msg.center.service.group.client.fallback.MessageGroupClientFallback;
import cn.axzo.msg.center.service.group.request.MessageTemplateGroupRelationMoveRequest;
import cn.axzo.msg.center.service.group.request.MessageTemplateGroupRelationPageRequest;
import cn.axzo.msg.center.service.group.request.MessageTemplateGroupRelationRemoveRequest;
import cn.axzo.msg.center.service.group.response.MessageTemplateGroupRelationResponse;
import cn.azxo.framework.common.model.CommonResponse;
import cn.azxo.framework.common.model.Page;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import javax.validation.Valid;
import java.util.List;

/**
 * @author cold_blade
 * @date 2023/10/12
 * @version 1.0
 */
@Component
@FeignClient(value = "msg-center", url = "${server.serviceUrl:http://msg-center:8080}",
        fallback = MessageGroupClientFallback.class)
public interface MessageTemplateGroupRelationClient {


    /**
     * 分页查询分类下关联的模板列表
     *
     * @param request 分类结点的编码及分页参数
     * @return 模板列表
     */
    @PostMapping(value = "/message/template/group-relation/page", produces = {MediaType.APPLICATION_JSON_VALUE})
    CommonResponse<Page<MessageTemplateGroupRelationResponse>> page(
            @RequestBody @Valid MessageTemplateGroupRelationPageRequest request);

    /**
     * 变更模板与分类的关联关系
     *
     * @param request 变更分类的相关参数
     */
    @PostMapping(value = "/message/template/group-relation/move", produces = {MediaType.APPLICATION_JSON_VALUE})
    CommonResponse<Void> move(@RequestBody @Valid MessageTemplateGroupRelationMoveRequest request);

    /**
     * 解除分类与模板的关联关系
     *
     * @param request 变更分类的相关参数
     * @return 关联关系解除失败的模板编码
     */
    @PostMapping(value = "/message/template/group-relation/remove", produces = {MediaType.APPLICATION_JSON_VALUE})
    CommonResponse<Void> remove(@RequestBody @Valid MessageTemplateGroupRelationRemoveRequest request);
}
