feat:完善信息
This commit is contained in:
@ -83,7 +83,7 @@ func (c *Instance) List(name, mobile string, status, page, pageSize int) (*contr
|
||||
for _, v := range out {
|
||||
list = append(list, &InstanceUserInfo{SysUserTenantUser: v, UID: utils.UintToString(v.UID)})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Page: page, TotalCount: count}, nil
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// Add 添加用户
|
||||
|
@ -1,8 +1,15 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/utils"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
type UserTenant struct {
|
||||
Model
|
||||
ModelTenant
|
||||
UUID uint64 `gorm:"column:uuid;uniqueIndex:idx_user_tenant_uuid;type:int;default:0;comment:用户唯一UUID" json:"-"`
|
||||
UID uint64 `gorm:"column:uid;index:idx_user_tenant_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"`
|
||||
@ -29,6 +36,13 @@ func (m *UserTenant) TableName() string {
|
||||
return m.NewTableName("user_tenant")
|
||||
}
|
||||
|
||||
func (m *UserTenant) BeforeCreate(db *gorm.DB) error {
|
||||
snowflake, _ := utils.NewSnowflake(1)
|
||||
m.UUID = uint64(snowflake.GetID())
|
||||
m.CreatedAt = time.Now()
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewUserTenant() *UserTenant {
|
||||
return &UserTenant{}
|
||||
}
|
||||
|
@ -15,8 +15,8 @@ type InstanceLoginCallback func(params *InstanceLoginParams) *InstanceLoginRetur
|
||||
|
||||
type (
|
||||
InstanceLoginParams struct {
|
||||
UID, TenantID uint64
|
||||
Name, Mobile, Avatar string
|
||||
UID, TenantID, TenantUID uint64
|
||||
Name, Mobile string
|
||||
Identity, SelectIdentity int
|
||||
Status model.AccountStatusKind
|
||||
}
|
||||
@ -35,7 +35,7 @@ func (c *Instance) Login() InstanceLoginCallback {
|
||||
session.Token = token
|
||||
session.UID = params.UID
|
||||
session.TenantID = params.TenantID
|
||||
session.Avatar = params.Avatar
|
||||
session.TenantUID = params.TenantUID
|
||||
session.Name = params.Name
|
||||
session.Mobile = params.Mobile
|
||||
session.Identity = params.Identity
|
||||
|
@ -79,8 +79,9 @@ func loginForSmsCaptcha(params *LoginParams) (*InstanceLoginParams, error) {
|
||||
}
|
||||
RETURNS:
|
||||
return &InstanceLoginParams{
|
||||
UID: mUserInstance.UUID, TenantID: mUserTenant.TenantID, Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
|
||||
Avatar: mUserTenant.Avatar, Identity: mUserInstance.Identity, SelectIdentity: mUserTenant.Identity,
|
||||
UID: mUserInstance.UUID, TenantID: mUserTenant.TenantID, TenantUID: mUserTenant.UUID,
|
||||
Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
|
||||
Identity: mUserInstance.Identity, SelectIdentity: mUserTenant.Identity,
|
||||
Status: mUserInstance.Status,
|
||||
}, nil
|
||||
}
|
||||
@ -110,8 +111,9 @@ func loginForPassword(params *LoginParams) (*InstanceLoginParams, error) {
|
||||
return nil, err
|
||||
}
|
||||
return &InstanceLoginParams{
|
||||
UID: mUserInstance.UUID, TenantID: mUserTenant.TenantID, Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
|
||||
Avatar: mUserTenant.Avatar, Identity: mUserInstance.Identity, SelectIdentity: mUserTenant.Identity,
|
||||
UID: mUserInstance.UUID, TenantID: mUserTenant.TenantID, TenantUID: mUserTenant.UUID,
|
||||
Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
|
||||
Identity: mUserInstance.Identity, SelectIdentity: mUserTenant.Identity,
|
||||
Status: mUserInstance.Status,
|
||||
}, nil
|
||||
}
|
||||
|
@ -36,8 +36,10 @@ func (c *Instance) List(status, page, pageSize int) (*controller.ReturnPages, er
|
||||
mTechnologyInstance := model.NewTechnologyInstance()
|
||||
out := make([]*model2.TechnologyInstance, 0)
|
||||
|
||||
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{Order: model2.NewOrder("id", model2.OrderModeToDesc)}}
|
||||
|
||||
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("status", status),
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
}}
|
||||
var count int64
|
||||
|
||||
if err := model2.Pages(mTechnologyInstance.TechnologyInstance, &out, page, pageSize, &count, where...); err != nil {
|
||||
@ -68,14 +70,14 @@ func (c *Instance) Form(params *InstanceParams) error {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("信息不存在")
|
||||
} else if c.UID != mTechnologyInstance.UID {
|
||||
} else if c.TenantUID != mTechnologyInstance.UID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
} else if mTechnologyInstance.Status != model2.TechnologyInstanceStatusForDraft &&
|
||||
mTechnologyInstance.Status != model2.TechnologyInstanceStatusForRefuse {
|
||||
return errors.New("操作错误,当前状态不允许修改")
|
||||
}
|
||||
}
|
||||
mTechnologyInstance.UID = c.UID
|
||||
mTechnologyInstance.UID = c.TenantUID
|
||||
mTechnologyInstance.PatentID = params.PatentID
|
||||
mTechnologyInstance.Title = params.Title
|
||||
mTechnologyInstance.Company = params.Company
|
||||
@ -98,6 +100,7 @@ func (c *Instance) Form(params *InstanceParams) error {
|
||||
return errors.New("操作错误,状态参数错误")
|
||||
}
|
||||
if params.ID > 0 {
|
||||
mTechnologyInstance.UpdatedAt = time.Now()
|
||||
return model2.Updates(mTechnologyInstance.TechnologyInstance, mTechnologyInstance.TechnologyInstance)
|
||||
}
|
||||
return model2.Create(mTechnologyInstance.TechnologyInstance)
|
||||
@ -113,7 +116,7 @@ func (c *Instance) Shelf(id uint64, status int) error {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("信息不存在")
|
||||
} else if c.UID != mTechnologyInstance.UID {
|
||||
} else if c.TenantUID != mTechnologyInstance.UID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
} else if mTechnologyInstance.Status != model2.TechnologyInstanceStatusForAgree {
|
||||
return errors.New("操作错误,当前状态不允许处理上下架")
|
||||
@ -138,7 +141,7 @@ func (c *Instance) Delete(id uint64) error {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("信息不存在")
|
||||
} else if c.UID != mTechnologyInstance.UID {
|
||||
} else if c.TenantUID != mTechnologyInstance.UID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
if err = model2.Delete(mTechnologyInstance.TechnologyInstance); err != nil {
|
||||
|
@ -65,11 +65,11 @@ func (c *Paper) Form(params *PaperParams) error {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("当前论文信息不存在")
|
||||
} else if mTechnologyPaper.UID != c.UID {
|
||||
} else if mTechnologyPaper.UID != c.TenantUID {
|
||||
return errors.New("无权限操作")
|
||||
}
|
||||
}
|
||||
mTechnologyPaper.UID = c.UID
|
||||
mTechnologyPaper.UID = c.TenantUID
|
||||
mTechnologyPaper.Title = params.Title
|
||||
mTechnologyPaper.Ext = params.Ext
|
||||
mTechnologyPaper.Author = params.Author
|
||||
@ -92,7 +92,7 @@ func (c *Paper) Delete(id uint64) error {
|
||||
|
||||
var count int64
|
||||
|
||||
err := model2.Count(mTechnologyPaper.TechnologyPaper, &count, model2.NewWhere("id", id), model2.NewWhere("uid", c.UID))
|
||||
err := model2.Count(mTechnologyPaper.TechnologyPaper, &count, model2.NewWhere("id", id), model2.NewWhere("uid", c.TenantUID))
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -57,7 +57,7 @@ func (c *SettledParams) pass(uid, mUID uint64, mStatus model2.ExamineStatusKind)
|
||||
func (c *Settled) Company(params *SettledParams, other *config.IdentityForCompany) error {
|
||||
mManageCompany := model.NewManageCompany()
|
||||
|
||||
err := params.effect(c.UID, mManageCompany.ManageCompany)
|
||||
err := params.effect(c.TenantUID, mManageCompany.ManageCompany)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@ -73,10 +73,10 @@ func (c *Settled) Company(params *SettledParams, other *config.IdentityForCompan
|
||||
mManageCompany.Introduce = params.Introduce
|
||||
|
||||
if mManageCompany.ID <= 0 {
|
||||
mManageCompany.UID = c.UID
|
||||
mManageCompany.UID = c.TenantUID
|
||||
return model2.Create(mManageCompany.ManageCompany)
|
||||
}
|
||||
if !params.pass(c.UID, mManageCompany.UID, mManageCompany.Status) {
|
||||
if !params.pass(c.TenantUID, mManageCompany.UID, mManageCompany.Status) {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
mManageCompany.Status = model2.ExamineStatusForOngoing
|
||||
@ -87,7 +87,7 @@ func (c *Settled) Company(params *SettledParams, other *config.IdentityForCompan
|
||||
func (c *Settled) Expert(params *SettledParams, other *config.IdentityForExpert) error {
|
||||
mManageExpert := model.NewManageExpert()
|
||||
|
||||
err := params.effect(c.UID, mManageExpert.ManageExpert)
|
||||
err := params.effect(c.TenantUID, mManageExpert.ManageExpert)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@ -108,10 +108,10 @@ func (c *Settled) Expert(params *SettledParams, other *config.IdentityForExpert)
|
||||
mManageExpert.Research = utils.AnyToJSON(other.Research)
|
||||
|
||||
if mManageExpert.ID <= 0 {
|
||||
mManageExpert.UID = c.UID
|
||||
mManageExpert.UID = c.TenantUID
|
||||
return model2.Create(mManageExpert.ManageExpert)
|
||||
}
|
||||
if !params.pass(c.UID, mManageExpert.UID, mManageExpert.Status) {
|
||||
if !params.pass(c.TenantUID, mManageExpert.UID, mManageExpert.Status) {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
mManageExpert.Status = model2.ExamineStatusForOngoing
|
||||
@ -122,7 +122,7 @@ func (c *Settled) Expert(params *SettledParams, other *config.IdentityForExpert)
|
||||
func (c *Settled) Research(params *SettledParams, other *config.IdentityForResearch) error {
|
||||
mManageResearch := model.NewManageResearch()
|
||||
|
||||
err := params.effect(c.UID, mManageResearch.ManageResearch)
|
||||
err := params.effect(c.TenantUID, mManageResearch.ManageResearch)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@ -137,10 +137,10 @@ func (c *Settled) Research(params *SettledParams, other *config.IdentityForResea
|
||||
mManageResearch.Research = other.Research
|
||||
|
||||
if mManageResearch.ID <= 0 {
|
||||
mManageResearch.UID = c.UID
|
||||
mManageResearch.UID = c.TenantUID
|
||||
return model2.Create(mManageResearch.ManageResearch)
|
||||
}
|
||||
if !params.pass(c.UID, mManageResearch.UID, mManageResearch.Status) {
|
||||
if !params.pass(c.TenantUID, mManageResearch.UID, mManageResearch.Status) {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
mManageResearch.Status = model2.ExamineStatusForOngoing
|
||||
@ -151,7 +151,7 @@ func (c *Settled) Research(params *SettledParams, other *config.IdentityForResea
|
||||
func (c *Settled) Laboratory(params *SettledParams, other *config.IdentityForLaboratory) error {
|
||||
mManageLaboratory := model.NewManageLaboratory()
|
||||
|
||||
err := params.effect(c.UID, mManageLaboratory.ManageLaboratory)
|
||||
err := params.effect(c.TenantUID, mManageLaboratory.ManageLaboratory)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@ -169,10 +169,10 @@ func (c *Settled) Laboratory(params *SettledParams, other *config.IdentityForLab
|
||||
mManageLaboratory.Research = utils.AnyToJSON(other.Research)
|
||||
|
||||
if mManageLaboratory.ID <= 0 {
|
||||
mManageLaboratory.UID = c.UID
|
||||
mManageLaboratory.UID = c.TenantUID
|
||||
return model2.Create(mManageLaboratory.ManageLaboratory)
|
||||
}
|
||||
if !params.pass(c.UID, mManageLaboratory.UID, mManageLaboratory.Status) {
|
||||
if !params.pass(c.TenantUID, mManageLaboratory.UID, mManageLaboratory.Status) {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
mManageLaboratory.Status = model2.ExamineStatusForOngoing
|
||||
|
@ -72,7 +72,7 @@ func (c *Tenant) Perfect(params *TenantPerfectParams) error {
|
||||
mUserTenant := model.NewUserTenant()
|
||||
|
||||
isExist, err := model2.FirstField(mUserTenant.UserTenant, []string{"id", "name", "identity"},
|
||||
model2.NewWhere("uid", c.UID), model2.NewWhere("identity", c.Identity))
|
||||
model2.NewWhere("uid", c.TenantUID), model2.NewWhere("identity", c.Identity))
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@ -116,12 +116,12 @@ func (c *Tenant) Switch(identity int) error {
|
||||
if err = orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
if err = model2.UpdatesWhere(mUserTenant.UserTenant, map[string]interface{}{
|
||||
"selected": model2.UserTenantSelectedForNo, "updated_at": now,
|
||||
}, []*model2.ModelWhere{model2.NewWhere("uid", c.UID)}, tx); err != nil {
|
||||
}, []*model2.ModelWhere{model2.NewWhere("uid", c.TenantUID)}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
return model2.UpdatesWhere(mUserTenant.UserTenant, map[string]interface{}{
|
||||
"selected": model2.UserTenantSelectedForYes, "updated_at": now,
|
||||
}, []*model2.ModelWhere{model2.NewWhere("uid", c.UID),
|
||||
}, []*model2.ModelWhere{model2.NewWhere("uid", c.TenantUID),
|
||||
model2.NewWhere("identity", identity)}, tx)
|
||||
}); err != nil {
|
||||
return err
|
||||
|
@ -9,7 +9,7 @@ type UserTenant struct {
|
||||
}
|
||||
|
||||
func (m *UserTenant) LastChooseInfo(uid uint64) error {
|
||||
_, err := model.FirstField(m.UserTenant, []string{"id", "tenant_id", "uid", "avatar", "identity"},
|
||||
_, err := model.FirstField(m.UserTenant, []string{"id", "tenant_id", "uuid", "identity"},
|
||||
model.NewWhere("uid", uid),
|
||||
model.NewWhere("selected", model.UserTenantSelectedForYes))
|
||||
return err
|
||||
|
@ -31,9 +31,9 @@ func NewSession() *Session {
|
||||
type SessionEnterprise struct {
|
||||
UID uint64 `json:"uid"` // 唯一标识ID
|
||||
TenantID uint64 `json:"tenant_id"` // 租户ID
|
||||
TenantUID uint64 `json:"tenant_uid"` // 租户下用户唯一ID
|
||||
Token string `json:"token"` // token
|
||||
Name string `json:"name"` // 名称
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
Mobile string `json:"mobile"` // 手机号码
|
||||
Identity int `json:"identity"` // 总身份信息
|
||||
SelectIdentity int `json:"select_identity"` // 选中身份信息
|
||||
|
Reference in New Issue
Block a user