| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- package schema
- // 知识库类型(DatasetRelation.Type / Dataset.Type)
- const (
- DatasetTypePublic = 1 // 公共/共享知识库(系统管理员创建)
- DatasetTypeOrg = 2 // 企业知识库(企业管理员创建)
- DatasetTypePersonal = 3 // 个人知识库(员工自建)
- )
- // DatasetRelation 知识库关系映射
- // BizID 表示授权主体:
- // - 组织级授权:BizID = org_id
- // - 用户级授权:BizID = user_id
- // Type 表示该知识库本身的分类(1/2/3),便于前端按类型区分渲染。
- type DatasetRelation struct {
- RecordID string `json:"record_id"` // 记录id
- DatasetId string `json:"dataset_id"` // 知识库id
- BizId string `json:"biz_id"` // 业务id:企业id 或 用户id
- Type int `json:"type"` // 1 公共/共享 2 企业 3 个人
- CreatorId string `json:"creator_id"` // 关联创建人
- }
- // DatasetRelationQueryParam 查询条件
- type DatasetRelationQueryParam struct {
- RecordIDs []string
- DatasetId string
- DatasetIds []string
- BizId string
- BizIds []string
- Type int // 0 表示不按类型筛选
- Types []int // 按多种类型筛选
- }
- // DatasetRelationQueryOptions 可选查询参数
- type DatasetRelationQueryOptions struct {
- PageParam *PaginationParam
- }
- type DatasetRelations []*DatasetRelation
- // DatasetRelationQueryResult 查询结果
- type DatasetRelationQueryResult struct {
- Data DatasetRelations
- PageResult *PaginationResult
- }
- // ToDatasetIds 提取 dataset_id 列表
- func (a DatasetRelations) ToDatasetIds() []string {
- ids := make([]string, len(a))
- for i, v := range a {
- ids[i] = v.DatasetId
- }
- return ids
- }
- // FilterByType 按 type 过滤
- func (a DatasetRelations) FilterByType(t int) DatasetRelations {
- out := make(DatasetRelations, 0, len(a))
- for _, v := range a {
- if v.Type == t {
- out = append(out, v)
- }
- }
- return out
- }
|