2024-06-28 11:50:29 +08:00
|
|
|
package oa
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"git.kumo.work/shama/service/client"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type department struct {
|
|
|
|
}
|
|
|
|
type DepartmentItem struct {
|
2024-08-01 14:51:51 +08:00
|
|
|
Id int64 `json:"id"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
ParentId int64 `json:"parentId"`
|
|
|
|
ManageStaffId int64 `json:"manageStaffId"`
|
|
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
|
|
Children []*DepartmentItem `json:"children"`
|
2024-06-28 11:50:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// All @TITLE 获取部门
|
|
|
|
func (d *department) All(ctx context.Context) (reply []DepartmentItem, err error) {
|
|
|
|
xClient, err := client.GetClient(d)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
err = xClient.Call(ctx, "All", 0, &reply)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
type ArgsDepartmentAdd struct {
|
2024-08-01 14:51:51 +08:00
|
|
|
Name string // 部门名称
|
|
|
|
ParentId int64 // 上级部门id
|
|
|
|
ManageStaffId int64 // 部门负责人
|
2024-06-28 11:50:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add @TITLE 添加部门
|
|
|
|
func (d *department) Add(ctx context.Context, args ArgsDepartmentAdd) (err error) {
|
|
|
|
xClient, err := client.GetClient(d)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var reply int
|
|
|
|
return xClient.Call(ctx, "Add", args, &reply)
|
|
|
|
}
|
|
|
|
|
2024-08-01 14:51:51 +08:00
|
|
|
// Info @TITLE 部门详情
|
|
|
|
func (d *department) Info(ctx context.Context, departmentId int64) (reply DepartmentItem, err error) {
|
|
|
|
xClient, err := client.GetClient(d)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
err = xClient.Call(ctx, "Info", departmentId, &reply)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-06-28 11:50:29 +08:00
|
|
|
type ArgsDepartmentEdit struct {
|
|
|
|
DepartmentId int64 // 部门id
|
|
|
|
ArgsDepartmentAdd
|
|
|
|
}
|
|
|
|
|
|
|
|
// Edit @TITLE 编辑部门
|
|
|
|
func (d *department) Edit(ctx context.Context, args ArgsDepartmentEdit) (err error) {
|
|
|
|
xClient, err := client.GetClient(d)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var reply int
|
|
|
|
return xClient.Call(ctx, "Edit", args, &reply)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete @TITLE 删除部门
|
|
|
|
func (d *department) Delete(ctx context.Context, departmentIds []int64) (err error) {
|
|
|
|
xClient, err := client.GetClient(d)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var reply int
|
|
|
|
return xClient.Call(ctx, "Delete", departmentIds, &reply)
|
|
|
|
}
|
|
|
|
|
|
|
|
type ArgsDepartmentSetStaff struct {
|
|
|
|
DepartmentId int64
|
|
|
|
StaffIds []int64
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetStaff @TITLE 配置部门员工
|
|
|
|
func (d *department) SetStaff(ctx context.Context, args ArgsDepartmentSetStaff) (err error) {
|
|
|
|
xClient, err := client.GetClient(d)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var reply int
|
|
|
|
return xClient.Call(ctx, "SetStaff", args, &reply)
|
|
|
|
}
|