feat:完善信息

This commit is contained in:
henry
2021-10-12 17:27:41 +08:00
parent eccd71809d
commit 17fb77e84a
10 changed files with 54 additions and 36 deletions

View File

@ -10,9 +10,12 @@ import (
)
// Instance 技术管理
type Instance struct{ *service.SessionEnterprise }
type Instance struct {
*service.SessionEnterprise
local uint64
}
type InstanceHandle func(enterprise *service.SessionEnterprise) *Instance
type InstanceHandle func(enterprise *service.SessionEnterprise, local uint64) *Instance
type (
// InstanceInfo 详细信息
@ -77,7 +80,6 @@ func (c *Instance) Form(params *InstanceParams) error {
return errors.New("操作错误,当前状态不允许修改")
}
}
mTechnologyInstance.UID = c.TenantUID
mTechnologyInstance.PatentID = params.PatentID
mTechnologyInstance.Title = params.Title
mTechnologyInstance.Company = params.Company
@ -103,6 +105,10 @@ func (c *Instance) Form(params *InstanceParams) error {
mTechnologyInstance.UpdatedAt = time.Now()
return model2.Updates(mTechnologyInstance.TechnologyInstance, mTechnologyInstance.TechnologyInstance)
}
mTechnologyInstance.UID = c.TenantUID
mTechnologyInstance.Local.Local = c.local
mTechnologyInstance.TenantID = c.TenantID
return model2.Create(mTechnologyInstance.TechnologyInstance)
}
@ -151,7 +157,7 @@ func (c *Instance) Delete(id uint64) error {
}
func NewInstance() InstanceHandle {
return func(enterprise *service.SessionEnterprise) *Instance {
return &Instance{enterprise}
return func(enterprise *service.SessionEnterprise, local uint64) *Instance {
return &Instance{enterprise, local}
}
}

View File

@ -11,9 +11,12 @@ import (
)
// Paper 论文管理
type Paper struct{ *service.SessionEnterprise }
type Paper struct {
*service.SessionEnterprise
local uint64
}
type PaperHandle func(enterprise *service.SessionEnterprise) *Paper
type PaperHandle func(enterprise *service.SessionEnterprise, local uint64) *Paper
type (
PaperInfo struct {
@ -35,6 +38,8 @@ func (c *Paper) List(title string, page, pageSize int) (*controller.ReturnPages,
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
Where: model2.NewWhere("tenant_id", c.TenantID),
Order: model2.NewOrder("id", model2.OrderModeToDesc),
}, &model2.ModelWhereOrder{
Where: model2.NewWhere("local", c.local),
}}
if title != "" {
where = append(where, &model2.ModelWhereOrder{Where: model2.NewWhereLike("title", title)})
@ -69,7 +74,6 @@ func (c *Paper) Form(params *PaperParams) error {
return errors.New("无权限操作")
}
}
mTechnologyPaper.UID = c.TenantUID
mTechnologyPaper.Title = params.Title
mTechnologyPaper.Ext = params.Ext
mTechnologyPaper.Author = params.Author
@ -79,6 +83,9 @@ func (c *Paper) Form(params *PaperParams) error {
mTechnologyPaper.Remark = params.Remark
if params.ID <= 0 {
mTechnologyPaper.TenantID = c.TenantID
mTechnologyPaper.UID = c.TenantUID
mTechnologyPaper.Local.Local = c.local
return model2.Create(mTechnologyPaper.TechnologyPaper)
}
mTechnologyPaper.UpdatedAt = time.Now()
@ -106,7 +113,7 @@ func (c *Paper) Delete(id uint64) error {
}
func NewPaper() PaperHandle {
return func(enterprise *service.SessionEnterprise) *Paper {
return &Paper{enterprise}
return func(enterprise *service.SessionEnterprise, local uint64) *Paper {
return &Paper{enterprise, local}
}
}

View File

@ -38,7 +38,7 @@ func (c *Instance) Info() *InstanceInfo {
}
// Detail 详细信息
func (c *Instance) Detail() *InstanceDetailInfo {
func (c *Instance) Detail() (*InstanceDetailInfo, error) {
resp := &InstanceDetailInfo{InstanceInfo: InstanceInfo{Name: c.Name, Identity: c.Identity, SelectIdentity: c.SelectIdentity}}
mUserTenant := model.NewUserTenant()
@ -47,18 +47,19 @@ func (c *Instance) Detail() *InstanceDetailInfo {
"email", "job", "fixed_phone", "other"},
model2.NewWhere("uid", c.UID), model2.NewWhere("identity", c.SelectIdentity))
if err != nil || !isExist {
return resp
if err != nil {
return nil, err
} else if isExist {
resp.Name = mUserTenant.Name
resp.Email = mUserTenant.Email
resp.Job = mUserTenant.Job
resp.FixedPhone = mUserTenant.FixedPhone
}
resp.Name = mUserTenant.Name
resp.Email = mUserTenant.Email
resp.Job = mUserTenant.Job
resp.FixedPhone = mUserTenant.FixedPhone
return resp
return resp, nil
}
// Switch 切换身份
func (c *Instance) Switch(identity int) error {
// SwitchIdentity 切换身份
func (c *Instance) SwitchIdentity(identity int) error {
if _, has := config.TenantUserIdentityData[identity]; !has {
return errors.New("未知的身份信息")
}