feat: manually mirror opencoze's code from bytedance
Change-Id: I09a73aadda978ad9511264a756b2ce51f5761adf
This commit is contained in:
108
backend/domain/search/entity/project_doc.go
Normal file
108
backend/domain/search/entity/project_doc.go
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package entity
|
||||
|
||||
import "github.com/coze-dev/coze-studio/backend/api/model/intelligence/common"
|
||||
|
||||
type ProjectDocument struct {
|
||||
ID int64 `json:"id"`
|
||||
Type common.IntelligenceType `json:"type"`
|
||||
Status common.IntelligenceStatus `json:"status,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
SpaceID *int64 `json:"space_id,omitempty"`
|
||||
OwnerID *int64 `json:"owner_id,omitempty"`
|
||||
HasPublished *int `json:"has_published,omitempty"`
|
||||
CreateTimeMS *int64 `json:"create_time,omitempty"`
|
||||
UpdateTimeMS *int64 `json:"update_time,omitempty"`
|
||||
PublishTimeMS *int64 `json:"publish_time,omitempty"`
|
||||
RecentlyOpenMS *int64 `json:"recently_open_time,omitempty"`
|
||||
FavTimeMS *int64 `json:"fav_time,omitempty"`
|
||||
IsFav *int `json:"is_fav,omitempty"`
|
||||
IsRecentlyOpen *int `json:"is_recently_open,omitempty"`
|
||||
}
|
||||
|
||||
// GetName
|
||||
func (a *ProjectDocument) GetName() string {
|
||||
if a.Name == nil {
|
||||
return ""
|
||||
}
|
||||
return *a.Name
|
||||
}
|
||||
|
||||
// GetSpaceID
|
||||
func (a *ProjectDocument) GetSpaceID() int64 {
|
||||
if a.SpaceID == nil {
|
||||
return 0
|
||||
}
|
||||
return *a.SpaceID
|
||||
}
|
||||
|
||||
// GetOwnerID
|
||||
func (a *ProjectDocument) GetOwnerID() int64 {
|
||||
if a.OwnerID == nil {
|
||||
return 0
|
||||
}
|
||||
return *a.OwnerID
|
||||
}
|
||||
|
||||
// GetCreateTime
|
||||
func (a *ProjectDocument) GetCreateTime() int64 {
|
||||
if a.CreateTimeMS == nil {
|
||||
return 0
|
||||
}
|
||||
return *a.CreateTimeMS
|
||||
}
|
||||
|
||||
// GetUpdateTime
|
||||
func (a *ProjectDocument) GetUpdateTime() int64 {
|
||||
if a.UpdateTimeMS == nil {
|
||||
return 0
|
||||
}
|
||||
return *a.UpdateTimeMS
|
||||
}
|
||||
|
||||
// GetPublishTime
|
||||
func (a *ProjectDocument) GetPublishTime() int64 {
|
||||
if a.PublishTimeMS == nil {
|
||||
return 0
|
||||
}
|
||||
return *a.PublishTimeMS
|
||||
}
|
||||
|
||||
// GetRecentlyOpenTime
|
||||
func (a *ProjectDocument) GetRecentlyOpenTime() int64 {
|
||||
if a.RecentlyOpenMS == nil {
|
||||
return 0
|
||||
}
|
||||
return *a.RecentlyOpenMS
|
||||
}
|
||||
|
||||
// GetFavTime
|
||||
func (a *ProjectDocument) GetFavTime() int64 {
|
||||
if a.FavTimeMS == nil {
|
||||
return 0
|
||||
}
|
||||
return *a.FavTimeMS
|
||||
}
|
||||
|
||||
// GetIsFav
|
||||
func (a *ProjectDocument) GetIsFav() bool {
|
||||
if a.IsFav == nil {
|
||||
return false
|
||||
}
|
||||
return *a.IsFav == 1
|
||||
}
|
||||
37
backend/domain/search/entity/project_event.go
Normal file
37
backend/domain/search/entity/project_event.go
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package entity
|
||||
|
||||
type OpType string
|
||||
|
||||
const (
|
||||
Created OpType = "created"
|
||||
Updated OpType = "updated"
|
||||
Deleted OpType = "deleted"
|
||||
)
|
||||
|
||||
type ProjectDomainEvent struct {
|
||||
OpType OpType `json:"op_type"`
|
||||
Project *ProjectDocument `json:"project_document,omitempty"`
|
||||
Meta *EventMeta `json:"meta,omitempty"`
|
||||
Extra map[string]any `json:"extra"`
|
||||
}
|
||||
|
||||
type EventMeta struct {
|
||||
SendTimeMs int64 `json:"send_time_ms"`
|
||||
ReceiveTimeMs int64 `json:"receive_time_ms"`
|
||||
}
|
||||
23
backend/domain/search/entity/resource_doc.go
Normal file
23
backend/domain/search/entity/resource_doc.go
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package entity
|
||||
|
||||
import (
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/search"
|
||||
)
|
||||
|
||||
type ResourceDocument = model.ResourceDocument
|
||||
26
backend/domain/search/entity/resources_event.go
Normal file
26
backend/domain/search/entity/resources_event.go
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package entity
|
||||
|
||||
// 复用AppDomainEvent中的DomainName和OpType
|
||||
|
||||
type ResourceDomainEvent struct {
|
||||
OpType OpType `json:"op_type"`
|
||||
Resource *ResourceDocument `json:"resource_document,omitempty"`
|
||||
Meta *EventMeta `json:"meta,omitempty"`
|
||||
Extra map[string]any `json:"extra"`
|
||||
}
|
||||
60
backend/domain/search/entity/search.go
Normal file
60
backend/domain/search/entity/search.go
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package entity
|
||||
|
||||
import (
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/search"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/intelligence/common"
|
||||
)
|
||||
|
||||
const (
|
||||
// resource index fields
|
||||
FieldOfResType = "res_type"
|
||||
FieldOfPublishStatus = "publish_status"
|
||||
FieldOfResSubType = "res_sub_type"
|
||||
FieldOfBizStatus = "biz_status"
|
||||
FieldOfScores = "scores"
|
||||
)
|
||||
|
||||
type SearchProjectsRequest struct {
|
||||
SpaceID int64
|
||||
ProjectID int64
|
||||
OwnerID int64
|
||||
Name string
|
||||
Status []common.IntelligenceStatus
|
||||
Types []common.IntelligenceType
|
||||
|
||||
IsPublished bool
|
||||
IsFav bool
|
||||
IsRecentlyOpen bool
|
||||
OrderFiledName string
|
||||
OrderAsc bool
|
||||
|
||||
Cursor string
|
||||
Limit int32
|
||||
}
|
||||
|
||||
type SearchProjectsResponse struct {
|
||||
HasMore bool
|
||||
NextCursor string
|
||||
|
||||
Data []*ProjectDocument
|
||||
}
|
||||
|
||||
type SearchResourcesRequest = model.SearchResourcesRequest
|
||||
|
||||
type SearchResourcesResponse = model.SearchResourcesResponse
|
||||
Reference in New Issue
Block a user