批量优化
This commit is contained in:
1 parent
438145cae7
commit
c925b198d1
50 files changed
+5716
-291
No files matched your search
@@ -26,3 +26,20 @@ func GetTenantAdminRole() (uint64, error) {
|
||||
}
|
||||
return role.ID, nil
|
||||
}
|
||||
|
||||
// GetTenantUserRole 返回全局「租户用户」角色(cid=2, tenant_id=0)的 ID。
|
||||
// 自助注册通过企业编码加入企业时默认绑定此角色(受限权限)。
|
||||
func GetTenantUserRole() (uint64, error) {
|
||||
if Orm == nil {
|
||||
return 0, orm.ErrNoRows
|
||||
}
|
||||
var role AdminRole
|
||||
if err := Orm.QueryTable(new(AdminRole)).
|
||||
Filter("cid", 2).
|
||||
Filter("tenant_id", 0).
|
||||
Filter("name", "租户用户").
|
||||
One(&role); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return role.ID, nil
|
||||
}
|
||||
@@ -20,6 +20,7 @@ const (
|
||||
type AuthIdentity struct {
|
||||
ID uint64 `orm:"column(id);pk;auto" json:"id"`
|
||||
UnionID string `orm:"column(union_id);size(32)" json:"union_id"`
|
||||
Account *string `orm:"column(account);size(64);null" json:"account"` // 全局登录账号(账号注册;手机号注册身份为 NULL)
|
||||
Mobile *string `orm:"column(mobile);size(20);null" json:"mobile"`
|
||||
Email *string `orm:"column(email);size(128);null" json:"email"`
|
||||
PasswordAlgo string `orm:"column(password_algo);size(16);default(argon2id)" json:"password_algo"`
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
// 企业申请类型 / 状态
|
||||
const (
|
||||
TenantApplyTypeJoin = 1 // 加入企业(绑定企业,企业管理员审批)
|
||||
TenantApplyTypeCreate = 2 // 创建企业(平台审批)
|
||||
|
||||
TenantApplyStatusPending = 0 // 待审核
|
||||
TenantApplyStatusPassed = 1 // 已通过
|
||||
TenantApplyStatusReject = 2 // 已驳回
|
||||
)
|
||||
|
||||
// AuthTenantApply 注册企业绑定/创建申请:yz_auth_tenant_apply
|
||||
//
|
||||
// 统一认证注册第二步产生:
|
||||
// - type=join:绑定企业申请,由目标企业的管理员在 backend「加入申请」页审批,
|
||||
// 通过后建立身份-企业绑定(默认「租户用户」角色);
|
||||
// - type=create:创建企业申请(含营业执照),由平台在 platform「企业创建审核」页审批,
|
||||
// 通过后自动创建租户并把申请人绑定为租户管理员。
|
||||
type AuthTenantApply struct {
|
||||
ID uint64 `orm:"column(id);pk;auto" json:"id"`
|
||||
IdentityID uint64 `orm:"column(identity_id)" json:"identity_id"`
|
||||
Type int8 `orm:"column(type);default(1)" json:"type"`
|
||||
Tid uint64 `orm:"column(tid);default(0)" json:"tid"`
|
||||
TenantName string `orm:"column(tenant_name);size(128);default('')" json:"tenant_name"`
|
||||
CreditCode string `orm:"column(credit_code);size(64);default('')" json:"credit_code"`
|
||||
LegalPerson string `orm:"column(legal_person);size(64);default('')" json:"legal_person"`
|
||||
LicenseFile string `orm:"column(license_file);size(500);default('')" json:"license_file"`
|
||||
ContactPerson string `orm:"column(contact_person);size(64);default('')" json:"contact_person"`
|
||||
ContactPhone string `orm:"column(contact_phone);size(20);default('')" json:"contact_phone"`
|
||||
ContactEmail string `orm:"column(contact_email);size(128);default('')" json:"contact_email"`
|
||||
Address string `orm:"column(address);size(255);default('')" json:"address"`
|
||||
Status int8 `orm:"column(status);default(0)" json:"status"`
|
||||
RejectReason string `orm:"column(reject_reason);size(255);default('')" json:"reject_reason"`
|
||||
ReviewerID uint64 `orm:"column(reviewer_id);default(0)" json:"reviewer_id"`
|
||||
ReviewerName string `orm:"column(reviewer_name);size(64);default('')" json:"reviewer_name"`
|
||||
ReviewTime *time.Time `orm:"column(review_time);type(datetime);null" json:"review_time"`
|
||||
CreateTime time.Time `orm:"column(create_time);type(datetime);auto_now_add" json:"create_time"`
|
||||
UpdateTime *time.Time `orm:"column(update_time);type(datetime);null" json:"update_time"`
|
||||
DeleteTime *time.Time `orm:"column(delete_time);type(datetime);null" json:"delete_time"`
|
||||
}
|
||||
|
||||
func (m *AuthTenantApply) TableName() string {
|
||||
return "yz_auth_tenant_apply"
|
||||
}
|
||||
@@ -213,6 +213,8 @@ func Init(_ string) {
|
||||
|
||||
// 微信小程序配置(docs/sql/create_wechat_mini_config.sql)
|
||||
new(WechatMiniConfig),
|
||||
// 微信小程序多应用配置(docs/sql/create_wechat_mini_app.sql)
|
||||
new(WechatMiniApp),
|
||||
|
||||
// 统一认证中心(UAC):docs/sql/create_auth_tables.sql,人工执行建表
|
||||
new(AuthIdentity),
|
||||
@@ -225,6 +227,8 @@ func Init(_ string) {
|
||||
new(AuthTokenBlacklist),
|
||||
new(AuthTenantIdp),
|
||||
new(AuthTenantAuthConfig),
|
||||
// 注册企业绑定/创建申请(docs/sql/create_auth_tenant_apply.sql)
|
||||
new(AuthTenantApply),
|
||||
new(AuthLoginLog),
|
||||
new(AuthAppLoginTicket),
|
||||
|
||||
|
||||
@@ -22,3 +22,21 @@ type WechatMiniConfig struct {
|
||||
}
|
||||
|
||||
func (m *WechatMiniConfig) TableName() string { return "yz_platform_wechat_mini_config" }
|
||||
|
||||
// WechatMiniApp 微信小程序(多应用) yz_platform_wechat_mini_app
|
||||
// 支持配置多个小程序:认证端登录时按客户端传入的 appid 精确匹配
|
||||
// (未传 appid 时回退第一条启用记录),AppSecret 加密存储不回显。
|
||||
type WechatMiniApp struct {
|
||||
ID uint64 `orm:"column(id);pk;auto" json:"id"`
|
||||
Name string `orm:"column(name);size(128);default('')" json:"name"`
|
||||
AppID string `orm:"column(app_id);size(64)" json:"app_id"`
|
||||
AppSecret string `orm:"column(app_secret);size(512)" json:"-"` // 加密存储,不回显
|
||||
Enabled int8 `orm:"column(enabled);default(0)" json:"enabled"`
|
||||
AutoBind int8 `orm:"column(auto_bind);default(1)" json:"auto_bind"` // 1:手机号命中身份后自动绑定
|
||||
Remark string `orm:"column(remark);size(255)" json:"remark"`
|
||||
CreateTime time.Time `orm:"column(create_time);type(datetime);auto_now_add" json:"create_time"`
|
||||
UpdateTime *time.Time `orm:"column(update_time);type(datetime);null" json:"update_time"`
|
||||
DeleteTime *time.Time `orm:"column(delete_time);type(datetime);null" json:"delete_time"`
|
||||
}
|
||||
|
||||
func (m *WechatMiniApp) TableName() string { return "yz_platform_wechat_mini_app" }
|
||||
Reference in new issue
Block a user