feat:完善信息
This commit is contained in:
@ -30,6 +30,13 @@ func GetSession() ApiHandle {
|
||||
}
|
||||
}
|
||||
|
||||
func GetLocal() ApiHandle {
|
||||
return func(c *gin.Context) interface{} {
|
||||
value, _ := c.Get(config.ContentForLocal)
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
||||
func Bind(req interface{}) ApiHandle {
|
||||
return func(c *gin.Context) interface{} {
|
||||
var err error
|
||||
|
@ -8,8 +8,8 @@ import (
|
||||
// ManageExpert 专家入驻信息管理
|
||||
type ManageExpert struct {
|
||||
Model
|
||||
Local
|
||||
ModelTenant
|
||||
Local
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
Area
|
||||
Position string `gorm:"column:position;type:varchar(50);default:null;comment:坐标" json:"-"`
|
||||
|
@ -7,8 +7,8 @@ import (
|
||||
// ManageLaboratory 实验室信息管理
|
||||
type ManageLaboratory struct {
|
||||
Model
|
||||
Local
|
||||
ModelTenant
|
||||
Local
|
||||
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"`
|
||||
Code string `gorm:"column:code;type:varchar(30);default:null;comment:信用代码" json:"code"`
|
||||
|
@ -6,6 +6,7 @@ import "SciencesServer/utils"
|
||||
type TechnologyInstance struct {
|
||||
Model
|
||||
ModelTenant
|
||||
Local
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
PatentID uint64 `gorm:"column:patent_id;type:int;default:0;comment:代表专利" json:"patent_id"`
|
||||
Title string `gorm:"column:title;type:varchar(30);default:null;comment:名称" json:"title"`
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
type TechnologyPaper struct {
|
||||
Model
|
||||
ModelTenant
|
||||
Local
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
Title string `gorm:"column:title;type:varchar(100);default:null;comment:题目" json:"title"`
|
||||
Ext string `gorm:"column:ext;type:varchar(30);default:null;comment:引用格式" json:"ext"`
|
||||
|
@ -14,25 +14,19 @@ func (a *User) Info(c *gin.Context) {
|
||||
api.APISuccess(data)
|
||||
}
|
||||
|
||||
func (a *User) Perfect(c *gin.Context) {
|
||||
func (a *User) Detail(c *gin.Context) {
|
||||
data, err := user.NewInstance()(api.GetSession()(c).(*service.SessionEnterprise)).Detail()
|
||||
api.APIResponse(err, data)
|
||||
}
|
||||
|
||||
func (a *User) SwitchIdentity(c *gin.Context) {
|
||||
form := &struct {
|
||||
Name string `json:"name" form:"name" binding:"required"` // 名称
|
||||
Email string `json:"email" form:"email" binding:"required"` // 邮箱
|
||||
Job string `json:"job" form:"job" binding:"required"` // 职务
|
||||
FixedPhone string `json:"fixed_phone" form:"fixed_phone" ` // 固定电话
|
||||
Identity int `json:"identity" form:"identity" binding:"required"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := user.NewTenant()(api.GetSession()(c).(*service.SessionEnterprise)).Perfect(&user.TenantPerfectParams{
|
||||
TenantBasicParams: &user.TenantBasicParams{
|
||||
Name: form.Name, Email: form.Email, Job: form.Job, FixedPhone: form.FixedPhone,
|
||||
},
|
||||
})
|
||||
err := user.NewInstance()(api.GetSession()(c).(*service.SessionEnterprise)).SwitchIdentity(form.Identity)
|
||||
api.APIResponse(err)
|
||||
}
|
||||
|
||||
func (a *User) SwitchIdentity(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
@ -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}
|
||||
}
|
||||
}
|
||||
|
@ -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}
|
||||
}
|
||||
}
|
||||
|
@ -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("未知的身份信息")
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ const (
|
||||
const (
|
||||
TokenForUID string = "uid"
|
||||
TokenForSession string = "session"
|
||||
ContentForLocal string = "local"
|
||||
)
|
||||
|
||||
const (
|
||||
|
Reference in New Issue
Block a user