add qcxg7a2b
This commit is contained in:
@@ -40,24 +40,24 @@ type WhiteListListResponse struct {
|
||||
|
||||
// API调用记录相关DTO
|
||||
type ApiCallRecordResponse struct {
|
||||
ID string `json:"id"`
|
||||
AccessId string `json:"access_id"`
|
||||
UserId string `json:"user_id"`
|
||||
ProductId *string `json:"product_id,omitempty"`
|
||||
ProductName *string `json:"product_name,omitempty"`
|
||||
TransactionId string `json:"transaction_id"`
|
||||
ClientIp string `json:"client_ip"`
|
||||
Status string `json:"status"`
|
||||
StartAt string `json:"start_at"`
|
||||
EndAt *string `json:"end_at,omitempty"`
|
||||
Cost *string `json:"cost,omitempty"`
|
||||
ErrorType *string `json:"error_type,omitempty"`
|
||||
ErrorMsg *string `json:"error_msg,omitempty"`
|
||||
TranslatedErrorMsg *string `json:"translated_error_msg,omitempty"`
|
||||
CompanyName *string `json:"company_name,omitempty"`
|
||||
User *UserSimpleResponse `json:"user,omitempty"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
ID string `json:"id"`
|
||||
AccessId string `json:"access_id"`
|
||||
UserId string `json:"user_id"`
|
||||
ProductId *string `json:"product_id,omitempty"`
|
||||
ProductName *string `json:"product_name,omitempty"`
|
||||
TransactionId string `json:"transaction_id"`
|
||||
ClientIp string `json:"client_ip"`
|
||||
Status string `json:"status"`
|
||||
StartAt string `json:"start_at"`
|
||||
EndAt *string `json:"end_at,omitempty"`
|
||||
Cost *string `json:"cost,omitempty"`
|
||||
ErrorType *string `json:"error_type,omitempty"`
|
||||
ErrorMsg *string `json:"error_msg,omitempty"`
|
||||
TranslatedErrorMsg *string `json:"translated_error_msg,omitempty"`
|
||||
CompanyName *string `json:"company_name,omitempty"`
|
||||
User *UserSimpleResponse `json:"user,omitempty"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
// UserSimpleResponse 用户简单信息响应
|
||||
@@ -95,8 +95,6 @@ func NewErrorResponse(code int, message, transactionId string) *ApiCallResponse
|
||||
Code: code,
|
||||
Message: message,
|
||||
TransactionId: transactionId,
|
||||
Data: "",
|
||||
Data: "",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,3 +45,9 @@ func GetErrorCode(err error) int {
|
||||
}
|
||||
return 1001 // 默认返回接口异常
|
||||
}
|
||||
|
||||
// GetErrorMessage 获取错误对应的错误消息
|
||||
func GetErrorMessage(err error) string {
|
||||
// 直接返回预定义的错误消息
|
||||
return err.Error()
|
||||
}
|
||||
|
||||
@@ -215,3 +215,7 @@ type COMB86PMReq struct {
|
||||
MobileNo string `json:"mobile_no" validate:"required,min=11,max=11,validMobileNo"`
|
||||
AuthDate string `json:"auth_date" validate:"required,validAuthDate" encrypt:"false"`
|
||||
}
|
||||
|
||||
type QCXG7A2BReq struct {
|
||||
IDCard string `json:"id_card" validate:"required,validIDCard"`
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"tyapi-server/internal/domains/api/services/processors/flxg"
|
||||
"tyapi-server/internal/domains/api/services/processors/ivyz"
|
||||
"tyapi-server/internal/domains/api/services/processors/jrzq"
|
||||
"tyapi-server/internal/domains/api/services/processors/qcxg"
|
||||
"tyapi-server/internal/domains/api/services/processors/qygl"
|
||||
"tyapi-server/internal/domains/api/services/processors/yysy"
|
||||
"tyapi-server/internal/domains/product/services"
|
||||
@@ -124,6 +125,9 @@ func registerAllProcessors(combService *comb.CombService) {
|
||||
// COMB系列处理器
|
||||
"COMB298Y": comb.ProcessCOMB298YRequest,
|
||||
"COMB86PM": comb.ProcessCOMB86PMRequest,
|
||||
|
||||
// QCXG系列处理器
|
||||
"QCXG7A2B": qcxg.ProcessQCXG7A2BRequest,
|
||||
}
|
||||
|
||||
// 批量注册到组合包服务
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package qcxg
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"tyapi-server/internal/domains/api/dto"
|
||||
"tyapi-server/internal/domains/api/services/processors"
|
||||
"tyapi-server/internal/infrastructure/external/westdex"
|
||||
)
|
||||
|
||||
// ProcessQCXG7A2BRequest QCXG7A2B API处理方法
|
||||
func ProcessQCXG7A2BRequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
|
||||
var paramsDto dto.QCXG7A2BReq
|
||||
if err := json.Unmarshal(params, ¶msDto); err != nil {
|
||||
return nil, fmt.Errorf("%s: %w", processors.ErrSystem, err)
|
||||
}
|
||||
|
||||
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
|
||||
return nil, fmt.Errorf("%s: %w", processors.ErrInvalidParam, err)
|
||||
}
|
||||
|
||||
reqData := map[string]interface{}{
|
||||
"id_card": paramsDto.IDCard,
|
||||
}
|
||||
|
||||
respBytes, err := deps.YushanService.CallAPI("CAR061", reqData)
|
||||
if err != nil {
|
||||
if errors.Is(err, westdex.ErrDatasource) {
|
||||
return nil, fmt.Errorf("%s: %w", processors.ErrDatasource, err)
|
||||
} else {
|
||||
return nil, fmt.Errorf("%s: %w", processors.ErrSystem, err)
|
||||
}
|
||||
}
|
||||
|
||||
return respBytes, nil
|
||||
}
|
||||
@@ -73,9 +73,10 @@ func (h *ApiHandler) HandleApiCall(c *gin.Context) {
|
||||
// 3. 调用应用服务
|
||||
transactionId, encryptedResp, err := h.appService.CallApi(c.Request.Context(), &cmd)
|
||||
if err != nil {
|
||||
// 根据错误类型返回对应的错误码
|
||||
// 根据错误类型返回对应的错误码和预定义错误消息
|
||||
errorCode := api.GetErrorCode(err)
|
||||
response := dto.NewErrorResponse(errorCode, err.Error(), transactionId)
|
||||
errorMessage := api.GetErrorMessage(err)
|
||||
response := dto.NewErrorResponse(errorCode, errorMessage, transactionId)
|
||||
c.JSON(200, response) // API调用接口统一返回200状态码
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user