This commit is contained in:
2024-09-14 10:48:09 +08:00
commit a5fa833937
192 changed files with 87641 additions and 0 deletions

1
model/common/Error.go Normal file
View File

@@ -0,0 +1 @@
package model

19
model/common/jwt.go Normal file
View File

@@ -0,0 +1,19 @@
package model
import (
jwt "github.com/golang-jwt/jwt/v5"
"qnc-server/model/model"
)
type CustomClaims struct {
BaseClaims
BufferTime int64
jwt.RegisteredClaims
}
type BaseClaims struct {
Userid uint
Disable bool
AuthIdentifiers model.AuthIdentifier
Platform model.AuthType
}

7
model/common/prodID.go Normal file
View File

@@ -0,0 +1,7 @@
package model
const (
ProdIDLawsuit = "JUD003"
ProdIDBankCardGamblingAndFraud = "FIN013"
ProdIDBankCardBlacklistV1 = "FIN019"
)

105
model/model/antifraud.go Normal file
View File

@@ -0,0 +1,105 @@
package model
import "qnc-server/model/request"
type AntiFraud struct {
BaseModel
UserID uint `gorm:"column:userid;not null"`
CardNo string `gorm:"column:card_no;type:varchar(255);not null"` // 卡号
Name string `gorm:"column:name;type:varchar(255);not null"` // 姓名
Mobile string `gorm:"column:mobile;type:varchar(255);not null"` // 手机号
FraudScoreResp string `gorm:"column:fraud_score_resp;type:varchar(600)"` // FIN025 反欺诈评分
RiskAssessmentResp string `gorm:"column:risk_assessment_resp;type:varchar(600)"` // FIN030 综合风险评估 输入姓名
MobileRiskCheckResp string `gorm:"column:mobile_risk_check_resp;type:varchar(600)"` // MOB032 风险手机号列表核验
NegativeSecurityCheckResp string `gorm:"column:negative_security_check_resp;type:varchar(600)"` // P_C_B019 社会负面安全核验
RiskPersonV2Resp string `gorm:"column:risk_person_v2_resp;type:varchar(600)"` // RIS010 风险人员V2
AntiFraudGamblingResp string `gorm:"column:anti_fraud_gambling_resp;type:varchar(600)"` // RIS031 反诈反赌核验
TelecomFraudListResp string `gorm:"column:telecom_fraud_list_resp;type:varchar(600)"` // RIS035 电信诈骗名单
PersonalCredibilityResp string `gorm:"column:personal_credibility_resp;type:varchar(600)"` // HRD015 个人可信度查询
OrderID uint `gorm:"column:order_id;not null"`
}
func (AntiFraud) TableName() string {
return "fraud_prevention"
}
var AntiFraudProdIDs = []string{
"FIN025", // 反欺诈评分
"FIN030", // 综合风险评估 输入姓名
"MOB032", // 风险手机号列表核验
//暂时不可用 "P_C_B019", // 社会负面安全核验
"RIS010", // 风险人员V2
"RIS031", // 反诈反赌核验
"RIS035", // 电信诈骗名单
"HRD015", // 个人可信度查询
}
var AntiFraudFieldMapping = map[string]string{
"FIN025": "FraudScoreResp",
"FIN030": "RiskAssessmentResp",
"MOB032": "MobileRiskCheckResp",
"P_C_B019": "NegativeSecurityCheckResp",
"RIS010": "RiskPersonV2Resp",
"RIS031": "AntiFraudGamblingResp",
"RIS035": "TelecomFraudListResp",
"HRD015": "PersonalCredibilityResp",
}
type AntiFraudReqPayload struct {
request.AntiFraudQueryReq
ProdID string
}
var AntiFraudProdIDParams = map[string][]string{
"FIN025": {"cardNo", "name", "mobile"},
"FIN030": {"cardNo", "name", "mobile"},
"MOB032": {"mobile"},
"P_C_B019": {"cardNo", "name"},
"RIS010": {"name", "cardNo", "mobile"},
"RIS031": {"type", "keyWord"},
"RIS035": {"cardNo", "name"},
"HRD015": {"name", "cardNo"},
}
type YuShanResponse[T any] struct {
ResponseSn string `json:"response_sn"` // 响应序列号
Retdata T `json:"retdata"` // 返回数据
Version string `json:"version"` // 版本号
RequestSn string `json:"request_sn"` // 请求序列号
Retmsg string `json:"retmsg"` // 返回消息
Retdate int64 `json:"retdate"` // 返回日期(时间戳)
Retcode string `json:"retcode"` // 返回代码
}
type FraudScoreRetData struct {
BjScore float64 `json:"bj_score"`
}
type RiskAssessmentRetData struct {
BjScore float64 `json:"bj_score"`
}
type MobileRiskCheckRetData struct {
phonePrimaryInfo float64 `json:"bj_score"`
//phoneRiskLabels
}
// 报告
type AntiFraudReport struct {
FraudScore struct {
Score int
Comment string
} `json:"fraud_score"` // FIN025 反欺诈评分
RiskAssessment struct {
Score int
Comment string
} `json:"risk_assessment"` // FIN030 综合风险评估
MobileRiskCheck map[string]interface{} `json:"mobile_risk_check"` // MOB032 风险手机号列表核验
//NegativeSecurityCheck map[string]interface{} `json:"negative_security_check"` // P_C_B019 社会负面安全核验
RiskPersonV2 map[string]interface{} `json:"risk_person_v2"` // RIS010 风险人员V2
AntiFraudGambling map[string]interface{} `json:"anti_fraud_gambling"` // RIS031 反诈反赌核验
TelecomFraudList map[string]interface{} `json:"telecom_fraud_list"` // RIS035 电信诈骗名单
PersonalCredibility map[string]interface{} `json:"personal_credibility"` // HRD015 个人可信度查询
IDInfo IDInfo `json:"id_info"`
Name string `json:"name" `
Mobile string `json:"mobile"`
CardNo string `json:"card_no" `
}

13
model/model/base.go Normal file
View File

