Compare commits

..

No commits in common. "7009d57f6514ea4e8b0968d967f1cfad0ed7fd77" and "ec958a88b38e5cbb414a7dfbd3b30be19202d5c4" have entirely different histories.

10 changed files with 5114 additions and 2733 deletions

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,7 @@
syntax = "proto3";
package accountFiee;
import "api/accountFiee/validator.proto";
import "github.com/mwitkow/go-proto-validators@v0.3.2/validator.proto";
option go_package = "./;accountFiee";
//protoc -I . -I C:\Users\lenovo\go\src --go_out=. --go-triple_out=. ./accountFiee.proto
@ -179,9 +179,6 @@ message UserListInfo{
string language = 18;
string subscriberNumber = 19;
string nickName = 20;
string idNumber = 21;
string dateOfBirth = 22;
string age = 23;
}
message UserListRequest{
string domain = 1;
@ -233,8 +230,6 @@ message RealNameRequest{
string placeOfResidence = 8;
string groupPhoto = 9;
string attachment = 10;
string idNumber = 11;
string dateOfBirth = 12;
}
message RegisterResponse{
uint64 ID = 1;

View File

@ -5,11 +5,11 @@ package accountFiee
import (
fmt "fmt"
math "math"
proto "github.com/golang/protobuf/proto"
_ "github.com/mwitkow/go-proto-validators"
regexp "regexp"
github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators"
math "math"
regexp "regexp"
)
// Reference imports to suppress errors if they are not otherwise used.

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go-triple. DO NOT EDIT.
// versions:
// - protoc-gen-go-triple v1.0.5
// - protoc v6.32.0
// - protoc-gen-go-triple v1.0.8
// - protoc v5.26.1
// source: api/accountFiee/accountFiee.proto
package accountFiee

View File

@ -1,80 +0,0 @@
// Copyright 2016 Michal Witkowski. All Rights Reserved.
// See LICENSE for licensing terms.
// Protocol Buffers extensions for defining auto-generateable validators for messages.
// TODO(mwitkow): Add example.
syntax = "proto2";
package validator;
import "google/protobuf/descriptor.proto";
option go_package = "github.com/mwitkow/go-proto-validators;validator";
// TODO(mwitkow): Email protobuf-global-extension-registry@google.com to get an extension ID.
extend google.protobuf.FieldOptions {
optional FieldValidator field = 65020;
}
extend google.protobuf.OneofOptions {
optional OneofValidator oneof = 65021;
}
message FieldValidator {
// Uses a Golang RE2-syntax regex to match the field contents.
optional string regex = 1;
// Field value of integer strictly greater than this value.
optional int64 int_gt = 2;
// Field value of integer strictly smaller than this value.
optional int64 int_lt = 3;
// Used for nested message types, requires that the message type exists.
optional bool msg_exists = 4;
// Human error specifies a user-customizable error that is visible to the user.
optional string human_error = 5;
// Field value of double strictly greater than this value.
// Note that this value can only take on a valid floating point
// value. Use together with float_epsilon if you need something more specific.
optional double float_gt = 6;
// Field value of double strictly smaller than this value.
// Note that this value can only take on a valid floating point
// value. Use together with float_epsilon if you need something more specific.
optional double float_lt = 7;
// Field value of double describing the epsilon within which
// any comparison should be considered to be true. For example,
// when using float_gt = 0.35, using a float_epsilon of 0.05
// would mean that any value above 0.30 is acceptable. It can be
// thought of as a {float_value_condition} +- {float_epsilon}.
// If unset, no correction for floating point inaccuracies in
// comparisons will be attempted.
optional double float_epsilon = 8;
// Floating-point value compared to which the field content should be greater or equal.
optional double float_gte = 9;
// Floating-point value compared to which the field content should be smaller or equal.
optional double float_lte = 10;
// Used for string fields, requires the string to be not empty (i.e different from "").
optional bool string_not_empty = 11;
// Repeated field with at least this number of elements.
optional int64 repeated_count_min = 12;
// Repeated field with at most this number of elements.
optional int64 repeated_count_max = 13;
// Field value of length greater than this value.
optional int64 length_gt = 14;
// Field value of length smaller than this value.
optional int64 length_lt = 15;
// Field value of length strictly equal to this value.
optional int64 length_eq = 16;
// Requires that the value is in the enum.
optional bool is_in_enum = 17;
// Ensures that a string value is in UUID format.
// uuid_ver specifies the valid UUID versions. Valid values are: 0-5.
// If uuid_ver is 0 all UUID versions are accepted.
optional int32 uuid_ver = 18;
}
message OneofValidator {
// Require that one of the oneof fields is set.
optional bool required = 1;
}

2
go.mod
View File

@ -8,7 +8,6 @@ replace (
//github.com/fonchain_enterprise/utils/objstorage => ../../tyfon-/utils/objstorage
github.com/fonchain/utils/voice => ../utils/voice
github.com/fonchain_enterprise/utils/aes => ../utils/aes
github.com/fonchain_enterprise/utils/baidu => ../utils/baidu
github.com/fonchain_enterprise/utils/objstorage => ../utils/objstorage
)
@ -108,7 +107,6 @@ require (
github.com/duke-git/lancet/v2 v2.3.8
github.com/envoyproxy/protoc-gen-validate v0.1.0
github.com/fonchain/utils/voice v0.0.0-00010101000000-000000000000
github.com/fonchain_enterprise/utils/baidu v0.0.0-00010101000000-000000000000
github.com/fonchain_enterprise/utils/objstorage v0.0.0-00010101000000-000000000000
github.com/gin-contrib/pprof v1.4.0
github.com/go-redis/redis v6.15.9+incompatible

View File

@ -8,11 +8,3 @@ type MsgLangQuery struct {
Lang string `json:"lang" binding:"required"` //环境
Msg string `json:"msg" binding:"required"` //环境
}
type OcrRes struct {
RealName string `json:"realName"`
IDNum string `json:"iDNum"`
Path string `json:"path"`
Age int `json:"age"`
Birthday string `json:"birthday"`
Sex string `json:"sex"`
}

View File

@ -76,7 +76,6 @@ func NewRouter() *gin.Engine {
acRoute.POST("real-name", account.RealName) //实名
acRoute.POST("info", account.UserInfo) //用户详情
acRoute.POST("update", account.UserUpdate) //用户更新
acRoute.POST("ocr", account.CheckIdOcr) //
}
webAcRouter := privateGroup.Group("/user")
//webAcRouter.Use(middleware.CheckWebLogin(service.AccountProvider))
@ -84,7 +83,6 @@ func NewRouter() *gin.Engine {
{
webAcRouter.POST("list", account.UserList) //用户列表
webAcRouter.POST("approval", account.UserApproval) //实名审核
webAcRouter.POST("excel/download", account.UserExcelDownload) //excel下载
}
}
{

View File

@ -2,74 +2,16 @@ package account
import (
"context"
"encoding/base64"
"errors"
"fmt"
account "fonchain-fiee/api/accountFiee"
"fonchain-fiee/pkg/e"
"fonchain-fiee/pkg/model/login"
"fonchain-fiee/pkg/model/query"
"fonchain-fiee/pkg/model/union"
"fonchain-fiee/pkg/service"
"fonchain-fiee/pkg/service/bundle"
"fonchain-fiee/pkg/utils"
"io/ioutil"
"net/http"
"time"
"github.com/fonchain_enterprise/utils/baidu"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
)
func UserExcelDownload(c *gin.Context) {
var req account.UserListRequest
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
service.Error(c, err)
return
}
req.Domain = "app"
res, err := service.AccountFieeProvider.UserList(context.Background(), &req)
if err != nil {
service.Error(c, err)
return
}
titleList := []string{
"用户编号", "姓名", "性别", "国籍", "手机号", "证件类型", "有效期至", "证件号码", "出生日期", "年龄", "现所在地", "注册时间", "审核时间", "审核状态", "不通过备注",
}
var dataList []interface{}
for _, i := range res.UserList {
DocumentType := bundle.GetDocumentTypeText(i.DocumentType)
Status := bundle.GetUserStatusText(i.Status)
data := []any{
i.SubNum,
i.Name,
i.Sex,
i.Nationality,
i.TelNum,
DocumentType,
i.Validity,
i.IdNumber,
i.DateOfBirth,
i.Age,
i.PlaceOfResidence,
i.RegistrationTime,
i.AuditTime,
Status,
i.NotPassRemarks,
}
dataList = append(dataList, &data)
}
content, err := utils.ToExcelByType(titleList, dataList, "slice", "")
if err != nil {
service.Error(c, err)
return
}
utils.ResponseXls(c, content, "艺人管理")
return
}
func UserApproval(c *gin.Context) {
var req account.CheckRealNameRequest
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
@ -138,91 +80,6 @@ func UserUpdate(c *gin.Context) {
service.Success(c, res)
return
}
func CheckIdOcr(c *gin.Context) {
var req account.RealNameRequest
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
service.Error(c, err)
return
}
res, err := getFormIdCar(req.CertificatePicture)
if err != nil {
service.Error(c, err)
return
}
service.Success(c, res)
return
}
/**
* 获取身份证OCR识别结果
* @param realIDImgA string - 身份证图片的URL地址
* @return res query.OcrRes - OCR识别结果结构体包含身份证号姓名图片路径年龄生日性别等信息
* @return err error - 错误信息如果请求或处理过程中出现错误则返回错误
*/
func getFormIdCar(realIDImgA string) (res query.OcrRes, err error) {
// 发送HTTP GET请求获取图片
resObj, err := http.Get(realIDImgA)
if err != nil {
fmt.Println("网络请求错误:", err)
return
}
// 确保在函数返回前关闭响应体
defer resObj.Body.Close()
// 读取图片数据
imageData, err := ioutil.ReadAll(resObj.Body)
if err != nil {
fmt.Println("读取图片数据错误:", err)
return
}
// 将图片数据转换为base64编码
base64Data := base64.StdEncoding.EncodeToString(imageData)
fmt.Println(base64Data)
// 调用百度OCR接口识别身份证信息
result, err := baidu.OcrGetIdCard(base64Data, "front")
if err != nil {
return
}
// 构造并返回OCR识别结果
res = query.OcrRes{
IDNum: result.IdCard, // 身份证号
RealName: result.Name, // 姓名
Path: result.Path, // 图片路径
Age: result.Age, // 年龄
Birthday: dd(result.Birthday), // 生日
Sex: result.Sex, // 性别
}
return res, nil
}
// dd 实在没时间好好写代码
func dd(dateStr string) string {
// 1. 解析字符串为time.Time类型
// 注意Go的布局字符串必须使用参考时间"2006-01-02 15:04:05"的格式
t, err := time.Parse("20060102", dateStr)
if err != nil {
fmt.Printf("日期解析错误: %v\n", err)
return ""
}
// 2. 格式化为目标格式
formattedDate := t.Format("2006-01-02")
fmt.Println("原始日期:", dateStr)
fmt.Println("转换后日期:", formattedDate)
return formattedDate
}
// SendMsg 用户发送验证码
func SendMsg(c *gin.Context) {
@ -330,17 +187,6 @@ func RealName(c *gin.Context) {
}
user := login.GetUserInfoFromC(c)
req.Id = user.ID
if req.DocumentType == 2 {
if len(req.IdNumber) != 18 {
service.Error(c, errors.New("身份证号格式错误"))
return
}
} else {
if req.IdNumber == "" {
service.Error(c, errors.New("证件号码不能为空"))
return
}
}
res, err := service.AccountFieeProvider.RealName(context.Background(), &req)
if err != nil {
service.Error(c, err)

View File

@ -598,38 +598,6 @@ func GetCurrencyTypeText(currencyType int32) string {
return strconv.Itoa(int(currencyType))
}
}
func GetUserStatusText(status int32) string {
switch status {
case 1:
return "未实名"
case 2:
return "审核中"
case 3:
return "审核失败"
case 4:
return "审核通过"
default:
return strconv.Itoa(int(status))
}
}
func GetDocumentTypeText(documentType int32) string {
switch documentType {
case 1:
return "护照"
case 2:
return "身份证"
case 3:
return "驾驶证"
case 4:
return "居住证"
case 5:
return "自拍照"
case 6:
return "社保卡"
default:
return strconv.Itoa(int(documentType))
}
}
func OrderRecordsList(c *gin.Context) {
var req bundle.OrderRecordsRequest