40 lines
1.3 KiB
Go
40 lines
1.3 KiB
Go
package app
|
|
|
|
import (
|
|
"context"
|
|
"github.com/gogf/gf/v2/errors/gerror"
|
|
"strings"
|
|
v1 "git.5iot.com/iotlcm-public/iotlcm-app/api/app/v1"
|
|
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/allocaterequest"
|
|
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/contexts"
|
|
"git.5iot.com/iotlcm-public/iotlcm-app/internal/service/executionlog"
|
|
)
|
|
|
|
type AllocateResultController struct{}
|
|
|
|
func (c *AllocateResultController) Result(ctx context.Context, req *v1.AllocateResultReq) (*v1.AllocateResultRes, error) {
|
|
batchNo := strings.TrimSpace(req.BatchNo)
|
|
if batchNo == "" {
|
|
batch, err := allocaterequest.Find(ctx, contexts.GetTenantId(ctx), contexts.GetUserId(ctx), req.RequestId)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if batch == nil {
|
|
return nil, gerror.New("划拨批次不存在或无权查看")
|
|
}
|
|
batchNo = batch.BatchNo
|
|
}
|
|
item, err := executionlog.AllocateSummary(ctx, batchNo)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &v1.AllocateResultRes{AppExecutionLogItem: item}, nil
|
|
}
|
|
func (c *AllocateResultController) Details(ctx context.Context, req *v1.AllocateDetailsReq) (*v1.AllocateDetailsRes, error) {
|
|
items, total, err := executionlog.AllocateDetails(ctx, &req.AppExecutionLogDetailParam)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &v1.AllocateDetailsRes{Items: items, Total: total}, nil
|
|
}
|