app

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

controllers/base_controller.go

models/IModel.go

app/ISchema.go

service/IService.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseController

type BaseController[T IModel, CreateDTO ICreateDTO, QueryDTO IQueryDTO, TVO IVO] struct {
	Service IBaseService[T]
}

func NewBaseController

func NewBaseController[T IModel, CreateDTO ICreateDTO, QueryDTO IQueryDTO, TVO IVO](s IBaseService[T]) *BaseController[T, CreateDTO, QueryDTO, TVO]

func (*BaseController[T, CreateDTO, QueryDTO, TVO]) BulkCreate

func (bc *BaseController[T, CreateDTO, QueryDTO, TVO]) BulkCreate(c *gin.Context)

func (*BaseController[T, CreateDTO, QueryDTO, TVO]) BulkDelete

func (bc *BaseController[T, CreateDTO, QueryDTO, TVO]) BulkDelete(c *gin.Context)

func (*BaseController[T, CreateDTO, QueryDTO, TVO]) Create

func (bc *BaseController[T, CreateDTO, QueryDTO, TVO]) Create(c *gin.Context)

func (*BaseController[T, CreateDTO, QueryDTO, TVO]) Delete

func (bc *BaseController[T, CreateDTO, QueryDTO, TVO]) Delete(c *gin.Context)

func (*BaseController[T, CreateDTO, QueryDTO, TVO]) GetById

func (bc *BaseController[T, CreateDTO, QueryDTO, TVO]) GetById(c *gin.Context)

func (*BaseController[T, CreateDTO, QueryDTO, TVO]) GetTreeById

func (bc *BaseController[T, CreateDTO, QueryDTO, TVO]) GetTreeById(c *gin.Context)

func (*BaseController[IModel, CreateDTO, QueryDTO, TVO]) PageByDTO

func (bc *BaseController[IModel, CreateDTO, QueryDTO, TVO]) PageByDTO(c *gin.Context)

func (*BaseController[T, CreateDTO, QueryDTO, TVO]) Update

func (bc *BaseController[T, CreateDTO, QueryDTO, TVO]) Update(c *gin.Context)

func (*BaseController[T, CreateDTO, QueryDTO, TVO]) UpdateByMap

func (bc *BaseController[T, CreateDTO, QueryDTO, TVO]) UpdateByMap(c *gin.Context)

type BaseDTO

type BaseDTO struct{}

type BaseService

type BaseService[model IModel] struct {
	DB    *gorm.DB
	Model model
}

func NewBaseService

func NewBaseService[T IModel](db *gorm.DB, model T) *BaseService[T]

func (*BaseService[T]) BulkCreate

func (bs *BaseService[T]) BulkCreate(models []T) (int, []T, error)

func (*BaseService[T]) BulkDelete

func (bs *BaseService[T]) BulkDelete(ids []string) (int, error)

func (*BaseService[T]) Create

func (bs *BaseService[T]) Create(model *T) (*T, error)

func (*BaseService[T]) Delete

func (bs *BaseService[T]) Delete(id string) error

func (*BaseService[T]) GetById

func (bs *BaseService[T]) GetById(id string) (*T, error)

func (*BaseService[T]) GetTreeById

func (bs *BaseService[T]) GetTreeById(id string) ([]T, error)

根据 [Id] 查询记录返回 [树形切片]

func (*BaseService[T]) PageByMap added in v1.7.0

func (bs *BaseService[T]) PageByMap(queryMap map[string]interface{}, queryPage *QueryPage) (*[]T, int, error)

func (*BaseService[T]) Update

func (bs *BaseService[T]) Update(id string, model T) (*T, error)

func (*BaseService[T]) UpdateByMap

func (bs *BaseService[T]) UpdateByMap(id string, dtoMap map[string]interface{}) error

type BaseVO

type BaseVO struct{}

func (BaseVO) GetDetailVO

func (BV BaseVO) GetDetailVO() interface{}

func (BaseVO) GetListVO

func (BV BaseVO) GetListVO() interface{}

type GenericModel

type GenericModel struct {
	Sort   int    `gorm:"column:sort;type:int" json:"Sort"`
	Remark string `gorm:"column:remark;size:1024" json:"Remark"`
	Status int    `gorm:"column:status;type:int" json:"Status"`
}

type IBaseController

