base

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 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 igin.IContext)

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

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

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

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

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

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

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

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

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

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

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

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

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

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 igin.IContext)
	BulkCreate(c igin.IContext)
	// Update(c igin.IContext)
	UpdateByMap(c igin.IContext)
	// Delete(c igin.IContext)
	BulkDelete(c igin.IContext)
	GetById(c igin.IContext)
	PageByDTO(c igin.IContext)
	GetTreeById(c igin.IContext)
}

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

type ISO8601Time struct {
	Time   time.Time // 时间
	Format string    // 自定义格式
}

ISO8601Time 自定义时间类型

func NewISO8601Time

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

NewISO8601Time 创建新的 ISO8601Time 实例

func (ISO8601Time) MarshalJSON

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

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

func (*ISO8601Time) Scan

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

Scan 实现数据库读取

func (*ISO8601Time) UnmarshalJSON

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

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

func (ISO8601Time) Value

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

Value 实现数据库写入

type IVO

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

type IdTimeStampsModel

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

func (*IdTimeStampsModel) BeforeCreate

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

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

func (*IdTimeStampsModel) BeforeUpdate

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 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 igin.IContext) *QueryPage

type SnowflakeIDModel

type SnowflakeIDModel struct {
	Id int64 `gorm:"column:id;primaryKey;autoIncrement:true" 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"`
}

Jump to

Keyboard shortcuts

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