Documentation

Overview

    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

    Constants

    This section is empty.

    Variables

    View Source
    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"
    )

    Functions

    This section is empty.

    Types

    type BaseData

    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

      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

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

          GetData get data

          func (*BaseResponse) SetData

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

            SetData the data will be serialized to json string

            type BaseResponseInfo

            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

              func (r *BaseResponseInfo) GetCode() int

                GetCode get error code

                func (*BaseResponseInfo) GetMessage

                func (r *BaseResponseInfo) GetMessage() string

                  GetMessage get message

                  func (*BaseResponseInfo) SetCode

                  func (r *BaseResponseInfo) SetCode(code int)

                    SetCode set error code

                    func (*BaseResponseInfo) SetMessage

                    func (r *BaseResponseInfo) SetMessage(message string)

                      SetMessage set message

                      type ListOptions

                      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

                        type RequestBody struct {
                        	at.RequestBody
                        }

                          RequestBody the annotation RequestBody

                          type RequestForm

                          type RequestForm struct {
                          	at.RequestForm
                          }

                            RequestForm the annotation RequestForm

                            type RequestParams

                            type RequestParams struct {
                            	at.RequestParams
                            }

                              RequestParams the annotation RequestParams

                              type Response

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

                              type ResponseInfo

                              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