fix querylist

This commit is contained in:
2025-04-12 11:13:23 +08:00
parent ab5a80df5e
commit 36de254ced
2 changed files with 13 additions and 17 deletions

View File

@@ -4,7 +4,6 @@ import (
"context"
"tyc-server/app/user/cmd/api/internal/svc"
"tyc-server/app/user/cmd/api/internal/types"
"tyc-server/app/user/model"
"tyc-server/common/ctxdata"
"tyc-server/common/xerr"
@@ -33,24 +32,21 @@ func (l *QueryListLogic) QueryList(req *types.QueryListReq) (resp *types.QueryLi
if getUidErr != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "报告列表查询, 获取用户信息失败, %+v", getUidErr)
}
build := l.svcCtx.OrderModel.SelectBuilder().Where(squirrel.Eq{
// 直接构建查询query表的条件
build := l.svcCtx.QueryModel.SelectBuilder().Where(squirrel.Eq{
"user_id": userID,
}).Where(squirrel.NotEq{
"status": []string{"pending", "closed"},
})
orderList, total, err := l.svcCtx.OrderModel.FindPageListByPageWithTotal(l.ctx, build, req.Page, req.PageSize, "create_time DESC")
if err != nil && !errors.Is(err, model.ErrNotFound) {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "报告列表查询, 查找订单列表错误, %+v", err)
// 直接从query表分页查询
queryList, total, err := l.svcCtx.QueryModel.FindPageListByPageWithTotal(l.ctx, build, req.Page, req.PageSize, "create_time DESC")
if err != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "报告列表查询, 查找报告列表错误, %+v", err)
}
var list []types.Query
if len(orderList) > 0 {
for _, orderModel := range orderList {
queryModel, findQueryErr := l.svcCtx.QueryModel.FindOneByOrderId(l.ctx, orderModel.Id)
if findQueryErr != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "报告列表查询, 查找报告错误, %+v", findQueryErr)
}
if len(queryList) > 0 {
for _, queryModel := range queryList {
var query types.Query
query.CreateTime = queryModel.CreateTime.Format("2006-01-02 15:04:05")
query.UpdateTime = queryModel.UpdateTime.Format("2006-01-02 15:04:05")