12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- package model
- import (
- "git.getensh.com/common/gopkgsv2/database"
- "gorm.io/gorm"
- )
- type RelationModel interface {
- List(db *gorm.DB, pagination *Pagination) ([]AdmRelation, error)
- Count(db *gorm.DB) (int64, error)
- Update(db *gorm.DB, values interface{}) error
- Get(db *gorm.DB) (*AdmRelation, error)
- }
- type AdmRelation struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- TaskId int64 `gorm:"column:task_id" json:"task_id" form:"task_id"`
- Desc string `gorm:"column:desc" json:"desc" form:"desc"`
- SourceCode string `gorm:"column:source_code" json:"source_code" form:"source_code"`
- IsOn string `gorm:"column:is_on" json:"is_on" form:"is_on"`
- 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 defaultRelation struct {
- tableName string
- fields string
- }
- func NewRelation() RelationModel {
- return &defaultRelation{
- tableName: "t_adm_task_data_relation",
- fields: "`id`, `task_id`, `source_code`, `is_on`, `created_at`, `updated_at`",
- }
- }
- func (d *defaultRelation) List(db *gorm.DB, pagination *Pagination) ([]AdmRelation, error) {
- var res []AdmRelation
- err := database.List(db, &res, database.Option{
- TableName: d.tableName,
- Fields: d.fields,
- Limit: pagination.Limit,
- OffSet: pagination.Offset,
- })
- return res, err
- }
- func (d *defaultRelation) Count(db *gorm.DB) (int64, error) {
- return database.Count(db, database.Option{
- TableName: d.tableName,
- })
- }
- func (d *defaultRelation) Update(db *gorm.DB, values interface{}) error {
- return database.Update(db, values, database.Option{
- TableName: d.tableName,
- })
- }
- func (d *defaultRelation) Get(db *gorm.DB) (*AdmRelation, error) {
- var res AdmRelation
- err := database.Get(db, &res, database.Option{
- TableName: d.tableName,
- Fields: d.fields,
- })
- return &res, err
- }
- type DataTaskInfo struct {
- Id int64 `gorm:"column:id" json:"id" form:"id"`
- TaskId int64 `gorm:"column:task_id" json:"task_id" form:"task_id"`
- TaskName string `gorm:"column:task_name" json:"task_name" form:"task_name"`
- IsOn int32 `gorm:"column:is_on" json:"is_on" form:"is_on"`
- }
|