feat:完善信息
This commit is contained in:
@ -11,7 +11,7 @@ type ManageCompany struct {
|
||||
Code string `gorm:"column:code;type:varchar(30);default:null;comment:信用代码" json:"code"`
|
||||
Image
|
||||
Area
|
||||
Industry uint64 `gorm:"column:industry;type:int(11);default:0;comment:行业领域" json:"industry"`
|
||||
Industry string `gorm:"column:industry;type:varchar(255);default:0;comment:行业领域" json:"industry"`
|
||||
Keyword string `gorm:"column:keyword;type:varchar(255);default:null;comment:关键词" json:"keyword"`
|
||||
Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"`
|
||||
ExamineStatus
|
||||
|
@ -18,7 +18,7 @@ type ManageExpert struct {
|
||||
Job string `gorm:"column:job;type:varchar(50);default:null;comment:职务" json:"job"`
|
||||
Title string `gorm:"column:title;type:varchar(50);default:null;comment:职称" json:"title"`
|
||||
WorkAt time.Time `gorm:"column:work_at;type:date;not null;comment:从业时间" json:"work_at"`
|
||||
Industry uint64 `gorm:"column:industry;type:int(11);default:0;comment:行业领域" json:"industry"`
|
||||
Industry string `gorm:"column:industry;type:varchar(30);default:0;comment:行业领域" json:"industry"`
|
||||
Keyword string `gorm:"column:keyword;type:varchar(255);default:null;comment:关键词" json:"keyword"`
|
||||
Research string `gorm:"column:research;type:varchar(255);default:null;comment:研究信息" json:"research"`
|
||||
Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"`
|
||||
|
@ -15,7 +15,7 @@ type ManageLaboratory struct {
|
||||
Image
|
||||
Area
|
||||
Position string `gorm:"column:position;type:varchar(50);default:null;comment:坐标" json:"-"`
|
||||
Industry uint64 `gorm:"column:industry;type:int(11);default:0;comment:行业领域" json:"industry"`
|
||||
Industry string `gorm:"column:industry;type:varchar(30);default:0;comment:行业领域" json:"industry"`
|
||||
Keyword string `gorm:"column:keyword;type:varchar(255);default:null;comment:关键词" json:"keyword"`
|
||||
Research string `gorm:"column:research;type:varchar(255);default:null;comment:研究信息" json:"research"`
|
||||
Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"`
|
||||
|
@ -13,7 +13,7 @@ type ManageResearch struct {
|
||||
Image
|
||||
Area
|
||||
Position string `gorm:"column:position;type:varchar(50);default:null;comment:坐标" json:"-"`
|
||||
Industry uint64 `gorm:"column:industry;type:int(11);default:0;comment:行业领域" json:"industry"`
|
||||
Industry string `gorm:"column:industry;type:int(11);default:0;comment:行业领域" json:"industry"`
|
||||
Keyword string `gorm:"column:keyword;type:varchar(255);default:null;comment:关键词" json:"keyword"`
|
||||
Research string `gorm:"column:research;type:varchar(255);default:null;comment:研究信息" json:"research"`
|
||||
Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"`
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
|
||||
// IModel
|
||||
type IModel interface {
|
||||
SetID(uint64)
|
||||
GetID() uint64
|
||||
GetEncodeID() string
|
||||
TableName() string
|
||||
@ -64,6 +65,10 @@ const (
|
||||
SubDatabase string = "tenant"
|
||||
)
|
||||
|
||||
func (m *Model) SetID(id uint64) {
|
||||
m.ID = id
|
||||
}
|
||||
|
||||
func (m *Model) GetID() uint64 {
|
||||
return m.ID
|
||||
}
|
||||
|
@ -3,6 +3,9 @@ package model
|
||||
// SysIndustry 行业领域数据模型
|
||||
type SysIndustry struct {
|
||||
Model
|
||||
ParentID uint64 `gorm:"column:parent_id;type:int;default:0;comment:父级ID" json:"-"`
|
||||
Code string `gorm:"column:code;type:varchar(30);default:null;comment:编号" json:"code"`
|
||||
Name string `gorm:"column:name;type:varchar(30);default:null;comment:行业名称" json:"name"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
@ -3,6 +3,9 @@ package model
|
||||
// SysResearch 研究领域数据模型
|
||||
type SysResearch struct {
|
||||
Model
|
||||
ParentID uint64 `gorm:"column:parent_id;type:int;default:0;comment:父级ID" json:"-"`
|
||||
Code string `gorm:"column:code;type:varchar(30);default:null;comment:编号" json:"code"`
|
||||
Name string `gorm:"column:name;type:varchar(30);default:null;comment:角色名" json:"name"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/utils"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
@ -10,20 +11,48 @@ import (
|
||||
type UserManage struct {
|
||||
Model
|
||||
ModelTenant
|
||||
UID uint64 `gorm:"column:uid;index:idx_user_manage_uid;type:int;default:0;comment:用户表UUID" json:"-"`
|
||||
UUID uint64 `gorm:"column:uuid;uniqueIndex:idx_user_manage_uuid;type:int;default:0;comment:用户唯一UUID" json:"-"`
|
||||
Name string `gorm:"column:name;type:varchar(20);default:null;comment:真实姓名" json:"name"`
|
||||
Email string `gorm:"column:email;type:varchar(50);default:null;comment:邮箱" json:"email"`
|
||||
Job string `gorm:"column:job;type:varchar(50);default:null;comment:职务" json:"job"`
|
||||
Identity int `gorm:"column:identity;type:tinyint(3);default:0;comment:身份信息" json:"-"`
|
||||
FixedPhone string `gorm:"column:fixed_phone;type:varchar(20);default:null;comment:固定电话" json:"fixed_phone"`
|
||||
Address string `gorm:"column:address;type:varchar(255);default:null;comment:详细地址" json:"address"`
|
||||
Other string `gorm:"column:other;type:varchar(255);default:null;comment:其他信息" json:"-"`
|
||||
Selected UserManageSelected `gorm:"column:selected;type:tinyint(1);default:0;comment:最后一次选中的身份状态,用于下次登陆展示" json:"-"`
|
||||
UID uint64 `gorm:"column:uid;index:idx_user_manage_uid;type:int;default:0;comment:用户表UUID" json:"-"`
|
||||
UUID uint64 `gorm:"column:uuid;uniqueIndex:idx_user_manage_uuid;type:int;default:0;comment:用户唯一UUID" json:"-"`
|
||||
Name string `gorm:"column:name;type:varchar(20);default:null;comment:真实姓名" json:"name"`
|
||||
Email string `gorm:"column:email;type:varchar(50);default:null;comment:邮箱" json:"email"`
|
||||
Job string `gorm:"column:job;type:varchar(50);default:null;comment:职务" json:"job"`
|
||||
FixedPhone string `gorm:"column:fixed_phone;type:varchar(20);default:null;comment:固定电话" json:"fixed_phone"`
|
||||
Address string `gorm:"column:address;type:varchar(255);default:null;comment:详细地址" json:"address"`
|
||||
Identity int `gorm:"column:identity;type:tinyint(3);default:0;comment:身份" json:"-"`
|
||||
IdentityInfo string `gorm:"column:identity_info;type:varchar(255);default:null;comment:身份信息" json:"-"`
|
||||
IsSelected UserManageSelected `gorm:"column:is_selected;type:tinyint(1);default:0;comment:最后一次选中的身份状态,用于下次登陆展示" json:"-"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
type IUserIdentity interface {
|
||||
Analysis(src string) interface{}
|
||||
}
|
||||
|
||||
type (
|
||||
// UserIdentityForCompany 公司信息
|
||||
UserIdentityForCompany struct {
|
||||
Industry string `json:"industry"`
|
||||
Keyword string `json:"keyword"`
|
||||
}
|
||||
// UserIdentityForExpert 专家信息
|
||||
UserIdentityForExpert struct {
|
||||
Industry string `json:"industry"`
|
||||
Keyword string `json:"keyword"`
|
||||
Research string `json:"research"`
|
||||
}
|
||||
)
|
||||
|
||||
func (this *UserIdentityForCompany) Analysis(src string) interface{} {
|
||||
utils.FromJSON(src, this)
|
||||
return this
|
||||
}
|
||||
|
||||
func (this *UserIdentityForExpert) Analysis(src string) interface{} {
|
||||
utils.FromJSON(src, this)
|
||||
return this
|
||||
}
|
||||
|
||||
type UserManageSelected int
|
||||
|
||||
const (
|
||||
@ -44,8 +73,22 @@ func (m *UserManage) BeforeCreate(db *gorm.DB) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *UserManage) GetOtherAttribute() {
|
||||
func (m *UserManage) GetIdentityInfoAttribute() interface{} {
|
||||
var manage IUserIdentity
|
||||
|
||||
switch m.Identity {
|
||||
case config.TenantUserIdentityForCompany:
|
||||
manage = new(UserIdentityForCompany)
|
||||
break
|
||||
case config.TenantUserIdentityForExpert:
|
||||
manage = new(UserIdentityForExpert)
|
||||
break
|
||||
}
|
||||
return manage.Analysis(m.IdentityInfo)
|
||||
}
|
||||
|
||||
func (m *UserManage) SetIdentityInfoAttribute(src IUserIdentity) {
|
||||
m.IdentityInfo = utils.AnyToJSON(src)
|
||||
}
|
||||
|
||||
func NewUserManage() *UserManage {
|
||||
|
@ -1,24 +1,23 @@
|
||||
package platform
|
||||
|
||||
import "SciencesServer/utils"
|
||||
import (
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type Wechat struct{}
|
||||
type Wechat struct {
|
||||
AppID, AppSecret string
|
||||
}
|
||||
|
||||
type WechatScan struct{}
|
||||
|
||||
type WechatScanHandle func() *WechatScan
|
||||
type WechatHandle func(appID, appSecret string) *Wechat
|
||||
|
||||
type (
|
||||
WechatBasicRequest struct {
|
||||
AppID, Secret string
|
||||
}
|
||||
WechatErrorResponse struct {
|
||||
ErrCode int `json:"errcode"`
|
||||
ErrMsg int `json:"errmsg"`
|
||||
ErrCode int `json:"errcode"`
|
||||
ErrMsg string `json:"errmsg"`
|
||||
}
|
||||
// WechatAccessTokenRequest 请求AccessToken参数
|
||||
WechatAccessTokenRequest struct {
|
||||
WechatBasicRequest
|
||||
Code string
|
||||
}
|
||||
// WechatAccessTokenResponse 获取AccessToken响应参数
|
||||
@ -29,7 +28,7 @@ type (
|
||||
OpenID string `json:"openid"`
|
||||
Scope string `json:"scope"`
|
||||
UnionID string `json:"unionid"`
|
||||
*WechatErrorResponse
|
||||
WechatErrorResponse
|
||||
}
|
||||
)
|
||||
|
||||
@ -38,18 +37,18 @@ const (
|
||||
WechatAccessTokenUrl string = "https://api.weixin.qq.com/sns/oauth2/access_token"
|
||||
)
|
||||
|
||||
func (this *WechatScan) Login() {
|
||||
func (this *Wechat) ScanLogin() {
|
||||
|
||||
}
|
||||
|
||||
func (this *WechatScan) Pay() {
|
||||
func (this *Wechat) ScanPay() {
|
||||
|
||||
}
|
||||
|
||||
// AccessToken AccessToken操作
|
||||
func (this *Wechat) AccessToken(req *WechatAccessTokenRequest) (*WechatAccessTokenResponse, error) {
|
||||
params := map[string]interface{}{
|
||||
"appid": req.AppID, "secret": req.Secret, "code": req.Code, "grant_type": "authorization_code",
|
||||
"appid": this.AppID, "secret": this.AppSecret, "code": req.Code, "grant_type": "authorization_code",
|
||||
}
|
||||
resp, err := utils.NewClient(WechatAccessTokenUrl, utils.MethodForGet, params).Request(utils.RequestBodyFormatForXWWWFormUrlencoded)
|
||||
|
||||
@ -61,16 +60,14 @@ func (this *Wechat) AccessToken(req *WechatAccessTokenRequest) (*WechatAccessTok
|
||||
if err = utils.FromJSONBytes(resp, out); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if out.WechatErrorResponse.ErrCode != 0 {
|
||||
return nil, errors.New(out.WechatErrorResponse.ErrMsg)
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Scan 扫码操作
|
||||
func (this *Wechat) Scan() WechatScanHandle {
|
||||
return func() *WechatScan {
|
||||
return &WechatScan{}
|
||||
func NewWechat() WechatHandle {
|
||||
return func(appID, appSecret string) *Wechat {
|
||||
return &Wechat{AppID: appID, AppSecret: appSecret}
|
||||
}
|
||||
}
|
||||
|
||||
func NewWechat() *Wechat {
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user