sync: 同步 v1.0.4 并脱敏配置与镜像
This commit is contained in:
@@ -1,31 +1,28 @@
|
||||
// Package gen
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2026 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <xxx@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
// @AutoGenerate Version
|
||||
package iot
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/consts"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/dao"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/library/contexts"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/library/exportcenter"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/library/xgorm/handler"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/library/xgorm/hook"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/model"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/model/entity"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/service"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/utility/convert"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/utility/excel"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/encoding/gjson"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
type sIotTOrder struct{}
|
||||
@@ -357,51 +354,38 @@ func orderItemView(item *entity.TOrderItem) *model.TOrderItemViewModel {
|
||||
return view
|
||||
}
|
||||
|
||||
// Export 导出订单(异步:提交任务后到下载中心取文件)
|
||||
func (s *sIotTOrder) Export(ctx context.Context, in *model.TOrderListParam) (err error) {
|
||||
query := *in
|
||||
query.Page = 1
|
||||
query.PageSize = orderExportPageSize
|
||||
list := make([]*model.TOrderListModel, 0)
|
||||
totalCount := 0
|
||||
for {
|
||||
var (
|
||||
pageList []*model.TOrderListModel
|
||||
pageTotal int
|
||||
)
|
||||
if query.Perspective == orderPerspectiveSell {
|
||||
pageList, pageTotal, err = s.SellList(ctx, &query)
|
||||
} else {
|
||||
pageList, pageTotal, err = s.List(ctx, &query)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
totalCount = pageTotal
|
||||
list = append(list, pageList...)
|
||||
if len(pageList) == 0 || len(list) >= totalCount {
|
||||
break
|
||||
}
|
||||
query.Page++
|
||||
}
|
||||
|
||||
// 字段的排序是依据tags的字段顺序,如果你不想使用默认的排序方式,可以直接定义 tags = []string{"字段名称", "字段名称2", ...}
|
||||
tags, err := convert.GetEntityDescTags(model.TOrderExportModel{})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
var (
|
||||
fileName = "导出订单主表-" + gctx.CtxId(ctx)
|
||||
sheetName = fmt.Sprintf("筛选结果共%v行", totalCount)
|
||||
exports []model.TOrderExportModel
|
||||
)
|
||||
|
||||
if err = gconv.Scan(list, &exports); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = excel.ExportByStructs(ctx, tags, exports, fileName, sheetName)
|
||||
return
|
||||
_, err = exportcenter.Submit(ctx, &exportcenter.Request{
|
||||
BizKey: "tOrder",
|
||||
BizName: "订单",
|
||||
PermCode: "cpm:iot:tOrder:export",
|
||||
QueryParam: in,
|
||||
Tags: func() ([]string, error) {
|
||||
return convert.GetEntityDescTags(model.TOrderListModel{})
|
||||
},
|
||||
Fetch: func(ctx context.Context, page, pageSize int) (rows []interface{}, total int, err error) {
|
||||
query := *in
|
||||
query.Page = page
|
||||
query.PageSize = pageSize
|
||||
var list []*model.TOrderListModel
|
||||
var count int
|
||||
if query.Perspective == orderPerspectiveSell {
|
||||
list, count, err = s.SellList(ctx, &query)
|
||||
} else {
|
||||
list, count, err = s.List(ctx, &query)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
rows = make([]interface{}, 0, len(list))
|
||||
for _, item := range list {
|
||||
rows = append(rows, item)
|
||||
}
|
||||
return rows, count, nil
|
||||
},
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
// Edit 订单由业务流程生成,不允许后台手工修改。
|
||||
|
||||
Reference in New Issue
Block a user