hiboot: hidevops.io/hiboot/pkg/model Index | Files

package model

import "hidevops.io/hiboot/pkg/model"

Package model provides common request and response models.

// UserRequest is the request body
type UserRequest struct {
	model.RequestBody	// annotation RequestBody
	Username string		`validate:"required"`
	Password string 	`validate:"required"`
}

Index

Package Files

data.go doc.go request.go response.go

Variables

var (
    // RequestTypeBody means it is RequestBody
    RequestTypeBody = "RequestBody"
    // RequestTypeParams means it is RequestParams
    RequestTypeParams = "RequestParams"
    // RequestTypeForm means it is RequestForm
    RequestTypeForm = "RequestForm"
    // Context means it is Context
    Context = "Context"
)

type BaseData Uses

type BaseData struct {
    // IsDeleted for soft delete
    IsDeleted bool `json:"is_deleted,omitempty"`

    // CreatedAt data created time
    CreatedAt time.Time `json:"created_at,omitempty"`

    // UpdatedAt data updated time
    UpdatedAt time.Time `json:"updated_at,omitempty"`
}

BaseData specifies the base data fields for database models

type BaseResponse Uses

type BaseResponse struct {
    BaseResponseInfo
    Data interface{} `json:"data,omitempty" schema:"HTTP response data"`
}

BaseResponse is the implementation of rest controller's Response

func (*BaseResponse) GetData Uses

func (r *BaseResponse) GetData() interface{}

GetData get data

func (*BaseResponse) SetData Uses

func (r *BaseResponse) SetData(data interface{})

SetData the data will be serialized to json string

type BaseResponseInfo Uses

type BaseResponseInfo struct {
    at.Schema
    Code    int    `json:"code" schema:"HTTP response code"`
    Message string `json:"message,omitempty" schema:"HTTP response message"`
}

BaseResponseInfo is the implementation of rest controller's Response

func (*BaseResponseInfo) GetCode Uses

func (r *BaseResponseInfo) GetCode() int

GetCode get error code

func (*BaseResponseInfo) GetMessage Uses

func (r *BaseResponseInfo) GetMessage() string

GetMessage get message

func (*BaseResponseInfo) SetCode Uses

func (r *BaseResponseInfo) SetCode(code int)

SetCode set error code

func (*BaseResponseInfo) SetMessage Uses

func (r *BaseResponseInfo) SetMessage(message string)

SetMessage set message

type ListOptions Uses

type ListOptions struct {
    // For paginated result sets, page of results to retrieve.
    Page int `url:"page,omitempty" json:"page,omitempty" validate:"min=1"`

    // For paginated result sets, the number of results to include per page.
    PerPage int `url:"per_page,omitempty" json:"per_page,omitempty" validate:"min=1"`
}

ListOptions specifies the optional parameters to various List methods that support pagination.

type RequestBody Uses

type RequestBody struct {
    at.RequestBody
}

RequestBody the annotation RequestBody

type RequestForm Uses

type RequestForm struct {
    at.RequestForm
}

RequestForm the annotation RequestForm

type RequestParams Uses

type RequestParams struct {
    at.RequestParams
}

RequestParams the annotation RequestParams

type Response Uses

type Response interface {
    ResponseInfo
    // Set data, the data will be serialized to json string
    SetData(data interface{})
    // Get data
    GetData() interface{}
}

type ResponseInfo Uses

type ResponseInfo interface {
    // Set error code
    SetCode(code int)
    // Get error code
    GetCode() int
    // Set message
    SetMessage(message string)
    // Get message
    GetMessage() string
}

Response is the interface of rest controller's Response

Package model imports 2 packages (graph) and is imported by 8 packages. Updated 2019-11-02. Refresh now. Tools for package owners.