department.api 3.4 KB
syntax = "v1"

// 后台接口
@server(
    prefix: v1
    group: department
    middleware: LogRequest
    jwt: SystemAuth
)
service Core {
    @doc  "部门-详情"
    @handler systemDepartmentGet
    get /system/department/:id (DepartmentGetRequest) returns (DepartmentGetResponse)
    @doc  "部门-保存"
    @handler systemDepartmentSave
    post /system/department (DepartmentSaveRequest) returns (DepartmentSaveResponse)
    @doc  "部门-删除"
    @handler systemDepartmentDelete
    delete /system/department/:id (DepartmentDeleteRequest) returns (DepartmentDeleteResponse)
    @doc  "部门-更新"
    @handler systemDepartmentUpdate
    put /system/department/:id (DepartmentUpdateRequest) returns (DepartmentUpdateResponse)
    @doc  "部门-搜索"
    @handler systemDepartmentSearch
    post /system/department/search (DepartmentSearchRequest) returns (DepartmentSearchResponse)
    @doc  "部门-批量删除"
    @handler systemDepartmentBatchDelete
    delete /system/department/batch-del (DepartmentBatchDeleteRequest) returns (DepartmentBatchDeleteResponse)
    @doc  "部门-批量导入"
    @handler systemDepartmentImport
    delete /system/department/import (DepartmentImportRequest) returns (DepartmentImportResponse)
    @doc  "部门-批量导出"
    @handler systemDepartmentExport
    delete /system/department/export (DepartmentSearchRequest) returns (DepartmentSearchResponse)

    @doc  "公司部门"
    @handler systemCompanyDepartments
    post /system/company-departments (DepartmentSearchRequest) returns (DepartmentSearchResponse)
}

type(
    DepartmentGetRequest {
        Id int64 `path:"id"`
    }
    DepartmentGetResponse {
        Department       Department `json:"department"`
        ParentDepartment Department `json:"parentDepartment"`
    }

    DepartmentSaveRequest {
        Department Department `json:"department"`
    }
    DepartmentSaveResponse {}

    DepartmentDeleteRequest {
        Id int64 `path:"id"`
    }
    DepartmentDeleteResponse {}

    DepartmentUpdateRequest {
        Id int64 `path:"id"`
        Department Department `json:"department"`
    }
    DepartmentUpdateResponse {}

    DepartmentSearchRequest {
        Page int  `json:"page,optional"`
        Size int  `json:"size,optional"`
        DepartmentHead string `json:"departmentHead,optional"` // 部门负责人
        DepartmentName string `json:"departmentName,optional"` // 部门名称
        CountUserNumber bool `json:"countUserNumber,optional"` // 统计用户数量
    }
    DepartmentSearchResponse{
        List []Department  `json:"list"`
        Total int64 `json:"total"`
    }
    Department {
        Id              int64   `json:"id,optional,omitempty"`              // 唯一标识
        Name            string  `json:"name,omitempty"`                     // 名称
        Code            string  `json:"code,optional,omitempty"`                     // 部门编码
        ParentId        int64   `json:"parentId,optional,omitempty"`                 // 父级部门ID
        DepartmentHeads []User  `json:"departmentHeads,optional,omitempty"` // 部门负责人
        NumberPeople    int64   `json:"numberPeople,optional,omitempty"`    // 部门人数
    }
)

type(
    // 部门-批量删除
    DepartmentBatchDeleteRequest{
        Departments []int64 `json:"departments"`
    }
    DepartmentBatchDeleteResponse{}

    // 部门-批量导入
    DepartmentImportRequest{}
    DepartmentImportResponse{}
)