app

package
v1.7.9 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: GPL-3.0 Imports: 14 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.Time // 时间
	Format string    // 自定义格式
}

ISO8601Time 自定义时间类型

func NewISO8601Time added in v1.7.2

func NewISO8601Time(t time.Time, format string) ISO8601Time

NewISO8601Time 创建新的 ISO8601Time 实例

func (ISO8601Time) MarshalJSON added in v1.7.7

func (t ISO8601Time) MarshalJSON() ([]byte, error)

MarshalJSON 实现自定义的 JSON 序列化方法

func (*ISO8601Time) Scan added in v1.7.2

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

Scan 实现数据库读取

func (*ISO8601Time) UnmarshalJSON added in v1.7.7

func (t *ISO8601Time) UnmarshalJSON(data []byte) error

UnmarshalJSON 实现自定义的 JSON 解析方法

func (ISO8601Time) Value added in v1.7.2

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

Value 实现数据库写入

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"`
}

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 MixinModel

type MixinModel struct {
	OperatorModel
	IdTimeStampsModel
	GenericModel
}

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