106 lines
2.6 KiB
Go
106 lines
2.6 KiB
Go
package custom
|
||
|
||
import (
|
||
"context"
|
||
"git.kumo.work/shama/service/client"
|
||
"time"
|
||
)
|
||
|
||
type contact struct {
|
||
}
|
||
|
||
type ContactItem struct {
|
||
Id int64 `json:"id"`
|
||
Name string `json:"name"`
|
||
Sex string `json:"sex"`
|
||
Dept string `json:"dept"`
|
||
Job string `json:"job"`
|
||
Email string `json:"email"`
|
||
Fax string `json:"fax"`
|
||
Phone string `json:"phone"`
|
||
Tel string `json:"tel"`
|
||
Birthday string `json:"birthday"`
|
||
Twitter string `json:"twitter"`
|
||
Facebook string `json:"facebook"`
|
||
Wechat string `json:"wechat"`
|
||
Qq string `json:"qq"`
|
||
Diet string `json:"diet"`
|
||
Religion string `json:"religion"`
|
||
Hobby string `json:"hobby"`
|
||
Info string `json:"info"`
|
||
MainFlag int64 `json:"mainFlag"`
|
||
CreatedAt *time.Time `json:"createdAt"`
|
||
UpdatedAt *time.Time `json:"updatedAt"`
|
||
}
|
||
|
||
// All @TITLE 获取联系人
|
||
func (c *contact) All(ctx context.Context, customId int64) (reply []ContactItem, err error) {
|
||
xClient, err := client.GetClient(c)
|
||
if err != nil {
|
||
return
|
||
}
|
||
err = xClient.Call(ctx, "All", customId, &reply)
|
||
return
|
||
}
|
||
|
||
type ArgsContactAdd struct {
|
||
CustomId int64 // 客户ID
|
||
ContactAdd
|
||
}
|
||
|
||
type ContactAdd struct {
|
||
Name string // 姓名
|
||
Sex string // 性别
|
||
Dept string // 部门
|
||
Job string // 职务
|
||
Email string // 邮箱
|
||
Fax string // 传真
|
||
Phone string // 手机号码
|
||
Tel string // 固定电话
|
||
Birthday string // 生日
|
||
Twitter string // twitter
|
||
Facebook string // facebook
|
||
Wechat string // wechat
|
||
Qq string // qq
|
||
Diet string // 饮食习惯
|
||
Religion string // 宗教信仰
|
||
Hobby string // 兴趣爱好
|
||
Info string // 备注
|
||
MainFlag int64 // 主联系人标记(1=是,2=不是)
|
||
}
|
||
|
||
// Add @TITLE 添加联系人
|
||
func (c *contact) Add(ctx context.Context, args ArgsContactAdd) (err error) {
|
||
xClient, err := client.GetClient(c)
|
||
if err != nil {
|
||
return
|
||
}
|
||
reply := 0
|
||
return xClient.Call(ctx, "Add", args, &reply)
|
||
}
|
||
|
||
type ArgsContactEdit struct {
|
||
ContactId int64 // 联系人ID
|
||
ContactAdd
|
||
}
|
||
|
||
// Edit @TITLE 编辑联系人
|
||
func (c *contact) Edit(ctx context.Context, args ArgsContactEdit) (err error) {
|
||
xClient, err := client.GetClient(c)
|
||
if err != nil {
|
||
return
|
||
}
|
||
reply := 0
|
||
return xClient.Call(ctx, "Edit", args, &reply)
|
||
}
|
||
|
||
// Delete @TITLE 删除联系人
|
||
func (c *contact) Delete(ctx context.Context, contactIds []int64) (err error) {
|
||
xClient, err := client.GetClient(c)
|
||
if err != nil {
|
||
return
|
||
}
|
||
reply := 0
|
||
return xClient.Call(ctx, "Delete", contactIds, &reply)
|
||
}
|