package purchase

import (
	"context"
	"git.kumo.work/shama/service/client"
	"time"
)

type annotations struct {
}

type AnnotationsItem struct {
	Id        int64      `json:"id"`
	Sort      int64      `json:"sort"`
	Value     string     `json:"value"`
	CreatedAt *time.Time `json:"createdAt"`
	UpdatedAt *time.Time `json:"updatedAt"`
}

// All @TITLE 获取附注
func (a *annotations) All(ctx context.Context, purchaseId int64) (reply []AnnotationsItem, err error) {
	xClient, err := client.GetClient(a)
	if err != nil {
		return
	}
	err = xClient.Call(ctx, "All", purchaseId, &reply)
	return
}

type ArgsAnnotationsAdd struct {
	PurchaseId int64 // 采购合同ID
	AnnotationsAdd
}

type AnnotationsAdd struct {
	Sort  int64  // 排序
	Value string // 内容
}

// Add @TITLE 添加附注
func (a *annotations) Add(ctx context.Context, args ArgsAnnotationsAdd) (err error) {
	xClient, err := client.GetClient(a)
	if err != nil {
		return
	}
	reply := 0
	return xClient.Call(ctx, "Add", args, &reply)
}

type ArgsAnnotationsEdit struct {
	AnnotationsId int64 // 附注ID
	AnnotationsAdd
}

// Edit @TITLE 编辑附注
func (a *annotations) Edit(ctx context.Context, args ArgsAnnotationsEdit) (err error) {
	xClient, err := client.GetClient(a)
	if err != nil {
		return
	}
	reply := 0
	return xClient.Call(ctx, "Edit", args, &reply)
}

// Delete @TITLE 删除附注
func (a *annotations) Delete(ctx context.Context, annotationsIds []int64) (err error) {
	xClient, err := client.GetClient(a)
	if err != nil {
		return
	}
	reply := 0
	return xClient.Call(ctx, "Delete", annotationsIds, &reply)
}