service

package
v0.0.0-...-31ef647 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bind

func Bind[T any](r *http.Request) (*T, error)

Bind 验证并绑定请求参数

func Error

func Error(w http.ResponseWriter, code int, message string)

Error 响应错误

func ErrorSystem

func ErrorSystem(w http.ResponseWriter)

ErrorSystem 响应系统错误

func Paginate

func Paginate[T any](r *http.Request, allItems []T) (pagedItems []T, total uint)

Paginate 取分页条目

func Success

func Success(w http.ResponseWriter, data any)

Success 响应成功

Types

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
}

ErrorResponse 通用错误响应

type SuccessResponse

type SuccessResponse struct {
	Message string `json:"message"`
	Data    any    `json:"data"`
}

SuccessResponse 通用成功响应

type UserService

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

func NewUserService

func NewUserService() *UserService

func (*UserService) Create

func (s *UserService) Create(w http.ResponseWriter, r *http.Request)

func (*UserService) Delete

func (s *UserService) Delete(w http.ResponseWriter, r *http.Request)

func (*UserService) Get

func (s *UserService) Get(w http.ResponseWriter, r *http.Request)

func (*UserService) List

func (s *UserService) List(w http.ResponseWriter, r *http.Request)

func (*UserService) Update

func (s *UserService) Update(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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