82 lines
1.8 KiB
Go
82 lines
1.8 KiB
Go
package custom
|
|
|
|
import (
|
|
"context"
|
|
"git.kumo.work/shama/service/client"
|
|
"time"
|
|
)
|
|
|
|
type consignee struct {
|
|
}
|
|
|
|
type ConsigneeItem struct {
|
|
Id int64 `json:"id"`
|
|
Type string `json:"type"`
|
|
Name string `json:"name"`
|
|
Phone string `json:"phone"`
|
|
Address string `json:"address"`
|
|
Port string `json:"port"`
|
|
Info string `json:"info"`
|
|
CreatedAt *time.Time `json:"createdAt"`
|
|
UpdatedAt *time.Time `json:"updatedAt"`
|
|
}
|
|
|
|
// All @TITLE 获取收货人
|
|
func (c *consignee) All(ctx context.Context, customId int64) (reply []ConsigneeItem, err error) {
|
|
xClient, err := client.GetClient(c)
|
|
if err != nil {
|
|
return
|
|
}
|
|
err = xClient.Call(ctx, "All", customId, &reply)
|
|
return
|
|
}
|
|
|
|
type ArgsConsigneeAdd struct {
|
|
CustomId int64 // 客户ID
|
|
ConsigneeAdd
|
|
}
|
|
|
|
type ConsigneeAdd struct {
|
|
Type string // 类型
|
|
Name string // 姓名
|
|
Phone string // 联系电话
|
|
Address string // 地址
|
|
Port string // 卸货港
|
|
Info string // 备注
|
|
}
|
|
|
|
// Add @TITLE 添加收货人
|
|
func (c *consignee) Add(ctx context.Context, args ArgsConsigneeAdd) (err error) {
|
|
xClient, err := client.GetClient(c)
|
|
if err != nil {
|
|
return
|
|
}
|
|
reply := 0
|
|
return xClient.Call(ctx, "Add", args, &reply)
|
|
}
|
|
|
|
type ArgsConsigneeEdit struct {
|
|
ConsigneeId int64 // 收货人ID
|
|
ConsigneeAdd
|
|
}
|
|
|
|
// Edit @TITLE 编辑收货人
|
|
func (c *consignee) Edit(ctx context.Context, args ArgsConsigneeEdit) (err error) {
|
|
xClient, err := client.GetClient(c)
|
|
if err != nil {
|
|
return
|
|
}
|
|
reply := 0
|
|
return xClient.Call(ctx, "Edit", args, &reply)
|
|
}
|
|
|
|
// Delete @TITLE 删除收货人
|
|
func (c *consignee) Delete(ctx context.Context, consigneeIds []int64) (err error) {
|
|
xClient, err := client.GetClient(c)
|
|
if err != nil {
|
|
return
|
|
}
|
|
reply := 0
|
|
return xClient.Call(ctx, "Delete", consigneeIds, &reply)
|
|
}
|