type IBaseController interface {
	Create(c *gin.Context)
	BulkCreate(c *gin.Context)
	Update(c *gin.Context)
	UpdateByMap(c *gin.Context)
	Delete(c *gin.Context)
	BulkDelete(c *gin.Context)
	GetById(c *gin.Context)
	PageByDTO(c *gin.Context)
	GetTreeById(c *gin.Context)
}

type IBaseService

type IBaseService[T IModel] interface {
	Create(model *T) (*T, error)
	BulkCreate(models []T) (int, []T, error)
	GetById(id string) (*T, error)
	Update(id string, model T) (*T, error)
	Delete(id string) error
	BulkDelete(ids []string) (int, error)
	PageByMap(queryDto map[string]any, queryPage *QueryPage) (*[]T, int, error)
	GetTreeById(id string) ([]T, error)
	UpdateByMap(id string, dtoMap map[string]interface{}) error
}

type ICreateDTO

type ICreateDTO interface {
}

type IModel

type IModel interface {
	TableName() string
}

type IQueryDTO

type IQueryDTO interface {
}

type ISO8601Time added in v1.7.2

type ISO8601Time struct {
	time.Time
	Format string
}

自定义时间类型

func NewISO8601Time added in v1.7.2

func NewISO8601Time(t time.Time) ISO8601Time

func (ISO8601Time) FormatTime added in v1.7.2

func (t ISO8601Time) FormatTime(format string) string

func (*ISO8601Time) Scan added in v1.7.2

func (t *ISO8601Time) Scan(value interface{}) error

Scan 实现 sql.Scanner 接口,用于从数据库扫描时间

func (ISO8601Time) Value added in v1.7.2

func (t ISO8601Time) Value() (driver.Value, error)

Value 实现 driver.Valuer 接口,用于将时间序列化为数据库支持的格式

func (ISO8601Time) WithFormat added in v1.7.2

func (t ISO8601Time) WithFormat(format string) ISO8601Time

type IVO

type IVO interface {
	GetDetailVO() interface{}
	GetListVO() interface{}
}

type IdTimeStampsModel added in v1.7.2

type IdTimeStampsModel struct {
	Id        int64       `gorm:"primaryKey;autoIncrement:false" json:"Id,string"`
	CreatedAt ISO8601Time `gorm:"column:created_at"`
	UpdatedAt ISO8601Time `gorm:"column:updated_at"`
}
type TimeStampsModel struct {
	CreatedAt ISO8601Time `gorm:"column:created_at"`
	UpdatedAt ISO8601Time `gorm:"column:updated_at"`
}

func (*IdTimeStampsModel) BeforeCreate added in v1.7.2

func (m *IdTimeStampsModel) BeforeCreate(tx *gorm.DB) error

BeforeCreate 钩子方法在记录创建前调用

func (*IdTimeStampsModel) BeforeUpdate added in v1.7.2

func (m *IdTimeStampsModel) BeforeUpdate(tx *gorm.DB) error

BeforeUpdate 钩子方法在记录更新前调用

type OperatorModel

type OperatorModel struct {
	CreateUser int64 `gorm:"column:create_user;type:bigint" json:"CreateUser,string"`
	CreateDept int64 `gorm:"column:create_dept;type:bigint" json:"CreateDept,string"`
	UpdateUser int64 `gorm:"column:update_user;type:bigint" json:"UpdateUser,string"`
}

type PaginationResult

type PaginationResult struct {
	Records []interface{} `json:"records"`
	Current int           `json:"current"`
	Size    int           `json:"size"`
	Total   int           `json:"total"`
	Pages   int           `json:"pages"`
}

type QueryPage

type QueryPage struct {
	Current int      `json:"current" form:"current"`
	Size    int      `json:"size" form:"size"`
	Ascs    []string `json:"ascs" form:"ascs"`
	Descs   []string `json:"descs" form:"descs"`
}

func NewQueryPageAndBind

func NewQueryPageAndBind(size int, c *gin.Context) *QueryPage

type SnowflakeIDModel

type SnowflakeIDModel struct {
	Id int64 `gorm:"primaryKey;autoIncrement:false" json:"Id,string"`
}

SnowflakeIDModel 是基于雪花算法生成唯一标识的基础模型

func (*SnowflakeIDModel) BeforeCreate

func (m *SnowflakeIDModel) BeforeCreate(tx *gorm.DB) error

BeforeCreate 在创建记录前为模型生成雪花算法ID

type SoftDeleteModel

type SoftDeleteModel struct {
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

Directories

Path Synopsis
service/base_service.go
service/base_service.go

Jump to

Keyboard shortcuts

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