syntax = "v1"

import "common.api"

info (
	title:   "聚玩争议服务"
	desc:    "处理订单争议申诉与仲裁。ID 字段（int64）以 string 传输"
	author:  "Asadz"
	version: "1.0"
)

type (
	DisputePathId {
		Id int64 `path:"id"`
	}
	Dispute {
		Id                 int64    `json:"id,string"`
		OrderId            int64    `json:"orderId,string"`
		InitiatorId        int64    `json:"initiatorId,string"`
		InitiatorName      string   `json:"initiatorName"`
		RespondentId       int64    `json:"respondentId,string"`
		Reason             string   `json:"reason"`
		Evidence           []string `json:"evidence"`
		Status             string   `json:"status"`
		Result             string   `json:"result,optional"`
		RespondentReason   string   `json:"respondentReason,optional"`
		RespondentEvidence []string `json:"respondentEvidence"`
		AppealReason       string   `json:"appealReason,optional"`
		AppealedAt         string   `json:"appealedAt,optional"`
		ResolvedBy         int64    `json:"resolvedBy,string,optional"`
		ResolvedAt         string   `json:"resolvedAt,optional"`
		CreatedAt          string   `json:"createdAt"`
		UpdatedAt          string   `json:"updatedAt"`
	}
	DisputeListReq {
		PageReq
		Status string `form:"status,optional"`
	}
	DisputeListResp {
		Items []Dispute `json:"items"`
		Meta  PageMeta  `json:"meta"`
	}
	CreateDisputeReq {
		DisputePathId
		Reason   string   `json:"reason"`
		Evidence []string `json:"evidence"`
	}
	DisputeResponseReq {
		DisputePathId
		Reason   string   `json:"reason"`
		Evidence []string `json:"evidence"`
	}
	AppealReq {
		DisputePathId
		Reason string `json:"reason"`
	}
)

@server (
	prefix: api/v1
	group:  dispute
)
service dispute-api {
	@doc "获取争议列表"
	@handler ListDisputes
	get /disputes (DisputeListReq) returns (DisputeListResp)

	@doc "获取订单争议"
	@handler GetOrderDispute
	get /orders/:id/dispute (DisputePathId) returns (Dispute)

	@doc "发起争议"
	@handler CreateDispute
	post /orders/:id/dispute (CreateDisputeReq) returns (EmptyResp)

	@doc "回应争议"
	@handler RespondDispute
	post /disputes/:id/response (DisputeResponseReq) returns (EmptyResp)

	@doc "申诉"
	@handler AppealDispute
	post /disputes/:id/appeal (AppealReq) returns (EmptyResp)
}