@@ -0,0 +1,13 @@
package model
import (
"gorm.io/gorm"
"time"
)
type BaseModel struct {
ID uint `gorm:"primarykey" json:"ID"` // 主键ID
CreatedAt time.Time // 创建时间
UpdatedAt time.Time // 更新时间
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` // 删除时间
}

148
model/model/car.go Normal file
View File

@@ -0,0 +1,148 @@
package model
import "qnc-server/model/request"
type CarInsurance struct {
BaseModel
UserID uint `gorm:"column:userid;not null"`
Vin string `gorm:"column:vin;type:varchar(255);not null"` //车架号
Resp string `gorm:"column:resp;type:text;not null"`
OrderID uint `gorm:"column:order_id;not null"`
}
func (CarInsurance) TableName() string {
return "car_insurance"
}
type CarInsuranceVerify struct {
BaseModel
UserID uint `gorm:"column:userid;not null"`
Vin string `gorm:"column:vin;type:varchar(255);not null"` //车架号
Resp string `gorm:"column:resp;type:text;not null"`
}
func (CarInsuranceVerify) TableName() string {
return "car_insurance_verify"
}
type CarInsurancePayload struct {
request.CarInsuranceReq
ProdID string
}
type CarMaintenance struct {
BaseModel
UserID uint `gorm:"column:userid;not null"`
Vin string `gorm:"column:vin;type:varchar(255);not null"` //车架号
LicenseImage string `gorm:"column:license_image;type:varchar(255);not null"`
OrderID uint `gorm:"column:order_id;not null"`
YuShanOrderID string `gorm:"column:yu_shan_order_id;type:varchar(255);not null"`
NotifySN string `gorm:"column:notify_sn;type:varchar(255);not null"`
Resp string `gorm:"column:resp;type:text"`
Status string `gorm:"column:status;type:varchar(50);not null"`
}
const (
StatusPending = "查询中"
StatusSuccess = "查询成功"
StatusFailed = "查询失败"
)
func (CarMaintenance) TableName() string {
return "car_maintenance"
}
// 人车核验 CAR012
type CarPersonCarVerify struct {
BaseModel
UserID uint `gorm:"column:userid;not null"`
Name string `gorm:"column:name;type:varchar(255);not null"` //人名
CarType string `gorm:"column:car_type;not null"`
CarNumber string `gorm:"column:car_number;type:varchar(255);not null"` // 车牌
OrderID uint `gorm:"column:order_id;not null"`
Resp string `gorm:"column:resp;type:text;not null"`
}
func (CarPersonCarVerify) TableName() string {
return "car_person_car_verify"
}
// CAR061名下车辆
type CarUnderName struct {
BaseModel
UserID uint `gorm:"column:userid;not null"`
OrderID uint `gorm:"column:order_id;not null"`
Resp string `gorm:"column:resp;type:text;not null"`
}
func (CarUnderName) TableName() string {
return "car_under_name"
}
// CAR070车辆上险信息 CAR095车五项 合并
type CarInsuranceInfo struct {
BaseModel
UserID uint `gorm:"column:userid;not null"`
Vin string `gorm:"column:vin;type:varchar(255);not null"` //车架号
OrderID uint `gorm:"column:order_id;not null"`
FiveResp string `gorm:"column:five_resp;type:text;not null"`
Resp string `gorm:"column:resp;type:text;not null"`
}
func (CarInsuranceInfo) TableName() string {
return "car_insurance_info"
}
// 新能源动力电池报告
type CarNewEnergyPower struct {
BaseModel
UserID uint `gorm:"column:userid;not null"`
Vin string `gorm:"column:vin;type:varchar(255);not null"` //车架号
OrderID uint `gorm:"column:order_id;not null"`
YuShanOrderID string `gorm:"column:yu_shan_order_id;type:varchar(255);not null"`
Resp string `gorm:"column:resp;type:text;not null"`
}
func (CarNewEnergyPower) TableName() string {
return "car_new_energy_power"
}
// vin查车辆信息
type CarVinCheckInfo struct {
BaseModel
UserID uint `gorm:"column:userid;not null"`
Vin string `gorm:"column:vin;type:varchar(255);not null"` //车架号
OrderID uint `gorm:"column:order_id;not null"`
Resp string `gorm:"column:resp;type:text;not null"`
}
func (CarVinCheckInfo) TableName() string {
return "car_vin_check_info"
}
// 车辆过户次数 Car066
type CarVehicleTransfer struct {
BaseModel
UserID uint `gorm:"column:userid;not null"`
Vin string `gorm:"column:vin;type:varchar(255);not null"` //车架号
OrderID uint `gorm:"column:order_id;not null"`
Resp string `gorm:"column:resp;type:text;not null"`
}
func (CarVehicleTransfer) TableName() string {
return "car_vehicle_transfer"
}
// 车辆估值 CAR100
type CarVehicleValuation struct {
BaseModel
UserID uint `gorm:"column:userid;not null"`
Vin string `gorm:"column:vin;type:varchar(255);not null"` //车架号
CarNumber string `gorm:"column:car_number;type:varchar(255);not null"` // 车牌
OrderID uint `gorm:"column:order_id;not null"`
Resp string `gorm:"column:resp;type:text;not null"`
}
func (CarVehicleValuation) TableName() string {
return "car_vehicle_valuation"
}

14
model/model/common.go Normal file
View File

@@ -0,0 +1,14 @@
package model
type Region struct {
FullRegion string `json:"fullRegion"`
Province string `json:"province"`
City string `json:"city"`
Region string `json:"region"`
}
type IDInfo struct {
Location string `json:"location"`
BirthDate string `json:"birth_date"`
Gender string `json:"gender"`
}

66
model/model/ent.go Normal file
View File

@@ -0,0 +1,66 @@
package model
type EntFeature struct {
BaseModel
UserID uint `gorm:"column:userid;not null"`
OrderID uint `gorm:"column:order_id;not null"`
Resp string `gorm:"column:resp;type:text"`
FeatureName string `gorm:"column:Feature_name;type:varchar(255);not null"`
}
func (EntFeature) TableName() string {
return "ent_feature"
}
var Links = map[string]string{
"search": "open/search/2.0", // 搜索
"baseinfo": "open/ic/baseinfoV2/2.0", // 企业基本信息(含企业联系方式)
"holder": "open/ic/holder/2.0", // 企业股东
"changeinfo": "open/ic/changeinfo/2.0", // 变更记录
"judicial": "open/cb/judicial/2.0", // 司法风险
"consumptionRestriction": "open/jr/consumptionRestriction/2.0", // 限制消费令
"appbkInfo": "open/m/appbkInfo/2.0", // 产品信息
"mortgageInfo": "open/mr/mortgageInfo/2.0", // 动产抵押
"historicalMortgageInfo": "open/hi/mortgageInfo/2.0", // 历史动产抵押
"landMortgage": "open/mr/landMortgage/2.0", // 土地抵押
"historicalIC": "open/hi/ic/2.0", // 历史工商信息
"profile": "v4/open/profile", // 企业简介
"trademarkDetail": "open/ipr/tm/detail/2.0", // 商标信息详情
"historicalAbnormal": "open/hi/abnormal/2.0", // 历史经营异常
"landMortgageDetail": "open/mr/landMortgage/detail/2.0", // 土地抵押详情
"companyType": "open/ic/companyType", // 企业类型
"historicalMembers": "open/hi/members", // 历史主要人员
"staff": "open/ic/staff/2.0", // 主要人员
"lawSuitDetail": "open/jr/lawSuit/detail", // 法律诉讼详情
"courtAnnouncement": "open/jr/courtAnnouncement/2.0", // 法院公告
"lawSuit": "open/jr/lawSuit/3.0", // 法律诉讼
"historicalLawSuit": "open/hi/lawSuit/3.0", // 历史法律诉讼
"historicalZhixing": "open/hi/zhixing/2.0", // 历史被执行人
"announcement": "open/hi/announcement/2.0", // 历史开庭公告
"historicalCourtAnnouncement": "open/hi/court/2.0", // 历史法院公告
"historicalDishonest": "open/hi/dishonest/2.0", // 历史失信人
"ktAnnouncement": "open/jr/ktannouncement/2.0", // 开庭公告
"zhixingInfo": "open/jr/zhixinginfo/2.0", // 被执行人
"endCase": "open/jr/endCase/2.0", // 终本案件
"sendAnnouncement": "open/jr/sendAnnouncement/2.0", // 送达公告
"courtRegister": "open/jr/courtRegister/2.0", // 立案信息
"dishonest": "open/jr/dishonest/2.0", // 失信人
"taxpayer": "open/m/taxpayer/2.0", // 一般纳税人
"publicWeChat": "open/ipr/publicWeChat/2.0", // 企业微信公账号
"customer": "open/m/customer/2.0", // 客户
"supply": "open/m/supply/2.0", // 供应商
"weibo": "open/m/weibo/2.0", // 企业微博
"getPledgeReg": "v4/open/getPledgeReg", // 知识产权出质
"equityInfo": "open/mr/equityInfo/2.0", // 股权出质
"ownTax": "open/mr/ownTax/2.0", // 欠税公告
"judicialSale": "open/mr/judicialSale/3.0", // 司法拍卖
"stockPledge": "open/mr/stockPledge/detail/2.0", // 质押明细详情
"abnormal": "open/mr/abnormal/2.0", // 经营异常
"punishmentInfo": "open/mr/punishmentInfo/3.0", // 行政处罚
"patents": "open/ipr/patents/3.0", // 企业专利信息
"copyReg": "open/ipr/copyReg/2.0", // 软件著作权
"companyholding": "open/human/companyholding/2.0", // 人员控股企业
"annualreport": "open/ic/annualreport/2.0", // 企业年报
"development": "open/cb/development/2.0", // 企业发展
"partners": "v4/open/partners", // 人员所有合作伙伴
}

View File

@@ -0,0 +1,18 @@
package model
import (
"qnc-server/model/types"
)
type JusticeLawsuit struct {
BaseModel
UserID uint `gorm:"column:userid;not null"`
LawsuitType types.LawsuitType `gorm:"column:lawsuit_type;type:tinyint(1);not null"`
Resp string `gorm:"column:list_resp;type:MEDIUMTEXT;"`
Mobile string `gorm:"column:mobile;type:varchar(255);not null"` // 手机号
OrderID uint `gorm:"column:order_id;not null"`
}
func (Lawsuit) TableName() string {
return "lawsuit"
}

41
model/model/lawsuit.go Normal file
View File

@@ -0,0 +1,41 @@
package model
import "encoding/json"
type Lawsuit struct {
BaseModel
UserID uint `gorm:"column:userid;not null"`
CardNo string `gorm:"column:card_no;type:varchar(255);not null"` // 卡号
Name string `gorm:"column:name;type:varchar(255);not null"` // 姓名
Mobile string `gorm:"column:mobile;type:varchar(255);not null"` // 手机号
ListResp string `gorm:"column:list_resp;type:text;"`
SxrResp string `gorm:"column:srx_resp;type:text;"`
LimitHightResp string `gorm:"column:limit_hight_resp;type:text;"`
OrderID uint `gorm:"column:order_id;not null"`
}
func (JusticeLawsuit) TableName() string {
return "justice_lawsuit"
}
type LawsuitInfo struct {
Msg string `json:"msg"`
Code string `json:"code"`
Data json.RawMessage `json:"data"`
}
type LawsuitInnerData struct {
PersonInfo *LawsuitInfo `json:"lawsuit_person_info,omitempty"`
CompanyInfo *LawsuitInfo `json:"lawsuit_company_info,omitempty"`
QueryID string `json:"query_id"`
}
type LawsuitData struct {
Data LawsuitInnerData `json:"data"`
ErrMsg string `json:"err_msg"`
ErrCode string `json:"err_code"`
}
type LawsuitResponse struct {
Data LawsuitData `json:"data"`
}

View File

@@ -0,0 +1,73 @@
package model
import (
"qnc-server/model/request"
)
type LoanEvaluation struct {
BaseModel
UserID uint `gorm:"column:userid;not null"`
CardNo string `gorm:"column:card_no;type:varchar(255);not null"` // 卡号
Name string `gorm:"column:name;type:varchar(255);not null"` // 姓名
Mobile string `gorm:"column:mobile;type:varchar(255);not null"` // 手机号
MobileMonthlyConsumptionLevelResp string `gorm:"column:mobile_monthly_consumption_level_resp;type:varchar(600)"` // MOB035 手机月消费档次
RecentSixMonthsSuspendedTimesResp string `gorm:"column:recent_six_months_suspended_times_resp;type:varchar(600)"` // MOB029 近六个月欠费停机次数查询
OverdueSelectionIndexResp string `gorm:"column:overdue_selection_index_resp;type:varchar(600)"` // RIS011 逾选指数
PaymentSelectionIndexResp string `gorm:"column:payment_selection_index_resp;type:varchar(600)"` // RIS012 付选指数
LoanSelectionIndexResp string `gorm:"column:loan_selection_index_resp;type:varchar(600)"` // RIS013 贷选指数
BorrowSelectionIndexResp string `gorm:"column:borrow_selection_index_resp;type:text"` // RIS015 借选指数
FinancialBlacklistResp string `gorm:"column:financial_blacklist_resp;type:varchar(600)"` // RIS029 金融黑名单
OrderID uint `gorm:"column:order_id;not null"`
}
func (LoanEvaluation) TableName() string {
return "loan_evaluation"
}
type LoanEvaluationReqPayload struct {
request.LoanEvaluationQueryReq
ProdID string
}
var LoanEvaluationProdIDs = []string{
"MOB035", // 手机月消费档次
"MOB029", // 近六个月欠费停机次数查询
"RIS011", // 逾选指数
"RIS012", // 付选指数
"RIS013", // 贷选指数
"RIS015", // 借选指数
"RIS029", // 金融黑名单
}
var LoanEvaluationFieldMapping = map[string]string{
"MOB035": "MobileMonthlyConsumptionLevelResp",
"MOB029": "RecentSixMonthsSuspendedTimesResp",
"RIS011": "OverdueSelectionIndexResp",
"RIS012": "PaymentSelectionIndexResp",
"RIS013": "LoanSelectionIndexResp",
"RIS015": "BorrowSelectionIndexResp",
"RIS029": "FinancialBlacklistResp",
}
var LoanEvaluationProdIDParams = map[string][]string{
"MOB035": {"mobile"},
"MOB029": {"mobile"},
"RIS011": {"mobile"},
"RIS012": {"mobile", "cardNo", "name"},
"RIS013": {"mobile", "cardNo", "name"},
"RIS015": {"mobile", "cardNo", "name"},
"RIS029": {"idCard", "name", "encryptionType", "phone"},
}
// 报告
type LoanEvaluationReport struct {
MobileMonthlyConsumptionLevel map[string]interface{} `json:"mobile_monthly_consumption_level"` // MOB035 手机月消费档次
RecentSixMonthsSuspendedTimes map[string]interface{} `json:"recent_six_months_suspended_times"` // MOB029 近六个月欠费停机次数查询
OverdueSelectionIndex map[string]interface{} `json:"overdue_selection_index"` // RIS011 逾选指数
PaymentSelectionIndex map[string]interface{} `json:"payment_selection_index"` // RIS012 付选指数
LoanSelectionIndex map[string]interface{} `json:"loan_selection_index"` // RIS013 贷选指数
BorrowSelectionIndex map[string]interface{} `json:"borrow_selection_index"` // RIS015 借选指数
FinancialBlacklist map[string]interface{} `json:"financial_blacklist"` // RIS029 金融黑名单
IDInfo IDInfo `json:"id_info"`
Name string `json:"name" `
Mobile string `json:"mobile"`
CardNo string `json:"card_no" `
}

49
model/model/pay.go Normal file
View File

@@ -0,0 +1,49 @@
package model
type PayOrder struct {
BaseModel
OutTradeNo string `gorm:"type:varchar(50);" json:"out_trade_no"` //商户单号
TransactionId string `gorm:"type:varchar(50);" json:"transaction_id"` //微信单号
AliTradeNo string `gorm:"type:varchar(50);" json:"ali_trade_no"`
Remarks string `gorm:"type:varchar(255)" json:"remarks"` // 备注
Amount int64 `gorm:"type:int" json:"amount"` //金额
Userid uint `gorm:"" json:"userid"`
PayStatus string `gorm:"type:varchar(20)" json:"pay_status"` // 支付状态
HasConsumed uint `gorm:"default:0" json:"has_consumed"` // 0未消费 1已消费
ProductID uint `gorm:"" json:"product_id"` // 外键关联Product
Product *Product `gorm:"foreignKey:ProductID"` // 关联的Product
Platform string `gorm:"type:varchar(20)" json:"platform"` //支付时的平套
PaymentMethod PaymentMethod `gorm:"type:varchar(20)" json:"payment_method"` // 支付平台
}
// 支付订单
func (PayOrder) TableName() string {
return "pay_order"
}
const (
PayStatusSuccess string = "SUCCESS" // 支付成功
PayStatusNotPay string = "NOTPAY" // 未支付
PayStatusPayError string = "PAYERROR" // 支付失败
PayStatusUnderRefund string = "UNDERREFUND" // 退款中
PayStatusRefund string = "REFUND" // 退款
PayStatusRefundError string = "REFUNDError" // 退款失败
PayStatusOther string = "OTHER" // 其他
)
type PaymentMethod string
const (
PaymentMethod_WECHAT PaymentMethod = "WECHAT"
PaymentMethod_ALIPAY PaymentMethod = "ALIPAY"
)
const (
NotConsumed uint = 0 // 支付成功
HasConsumed uint = 1 // 未支付
)
const (
PlatformMPWEIXIN = "mp-weixin"
PlatformMPH5 = "mp-h5"
PlatformH5 = "h5"
)

17
model/model/product.go Normal file
View File

@@ -0,0 +1,17 @@
package model
type Product struct {
BaseModel
ProductName string `gorm:"type:varchar(50)" json:"product_name"` // 服务名
ProductEn string `gorm:"type:varchar(50)" json:"product_en"` // 英文名
Description string `gorm:"type:varchar(255)" json:"description"` // 描述
Notes string `gorm:"type:text" json:"notes"`
CostPrice int `gorm:"type:int" json:"cost_price"` // 成本
SellPrice int `gorm:"type:int" json:"sell_price"` //售价
PayOrders []PayOrder `gorm:"foreignKey:ProductID"` // 与PayOrder的一对多关系
}
// 设置表名
func (Product) TableName() string {
return "product"
}

16
model/model/query.go Normal file
View File

@@ -0,0 +1,16 @@
package model
type Query struct {
ID uint `gorm:"primaryKey"`
OrderID uint `gorm:"not null"` // 外键关联到 Order 表
Order *PayOrder `gorm:"foreignKey:OrderID"` // 与 Order 表建立一对一的关系
ProductID uint `gorm:"not null"`
Product *Product `gorm:"foreignKey:ProductID"`
Code string `gorm:"type:varchar(255)"` // 存储手机号码
SignFile string `gorm:"type:varchar(255)"`
Userid uint `gorm:"not null"` // 外键关联到 User 表的 userid
}
func (Query) TableName() string {
return "query"
}

59
model/model/render.go Normal file
View File

@@ -0,0 +1,59 @@
package model
type Render struct {
BaseModel
Title string `json:"title" gorm:"column:title;type:varchar(255);not null"`
Description string `json:"description" gorm:"column:description;type:varchar(255)"`
Remark string `json:"remark" gorm:"column:remark;type:varchar(255)"`
Enable bool `json:"enable" gorm:"column:enable;type:tinyint(1);not null"`
}
func (Render) TableName() string {
return "render"
}
type CarRender struct {
BaseModel
Title string `json:"title" gorm:"column:title;type:varchar(255);not null"`
Feature string `json:"feature" gorm:"column:feature;type:varchar(255);not null"`
Enable bool `json:"enable" gorm:"column:enable;type:tinyint(1);not null"`
}
func (CarRender) TableName() string {
return "car_render"
}
type VerifyRender struct {
BaseModel
Title string `json:"title" gorm:"column:title;type:varchar(255);not null"`
Feature string `json:"feature" gorm:"column:feature;type:varchar(255);not null"`
Enable bool `json:"enable" gorm:"column:enable;type:tinyint(1);not null"`
}
func (VerifyRender) TableName() string {
return "verify_render"
}
type GlobalNotification struct {
BaseModel
Show bool `gorm:"column:show;default:true"`
Title string `gorm:"column:title;type:varchar(255)"`
Image string `gorm:"column:image;type:text"`
Content string `gorm:"column:content;type:text"`
Platform string `gorm:"column:platform;type:varchar(10)"`
System string `gorm:"column:system;type:varchar(10)"`
Url string `gorm:"column:url;type:varchar(4096)"`
}
func (GlobalNotification) TableName() string {
return "global_notification"
}
type RenderShadow struct {
ID uint `gorm:"primarykey" json:"ID"` // 主键ID
Show bool `gorm:"column:show;default:false"`
}
func (RenderShadow) TableName() string {
return "render_shadow"
}

View File

@@ -0,0 +1,40 @@
package model
import "qnc-server/model/request"
type EvaluateMarriage struct {
BaseModel
UserID uint `gorm:"column:userid;not null"`
CardNo string `gorm:"column:card_no;type:varchar(255)"` // 卡号
Name string `gorm:"column:name;type:varchar(255)"` // 姓名
Mobile string `gorm:"column:mobile;type:varchar(255)"` // 手机号
Resp string `gorm:"column:overdue_selection_index_resp;type:varchar(3000)"`
OrderID uint `gorm:"column:order_id;not null"`
}
func (EvaluateMarriage) TableName() string {
return "evaluate_marriage"
}
type EvaluateMarriagePayload struct {
request.EvaluateMarriageReq
ProdID string
}
var SingleQueryProdIDParams = map[string][]string{
"FIN013": {"bcNo"},
"FIN019": {"mobile", "cardNo", "name", "bcNo"},
"IDV041": {"cardNo", "name", "pageNo", "pageSize"},
}
var SingleQueryProdIDs = map[string]string{
"BankCardGamblingAndFraud": "FIN013",
"BankCardBlacklistV1": "FIN019",
"EvaluateMarriage": "IDV041",
}
type MerryResponse struct {
Msg string `json:"msg"`
Code int `json:"code"`
Data string `json:"data"`
Success bool `json:"success"`
}

79
model/model/user.go Normal file
View File

@@ -0,0 +1,79 @@
package model
import (
"gorm.io/gorm"
"qnc-server/config"
"time"
)
// 全能查用户 结构体 User
type User struct {
BaseModel
Userid uint `json:"userid" form:"userid" gorm:"column:userid;comment:" binding:"required"` //userid
Phone string `json:"phone" form:"phone" gorm:"column:phone;"`
Disable *bool `json:"disable" form:"disable" gorm:"default:false;column:disable;comment:;" binding:"required"` //禁用
Inside bool `json:"inside" form:"inside" gorm:"column:inside;type:tinyint(1);comment:;default:0"`
}
// TableName 全能查用户 User自定义表名 user
func (User) TableName() string {
return "user"
}
type AuthType string
const (
AUTHTYPE_WECHAT_H5 AuthType = "wechat_h5"
AUTHTYPE_WECHAT_MP AuthType = "wechat_mp"
AUTHTYPE_PHONE AuthType = "phone"
)
type AuthIdentifier struct {
OpenID string `json:"openid" `
UnionID string `json:"unionid"`
Phone string `json:"phone"`
}
type Authentication struct {
ID uint `gorm:"primaryKey"`
UserID uint `gorm:"not null"`
AuthType AuthType `gorm:"type:ENUM('wechat_h5', 'wechat_mp', 'phone');not null"`
OpenID string `json:"openid"`
UnionID string `json:"unionid"`
Phone string `json:"phone"`
AuthData string
CreatedAt time.Time
UpdatedAt time.Time
User User `gorm:"foreignKey:UserID"`
}
func (Authentication) TableName() string {
return "authentication"
}
// BeforeCreate GORM的钩子在创建记录之前触发
func (user *User) BeforeCreate(tx *gorm.DB) (err error) {
// 查询当前数据库中最大的userid
var maxUserID uint
var StartingUserID = config.ConfigData.System.StartingUserId
if err = tx.Model(&User{}).Select("COALESCE(MAX(userid), 0)").Row().Scan(&maxUserID); err != nil {
return
}
// 确定下一个可用的userid要确保大于StartingUserID
if maxUserID >= StartingUserID {
maxUserID++
user.Userid = maxUserID
} else {
user.Userid = StartingUserID
}
return
}
type WxLoginResponse struct {
OpenId string `json:"openid"`
SessionKey string `json:"session_key"`
ErrCode int `json:"errcode"`
ErrMsg string `json:"errmsg"`
}

47
model/model/verify.go Normal file
View File

@@ -0,0 +1,47 @@
package model
type VerifyPhoneName struct {
BaseModel
UserID uint `gorm:"column:userid;not null"`
Code string `gorm:"column:code;type:varchar(255);not null"`
Resp string `gorm:"column:resp;type:text;not null"`
OrderID uint `gorm:"column:order_id;not null"`
}
func (VerifyPhoneName) TableName() string {
return "verify_phone_name"
}
type VerifyCardName struct {
BaseModel
UserID uint `gorm:"column:userid;not null"`
Resp string `gorm:"column:resp;type:text;not null"`
OrderID uint `gorm:"column:order_id;not null"`
}
func (VerifyCardName) TableName() string {
return "verify_card_name"
}
type VerifyBankCard struct {
BaseModel
UserID uint `gorm:"column:userid;not null"`
Code string `gorm:"column:code;type:varchar(255);not null"`
Resp string `gorm:"column:resp;type:text;not null"`
OrderID uint `gorm:"column:order_id;not null"`
}
func (VerifyBankCard) TableName() string {
return "verify_bank_card"
}
type VerifySkillCert struct {
BaseModel
UserID uint `gorm:"column:userid;not null"`
Resp string `gorm:"column:resp;type:text;not null"`
OrderID uint `gorm:"column:order_id;not null"`
}
func (VerifySkillCert) TableName() string {
return "verify_skill_cert"
}

View File

@@ -0,0 +1,8 @@
package request
type AntiFraudQueryReq struct {
Name string `json:"name" binding:"required"`
Mobile string `json:"mobile" binding:"required"`
CardNo string `json:"card_no" binding:"required"`
VerifyCode string `json:"verify_code" binding:"required"`
}

30
model/request/car.go Normal file
View File

@@ -0,0 +1,30 @@
package request
type CarVinReq struct {
Vin string `json:"vin" form:"vin" binding:"required"`
}
type CarInsuranceReq struct {
Vin string `json:"vin" binding:"required"`
}
type CarMaintenanceReq struct {
Vin string `json:"vin" binding:"required"`
ImageBase64 string `json:"image_base64" binding:"required"` //行驶证base64
}
type CarCardNoReq struct {
CardNo string `json:"card_no" binding:"required"`
}
type GetQueryRecordReq struct {
ID uint `json:"id" form:"id"`
IsCase bool `json:"is_case" form:"is_case"`
Feature string `json:"feature" form:"feature" binding:"required"`
}
type CarNameTypeNumberReq struct {
Name string `json:"name" binding:"required"`
CarType string `json:"car_type" binding:"required"`
CarNumber string `json:"car_number" binding:"required"`
}
type VehicleValuationReq struct {
CarNumber string `json:"car_number" binding:"required"`
Vin string `json:"vin" binding:"required"`
}

16
model/request/ent.go Normal file
View File

@@ -0,0 +1,16 @@
package request
type EntReq struct {
Keyword string `form:"keyword" json:"keyword" binding:"required"`
}
type EntSearchReq struct {
Work string `form:"work" json:"work" binding:"required"`
PageNum int `form:"page_num" json:"page_num"`
PageSize int `form:"page_size" json:"page_size"`
}
type EntListReq struct {
Keyword string `form:"keyword" json:"keyword" binding:"required"`
PageNum int `form:"page_num" json:"page_num"`
PageSize int `form:"page_size" json:"page_size"`
}

11
model/request/feature.go Normal file
View File

@@ -0,0 +1,11 @@
package request
type FeatureOcrReq struct {
Base64 string `json:"base64" binding:"required"` // base64 字段必填
Name string `json:"name" binding:"required"` // name 字段必填
}
type FeatureVerifyElementsReq struct {
Name string `json:"name" binding:"required"`
CardNo string `json:"card_no" binding:"required"`
Mobile string `json:"mobile" binding:"required"`
}

View File

@@ -0,0 +1,22 @@
package request
import (
"qnc-server/model/types"
)
type LawsuitQueryReq struct {
Name string `json:"name" binding:"required"`
Mobile string `json:"mobile" binding:"required"`
CardNo string `json:"card_no" binding:"required"`
VerifyCode string `json:"verify_code" binding:"required"`
}
type LawsuitQueryV2Req struct {
Name string `json:"name" binding:"required"` // 姓名或企业名
CardNo string `json:"card_no" binding:"required"` // 身份证号或者企业统一信用代码
Type *types.LawsuitType `json:"type" binding:"required"`
Mobile string `json:"mobile" binding:"required"`
VerifyCode string `json:"verify_code" binding:"required"`
}
type GetLawsuitRecordReq struct {
ID string `json:"id" form:"id" binding:"required"`
}

View File

@@ -0,0 +1,8 @@
package request
type LoanEvaluationQueryReq struct {
Name string `json:"name" binding:"required"`
Mobile string `json:"mobile" binding:"required"`
CardNo string `json:"card_no" binding:"required"`
VerifyCode string `json:"verify_code" binding:"required"`
}

20
model/request/pay.go Normal file
View File

@@ -0,0 +1,20 @@
package request
type PrepayReq struct {
ProductName string `json:"product_name" binding:"required"`
Platform string `json:"platform" binding:"required"`
}
type RefundReq struct {
ProductName string `json:"product_name" binding:"required"`
Platform string `json:"platform" binding:"required"`
}
type H5PrepayReq struct {
QueryData string `json:"query_data" binding:"required"`
Href string `json:"href" binding:"required"`
ProductName string `json:"product_name" binding:"required"`
Platform string `json:"platform" binding:"required"`
}
type QueryDataReq struct {
OutTradeNo string `json:"out_trade_no" form:"out_trade_no" binding:"required"`
}

5
model/request/product.go Normal file
View File

@@ -0,0 +1,5 @@
package request
type GetProductNotesReq struct {
ProductName string `json:"product_name" form:"product_name" binding:"required"`
}

View File

@@ -0,0 +1,21 @@
package request
type BankCardGamblingAndFraudQueryReq struct {
BcNo string `json:"bc_no" binding:"required"`
}
type BankCardBlacklistV1QueryReq struct {
Name string `json:"name" binding:"required"`
Mobile string `json:"mobile" binding:"required"`
CardNo string `json:"card_no" binding:"required"`
BcNo string `json:"bc_no" binding:"required"`
}
type EvaluateMarriageReq struct {
Name string `json:"name" binding:"required"`
CardNo string `json:"card_no" binding:"required"`
Mobile string `json:"mobile" binding:"required"`
VerifyCode string `json:"verify_code" binding:"required"`
SignImage string `json:"sign_image"`
}
type GetMerriageRecordReq struct {
ID string `json:"id" form:"id" binding:"required"`
}

17
model/request/user.go Normal file
View File

@@ -0,0 +1,17 @@
package request
type UserLoginReq struct {
Code string `json:"code" binding:"required"`
}
type H5UserLoginReq struct {
Code string `json:"code" binding:"required"`
UserinfoAuth *bool `json:"userinfo_auth"` // 是否手动授权,否则为静默授权
}
type PhoneLoginReq struct {
PhoneNumber string `json:"phone_number" binding:"required"`
VerifyCode string `json:"verify_code" binding:"required"`
}
type VerifyCodeReq struct {
PhoneNumber string `json:"phone_number" binding:"required"`
Template string `json:"template"`
}

16
model/request/verify.go Normal file
View File

@@ -0,0 +1,16 @@
package request
type VerifyNamePhoneReq struct {
Name string `json:"name" binding:"required"`
Phone string `json:"phone" binding:"required"`
}
type VerifyNameCardReq struct {
Name string `json:"name" binding:"required"`
Card string `json:"card_no" binding:"required"`
}
type VerifyBankCardReq struct {
Name string `json:"name" binding:"required"`
Phone string `json:"phone" binding:"required"`
CardNo string `json:"card_no" binding:"required"`
CardID string `json:"card_id" binding:"required"`
}

38
model/response/common.go Normal file
View File

@@ -0,0 +1,38 @@
package response
type ThreeElementsResp struct {
Data ThreeElementsRespData `json:"data"` // 使用指针和omitempty处理可能缺失的字段
Resp ThreeElementsRespResp `json:"resp"`
}
type ThreeElementsRespData struct {
AreaCode string `json:"areacode"`
ISP string `json:"isp"`
ID string `json:"id"`
City string `json:"city"`
Mobile string `json:"Mobile"`
Name string `json:"Name"`
Postcode string `json:"postcode"`
}
type ThreeElementsRespResp struct {
Code string `json:"code"`
Desc string `json:"desc"`
}
// Data 结构体表示响应中的数据部分
type TwoElementsData struct {
Birthday string `json:"birthday"`
Result int `json:"result"`
Address string `json:"address"`
OrderNo string `json:"orderNo"`
Sex string `json:"sex"`
Desc string `json:"desc"`
}
// Response 结构体表示整个响应
type TwoElementsResp struct {
Msg string `json:"msg"`
Success bool `json:"success"`
Code int `json:"code"`
Data *TwoElementsData `json:"data"` // 使用指针类型,以便在失败响应时处理为 nil
}

24
model/response/ent.go Normal file
View File

@@ -0,0 +1,24 @@
package response
type EntResponse struct {
ErrorCode int `json:"error_code"`
Reason string `json:"reason"`
Result interface{} `json:"result"`
}
var EntRepsStatusCodeMap = map[int]string{
0: "请求成功",
300000: "经查无结果",
300001: "请求失败",
300002: "账号失效",
300003: "账号过期",
300004: "访问频率过快",
300005: "无权限访问此api",
300006: "余额不足",
300007: "剩余次数不足",
300008: "缺少必要参数",
300009: "账号信息有误",
300010: "URL不存在",
300011: "此IP无权限访问此api",
300012: "报告生成中",
}

17
model/response/feature.go Normal file
View File

@@ -0,0 +1,17 @@
package response
// 成功的 OCR 响应结构
type OcrSuccessResponse struct {
WordsResult []struct {
Words string `json:"words"`
} `json:"words_result"`
WordsResultNum int `json:"words_result_num"`
LogID int `json:"log_id"`
}
// 失败的 OCR 响应结构
type OcrErrorResponse struct {
LogID string `json:"log_id"`
ErrorMsg string `json:"error_msg"`
ErrorCode int `json:"error_code"`
}

View File

@@ -0,0 +1,78 @@
package response
import "qnc-server/model/model"
type CombinedResponse struct {
ListResp []CaseDetail `json:"listResp"`
SxrResp []SxrDetail `json:"sxrResp"`
LimitHightResp []LimitHightDetail `json:"limitHightResp"`
IDInfo model.IDInfo `json:"id_info"`
Name string `json:"name" `
Mobile string `json:"mobile"`
CardNo string `json:"card_no" `
}
type LawsuitQueryListResponse struct {
OrderNo string `json:"orderNo"`
Rc string `json:"rc"`
Msg string `json:"msg"`
Data interface{} `json:"data"`
}
type LawsuitQueryListData struct {
Count int `json:"count"`
List []CaseDetail `json:"list"`
}
type CaseDetail struct {
Content string `json:"content"`
ID string `json:"id"`
Title string `json:"title"`
CaseCode string `json:"caseCode"`
Court string `json:"court"`
StandPoint string `json:"standPoint"`
PublishDate string `json:"publishDate"`
}
type SxrDetail struct {
EntityName string `json:"entityName"`
EntityID string `json:"entityId"`
CaseCode string `json:"caseCode"`
Age string `json:"age"`
Sex string `json:"sex"`
BusinessEntity string `json:"bussinessEntity"` // 注意这里是原始 JSON 中的拼写错误,应为 "businessEntity"
CourtName string `json:"courtName"`
AreaName string `json:"areaName"`
PartyTypeName string `json:"partyTypeName"`
GistID string `json:"gistId"`
RegDate string `json:"regDate"`
GistUnit string `json:"gistUnit"`
Duty string `json:"duty"`
Performance string `json:"performance"`
PerformedPart string `json:"performedPart"`
UnperformPart string `json:"unPerformPart"` // 注意这里是原始 JSON 中的拼写错误,应为 "unperformPart"
DisruptTypeName string `json:"disruptTypeName"`
PublishDate string `json:"publishDate"`
RelateType string `json:"relateType"`
Status string `json:"status"`
}
type LawsuitLimitHightQueryListResponse struct {
Data interface{} `json:"data"`
Msg string `json:"msg"`
Success bool `json:"success"`
Code int `json:"code"`
TaskNo string `json:"taskNo"`
}
type LimitHightData struct {
CaseCount int `json:"caseCount"`
CaseList []LimitHightDetail `json:"caseList"`
}
type LimitHightDetail struct {
Datatype string `json:"datatype"`
IName string `json:"iname"`
SexName string `json:"sexname"`
Age string `json:"age"`
CaseCode string `json:"casecode"`
AreaName string `json:"areaname"`
CourtName string `json:"courtname"`
RegDate string `json:"regdate"`
PublishDate string `json:"publishdate"`
}

8
model/response/pay.go Normal file
View File

@@ -0,0 +1,8 @@
package response
import "github.com/wechatpay-apiv3/wechatpay-go/services/payments/jsapi"
type PrepayResponse struct {
Resp *jsapi.PrepayWithRequestPaymentResponse `json:"resp"`
Result string `json:"result"`
}

View File

@@ -0,0 +1,93 @@
package response
import (
"github.com/gin-gonic/gin"
"net/http"
)
type Response struct {
Code int `json:"code"`
Data interface{} `json:"data"`
Msg string `json:"msg"`
}
const (
SUCCESS = 0 //成功
EMPTY = 1 //为空
SIGN = 2
NOTIFY = 3 //通知
NeedAuth = 4 //需要登录
NeedManualAuth = 5 //需要手动授权登录
Wait = 6 //等待结果
ERROR = 7 //报错
NeedPay = 8 //需要支付
Refund = 9 //查询为空或错误,提示退款
)
func Result(code int, data interface{}, msg string, c *gin.Context) {
c.JSON(http.StatusOK, Response{
code,
data,
msg,
})
}
func Ok(c *gin.Context) {
Result(SUCCESS, map[string]interface{}{}, "操作成功", c)
}
func OkWithMessage(message string, c *gin.Context) {
Result(SUCCESS, map[string]interface{}{}, message, c)
}
func OkWithData(data interface{}, c *gin.Context) {
Result(SUCCESS, data, "查询成功", c)
}
func OkWithDetailed(data interface{}, message string, c *gin.Context) {
Result(SUCCESS, data, message, c)
}
func OkWithEmpty(c *gin.Context) {
Result(EMPTY, map[string]interface{}{}, "查询为空", c)
}
func Fail(c *gin.Context) {
Result(ERROR, map[string]interface{}{}, "操作失败", c)
}
func FailWithMessage(message string, c *gin.Context) {
Result(ERROR, map[string]interface{}{}, message, c)
}
func NoAuth(message string, c *gin.Context) {
c.JSON(http.StatusUnauthorized, Response{
NeedAuth,
nil,
message,
})
}
func ManualAuth(c *gin.Context) {
c.JSON(SUCCESS, Response{
NeedManualAuth,
nil,
"需要手动授权",
})
}
func FailWithDetailed(data interface{}, message string, c *gin.Context) {
Result(ERROR, data, message, c)
}
func OkNeedPay(c *gin.Context) {
Result(NeedPay, map[string]interface{}{}, "请支付", c)
}
func FailRefund(c *gin.Context) {
Result(Refund, map[string]interface{}{}, "无相关记录或系统错误", c)
}
func OkWait(c *gin.Context) {
Result(Wait, map[string]interface{}{}, "提交成功", c)
}
func FailNotify(c *gin.Context) {
Result(NOTIFY, map[string]interface{}{}, "通知", c)
}
func OkNeedSign(c *gin.Context) {
Result(SIGN, map[string]interface{}{}, "需要签名", c)
}

41
model/response/user.go Normal file
View File

@@ -0,0 +1,41 @@
package response
import "qnc-server/model/model"
type WxLoginResp struct {
OpenId string `json:"openid"`
SessionKey string `json:"session_key"`
Unionid string `json:"unionid"`
ErrCode int `json:"errcode"`
ErrMsg string `json:"errmsg"`
}
type WxH5LoginResp struct {
AccessToken string `json:"access_token"`
ExpiresIn int `json:"expires_in"`
RefreshToken string `json:"refresh_token"`
Openid string `json:"openid"`
Scope string `json:"scope"`
IsSnapshotuser int `json:"is_snapshotuser"`
Unionid string `json:"unionid"`
Errcode int `json:"errcode"`
Errmsg string `json:"errmsg"`
}
type WeChatUserInfoResp struct {
OpenID string `json:"openid"`
Nickname string `json:"nickname"`
Sex int `json:"sex"`
Province string `json:"province"`
City string `json:"city"`
Country string `json:"country"`
HeadImgURL string `json:"headimgurl"`
Privilege []string `json:"privilege"`
UnionID string `json:"unionid"`
Errcode int `json:"errcode"`
Errmsg string `json:"errmsg"`
}
type LoginResponse struct {
User model.User `json:"user"`
Token string `json:"token"`
//AuthIdentifier model.AuthIdentifier `json:"auth_identifier"`
ExpiresAt int64 `json:"expiresAt"`
}

28
model/response/verify.go Normal file
View File

@@ -0,0 +1,28 @@
package response
type VerifyPhoneRespData struct {
Result string `json:"result"`
ResultMsg string `json:"resultMsg"`
}
type VerifyPhoneResp struct {
Data VerifyPhoneRespData `json:"data"`
}
// 通用的响应结构体
type VerifyCardResp struct {
Msg string `json:"msg"`
Success bool `json:"success"`
Code int `json:"code"`
Data *VerifyCardRespData `json:"data"` // 使用 json.RawMessage 暂存 data 字段的数据
}
// 成功时的数据结构体
type VerifyCardRespData struct {
Birthday string `json:"birthday,omitempty"`
Result int `json:"result,omitempty"` // 1.不一致 0.一致
Address string `json:"address,omitempty"`
OrderNo string `json:"orderNo,omitempty"`
Sex string `json:"sex,omitempty"`
Desc string `json:"desc,omitempty"`
}

19
model/response/westdex.go Normal file
View File

@@ -0,0 +1,19 @@
package response
type WestdexResp struct {
Message string `json:"message"`
Code string `json:"code"`
Data string `json:"data"`
ID string `json:"id"`
ErrorCode *int `json:"error_code"`
Reason string `json:"reason"`
}
type Wrapper[T any] struct {
Data T `json:"data"`
}
type ThreeElementsResponse struct {
Code int `json:"code"`
Msg string `json:"msg"`
PhoneType string `json:"phoneType"`
}

8
model/types/types.go Normal file
View File

@@ -0,0 +1,8 @@
package types
type LawsuitType uint
const (
Individual LawsuitType = 0
Company LawsuitType = 1
)