数据引擎-快手平台数据抽取bug修复

This commit is contained in:
2026-06-16 10:44:10 +08:00
parent e5133eea34
commit b4fc6f54af
22 changed files with 1324 additions and 487 deletions

View File

@@ -18,13 +18,14 @@ var ApiInterface = new(apiInterfaceDao)
type apiInterfaceDao struct{}
// Insert 插入接口
func (d *apiInterfaceDao) Insert(ctx context.Context, req *dto.CreateApiInterfaceReq, creator string) (id int64, err error) {
func (d *apiInterfaceDao) Insert(ctx context.Context, req *dto.CreateApiInterfaceReq, creator string, tenantId uint64) (id int64, err error) {
var res *entity.ApiInterface
if err = gconv.Struct(req, &res); err != nil {
return
}
// 设置创建人和时间(服务端生成,不依赖前端入参)
// 设置审计字段(服务端生成,不依赖前端入参)
now := gtime.Now()
res.TenantId = tenantId
res.Creator = creator
res.CreatedAt = now
res.Updater = creator
@@ -38,7 +39,7 @@ func (d *apiInterfaceDao) Insert(ctx context.Context, req *dto.CreateApiInterfac
}
// Update 更新接口
func (d *apiInterfaceDao) Update(ctx context.Context, req *dto.UpdateApiInterfaceReq, updater string) (rows int64, err error) {
func (d *apiInterfaceDao) Update(ctx context.Context, req *dto.UpdateApiInterfaceReq, updater string, tenantId uint64) (rows int64, err error) {
// 设置更新人和更新时间(服务端生成,不依赖前端入参)
data := gconv.Map(req)
data[entity.ApiInterfaceCols.Updater] = updater
@@ -48,6 +49,7 @@ func (d *apiInterfaceDao) Update(ctx context.Context, req *dto.UpdateApiInterfac
Data(data).
OmitEmpty().
Where(entity.ApiInterfaceCols.Id, req.Id).
Where(entity.ApiInterfaceCols.TenantId, tenantId).
Update()
if err != nil {
return
@@ -56,8 +58,11 @@ func (d *apiInterfaceDao) Update(ctx context.Context, req *dto.UpdateApiInterfac
}
// Delete 删除接口
func (d *apiInterfaceDao) Delete(ctx context.Context, req *dto.DeleteApiInterfaceReq) (rows int64, err error) {
r, err := gfdb.DB(ctx).Model(ctx, consts.ApiInterfaceTable).Where(entity.ApiInterfaceCols.Id, req.Id).Delete()
func (d *apiInterfaceDao) Delete(ctx context.Context, req *dto.DeleteApiInterfaceReq, tenantId uint64) (rows int64, err error) {
r, err := gfdb.DB(ctx).Model(ctx, consts.ApiInterfaceTable).
Where(entity.ApiInterfaceCols.Id, req.Id).
Where(entity.ApiInterfaceCols.TenantId, tenantId).
Delete()
if err != nil {
return
}
@@ -65,8 +70,11 @@ func (d *apiInterfaceDao) Delete(ctx context.Context, req *dto.DeleteApiInterfac
}
// GetOne 获取单个接口
func (d *apiInterfaceDao) GetOne(ctx context.Context, req *dto.GetApiInterfaceReq) (res *entity.ApiInterface, err error) {
r, err := gfdb.DB(ctx).Model(ctx, consts.ApiInterfaceTable).Where(entity.ApiInterfaceCols.Id, req.Id).One()
func (d *apiInterfaceDao) GetOne(ctx context.Context, req *dto.GetApiInterfaceReq, tenantId uint64) (res *entity.ApiInterface, err error) {
r, err := gfdb.DB(ctx).Model(ctx, consts.ApiInterfaceTable).
Where(entity.ApiInterfaceCols.Id, req.Id).
Where(entity.ApiInterfaceCols.TenantId, tenantId).
One()
if err != nil {
return
}
@@ -75,13 +83,13 @@ func (d *apiInterfaceDao) GetOne(ctx context.Context, req *dto.GetApiInterfaceRe
}
// Count 获取接口数量
func (d *apiInterfaceDao) Count(ctx context.Context, req *dto.ListApiInterfaceReq) (count int, err error) {
return d.buildListFilter(ctx, req).Count()
func (d *apiInterfaceDao) Count(ctx context.Context, req *dto.ListApiInterfaceReq, tenantId uint64) (count int, err error) {
return d.buildListFilter(ctx, req, tenantId).Count()
}
// List 获取接口列表
func (d *apiInterfaceDao) List(ctx context.Context, req *dto.ListApiInterfaceReq) (res []entity.ApiInterface, total int, err error) {
model := d.buildListFilter(ctx, req)
func (d *apiInterfaceDao) List(ctx context.Context, req *dto.ListApiInterfaceReq, tenantId uint64) (res []entity.ApiInterface, total int, err error) {
model := d.buildListFilter(ctx, req, tenantId)
model.OrderDesc(entity.ApiInterfaceCols.CreatedAt)
if req.Page != nil {
model.Page(int(req.Page.PageNum), int(req.Page.PageSize))
@@ -95,8 +103,12 @@ func (d *apiInterfaceDao) List(ctx context.Context, req *dto.ListApiInterfaceReq
}
// buildListFilter 构建列表查询的过滤条件
func (d *apiInterfaceDao) buildListFilter(ctx context.Context, req *dto.ListApiInterfaceReq) *gdb.Model {
func (d *apiInterfaceDao) buildListFilter(ctx context.Context, req *dto.ListApiInterfaceReq, tenantId uint64) *gdb.Model {
model := gfdb.DB(ctx).Model(ctx, consts.ApiInterfaceTable).Model
// 租户隔离
model.Where(entity.ApiInterfaceCols.TenantId, tenantId)
if !g.IsEmpty(req.Keyword) {
model.WhereLike(entity.ApiInterfaceCols.Name, "%"+req.Keyword+"%")
model.WhereOrLike(entity.ApiInterfaceCols.Code, "%"+req.Keyword+"%")
@@ -104,16 +116,24 @@ func (d *apiInterfaceDao) buildListFilter(ctx context.Context, req *dto.ListApiI
if req.PlatformId > 0 {
model.Where(entity.ApiInterfaceCols.PlatformId, req.PlatformId)
}
model.Where(entity.ApiInterfaceCols.Name, req.Name)
model.Where(entity.ApiInterfaceCols.Code, req.Code)
model.Where(entity.ApiInterfaceCols.Method, req.Method)
model.Where(entity.ApiInterfaceCols.Status, req.Status)
if !g.IsEmpty(req.Name) {
model.Where(entity.ApiInterfaceCols.Name, req.Name)
}
if !g.IsEmpty(req.Code) {
model.Where(entity.ApiInterfaceCols.Code, req.Code)
}
if !g.IsEmpty(req.Method) {
model.Where(entity.ApiInterfaceCols.Method, req.Method)
}
if !g.IsEmpty(req.Status) {
model.Where(entity.ApiInterfaceCols.Status, req.Status)
}
model.OmitEmptyWhere()
return model
}
// UpdateStatus 更新接口状态
func (d *apiInterfaceDao) UpdateStatus(ctx context.Context, id int64, status string, updater string) (rows int64, err error) {
func (d *apiInterfaceDao) UpdateStatus(ctx context.Context, id int64, status string, updater string, tenantId uint64) (rows int64, err error) {
r, err := gfdb.DB(ctx).Model(ctx, consts.ApiInterfaceTable).
Data(map[string]interface{}{
entity.ApiInterfaceCols.Status: status,
@@ -121,6 +141,7 @@ func (d *apiInterfaceDao) UpdateStatus(ctx context.Context, id int64, status str
entity.ApiInterfaceCols.UpdatedAt: gtime.Now(),
}).
Where(entity.ApiInterfaceCols.Id, id).
Where(entity.ApiInterfaceCols.TenantId, tenantId).
Update()
if err != nil {
return
@@ -129,9 +150,10 @@ func (d *apiInterfaceDao) UpdateStatus(ctx context.Context, id int64, status str
}
// GetByIds 根据ID列表获取接口列表
func (d *apiInterfaceDao) GetByIds(ctx context.Context, ids []int64) (res []entity.ApiInterface, err error) {
func (d *apiInterfaceDao) GetByIds(ctx context.Context, ids []int64, tenantId uint64) (res []entity.ApiInterface, err error) {
r, err := gfdb.DB(ctx).Model(ctx, consts.ApiInterfaceTable).
WhereIn(entity.ApiInterfaceCols.Id, ids).
Where(entity.ApiInterfaceCols.TenantId, tenantId).
All()
if err != nil {
return