This commit is contained in:
@@ -46,7 +46,7 @@ type ApiApplicationService interface {
|
||||
|
||||
// 管理端API调用记录
|
||||
GetAdminApiCalls(ctx context.Context, filters map[string]interface{}, options shared_interfaces.ListOptions) (*dto.ApiCallListResponse, error)
|
||||
|
||||
|
||||
// 导出功能
|
||||
ExportAdminApiCalls(ctx context.Context, filters map[string]interface{}, format string) ([]byte, error)
|
||||
|
||||
@@ -442,7 +442,7 @@ func (s *ApiApplicationServiceImpl) asyncRecordFailure(ctx context.Context, apiC
|
||||
zap.String("transaction_id", apiCall.TransactionId),
|
||||
zap.String("error_type", errorType),
|
||||
zap.String("error_msg", errorMsg))
|
||||
|
||||
|
||||
// 可选:如果需要统计失败请求,可以在这里添加计数器
|
||||
// s.failureCounter.Inc()
|
||||
}
|
||||
@@ -774,7 +774,7 @@ func (s *ApiApplicationServiceImpl) ExportAdminApiCalls(ctx context.Context, fil
|
||||
const batchSize = 1000 // 每批处理1000条记录
|
||||
var allCalls []*entities.ApiCall
|
||||
var productNameMap map[string]string
|
||||
|
||||
|
||||
// 分批获取数据
|
||||
page := 1
|
||||
for {
|
||||
@@ -819,7 +819,7 @@ func (s *ApiApplicationServiceImpl) ExportAdminApiCalls(ctx context.Context, fil
|
||||
// 准备导出数据
|
||||
headers := []string{"企业名称", "产品名称", "交易ID", "客户端IP", "状态", "开始时间", "结束时间"}
|
||||
columnWidths := []float64{30, 20, 40, 15, 10, 20, 20}
|
||||
|
||||
|
||||
data := make([][]interface{}, len(allCalls))
|
||||
for i, call := range allCalls {
|
||||
// 从映射中获取企业名称
|
||||
@@ -1206,8 +1206,8 @@ func (s *ApiApplicationServiceImpl) GetUserBalanceAlertSettings(ctx context.Cont
|
||||
// 获取API用户信息
|
||||
apiUser, err := s.apiUserService.LoadApiUserByUserId(ctx, userID)
|
||||
if err != nil {
|
||||
s.logger.Error("获取API用户信息失败",
|
||||
zap.String("user_id", userID),
|
||||
s.logger.Error("获取API用户信息失败",
|
||||
zap.String("user_id", userID),
|
||||
zap.Error(err))
|
||||
return nil, fmt.Errorf("获取API用户信息失败: %w", err)
|
||||
}
|
||||
@@ -1218,9 +1218,9 @@ func (s *ApiApplicationServiceImpl) GetUserBalanceAlertSettings(ctx context.Cont
|
||||
|
||||
// 返回预警设置
|
||||
settings := map[string]interface{}{
|
||||
"enabled": apiUser.BalanceAlertEnabled,
|
||||
"threshold": apiUser.BalanceAlertThreshold,
|
||||
"alert_phone": apiUser.AlertPhone,
|
||||
"enabled": apiUser.BalanceAlertEnabled,
|
||||
"threshold": apiUser.BalanceAlertThreshold,
|
||||
"alert_phone": apiUser.AlertPhone,
|
||||
}
|
||||
|
||||
return settings, nil
|
||||
@@ -1231,8 +1231,8 @@ func (s *ApiApplicationServiceImpl) UpdateUserBalanceAlertSettings(ctx context.C
|
||||
// 获取API用户信息
|
||||
apiUser, err := s.apiUserService.LoadApiUserByUserId(ctx, userID)
|
||||
if err != nil {
|
||||
s.logger.Error("获取API用户信息失败",
|
||||
zap.String("user_id", userID),
|
||||
s.logger.Error("获取API用户信息失败",
|
||||
zap.String("user_id", userID),
|
||||
zap.Error(err))
|
||||
return fmt.Errorf("获取API用户信息失败: %w", err)
|
||||
}
|
||||
@@ -1243,16 +1243,16 @@ func (s *ApiApplicationServiceImpl) UpdateUserBalanceAlertSettings(ctx context.C
|
||||
|
||||
// 更新预警设置
|
||||
if err := apiUser.UpdateBalanceAlertSettings(enabled, threshold, alertPhone); err != nil {
|
||||
s.logger.Error("更新预警设置失败",
|
||||
zap.String("user_id", userID),
|
||||
s.logger.Error("更新预警设置失败",
|
||||
zap.String("user_id", userID),
|
||||
zap.Error(err))
|
||||
return fmt.Errorf("更新预警设置失败: %w", err)
|
||||
}
|
||||
|
||||
// 保存到数据库
|
||||
if err := s.apiUserService.SaveApiUser(ctx, apiUser); err != nil {
|
||||
s.logger.Error("保存API用户信息失败",
|
||||
zap.String("user_id", userID),
|
||||
s.logger.Error("保存API用户信息失败",
|
||||
zap.String("user_id", userID),
|
||||
zap.Error(err))
|
||||
return fmt.Errorf("保存API用户信息失败: %w", err)
|
||||
}
|
||||
@@ -1271,8 +1271,8 @@ func (s *ApiApplicationServiceImpl) TestBalanceAlertSms(ctx context.Context, use
|
||||
// 获取用户信息以获取企业名称
|
||||
user, err := s.userRepo.GetByID(ctx, userID)
|
||||
if err != nil {
|
||||
s.logger.Error("获取用户信息失败",
|
||||
zap.String("user_id", userID),
|
||||
s.logger.Error("获取用户信息失败",
|
||||
zap.String("user_id", userID),
|
||||
zap.Error(err))
|
||||
return fmt.Errorf("获取用户信息失败: %w", err)
|
||||
}
|
||||
@@ -1285,8 +1285,8 @@ func (s *ApiApplicationServiceImpl) TestBalanceAlertSms(ctx context.Context, use
|
||||
|
||||
// 调用短信服务发送测试短信
|
||||
if err := s.balanceAlertService.CheckAndSendAlert(ctx, userID, decimal.NewFromFloat(balance)); err != nil {
|
||||
s.logger.Error("发送测试预警短信失败",
|
||||
zap.String("user_id", userID),
|
||||
s.logger.Error("发送测试预警短信失败",
|
||||
zap.String("user_id", userID),
|
||||
zap.String("phone", phone),
|
||||
zap.Float64("balance", balance),
|
||||
zap.String("alert_type", alertType),
|
||||
|
||||
@@ -965,7 +965,7 @@ func (s *ProductApplicationServiceImpl) getDTOMap() map[string]interface{} {
|
||||
"JRZQ0A03": &dto.JRZQ0A03Req{},
|
||||
"JRZQ4AA8": &dto.JRZQ4AA8Req{},
|
||||
"JRZQ8203": &dto.JRZQ8203Req{},
|
||||
"JRZQDBCE": &dto.JRZQDBCEReq{},
|
||||
"JRZQDBCE": &dto.JRZQDCBEReq{},
|
||||
"QYGL2ACD": &dto.QYGL2ACDReq{},
|
||||
"QYGL6F2D": &dto.QYGL6F2DReq{},
|
||||
"QYGL45BD": &dto.QYGL45BDReq{},
|
||||
|
||||
Reference in New Issue
Block a user