12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- package model
- import (
- "git.getensh.com/common/gopkgsv2/database"
- "gorm.io/gorm"
- )
- type ManualTaskModel interface {
- List(db *gorm.DB, pagination *Pagination) ([]AdmManualTask, error)
- Count(db *gorm.DB) (int64, error)
- Update(db *gorm.DB, values interface{}) error
- Get(db *gorm.DB) (*AdmManualTask, error)
- }
- type AdmManualTask struct {
- Id int64 `gorm:"column:id" json:"id" form:"id"`
- TaskName string `gorm:"column:task_name" json:"task_name" form:"task_name"`
- Type int64 `gorm:"column:type" json:"type" form:"type"`
- Source string `gorm:"column:source" json:"source" form:"source"`
- Sql string `gorm:"column:sql" json:"sql" form:"sql"`
- TaskIds string `gorm:"column:task_ids" json:"task_ids" form:"task_ids"`
- Total int64 `gorm:"column:total" json:"total" form:"total"`
- FinishCount int64 `gorm:"column:finish_count" json:"finish_count" form:"finish_count"`
- IsFinish int64 `gorm:"column:is_finish" json:"is_finish" form:"is_finish"`
- CreatedAt int64 `gorm:"column:created_at" json:"created_at" form:"created_at"`
- UpdatedAt int64 `gorm:"column:updated_at" json:"updated_at" form:"updated_at"`
- }
- type defaultManualTask struct {
- tableName string
- fields string
- }
- func NewManualTask() ManualTaskModel {
- return &defaultManualTask{
- tableName: "t_adm_offline_task",
- fields: "`id`, `task_name`, `type`, `source`, `sql`, `task_ids`, `total`, `finish_count`, `is_finish`, `created_at`, `updated_at`",
- }
- }
- func (d *defaultManualTask) List(db *gorm.DB, pagination *Pagination) ([]AdmManualTask, error) {
- var res []AdmManualTask
- err := database.List(db, &res, database.Option{
- TableName: d.tableName,
- Fields: d.fields,
- Limit: pagination.Limit,
- OffSet: pagination.Offset,
- })
- return res, err
- }
- func (d *defaultManualTask) Count(db *gorm.DB) (int64, error) {
- return database.Count(db, database.Option{
- TableName: d.tableName,
- })
- }
- func (d *defaultManualTask) Update(db *gorm.DB, values interface{}) error {
- return database.Update(db, values, database.Option{
- TableName: d.tableName,
- })
- }
- func (d *defaultManualTask) Get(db *gorm.DB) (*AdmManualTask, error) {
- var res AdmManualTask
- err := database.Get(db, &res, database.Option{
- TableName: d.tableName,
- Fields: d.fields,
- })
- return &res, err
- }
|