41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package model
|
|
|
|
import (
|
|
"ArmedPolice/app/common/model"
|
|
"ArmedPolice/serve/orm"
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
type WorkProgress struct {
|
|
*model.WorkProgress
|
|
}
|
|
|
|
type WorkProgressInfo struct {
|
|
ID uint64 `json:"id"`
|
|
ScheduleTitle string `json:"schedule_title"`
|
|
Username string `json:"username"`
|
|
Status int `json:"status"`
|
|
Remark string `json:"remark"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
func (m *WorkProgress) Progress(workID uint64) ([]*WorkProgressInfo, error) {
|
|
db := orm.GetDB().Table(m.TableName()+" AS p").
|
|
Select("p.id", "s.title AS schedule_title", "u.name AS username", "p.status", "p.remark", "p.created_at").
|
|
Joins(fmt.Sprintf("LEFT JOIN %s AS s ON p.schedule_id = s.id", model.NewWorkSchedule().TableName())).
|
|
Joins(fmt.Sprintf("LEFT JOIN %s AS u ON p.uid = u.uuid", model.NewSysUser().TableName())).
|
|
Where("p.work_id = ?", workID).
|
|
Where("p.is_deleted = ?", model.DeleteStatusForNot)
|
|
|
|
out := make([]*WorkProgressInfo, 0)
|
|
|
|
err := db.Order("p.id " + model.OrderModeToDesc).Scan(&out).Error
|
|
|
|
return out, err
|
|
}
|
|
|
|
func NewWorkProgress() *WorkProgress {
|
|
return &WorkProgress{model.NewWorkProgress()}
|
|
}
|