feat:完善入驻信息管理

This commit is contained in:
henry
2021-12-02 09:06:15 +08:00
parent 88077da6f0
commit 30173f8dd2
3 changed files with 141 additions and 1 deletions

View File

@ -0,0 +1,49 @@
package settled
import (
"SciencesServer/app/api/enterprise/model"
"SciencesServer/app/basic/config"
model2 "SciencesServer/app/common/model"
"errors"
)
// BasicParams 基本信息
type BasicParams struct {
Name, Image, Code, Introduce string
config.Area
Industrys, Keywords []string
}
// filter 筛选信息
func (c *BasicParams) filter(identity int, where ...*model2.ModelWhere) (bool, error) {
mSysIdentity := model.NewSysIdentity()
_, err := model2.FirstField(mSysIdentity.SysIdentity, []string{"id", "register_count", "is_examine"}, model2.NewWhere("identity", identity))
if err != nil {
return true, err
}
var iModel model2.IModel
if identity&config.TenantUserIdentityForCompany > 0 {
iModel = model2.NewUserCompany()
} else if identity&config.TenantUserIdentityForExpert > 0 {
iModel = model2.NewUserExpert()
} else if identity&config.TenantUserIdentityForResearch > 0 {
iModel = model2.NewUserResearch()
} else if identity&config.TenantUserIdentityForLaboratory > 0 {
iModel = model2.NewUserLaboratory()
} else if identity&config.TenantUserIdentityForAgent > 0 {
iModel = model2.NewUserAgent()
}
var count int64
where = append(where, model2.NewWhere("status", model2.InvalidStatusForNot))
if err = model2.Count(iModel, &count, where...); err != nil {
return true, err
}
if count >= int64(mSysIdentity.RegisterCount) {
return true, errors.New("操作错误,已超过当前身份最大入驻人数")
}
return mSysIdentity.IsExamine == model2.SysIdentityExamineForYes, nil
}