hrbrain

package
v1.0.63 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package hrbrain registers fail-closed Shortcut adapters for DingTalk Organization Brain reads. A declaration becomes available only after the lower service supplies a reviewed, verifiable business response.

Index

Constants

This section is empty.

Variables

View Source
var GetPool = func() shortcut.Shortcut {
	declaration := hrbrainBase(
		"+get-pool", "根据 poolCode 查询人才池详情", "已知稳定 poolCode 并需要读取同一人才池详情时使用;没有安全非空 fixture 前保持 unavailable。",
		hrbrainObjectResult("身份匹配的人才池详情"), nil,
		[]shortcut.Flag{{Name: "pool-code", Type: shortcut.FlagString, Required: true, Desc: "人才池稳定 poolCode"}},
		[]contract.ParamDecl{{Name: "pool-code", Property: "poolCode"}},
		`dws hrbrain +get-pool --pool-code <POOL_CODE> --format json`,
	)
	declaration.Execute = func(rt *shortcut.RuntimeContext) error {
		return hrbrainCallObject(rt, "get_talent_pool_detail", map[string]any{"poolCode": rt.Str("pool-code")}, rt.Str("pool-code"), "poolCode")
	}
	return declaration
}()
View Source
var ListPoolEmployees = func() shortcut.Shortcut {
	declaration := hrbrainBase(
		"+list-pool-employees", "查询指定人才池内的员工列表", "已知稳定 poolCode 并需要分页读取池内员工时使用;缺少安全人才池与员工 fixture 前保持 unavailable。",
		hrbrainPageResult("严格校验的人才池员工页"), hrbrainPagination(),
		[]shortcut.Flag{
			{Name: "pool-code", Type: shortcut.FlagString, Required: true, Desc: "人才池稳定 poolCode"},
			{Name: "page", Type: shortcut.FlagInt, Default: "1", Desc: "页码必须大于 0"},
			{Name: "page-size", Type: shortcut.FlagInt, Default: "20", Desc: "每页数量必须在 1 到 100 之间"},
		},
		[]contract.ParamDecl{
			{Name: "pool-code", Property: "poolCode"}, {Name: "page", Property: "currentPage", InterfaceType: "number"},
			{Name: "page-size", Property: "pageSize", InterfaceType: "number"},
		},
		`dws hrbrain +list-pool-employees --pool-code <POOL_CODE> --page 1 --page-size 20 --format json`,
	)
	declaration.Constraints = hrbrainPageConstraints()
	declaration.Validate = hrbrainValidatePage
	declaration.Execute = func(rt *shortcut.RuntimeContext) error {
		return hrbrainCallPage(rt, "list_pool_employees", map[string]any{
			"poolCode": rt.Str("pool-code"), "currentPage": rt.Int("page"), "pageSize": rt.Int("page-size"),
		}, "workNo", "staffId", "userId")
	}
	return declaration
}()
View Source
var ListPools = func() shortcut.Shortcut {
	declaration := hrbrainBase(
		"+list-pools", "查询组织大脑人才池列表", "需要按名称、类型、创建人或标签发现人才池时使用;严格验证 content.pools 与分页字段,但在获得安全非空人才池 fixture 前保持 unavailable。",
		hrbrainPageResult("严格校验的人才池搜索页"), hrbrainPagination(),
		[]shortcut.Flag{
			{Name: "keyword", Type: shortcut.FlagString, Desc: "人才池名称关键词"},
			{Name: "pool-type", Type: shortcut.FlagString, Desc: "人才池类型"},
			{Name: "creator", Type: shortcut.FlagString, Desc: "创建人稳定身份"},
			{Name: "labels", Type: shortcut.FlagStringSlice, Desc: "标签列表"},
			{Name: "page", Type: shortcut.FlagInt, Default: "1", Desc: "页码必须大于 0"},
			{Name: "page-size", Type: shortcut.FlagInt, Default: "20", Desc: "每页数量必须在 1 到 100 之间"},
		},
		[]contract.ParamDecl{
			{Name: "keyword", Property: "keyword"}, {Name: "pool-type", Property: "poolType"},
			{Name: "creator", Property: "creator"}, {Name: "labels", Property: "labels"},
			{Name: "page", Property: "currentPage", InterfaceType: "number"}, {Name: "page-size", Property: "pageSize", InterfaceType: "number"},
		},
		`dws hrbrain +list-pools --page 1 --page-size 20 --format json`,
	)
	declaration.Constraints = hrbrainPageConstraints()
	declaration.Validate = hrbrainValidatePage
	declaration.Execute = func(rt *shortcut.RuntimeContext) error {
		params := map[string]any{"currentPage": rt.Int("page"), "pageSize": rt.Int("page-size")}
		hrbrainAddOptional(params, rt, "keyword", "keyword")
		hrbrainAddOptional(params, rt, "pool-type", "poolType")
		hrbrainAddOptional(params, rt, "creator", "creator")
		if rt.Changed("labels") {
			params["labels"] = hrbrainCleanValues(rt.StrSlice("labels"))
		}
		return hrbrainCallPoolsPage(rt, params)
	}
	return declaration
}()
View Source
var ProfileCareer = hrbrainCollectionShortcut(
	"+profile-career", "查询员工公司内职业历程", "已知稳定工号并需要读取岗位或职级变动历史时使用;下游未通过 live 可用性验证。",
	"get_employee_career", "work-no", "workNo", "职业历程", []string{"careerId", "id", "workNo"},
)
View Source
var ProfileLabels = func() shortcut.Shortcut {
	declaration := hrbrainBase(
		"+profile-labels", "批量查询员工档案标签", "已知一组稳定工号并需要读取标签时使用;下游当前 success=true 但 result=null,保持 unavailable。",
		hrbrainCollectionResult("严格校验的员工标签结果"), nil,
		[]shortcut.Flag{
			{Name: "staff-ids", Type: shortcut.FlagStringSlice, Required: true, Desc: "一个或多个非空员工工号"},
			{Name: "all-label", Type: shortcut.FlagBool, Desc: "是否返回全部标签"},
		},
		[]contract.ParamDecl{{Name: "staff-ids", Property: "staffIds"}, {Name: "all-label", Property: "allLabel"}},
		`dws hrbrain +profile-labels --staff-ids <WORK_NO> --format json`,
	)
	declaration.Constraints = []shortcut.Constraint{{Kind: shortcut.ConstraintCustom, Flags: []string{"staff-ids"}, Description: "必须包含一个或多个非空员工工号"}}
	declaration.Validate = func(rt *shortcut.RuntimeContext) error {
		if len(hrbrainCleanValues(rt.StrSlice("staff-ids"))) == 0 {
			return apperrors.NewValidation("--staff-ids 必须包含一个或多个非空员工工号")
		}
		return nil
	}
	declaration.Execute = func(rt *shortcut.RuntimeContext) error {
		params := map[string]any{"staffIds": hrbrainCleanValues(rt.StrSlice("staff-ids"))}
		if rt.Changed("all-label") {
			params["allLabel"] = rt.Bool("all-label")
		}
		return hrbrainCallCollection(rt, "get_profile_label", params, "workNo", "staffId", "userId")
	}
	return declaration
}()
View Source
var ProfileMetadata = hrbrainCollectionShortcut(
	"+profile-metadata", "查询员工档案元数据结构", "已知工号并需要发现可查询档案模块与字段时使用;下游工具当前不可验证,保持 unavailable。",
	"get_profile_metadata", "work-no", "workNo", "档案元数据", []string{"modelCode", "fieldCode", "code"},
)
View Source
var ProfilePerformance = hrbrainCollectionShortcut(
	"+profile-performance", "查询员工历史绩效记录", "已知稳定工号并需要读取历史绩效时使用;下游未通过 live 可用性验证。",
	"get_employee_performance", "work-no", "workNo", "绩效记录", []string{"performanceId", "id", "workNo"},
)
View Source
var QueryProfile = func() shortcut.Shortcut {
	declaration := hrbrainBase(
		"+query-profile", "按模块批量查询员工档案数据", "已知工号、模块与字段编码并需要批量读取档案时使用;下游可用性和结果合同未通过 live 验证。",
		hrbrainCollectionResult("严格校验的员工档案模块结果"), nil,
		[]shortcut.Flag{
			{Name: "work-no", Type: shortcut.FlagString, Required: true, Desc: "员工稳定工号"},
			{Name: "data-queries", Type: shortcut.FlagString, Required: true, Desc: "必须是非空 JSON 数组的模块查询条件"},
		},
		[]contract.ParamDecl{{Name: "work-no", Property: "workNo"}, {Name: "data-queries", Property: "dataQueries"}},
		`dws hrbrain +query-profile --work-no <WORK_NO> --data-queries '[{"modelCode":"basic","fields":["name"]}]' --format json`,
	)
	declaration.Constraints = []shortcut.Constraint{{Kind: shortcut.ConstraintCustom, Flags: []string{"data-queries"}, Description: "必须是非空 JSON 数组的模块查询条件"}}
	declaration.Validate = func(rt *shortcut.RuntimeContext) error {
		_, err := hrbrainJSONArray(rt.Str("data-queries"), "--data-queries")
		return err
	}
	declaration.Execute = func(rt *shortcut.RuntimeContext) error {

		queries, _ := hrbrainJSONArray(rt.Str("data-queries"), "--data-queries")
		return hrbrainCallCollection(rt, "query_profile_data", map[string]any{"workNo": rt.Str("work-no"), "dataQueries": queries}, "modelCode", "moduleCode")
	}
	return declaration
}()
View Source
var SearchEmployees = func() shortcut.Shortcut {
	declaration := hrbrainEmployeeSearchBase(
		"+search-employees", "按关键词、部门、职务、职级或人才池搜索员工", "需要按至少一个基础过滤条件搜索员工时使用;当前下游返回业务错误且缺少安全非空 fixture。",
		"search_employees",
	)
	declaration.Constraints = append(hrbrainPageConstraints(), shortcut.Constraint{
		Kind: shortcut.ConstraintAtLeastOne, Flags: []string{"keyword", "dept-name", "position-name", "job-level", "pool-code"},
		Description: "至少提供一个员工搜索过滤条件,禁止无条件枚举组织人员",
	})
	declaration.Validate = hrbrainValidatePage
	declaration.Execute = func(rt *shortcut.RuntimeContext) error {
		params := map[string]any{"currentPage": rt.Int("page"), "pageSize": rt.Int("page-size")}
		for _, pair := range [][2]string{{"keyword", "keyword"}, {"dept-name", "deptName"}, {"position-name", "positionName"}, {"job-level", "jobLevel"}, {"pool-code", "poolCode"}} {
			hrbrainAddOptional(params, rt, pair[0], pair[1])
		}
		return hrbrainCallPage(rt, "search_employees", params, "workNo", "staffId", "userId")
	}
	return declaration
}()
View Source
var SearchEmployeesStructured = func() shortcut.Shortcut {
	declaration := hrbrainBase(
		"+search-employees-structured", "使用高级条件表达式搜索员工", "已先取得有权限字段,并需要组合过滤表达式搜索员工时使用;下游工具当前不可用。",
		hrbrainPageResult("严格校验的高级员工搜索页"), hrbrainPagination(),
		[]shortcut.Flag{
			{Name: "origin-json", Type: shortcut.FlagString, Required: true, Desc: "必须是非空 JSON 对象的搜索表达式"},
			{Name: "fields", Type: shortcut.FlagString, Required: true, Desc: "必须是非空 JSON 数组的返回字段"},
			{Name: "order-by", Type: shortcut.FlagStringSlice, Desc: "排序字段列表"},
			{Name: "page", Type: shortcut.FlagInt, Default: "1", Desc: "页码必须大于 0"},
			{Name: "page-size", Type: shortcut.FlagInt, Default: "20", Desc: "每页数量必须在 1 到 100 之间"},
		},
		[]contract.ParamDecl{
			{Name: "origin-json", Property: "originJson"}, {Name: "fields", Property: "fields"}, {Name: "order-by", Property: "orderByClauses"},
			{Name: "page", Property: "currentPage", InterfaceType: "number"}, {Name: "page-size", Property: "pageSize", InterfaceType: "number"},
		},
		`dws hrbrain +search-employees-structured --origin-json '{"rules":[],"combinator":"and"}' --fields '[{"label":"name","value":"name"}]' --format json`,
	)
	declaration.Constraints = append(hrbrainPageConstraints(),
		shortcut.Constraint{Kind: shortcut.ConstraintCustom, Flags: []string{"origin-json"}, Description: "必须是非空 JSON 对象的搜索表达式"},
		shortcut.Constraint{Kind: shortcut.ConstraintCustom, Flags: []string{"fields"}, Description: "必须是非空 JSON 数组的返回字段"},
	)
	declaration.Validate = func(rt *shortcut.RuntimeContext) error {
		if err := hrbrainValidatePage(rt); err != nil {
			return err
		}
		if _, err := hrbrainJSONObject(rt.Str("origin-json"), "--origin-json"); err != nil {
			return err
		}
		_, err := hrbrainJSONArray(rt.Str("fields"), "--fields")
		return err
	}
	declaration.Execute = func(rt *shortcut.RuntimeContext) error {

		origin, _ := hrbrainJSONObject(rt.Str("origin-json"), "--origin-json")
		fields, _ := hrbrainJSONArray(rt.Str("fields"), "--fields")
		params := map[string]any{
			"originJson": string(mustJSON(origin)), "fields": fields,
			"currentPage": rt.Int("page"), "pageSize": rt.Int("page-size"),
		}
		if rt.Changed("order-by") {
			params["orderByClauses"] = hrbrainCleanValues(rt.StrSlice("order-by"))
		}
		return hrbrainCallPage(rt, "search_employees_structured", params, "workNo", "staffId", "userId")
	}
	return declaration
}()
View Source
var SearchFields = func() shortcut.Shortcut {
	declaration := hrbrainBase(
		"+search-fields", "获取当前身份可用的高级人才搜索字段", "构造高级员工搜索表达式前发现字段与操作符时使用;下游工具当前返回业务错误,保持 unavailable。",
		hrbrainCollectionResult("严格校验的高级搜索字段"), nil, nil, nil,
		`dws hrbrain +search-fields --format json`,
	)
	declaration.Execute = func(rt *shortcut.RuntimeContext) error {
		return hrbrainCallCollection(rt, "get_search_fields", nil, "fieldCode", "code", "value")
	}
	return declaration
}()

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL