gen

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(r *gin.Engine) error

Types

type StudentApi

type StudentApi struct {
}

func NewApi

func NewApi() *StudentApi

func (*StudentApi) Create

func (api *StudentApi) Create(c *gin.Context)

Create 创建学生 @Summary 创建学生 @Description 创建一个新的学生 @Produce json @Tags students @Param student body StudentModel true "学生信息" @Success 201 {object} StudentModel @Failure 400 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /students [post]

func (*StudentApi) Delete

func (api *StudentApi) Delete(c *gin.Context)

Delete 删除学生 @Summary 删除学生 @Description 根据主键id删除学生 @Produce json @Tags students @Param id path int true "学生主键id" @Success 200 "No Content" @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /students/delete [post]

func (*StudentApi) List

func (api *StudentApi) List(c *gin.Context)

List 获取学生列表 @Summary 获取学生列表 @Description 获取分页的学生信息列表 @Produce json @Tags students @Param offset query int true "偏移量,从0开始" @Param size query int true "每页大小" @Success 200 {array} Student @Failure 400 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /students/list [get]

func (*StudentApi) Show

func (api *StudentApi) Show(c *gin.Context)

Show 获取指定id的学生信息 @Summary 获取学生信息 @Description 根据主键id获取学生信息 @Produce json @Tags students @Param id query int true "学生主键id" @Success 200 {object} Student @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /students/show [get]

func (*StudentApi) Update

func (api *StudentApi) Update(c *gin.Context)

Update 更新学生 @Summary 更新学生 @Description 更新现有学生 @Produce json @Tags students @Param student body StudentModel true "学生信息" @Success 200 {object} StudentModel @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /students/update [post]

type StudentModel

type StudentModel struct {
	ID      int64  `gorm:"id,primary_key"  json:"id,omitempty"`
	Name    string `gorm:"name,not null" json:"name,omitempty"`
	Age     uint   `gorm:"age,not null" json:"age,omitempty"`
	ClassID uint   `gorm:"class_id,not null" json:"class_id,omitempty"`
}

func (StudentModel) TableName

func (StudentModel) TableName() string

Jump to

Keyboard shortcuts

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