This commit is contained in:
2024-06-28 11:50:29 +08:00
commit 6dd80a46ca
13 changed files with 1364 additions and 0 deletions

82
oa/department.go Normal file
View File

@@ -0,0 +1,82 @@
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"`
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
}
// 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)
}
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)
}

7
oa/oa.go Normal file
View File

@@ -0,0 +1,7 @@
package oa
type Oa struct {
Department department
Staff staff
Role role
}

96
oa/role.go Normal file
View File

@@ -0,0 +1,96 @@
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)
}

192
oa/staff.go Normal file
View File

@@ -0,0 +1,192 @@
package oa
import (
"context"
"git.kumo.work/shama/service/client"
"git.kumo.work/shama/service/lib/bean"
"time"
)
type staff struct {
}
type ArgsStaffLogin struct {
Account string
Password string
}
type ReplyStaffInfo struct {
Id int64 `json:"id"`
Name string `json:"name"`
EnName string `json:"enName"`
Account string `json:"account"`
Status int64 `json:"status"`
Avatar string `json:"avatar"`
Gender string `json:"gender"`
Phone string `json:"phone"`
Email string `json:"email"`
DepartmentId int64 `json:"departmentId"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
// Login @TITLE 登录
func (s *staff) Login(ctx context.Context, args ArgsStaffLogin) (reply ReplyStaffInfo, err error) {
xClient, err := client.GetClient(s)
if err != nil {
return
}
err = xClient.Call(ctx, "Login", args, &reply)
return
}
type ArgsStaffResetPass struct {
StaffId int64 // 员工id
Password string // 密码
}
// ResetPass @TITLE 修改密码
func (s *staff) ResetPass(ctx context.Context, args ArgsStaffResetPass) (err error) {
xClient, err := client.GetClient(s)
if err != nil {
return
}
var reply int
return xClient.Call(ctx, "ResetPass", args, &reply)
}
type ArgsStaffResetPassByPhone struct {
Phone string // 手机号
Password string // 密码
}
// ResetPassByPhone @TITLE 根据手机号修改密码
func (s *staff) ResetPassByPhone(ctx context.Context, args ArgsStaffResetPassByPhone) (err error) {
xClient, err := client.GetClient(s)
if err != nil {
return
}
var reply int
return xClient.Call(ctx, "ResetPassByPhone", args, &reply)
}
type ArgsStaffList struct {
Page bean.Page
Search StaffSearch
}
type StaffSearch struct {
Status int64 // 状态 1=启用 2=停用
Keyword string // 关键字
Phone string // 手机号
DepartmentIds []int64 // 部门筛选
RoleIds []int64 // 角色筛选
}
type ReplyStaffList struct {
List []StaffItem `json:"list"` // 员工列表
Total int64 `json:"total"` // 总数
}
type StaffItem struct {
Id int64 `json:"id"` // 员工id
Name string `json:"name"` // 中文名
EnName string `json:"enName"` // 英文名
Account string `json:"account"` // 账号
Status int64 `json:"status"` // 状态 1=启用 2=停用
Avatar string `json:"avatar"` // 头像
Gender string `json:"gender"` // 性别
Phone string `json:"phone"` // 手机号
Email string `json:"email"` // 邮箱
DepartmentId int64 `json:"departmentId"` // 部门id
DepartmentName string `json:"departmentName"` // 部门名称
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
// 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 // 中文名
EnName string // 英文名
Account string // 账号
Password string // 密码
Status int64 // 状态 1=启用 2=停用
Avatar string // 头像
Gender string // 性别
Phone string // 手机号
Email string // 邮箱
DepartmentId int64 // 所属部门
}
// Add @TITLE 添加员工
func (s *staff) Add(ctx context.Context, args ArgsStaffAdd) (err error) {
xClient, err := client.GetClient(s)
if err != nil {
return
}
var reply int
return xClient.Call(ctx, "Add", args, &reply)
}
// Info @TITLE 员工详情
func (s *staff) Info(ctx context.Context, staffId int64) (reply ReplyStaffInfo, err error) {
xClient, err := client.GetClient(s)
if err != nil {
return
}
err = xClient.Call(ctx, "Info", staffId, &reply)
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)
}
type ReplyStaffRoleItem struct {
Id int64 // 角色id
Name string // 角色名称
Describe string // 角色描述
CreatedAt time.Time
UpdatedAt time.Time
}
// Roles @TITLE 获取角色
func (s *staff) Roles(ctx context.Context, staffId int64) (reply []ReplyStaffRoleItem, err error) {
xClient, err := client.GetClient(s)
if err != nil {
return
}
err = xClient.Call(ctx, "Roles", staffId, &reply)
return
}
type ArgsStaffSetRoles struct {
StaffId int64 // 员工id
RoleIds []int64 // 角色id
}
// SetRoles @TITLE 设置角色
func (s *staff) SetRoles(ctx context.Context, args ArgsStaffSetRoles) (err error) {
xClient, err := client.GetClient(s)
if err != nil {
return
}
var reply int
return xClient.Call(ctx, "SetRoles", args, &reply)
}