sync: 同步 v1.0.4 并脱敏配置与镜像
This commit is contained in:
@@ -1,28 +1,25 @@
|
||||
// package system
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <xxx@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package system
|
||||
|
||||
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/event"
|
||||
"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/model"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/model/do"
|
||||
"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"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
@@ -180,35 +177,31 @@ func (l *sSysPost) Delete(ctx context.Context, param *model.SysPostDeleteParam)
|
||||
return
|
||||
}
|
||||
|
||||
// Export 导出岗位管理(异步:提交任务后到下载中心取文件)
|
||||
func (l *sSysPost) Export(ctx context.Context, param *model.SysPostExportParam) (post *model.SysPostExportModel, err error) {
|
||||
if param.Page == 0 {
|
||||
param.Page = 1
|
||||
}
|
||||
if param.PageSize == 0 {
|
||||
param.PageSize = 1000
|
||||
}
|
||||
items, total, err := l.List(ctx, param.SysPostListParam)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
// 字段的排序是依据tags的字段顺序,如果你不想使用默认的排序方式,可以直接定义 tags = []string{"字段名称", "字段名称2", ...}
|
||||
tags, err := convert.GetEntityDescTags(model.SysPostExportModel{})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
var (
|
||||
fileName = "导出CURD列表-" + gctx.CtxId(ctx)
|
||||
sheetName = fmt.Sprintf("索引条件共%v行,共%v页,当前导出是第%v页,本页共%v行", total, total+param.PageSize-1/param.PageSize, param.Page, len(items))
|
||||
exports []model.SysPostExportModel
|
||||
)
|
||||
g.Log().Info(ctx, " sSysPost.Export total", total)
|
||||
if err = gconv.Scan(items, &exports); err != nil {
|
||||
return
|
||||
}
|
||||
g.Log().Info(ctx, " sSysPost.Export exports", len(exports))
|
||||
err = excel.ExportByStructs(ctx, tags, exports, fileName, sheetName)
|
||||
g.Log().Info(ctx, " sSysPost.Export err", err)
|
||||
_, err = exportcenter.Submit(ctx, &exportcenter.Request{
|
||||
BizKey: "post",
|
||||
BizName: "岗位管理",
|
||||
PermCode: "cpm:system:post:export",
|
||||
QueryParam: param,
|
||||
Tags: func() ([]string, error) {
|
||||
return convert.GetEntityDescTags(model.SysPostListModel{})
|
||||
},
|
||||
Fetch: func(ctx context.Context, page, pageSize int) (rows []interface{}, total int, err error) {
|
||||
query := param.SysPostListParam
|
||||
query.Page = page
|
||||
query.PageSize = pageSize
|
||||
items, count, err := l.List(ctx, query)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
rows = make([]interface{}, 0, len(items))
|
||||
for _, item := range items {
|
||||
rows = append(rows, item)
|
||||
}
|
||||
return rows, count, nil
|
||||
},
|
||||
})
|
||||
post = &model.SysPostExportModel{}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user