native

package
v4.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package native implements the knowledge package's v2 routes in the package itself. The package adopts the kernel's v2_knowledge table (kernel.storage.adopt:v2_knowledge), so the native routes and the kernel's legacy handlers read and write the same rows: switching a route between legacy and native needs no data move and can be undone at any time. Responses are byte-compatible with the legacy handlers (internal/tests/knowledgecompat).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Article

type Article struct {
	ID        uint      `gorm:"primaryKey" json:"id"`
	Category  string    `gorm:"size:64" json:"category"`
	Title     string    `gorm:"size:255" json:"title"`
	Body      string    `gorm:"type:text" json:"body"`
	Sort      int       `gorm:"default:0" json:"sort"`
	Show      int       `gorm:"default:1" json:"show"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

Article is a v2_knowledge row. Its JSON matches the kernel model, which the admin create answer returns as is.

func (Article) TableName

func (Article) TableName() string

TableName is the adopted kernel table.

type Service

type Service struct {
	// Open returns the package's storage connection, on which the adopted
	// v2_knowledge table is visible.
	Open func(ctx context.Context) (*gorm.DB, error)
	// Now defaults to time.Now.
	Now func() time.Time
}

Service holds what the native routes need.

func (*Service) AdminCreate

AdminCreate is POST /api/v2/admin/knowledge.

func (*Service) AdminDelete

AdminDelete is DELETE /api/v2/admin/knowledge/:id.

func (*Service) AdminList

AdminList is GET /api/v2/admin/knowledge.

func (*Service) AdminUpdate

AdminUpdate is PUT /api/v2/admin/knowledge/:id.

func (*Service) Handlers

func (s *Service) Handlers() map[string]pluginhostsdk.NativeHandler

Handlers returns the native handlers by route id.

func (*Service) UserGet

UserGet is GET /api/v2/user/knowledge/:id.

func (*Service) UserList

UserList is GET /api/v2/user/knowledge: visible articles.

Jump to

Keyboard shortcuts

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