employee.api 5.9 KB
syntax = "v1"

// 后台接口
@server(
    prefix: v1
    group: employee
    middleware: LogRequest
    jwt: SystemAuth
)
service Core {
    @doc  "职员-详情"
    @handler systemEmployeeGet
    get /system/employee/:id (EmployeeGetRequest) returns (EmployeeGetResponse)
    @doc  "职员-保存"
    @handler systemEmployeeSave
    post /system/employee (EmployeeSaveRequest) returns (EmployeeSaveResponse)
    @doc  "职员-删除"
    @handler systemEmployeeDelete
    delete /system/employee/:id (EmployeeDeleteRequest) returns (EmployeeDeleteResponse)
    @doc  "职员-更新"
    @handler systemEmployeeUpdate
    put /system/employee/:id (EmployeeUpdateRequest) returns (EmployeeUpdateResponse)
    @doc  "职员-搜索"
    @handler systemEmployeeSearch
    post /system/employee/search (EmployeeSearchRequest) returns (EmployeeSearchResponse)
    @doc  "职员-设置账号状态(启用、停用)"
    @handler systemEmployeeSetAccountStatus
    post /system/employee/set-account-status (EmployeeSetAccountStatusRequest) returns (EmployeeSetAccountStatusResponse)
    @doc  "职员-变更部门"
    @handler systemEmployeeChangeDepartments
    post /system/employee/change-departments (EmployeeChangeDepartmentsRequest) returns (EmployeeChangeDepartmentsResponse)
    @doc  "职员-导入"
    @handler systemEmployeeImport
    post /system/employee/import (EmployeeImportRequest) returns (EmployeeImportResponse)
    @doc  "职员-导出"
    @handler systemEmployeeExport
    post /system/employee/export (EmployeeSearchRequest) returns (EmployeeSearchResponse)
    @doc  "职员-部门职员"
    @handler systemDepartmentEmployees
    post /system/department-employees (DepartmentEmployeesRequest) returns (DepartmentEmployeesResponse)
}

type(
    EmployeeGetRequest {
        Id int64 `path:"id"`
    }
    EmployeeGetResponse{
        Employee Employee `json:"employee"`
    }

    EmployeeSaveRequest{
        Employee Employee `json:"employee"`
    }
    EmployeeSaveResponse{}

    EmployeeDeleteRequest{
        Id int64 `path:"id"`
    }
    EmployeeDeleteResponse{}

    EmployeeUpdateRequest{
        Id int64 `path:"id"`
        Employee Employee `json:"employee"`
    }
    EmployeeUpdateResponse{}

    EmployeeSearchRequest{
        Page int  `json:"page,optional"`
        Size int  `json:"size,optional"`
        AccountStatus *int `json:"accountStatus,optional"` // 1.正常 2.已暂停
        Name string `json:"name,optional"`     // 姓名
        Phone string `json:"phone,optional"`   // 手机号
        DepartmentId int64 `json:"departmentId,string,optional"` // 按部门过滤
    }
    EmployeeSearchResponse{
        List  []Employee  `json:"list"`
        Total int64           `json:"total"`
    }
    Employee{
        Id           int64   `json:"id,string,optional,omitempty"`
        UserId       int64   `json:"userId,optional,omitempty"`
        Name         string  `json:"name,omitempty"`     // 姓名
        Code         string  `json:"code,optional,omitempty"`     // 员工编码
        Phone        string  `json:"phone,omitempty"`    // 手机号
        Departments  []Department         `json:"departments,optional,omitempty"` // 部门列表
        AccountStatus int                 `json:"accountStatus,optional,omitempty"` // 账号状态  1.正常 2.已暂停
        EmployeeType string               `json:"employeeType,optional,omitempty"` // 人员类型 正式、实习、外包、劳务、顾问
        EmployedDate int64                `json:"employedDate,optional,omitempty"`    // 入职时间
        Superior     *User                `json:"superior,optional,omitempty"`        // 直属上级
        Roles        []Role       `json:"roles,optional,omitempty"`    // 管理员角色
        Groups       []Group      `json:"groups,optional,omitempty"`   // 用户组
    }

    // 职员-设置账号状态(启用、停用)
    EmployeeSetAccountStatusRequest{
        EmployeeList []int64 `json:"employeeList"` // 职员列表
        AccountStatus int `json:"accountStatus"` // 1.正常 2.已暂停
    }
    EmployeeSetAccountStatusResponse{}

    // 职员-变更部门
    EmployeeChangeDepartmentsRequest{
        EmployeeList []string `json:"employeeList"` // 职员列表
        Departments  []string `json:"departments"`  // 部门列表
    }
    EmployeeChangeDepartmentsResponse{}

    // 职员-导入
    EmployeeImportRequest{

    }
    EmployeeImportResponse{}
)

type (
    DepartmentEmployeesRequest{
        CompanyId int64 `json:"companyId,optional"`
    }
    DepartmentEmployeesResponse{
        Departments []DepartmentEmployeeItem `json:"departments"`
    }
    DepartmentEmployeeItem{
        Id        int64      `json:"id,string"`         // 部门ID
        Name      string     `json:"name"`       // 部门名称
        Parent    int64      `json:"parent"`     // 父级
        Employees []Employee `json:"employees"`  // 职员列表
    }
)

//type(
//    Department {
//        Id              int64   `json:"id,optional,omitempty"`              // 唯一标识
//        Name            string  `json:"name,omitempty"`                     // 名称
//        Code            string  `json:"code,omitempty"`                     // 部门编码
//        ParentId        int64   `json:"parentId,omitempty"`                 // 父级部门ID
//        DepartmentHeads []User  `json:"departmentHeads,optional,omitempty"` // 部门负责人
//        NumberPeople    int64   `json:"numberPeople,optional,omitempty"`    // 部门人数
//    }
//    User{
//        Id    int64  `json:"id"`   // 用户ID
//        Name  string `json:"name"` // 用户名称
//        Phone string `json:"phone,omitempty"` // 用户手机号
//    }
//    Group {
//        Id   int64  `json:"id"`      // 分组ID
//        Name string `json:"name"`    // 分组名称
//    }
//    Role{
//        Id   int64  `json:"id"`      // 角色ID
//        Name string `json:"name"`    // 角色名称
//    }
//)