feat:完善项目

This commit is contained in:
henry
2022-01-15 16:48:49 +08:00
parent 57daf5119d
commit 6d075dab4f
33 changed files with 196 additions and 154 deletions

View File

@ -11,10 +11,10 @@ import (
"gorm.io/gorm"
)
type Login struct{ local string }
type Login struct{ tenantID uint64 }
type (
LoginHandle func(local string) *Login
LoginHandle func(tenantID uint64) *Login
)
type (
@ -41,12 +41,12 @@ const (
LoginModeForQQ // QQ登陆
)
var loginHandle = map[LoginMode]func(*LoginParams, string) (*InstanceLoginParams, error){
var loginHandle = map[LoginMode]func(*LoginParams, uint64) (*InstanceLoginParams, error){
LoginModeForSmsCaptcha: loginForSmsCaptcha, LoginModeForPassword: loginForPassword,
}
// loginForSmsCaptcha 短信验证码登陆
func loginForSmsCaptcha(params *LoginParams, local string) (*InstanceLoginParams, error) {
func loginForSmsCaptcha(params *LoginParams, tenantID uint64) (*InstanceLoginParams, error) {
if !utils.ValidateMobile(params.Captcha.Mobile) {
return nil, errors.New("操作错误,手机号码格式异常")
}
@ -107,7 +107,7 @@ RETURNS:
}
// loginForPassword 密码登陆
func loginForPassword(params *LoginParams, local string) (*InstanceLoginParams, error) {
func loginForPassword(params *LoginParams, tenantID uint64) (*InstanceLoginParams, error) {
if !utils.ValidateMobile(params.Password.Account) {
return nil, errors.New("操作错误,手机号码格式异常")
}
@ -156,7 +156,7 @@ func (c *Login) Launch(mode LoginMode, params *LoginParams) (*InstanceLoginRetur
if !has {
return nil, errors.New("操作错误,未知的登陆模式")
}
ret, err := _handle(params, c.local)
ret, err := _handle(params, c.tenantID)
if err != nil {
return nil, err
@ -168,7 +168,7 @@ func (c *Login) Launch(mode LoginMode, params *LoginParams) (*InstanceLoginRetur
}
func NewLogin() LoginHandle {
return func(local string) *Login {
return &Login{local: local}
return func(tenantID uint64) *Login {
return &Login{tenantID: tenantID}
}
}

View File

@ -10,9 +10,9 @@ import (
"gorm.io/gorm"
)
type Register struct{ local string }
type Register struct{ tenantID uint64 }
type RegisterHandle func(local string) *Register
type RegisterHandle func(tenantID uint64) *Register
type (
RegisterParams struct {
@ -28,7 +28,7 @@ func (c *RegisterParams) checkCaptcha() (bool, error) {
return handle.NewCaptcha().Validate(&handle.CaptchaSms{Captcha: c.Captcha, Mobile: c.Mobile})
}
func (c *RegisterParams) checkUserExist(mUserInstance *model2.UserInstance, local string) (bool, error) {
func (c *RegisterParams) checkUserExist(mUserInstance *model2.UserInstance, tenantID uint64) (bool, error) {
var count int64
if err := model2.Count(mUserInstance, &count, model2.NewWhere("mobile", c.Mobile)); //model2.NewWhere("local", local)
@ -55,7 +55,7 @@ func (c *Register) Launch(params *RegisterParams) (*InstanceLoginReturn, error)
// 验证账号信息
mUserInstance := model3.NewUserInstance()
if pass, err = params.checkUserExist(mUserInstance.UserInstance, c.local); err != nil {
if pass, err = params.checkUserExist(mUserInstance.UserInstance, c.tenantID); err != nil {
return nil, err
} else if !pass {
return nil, errors.New("当前手机号码已注册")
@ -84,7 +84,7 @@ func (c *Register) Launch(params *RegisterParams) (*InstanceLoginReturn, error)
}
func NewRegister() RegisterHandle {
return func(local string) *Register {
return &Register{local: local}
return func(tenantID uint64) *Register {
return &Register{tenantID: tenantID}
}
}

View File

@ -4,10 +4,10 @@ import "SciencesServer/app/session"
type Instance struct {
*session.Enterprise
local string
tenantID uint64
}
type InstanceHandle func(session *session.Enterprise, local string) *Instance
type InstanceHandle func(session *session.Enterprise, tenantID uint64) *Instance
type InstanceInfo struct {
Currency float64 `json:"currency"`
@ -18,7 +18,7 @@ func (c *Instance) Instance() (*InstanceInfo, error) {
}
func NewInstance() InstanceHandle {
return func(session *session.Enterprise, local string) *Instance {
return &Instance{Enterprise: session, local: local}
return func(session *session.Enterprise, tenantID uint64) *Instance {
return &Instance{Enterprise: session, tenantID: tenantID}
}
}

View File

@ -11,10 +11,10 @@ import (
// Enterprise 企业管理信息
type Enterprise struct {
*session.Enterprise
local string
tenantID uint64
}
type EnterpriseHandle func(session *session.Enterprise, local string) *Enterprise
type EnterpriseHandle func(session *session.Enterprise, tenantID uint64) *Enterprise
type (
// EnterpriseInfo 企业信息
@ -40,7 +40,7 @@ func (c *Enterprise) List(mode int, title string, page, pageSize int) (*controll
where := []*model2.ModelWhere{
model2.NewWhere("mode", mode),
model2.NewWhere("local", c.local),
//model2.NewWhere("tenant_id", c.tenantID),
model2.NewWhere("uid", c.UID),
}
if title != "" {
@ -98,7 +98,7 @@ func (c *Enterprise) Form(params *EnterpriseParams) error {
if mUserCooperateEnterprise.ID > 0 {
return model2.Updates(mUserCooperateEnterprise.UserCooperateEnterprise, mUserCooperateEnterprise.UserCooperateEnterprise)
}
mUserCooperateEnterprise.Local.Local = c.local
mUserCooperateEnterprise.TenantID = c.tenantID
mUserCooperateEnterprise.UID = c.UID
return model2.Create(mUserCooperateEnterprise.UserCooperateEnterprise)
}
@ -122,7 +122,7 @@ func (c *Enterprise) Delete(id uint64) error {
}
func NewEnterprise() EnterpriseHandle {
return func(session *session.Enterprise, local string) *Enterprise {
return &Enterprise{Enterprise: session, local: local}
return func(session *session.Enterprise, tenantID uint64) *Enterprise {
return &Enterprise{Enterprise: session, tenantID: tenantID}
}
}

View File

@ -10,7 +10,7 @@ import (
type Demand struct {
*session.Enterprise
local string
tenantID uint64
}
type (
@ -29,7 +29,7 @@ type (
}
)
type DemandHandle func(session *session.Enterprise, local string) *Demand
type DemandHandle func(session *session.Enterprise, tenantID uint64) *Demand
// List 列表信息
func (c *Demand) List(title string, status, page, pageSize int) (*controller.ReturnPages, error) {
@ -37,7 +37,7 @@ func (c *Demand) List(title string, status, page, pageSize int) (*controller.Ret
where := []*model2.ModelWhereOrder{
&model2.ModelWhereOrder{
Where: model2.NewWhere("local", c.local),
Where: model2.NewWhere("tenant_id", c.tenantID),
Order: model2.NewOrder("id", model2.OrderModeToDesc),
},
&model2.ModelWhereOrder{Where: model2.NewWhere("uid", c.UID)},
@ -116,7 +116,7 @@ func (c *Demand) Form(params *DemandParams) error {
return model2.Updates(mServiceDemand.ServiceDemand, mServiceDemand.ServiceDemand)
}
mServiceDemand.Local.Local = c.local
mServiceDemand.TenantID = c.tenantID
mServiceDemand.UID = c.UID
if params.IsSubmit > 0 {
@ -141,10 +141,10 @@ func (c *Demand) Delete(id uint64) error {
}
func NewDemand() DemandHandle {
return func(session *session.Enterprise, local string) *Demand {
return func(session *session.Enterprise, tenantID uint64) *Demand {
return &Demand{
Enterprise: session,
local: local,
tenantID: tenantID,
}
}
}

View File

@ -10,10 +10,10 @@ import (
// Instance 首页信息
type Instance struct {
*session.Enterprise
local string
tenantID uint64
}
type InstanceHandle func(session *session.Enterprise, local string) *Instance
type InstanceHandle func(session *session.Enterprise, tenantID uint64) *Instance
type InstanceInfo struct {
Identity int `json:"identity"` // 所有身份
@ -97,7 +97,7 @@ func (c *Instance) Index() (*InstanceInfo, error) {
}
func NewInstance() InstanceHandle {
return func(session *session.Enterprise, local string) *Instance {
return &Instance{Enterprise: session, local: local}
return func(session *session.Enterprise, tenantID uint64) *Instance {
return &Instance{Enterprise: session, tenantID: tenantID}
}
}

View File

@ -15,10 +15,10 @@ import (
// Achievement 成果信息
type Achievement struct {
*session.Enterprise
local string
tenantID uint64
}
type AchievementHandle func(session *session.Enterprise, local string) *Achievement
type AchievementHandle func(session *session.Enterprise, tenantID uint64) *Achievement
type (
// AchievementInfo 成果信息
@ -183,7 +183,7 @@ func (c *Achievement) Form(params *AchievementParams) error {
mTechnologyAchievement.Status = model2.TechnologyAchievementStatusForExamining
return model2.Updates(mTechnologyAchievement.TechnologyAchievement, mTechnologyAchievement.TechnologyAchievement)
}
mTechnologyAchievement.Local.Local = c.local
mTechnologyAchievement.TenantID = c.tenantID
mTechnologyAchievement.UID = c.UID
if params.IsSubmit > 0 {
@ -231,10 +231,10 @@ func (c *Achievement) Delete(id uint64) error {
}
func NewAchievement() AchievementHandle {
return func(session *session.Enterprise, local string) *Achievement {
return func(session *session.Enterprise, tenantID uint64) *Achievement {
return &Achievement{
Enterprise: session,
local: local,
tenantID: tenantID,
}
}
}

View File

@ -13,10 +13,10 @@ import (
// Demand 技术需求管理
type Demand struct {
*session.Enterprise
local string
tenantID uint64
}
type DemandHandle func(session *session.Enterprise, local string) *Demand
type DemandHandle func(session *session.Enterprise, tenantID uint64) *Demand
type (
// DemandInfo 需求信息
@ -149,7 +149,7 @@ func (c *Demand) Form(params *DemandParams) error {
return model2.Updates(mTechnologyDemand.TechnologyDemand, mTechnologyDemand.TechnologyDemand)
}
mTechnologyDemand.UID = c.UID
mTechnologyDemand.Local.Local = c.local
mTechnologyDemand.TenantID = c.tenantID
if params.IsSubmit > 0 {
mTechnologyDemand.Status = model2.TechnologyDemandStatusForExamining
@ -178,7 +178,7 @@ func (c *Demand) Delete(id uint64) error {
}
func NewDemand() DemandHandle {
return func(session *session.Enterprise, local string) *Demand {
return &Demand{Enterprise: session, local: local}
return func(session *session.Enterprise, tenantID uint64) *Demand {
return &Demand{Enterprise: session, tenantID: tenantID}
}
}

View File

@ -13,10 +13,10 @@ import (
// Instance 技术管理
type Instance struct {
*session.Enterprise
local string
tenantID uint64
}
type InstanceHandle func(session *session.Enterprise, local string) *Instance
type InstanceHandle func(session *session.Enterprise, tenantID uint64) *Instance
type (
// InstanceInfo 详细信息
@ -108,7 +108,7 @@ func (c *Instance) Form(params *InstanceParams) error {
return model2.Updates(mTechnologyInstance.TechnologyInstance, mTechnologyInstance.TechnologyInstance)
}
mTechnologyInstance.UID = c.UID
mTechnologyInstance.Local.Local = c.local
mTechnologyInstance.TenantID = c.tenantID
if params.IsSubmit > 0 {
mTechnologyInstance.Status = model2.TechnologyInstanceStatusForExamining
@ -161,7 +161,7 @@ func (c *Instance) Delete(id uint64) error {
}
func NewInstance() InstanceHandle {
return func(session *session.Enterprise, local string) *Instance {
return &Instance{Enterprise: session, local: local}
return func(session *session.Enterprise, tenantID uint64) *Instance {
return &Instance{Enterprise: session, tenantID: tenantID}
}
}

View File

@ -13,10 +13,10 @@ import (
// Paper 论文管理
type Paper struct {
*session.Enterprise
local string
tenantID uint64
}
type PaperHandle func(session *session.Enterprise, local string) *Paper
type PaperHandle func(session *session.Enterprise, tenantID uint64) *Paper
type (
PaperInfo struct {
@ -38,7 +38,7 @@ func (c *Paper) List(title string, page, pageSize int) (*controller.ReturnPages,
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
Order: model2.NewOrder("id", model2.OrderModeToDesc),
}, &model2.ModelWhereOrder{
Where: model2.NewWhere("local", c.local),
Where: model2.NewWhere("tenant_id", c.tenantID),
}}
if title != "" {
where = append(where, &model2.ModelWhereOrder{Where: model2.NewWhereLike("title", title)})
@ -83,7 +83,7 @@ func (c *Paper) Form(params *PaperParams) error {
if params.ID <= 0 {
mTechnologyPaper.UID = c.UID
mTechnologyPaper.Local.Local = c.local
mTechnologyPaper.TenantID = c.tenantID
return model2.Create(mTechnologyPaper.TechnologyPaper)
}
mTechnologyPaper.UpdatedAt = time.Now()
@ -111,7 +111,7 @@ func (c *Paper) Delete(id uint64) error {
}
func NewPaper() PaperHandle {
return func(session *session.Enterprise, local string) *Paper {
return &Paper{Enterprise: session, local: local}
return func(session *session.Enterprise, tenantID uint64) *Paper {
return &Paper{Enterprise: session, tenantID: tenantID}
}
}

View File

@ -17,10 +17,10 @@ import (
// Patent 专利管理
type Patent struct {
*session.Enterprise
local string
tenantID uint64
}
type PatentHandle func(session *session.Enterprise, local string) *Patent
type PatentHandle func(session *session.Enterprise, tenantID uint64) *Patent
type (
// PatentInfo 专利信息
@ -55,7 +55,7 @@ type (
)
// add 新增专利信息
func (c *PatentParams) add(uid uint64) error {
func (c *PatentParams) add(tenantID, uid uint64) error {
mSysPatent := model.NewSysPatent()
isExist, err := mSysPatent.IsExistParams(map[string]interface{}{
"apply_code": c.ApplyCode, "open_code": c.OpenCode,
@ -67,6 +67,7 @@ func (c *PatentParams) add(uid uint64) error {
}
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
mSysPatent.Kind = model2.SysParentKind(c.Kind)
mSysPatent.TenantID = tenantID
mSysPatent.Title = c.Title
mSysPatent.FileUrl = c.FileUrl
mSysPatent.ApplyCode = c.ApplyCode
@ -258,7 +259,7 @@ func (c *Patent) Form(params *PatentParams) error {
if params.ID > 0 {
return params.edit(c.UID)
}
return params.add(c.UID)
return params.add(c.tenantID, c.UID)
}
@ -310,7 +311,7 @@ func (c *Patent) Delete(id uint64) error {
}
func NewPatent() PatentHandle {
return func(session *session.Enterprise, local string) *Patent {
return &Patent{Enterprise: session, local: local}
return func(session *session.Enterprise, tenantID uint64) *Patent {
return &Patent{Enterprise: session, tenantID: tenantID}
}
}

View File

@ -15,10 +15,10 @@ import (
// Product 产品信息
type Product struct {
*session.Enterprise
local string
tenantID uint64
}
type ProductHandle func(session *session.Enterprise, local string) *Product
type ProductHandle func(session *session.Enterprise, tenantID uint64) *Product
type (
// ProductInfo 产品信息
@ -205,7 +205,7 @@ func (c *Product) Form(params *ProductParams) error {
mTechnologyProduct.Status = model2.TechnologyProductStatusForExamining
return model2.Updates(mTechnologyProduct.TechnologyProduct, mTechnologyProduct.TechnologyProduct)
}
mTechnologyProduct.Local.Local = c.local
mTechnologyProduct.TenantID = c.tenantID
mTechnologyProduct.UID = c.UID
if params.IsSubmit > 0 {
@ -253,10 +253,10 @@ func (c *Product) Delete(id uint64) error {
}
func NewProduct() ProductHandle {
return func(session *session.Enterprise, local string) *Product {
return func(session *session.Enterprise, tenantID uint64) *Product {
return &Product{
Enterprise: session,
local: local,
tenantID: tenantID,
}
}
}

View File

@ -13,10 +13,10 @@ import (
// Project 项目列表
type Project struct {
*session.Enterprise
local string
tenantID uint64
}
type ProjectHandle func(session *session.Enterprise, local string) *Project
type ProjectHandle func(session *session.Enterprise, tenantID uint64) *Project
type (
// ProjectInfo 产品信息
@ -90,7 +90,7 @@ func (c *Project) Form(params *ProjectParams) error {
if mTechnologyProject.ID > 0 {
return model2.Updates(mTechnologyProject.TechnologyProject, mTechnologyProject.TechnologyProject)
}
mTechnologyProject.Local.Local = c.local
mTechnologyProject.TenantID = c.tenantID
mTechnologyProject.UID = c.UID
return model2.Create(mTechnologyProject.TechnologyProject)
}
@ -135,7 +135,7 @@ func (c *Project) Delete(id uint64) error {
}
func NewProject() ProjectHandle {
return func(session *session.Enterprise, local string) *Project {
return &Project{Enterprise: session, local: local}
return func(session *session.Enterprise, tenantID uint64) *Project {
return &Project{Enterprise: session, tenantID: tenantID}
}
}

View File

@ -12,10 +12,10 @@ import (
type Topic struct {
*session.Enterprise
local string
tenantID uint64
}
type TopicHandle func(session *session.Enterprise, local string) *Topic
type TopicHandle func(session *session.Enterprise, tenantID uint64) *Topic
type (
// TopicInfo 课题信息
@ -122,7 +122,7 @@ func (c *Topic) Form(params *TopicParams) error {
mTechnologyTopic.UpdatedAt = time.Now()
return model2.Updates(mTechnologyTopic.TechnologyTopic, mTechnologyTopic.TechnologyTopic)
}
mTechnologyTopic.Local.Local = c.local
mTechnologyTopic.TenantID = c.tenantID
mTechnologyTopic.UID = c.UID
return model2.Create(mTechnologyTopic.TechnologyTopic)
}
@ -145,10 +145,10 @@ func (c *Topic) Delete(id uint64) error {
}
func NewTopic() TopicHandle {
return func(session *session.Enterprise, local string) *Topic {
return func(session *session.Enterprise, tenantID uint64) *Topic {
return &Topic{
Enterprise: session,
local: local,
tenantID: tenantID,
}
}
}