95 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			95 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package oa
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 	"git.kumo.work/shama/service/client"
 | |
| 	"time"
 | |
| )
 | |
| 
 | |
| type department struct {
 | |
| }
 | |
| type DepartmentItem struct {
 | |
| 	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"`
 | |
| }
 | |
| 
 | |
| // 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 {
 | |
| 	Name          string // 部门名称
 | |
| 	ParentId      int64  // 上级部门id
 | |
| 	ManageStaffId int64  // 部门负责人
 | |
| }
 | |
| 
 | |
| // 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)
 | |
| }
 | |
| 
 | |
| // 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
 | |
| }
 | |
| 
 | |
| 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)
 | |
| }
 |