七月迭代短暂完结,还有很多后端的关键东西没有弄,这是一版赶时间做的东西
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m26s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m26s
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/middleware"
|
||||
@@ -57,10 +58,26 @@ func (q *ListQuery) List(ctx context.Context, req *dto.ExchangeListRequest) (*dt
|
||||
if err := query.Order("created_at DESC").Offset(offset).Limit(pageSize).Find(&orders).Error; err != nil {
|
||||
return nil, errors.Wrap(errors.CodeDatabaseError, err, "查询换货单列表失败")
|
||||
}
|
||||
submitterIDs := make([]uint, 0, len(orders))
|
||||
for _, order := range orders {
|
||||
if order.Creator > 0 {
|
||||
submitterIDs = append(submitterIDs, order.Creator)
|
||||
}
|
||||
}
|
||||
accounts, err := postgres.NewAccountStore(q.db, nil).GetDisplayAccountsByIDs(ctx, submitterIDs)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(errors.CodeDatabaseError, err, "查询换货提交人失败")
|
||||
}
|
||||
submitterNames := make(map[uint]string, len(accounts))
|
||||
for _, account := range accounts {
|
||||
submitterNames[account.ID] = account.Username
|
||||
}
|
||||
|
||||
items := make([]*dto.ExchangeOrderResponse, 0, len(orders))
|
||||
for _, order := range orders {
|
||||
items = append(items, projectExchangeOrder(order))
|
||||
item := projectExchangeOrder(order)
|
||||
item.SubmitterName = submitterNames[order.Creator]
|
||||
items = append(items, item)
|
||||
}
|
||||
return &dto.ExchangeListResponse{List: items, Total: total, Page: page, PageSize: pageSize}, nil
|
||||
}
|
||||
@@ -121,7 +138,7 @@ func projectExchangeOrder(order *model.ExchangeOrder) *dto.ExchangeOrderResponse
|
||||
ExchangeReason: order.ExchangeReason, Remark: order.Remark,
|
||||
Status: order.Status, StatusName: constants.GetExchangeStatusName(order.Status), StatusText: constants.GetExchangeStatusName(order.Status),
|
||||
ShopID: order.ShopID, CreatedAt: order.CreatedAt, UpdatedAt: order.UpdatedAt, DeletedAt: deletedAt,
|
||||
Creator: order.Creator, Updater: order.Updater,
|
||||
SubmitterID: order.Creator, Creator: order.Creator, Updater: order.Updater,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user