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.MessageGroupNodeAddRequest;
import cn.axzo.msg.center.service.group.request.MessageGroupNodeListRequest;
import cn.axzo.msg.center.service.group.request.MessageGroupNodeUpdateRequest;
import cn.axzo.msg.center.service.group.request.MessageGroupQueryRequest;
import cn.axzo.msg.center.service.group.response.MessageGroupNodeBriefResponse;
import cn.axzo.msg.center.service.group.response.MessageGroupTreeNodeResponse;
import cn.azxo.framework.common.model.CommonResponse;
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 org.springframework.web.bind.annotation.RequestParam;

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

/**
 * 消息分类管理
 *
 * @description
 * @author cold_blade
 * @date 2023/9/26
 * @version 1.0
 */
@Component
@FeignClient(value = "msg-center", url = "${server.serviceUrl:http://msg-center:8080}",
        fallback = MessageGroupClientFallback.class)
public interface MessageGroupClient {

    /**
     * 添加消息分类结点
     *
     * @param request 结点相关参数
     */
    @PostMapping(value = "/message/group/node/add", produces = {MediaType.APPLICATION_JSON_VALUE})
    CommonResponse<Void> addNode(@RequestBody @Valid MessageGroupNodeAddRequest request);

    /**
     * 更新结点数据
     *
     * @param request 待更新的结点相关数据项
     */
    @PostMapping(value = "/message/group/node/update", produces = {MediaType.APPLICATION_JSON_VALUE})
    CommonResponse<Void> updateNode(@RequestBody @Valid MessageGroupNodeUpdateRequest request);

    /**
     * 删除结点
     *
     * @param nodeCode 结点编码
     */
    @PostMapping(value = "/message/group/node/delete", produces = {MediaType.APPLICATION_JSON_VALUE})
    CommonResponse<Void> deleteNode(@RequestParam("nodeCode") String nodeCode,
                                    @RequestParam("operatorId") Long operatorId);

    /**
     * 查询通知/待办的分类信息
     *
     * @param request 分页查询相关参数
     */
    @PostMapping(value = "/message/group/node/list", produces = {MediaType.APPLICATION_JSON_VALUE})
    CommonResponse<List<MessageGroupTreeNodeResponse>> list(@RequestBody MessageGroupQueryRequest request);

    /**
     * 查询通知/待办的分类信息
     *
     * @param request 分页查询相关参数
     */
    @PostMapping(value = "/message/group/cutTree/list", produces = {MediaType.APPLICATION_JSON_VALUE})
    CommonResponse<List<MessageGroupTreeNodeResponse>> listCutTree(@RequestBody MessageGroupQueryRequest request);

    /**
     * 查询通知/待办的分类信息
     *
     * @param request 分页查询相关参数
     */
    @PostMapping(value = "/message/group/node/brief/list", produces = {MediaType.APPLICATION_JSON_VALUE})
    CommonResponse<List<MessageGroupNodeBriefResponse>> listNodeBriefInfo(@RequestBody
                                                                          MessageGroupNodeListRequest request);
}
