Documentation ¶
Index ¶
- Constants
- func Exit(cb func())
- type AuthMixin
- type BaseController
- type BaseDao
- func (dao BaseDao[T]) Delete(record *T) error
- func (dao BaseDao[T]) DeleteByCondition(conditions *Conditions) error
- func (dao BaseDao[T]) DeleteById(id string) error
- func (dao BaseDao[T]) DeleteByIds(ids ...string) error
- func (dao BaseDao[T]) DeleteHard(record *T) error
- func (dao BaseDao[T]) DeleteHardByCondition(conditions *Conditions) error
- func (dao BaseDao[T]) DeleteHardById(id string) error
- func (dao BaseDao[T]) DeleteHardByIds(ids ...string) error
- func (dao BaseDao[T]) Exist(record *T) (bool, error)
- func (dao BaseDao[T]) Insert(record *T) error
- func (dao BaseDao[T]) InsertBatch(records []*T, batch int) error
- func (dao BaseDao[T]) InsertList(records []*T) error
- func (dao BaseDao[T]) InsertOrSelect(record *T) error
- func (dao BaseDao[T]) Save(record *T) error
- func (dao BaseDao[T]) Select(record *T) ([]*T, error)
- func (dao BaseDao[T]) SelectAll() ([]*T, error)
- func (dao BaseDao[T]) SelectByCondition(conditions *Conditions) ([]*T, error)
- func (dao BaseDao[T]) SelectById(id string) (*T, error)
- func (dao BaseDao[T]) SelectByIds(ids ...string) ([]*T, error)
- func (dao BaseDao[T]) SelectCount(record *T) (int64, error)
- func (dao BaseDao[T]) SelectCountByCondition(conditions *Conditions) (int64, error)
- func (dao BaseDao[T]) SelectDistinct(conditions *Conditions) ([]*T, error)
- func (dao BaseDao[T]) SelectOne(record *T) (*T, error)
- func (dao BaseDao[T]) SelectOneByConditions(record *T, conditions *Conditions) (*T, error)
- func (dao BaseDao[T]) SelectPage(currentPage, pageSize int, sort string) (*Pagination[T], error)
- func (dao BaseDao[T]) SelectPageByCondition(currentPage, pageSize int, sort string, conditions *Conditions) (*Pagination[T], error)
- func (dao BaseDao[T]) Update(record *T) error
- func (dao BaseDao[T]) UpdateByCondition(record *T, conditions *Conditions) error
- func (dao BaseDao[T]) UpdateSelective(record *T, values any) error
- func (dao BaseDao[T]) UpdateSelectiveByCondition(record *T, conditions *Conditions) error
- type BaseModel
- type BaseModelNoPg
- type BaseService
- func (srv BaseService[T]) DeleteById(id string) error
- func (srv BaseService[T]) DeleteByIds(ids ...string) error
- func (srv BaseService[T]) FindAll() ([]*T, error)
- func (srv BaseService[T]) FindBy(colName string, value any) (*T, error)
- func (srv BaseService[T]) FindByCondition(conditions *Conditions) ([]*T, error)
- func (srv BaseService[T]) FindById(id string) (*T, error)
- func (srv BaseService[T]) FindByIds(ids ...string) ([]*T, error)
- func (srv BaseService[T]) Save(entity *T) error
- func (srv BaseService[T]) Saves(entities []*T) error
- func (srv BaseService[T]) Update(entity *T) error
- type Conditions
- func (c *Conditions) AndBetween(field string, value1, value2 any) *Conditions
- func (c *Conditions) AndEqualTo(field string, value any) *Conditions
- func (c *Conditions) AndGreaterThan(field string, value any) *Conditions
- func (c *Conditions) AndGreaterThanOrEqualTo(field string, value any) *Conditions
- func (c *Conditions) AndILike(field string, value any) *Conditions
- func (c *Conditions) AndIn(field string, value any) *Conditions
- func (c *Conditions) AndIsNotNull(field string) *Conditions
- func (c *Conditions) AndIsNull(field string) *Conditions
- func (c *Conditions) AndLessThan(field string, value any) *Conditions
- func (c *Conditions) AndLessThanOrEqualTo(field string, value any) *Conditions
- func (c *Conditions) AndLike(field string, value any) *Conditions
- func (c *Conditions) AndNotBetween(field string, value1, value2 any) *Conditions
- func (c *Conditions) AndNotEqualTo(field string, value any) *Conditions
- func (c *Conditions) AndNotIn(field string, value any) *Conditions
- func (c *Conditions) AndNotLike(field string, value any) *Conditions
- func (c *Conditions) Group(fields string) *Conditions
- func (c *Conditions) Joins(joinCondition string) *Conditions
- func (c *Conditions) OrBetween(field string, value1, value2 any) *Conditions
- func (c *Conditions) OrEqualTo(field string, value any) *Conditions
- func (c *Conditions) OrGreaterThan(field string, value any) *Conditions
- func (c *Conditions) OrGreaterThanOrEqualTo(field string, value any) *Conditions
- func (c *Conditions) OrILike(field string, value any) *Conditions
- func (c *Conditions) OrIn(field string, value any) *Conditions
- func (c *Conditions) OrIsNotNull(field string) *Conditions
- func (c *Conditions) OrIsNull(field string) *Conditions
- func (c *Conditions) OrLessThan(field string, value any) *Conditions
- func (c *Conditions) OrLessThanOrEqualTo(field string, value any) *Conditions
- func (c *Conditions) OrLike(field string, value any) *Conditions
- func (c *Conditions) OrNotBetween(field string, value1, value2 any) *Conditions
- func (c *Conditions) OrNotEqualTo(field string, value any) *Conditions
- func (c *Conditions) OrNotLike(field string, value any) *Conditions
- func (c *Conditions) Order(fields string) *Conditions
- func (c *Conditions) OtNotIn(field string, value any) *Conditions
- func (c *Conditions) Select(fields string) *Conditions
- func (c *Conditions) To(db *gorm.DB) *gorm.DB
- type Dao
- type IdMixin
- type Pagination
- type PgTimeMixin
- type Service
- type TimeMixin
- type Timestamp
- type TimestampUTC
Constants ¶
View Source
const ( AND = iota OR ORDER SELECT GROUP JOIN )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BaseController ¶
func (BaseController[T]) Add ¶
func (ctl BaseController[T]) Add(c *gin.Context)
func (BaseController[T]) DeleteById ¶
func (ctl BaseController[T]) DeleteById(c *gin.Context)
func (BaseController[T]) FindAll ¶
func (ctl BaseController[T]) FindAll(c *gin.Context)
func (BaseController[T]) FindById ¶
func (ctl BaseController[T]) FindById(c *gin.Context)
func (BaseController[T]) Update ¶
func (ctl BaseController[T]) Update(c *gin.Context)
type BaseDao ¶
func (BaseDao[T]) DeleteByCondition ¶
func (dao BaseDao[T]) DeleteByCondition(conditions *Conditions) error
func (BaseDao[T]) DeleteById ¶
func (BaseDao[T]) DeleteByIds ¶
func (BaseDao[T]) DeleteHard ¶
func (BaseDao[T]) DeleteHardByCondition ¶
func (dao BaseDao[T]) DeleteHardByCondition(conditions *Conditions) error
func (BaseDao[T]) DeleteHardById ¶
func (BaseDao[T]) DeleteHardByIds ¶
func (BaseDao[T]) InsertBatch ¶
func (BaseDao[T]) InsertList ¶
func (BaseDao[T]) InsertOrSelect ¶
func (BaseDao[T]) SelectByCondition ¶
func (dao BaseDao[T]) SelectByCondition(conditions *Conditions) ([]*T, error)
func (BaseDao[T]) SelectById ¶
func (BaseDao[T]) SelectByIds ¶
func (BaseDao[T]) SelectCount ¶
func (BaseDao[T]) SelectCountByCondition ¶
func (dao BaseDao[T]) SelectCountByCondition(conditions *Conditions) (int64, error)
func (BaseDao[T]) SelectDistinct ¶
func (dao BaseDao[T]) SelectDistinct(conditions *Conditions) ([]*T, error)
func (BaseDao[T]) SelectOneByConditions ¶
func (dao BaseDao[T]) SelectOneByConditions(record *T, conditions *Conditions) (*T, error)
func (BaseDao[T]) SelectPage ¶
func (dao BaseDao[T]) SelectPage(currentPage, pageSize int, sort string) (*Pagination[T], error)
func (BaseDao[T]) SelectPageByCondition ¶
func (dao BaseDao[T]) SelectPageByCondition(currentPage, pageSize int, sort string, conditions *Conditions) (*Pagination[T], error)
func (BaseDao[T]) UpdateByCondition ¶
func (dao BaseDao[T]) UpdateByCondition(record *T, conditions *Conditions) error
func (BaseDao[T]) UpdateSelective ¶
func (BaseDao[T]) UpdateSelectiveByCondition ¶
func (dao BaseDao[T]) UpdateSelectiveByCondition(record *T, conditions *Conditions) error
type BaseModel ¶
type BaseModel struct { IdMixin PgTimeMixin AuthMixin Remarks string `json:"remarks,omitempty" gorm:"column:remarks;default:null;comment:备注"` // 备注 }
type BaseModelNoPg ¶
type BaseService ¶
func (BaseService[T]) DeleteById ¶
func (srv BaseService[T]) DeleteById(id string) error
func (BaseService[T]) DeleteByIds ¶
func (srv BaseService[T]) DeleteByIds(ids ...string) error
func (BaseService[T]) FindAll ¶
func (srv BaseService[T]) FindAll() ([]*T, error)
func (BaseService[T]) FindBy ¶
func (srv BaseService[T]) FindBy(colName string, value any) (*T, error)
func (BaseService[T]) FindByCondition ¶
func (srv BaseService[T]) FindByCondition(conditions *Conditions) ([]*T, error)
func (BaseService[T]) FindById ¶
func (srv BaseService[T]) FindById(id string) (*T, error)
func (BaseService[T]) FindByIds ¶
func (srv BaseService[T]) FindByIds(ids ...string) ([]*T, error)
func (BaseService[T]) Save ¶
func (srv BaseService[T]) Save(entity *T) error
func (BaseService[T]) Saves ¶
func (srv BaseService[T]) Saves(entities []*T) error
func (BaseService[T]) Update ¶
func (srv BaseService[T]) Update(entity *T) error
type Conditions ¶
type Conditions struct {
// contains filtered or unexported fields
}
func NewConditions ¶
func NewConditions() *Conditions
func (*Conditions) AndBetween ¶
func (c *Conditions) AndBetween(field string, value1, value2 any) *Conditions
func (*Conditions) AndEqualTo ¶
func (c *Conditions) AndEqualTo(field string, value any) *Conditions
func (*Conditions) AndGreaterThan ¶
func (c *Conditions) AndGreaterThan(field string, value any) *Conditions
func (*Conditions) AndGreaterThanOrEqualTo ¶
func (c *Conditions) AndGreaterThanOrEqualTo(field string, value any) *Conditions
func (*Conditions) AndILike ¶
func (c *Conditions) AndILike(field string, value any) *Conditions
func (*Conditions) AndIn ¶
func (c *Conditions) AndIn(field string, value any) *Conditions
func (*Conditions) AndIsNotNull ¶
func (c *Conditions) AndIsNotNull(field string) *Conditions
func (*Conditions) AndIsNull ¶
func (c *Conditions) AndIsNull(field string) *Conditions
func (*Conditions) AndLessThan ¶
func (c *Conditions) AndLessThan(field string, value any) *Conditions
func (*Conditions) AndLessThanOrEqualTo ¶
func (c *Conditions) AndLessThanOrEqualTo(field string, value any) *Conditions
func (*Conditions) AndLike ¶
func (c *Conditions) AndLike(field string, value any) *Conditions
func (*Conditions) AndNotBetween ¶
func (c *Conditions) AndNotBetween(field string, value1, value2 any) *Conditions
func (*Conditions) AndNotEqualTo ¶
func (c *Conditions) AndNotEqualTo(field string, value any) *Conditions
func (*Conditions) AndNotIn ¶
func (c *Conditions) AndNotIn(field string, value any) *Conditions
func (*Conditions) AndNotLike ¶
func (c *Conditions) AndNotLike(field string, value any) *Conditions
func (*Conditions) Group ¶
func (c *Conditions) Group(fields string) *Conditions
func (*Conditions) Joins ¶
func (c *Conditions) Joins(joinCondition string) *Conditions
func (*Conditions) OrBetween ¶
func (c *Conditions) OrBetween(field string, value1, value2 any) *Conditions
func (*Conditions) OrEqualTo ¶
func (c *Conditions) OrEqualTo(field string, value any) *Conditions
func (*Conditions) OrGreaterThan ¶
func (c *Conditions) OrGreaterThan(field string, value any) *Conditions
func (*Conditions) OrGreaterThanOrEqualTo ¶
func (c *Conditions) OrGreaterThanOrEqualTo(field string, value any) *Conditions
func (*Conditions) OrILike ¶
func (c *Conditions) OrILike(field string, value any) *Conditions
func (*Conditions) OrIn ¶
func (c *Conditions) OrIn(field string, value any) *Conditions
func (*Conditions) OrIsNotNull ¶
func (c *Conditions) OrIsNotNull(field string) *Conditions
func (*Conditions) OrIsNull ¶
func (c *Conditions) OrIsNull(field string) *Conditions
func (*Conditions) OrLessThan ¶
func (c *Conditions) OrLessThan(field string, value any) *Conditions
func (*Conditions) OrLessThanOrEqualTo ¶
func (c *Conditions) OrLessThanOrEqualTo(field string, value any) *Conditions
func (*Conditions) OrLike ¶
func (c *Conditions) OrLike(field string, value any) *Conditions
func (*Conditions) OrNotBetween ¶
func (c *Conditions) OrNotBetween(field string, value1, value2 any) *Conditions
func (*Conditions) OrNotEqualTo ¶
func (c *Conditions) OrNotEqualTo(field string, value any) *Conditions
func (*Conditions) OrNotLike ¶
func (c *Conditions) OrNotLike(field string, value any) *Conditions
func (*Conditions) Order ¶
func (c *Conditions) Order(fields string) *Conditions
func (*Conditions) OtNotIn ¶
func (c *Conditions) OtNotIn(field string, value any) *Conditions
func (*Conditions) Select ¶
func (c *Conditions) Select(fields string) *Conditions
type Dao ¶
type Dao[T any] interface { Save(record *T) error // 插入或者更新 Insert(record *T) error // 插入 InsertList(records []*T) error // 批量插入 InsertBatch(records []*T, batch int) error // 批量插入, 自定义batch InsertOrSelect(record *T) error // 插入或者获取第一个 Delete(record *T) error // 删除 DeleteHard(record *T) error // 硬删除 DeleteById(id string) error // 根据id删除 DeleteHardById(id string) error // 根据id硬删除 DeleteByIds(ids ...string) error // 根据多个id批量删除 DeleteHardByIds(ids ...string) error // 根据多个id批量硬删除 DeleteByCondition(conditions *Conditions) error // 根据条件删除 DeleteHardByCondition(conditions *Conditions) error // 根据条件硬删除 Update(*T) error // 更新 UpdateSelective(record *T, values any) error // 更新一个数据多列 UpdateSelectiveByCondition(record *T, conditions *Conditions) error // 根据条件更新部分字段 UpdateByCondition(record *T, conditions *Conditions) error // 根据条件更新全部字段 SelectById(id string) (*T, error) // 根据id查询 SelectByIds(ids ...string) ([]*T, error) // 根据多个id查询 SelectOne(record *T) (*T, error) // 根据记录查询一个 SelectOneByConditions(record *T, conditions *Conditions) (*T, error) // 根据条件查询一个 Select(record *T) ([]*T, error) // 根据记录查询多个 SelectAll() ([]*T, error) // 查询所有 SelectCount(record *T) (int64, error) // 查询数量 SelectByCondition(conditions *Conditions) ([]*T, error) // 根据条件查询 SelectCountByCondition(conditions *Conditions) (int64, error) // 根据条件查询数量 SelectDistinct(conditions *Conditions) ([]*T, error) // 去重查询 SelectPage(currentPage, pageSize int, sort string) (*Pagination[T], error) // 分页查询 SelectPageByCondition(currentPage, pageSize int, sort string, conditions *Conditions) (*Pagination[T], error) // 根据条件分页查询 Exist(record *T) (bool, error) // 判断是否存在 }
type IdMixin ¶
type IdMixin struct {
ID string `json:"id" gorm:"primaryKey;column:id;type:varchar(32);comment:主键"` // 主键ID
}
type Pagination ¶
type PgTimeMixin ¶
type PgTimeMixin struct { CreateTime Timestamp `json:"createTime,omitempty" gorm:"autoCreateTime;column:create_time;type:timestamptz;comment:创建时间"` // 创建时间 UpdateTime Timestamp `json:"updateTime,omitempty" gorm:"autoUpdateTime;column:update_time;type:timestamptz;comment:更新时间"` // 更新时间 DeleteTime gorm.DeletedAt `json:"-" gorm:"index;column:delete_time;type:timestamptz;comment:删除时间"` // 删除标记 }
type Service ¶
type Service[T any] interface { Save(entity *T) error // 保存 Saves(entities []*T) error // 批量保存 DeleteById(id string) error // 根据id删除单个 DeleteByIds(ids ...string) error // 根据多个id删除 Update(entity *T) error // 更新 FindById(id string) (*T, error) // 根据id查找 FindBy(colName string, value any) (*T, error) // 根据某个字段查找唯一值 FindByIds(ids ...string) ([]*T, error) // 根据id查找多个 FindByCondition(conditions *Conditions) ([]*T, error) // 根据条件查找 FindAll() ([]*T, error) // 查找全部 }
type TimeMixin ¶
type TimeMixin struct { CreateTime Timestamp `json:"createTime,omitempty" gorm:"autoCreateTime;column:create_time;type:datetime;comment:创建时间"` // 创建时间 UpdateTime Timestamp `json:"updateTime,omitempty" gorm:"autoUpdateTime;column:update_time;type:datetime;comment:更新时间"` // 更新时间 DeleteTime gorm.DeletedAt `json:"-" gorm:"index;column:delete_time;type:datetime;comment:删除时间"` // 删除标记 }
type TimestampUTC ¶
时间格式
func (TimestampUTC) MarshalJSON ¶
func (ts TimestampUTC) MarshalJSON() ([]byte, error)
func (*TimestampUTC) Scan ¶
func (ts *TimestampUTC) Scan(value interface{}) error
func (*TimestampUTC) UnmarshalJSON ¶
func (ts *TimestampUTC) UnmarshalJSON(data []byte) error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.