init
This commit is contained in:
@ -57,7 +57,9 @@ func (c *Account) Login(account, password, captchaKey, captchaValue, equipment,
|
||||
|
||||
// Logout 退出请求
|
||||
func (c *Account) Logout() error {
|
||||
service.Publish(config.EventForRedisHashDestroy, config.RedisKeyForAccount, utils.UintToString(c.UID))
|
||||
if c.Session != nil && c.UID > 0 {
|
||||
service.Publish(config.EventForRedisHashDestroy, config.RedisKeyForAccount, utils.UintToString(c.UID))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -28,8 +28,10 @@ type ExamineManageInfo struct {
|
||||
|
||||
// examineHandle 审核处理
|
||||
var examineHandle = map[int]func(uint64) (*ExamineManageInfo, error){
|
||||
config.TenantUserIdentityForCompany: examineCompany,
|
||||
config.TenantUserIdentityForExpert: examineExpert,
|
||||
config.TenantUserIdentityForCompany: examineCompany,
|
||||
config.TenantUserIdentityForExpert: examineExpert,
|
||||
config.TenantUserIdentityForResearch: examineResearch,
|
||||
config.TenantUserIdentityForLaboratory: examineLaboratory,
|
||||
}
|
||||
|
||||
func checkManage(IModel model2.IModel, id uint64) error {
|
||||
@ -56,7 +58,7 @@ func examineCompany(id uint64) (*ExamineManageInfo, error) {
|
||||
return &ExamineManageInfo{
|
||||
IModel: mManageCompany.ManageCompany, UID: mManageCompany.UID,
|
||||
IdentityInfo: &model2.UserIdentityForCompany{
|
||||
Industry: mManageCompany.Industry, Keyword: mManageCompany.Keyword,
|
||||
Industry: mManageCompany.Industry, Keyword: mManageCompany.Keyword, CreatedAt: time.Now(),
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
@ -75,6 +77,45 @@ func examineExpert(id uint64) (*ExamineManageInfo, error) {
|
||||
IModel: mManageExpert.ManageExpert, UID: mManageExpert.UID,
|
||||
IdentityInfo: &model2.UserIdentityForExpert{
|
||||
Industry: mManageExpert.Industry, Keyword: mManageExpert.Keyword, Research: mManageExpert.Research,
|
||||
CreatedAt: time.Now(),
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func examineResearch(id uint64) (*ExamineManageInfo, error) {
|
||||
mManageResearch := model.NewManageResearch()
|
||||
|
||||
err := checkManage(mManageResearch.ManageResearch, id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if mManageResearch.Status != model2.ExamineStatusForOngoing {
|
||||
return nil, errors.New("当前入住信息已审核")
|
||||
}
|
||||
return &ExamineManageInfo{
|
||||
IModel: mManageResearch.ManageResearch, UID: mManageResearch.UID,
|
||||
IdentityInfo: &model2.UserIdentityForResearch{
|
||||
Name: mManageResearch.Name, Industry: mManageResearch.Industry, Keyword: mManageResearch.Keyword,
|
||||
Research: mManageResearch.Research, CreatedAt: time.Now(),
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func examineLaboratory(id uint64) (*ExamineManageInfo, error) {
|
||||
mManageLaboratory := model.NewManageLaboratory()
|
||||
|
||||
err := checkManage(mManageLaboratory.ManageLaboratory, id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if mManageLaboratory.Status != model2.ExamineStatusForOngoing {
|
||||
return nil, errors.New("当前入住信息已审核")
|
||||
}
|
||||
return &ExamineManageInfo{
|
||||
IModel: mManageLaboratory.ManageLaboratory, UID: mManageLaboratory.UID,
|
||||
IdentityInfo: &model2.UserIdentityForLaboratory{
|
||||
Name: mManageLaboratory.Name, Industry: mManageLaboratory.Industry, Keyword: mManageLaboratory.Keyword,
|
||||
Research: mManageLaboratory.Research, CreatedAt: time.Now(),
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
@ -96,7 +137,6 @@ func (c *Examine) Launch(id uint64, identity, status int) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
if err = model2.Updates(data.IModel, map[string]interface{}{
|
||||
"status": status, "updated_at": time.Now(),
|
||||
|
@ -1,14 +1,91 @@
|
||||
package manage
|
||||
|
||||
import "SciencesServer/app/service"
|
||||
import (
|
||||
"SciencesServer/app/api/manage/controller"
|
||||
"SciencesServer/app/api/manage/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"gorm.io/gorm"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Instance struct {
|
||||
*service.Session
|
||||
gorm.Model
|
||||
local string
|
||||
}
|
||||
|
||||
type InstanceHandle func(session *service.Session, local string) *Instance
|
||||
|
||||
type (
|
||||
// InstanceForExpert 专家信息
|
||||
InstanceForExpert struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Industry []string `json:"industry"`
|
||||
ResearchName string `json:"research_name"`
|
||||
LaboratoryName string `json:"laboratory_name"`
|
||||
Address string `json:"address"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
)
|
||||
|
||||
func (c *Instance) Company(name string, status int, page, pageSize int) {
|
||||
mManageCompany := model.NewManageCompany()
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
if name != "" {
|
||||
where = append(where, model2.NewWhereLike("name", name))
|
||||
}
|
||||
|
||||
var count int64
|
||||
|
||||
mManageCompany.Companys(page, pageSize, &count)
|
||||
}
|
||||
|
||||
// Expert 专家信息
|
||||
func (c *Instance) Expert(name string, status int, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mManageExpert := model.NewManageExpert()
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
if name != "" {
|
||||
where = append(where, model2.NewWhereLike("name", name))
|
||||
}
|
||||
var count int64
|
||||
|
||||
out, err := mManageExpert.Experts(page, pageSize, &count, where...)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*InstanceForExpert, 0)
|
||||
|
||||
for _, v := range out {
|
||||
industry := make([]string, 0)
|
||||
|
||||
for _, v := range strings.Split(v.Industry, ";") {
|
||||
industry = append(industry, config.GetIndustryInfo(v, "-"))
|
||||
}
|
||||
// 研究机构,实验室
|
||||
researchName := v.LaboratoryName
|
||||
laboratoryName := ""
|
||||
|
||||
if v.LaboratoryName != "" {
|
||||
researchName = v.ResearchName
|
||||
laboratoryName = v.LaboratoryName
|
||||
}
|
||||
list = append(list, &InstanceForExpert{ID: v.GetEncodeID(), Name: v.Name, Industry: industry,
|
||||
ResearchName: researchName, LaboratoryName: laboratoryName,
|
||||
Address: v.FormatBasic(), CreatedAt: v.CreatedAt,
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
func NewInstance() InstanceHandle {
|
||||
return func(session *service.Session, local string) *Instance {
|
||||
return &Instance{
|
||||
|
Reference in New Issue
Block a user