feat:完善项目
This commit is contained in:
@ -23,7 +23,7 @@ type ExamineManageInfo struct {
|
||||
}
|
||||
|
||||
// examineHandle 审核处理
|
||||
var examineHandle = map[int]func(uint64) (*ExamineManageInfo, error){
|
||||
var examineHandle = map[int]func(id, tenantID uint64) (*ExamineManageInfo, error){
|
||||
config.TenantUserIdentityForCompany: examineCompany,
|
||||
config.TenantUserIdentityForExpert: examineExpert,
|
||||
config.TenantUserIdentityForResearch: examineResearch,
|
||||
@ -33,21 +33,23 @@ var examineHandle = map[int]func(uint64) (*ExamineManageInfo, error){
|
||||
func checkManage(IModel model2.IModel, id uint64) error {
|
||||
IModel.SetID(id)
|
||||
|
||||
if isExist, err := model2.FirstField(IModel, []string{"id", "examine_status"}); err != nil {
|
||||
if isExist, err := model2.FirstField(IModel, []string{"id", "tenant_id", "examine_status"}); err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("数据信息不存在")
|
||||
return errors.New("操作错误,数据信息不存在")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func examineCompany(id uint64) (*ExamineManageInfo, error) {
|
||||
func examineCompany(id, tenantID uint64) (*ExamineManageInfo, error) {
|
||||
mManageCompany := model.NewManageCompany()
|
||||
|
||||
err := checkManage(mManageCompany.ManageCompany, id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if tenantID > 0 && mManageCompany.TenantID != tenantID {
|
||||
return nil, errors.New("操作错误,无权限操作")
|
||||
} else if mManageCompany.Examine.ExamineStatus != model2.ExamineStatusForOngoing {
|
||||
return nil, errors.New("操作错误,当前入驻信息已审核")
|
||||
}
|
||||
@ -61,13 +63,15 @@ func examineCompany(id uint64) (*ExamineManageInfo, error) {
|
||||
return &ExamineManageInfo{IModel: mManageCompany.ManageCompany, UIDs: uids}, nil
|
||||
}
|
||||
|
||||
func examineExpert(id uint64) (*ExamineManageInfo, error) {
|
||||
func examineExpert(id, tenantID uint64) (*ExamineManageInfo, error) {
|
||||
mManageExpert := model.NewManageExpert()
|
||||
|
||||
err := checkManage(mManageExpert.ManageExpert, id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if tenantID > 0 && mManageExpert.TenantID != tenantID {
|
||||
return nil, errors.New("操作错误,无权限操作")
|
||||
} else if mManageExpert.Examine.ExamineStatus != model2.ExamineStatusForOngoing {
|
||||
return nil, errors.New("操作错误,当前入驻信息已审核")
|
||||
}
|
||||
@ -81,13 +85,15 @@ func examineExpert(id uint64) (*ExamineManageInfo, error) {
|
||||
return &ExamineManageInfo{IModel: mManageExpert.ManageExpert, UIDs: uids}, nil
|
||||
}
|
||||
|
||||
func examineResearch(id uint64) (*ExamineManageInfo, error) {
|
||||
func examineResearch(id, tenantID uint64) (*ExamineManageInfo, error) {
|
||||
mManageResearch := model.NewManageResearch()
|
||||
|
||||
err := checkManage(mManageResearch.ManageResearch, id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if tenantID > 0 && mManageResearch.TenantID != tenantID {
|
||||
return nil, errors.New("操作错误,无权限操作")
|
||||
} else if mManageResearch.Examine.ExamineStatus != model2.ExamineStatusForOngoing {
|
||||
return nil, errors.New("操作错误,当前入驻信息已审核")
|
||||
}
|
||||
@ -102,13 +108,15 @@ func examineResearch(id uint64) (*ExamineManageInfo, error) {
|
||||
return &ExamineManageInfo{IModel: mManageResearch.ManageResearch, UIDs: uids}, nil
|
||||
}
|
||||
|
||||
func examineLaboratory(id uint64) (*ExamineManageInfo, error) {
|
||||
func examineLaboratory(id, tenantID uint64) (*ExamineManageInfo, error) {
|
||||
mManageLaboratory := model.NewManageLaboratory()
|
||||
|
||||
err := checkManage(mManageLaboratory.ManageLaboratory, id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if tenantID > 0 && mManageLaboratory.TenantID != tenantID {
|
||||
return nil, errors.New("操作错误,无权限操作")
|
||||
} else if mManageLaboratory.Examine.ExamineStatus != model2.ExamineStatusForOngoing {
|
||||
return nil, errors.New("操作错误,当前入驻信息已审核")
|
||||
}
|
||||
@ -123,13 +131,15 @@ func examineLaboratory(id uint64) (*ExamineManageInfo, error) {
|
||||
return &ExamineManageInfo{IModel: mManageLaboratory.ManageLaboratory, UIDs: uids}, nil
|
||||
}
|
||||
|
||||
func examineAgent(id uint64) (*ExamineManageInfo, error) {
|
||||
func examineAgent(id, tenantID uint64) (*ExamineManageInfo, error) {
|
||||
mManageAgent := model.NewManageAgent()
|
||||
|
||||
err := checkManage(mManageAgent.ManageAgent, id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if tenantID > 0 && mManageAgent.TenantID != tenantID {
|
||||
return nil, errors.New("操作错误,无权限操作")
|
||||
} else if mManageAgent.Examine.ExamineStatus != model2.ExamineStatusForOngoing {
|
||||
return nil, errors.New("操作错误,当前入驻信息已审核")
|
||||
}
|
||||
@ -149,22 +159,20 @@ func (c *Examine) Launch(id uint64, identity, status int) error {
|
||||
_status := model2.ExamineStatusKind(status)
|
||||
|
||||
if _status != model2.ExamineStatusForRefuse && _status != model2.ExamineStatusForAgree {
|
||||
return errors.New("未知的审核模式")
|
||||
return errors.New("操作错误,未知的审核模式")
|
||||
}
|
||||
handle, has := examineHandle[identity]
|
||||
|
||||
if !has {
|
||||
return errors.New("未知的身份信息")
|
||||
return errors.New("操作错误,未知的身份信息")
|
||||
}
|
||||
data, err := handle(id)
|
||||
data, err := handle(id, c.TenantID)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
if err = model2.Updates(data.IModel, map[string]interface{}{
|
||||
"examine_status": status, "updated_at": time.Now(),
|
||||
}, tx); err != nil {
|
||||
if err = model2.Updates(data.IModel, map[string]interface{}{"examine_status": status, "updated_at": time.Now()}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
// 拒绝后,不执行以下数据
|
||||
@ -181,7 +189,6 @@ func (c *Examine) Launch(id uint64, identity, status int) error {
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mUserIdentity := model.NewUserIdentity()
|
||||
|
||||
identitys := make([]*model2.UserIdentity, 0)
|
||||
@ -215,8 +222,6 @@ func (c *Examine) Launch(id uint64, identity, status int) error {
|
||||
|
||||
func NewExamine() ExamineHandle {
|
||||
return func(session *session.Admin) *Examine {
|
||||
return &Examine{
|
||||
Admin: session,
|
||||
}
|
||||
return &Examine{Admin: session}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user