- 为 DepartmentItem 结构体添加 Id 字段以支持唯一标识 - 新增部门添加、编辑和删除方法,支持基础信息维护 - 为 StaffItem 结构体添加 Id 和 Tel 字段,完善员工信息结构 - 新增员工添加、编辑、启用、禁用及删除方法 - 所有操作均通过 RPC 客户端调用对应服务接口实现 - 方法参数结构体定义明确,便于外部调用与数据传输
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) (staffId int64, err error) {
|
|
xClient, err := client.GetClient(s)
|
|
if err != nil {
|
|
return
|
|
}
|
|
err = xClient.Call(ctx, "Add", args, &staffId)
|
|
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, numbers []string) (err error) {
|
|
xClient, err := client.GetClient(s)
|
|
if err != nil {
|
|
return
|
|
}
|
|
var reply int
|
|
return xClient.Call(ctx, "Disable", numbers, &reply)
|
|
}
|
|
|
|
// Enable @TITLE 启用员工
|
|
func (s *staff) Enable(ctx context.Context, numbers []string) (err error) {
|
|
xClient, err := client.GetClient(s)
|
|
if err != nil {
|
|
return
|
|
}
|
|
var reply int
|
|
return xClient.Call(ctx, "Enable", numbers, &reply)
|
|
}
|
|
|
|
// Delete @TITLE 删除员工
|
|
func (s *staff) Delete(ctx context.Context, numbers []string) (err error) {
|
|
xClient, err := client.GetClient(s)
|
|
if err != nil {
|
|
return
|
|
}
|
|
var reply int
|
|
return xClient.Call(ctx, "Delete", numbers, &reply)
|
|
}
|