feat:完善入驻信息管理
This commit is contained in:
@ -6,6 +6,7 @@ import (
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/serve/orm"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
@ -34,7 +35,7 @@ var examineHandle = map[int]func(uint64) (*ExamineManageInfo, error){
|
||||
func checkManage(IModel model2.IModel, id uint64) error {
|
||||
IModel.SetID(id)
|
||||
|
||||
if isExist, err := model2.First(IModel); err != nil {
|
||||
if isExist, err := model2.FirstField(IModel, []string{"id", "examine_status"}); err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("数据信息不存在")
|
||||
@ -50,11 +51,16 @@ func examineCompany(id uint64) (*ExamineManageInfo, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if mManageCompany.Examine.ExamineStatus != model2.ExamineStatusForOngoing {
|
||||
return nil, errors.New("当前入住信息已审核")
|
||||
return nil, errors.New("操作错误,当前入驻信息已审核")
|
||||
}
|
||||
return &ExamineManageInfo{
|
||||
IModel: mManageCompany.ManageCompany,
|
||||
}, nil
|
||||
mUserCompany := model.NewUserCompany()
|
||||
uids := make([]uint64, 0)
|
||||
|
||||
if err = model2.Pluck(mUserCompany.UserCompany, "uid", &uids, model2.NewWhere("company_id", id),
|
||||
model2.NewWhere("invalid_status", model2.InvalidStatusForNot)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ExamineManageInfo{IModel: mManageCompany.ManageCompany, UIDs: uids}, nil
|
||||
}
|
||||
|
||||
func examineExpert(id uint64) (*ExamineManageInfo, error) {
|
||||
@ -65,11 +71,16 @@ func examineExpert(id uint64) (*ExamineManageInfo, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if mManageExpert.Examine.ExamineStatus != model2.ExamineStatusForOngoing {
|
||||
return nil, errors.New("当前入住信息已审核")
|
||||
return nil, errors.New("操作错误,当前入驻信息已审核")
|
||||
}
|
||||
return &ExamineManageInfo{
|
||||
IModel: mManageExpert.ManageExpert,
|
||||
}, nil
|
||||
mUserExpert := model.NewUserExpert()
|
||||
uids := make([]uint64, 0)
|
||||
|
||||
if err = model2.Pluck(mUserExpert.UserExpert, "uid", &uids, model2.NewWhere("expert_id", id),
|
||||
model2.NewWhere("invalid_status", model2.InvalidStatusForNot)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ExamineManageInfo{IModel: mManageExpert.ManageExpert, UIDs: uids}, nil
|
||||
}
|
||||
|
||||
func examineResearch(id uint64) (*ExamineManageInfo, error) {
|
||||
@ -80,11 +91,17 @@ func examineResearch(id uint64) (*ExamineManageInfo, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if mManageResearch.Examine.ExamineStatus != model2.ExamineStatusForOngoing {
|
||||
return nil, errors.New("当前入住信息已审核")
|
||||
return nil, errors.New("操作错误,当前入驻信息已审核")
|
||||
}
|
||||
return &ExamineManageInfo{
|
||||
IModel: mManageResearch.ManageResearch,
|
||||
}, nil
|
||||
|
||||
mUserResearch := model.NewUserResearch()
|
||||
uids := make([]uint64, 0)
|
||||
|
||||
if err = model2.Pluck(mUserResearch.UserResearch, "uid", &uids, model2.NewWhere("research_id", id),
|
||||
model2.NewWhere("invalid_status", model2.InvalidStatusForNot)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ExamineManageInfo{IModel: mManageResearch.ManageResearch, UIDs: uids}, nil
|
||||
}
|
||||
|
||||
func examineLaboratory(id uint64) (*ExamineManageInfo, error) {
|
||||
@ -95,11 +112,38 @@ func examineLaboratory(id uint64) (*ExamineManageInfo, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if mManageLaboratory.Examine.ExamineStatus != model2.ExamineStatusForOngoing {
|
||||
return nil, errors.New("当前入住信息已审核")
|
||||
return nil, errors.New("操作错误,当前入驻信息已审核")
|
||||
}
|
||||
return &ExamineManageInfo{
|
||||
IModel: mManageLaboratory.ManageLaboratory,
|
||||
}, nil
|
||||
|
||||
mUserLaboratory := model.NewUserLaboratory()
|
||||
uids := make([]uint64, 0)
|
||||
|
||||
if err = model2.Pluck(mUserLaboratory.UserLaboratory, "uid", &uids, model2.NewWhere("laboratory_id", id),
|
||||
model2.NewWhere("invalid_status", model2.InvalidStatusForNot)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ExamineManageInfo{IModel: mManageLaboratory.ManageLaboratory, UIDs: uids}, nil
|
||||
}
|
||||
|
||||
func examineAgent(id uint64) (*ExamineManageInfo, error) {
|
||||
mManageAgent := model.NewManageAgent()
|
||||
|
||||
err := checkManage(mManageAgent.ManageAgent, id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if mManageAgent.Examine.ExamineStatus != model2.ExamineStatusForOngoing {
|
||||
return nil, errors.New("操作错误,当前入驻信息已审核")
|
||||
}
|
||||
|
||||
mUserAgent := model.NewUserAgent()
|
||||
uids := make([]uint64, 0)
|
||||
|
||||
if err = model2.Pluck(mUserAgent.UserAgent, "uid", &uids, model2.NewWhere("laboratory_id", id),
|
||||
model2.NewWhere("invalid_status", model2.InvalidStatusForNot)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ExamineManageInfo{IModel: mManageAgent.ManageAgent, UIDs: uids}, nil
|
||||
}
|
||||
|
||||
// Launch 发起审核
|
||||
@ -121,7 +165,7 @@ func (c *Examine) Launch(id uint64, identity, status int) error {
|
||||
}
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
if err = model2.Updates(data.IModel, map[string]interface{}{
|
||||
"status": status, "updated_at": time.Now(),
|
||||
"examine_status": status, "updated_at": time.Now(),
|
||||
}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -129,30 +173,46 @@ func (c *Examine) Launch(id uint64, identity, status int) error {
|
||||
if _status == model2.ExamineStatusForRefuse {
|
||||
return nil
|
||||
}
|
||||
mUserIdentity := model.NewUserIdentity()
|
||||
|
||||
isExist := true
|
||||
|
||||
if isExist, err = model2.FirstField(mUserIdentity.UserIdentity, []string{"id", "uid"},
|
||||
model2.NewWhere("uid", 0),
|
||||
model2.NewWhere("identity", identity)); err != nil {
|
||||
return err
|
||||
}
|
||||
if !isExist {
|
||||
//mUserIdentity.UID = data.UID
|
||||
mUserIdentity.Identity = identity
|
||||
}
|
||||
// 更新账户身份信息
|
||||
mUserInstance := model.NewUserInstance()
|
||||
|
||||
if _, err = model2.FirstField(mUserInstance.UserInstance, []string{"id", "uuid", "identity"},
|
||||
model2.NewWhere("uuid", 0)); err != nil {
|
||||
users := make([]*model2.UserInstance, 0)
|
||||
|
||||
if err = model2.ScanFields(mUserInstance.UserInstance, &users, []string{"id", "uuid", "identity"},
|
||||
&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhereIn("uuid", data.UIDs),
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = model2.Updates(mUserInstance.UserInstance, map[string]interface{}{
|
||||
"identity": mUserInstance.Identity | identity, "updated_at": time.Now(),
|
||||
}, tx); err != nil {
|
||||
return err
|
||||
|
||||
mUserIdentity := model.NewUserIdentity()
|
||||
|
||||
identitys := make([]*model2.UserIdentity, 0)
|
||||
|
||||
now := time.Now()
|
||||
|
||||
snowflake, _ := utils.NewSnowflake(1)
|
||||
|
||||
for _, v := range users {
|
||||
identitys = append(identitys, &model2.UserIdentity{
|
||||
UUID: uint64(snowflake.GetID()),
|
||||
UID: v.UUID,
|
||||
Identity: identity,
|
||||
ModelAt: model2.ModelAt{
|
||||
CreatedAt: now, UpdatedAt: now,
|
||||
},
|
||||
})
|
||||
if err = model2.UpdatesWhere(mUserInstance.UserInstance, map[string]interface{}{
|
||||
"identity": mUserInstance.Identity | identity, "updated_at": now,
|
||||
}, []*model2.ModelWhere{
|
||||
model2.NewWhere("id", v.ID),
|
||||
}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if len(identitys) > 0 {
|
||||
if err = model2.Creates(mUserIdentity.UserIdentity, identity, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
11
app/api/manage/model/manage_agent.go
Normal file
11
app/api/manage/model/manage_agent.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type ManageAgent struct {
|
||||
*model.ManageAgent
|
||||
}
|
||||
|
||||
func NewManageAgent() *ManageAgent {
|
||||
return &ManageAgent{model.NewManageAgent()}
|
||||
}
|
11
app/api/manage/model/user_agent.go
Normal file
11
app/api/manage/model/user_agent.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type UserAgent struct {
|
||||
*model.UserAgent
|
||||
}
|
||||
|
||||
func NewUserAgent() *UserAgent {
|
||||
return &UserAgent{model.NewUserAgent()}
|
||||
}
|
11
app/api/manage/model/user_company.go
Normal file
11
app/api/manage/model/user_company.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type UserCompany struct {
|
||||
*model.UserCompany
|
||||
}
|
||||
|
||||
func NewUserCompany() *UserCompany {
|
||||
return &UserCompany{model.NewUserCompany()}
|
||||
}
|
11
app/api/manage/model/user_expert.go
Normal file
11
app/api/manage/model/user_expert.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type UserExpert struct {
|
||||
*model.UserExpert
|
||||
}
|
||||
|
||||
func NewUserExpert() *UserExpert {
|
||||
return &UserExpert{model.NewUserExpert()}
|
||||
}
|
11
app/api/manage/model/user_laboratory.go
Normal file
11
app/api/manage/model/user_laboratory.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type UserLaboratory struct {
|
||||
*model.UserLaboratory
|
||||
}
|
||||
|
||||
func NewUserLaboratory() *UserLaboratory {
|
||||
return &UserLaboratory{model.NewUserLaboratory()}
|
||||
}
|
11
app/api/manage/model/user_research.go
Normal file
11
app/api/manage/model/user_research.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type UserResearch struct {
|
||||
*model.UserResearch
|
||||
}
|
||||
|
||||
func NewUserResearch() *UserResearch {
|
||||
return &UserResearch{model.NewUserResearch()}
|
||||
}
|
Reference in New Issue
Block a user