33 lines
878 B
Go
33 lines
878 B
Go
package cpdaily
|
|
|
|
import (
|
|
"context"
|
|
v1 "likedream-goframe/internal/api/v1"
|
|
"likedream-goframe/internal/db"
|
|
"likedream-goframe/internal/ent"
|
|
"likedream-goframe/internal/ent/cptasklog"
|
|
"likedream-goframe/internal/ent/sysuser"
|
|
"likedream-goframe/internal/utils"
|
|
)
|
|
|
|
type CpTaskLogServiceV1 struct {
|
|
}
|
|
|
|
func (v CpTaskLogServiceV1) List(ctx context.Context, req *v1.CpTaskLogListReq) *utils.Response[[]*ent.CpTaskLog] {
|
|
user := utils.GetUserInfoFromCtx(ctx)
|
|
query := db.Global.CpTaskLog.Query().Where(
|
|
cptasklog.HasSystemUserWith(sysuser.ID(user.ID)),
|
|
cptasklog.CpTaskID(req.TaskID))
|
|
total := query.CountX(ctx)
|
|
var data []*ent.CpTaskLog
|
|
if total > 0 {
|
|
query.Limit(req.Size).Offset((req.Page - 1) * req.Size)
|
|
data = query.AllX(ctx)
|
|
}
|
|
return utils.SuccessWithTotal(data, total)
|
|
}
|
|
|
|
func NewCpTaskLogServiceV1() *CpTaskLogServiceV1 {
|
|
return &CpTaskLogServiceV1{}
|
|
}
|