2026-08-09 10:43:45 +08:00
|
|
|
|
// Models generated by mesh dev cli,@Author: David Yan(david.yan@qq.com).
|
|
|
|
|
|
package models
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"errors"
|
|
|
|
|
|
"time"
|
|
|
|
|
|
|
2026-08-09 12:41:08 +08:00
|
|
|
|
"bsm/full/module/base/passport/internal/impl"
|
2026-08-09 10:43:45 +08:00
|
|
|
|
"git.apinb.com/bsm-sdk/core/database"
|
|
|
|
|
|
"git.apinb.com/bsm-sdk/core/types"
|
|
|
|
|
|
"gorm.io/gorm"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* PassportExtend
|
|
|
|
|
|
* Comment: 通行证帐号扩展表
|
|
|
|
|
|
* Version: 10
|
|
|
|
|
|
* Created: 2022-04-12 10:50:54 , Updated:0001-01-01 00:00:00
|
|
|
|
|
|
*/
|
|
|
|
|
|
type PassportData struct {
|
|
|
|
|
|
types.Std_ID
|
|
|
|
|
|
types.Std_Passport
|
|
|
|
|
|
Nickname string `gorm:"column:nickname;type:varchar(64);default:'';" json:"nickname"` // 昵称
|
|
|
|
|
|
Avatar string `gorm:"column:avatar;type:varchar(255);default:'';" json:"avatar"` // 头像
|
|
|
|
|
|
Birthday time.Time `gorm:"column:birthday;" json:"birthday"` // 生日
|
|
|
|
|
|
Sex int8 `gorm:"column:sex;default:0;" json:"sex"` // 性别,1为女性,2为男性
|
|
|
|
|
|
Country string `gorm:"column:country;default:'';" json:"country"` // 国家
|
|
|
|
|
|
Province string `gorm:"column:province;default:'';" json:"province"` // 省
|
|
|
|
|
|
City string `gorm:"column:city;default:'';" json:"city"` // 市
|
|
|
|
|
|
Area string `gorm:"column:area;default:'';" json:"area"` // 区
|
|
|
|
|
|
Sign string `gorm:"column:sign;type:varchar(500);default:'';" json:"sign"` // 签名
|
|
|
|
|
|
Cover string `gorm:"column:cover;type:varchar(255);default:'';" json:"cover"` // 背景&封面
|
|
|
|
|
|
Score int32 `gorm:"column:score;default:0;" json:"score"` // 积分
|
|
|
|
|
|
Level int32 `gorm:"column:level;default:0;" json:"level"` // 等级
|
|
|
|
|
|
Rights string `gorm:"column:rights;type:varchar(255);default:'';" json:"rights"` // 权限
|
|
|
|
|
|
AgencyId uint `gorm:"column:agency_id;default:0;" json:"agency_id"` // 分销代理id
|
|
|
|
|
|
StaffId uint `gorm:"column:staff_id;default:0;" json:"staff_id"` // 工作人员id
|
|
|
|
|
|
OwnerId uint `gorm:"column:owner_id;default:0;" json:"owner_id"` // 所属唯一id
|
|
|
|
|
|
OwnerIdentity string `gorm:"column:owner_identity;type:varchar(64);default:'';" json:"owner_identity"` // 所属唯一码
|
|
|
|
|
|
EmailVerify int32 `gorm:"default:0"` // 邮件验证状态:0 未验证 1 验证中,2 验证成功,-1 验证失败
|
|
|
|
|
|
PhoneVerify int32 `gorm:"default:0"` // 手机验证状态:0 未验证 1 验证中,2 验证成功,-1 验证失败
|
|
|
|
|
|
FaceVerify int32 `gorm:"default:0"` // 人脸或照片验证状态:0 未验证 1 验证中,2 验证成功,-1 验证失败
|
|
|
|
|
|
DocumentVerify int32 `gorm:"default:0"` // 证件验证状态:0 未验证 1 验证中,2 验证成功,-1 验证失败
|
|
|
|
|
|
KycVerify int32 `gorm:"default:0"` // KYC验证状态:0 未验证 1 验证中,2 验证成功,-1 验证失败
|
|
|
|
|
|
|
|
|
|
|
|
UpdatedAt time.Time // 最后更新时间
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
|
database.AppendMigrate(&PassportData{})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TableName .
|
|
|
|
|
|
func (table *PassportData) TableName() string {
|
|
|
|
|
|
return "passport_data" //对应数据库表名
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func CheckPassportData(id uint, identity string) (*PassportData, error) {
|
|
|
|
|
|
var data PassportData
|
|
|
|
|
|
err := impl.DBService.Where("passport_id=? AND passport_identity=?", id, identity).First(&data).Error
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
|
|
|
data = PassportData{
|
|
|
|
|
|
Std_Passport: types.Std_Passport{
|
|
|
|
|
|
PassportID: id,
|
|
|
|
|
|
PassportIdentity: identity,
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
impl.DBService.Create(&data)
|
|
|
|
|
|
return &data, nil
|
|
|
|
|
|
}
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
}
|
|
|
|
|
|
return &data, nil
|
|
|
|
|
|
}
|