Merge pull request 'fix' (#137) from devad/pcm-coordinator:master into master
Former-commit-id: 83ce60817e00d92e8f05dbc44189205a0be51a6a
This commit is contained in:
commit
f9885d64ff
|
@ -338,7 +338,7 @@ type (
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskModel {
|
TaskModel {
|
||||||
Id int64 `json:"id,omitempty" db:"id"` // id
|
Id int64 `json:"id,omitempty,string" db:"id"` // id
|
||||||
Name string `json:"name,omitempty" db:"name"` // 作业名称
|
Name string `json:"name,omitempty" db:"name"` // 作业名称
|
||||||
Description string `json:"description,omitempty" db:"description"` // 作业描述
|
Description string `json:"description,omitempty" db:"description"` // 作业描述
|
||||||
Status string `json:"status,omitempty" db:"status"` // 作业状态
|
Status string `json:"status,omitempty" db:"status"` // 作业状态
|
||||||
|
|
|
@ -3,6 +3,7 @@ package core
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
|
"time"
|
||||||
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
@ -28,7 +29,7 @@ func (l *PageListTaskLogic) PageListTask(req *types.PageTaskReq) (resp *types.Pa
|
||||||
limit := req.PageSize
|
limit := req.PageSize
|
||||||
offset := req.PageSize * (req.PageNum - 1)
|
offset := req.PageSize * (req.PageNum - 1)
|
||||||
resp = &types.PageResult{}
|
resp = &types.PageResult{}
|
||||||
var list []types.TaskModel
|
var list []*types.TaskModel
|
||||||
db := l.svcCtx.DbEngin.Model(&types.TaskModel{}).Table("task")
|
db := l.svcCtx.DbEngin.Model(&types.TaskModel{}).Table("task")
|
||||||
|
|
||||||
db = db.Where("deleted_at is null")
|
db = db.Where("deleted_at is null")
|
||||||
|
@ -48,8 +49,19 @@ func (l *PageListTaskLogic) PageListTask(req *types.PageTaskReq) (resp *types.Pa
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, result.NewDefaultError(err.Error())
|
return nil, result.NewDefaultError(err.Error())
|
||||||
}
|
}
|
||||||
|
const layout = "2006-01-02 15:04:05"
|
||||||
resp.List = list
|
for _, model := range list {
|
||||||
|
if model.EndTime != "" && model.StartTime != "" {
|
||||||
|
starTime, _ := time.Parse(layout, model.StartTime)
|
||||||
|
endTime, _ := time.Parse(layout, model.EndTime)
|
||||||
|
model.RunningTime = int64(endTime.Sub(starTime).Seconds())
|
||||||
|
}
|
||||||
|
if model.StartTime != "" {
|
||||||
|
starTime, _ := time.Parse(layout, model.StartTime)
|
||||||
|
model.RunningTime = int64(time.Now().Sub(starTime).Seconds())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resp.List = &list
|
||||||
resp.PageSize = req.PageSize
|
resp.PageSize = req.PageSize
|
||||||
resp.PageNum = req.PageNum
|
resp.PageNum = req.PageNum
|
||||||
resp.Total = total
|
resp.Total = total
|
||||||
|
|
|
@ -261,7 +261,7 @@ type PageTaskReq struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type TaskModel struct {
|
type TaskModel struct {
|
||||||
Id int64 `json:"id,omitempty" db:"id"` // id
|
Id int64 `json:"id,omitempty,string" db:"id"` // id
|
||||||
Name string `json:"name,omitempty" db:"name"` // 作业名称
|
Name string `json:"name,omitempty" db:"name"` // 作业名称
|
||||||
Description string `json:"description,omitempty" db:"description"` // 作业描述
|
Description string `json:"description,omitempty" db:"description"` // 作业描述
|
||||||
Status string `json:"status,omitempty" db:"status"` // 作业状态
|
Status string `json:"status,omitempty" db:"status"` // 作业状态
|
||||||
|
|
Loading…
Reference in New Issue