package model import ( "github.com/jinzhu/gorm" "time" ) type TaskProcessingInfo struct { ID int64 `gorm:"column:ID;PRIMARY_KEY"` Code string `gorm:"column:Code"` TaskID string `gorm:"column:TaskID"` TaskName string `gorm:"column:TaskName"` AssignmentDate time.Time `gorm:"column:AssignmentDate"` FinishDate time.Time `gorm:"column:FinishDate"` ProcessingPerson string `gorm:"column:processingperson"` Reviewer string `gorm:"column:Reviewer"` ProcessingDate time.Time `gorm:"column:ProcessingDate"` ProcessingResults string `gorm:"column:ProcessingResults"` Status int32 `gorm:"column:Status"` ProcessingResultsImg string `gorm:"column:ProcessingResultsImg"` Feedback string `gorm:"column:Feedback"` ProjectID int64 `gorm:"column:ProjectID"` TaskDesc string `gorm:"column:TaskDesc"` TaskType int32 `gorm:"column:TaskType"` TaskImg string `gorm:"column:TaskImg"` Pipeline string `gorm:"column:Pipeline"` ApproveDate time.Time `gorm:"column:ApproveDate"` ApproveImg string `gorm:"column:ApproveImg"` } const ( PipelineCreate = 1 PipelineProcessing = 2 PipelineApprove = 3 ) type TaskPipeline struct { PipeType int32 `json:"pipe_type"` Person string `json:"person"` Desc string `json:"desc"` Img string `json:"img"` PipeTime string `json:"pipe_time"` ApproveStatus bool `json:"approve_status"` } func (TaskProcessingInfo) TableName() string { return "TaskProcessingInfo" } func (p *TaskProcessingInfo) List(db *gorm.DB, where map[string]interface{}, or map[string]interface{}, page int32, pageSize int32) (list []TaskProcessingInfo, err error) { if len(where) > 0 || len(or) > 0 { cond, val, err := whereBuildAndOr(where, or) if err != nil { return list, err } if pageSize < 0 { result := db.Table(p.TableName()).Where(cond, val...).Order("AssignmentDate desc").Find(&list) return list, result.Error } offset := (page - 1) * pageSize result := db.Table(p.TableName()).Where(cond, val...).Order("AssignmentDate desc").Limit(pageSize).Offset(offset).Find(&list) return list, result.Error } if pageSize < 0 { result := db.Table(p.TableName()).Order("AssignmentDate desc").Find(&list) return list, result.Error } offset := (page - 1) * pageSize result := db.Table(p.TableName()).Order("AssignmentDate desc").Limit(pageSize).Offset(offset).Find(&list) return list, result.Error } func (p *TaskProcessingInfo) Insert(db *gorm.DB) error { return db.Table(p.TableName()).Create(p).Error } func (p *TaskProcessingInfo) Del(db *gorm.DB, where map[string]interface{}) error { cond, val, err := whereBuild(where) if err != nil { return err } return db.Table(p.TableName()).Where(cond, val...).Delete(p).Error } func (p *TaskProcessingInfo) Find(db *gorm.DB, where map[string]interface{}) error { cond, val, err := whereBuild(where) if err != nil { return err } return db.Table(p.TableName()).Where(cond, val...).First(p).Error } func (p *TaskProcessingInfo) FindOr(db *gorm.DB, where map[string]interface{}, or map[string]interface{}) error { cond, val, err := whereBuildAndOr(where, or) if err != nil { return err } return db.Table(p.TableName()).Where(cond, val...).First(p).Error } func (p *TaskProcessingInfo) Update(db *gorm.DB, where map[string]interface{}, values map[string]interface{}) error { cond, val, err := whereBuild(where) if err != nil { return err } return db.Table(p.TableName()).Where(cond, val...).Updates(values).Error } func (p *TaskProcessingInfo) Count(db *gorm.DB, where map[string]interface{}, or map[string]interface{}) (int64, error) { if len(where) > 0 || len(or) > 0{ cond, val, err := whereBuildAndOr(where, or) if err != nil { return 0, err } ret := int64(0) err = db.Table(p.TableName()).Where(cond, val...).Count(&ret).Error return ret, err } ret := int64(0) err := db.Table(p.TableName()).Count(&ret).Error return ret, err }