Documentation ¶
Overview ¶
controllers/base_controller.go
models/IModel.go
app/ISchema.go
service/IService.go
Index ¶
- type BaseController
- func (bc *BaseController[T, CreateDTO, QueryDTO, TVO]) BulkCreate(c *gin.Context)
- func (bc *BaseController[T, CreateDTO, QueryDTO, TVO]) BulkDelete(c *gin.Context)
- func (bc *BaseController[T, CreateDTO, QueryDTO, TVO]) Create(c *gin.Context)
- func (bc *BaseController[T, CreateDTO, QueryDTO, TVO]) GetById(c *gin.Context)
- func (bc *BaseController[T, CreateDTO, QueryDTO, TVO]) GetTreeById(c *gin.Context)
- func (bc *BaseController[IModel, CreateDTO, QueryDTO, TVO]) PageByDTO(c *gin.Context)
- func (bc *BaseController[T, CreateDTO, QueryDTO, TVO]) UpdateByMap(c *gin.Context)
- type BaseDTO
- type BaseService
- func (bs *BaseService[T]) BulkCreate(models []T) (int, []T, error)
- func (bs *BaseService[T]) BulkDelete(ids []string) (int, error)
- func (bs *BaseService[T]) Create(model *T) (*T, error)
- func (bs *BaseService[T]) Delete(id string) error
- func (bs *BaseService[T]) GetById(id string) (*T, error)
- func (bs *BaseService[T]) GetTreeById(id string) ([]T, error)
- func (bs *BaseService[T]) PageByMap(queryMap map[string]interface{}, queryPage *QueryPage) (*[]T, int, error)
- func (bs *BaseService[T]) Update(id string, model T) (*T, error)
- func (bs *BaseService[T]) UpdateByMap(id string, dtoMap map[string]interface{}) error
- type BaseVO
- type GenericModel
- type IBaseController
- type IBaseService
- type ICreateDTO
- type IModel
- type IQueryDTO
- type ISO8601Time
- type IVO
- type IdTimeStampsModel
- type MixinModel
- type OperatorModel
- type PaginationResult
- type QueryPage
- type SnowflakeIDModel
- type SoftDeleteModel
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]) 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]) UpdateByMap ¶
func (bc *BaseController[T, CreateDTO, QueryDTO, TVO]) UpdateByMap(c *gin.Context)
type BaseService ¶
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{}
type GenericModel ¶
type IBaseController ¶
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 ISO8601Time ¶ added in v1.7.2
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 解析方法
type IdTimeStampsModel ¶ added in v1.7.2
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 ¶ 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 PaginationResult ¶
type 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 ¶
Click to show internal directories.
Click to hide internal directories.