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

104 lines
2.6 KiB

package customer
import (
"context"
"git.oa00.com/supply-chain/service/client"
"git.oa00.com/supply-chain/service/lib/bean"
)
const (
UserStatusDisabled = 1 // 停用
UserStatusEnabled = 2 // 启用
UserTypeManage = 1 // 后台创建
UserTypeSelf = 2 // 自主创建
)
type user struct {
}
type UserSearch struct {
Status uint // 状态
Name string // 客户名称
}
type ArgsUserList struct {
Search UserSearch
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)
}