1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- package model
- import (
- "git.getensh.com/common/gopkgsv2/database"
- "gorm.io/gorm"
- )
- type TaskListModel interface {
- List(db *gorm.DB, pagination *Pagination) ([]AdmTaskList, error)
- Count(db *gorm.DB) (int64, error)
- Update(db *gorm.DB, values interface{}) error
- Get(db *gorm.DB) (*AdmTaskList, error)
- }
- type AdmTaskList struct {
- TaskId int64 `gorm:"column:task_id" json:"task_id" form:"task_id"`
- TaskName string `gorm:"column:task_name" json:"task_name" form:"task_name"`
- Desc string `gorm:"column:desc" json:"desc" form:"desc"`
- TargetTable string `gorm:"column:target_table" json:"target_table" form:"target_table"`
- 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 defaultTaskList struct {
- tableName string
- fields string
- }
- func NewTaskList() TaskListModel {
- return &defaultTaskList{
- tableName: "t_adm_tasks_management",
- fields: "`task_id`, `task_name`, `desc`, `target_table`, `created_at`, `updated_at`",
- }
- }
- func (d *defaultTaskList) List(db *gorm.DB, pagination *Pagination) ([]AdmTaskList, error) {
- var res []AdmTaskList
- err := database.List(db, &res, database.Option{
- TableName: d.tableName,
- Fields: d.fields,
- Limit: pagination.Limit,
- OffSet: pagination.Offset,
- })
- return res, err
- }
- func (d *defaultTaskList) Count(db *gorm.DB) (int64, error) {
- return database.Count(db, database.Option{
- TableName: d.tableName,
- })
- }
- func (d *defaultTaskList) Update(db *gorm.DB, values interface{}) error {
- return database.Update(db, values, database.Option{
- TableName: d.tableName,
- })
- }
- func (d *defaultTaskList) Get(db *gorm.DB) (*AdmTaskList, error) {
- var res AdmTaskList
- err := database.Get(db, &res, database.Option{
- TableName: d.tableName,
- Fields: d.fields,
- })
- return &res, err
- }
- type TaskInfo struct {
- TaskId int64 `gorm:"column:task_id" json:"task_id" form:"task_id"`
- TaskName string `gorm:"column:task_name" json:"task_name" form:"task_name"`
- Desc string `gorm:"column:desc" json:"desc" form:"desc"`
- }
|