feat:优化项目信息
This commit is contained in:
@ -24,7 +24,6 @@ type (
|
||||
Captcha string `json:"captcha" form:"captcha" binding:"required"`
|
||||
Password string `json:"password" form:"password" binding:"required"`
|
||||
RepeatPass string `json:"repeat_pass" form:"repeat_pass" binding:"required"`
|
||||
Identity int `json:"identity" form:"identity" binding:"required"`
|
||||
}
|
||||
)
|
||||
|
||||
@ -57,7 +56,7 @@ func (a *Account) Register(c *gin.Context) {
|
||||
}
|
||||
data, err := account.NewRegister()(api.GetLocal()(c).(string)).Launch(&account.RegisterParams{
|
||||
Name: form.Name, Mobile: form.Mobile, Captcha: form.Captcha,
|
||||
Password: form.Password, RepeatPass: form.RepeatPass, Identity: form.Identity,
|
||||
Password: form.Password, RepeatPass: form.RepeatPass,
|
||||
})
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
@ -37,11 +37,6 @@ func (*User) Info(c *gin.Context) {
|
||||
api.APISuccess(data)
|
||||
}
|
||||
|
||||
func (*User) Detail(c *gin.Context) {
|
||||
data, err := user.NewInstance()(api.GetSession()(c).(*session.Enterprise)).Detail()
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*User) BindMobile(c *gin.Context) {
|
||||
form := &struct {
|
||||
Mobile string `json:"mobile" form:"mobile" binding:"required"`
|
||||
@ -118,7 +113,32 @@ func (*User) SettledLaboratory(c *gin.Context) {
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*User) SwitchIdentity(c *gin.Context) {
|
||||
func (*User) SettledAgent(c *gin.Context) {
|
||||
form := &struct {
|
||||
userSettledForm
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := user.NewSettled()(api.GetSession()(c).(*session.Enterprise)).Agent(&user.SettledParams{
|
||||
ID: form.Convert(), Image: form.FilterImageURL(), Name: form.Name, Code: form.Code,
|
||||
Area: form.Area, Introduce: form.Introduce, Industry: form.Industry, Keywords: form.Keywords,
|
||||
})
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*User) IdentityBasic(c *gin.Context) {
|
||||
data, err := user.NewIdentity()(api.GetSession()(c).(*session.Enterprise)).Basic()
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*User) IdentityDetail(c *gin.Context) {
|
||||
data, err := user.NewIdentity()(api.GetSession()(c).(*session.Enterprise)).Detail()
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*User) IdentitySwitch(c *gin.Context) {
|
||||
form := &struct {
|
||||
Identity int `json:"identity" form:"identity" binding:"required"`
|
||||
}{}
|
||||
@ -126,7 +146,7 @@ func (*User) SwitchIdentity(c *gin.Context) {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := user.NewInstance()(api.GetSession()(c).(*session.Enterprise)).SwitchIdentity(form.Identity)
|
||||
err := user.NewIdentity()(api.GetSession()(c).(*session.Enterprise)).Switch(form.Identity)
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ type InstanceLoginCallback func(params *InstanceLoginParams) *InstanceLoginRetur
|
||||
|
||||
type (
|
||||
InstanceLoginParams struct {
|
||||
UID, TenantID, ManageUID uint64
|
||||
UID uint64
|
||||
Name, Mobile string
|
||||
Identity, SelectIdentity int
|
||||
Status model.AccountStatusKind
|
||||
@ -34,8 +34,6 @@ func (c *Instance) Login() InstanceLoginCallback {
|
||||
session := service.NewSessionEnterprise()
|
||||
session.Token = token
|
||||
session.UID = params.UID
|
||||
session.TenantID = params.TenantID
|
||||
session.ManageUID = params.ManageUID
|
||||
session.Name = params.Name
|
||||
session.Mobile = params.Mobile
|
||||
session.Identity = params.Identity
|
||||
|
@ -63,11 +63,11 @@ func loginForSmsCaptcha(params *LoginParams, local string) (*InstanceLoginParams
|
||||
model2.NewWhere("mobile", params.Captcha.Mobile), model2.NewWhere("local", local)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mUserManage := model3.NewUserManage()
|
||||
mUserIdentity := model3.NewUserIdentity()
|
||||
|
||||
if isExist {
|
||||
// 查询该区域下最后一次选中的信息
|
||||
if err = mUserManage.LastChooseInfo(mUserInstance.UUID); err != nil {
|
||||
if err = mUserIdentity.LastChooseInfo(mUserInstance.UUID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
goto RETURNS
|
||||
@ -79,9 +79,9 @@ func loginForSmsCaptcha(params *LoginParams, local string) (*InstanceLoginParams
|
||||
}
|
||||
RETURNS:
|
||||
return &InstanceLoginParams{
|
||||
UID: mUserInstance.UUID, ManageUID: mUserManage.UUID,
|
||||
UID: mUserInstance.UUID,
|
||||
Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
|
||||
Identity: mUserInstance.Identity, SelectIdentity: mUserManage.Identity,
|
||||
Identity: mUserInstance.Identity, SelectIdentity: mUserIdentity.Identity,
|
||||
Status: mUserInstance.Status,
|
||||
}, nil
|
||||
}
|
||||
@ -105,15 +105,16 @@ func loginForPassword(params *LoginParams, local string) (*InstanceLoginParams,
|
||||
return nil, errors.New("账户或密码错误")
|
||||
}
|
||||
// 最后一次选中的身份信息
|
||||
mUserManage := model3.NewUserManage()
|
||||
mUserIdentity := model3.NewUserIdentity()
|
||||
|
||||
if err = mUserManage.LastChooseInfo(mUserInstance.UUID); err != nil {
|
||||
if err = mUserIdentity.LastChooseInfo(mUserInstance.UUID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &InstanceLoginParams{
|
||||
UID: mUserInstance.UUID, ManageUID: mUserManage.UUID,
|
||||
UID: mUserInstance.UUID,
|
||||
Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
|
||||
Identity: mUserInstance.Identity, SelectIdentity: mUserManage.Identity,
|
||||
Identity: mUserInstance.Identity, SelectIdentity: mUserIdentity.Identity,
|
||||
Status: mUserInstance.Status,
|
||||
}, nil
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ type RegisterHandle func(local string) *Register
|
||||
type (
|
||||
RegisterParams struct {
|
||||
Name, Mobile, Captcha, Password, RepeatPass string
|
||||
Identity int
|
||||
}
|
||||
)
|
||||
|
||||
@ -66,25 +65,18 @@ func (c *Register) Launch(params *RegisterParams) (*InstanceLoginReturn, error)
|
||||
mUserInstance.Password = utils.GetRandomString(12)
|
||||
mUserInstance.Mobile = params.Mobile
|
||||
mUserInstance.Password = params.Password
|
||||
mUserInstance.Identity = params.Identity
|
||||
|
||||
mUserManage := model3.NewUserManage()
|
||||
|
||||
if err = orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
if err = model2.Create(mUserInstance.UserInstance, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
mUserManage.UID = mUserInstance.UUID
|
||||
mUserManage.Name = params.Name
|
||||
mUserManage.Identity = params.Identity
|
||||
mUserManage.IsSelected = model2.UserManageSelectedForYes
|
||||
return model2.Create(mUserManage.UserManage, tx)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return NewInstance()().Login()(&InstanceLoginParams{
|
||||
UID: mUserManage.UUID, Name: mUserManage.Name, Mobile: mUserInstance.Mobile,
|
||||
Identity: mUserInstance.Identity, SelectIdentity: params.Identity,
|
||||
UID: mUserInstance.UUID, Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
|
||||
Identity: mUserInstance.Identity,
|
||||
}), err
|
||||
}
|
||||
|
||||
|
@ -3,10 +3,8 @@ package identity
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/api/manage/controller"
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Instance struct {
|
||||
@ -19,15 +17,14 @@ type InstanceHandle func(session *session.Enterprise, local string) *Instance
|
||||
type (
|
||||
// InstanceForExpert 专家信息
|
||||
InstanceForExpert struct {
|
||||
*model.UserManageForExpert
|
||||
ID string `json:"id"`
|
||||
Industry string `json:"industry"`
|
||||
ID string `json:"id"`
|
||||
*model.UserIdentityForExpert
|
||||
}
|
||||
)
|
||||
|
||||
// Expert 专家列表
|
||||
func (c *Instance) Expert(name, mobile string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mUserManage := model.NewUserManage()
|
||||
mUserIdentity := model.NewUserIdentity()
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
@ -39,7 +36,7 @@ func (c *Instance) Expert(name, mobile string, page, pageSize int) (*controller.
|
||||
}
|
||||
var count int64
|
||||
|
||||
out, err := mUserManage.Expert(page, pageSize, &count, where...)
|
||||
out, err := mUserIdentity.Expert(page, pageSize, &count, where...)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -48,16 +45,10 @@ func (c *Instance) Expert(name, mobile string, page, pageSize int) (*controller.
|
||||
list := make([]*InstanceForExpert, 0)
|
||||
|
||||
for _, v := range out {
|
||||
mUserManage.ID = v.ID
|
||||
mUserManage.IdentityInfo = v.IdentityInfo
|
||||
obj := mUserManage.GetIdentityInfoAttribute().(*model2.UserIdentityForExpert)
|
||||
industry := make([]string, 0)
|
||||
mUserIdentity.ID = v.ID
|
||||
|
||||
for _, v := range strings.Split(obj.Industry, ";") {
|
||||
industry = append(industry, config.GetIndustryInfo(v, "-"))
|
||||
}
|
||||
list = append(list, &InstanceForExpert{
|
||||
UserManageForExpert: v, ID: mUserManage.GetEncodeID(), Industry: strings.Join(industry, ";"),
|
||||
ID: mUserIdentity.GetEncodeID(), UserIdentityForExpert: v,
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
|
@ -19,7 +19,7 @@ type (
|
||||
// BankInfo 银行卡信息
|
||||
BankInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model2.UserManageBank
|
||||
*model2.UserBank
|
||||
}
|
||||
// BankParams 银行卡参数信息
|
||||
BankParams struct {
|
||||
@ -39,21 +39,21 @@ func (c *BankParams) checkBankCard() bool {
|
||||
|
||||
// List 列表信息
|
||||
func (c *Bank) List() ([]*BankInfo, error) {
|
||||
mUserManageBank := model.NewUserManageBank()
|
||||
mUserManageBank := model.NewUserBank()
|
||||
|
||||
out := make([]*model2.UserManageBank, 0)
|
||||
out := make([]*model2.UserBank, 0)
|
||||
|
||||
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("uid", c.UID),
|
||||
Order: model2.NewOrder("is_default", model2.OrderModeToDesc),
|
||||
}}
|
||||
if err := model2.Find(mUserManageBank.UserManageBank, &out, where...); err != nil {
|
||||
if err := model2.Find(mUserManageBank.UserBank, &out, where...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*BankInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &BankInfo{ID: v.GetEncodeID(), UserManageBank: v})
|
||||
list = append(list, &BankInfo{ID: v.GetEncodeID(), UserBank: v})
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
@ -75,11 +75,11 @@ func (c *Bank) Bind(params *BankParams, captcha string) error {
|
||||
if !params.checkBankCard() {
|
||||
return errors.New("银行卡信息错误")
|
||||
}
|
||||
mUserManageBank := model.NewUserManageBank()
|
||||
mUserManageBank := model.NewUserBank()
|
||||
|
||||
var count int64
|
||||
|
||||
if err = model2.Count(mUserManageBank.UserManageBank, &count, model2.NewWhere("bank_card", params.BankCard)); err != nil {
|
||||
if err = model2.Count(mUserManageBank.UserBank, &count, model2.NewWhere("bank_card", params.BankCard)); err != nil {
|
||||
return err
|
||||
} else if count > 0 {
|
||||
return errors.New("当前银行卡已被注册")
|
||||
@ -90,20 +90,20 @@ func (c *Bank) Bind(params *BankParams, captcha string) error {
|
||||
mUserManageBank.BankCard = params.BankCard
|
||||
mUserManageBank.BankName = params.BankName
|
||||
|
||||
if err = model2.Count(mUserManageBank.UserManageBank, &count, model2.NewWhere("uid", c.UID)); err != nil {
|
||||
if err = model2.Count(mUserManageBank.UserBank, &count, model2.NewWhere("uid", c.UID)); err != nil {
|
||||
return err
|
||||
} else if count <= 0 {
|
||||
mUserManageBank.IsDefault = model2.UserManageBankDefaultForYes
|
||||
mUserManageBank.IsDefault = model2.UserBankDefaultForYes
|
||||
}
|
||||
return model2.Create(mUserManageBank.UserManageBank)
|
||||
return model2.Create(mUserManageBank.UserBank)
|
||||
}
|
||||
|
||||
// Unbind 解绑,直接删除
|
||||
func (c *Bank) Unbind(id uint64) error {
|
||||
mUserManageBank := model.NewUserManageBank()
|
||||
mUserManageBank := model.NewUserBank()
|
||||
mUserManageBank.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mUserManageBank.UserManageBank, []string{"id", "uid"})
|
||||
isExist, err := model2.FirstField(mUserManageBank.UserBank, []string{"id", "uid"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
|
93
app/api/enterprise/controller/user/identity.go
Normal file
93
app/api/enterprise/controller/user/identity.go
Normal file
@ -0,0 +1,93 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
config2 "SciencesServer/config"
|
||||
"SciencesServer/serve/orm"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Identity struct{ *session.Enterprise }
|
||||
|
||||
type IdentityHandle func(session *session.Enterprise) *Identity
|
||||
|
||||
// Basic 详细信息
|
||||
func (c *Identity) Basic() (*InstanceDetailInfo, error) {
|
||||
resp := &InstanceDetailInfo{InstanceInfo: InstanceInfo{Name: c.Name, Identity: c.Identity, SelectIdentity: c.SelectIdentity}}
|
||||
|
||||
mUserIdentity := model.NewUserIdentity()
|
||||
|
||||
isExist, err := model2.FirstField(mUserIdentity.UserIdentity, []string{"id", "tenant_id", "uuid", "name",
|
||||
"email", "job", "fixed_phone"},
|
||||
model2.NewWhere("uid", c.UID), model2.NewWhere("identity", c.SelectIdentity))
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !!isExist {
|
||||
return nil, errors.New("操作错误,用户身份信息不存在或已被删除")
|
||||
}
|
||||
resp.Name = mUserIdentity.Name
|
||||
resp.Email = mUserIdentity.Email
|
||||
resp.Job = mUserIdentity.Job
|
||||
resp.FixedPhone = mUserIdentity.FixedPhone
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
func (c *Identity) Detail() (*InstanceDetailInfo, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Switch 切换身份
|
||||
func (c *Identity) Switch(identity int) error {
|
||||
if _, has := config.TenantUserIdentityData[identity]; !has {
|
||||
return errors.New("未知的身份信息")
|
||||
}
|
||||
if c.SelectIdentity == identity {
|
||||
return nil
|
||||
}
|
||||
c.ManageUID = 0
|
||||
// 已存在相应的身份,更新最后
|
||||
if c.Identity&identity > 0 {
|
||||
mUserIdentity := model.NewUserIdentity()
|
||||
// 查询用户身份
|
||||
isExist, err := model2.FirstField(mUserIdentity.UserIdentity, []string{"id", "tenant_id", "name", "uuid"},
|
||||
model2.NewWhere("uid", c.UID), model2.NewWhere("identity", identity))
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
now := time.Now()
|
||||
|
||||
if err = orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
if err = model2.UpdatesWhere(mUserIdentity.UserIdentity, map[string]interface{}{
|
||||
"is_selected": model2.UserIdentitySelectedForNo, "updated_at": now,
|
||||
}, []*model2.ModelWhere{model2.NewWhere("uid", c.ManageUID)}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
return model2.Updates(mUserIdentity.UserIdentity, map[string]interface{}{
|
||||
"is_selected": model2.UserIdentitySelectedForYes, "updated_at": now,
|
||||
}, tx)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
c.ManageUID = mUserIdentity.UUID
|
||||
c.SelectIdentity = identity
|
||||
service.Publish(config2.EventForAccountLoginProduce, config2.RedisKeyForAccount, c.UIDToString(), c.Enterprise)
|
||||
return nil
|
||||
}
|
||||
return errors.New("操作错误,无效的身份信息")
|
||||
}
|
||||
|
||||
func NewIdentity() IdentityHandle {
|
||||
return func(session *session.Enterprise) *Identity {
|
||||
return &Identity{Enterprise: session}
|
||||
}
|
||||
}
|
@ -2,16 +2,11 @@ package user
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/handle"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
config2 "SciencesServer/config"
|
||||
"SciencesServer/serve/orm"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -40,27 +35,6 @@ func (c *Instance) Info() *InstanceInfo {
|
||||
return &InstanceInfo{Name: c.Name, Identity: c.Identity, SelectIdentity: c.SelectIdentity}
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
func (c *Instance) Detail() (*InstanceDetailInfo, error) {
|
||||
resp := &InstanceDetailInfo{InstanceInfo: InstanceInfo{Name: c.Name, Identity: c.Identity, SelectIdentity: c.SelectIdentity}}
|
||||
|
||||
mUserManage := model.NewUserManage()
|
||||
|
||||
isExist, err := model2.FirstField(mUserManage.UserManage, []string{"id", "tenant_id", "uuid", "name",
|
||||
"email", "job", "fixed_phone", "other"},
|
||||
model2.NewWhere("uid", c.UID), model2.NewWhere("identity", c.SelectIdentity))
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if isExist {
|
||||
resp.Name = mUserManage.Name
|
||||
resp.Email = mUserManage.Email
|
||||
resp.Job = mUserManage.Job
|
||||
resp.FixedPhone = mUserManage.FixedPhone
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// BindMobile 绑定手机号码
|
||||
func (c *Instance) BindMobile(mobile, captcha string) error {
|
||||
if !utils.ValidateMobile(mobile) {
|
||||
@ -91,48 +65,6 @@ func (c *Instance) BindMobile(mobile, captcha string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// SwitchIdentity 切换身份
|
||||
func (c *Instance) SwitchIdentity(identity int) error {
|
||||
if _, has := config.TenantUserIdentityData[identity]; !has {
|
||||
return errors.New("未知的身份信息")
|
||||
}
|
||||
if c.SelectIdentity == identity {
|
||||
return nil
|
||||
}
|
||||
c.ManageUID = 0
|
||||
// 已存在相应的身份,更新最后
|
||||
if c.Identity&identity > 0 {
|
||||
mUserManage := model.NewUserManage()
|
||||
// 查询用户身份
|
||||
isExist, err := model2.FirstField(mUserManage.UserManage, []string{"id", "tenant_id", "name", "uuid"},
|
||||
model2.NewWhere("uid", c.UID), model2.NewWhere("identity", identity))
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
now := time.Now()
|
||||
|
||||
if err = orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
if err = model2.UpdatesWhere(mUserManage.UserManage, map[string]interface{}{
|
||||
"is_selected": model2.UserManageSelectedForNo, "updated_at": now,
|
||||
}, []*model2.ModelWhere{model2.NewWhere("uid", c.ManageUID)}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
return model2.Updates(mUserManage.UserManage, map[string]interface{}{
|
||||
"is_selected": model2.UserManageSelectedForYes, "updated_at": now,
|
||||
}, tx)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
c.ManageUID = mUserManage.UUID
|
||||
c.SelectIdentity = identity
|
||||
service.Publish(config2.EventForAccountLoginProduce, config2.RedisKeyForAccount, c.UIDToString(), c.Enterprise)
|
||||
return nil
|
||||
}
|
||||
return errors.New("操作错误,无效的身份信息")
|
||||
}
|
||||
|
||||
func NewInstance() InstanceHandle {
|
||||
return func(session *session.Enterprise) *Instance {
|
||||
return &Instance{Enterprise: session}
|
||||
|
@ -178,8 +178,8 @@ func (c *Settled) Laboratory(params *SettledParams, other *config.IdentityForLab
|
||||
}
|
||||
|
||||
// Agent 经纪人
|
||||
func (c *Settled) Agent() {
|
||||
|
||||
func (c *Settled) Agent(params *SettledParams) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewSettled() SettledHandle {
|
||||
|
@ -1,11 +0,0 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type ManageEnterprise struct {
|
||||
*model.ManageEnterprise
|
||||
}
|
||||
|
||||
func NewManageEnterprise() *ManageEnterprise {
|
||||
return &ManageEnterprise{model.NewManageEnterprise()}
|
||||
}
|
11
app/api/enterprise/model/user_bank.go
Normal file
11
app/api/enterprise/model/user_bank.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type UserBank struct {
|
||||
*model.UserBank
|
||||
}
|
||||
|
||||
func NewUserBank() *UserBank {
|
||||
return &UserBank{model.NewUserBank()}
|
||||
}
|
59
app/api/enterprise/model/user_identity.go
Normal file
59
app/api/enterprise/model/user_identity.go
Normal file
@ -0,0 +1,59 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type UserIdentity struct {
|
||||
*model.UserIdentity
|
||||
}
|
||||
|
||||
type (
|
||||
// UserIdentityForExpert 专家信息
|
||||
UserIdentityForExpert struct {
|
||||
ID uint64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Mobile string `json:"mobile"`
|
||||
Identity string `json:"-"`
|
||||
}
|
||||
)
|
||||
|
||||
// Expert 专家数据
|
||||
func (m *UserIdentity) Expert(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*UserIdentityForExpert, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS i").
|
||||
Select(strings.Join([]string{"i.id", "i.name", "u.mobile"}, ",")).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u ON m.uid = u.uuid", model.NewUserInstance().TableName())).
|
||||
Where("m.is_deleted = ?", model.DeleteStatusForNot).
|
||||
Where("m.identity = ?", config.TenantUserIdentityForExpert)
|
||||
|
||||
out := make([]*UserIdentityForExpert, 0)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, v := range where {
|
||||
db = db.Where(v.Condition, v.Value)
|
||||
}
|
||||
}
|
||||
if err := db.Count(count).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := db.Order("i.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// LastChooseInfo 最后一次选中的信息
|
||||
func (m *UserIdentity) LastChooseInfo(uid uint64) error {
|
||||
_, err := model.FirstField(m.UserIdentity, []string{"id", "uuid", "identity"},
|
||||
model.NewWhere("uid", uid),
|
||||
model.NewWhere("is_selected", model.UserIdentitySelectedForYes))
|
||||
return err
|
||||
}
|
||||
|
||||
func NewUserIdentity() *UserIdentity {
|
||||
return &UserIdentity{model.NewUserIdentity()}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type UserManage struct {
|
||||
*model.UserManage
|
||||
}
|
||||
|
||||
type (
|
||||
// UserManageForExpert 专家信息
|
||||
UserManageForExpert struct {
|
||||
ID uint64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Mobile string `json:"mobile"`
|
||||
IdentityInfo string `json:"-"`
|
||||
}
|
||||
)
|
||||
|
||||
// Expert 专家数据
|
||||
func (m *UserManage) Expert(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*UserManageForExpert, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS m").
|
||||
Select(strings.Join([]string{"m.id", "m.name", "u.mobile", "m.identity_info"}, ",")).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u ON m.uid = u.uuid", model.NewUserInstance().TableName())).
|
||||
Where("m.is_deleted = ?", model.DeleteStatusForNot).
|
||||
Where("m.identity = ?", config.TenantUserIdentityForExpert)
|
||||
|
||||
out := make([]*UserManageForExpert, 0)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, v := range where {
|
||||
db = db.Where(v.Condition, v.Value)
|
||||
}
|
||||
}
|
||||
if err := db.Count(count).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := db.Order("m.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// LastChooseInfo 最后一次选中的信息
|
||||
func (m *UserManage) LastChooseInfo(uid uint64) error {
|
||||
_, err := model.FirstField(m.UserManage, []string{"id", "tenant_id", "uuid", "identity"},
|
||||
model.NewWhere("uid", uid),
|
||||
model.NewWhere("selected", model.UserManageSelectedForYes))
|
||||
return err
|
||||
}
|
||||
|
||||
func NewUserManage() *UserManage {
|
||||
return &UserManage{UserManage: model.NewUserManage()}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type UserManageBank struct {
|
||||
*model.UserManageBank
|
||||
}
|
||||
|
||||
func NewUserManageBank() *UserManageBank {
|
||||
return &UserManageBank{model.NewUserManageBank()}
|
||||
}
|
@ -6,7 +6,6 @@ import (
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/serve/orm"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
@ -20,10 +19,9 @@ type Examine struct {
|
||||
type ExamineHandle func(session *service.Session, local string) *Examine
|
||||
|
||||
type ExamineManageInfo struct {
|
||||
IModel model2.IModel
|
||||
TenantID uint64 // 租户ID
|
||||
UID uint64 // 用户表UUID
|
||||
IdentityInfo model2.IUserIdentity
|
||||
IModel model2.IModel
|
||||
TenantID uint64 // 租户ID
|
||||
UID uint64 // 用户表UUID
|
||||
}
|
||||
|
||||
// examineHandle 审核处理
|
||||
@ -57,9 +55,6 @@ func examineCompany(id uint64) (*ExamineManageInfo, error) {
|
||||
}
|
||||
return &ExamineManageInfo{
|
||||
IModel: mManageCompany.ManageCompany, UID: mManageCompany.UID,
|
||||
IdentityInfo: &model2.UserIdentityForCompany{
|
||||
Industry: mManageCompany.Industry, Keyword: mManageCompany.Keyword, CreatedAt: time.Now(),
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -75,10 +70,6 @@ func examineExpert(id uint64) (*ExamineManageInfo, error) {
|
||||
}
|
||||
return &ExamineManageInfo{
|
||||
IModel: mManageExpert.ManageExpert, UID: mManageExpert.UID,
|
||||
IdentityInfo: &model2.UserIdentityForExpert{
|
||||
Industry: mManageExpert.Industry, Keyword: mManageExpert.Keyword, Research: mManageExpert.Research,
|
||||
CreatedAt: time.Now(),
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -94,10 +85,6 @@ func examineResearch(id uint64) (*ExamineManageInfo, error) {
|
||||
}
|
||||
return &ExamineManageInfo{
|
||||
IModel: mManageResearch.ManageResearch, UID: mManageResearch.UID,
|
||||
IdentityInfo: &model2.UserIdentityForResearch{
|
||||
Name: mManageResearch.Name, Industry: mManageResearch.Industry, Keyword: mManageResearch.Keyword,
|
||||
Research: mManageResearch.Research, CreatedAt: time.Now(),
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -113,10 +100,6 @@ func examineLaboratory(id uint64) (*ExamineManageInfo, error) {
|
||||
}
|
||||
return &ExamineManageInfo{
|
||||
IModel: mManageLaboratory.ManageLaboratory, UID: mManageLaboratory.UID,
|
||||
IdentityInfo: &model2.UserIdentityForLaboratory{
|
||||
Name: mManageLaboratory.Name, Industry: mManageLaboratory.Industry, Keyword: mManageLaboratory.Keyword,
|
||||
Research: mManageLaboratory.Research, CreatedAt: time.Now(),
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -147,25 +130,17 @@ func (c *Examine) Launch(id uint64, identity, status int) error {
|
||||
if _status == model2.ExamineStatusForRefuse {
|
||||
return nil
|
||||
}
|
||||
mUserManage := model.NewUserManage()
|
||||
mUserIdentity := model.NewUserIdentity()
|
||||
|
||||
isExist := true
|
||||
|
||||
if isExist, err = model2.FirstField(mUserManage.UserManage, []string{"id", "uid"}, model2.NewWhere("uid", data.UID),
|
||||
if isExist, err = model2.FirstField(mUserIdentity.UserIdentity, []string{"id", "uid"}, model2.NewWhere("uid", data.UID),
|
||||
model2.NewWhere("identity", identity)); err != nil {
|
||||
return err
|
||||
}
|
||||
if !isExist {
|
||||
mUserManage.ManageID = data.IModel.GetID()
|
||||
mUserManage.UID = data.UID
|
||||
mUserManage.Identity = identity
|
||||
mUserManage.IdentityInfo = utils.AnyToJSON(data.IdentityInfo)
|
||||
} else {
|
||||
if err = model2.Updates(mUserManage.UserManage, map[string]interface{}{
|
||||
"identity_info": utils.AnyToJSON(data.IdentityInfo), "updated_at": time.Now(),
|
||||
}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
mUserIdentity.UID = data.UID
|
||||
mUserIdentity.Identity = identity
|
||||
}
|
||||
// 更新账户身份信息
|
||||
mUserInstance := model.NewUserInstance()
|
||||
|
11
app/api/manage/model/user_identity.go
Normal file
11
app/api/manage/model/user_identity.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type UserIdentity struct {
|
||||
*model.UserIdentity
|
||||
}
|
||||
|
||||
func NewUserIdentity() *UserIdentity {
|
||||
return &UserIdentity{model.NewUserIdentity()}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type UserManage struct {
|
||||
*model.UserManage
|
||||
}
|
||||
|
||||
func NewUserManage() *UserManage {
|
||||
return &UserManage{model.NewUserManage()}
|
||||
}
|
15
app/common/model/manage_agent.go
Normal file
15
app/common/model/manage_agent.go
Normal file
@ -0,0 +1,15 @@
|
||||
package model
|
||||
|
||||
type ManageAgent struct {
|
||||
Model
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *ManageAgent) TableName() string {
|
||||
return "manage_agent"
|
||||
}
|
||||
|
||||
func NewManageAgent() *ManageAgent {
|
||||
return &ManageAgent{}
|
||||
}
|
@ -2,7 +2,7 @@ package model
|
||||
|
||||
import "SciencesServer/utils"
|
||||
|
||||
// ManageCompany 公司企业管理
|
||||
// ManageCompany 公司企业入住信息管理
|
||||
type ManageCompany struct {
|
||||
Model
|
||||
Local
|
||||
|
@ -1,20 +0,0 @@
|
||||
package model
|
||||
|
||||
// ManageEnterprise 企业管理数据模型
|
||||
type ManageEnterprise struct {
|
||||
Model
|
||||
Title string `gorm:"column:title;type:varchar(30);default:null;comment:企业名称" json:"title"`
|
||||
Name string `gorm:"column:name;type:varchar(50);default:null;comment:企业联系人" json:"name"`
|
||||
Mobile string `gorm:"column:mobile;type:varchar(15);default:null;comment:企业联系方式" json:"mobile"`
|
||||
Area
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *ManageEnterprise) TableName() string {
|
||||
return "manage_enterprise"
|
||||
}
|
||||
|
||||
func NewManageEnterprise() *ManageEnterprise {
|
||||
return &ManageEnterprise{}
|
||||
}
|
@ -4,7 +4,7 @@ import (
|
||||
"SciencesServer/utils"
|
||||
)
|
||||
|
||||
// ManageLaboratory 实验室信息管理
|
||||
// ManageLaboratory 实验室入住信息管理
|
||||
type ManageLaboratory struct {
|
||||
Model
|
||||
Local
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"SciencesServer/utils"
|
||||
)
|
||||
|
||||
// ManageResearch 科研机构信息管理
|
||||
// ManageResearch 科研机构入住信息管理
|
||||
type ManageResearch struct {
|
||||
Model
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
|
15
app/common/model/user_agent.go
Normal file
15
app/common/model/user_agent.go
Normal file
@ -0,0 +1,15 @@
|
||||
package model
|
||||
|
||||
type UserAgent struct {
|
||||
Model
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *UserAgent) TableName() string {
|
||||
return "user_agent"
|
||||
}
|
||||
|
||||
func NewUserAgent() *UserAgent {
|
||||
return &UserAgent{}
|
||||
}
|
29
app/common/model/user_bank.go
Normal file
29
app/common/model/user_bank.go
Normal file
@ -0,0 +1,29 @@
|
||||
package model
|
||||
|
||||
// UserBank 用户银行卡数据模型
|
||||
type UserBank struct {
|
||||
Model
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
Name string `gorm:"column:name;type:varchar(30);default:null;comment:姓名" json:"name"`
|
||||
IDCard string `gorm:"column:id_card;type:varchar(18);default:null;comment:身份证号" json:"id_card"`
|
||||
BankCard string `gorm:"column:bank_card;type:varchar(18);default:null;comment:银行卡号" json:"bank_card"`
|
||||
BankName string `gorm:"column:bank_name;type:varchar(15);default:null;comment:银行名称" json:"bank_name"`
|
||||
IsDefault UserBankDefault `gorm:"column:is_default;type:tinyint(1);default:0;comment:默认使用(0:不默认,1:默认)" json:"-"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
type UserBankDefault int
|
||||
|
||||
const (
|
||||
UserBankDefaultForNot UserBankDefault = iota
|
||||
UserBankDefaultForYes
|
||||
)
|
||||
|
||||
func (m *UserBank) TableName() string {
|
||||
return m.NewTableName("user_bank")
|
||||
}
|
||||
|
||||
func NewUserBank() *UserBank {
|
||||
return &UserBank{}
|
||||
}
|
15
app/common/model/user_expert.go
Normal file
15
app/common/model/user_expert.go
Normal file
@ -0,0 +1,15 @@
|
||||
package model
|
||||
|
||||
type UserExpert struct {
|
||||
Model
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *UserExpert) TableName() string {
|
||||
return "user_expert"
|
||||
}
|
||||
|
||||
func NewUserExpert() *UserExpert {
|
||||
return &UserExpert{}
|
||||
}
|
48
app/common/model/user_identity.go
Normal file
48
app/common/model/user_identity.go
Normal file
@ -0,0 +1,48 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/utils"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// UserIdentity 用户身份管理数据模型
|
||||
type UserIdentity struct {
|
||||
Model
|
||||
UUID uint64 `gorm:"column:uuid;uniqueIndex:idx_user_manage_uuid;type:int;default:0;comment:用户唯一UUID" json:"-"`
|
||||
UID uint64 `gorm:"column:uid;index:idx_user_manage_uid;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:"-"`
|
||||
IsSelected UserIdentitySelected `gorm:"column:is_selected;type:tinyint(1);default:0;comment:最后一次选中的身份信息" json:"-"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
// UserIdentitySelected 身份选中状态
|
||||
type UserIdentitySelected int
|
||||
|
||||
const (
|
||||
// UserIdentitySelectedForNo 未选中
|
||||
UserIdentitySelectedForNo UserIdentitySelected = iota
|
||||
// UserIdentitySelectedForYes 已选中
|
||||
UserIdentitySelectedForYes
|
||||
)
|
||||
|
||||
func (m *UserIdentity) TableName() string {
|
||||
return m.NewTableName("user_identity")
|
||||
}
|
||||
|
||||
func (m *UserIdentity) BeforeCreate(db *gorm.DB) error {
|
||||
snowflake, _ := utils.NewSnowflake(1)
|
||||
m.UUID = uint64(snowflake.GetID())
|
||||
m.CreatedAt = time.Now()
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewUserIdentity() *UserIdentity {
|
||||
return &UserIdentity{}
|
||||
}
|
15
app/common/model/user_laboratory.go
Normal file
15
app/common/model/user_laboratory.go
Normal file
@ -0,0 +1,15 @@
|
||||
package model
|
||||
|
||||
type UserLaboratory struct {
|
||||
Model
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *UserLaboratory) TableName() string {
|
||||
return "user_laboratory"
|
||||
}
|
||||
|
||||
func NewUserLaboratory() *UserLaboratory {
|
||||
return &UserLaboratory{}
|
||||
}
|
@ -1,124 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/utils"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// UserManage 用户管理信息
|
||||
type UserManage struct {
|
||||
Model
|
||||
UUID uint64 `gorm:"column:uuid;uniqueIndex:idx_user_manage_uuid;type:int;default:0;comment:用户唯一UUID" json:"-"`
|
||||
UID uint64 `gorm:"column:uid;index:idx_user_manage_uid;type:int;default:0;comment:用户表UUID" json:"-"`
|
||||
ManageID uint64 `gorm:"column:manage_id;type:int(11);default:0;comment:信息管理ID,根据所在身份,对应不同数据表" 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"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
// UserIdentityForExpert 专家信息
|
||||
UserIdentityForExpert struct {
|
||||
Industry string `json:"industry"`
|
||||
Keyword string `json:"keyword"`
|
||||
Research string `json:"research"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
// UserIdentityForResearch 研究机构信息
|
||||
UserIdentityForResearch struct {
|
||||
Name string `json:"name"`
|
||||
Industry string `json:"industry"`
|
||||
Keyword string `json:"keyword"`
|
||||
Research string `json:"research"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
// UserIdentityForLaboratory 实验室信息
|
||||
UserIdentityForLaboratory struct {
|
||||
Name string `json:"name"`
|
||||
Industry string `json:"industry"`
|
||||
Keyword string `json:"keyword"`
|
||||
Research string `json:"research"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
func (this *UserIdentityForResearch) Analysis(src string) interface{} {
|
||||
utils.FromJSON(src, this)
|
||||
return this
|
||||
}
|
||||
|
||||
func (this *UserIdentityForLaboratory) Analysis(src string) interface{} {
|
||||
utils.FromJSON(src, this)
|
||||
return this
|
||||
}
|
||||
|
||||
type UserManageSelected int
|
||||
|
||||
const (
|
||||
// UserManageSelectedForNo 未选中
|
||||
UserManageSelectedForNo UserManageSelected = iota
|
||||
// UserManageSelectedForYes 已选中
|
||||
UserManageSelectedForYes
|
||||
)
|
||||
|
||||
func (m *UserManage) TableName() string {
|
||||
return m.NewTableName("user_manage")
|
||||
}
|
||||
|
||||
func (m *UserManage) BeforeCreate(db *gorm.DB) error {
|
||||
snowflake, _ := utils.NewSnowflake(1)
|
||||
m.UUID = uint64(snowflake.GetID())
|
||||
m.CreatedAt = time.Now()
|
||||
return nil
|
||||
}
|
||||
|
||||
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 {
|
||||
return &UserManage{}
|
||||
}
|
15
app/common/model/user_research.go
Normal file
15
app/common/model/user_research.go
Normal file
@ -0,0 +1,15 @@
|
||||
package model
|
||||
|
||||
type UserResearch struct {
|
||||
Model
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *UserResearch) TableName() string {
|
||||
return "user_research"
|
||||
}
|
||||
|
||||
func NewUserResearch() *UserResearch {
|
||||
return &UserResearch{}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package model
|
||||
|
||||
// UserManageBank 用户银行卡管理
|
||||
type UserManageBank struct {
|
||||
Model
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
Name string `gorm:"column:name;type:varchar(30);default:null;comment:姓名" json:"name"`
|
||||
IDCard string `gorm:"column:id_card;type:varchar(18);default:null;comment:身份证号" json:"id_card"`
|
||||
BankCard string `gorm:"column:bank_card;type:varchar(18);default:null;comment:银行卡号" json:"bank_card"`
|
||||
BankName string `gorm:"column:bank_name;type:varchar(15);default:null;comment:银行名称" json:"bank_name"`
|
||||
IsDefault UserManageBankDefault `gorm:"column:is_default;type:tinyint(1);default:0;comment:默认使用(0:不默认,1:默认)" json:"-"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
type UserManageBankDefault int
|
||||
|
||||
const (
|
||||
UserManageBankDefaultForNot UserManageBankDefault = iota
|
||||
UserManageBankDefaultForYes
|
||||
)
|
||||
|
||||
func (m *UserManageBank) TableName() string {
|
||||
return m.NewTableName("user_manage_bank")
|
||||
}
|
||||
|
||||
func NewUserManageBank() *UserManageBank {
|
||||
return &UserManageBank{}
|
||||
}
|
@ -30,7 +30,6 @@ func NewSession() *Session {
|
||||
type SessionEnterprise struct {
|
||||
UID uint64 `json:"uid"` // 唯一标识ID
|
||||
TenantID uint64 `json:"tenant_id"` // 租户ID
|
||||
ManageUID uint64 `json:"manage_uid"` // 管理平台用户唯一ID
|
||||
Token string `json:"token"` // token
|
||||
Name string `json:"name"` // 名称
|
||||
Mobile string `json:"mobile"` // 手机号码
|
||||
|
Reference in New Issue
Block a user