feat:完善信息

This commit is contained in:
henry
2021-10-13 17:17:28 +08:00
parent 52dc8cb57d
commit 8f7aeba547
14 changed files with 272 additions and 113 deletions

View File

@ -15,7 +15,7 @@ type InstanceLoginCallback func(params *InstanceLoginParams) *InstanceLoginRetur
type (
InstanceLoginParams struct {
UID, TenantID, TenantUID uint64
UID, TenantID, ManageUID 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.TenantUID = params.TenantUID
session.ManageUID = params.ManageUID
session.Name = params.Name
session.Mobile = params.Mobile
session.Identity = params.Identity

View File

@ -79,7 +79,7 @@ func loginForSmsCaptcha(params *LoginParams, local string) (*InstanceLoginParams
}
RETURNS:
return &InstanceLoginParams{
UID: mUserInstance.UUID, TenantID: mUserManage.TenantID, TenantUID: mUserManage.UUID,
UID: mUserInstance.UUID, TenantID: mUserManage.TenantID, ManageUID: mUserManage.UUID,
Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
Identity: mUserInstance.Identity, SelectIdentity: mUserManage.Identity,
Status: mUserInstance.Status,
@ -111,7 +111,7 @@ func loginForPassword(params *LoginParams, local string) (*InstanceLoginParams,
return nil, err
}
return &InstanceLoginParams{
UID: mUserInstance.UUID, TenantID: mUserManage.TenantID, TenantUID: mUserManage.UUID,
UID: mUserInstance.UUID, TenantID: mUserManage.TenantID, ManageUID: mUserManage.UUID,
Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
Identity: mUserInstance.Identity, SelectIdentity: mUserManage.Identity,
Status: mUserInstance.Status,

View File

@ -73,7 +73,7 @@ func (c *Instance) Form(params *InstanceParams) error {
return err
} else if !isExist {
return errors.New("信息不存在")
} else if c.TenantUID != mTechnologyInstance.UID {
} else if c.ManageUID != mTechnologyInstance.UID {
return errors.New("操作错误,无权限操作")
} else if mTechnologyInstance.Status != model2.TechnologyInstanceStatusForDraft &&
mTechnologyInstance.Status != model2.TechnologyInstanceStatusForRefuse {
@ -105,7 +105,7 @@ func (c *Instance) Form(params *InstanceParams) error {
mTechnologyInstance.UpdatedAt = time.Now()
return model2.Updates(mTechnologyInstance.TechnologyInstance, mTechnologyInstance.TechnologyInstance)
}
mTechnologyInstance.UID = c.TenantUID
mTechnologyInstance.UID = c.ManageUID
mTechnologyInstance.Local.Local = c.local
mTechnologyInstance.TenantID = c.TenantID
@ -122,7 +122,7 @@ func (c *Instance) Shelf(id uint64, status int) error {
return err
} else if !isExist {
return errors.New("信息不存在")
} else if c.TenantUID != mTechnologyInstance.UID {
} else if c.ManageUID != mTechnologyInstance.UID {
return errors.New("操作错误,无权限操作")
} else if mTechnologyInstance.Status != model2.TechnologyInstanceStatusForAgree {
return errors.New("操作错误,当前状态不允许处理上下架")
@ -147,7 +147,7 @@ func (c *Instance) Delete(id uint64) error {
return err
} else if !isExist {
return errors.New("信息不存在")
} else if c.TenantUID != mTechnologyInstance.UID {
} else if c.ManageUID != mTechnologyInstance.UID {
return errors.New("操作错误,无权限操作")
}
if err = model2.Delete(mTechnologyInstance.TechnologyInstance); err != nil {
@ -158,6 +158,6 @@ func (c *Instance) Delete(id uint64) error {
func NewInstance() InstanceHandle {
return func(enterprise *service.SessionEnterprise, local string) *Instance {
return &Instance{enterprise, local}
return &Instance{SessionEnterprise: enterprise, local: local}
}
}

View File

@ -70,7 +70,7 @@ func (c *Paper) Form(params *PaperParams) error {
return err
} else if !isExist {
return errors.New("当前论文信息不存在")
} else if mTechnologyPaper.UID != c.TenantUID {
} else if mTechnologyPaper.UID != c.ManageUID {
return errors.New("无权限操作")
}
}
@ -84,7 +84,7 @@ func (c *Paper) Form(params *PaperParams) error {
if params.ID <= 0 {
mTechnologyPaper.TenantID = c.TenantID
mTechnologyPaper.UID = c.TenantUID
mTechnologyPaper.UID = c.ManageUID
mTechnologyPaper.Local.Local = c.local
return model2.Create(mTechnologyPaper.TechnologyPaper)
}
@ -99,7 +99,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.TenantUID))
err := model2.Count(mTechnologyPaper.TechnologyPaper, &count, model2.NewWhere("id", id), model2.NewWhere("uid", c.ManageUID))
if err != nil {
return err
@ -114,6 +114,6 @@ func (c *Paper) Delete(id uint64) error {
func NewPaper() PaperHandle {
return func(enterprise *service.SessionEnterprise, local string) *Paper {
return &Paper{enterprise, local}
return &Paper{SessionEnterprise: enterprise, local: local}
}
}

View File

@ -0,0 +1,114 @@
package user
import (
model2 "SciencesServer/app/common/model"
"SciencesServer/app/enterprise/model"
"SciencesServer/app/service"
"SciencesServer/utils"
"errors"
)
type Back struct {
*service.SessionEnterprise
}
type BackHandle func(enterprise *service.SessionEnterprise) *Back
type (
// BackInfo 银行卡信息
BackInfo struct {
ID string `json:"id"`
*model2.UserManageBank
}
// BackParams 银行卡参数信息
BackParams struct {
Name, IDCard, BackCard, BackName string
}
)
// checkIDCard 验证身份证号
func (c *BackParams) checkIDCard() bool {
return utils.ValidateIDCard(c.IDCard)
}
// checkBankCard 验证银行卡号
func (c *BackParams) checkBankCard() bool {
return true
}
// List 列表信息
func (c *Back) List() ([]*BackInfo, error) {
mUserManageBack := model.NewUserManageBank()
out := make([]*model2.UserManageBank, 0)
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
Where: model2.NewWhere("uid", c.ManageUID),
Order: model2.NewOrder("is_default", model2.OrderModeToDesc),
}}
if err := model2.Find(mUserManageBack.UserManageBank, &out, where...); err != nil {
return nil, err
}
list := make([]*BackInfo, 0)
for _, v := range out {
list = append(list, &BackInfo{ID: v.GetEncodeID(), UserManageBank: v})
}
return list, nil
}
// Bind 绑定
func (c *Back) Bind(params *BackParams) error {
if !params.checkIDCard() {
return errors.New("身份证号信息错误")
}
if !params.checkBankCard() {
return errors.New("银行卡信息错误")
}
mUserManageBack := model.NewUserManageBank()
var count int64
err := model2.Count(mUserManageBack.UserManageBank, &count, model2.NewWhere("back_card", params.BackCard))
if err != nil {
return err
} else if count > 0 {
return errors.New("当前银行卡已被注册")
}
mUserManageBack.UID = c.ManageUID
mUserManageBack.Name = params.Name
mUserManageBack.IDCard = params.IDCard
mUserManageBack.BankCard = params.BackCard
mUserManageBack.BackName = params.BackName
if err = model2.Count(mUserManageBack.UserManageBank, &count, model2.NewWhere("uid", c.ManageUID)); err != nil {
return err
} else if count <= 0 {
mUserManageBack.IsDefault = model2.UserManageBankDefaultForYes
}
return model2.Create(mUserManageBack.UserManageBank)
}
// Unbind 解绑,直接删除
func (c *Back) Unbind(id uint64) error {
mUserManageBack := model.NewUserManageBank()
mUserManageBack.ID = id
isExist, err := model2.FirstField(mUserManageBack.UserManageBank, []string{"id", "uid"})
if err != nil {
return err
} else if !isExist {
return errors.New("操作错误,绑定信息不存在")
} else if mUserManageBack.UID != c.ManageUID {
return errors.New("无权限操作")
}
return model2.Delete(mUserManageBack)
}
func NewBack() BackHandle {
return func(enterprise *service.SessionEnterprise) *Back {
return &Back{enterprise}
}
}

View File

@ -83,7 +83,7 @@ func (c *Instance) SwitchIdentity(identity int) error {
if err = orm.GetDB().Transaction(func(tx *gorm.DB) error {
if err = model2.UpdatesWhere(mUserManage.UserManage, map[string]interface{}{
"selected": model2.UserManageSelectedForNo, "updated_at": now,
}, []*model2.ModelWhere{model2.NewWhere("uid", c.TenantUID)}, tx); err != nil {
}, []*model2.ModelWhere{model2.NewWhere("uid", c.ManageUID)}, tx); err != nil {
return err
}
return model2.Updates(mUserManage.UserManage, map[string]interface{}{
@ -94,7 +94,7 @@ func (c *Instance) SwitchIdentity(identity int) error {
}
}
c.TenantID = mUserManage.TenantID
c.TenantUID = mUserManage.UUID
c.ManageUID = mUserManage.UUID
}
c.SelectIdentity = identity
service.Publish(config2.EventForAccountLoginProduce, config2.RedisKeyForAccount, c.UIDToString(), c.SessionEnterprise)
@ -103,6 +103,6 @@ func (c *Instance) SwitchIdentity(identity int) error {
func NewInstance() InstanceHandle {
return func(enterprise *service.SessionEnterprise) *Instance {
return &Instance{enterprise}
return &Instance{SessionEnterprise: enterprise}
}
}

View File

@ -1,4 +1,4 @@
package tenant
package user
import (
"SciencesServer/app/basic/config"
@ -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.TenantUID, mManageCompany.ManageCompany)
err := params.effect(c.ManageUID, 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.TenantUID
mManageCompany.UID = c.ManageUID
return model2.Create(mManageCompany.ManageCompany)
}
if !params.pass(c.TenantUID, mManageCompany.UID, mManageCompany.Status) {
if !params.pass(c.ManageUID, 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.TenantUID, mManageExpert.ManageExpert)
err := params.effect(c.ManageUID, 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.TenantUID
mManageExpert.UID = c.ManageUID
return model2.Create(mManageExpert.ManageExpert)
}
if !params.pass(c.TenantUID, mManageExpert.UID, mManageExpert.Status) {
if !params.pass(c.ManageUID, 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.TenantUID, mManageResearch.ManageResearch)
err := params.effect(c.ManageUID, 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.TenantUID
mManageResearch.UID = c.ManageUID
return model2.Create(mManageResearch.ManageResearch)
}
if !params.pass(c.TenantUID, mManageResearch.UID, mManageResearch.Status) {
if !params.pass(c.ManageUID, 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.TenantUID, mManageLaboratory.ManageLaboratory)
err := params.effect(c.ManageUID, 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.TenantUID
mManageLaboratory.UID = c.ManageUID
return model2.Create(mManageLaboratory.ManageLaboratory)
}
if !params.pass(c.TenantUID, mManageLaboratory.UID, mManageLaboratory.Status) {
if !params.pass(c.ManageUID, mManageLaboratory.UID, mManageLaboratory.Status) {
return errors.New("操作错误,无权限操作")
}
mManageLaboratory.Status = model2.ExamineStatusForOngoing