You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
service/customer/user.go

122 lines
3.2 KiB

package customer
import (
"context"
"git.oa00.com/supply-chain/service/client"
user2 "git.oa00.com/supply-chain/service/customer/user"
"git.oa00.com/supply-chain/service/lib/bean"
)
const (
UserStatusDisabled = 1 // 停用
UserStatusEnabled = 2 // 启用
UserTypeManage = 1 // 后台创建
UserTypeSelf = 2 // 自主创建
)
type user struct {
user2.User
}
type UserSearch struct {
Status uint // 状态
Name string // 客户名称
}
type ArgsUserList struct {
Search UserSearch
2 years ago
Page bean.Page
}
type UserItem struct {
Id uint `json:"id"`
Name string `json:"name"`
Account string `json:"account"`
Liaison string `json:"liaison"`
Phone string `json:"phone"`
Status uint `json:"status"`
CreatedType uint `json:"createdType"`
CreatedUserId uint `json:"createdUserId"`
CreatedAt int64 `json:"createdAt"`
}
type ReplyUserList struct {
Lists []UserItem `json:"lists"`
Total int64 `json:"total"`
}
// Lists @Title 获取客户列表
func (u *user) Lists(ctx context.Context, args ArgsUserList) (reply ReplyUserList, err error) {
err = client.GetClient(u).Call(ctx, "Lists", args, &reply)
return
}
type ArgsUserAdd struct {
Name string // 名称
Account string // 账号
Liaison string // 联系人
Phone string // 手机号
Password string // 密码
CreatedType uint // 创建账号类型 1=后台创建 2=自主创建
CreatedUserId uint // 创建人Id
}
// Add @Title 添加客户
func (u *user) Add(ctx context.Context, args ArgsUserAdd) error {
reply := 0
return client.GetClient(u).Call(ctx, "Add", args, &reply)
}
type ReplyUserInfo struct {
Id uint `json:"id"`
Name string `json:"name"`
Liaison string `json:"liaison"`
Phone string `json:"phone"`
Account string `json:"account"`
}
// Info @Title 客户详情
func (u *user) Info(ctx context.Context, userId uint) (result ReplyUserInfo, err error) {
err = client.GetClient(u).Call(ctx, "Info", userId, &result)
return
}
type ArgsUserEdit struct {
Id uint // 客户id
Name string // 名称
Liaison string // 联系人
Phone string // 手机号
Password string // 密码 空=不修改
}
// Edit @Title 编辑客户
func (u *user) Edit(ctx context.Context, args ArgsUserEdit) error {
reply := 0
return client.GetClient(u).Call(ctx, "Edit", args, &reply)
}
// Enable @Title 启用
func (u *user) Enable(ctx context.Context, userId uint) error {
reply := 0
return client.GetClient(u).Call(ctx, "Enable", userId, &reply)
}
// Disable @Title 停用
func (u *user) Disable(ctx context.Context, userId uint) error {
reply := 0
return client.GetClient(u).Call(ctx, "Disable", userId, &reply)
}
type ArgsUserServiceInfo struct {
ServiceId serviceId // 服务id
AppKey string // 渠道appKey
}
type ReplyUserServiceInfo struct {
CustomerId uint `json:"customerId"`
AppSecret string `json:"appSecret"`
ExpirationAt int64 `json:"expirationAt"`
}
// ServiceInfo @Title 获取服务信息
func (u *user) ServiceInfo(ctx context.Context, args ArgsUserServiceInfo) (reply ReplyUserServiceInfo, err error) {
err = client.GetClient(u).Call(ctx, "ServiceInfo", args, &reply)
return
}