package cn.axzo.msg.center.api;

import cn.axzo.msg.center.api.fallback.InsideMessageTemplateApiFallBack;
import cn.axzo.msg.center.api.request.CreateTemplateReq;
import cn.axzo.msg.center.api.request.SearchTemplateReq;
import cn.axzo.msg.center.api.request.SyncRelationDataReq;
import cn.axzo.msg.center.api.request.UpdateTemplateAudioFileReq;
import cn.axzo.msg.center.api.request.UpdateTemplateReq;
import cn.axzo.msg.center.api.response.CommonPlatManagerRes;
import cn.axzo.msg.center.api.response.SearchTemplateRes;
import cn.axzo.msg.center.api.response.SyncRelationDataRes;
import cn.azxo.framework.common.model.CommonResponse;
import java.util.List;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(name = "msg-center", url = "${server.serviceUrl:http://msg-center:8080}", fallback = InsideMessageTemplateApiFallBack.class)
@Component
public interface InsideMessageTemplateApi {

    /**
     *  添加消息模板
     * @param req
     * o
     * @return
     */
    @PostMapping("/add/template")
    CommonResponse<String> addTemplate(@Validated @RequestBody CreateTemplateReq req);

    /**
     *  修改消息模板
     * @param req
     * @return
     */
    @PostMapping("/update/template")
    CommonResponse<String> updateTemplate(@Validated @RequestBody UpdateTemplateReq req);

    /**
     * 更新消息模板的语音包
     * @param req
     * @return
     */
    @PostMapping("/update/template/audioFile")
    CommonResponse<String> updateTemplateAudioFile(@Validated @RequestBody UpdateTemplateAudioFileReq req);

    /**
     *  分页查询模板
     * @param req
     * @return
     */
    @PostMapping("/page")
    CommonResponse<CommonPlatManagerRes> pageTemplates(@RequestBody SearchTemplateReq req);

    /**
     * 根据id查询模板
     * @param id
     * @return
     */
    @GetMapping("/get/{id}")
    CommonResponse<SearchTemplateRes> get(@PathVariable Long id);

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

    @GetMapping("/template/findByIds")
    CommonResponse<List<SyncRelationDataRes>> findTemplateByIds(@RequestParam("ids") List<Long> ids);

    @PostMapping("sync/template/data")
    CommonResponse<String> syncTemplateData(@RequestBody List<SyncRelationDataReq> syncRelationDataReqList);
}
