gserver

package
v0.7.6 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseDao

type BaseDao[T IModel] interface {
	Gen(*T) error
	GenOrGet(*T) error
	FindByID(string) (*T, error)
	FindByIDs(...string) ([]*T, error)
	FindOne(string, any) (*T, error)
	FindBy(string, ...any) ([]*T, error)
	FindAll() ([]*T, error)
}

type BaseDaoImpl

type BaseDaoImpl[T IModel] struct {
	// contains filtered or unexported fields
}

func (BaseDaoImpl[T]) Create

func (dao BaseDaoImpl[T]) Create(obj *T) (err error)

Create 创建

func (BaseDaoImpl[T]) Delete

func (dao BaseDaoImpl[T]) Delete(objs ...T) (err error)

Delete 根据对象删除

func (BaseDaoImpl[T]) DeleteBy

func (dao BaseDaoImpl[T]) DeleteBy(filedName string, value ...string) (err error)

DeleteBy 通过一个或者多个id删除

func (BaseDaoImpl[T]) DeleteByIDs

func (dao BaseDaoImpl[T]) DeleteByIDs(ids ...string) (err error)

DeleteByIDs 通过一个或者多个id删除

func (BaseDaoImpl[T]) GetAll

func (dao BaseDaoImpl[T]) GetAll() (objs []T, err error)

GetAll 获取全部数据

func (BaseDaoImpl[T]) GetBy

func (dao BaseDaoImpl[T]) GetBy(filedName string, value ...any) (objs []T, err error)

GetBy 获取多条数据

func (BaseDaoImpl[T]) GetByID

func (dao BaseDaoImpl[T]) GetByID(id string) (obj T, err error)

GetByID 根据id查询

func (BaseDaoImpl[T]) GetByIDs

func (dao BaseDaoImpl[T]) GetByIDs(ids ...string) (objs []T, err error)

GetByIDs 根据多个id查询

func (BaseDaoImpl[T]) GetOne

func (dao BaseDaoImpl[T]) GetOne(filedName string, value any) (obj T, err error)

GetOne 根据字段查询

func (BaseDaoImpl[T]) GetPage

func (dao BaseDaoImpl[T]) GetPage(pagination Pagination) (PagingResult[T], error)

GetPage 分页查询全部

func (BaseDaoImpl[T]) GetPageBy

func (dao BaseDaoImpl[T]) GetPageBy(pagination Pagination, filter string, args ...any) (PagingResult[T], error)

GetPageBy 分页查询

func (*BaseDaoImpl[T]) SetDB

func (dao *BaseDaoImpl[T]) SetDB(db *gorm.DB) *BaseDaoImpl[T]

func (BaseDaoImpl[T]) Update

func (dao BaseDaoImpl[T]) Update(obj *T) (err error)

Update 通过对象更新

func (BaseDaoImpl[T]) UpdateBy

func (dao BaseDaoImpl[T]) UpdateBy(obj *T, value map[string]any) (err error)

UpdateBy 通过列更新

type BaseModel

type BaseModel struct {
	ID         string         `json:"id" gorm:"type:varchar(32);comment:主键"`         // 主键ID
	CreateTime time.Time      `json:"createTime" gorm:"autoCreateTime;comment:创建时间"` // 创建时间
	UpdateTime time.Time      `json:"updateTime" gorm:"autoUpdateTime;comment:更新时间"` // 更新时间
	DeleteTime gorm.DeletedAt `json:"-" gorm:"index;comment:删除时间"`                   // 删除标记
	Remarks    string         `json:"remarks" gorm:"default:null;comment:备注"`        // 备注
}

func (*BaseModel) BeforeCreate

func (b *BaseModel) BeforeCreate(tx *gorm.DB) error

type BaseModelInt

type BaseModelInt struct {
	ID        int            `json:"id" gorm:"type:int;comment:主键"`          // 主键ID
	CreatedAt time.Time      `json:"createdAt" gorm:"comment:创建时间"`          // 创建时间
	UpdatedAt time.Time      `json:"updatedAt" gorm:"comment:更新时间"`          // 更新时间
	DeletedAt gorm.DeletedAt `json:"-" gorm:"index;comment:删除时间"`            // 删除时间
	Remarks   string         `json:"remarks" gorm:"default:null;comment:备注"` // 备注
}

type BaseService

type BaseService[T IModel] interface {
	Create(obj T)
	Delete(obj T)
	DeleteByID(id string)
	GetByID(id string) (obj T)
	GetBy(filedName string, value ...any) (obj T)
	GetAll() (objs []T)
	GetPage(pagination Pagination) (objs []T)
	Update(obj T)
}

type BaseServiceImpl

type BaseServiceImpl[T IModel] struct {
}

func (BaseServiceImpl[T]) Create

func (service BaseServiceImpl[T]) Create(obj T)

func (BaseServiceImpl[T]) Delete

func (service BaseServiceImpl[T]) Delete(obj T)

func (BaseServiceImpl[T]) DeleteByID

func (service BaseServiceImpl[T]) DeleteByID(id string)

func (BaseServiceImpl[T]) GetByID

func (service BaseServiceImpl[T]) GetByID(id string) (obj T)

func (BaseServiceImpl[T]) GetList

func (service BaseServiceImpl[T]) GetList() (objs []T)

func (BaseServiceImpl[T]) GetPage

func (service BaseServiceImpl[T]) GetPage(pagination Pagination) (objs []T)

func (BaseServiceImpl[T]) Update

func (service BaseServiceImpl[T]) Update(obj T)

type IModel

type IModel interface{}

type Pagination

type Pagination struct {
	PageSize int    `json:"pageSize" uri:"pageSize"`
	Page     int    `json:"page" uri:"page"`
	Sort     string `json:"sort" uri:"sort"`
}

func NewPagination

func NewPagination(pageSize, page int, sort string) Pagination

type PagingResult

type PagingResult[T any] struct {
	TotalPages int64 `json:"totalPages" uri:"totalPages"`
	TotalCount int64 `json:"totalCount" uri:"totalCount"`
	Objs       []T   `json:"objs" uri:"objs"`
}

Jump to

Keyboard shortcuts

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