init
This commit is contained in:
192
oa/staff.go
Normal file
192
oa/staff.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user