feat:优化项目结构
This commit is contained in:
@ -2,25 +2,26 @@ package account
|
||||
|
||||
import (
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
"SciencesServer/config"
|
||||
"SciencesServer/utils"
|
||||
)
|
||||
|
||||
type Logout struct {
|
||||
*service.SessionEnterprise
|
||||
*session.Enterprise
|
||||
}
|
||||
|
||||
type LogoutHandle func(enterprise *service.SessionEnterprise) *Logout
|
||||
type LogoutHandle func(session *session.Enterprise) *Logout
|
||||
|
||||
func (c *Logout) Launch() error {
|
||||
if c.SessionEnterprise != nil && c.UID > 0 {
|
||||
if c.Enterprise != nil && c.UID > 0 {
|
||||
service.Publish(config.EventForRedisHashDestroy, config.RedisKeyForAccount, utils.UintToString(c.UID))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewLogout() LogoutHandle {
|
||||
return func(enterprise *service.SessionEnterprise) *Logout {
|
||||
return &Logout{enterprise}
|
||||
return func(session *session.Enterprise) *Logout {
|
||||
return &Logout{Enterprise: session}
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +0,0 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"SciencesServer/app/handle"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type Other struct{}
|
||||
|
||||
type OtherHandle func() *Other
|
||||
|
||||
// BindMobile 绑定手机号码
|
||||
func (c *Other) BindMobile(token, mobile, captcha string) (interface{}, error) {
|
||||
if !utils.ValidateMobile(mobile) {
|
||||
return nil, errors.New("手机号码格式异常")
|
||||
}
|
||||
pass, err := handle.NewCaptcha().Validate(&handle.CaptchaSms{
|
||||
Mobile: mobile, Captcha: captcha,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !pass {
|
||||
return nil, errors.New("验证码错误或已过期")
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func NewOther() OtherHandle {
|
||||
return func() *Other {
|
||||
return &Other{}
|
||||
}
|
||||
}
|
@ -5,16 +5,16 @@ import (
|
||||
"SciencesServer/app/api/manage/controller"
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Instance struct {
|
||||
*service.SessionEnterprise
|
||||
*session.Enterprise
|
||||
local string
|
||||
}
|
||||
|
||||
type InstanceHandle func(enterprise *service.SessionEnterprise, local string) *Instance
|
||||
type InstanceHandle func(session *session.Enterprise, local string) *Instance
|
||||
|
||||
type (
|
||||
// InstanceForExpert 专家信息
|
||||
@ -64,10 +64,10 @@ func (c *Instance) Expert(name, mobile string, page, pageSize int) (*controller.
|
||||
}
|
||||
|
||||
func NewInstance() InstanceHandle {
|
||||
return func(enterprise *service.SessionEnterprise, local string) *Instance {
|
||||
return func(session *session.Enterprise, local string) *Instance {
|
||||
return &Instance{
|
||||
SessionEnterprise: enterprise,
|
||||
local: local,
|
||||
Enterprise: session,
|
||||
local: local,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"SciencesServer/app/api/manage/controller"
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
"time"
|
||||
@ -13,11 +13,11 @@ import (
|
||||
|
||||
// Demand 技术需求管理
|
||||
type Demand struct {
|
||||
*service.SessionEnterprise
|
||||
*session.Enterprise
|
||||
local string
|
||||
}
|
||||
|
||||
type DemandHandle func(enterprise *service.SessionEnterprise, local string) *Demand
|
||||
type DemandHandle func(session *session.Enterprise, local string) *Demand
|
||||
|
||||
type (
|
||||
// DemandInfo 需求信息
|
||||
@ -182,7 +182,7 @@ func (c *Demand) Delete(id uint64) error {
|
||||
}
|
||||
|
||||
func NewDemand() DemandHandle {
|
||||
return func(enterprise *service.SessionEnterprise, local string) *Demand {
|
||||
return &Demand{SessionEnterprise: enterprise, local: local}
|
||||
return func(session *session.Enterprise, local string) *Demand {
|
||||
return &Demand{Enterprise: session, local: local}
|
||||
}
|
||||
}
|
||||
|
@ -4,16 +4,16 @@ import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/api/manage/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type Equipment struct {
|
||||
*service.SessionEnterprise
|
||||
*session.Enterprise
|
||||
local string
|
||||
}
|
||||
|
||||
type EquipmentHandle func(enterprise *service.SessionEnterprise, local string) *Equipment
|
||||
type EquipmentHandle func(session *session.Enterprise, local string) *Equipment
|
||||
|
||||
type EquipmentParams struct {
|
||||
ID uint64
|
||||
@ -102,10 +102,10 @@ func (c *Equipment) Delete(id uint64) error {
|
||||
}
|
||||
|
||||
func NewEquipment() EquipmentHandle {
|
||||
return func(enterprise *service.SessionEnterprise, local string) *Equipment {
|
||||
return func(session *session.Enterprise, local string) *Equipment {
|
||||
return &Equipment{
|
||||
SessionEnterprise: enterprise,
|
||||
local: local,
|
||||
Enterprise: session,
|
||||
local: local,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,18 +4,18 @@ import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/api/manage/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Instance 技术管理
|
||||
type Instance struct {
|
||||
*service.SessionEnterprise
|
||||
*session.Enterprise
|
||||
local string
|
||||
}
|
||||
|
||||
type InstanceHandle func(enterprise *service.SessionEnterprise, local string) *Instance
|
||||
type InstanceHandle func(session *session.Enterprise, local string) *Instance
|
||||
|
||||
type (
|
||||
// InstanceInfo 详细信息
|
||||
@ -157,7 +157,7 @@ func (c *Instance) Delete(id uint64) error {
|
||||
}
|
||||
|
||||
func NewInstance() InstanceHandle {
|
||||
return func(enterprise *service.SessionEnterprise, local string) *Instance {
|
||||
return &Instance{SessionEnterprise: enterprise, local: local}
|
||||
return func(session *session.Enterprise, local string) *Instance {
|
||||
return &Instance{Enterprise: session, local: local}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/api/manage/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
"time"
|
||||
@ -12,11 +12,11 @@ import (
|
||||
|
||||
// Paper 论文管理
|
||||
type Paper struct {
|
||||
*service.SessionEnterprise
|
||||
*session.Enterprise
|
||||
local string
|
||||
}
|
||||
|
||||
type PaperHandle func(enterprise *service.SessionEnterprise, local string) *Paper
|
||||
type PaperHandle func(session *session.Enterprise, local string) *Paper
|
||||
|
||||
type (
|
||||
PaperInfo struct {
|
||||
@ -113,7 +113,7 @@ func (c *Paper) Delete(id uint64) error {
|
||||
}
|
||||
|
||||
func NewPaper() PaperHandle {
|
||||
return func(enterprise *service.SessionEnterprise, local string) *Paper {
|
||||
return &Paper{SessionEnterprise: enterprise, local: local}
|
||||
return func(session *session.Enterprise, local string) *Paper {
|
||||
return &Paper{Enterprise: session, local: local}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/api/manage/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
"time"
|
||||
@ -12,11 +12,11 @@ import (
|
||||
|
||||
// Patent 专利管理
|
||||
type Patent struct {
|
||||
*service.SessionEnterprise
|
||||
*session.Enterprise
|
||||
local string
|
||||
}
|
||||
|
||||
type PatentHandle func(enterprise *service.SessionEnterprise, local string) *Patent
|
||||
type PatentHandle func(session *session.Enterprise, local string) *Patent
|
||||
|
||||
type (
|
||||
// PatentInfo 专利信息
|
||||
@ -148,7 +148,7 @@ func (c *Patent) Delete(id uint64) error {
|
||||
}
|
||||
|
||||
func NewPatent() PatentHandle {
|
||||
return func(enterprise *service.SessionEnterprise, local string) *Patent {
|
||||
return &Patent{SessionEnterprise: enterprise, local: local}
|
||||
return func(session *session.Enterprise, local string) *Patent {
|
||||
return &Patent{Enterprise: session, local: local}
|
||||
}
|
||||
}
|
||||
|
@ -4,18 +4,18 @@ import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/api/manage/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Topic struct {
|
||||
*service.SessionEnterprise
|
||||
*session.Enterprise
|
||||
local string
|
||||
}
|
||||
|
||||
type TopicHandle func(enterprise *service.SessionEnterprise, local string) *Topic
|
||||
type TopicHandle func(session *session.Enterprise, local string) *Topic
|
||||
|
||||
type (
|
||||
// TopicInfo 课题信息
|
||||
@ -146,10 +146,10 @@ func (c *Topic) Delete(id uint64) error {
|
||||
}
|
||||
|
||||
func NewTopic() TopicHandle {
|
||||
return func(enterprise *service.SessionEnterprise, local string) *Topic {
|
||||
return func(session *session.Enterprise, local string) *Topic {
|
||||
return &Topic{
|
||||
SessionEnterprise: enterprise,
|
||||
local: local,
|
||||
Enterprise: session,
|
||||
local: local,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,16 +4,16 @@ import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/handle"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type Bank struct {
|
||||
*service.SessionEnterprise
|
||||
*session.Enterprise
|
||||
}
|
||||
|
||||
type BankHandle func(enterprise *service.SessionEnterprise) *Bank
|
||||
type BankHandle func(session *session.Enterprise) *Bank
|
||||
|
||||
type (
|
||||
// BankInfo 银行卡信息
|
||||
@ -116,7 +116,7 @@ func (c *Bank) Unbind(id uint64) error {
|
||||
}
|
||||
|
||||
func NewBank() BankHandle {
|
||||
return func(enterprise *service.SessionEnterprise) *Bank {
|
||||
return &Bank{enterprise}
|
||||
return func(session *session.Enterprise) *Bank {
|
||||
return &Bank{Enterprise: session}
|
||||
}
|
||||
}
|
||||
|
@ -4,17 +4,20 @@ 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"
|
||||
)
|
||||
|
||||
type Instance struct{ *service.SessionEnterprise }
|
||||
type Instance struct{ *session.Enterprise }
|
||||
|
||||
type InstanceHandle func(enterprise *service.SessionEnterprise) *Instance
|
||||
type InstanceHandle func(session *session.Enterprise) *Instance
|
||||
|
||||
type (
|
||||
// InstanceInfo 基本信息
|
||||
@ -58,6 +61,36 @@ func (c *Instance) Detail() (*InstanceDetailInfo, error) {
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// BindMobile 绑定手机号码
|
||||
func (c *Instance) BindMobile(mobile, captcha string) error {
|
||||
if !utils.ValidateMobile(mobile) {
|
||||
return errors.New("操作错误,手机号码格式异常")
|
||||
}
|
||||
// 查询用户手机号码是否绑定
|
||||
mUserInstance := model.NewUserInstance()
|
||||
|
||||
if _, err := model2.FirstField(mUserInstance.UserInstance, []string{"id", "uuid", "mobile"}, model2.NewWhere("uuid", c.UID)); err != nil {
|
||||
return err
|
||||
}
|
||||
if mUserInstance.Mobile == mobile {
|
||||
return nil
|
||||
}
|
||||
pass, err := handle.NewCaptcha().Validate(&handle.CaptchaSms{
|
||||
Mobile: mobile, Captcha: captcha,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !pass {
|
||||
return errors.New("操作错误,验证码错误或已过期")
|
||||
}
|
||||
if err := model2.Updates(mUserInstance.UserInstance, map[string]interface{}{
|
||||
"mobile": mobile, "updated_at": time.Now(),
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SwitchIdentity 切换身份
|
||||
func (c *Instance) SwitchIdentity(identity int) error {
|
||||
if _, has := config.TenantUserIdentityData[identity]; !has {
|
||||
@ -96,12 +129,12 @@ func (c *Instance) SwitchIdentity(identity int) error {
|
||||
c.ManageUID = mUserManage.UUID
|
||||
}
|
||||
c.SelectIdentity = identity
|
||||
service.Publish(config2.EventForAccountLoginProduce, config2.RedisKeyForAccount, c.UIDToString(), c.SessionEnterprise)
|
||||
service.Publish(config2.EventForAccountLoginProduce, config2.RedisKeyForAccount, c.UIDToString(), c.Enterprise)
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewInstance() InstanceHandle {
|
||||
return func(enterprise *service.SessionEnterprise) *Instance {
|
||||
return &Instance{SessionEnterprise: enterprise}
|
||||
return func(session *session.Enterprise) *Instance {
|
||||
return &Instance{Enterprise: session}
|
||||
}
|
||||
}
|
||||
|
@ -4,15 +4,15 @@ import (
|
||||
model3 "SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
)
|
||||
|
||||
// Settled 入驻
|
||||
type Settled struct{ *service.SessionEnterprise }
|
||||
type Settled struct{ *session.Enterprise }
|
||||
|
||||
type SettledHandle func(enterprise *service.SessionEnterprise) *Settled
|
||||
type SettledHandle func(session *session.Enterprise) *Settled
|
||||
|
||||
type SettledParams struct {
|
||||
ID uint64
|
||||
@ -185,7 +185,7 @@ func (c *Settled) Agent() {
|
||||
}
|
||||
|
||||
func NewSettled() SettledHandle {
|
||||
return func(enterprise *service.SessionEnterprise) *Settled {
|
||||
return &Settled{enterprise}
|
||||
return func(session *session.Enterprise) *Settled {
|
||||
return &Settled{Enterprise: session}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user