fix:修复ai识别的bug

This commit is contained in:
chengqian committed 2026-05-28 15:43:05 +08:00
1 parent 941ba902f6
commit 31cefe4800
5 files changed
+23 -12

No files matched your search

@@ -3,12 +3,10 @@ package tenant
import (
"context"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/qianfree/team-api/api/tenant/v1"
v1 "github.com/qianfree/team-api/api/tenant/v1"
"github.com/qianfree/team-api/internal/service"
)
func (c *ControllerV1) TenantNotificationDelete(ctx context.Context, req *v1.TenantNotificationDeleteReq) (res *v1.TenantNotificationDeleteRes, err error) {
return nil, gerror.NewCode(gcode.CodeNotImplemented)
return service.Tenant().DeleteNotification(ctx, req)
}
+14 -1
View File
@@ -87,8 +87,21 @@ func (s *sAdmin) UpdateAuditConfig(ctx context.Context, req *v1.AuditConfigUpdat
return nil, nil
}
// queryPage 使用原生 SQL 分页查询,绕过 GoFrame ScanAndCount 对 map[string]any 的 bug
// allowedQueryTables 白名单:仅允许 queryPage 查询这些表
var allowedQueryTables = map[string]bool{
"aud_operation_logs": true,
"aud_sensitive_access_logs": true,
"aud_request_logs": true,
"aud_content_filter_logs": true,
}
// queryPage 使用原生 SQL 分页查询,绕过 GoFrame ScanAndCount 对 map[string]any 的 bug。
// table 和 fields 仅接受白名单中的表名和预定义字段,防止 SQL 注入。
func queryPage(ctx context.Context, table, fields, where, orderBy string, page, pageSize int, args ...any) ([]map[string]any, int, error) {
if !allowedQueryTables[table] {
return nil, 0, fmt.Errorf("不允许查询的表: %s", table)
}
countSQL := fmt.Sprintf("SELECT COUNT(*) AS total FROM %s", table)
if where != "" {
countSQL += " WHERE " + where
+1 -1
View File
@@ -121,7 +121,7 @@ func (s *sAdmin) CronJobExecutions(ctx context.Context, req *v1.CronJobExecution
func (s *sAdmin) CronJobTrigger(ctx context.Context, req *v1.CronJobTriggerReq) (*v1.CronJobTriggerRes, error) {
err := common.GetCronScheduler().TriggerJob(ctx, req.Name)
if err != nil {
return nil, fmt.Errorf("触发任务失败: %v", err)
return nil, fmt.Errorf("触发任务失败: %w", err)
}
return &v1.CronJobTriggerRes{Message: "任务已触发"}, nil
}
+3 -3
View File
@@ -36,7 +36,7 @@ func ApiMaintenance(r *ghttp.Request) {
}
durationStr := common.Config().GetString(ctx, "maintenance_duration")
retryAfter := parseMaintenanceDuration(durationStr)
retryAfter := parseMaintenanceDuration(ctx, durationStr)
message := common.Config().GetString(ctx, "maintenance_message")
if message == "" {
@@ -70,14 +70,14 @@ func ApiMaintenance(r *ghttp.Request) {
// parseMaintenanceDuration parses a duration string like "2h", "30m", "1h30m"
// and returns the total number of seconds. Returns 300 (5 minutes) as default
// if parsing fails or the string is empty.
func parseMaintenanceDuration(s string) int {
func parseMaintenanceDuration(ctx context.Context, s string) int {
if s == "" {
return 300
}
d, err := time.ParseDuration(s)
if err != nil {
g.Log().Warningf(context.TODO(), "failed to parse maintenance duration %q: %v, using default 300s", s, err)
g.Log().Warningf(ctx, "failed to parse maintenance duration %q: %v, using default 300s", s, err)
return 300
}
+2 -2
View File
@@ -101,8 +101,8 @@ func (a *VolcengineVideoAdaptor) ValidateRequest(_ context.Context, _ *common.Re
func (a *VolcengineVideoAdaptor) EstimateBilling(_ context.Context, info *common.RelayInfo, body []byte) map[string]float64 {
var req map[string]any
if json.Unmarshal(body, &req) != nil {
return nil
if err := json.Unmarshal(body, &req); err != nil {
return map[string]float64{}
}
ratios := make(map[string]float64)