package cn.axzo.msg.center.api;


import cn.axzo.core.domain.PageResult;
import cn.axzo.msg.center.api.fallback.InsideNoticesApiFallBack;
import cn.axzo.msg.center.api.request.*;
import cn.axzo.msg.center.api.response.*;
import cn.azxo.framework.common.model.CommonResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

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

/**
 * 站内消息相关接口
 */
@FeignClient(name = "msg-center", url = "${server.serviceUrl:http://msg-center:8080}", fallback = InsideNoticesApiFallBack.class)
@Component
public interface InsideNoticesApi {

  /**
   * 新增推送消息接口
   *
   * @param message
   * @return 消息唯一主键
   */
  @RequestMapping(value = "api/message/push", method = RequestMethod.POST)
  CommonResponse<List<MsgReturnParamRes>> pushMsg(@RequestBody @Valid GeneralMessageReq message);

  /**
   * 消息\待办数量总数
   *
   * @return
   */
  @PostMapping("msg/total")
  //@PreBuildContext
  CommonResponse<MessageTotalRes> statisticsMsg(@RequestBody @Valid MessageTotalReq req);

  /**
   * 消息统计
   * @param
   * @return
   */
  @PostMapping("statistics")
  CommonResponse<MessageTotalRes> statisticsMsg(@RequestBody @Valid StatisticsReq req);

  /**
   * 消息列表搜索、待办列表
   *
   * @param req
   * @return
   */
  @PostMapping("msg/list")
  /*@PreBuildContext*/
  CommonResponse<PageResult<MessageNewRes>> msgList(@RequestBody @Valid CmsMsgQueryReq req);

  /**
   * 根据用户类型获取消息列表模块
   *
   * @param userType
   * @return
   */
  @GetMapping("module/list")
  CommonResponse<List<InsideMessageModuleRes>> listModule(@RequestParam(value = "userType") Integer userType);

  /**
   * 变更执行消息的状态
   *
   * @return
   */
  @PostMapping("api/message/state/change")
  CommonResponse<Boolean> changeMessageState(@RequestBody @Valid ChangeMessageStateReq req);

  @PostMapping("api/message/state/change4Biz")
  CommonResponse<Boolean> changeMessageState(@RequestBody @Valid  ChangeMessageReq req);

  /**
   * 获取所有模板数据集合
   *
   * @return 模板信息集合
   */
  @GetMapping("api/message/templates/{time}")
  CommonResponse<List<TemplateRes>> getTemplates(
      @PathVariable("time") String lastUpdate);

  /**
   * 获取所有的模块与模板的关系数据集合
   *
   * @return 模块与模板关系集合
   */
  @GetMapping("api/message/relations{time}")
  CommonResponse<List<RelationRes>> getRelations(@PathVariable("time") String lastUpdate);

  @PostMapping("update/msg/status")
  CommonResponse<Void> updateReadMsgStatus(@RequestBody @Valid CmsReadMsgReq req);


  /**
   * uqjq
   * @param req
   * @return
   */
  @PostMapping("trade/list")
    /*@PreBuildContext*/
  CommonResponse<PageResult<MessageNewRes>> listMsgInfo4Trade(@RequestBody @Valid CmsMsgQueryReq req);
}
