- 新增统计控制器、服务层与数据访问层,提供按天统计接口 - 在 worker 处理任务时原子累加请求计数(仅实际调用模型时计数) - 更新数据库表结构,添加 asynch_model_stat 表及索引 - 更新文档说明统计功能的使用方式与统计口径
41 lines
895 B
Go
41 lines
895 B
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
|
|
"model-asynch/dao"
|
|
"model-asynch/model/dto"
|
|
)
|
|
|
|
type statService struct{}
|
|
|
|
var Stat = &statService{}
|
|
|
|
func (s *statService) List(ctx context.Context, req *dto.ListModelStatReq) (res *dto.ListModelStatRes, err error) {
|
|
pageNum, pageSize := 1, 10
|
|
if req != nil && req.Page != nil {
|
|
if req.Page.PageNum > 0 {
|
|
pageNum = int(req.Page.PageNum)
|
|
}
|
|
if req.Page.PageSize > 0 {
|
|
pageSize = int(req.Page.PageSize)
|
|
}
|
|
}
|
|
startDay, endDay := "", ""
|
|
var tenantID *int64
|
|
creator, modelName := "", ""
|
|
if req != nil {
|
|
startDay = req.StartDay
|
|
endDay = req.EndDay
|
|
tenantID = req.TenantID
|
|
creator = req.Creator
|
|
modelName = req.ModelName
|
|
}
|
|
list, total, err := dao.Stat.List(ctx, pageNum, pageSize, startDay, endDay, tenantID, creator, modelName)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &dto.ListModelStatRes{List: list, Total: total}, nil
|
|
}
|
|
|