web

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SUCCESS_CODE         int = 200
	ERROR_PARAMETER_CODE int = 400
	SERVER_ERROR_CODE    int = 500
)
View Source
const (
	Default_Size int = 10
)

Variables

View Source
var (
	CODE_MAPS = map[int]string{
		SUCCESS_CODE:         "success",
		ERROR_PARAMETER_CODE: "parammeter error",
		SERVER_ERROR_CODE:    "server error",
	}
)

Functions

func RegisterCallBackProcessFunc

func RegisterCallBackProcessFunc(scene string, f CallBackProcessFunc)

func Send

func Send(controller *CallBackController)

Types

type CallBackController

type CallBackController struct {
	Controller
	// contains filtered or unexported fields
}

func (*CallBackController) CheckParameter

func (r *CallBackController) CheckParameter() error

func (*CallBackController) Process

type CallBackControllerHandler

type CallBackControllerHandler struct {
	// contains filtered or unexported fields
}

func NewCallBackControllerHandler

func NewCallBackControllerHandler() *CallBackControllerHandler

type CallBackParam

type CallBackParam struct {
	SceneId     string                   `json:"scene_id"`
	RequestId   string                   `json:"request_id"`
	Uid         string                   `json:"uid"`
	Features    map[string]interface{}   `json:"features"`
	ItemList    []map[string]interface{} `json:"item_list"`
	RequestInfo map[string]interface{}   `json:"request_info"`
	Debug       bool                     `json:"debug"`
}

func (*CallBackParam) GetParameter

func (r *CallBackParam) GetParameter(name string) interface{}

type CallBackProcessFunc

type CallBackProcessFunc func(user *module.User, items []*module.Item, context *context.RecommendContext)

type CallBackResponse

type CallBackResponse struct {
	Response
}

func (*CallBackResponse) ToString

func (r *CallBackResponse) ToString() string

type Controller

type Controller struct {
	RequestBody []byte
	RequestId   string
	Start       time.Time
	End         time.Time
}

func (*Controller) LogRequestBegin

func (c *Controller) LogRequestBegin(r *http.Request)

func (*Controller) LogRequestEnd

func (c *Controller) LogRequestEnd(r *http.Request)

func (*Controller) SendError

func (c *Controller) SendError(w http.ResponseWriter, code int, msg string)

type DataSourceInfo

type DataSourceInfo struct {
	Type       string `json:"type"`
	AccessId   string `json:"access_id"`
	AccessKey  string `json:"access_key"`
	Endpoint   string `json:"endpoint"`
	Project    string `json:"project"`
	Topic      string `json:"topic"`
	VpcAddress string `json:"vpc_address"`
	Token      string `json:"token"`
	JobId      uint32 `json:"job_id"`
}

type ErrorResponse

type ErrorResponse struct {
	Response
}

func (*ErrorResponse) ToString

func (e *ErrorResponse) ToString() string

type FeatureReplyController

type FeatureReplyController struct {
	Controller
	// contains filtered or unexported fields
}

func (*FeatureReplyController) CheckParameter

func (r *FeatureReplyController) CheckParameter() error

func (*FeatureReplyController) Process

type FeatureReplyData

type FeatureReplyData struct {
	Scene        string   `json:"scene"`
	RequestId    string   `json:"request_id"`
	UserId       string   `json:"user_id"` // user id
	UserFeatures string   `json:"user_features"`
	ItemIds      []string `json:"item_ids"` // item ids
	ItemFeatures []string `json:"item_features"`
}

type FeatureReplyParam

type FeatureReplyParam struct {
	DataSource  DataSourceInfo   `json:"datasource"`
	FeatureData FeatureReplyData `json:"items"`
}

func (*FeatureReplyParam) GetParameter

func (r *FeatureReplyParam) GetParameter(name string) interface{}

type FeatureReplyResponse

type FeatureReplyResponse struct {
	Response
}

func (*FeatureReplyResponse) ToString

func (r *FeatureReplyResponse) ToString() string

type ItemData

type ItemData struct {
	ItemId     string `json:"item_id"`
	ItemType   string `json:"item_type"`
	RetrieveId string `json:"retrieve_id"`
}

type RecommendController

type RecommendController struct {
	Controller
	// contains filtered or unexported fields
}

func (*RecommendController) CheckParameter

func (r *RecommendController) CheckParameter() error

func (*RecommendController) Process

type RecommendParam

type RecommendParam struct {
	SceneId  string                 `json:"scene_id"`
	Category string                 `json:"category"`
	Uid      string                 `json:"uid"`  // user id
	Size     int                    `json:"size"` // get recommend items size
	Debug    bool                   `json:"debug"`
	Features map[string]interface{} `json:"features"`
}

func (*RecommendParam) GetParameter

func (r *RecommendParam) GetParameter(name string) interface{}

type RecommendResponse

type RecommendResponse struct {
	Response
	Size  int         `json:"size"`
	Items []*ItemData `json:"items"`
}

func (*RecommendResponse) ToString

func (r *RecommendResponse) ToString() string

type Response

type Response struct {
	Code      int    `json:"code"`
	Message   string `json:"msg"`
	RequestId string `json:"request_id"`
}

type UserRecallController

type UserRecallController struct {
	Controller
	// contains filtered or unexported fields
}

func (*UserRecallController) CheckParameter

func (r *UserRecallController) CheckParameter() error

func (*UserRecallController) Process

type UserRecallItemData

type UserRecallItemData struct {
	ItemId string `json:"item_id"`
	// ItemType   string `json:"item_type"`
	RetrieveId string `json:"retrieve_id"`
}

type UserRecallParam

type UserRecallParam struct {
	SceneId  string `json:"scene_id"`
	Category string `json:"category"`
	Uid      string `json:"uid"`  // user id
	Size     int    `json:"size"` // get recommend items size
}

func (*UserRecallParam) GetParameter

func (r *UserRecallParam) GetParameter(name string) interface{}

type UserRecallResponse

type UserRecallResponse struct {
	Response
	Size   int                   `json:"size"`
	Items  []*UserRecallItemData `json:"items"`
	Errors []error               `json:"errors"`
}

func (*UserRecallResponse) ToString

func (r *UserRecallResponse) ToString() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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