97 lines
2.0 KiB
Go
97 lines
2.0 KiB
Go
package oa
|
|
|
|
import (
|
|
"context"
|
|
"git.kumo.work/shama/service/client"
|
|
"git.kumo.work/shama/service/lib/bean"
|
|
"time"
|
|
)
|
|
|
|
type role struct {
|
|
}
|
|
|
|
type ArgsRoleList struct {
|
|
Page bean.Page
|
|
Search RoleSearch
|
|
}
|
|
type RoleSearch struct {
|
|
Name string // 角色名称
|
|
}
|
|
type ReplyRoleList struct {
|
|
List []RoleItem `json:"list"` // 员工列表
|
|
Total int64 `json:"total"` // 总数
|
|
}
|
|
type RoleItem struct {
|
|
Id int64 `json:"id"`
|
|
Name string `json:"name"` // 角色名称
|
|
Describe string `json:"describe"` // 角色描述
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
}
|
|
|
|
// List @TITLE 角色列表
|
|
func (r *role) List(ctx context.Context, args ArgsRoleList) (reply ReplyRoleList, err error) {
|
|
xClient, err := client.GetClient(r)
|
|
if err != nil {
|
|
return
|
|
}
|
|
err = xClient.Call(ctx, "List", args, &reply)
|
|
return
|
|
}
|
|
|
|
type ArgsRoleAdd struct {
|
|
Name string // 角色名称
|
|
Describe string // 描述
|
|
}
|
|
|
|
// Add @TITLE 添加角色
|
|
func (r *role) Add(ctx context.Context, args ArgsRoleAdd) (err error) {
|
|
xClient, err := client.GetClient(r)
|
|
if err != nil {
|
|
return
|
|
}
|
|
var reply int
|
|
err = xClient.Call(ctx, "Add", args, &reply)
|
|
return
|
|
}
|
|
|
|
type ArgsRoleEdit struct {
|
|
RoleId int64 // 部门id
|
|
ArgsRoleAdd
|
|
}
|
|
|
|
// Edit @TITLE 编辑角色
|
|
func (r *role) Edit(ctx context.Context, args ArgsRoleEdit) (err error) {
|
|
xClient, err := client.GetClient(r)
|
|
if err != nil {
|
|
return
|
|
}
|
|
var reply int
|
|
err = xClient.Call(ctx, "Edit", args, &reply)
|
|
return
|
|
}
|
|
|
|
// Delete @TITLE 删除角色
|
|
func (r *role) Delete(ctx context.Context, roleIds []int64) (err error) {
|
|
xClient, err := client.GetClient(r)
|
|
if err != nil {
|
|
return
|
|
}
|
|
var reply int
|
|
return xClient.Call(ctx, "Delete", roleIds, &reply)
|
|
}
|
|
|
|
type ArgsRoleSetStaff struct {
|
|
RoleId int64
|
|
StaffIds []int64
|
|
}
|
|
|
|
// SetStaff @TITLE 配置角色员工
|
|
func (r *role) SetStaff(ctx context.Context, args ArgsRoleSetStaff) (err error) {
|
|
xClient, err := client.GetClient(r)
|
|
if err != nil {
|
|
return
|
|
}
|
|
var reply int
|
|
return xClient.Call(ctx, "SetStaff", args, &reply)
|
|
}
|