- 在Ik3cloud结构体中新增Contact和Factory字段 - 定义Entity结构体用于统一返回格式 - 定义Unique结构体用于批量操作参数 - 修改员工添加接口返回值为Entity结构体 - 修改员工禁用、启用和删除接口参数为Unique结构体
107 lines
2.4 KiB
Go
107 lines
2.4 KiB
Go
package ik3cloud
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.kumo.work/shama/service/client"
|
|
"git.kumo.work/shama/service/lib/bean"
|
|
)
|
|
|
|
type staff struct {
|
|
}
|
|
type ArgsStaffList struct {
|
|
Page bean.Page
|
|
Search StaffSearch
|
|
}
|
|
type StaffSearch struct {
|
|
Status int64 // 状态 1=启用 2=停用
|
|
Name string // 姓名
|
|
Phone string // 手机号
|
|
}
|
|
type ReplyStaffList struct {
|
|
List []StaffItem `json:"list"` // 员工列表
|
|
Total int64 `json:"total"` // 总数
|
|
}
|
|
type StaffItem struct {
|
|
Id int64 `json:"id"`
|
|
Number *string `json:"number"` // 工号
|
|
Name *string `json:"name"` // 姓名
|
|
Position *string `json:"position"` // 职位
|
|
Mobile *string `json:"mobile"` // 手机号
|
|
Tel *string `json:"tel"` // 座机
|
|
Status *string `json:"status"` // 状态
|
|
}
|
|
|
|
// List @TITLE 员工列表
|
|
func (s *staff) List(ctx context.Context, args ArgsStaffList) (reply ReplyStaffList, err error) {
|
|
xClient, err := client.GetClient(s)
|
|
if err != nil {
|
|
return
|
|
}
|
|
err = xClient.Call(ctx, "List", args, &reply)
|
|
return
|
|
}
|
|
|
|
type ArgsStaffAdd struct {
|
|
Name string // 姓名
|
|
Number string // 编码
|
|
Mobile any // 手机号
|
|
Tel string // 座机
|
|
Email string // 邮箱
|
|
}
|
|
|
|
// Add @TITLE 添加员工
|
|
func (s *staff) Add(ctx context.Context, args ArgsStaffAdd) (entity Entity, err error) {
|
|
xClient, err := client.GetClient(s)
|
|
if err != nil {
|
|
return
|
|
}
|
|
err = xClient.Call(ctx, "Add", args, &entity)
|
|
return
|
|
}
|
|
|
|
type ArgsStaffEdit struct {
|
|
StaffId int64 // 员工id
|
|
ArgsStaffAdd
|
|
}
|
|
|
|
// Edit @TITLE 员工编辑
|
|
func (s *staff) Edit(ctx context.Context, args ArgsStaffEdit) (err error) {
|
|
xClient, err := client.GetClient(s)
|
|
if err != nil {
|
|
return
|
|
}
|
|
var reply int
|
|
return xClient.Call(ctx, "Edit", args, &reply)
|
|
}
|
|
|
|
// Disable @TITLE 禁用员工
|
|
func (s *staff) Disable(ctx context.Context, args Unique) (err error) {
|
|
xClient, err := client.GetClient(s)
|
|
if err != nil {
|
|
return
|
|
}
|
|
var reply int
|
|
return xClient.Call(ctx, "Disable", args, &reply)
|
|
}
|
|
|
|
// Enable @TITLE 启用员工
|
|
func (s *staff) Enable(ctx context.Context, args Unique) (err error) {
|
|
xClient, err := client.GetClient(s)
|
|
if err != nil {
|
|
return
|
|
}
|
|
var reply int
|
|
return xClient.Call(ctx, "Enable", args, &reply)
|
|
}
|
|
|
|
// Delete @TITLE 删除员工
|
|
func (s *staff) Delete(ctx context.Context, args Unique) (err error) {
|
|
xClient, err := client.GetClient(s)
|
|
if err != nil {
|
|
return
|
|
}
|
|
var reply int
|
|
return xClient.Call(ctx, "Delete", args, &reply)
|
|
}
|