Refactor WeChat integration to support multiple mini programs, removing hardcoded WeChat credentials and updating user model and authentication flow accordingly.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type MiniProgram struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
|
||||
Name string `gorm:"size:100;not null" json:"name"`
|
||||
AppID string `gorm:"size:100;uniqueIndex" json:"app_id"`
|
||||
AppSecret string `gorm:"size:200;not null" json:"-"`
|
||||
Description string `gorm:"size:255" json:"description"`
|
||||
}
|
||||
|
||||
func (MiniProgram) TableName() string {
|
||||
return "mini_programs"
|
||||
}
|
||||
@@ -12,12 +12,14 @@ type User struct {
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
|
||||
OpenID string `gorm:"uniqueIndex;size:100" json:"open_id"`
|
||||
UnionID string `gorm:"size:100" json:"union_id,omitempty"`
|
||||
NickName string `gorm:"size:100" json:"nickname"`
|
||||
AvatarURL string `gorm:"size:500" json:"avatar_url"`
|
||||
Gender int `gorm:"default:0" json:"gender"`
|
||||
Phone string `gorm:"size:20" json:"phone,omitempty"`
|
||||
MiniProgramID uint `gorm:"index:idx_mini_open,priority:1" json:"mini_program_id"`
|
||||
MiniProgram MiniProgram `gorm:"foreignKey:MiniProgramID" json:"mini_program,omitempty"`
|
||||
OpenID string `gorm:"size:100;index:idx_mini_open,priority:2" json:"open_id"`
|
||||
UnionID string `gorm:"size:100" json:"union_id,omitempty"`
|
||||
NickName string `gorm:"size:100" json:"nickname"`
|
||||
AvatarURL string `gorm:"size:500" json:"avatar_url"`
|
||||
Gender int `gorm:"default:0" json:"gender"`
|
||||
Phone string `gorm:"size:20" json:"phone,omitempty"`
|
||||
|
||||
SessionKey string `gorm:"size:100" json:"-"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user