package cn.axzo.msg.center.api.fallback;

import cn.axzo.core.domain.PageResult;
import cn.axzo.msg.center.api.InsideNoticesApi;
import cn.axzo.msg.center.api.request.*;
import cn.axzo.msg.center.api.response.*;
import cn.azxo.framework.common.model.CommonResponse;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;

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

/**
 * @author zhangPeng
 * @description
 * @date 2021/6/29 11:18
 */
@Component
@Slf4j
public class InsideNoticesApiFallBack implements InsideNoticesApi {


  @Override
  public CommonResponse<List<MsgReturnParamRes>> pushMsg(GeneralMessageReq message) {
    log.info("推送消息超时, message: {}", message);
    return CommonResponse.fail("推送消息超时");
  }

  @Override
  public CommonResponse<MessageTotalRes> statisticsMsg(MessageTotalReq req) {
    log.info("消息待办数量总数超时,req={}", JSONUtil.toJsonStr(req));
    return CommonResponse.fail("消息待办数量总数超时");
  }

  @Override
  public CommonResponse<MessageTotalRes> statisticsMsg(@RequestBody @Valid StatisticsReq req) {
    return CommonResponse.fail("统计数据异常");
  }

  @Override
  public CommonResponse<PageResult<MessageNewRes>> msgList(CmsMsgQueryReq req) {
    log.info("消息列表搜索、待办列表超时,req:{}",req);
    return CommonResponse.fail("消息列表搜索、待办列表超时");
  }

  @Override
  public CommonResponse<List<InsideMessageModuleRes>> listModule(Integer userType) {
    return null;
  }

  @Override
  public CommonResponse<Boolean> changeMessageState(@RequestBody @Valid ChangeMessageStateReq req) {
    log.info("调用变更消息状态超时, req = {}",JSONUtil.toJsonStr(req));
    return CommonResponse.fail("调用变更消息状态超时");
  }

  @Override
  public CommonResponse<Boolean> changeMessageState(@RequestBody @Valid  ChangeMessageReq req) {
    log.info("调用变更消息状态超时2, req= {}", JSONUtil.toJsonStr(req));
    return CommonResponse.fail("调用变更消息状态超时2");
  }


  @Override
  public CommonResponse<List<TemplateRes>> getTemplates(String lastUpdate) {
    log.info("获取消息模板信息超时");
    return CommonResponse.fail("获取消息模板信息超时");
  }

  @Override
  public CommonResponse<List<RelationRes>> getRelations(String lastUpdate) {
    log.info("获取模块与模板关联关系配置信息超时");
    return CommonResponse.fail("获取模块与模板关联关系配置信息超时");
  }

  @Override
  public CommonResponse<Void> updateReadMsgStatus(CmsReadMsgReq req) {
      return CommonResponse.fail("更新状态异常");
  }

  @Override
  public CommonResponse<PageResult<MessageNewRes>> listMsgInfo4Trade(CmsMsgQueryReq req) {
    return null;
  }
}
