Skip to content
Snippets Groups Projects
Commit d0e97459 authored by Danis Kirasirov's avatar Danis Kirasirov :8ball: Committed by Pavel Antonov
Browse files

Добавлено системное поле SearchScore в Item

parent 8ca77dad
No related branches found
No related tags found
No related merge requests found
Subproject commit 2fd02d31a11e9c98547acc4f8416d17c5367411c
Subproject commit 0c9587bc749ae4150552445173078ab5b36ef42c
......@@ -76,6 +76,7 @@ var SystemFields = []string{
"deleted",
"hidden",
"template",
"search_score",
}
type Permissions struct {
......@@ -103,6 +104,7 @@ type Item struct {
RevisionID string `json:"revId,omitempty" bson:"revision_id"`
RevisionDescription string `json:"revDescription,omitempty" bson:"revision_description"`
Permissions *Permissions `json:"permissions,omitempty" bson:"-"`
SearchScore float64 `json:"searchScore,omitempty" bson:"search_score,omitempty"`
// Флаги записи
Deleted bool `json:"deleted" bson:"deleted,omitempty"`
......@@ -155,6 +157,7 @@ func (i *Item) ToMap() map[string]interface{} {
"deleted": i.Deleted,
"hidden": i.Hidden,
"template": i.Template,
"search_score": i.SearchScore,
}
}
......@@ -315,6 +318,8 @@ func (i *Item) SetSystemField(field string, value interface{}) error {
i.Deleted, ok = value.(bool)
case "template":
i.Template, ok = value.(bool)
case "search_score":
i.SearchScore, ok = value.(float64)
default:
return ErrNotSystemField
}
......@@ -326,7 +331,7 @@ func (i *Item) SetSystemField(field string, value interface{}) error {
return nil
}
// GetSystem устанавливает значение системного поля
// GetSystem возвращает значение системного поля
func (i *Item) GetSystem(field string) (any, error) {
switch field {
case "id":
......@@ -357,6 +362,8 @@ func (i *Item) GetSystem(field string) (any, error) {
return i.Deleted, nil
case "template":
return i.Template, nil
case "search_score":
return i.SearchScore, nil
}
return nil, ErrNotSystemField
......@@ -419,6 +426,8 @@ func GetSystemField(fld string) (*field.Field, error) {
return field.String(), nil
case "hidden", "deleted", "template":
return field.Bool(), nil
case "search_score":
return field.Number(field.NumberFormatFloat), nil
}
return nil, ErrNotSystemField
......@@ -469,6 +478,7 @@ func ItemToProto(item *Item) *pb.Item {
Hidden: item.Hidden,
Template: item.Template,
Deleted: item.Deleted,
SearchScore: item.SearchScore,
}
if item.Data != nil {
......@@ -518,6 +528,7 @@ func ItemFromProto(protoItem *pb.Item) *Item {
Hidden: protoItem.Hidden,
Template: protoItem.Template,
Deleted: protoItem.Deleted,
SearchScore: protoItem.SearchScore,
}
if protoItem.Data != nil {
......
This diff is collapsed.
......@@ -9,7 +9,7 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc v4.24.3
// - protoc v4.25.1
// source: items/items.proto
package items
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment