helper

package
v0.0.0-...-d4bccd0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapEntityToData

func MapEntityToData(entity interface{}) interface{}

func ResponseFailed

func ResponseFailed(message string) map[string]interface{}

func ResponseFailedWithData

func ResponseFailedWithData(message string, data interface{}) map[string]interface{}

func ResponseSuccess

func ResponseSuccess(message string, data interface{}) map[string]interface{}

func ResponseSuccessWithoutData

func ResponseSuccessWithoutData(message string) map[string]interface{}

Types

type AddressData

type AddressData struct {
	ID     uint   `json:"id" example:"1"`
	Street string `json:"street" example:"Jl. Raya Ciputat"`
	City   string `json:"city" example:"Tangerang"`
	State  string `json:"state" example:"Banten"`
	Zip    string `json:"zip" example:"15123"`

} //@name Address

type BookData

type BookData struct {
	ID          uint     `json:"id" example:"1"`
	Title       string   `json:"title" example:"The Lord of the Rings"`
	Isbn        string   `json:"isbn" example:"123456789"`
	Author      string   `json:"author" example:"J.R.R. Tolkien"`
	Publisher   string   `json:"publisher" example:"HarperCollins"`
	Description string   `` /* 136-byte string literal not displayed */
	Cover       string   `json:"cover" example:"https://example.com/cover.jpg"`
	CreatedAt   string   `json:"created_at" example:"2020-01-01T00:00:00Z"`
	UpdatedAt   string   `json:"updated_at" example:"2020-01-01T00:00:00Z"`
	Category    string   `json:"category" example:"Fiction"`
	Owner       UserData `json:"owner"`

} //@name Book

type BookQueryRequest

type BookQueryRequest struct {
	Page     int    `json:"page" example:"1" format:"int64"`
	Limit    int    `json:"limit" example:"10" format:"int64"`
	Category string `json:"category" example:"Fiction"`

} //@name PaginationRequest

type BookRequest

type BookRequest struct {
	Title       string `json:"title" example:"The Lord of the Rings" format:"int64"`
	Isbn        string `json:"isbn" example:"123456789"`
	Author      string `json:"author" example:"J.R.R. Tolkien"`
	Publisher   string `json:"publisher" example:"HarperCollins"`
	Category    string `json:"category" example:"Fiction"`
	Cover       string `json:"cover" example:"https://example.com/cover.jpg"`
	Description string `` /* 136-byte string literal not displayed */
	OwnerID     uint   `json:"owner_id" example:"1" format:"int64"`
	PublishDate string `json:"publish_date" example:"2020-01-01" format:"date"`

} //@name BookRequest

type BookResponse

type BookResponse struct {
	Status  string   `json:"status" example:"success"`
	Message string   `json:"message" example:"success"`
	Data    BookData `json:"data"`

} //@name BookResponse

type BookUpdateRequest

type BookUpdateRequest struct {
	ID          uint   `json:"id" example:"1" format:"int64"`
	Title       string `json:"title" example:"The Lord of the Rings"`
	Isbn        string `json:"isbn" example:"123456789"`
	Author      string `json:"author" example:"J.R.R. Tolkien"`
	Publisher   string `json:"publisher" example:"HarperCollins"`
	Category    string `json:"category" example:"Fiction"`
	Cover       string `json:"cover" example:"https://example.com/cover.jpg"`
	Description string `` /* 136-byte string literal not displayed */
	OwnerID     uint   `json:"owner_id" example:"1" format:"int64"`
	PublishDate string `json:"publish_date" example:"2020-01-01" format:"date"`

} //@name BookUpdateRequest

type BooksResponse

type BooksResponse struct {
	Status  string     `json:"status" example:"success"`
	Message string     `json:"message" example:"success"`
	Data    []BookData `json:"data"`

} //@name BooksResponse

type DuplicateKeyError

type DuplicateKeyError struct {
	Property string
	Value    string
}

func (DuplicateKeyError) Error

func (e DuplicateKeyError) Error() string

type Error

type Error interface {
	Error() string
}

func NewDuplicateKeyError

func NewDuplicateKeyError(property, value string) Error

func NewErrorCredential

func NewErrorCredential(message string) Error

func NewErrorNotFound

func NewErrorNotFound(name string) Error

type ErrorCredential

type ErrorCredential struct {
	Message string
}

func (ErrorCredential) Error

func (e ErrorCredential) Error() string

type ErrorNotFound

type ErrorNotFound struct {
	Name string
}

func (ErrorNotFound) Error

func (e ErrorNotFound) Error() string

type PagedDataResponse

type PagedDataResponse struct {
	Data       []BookData     `json:"data"`
	Pagination PaginationData `json:"pagination"`
}

type PaginationData

type PaginationData struct {
	Page  int `json:"page" example:"1" format:"int64"`
	Limit int `json:"limit" example:"10" format:"int64"`
	Total int `json:"total" example:"100" format:"int64"`
}

type PaginationResponse

type PaginationResponse struct {
	Status  string `json:"status" example:"success"`
	Message string `json:"message" example:"success"`
	PagedDataResponse

} //@name PaginationResponse

type RentData

type RentData struct {
	ID       uint        `json:"id" example:"1"`
	User     UserData    `json:"user"`
	Book     BookData    `json:"book"`
	Status   string      `json:"status" example:"received"`
	RentAt   string      `json:"rent_at" example:"2020-01-01T00:00:00Z"`
	ReturnAt string      `json:"return_at" example:"2020-01-01T00:00:00Z"`
	Address  AddressData `json:"address"`

} //@name Rent

type RentRequest

type RentRequest struct {
	UserID   uint        `json:"user_id" example:"1"`
	BookID   uint        `json:"book_id" example:"1"`
	Address  AddressData `json:"address"`
	ReturnAt string      `json:"return_at" example:"2020-01-01T00:00:00Z"`

} //@name RentRequest

type RentResponse

type RentResponse struct {
	Status  string     `json:"status" example:"success"`
	Message string     `json:"message" example:"success"`
	Data    []RentData `json:"data"`

} //@name RentResponse

type RentsResponse

type RentsResponse struct {
	Status  string     `json:"status" example:"success"`
	Message string     `json:"message" example:"success"`
	Data    []RentData `json:"data"`

} //@name RentsResponse

type ResponseFailedBody

type ResponseFailedBody struct {
	Status  string `json:"status" example:"failed"`
	Message string `json:"message" example:"failed"`
	Data    string `json:"data"`

} //@name ResponseFailed

type ResponseSuccessBody

type ResponseSuccessBody struct {
	Status  string      `json:"status" example:"success"`
	Message string      `json:"message" example:"success"`
	Data    interface{} `json:"data"`

} //@name ResponseSuccess

type ResponseSuccessWithoutDataBody

type ResponseSuccessWithoutDataBody struct {
	Status  string `json:"status" example:"success"`
	Message string `json:"message" example:"success"`

} //@name ResponseSuccessWithoutData

type ReturnBookRequest

type ReturnBookRequest struct {
	BookID uint `json:"book_id" example:"1" format:"int64"`

} //@name ReturnBookRequest

type UserData

type UserData struct {
	ID        uint   `json:"id" example:"1"`
	Name      string `json:"name" example:"John Doe"`
	Email     string `json:"email" example:"[email protected]"`
	CreatedAt string `json:"created_at" example:"2020-01-01T00:00:00Z"`
	UpdatedAt string `json:"updated_at" example:"2020-01-01T00:00:00Z"`

} //@name User

type UserRequest

type UserRequest struct {
	Name     string `json:"name" example:"John Doe"`
	Email    string `json:"email" example:"[email protected]"`
	Password string `json:"password" example:"secret"`
	IsAdmin  bool   `json:"is_admin" example:"true" format:"boolean"`

} //@name UserRequest

type UserResponse

type UserResponse struct {
	Status  string   `json:"status" example:"success"`
	Message string   `json:"message" example:"success"`
	Data    UserData `json:"data"`

} //@name UserResponse

type UsersResponse

type UsersResponse struct {
	Status  string     `json:"status" example:"success"`
	Message string     `json:"message" example:"success"`
	Data    []UserData `json:"data"`

} //@name UsersResponse

Jump to

Keyboard shortcuts

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