feat:完善项目信息
This commit is contained in:
@ -37,9 +37,9 @@ type (
|
||||
}
|
||||
// InstanceParams 活动参数信息
|
||||
InstanceParams struct {
|
||||
ID, ApplyID, TenantID uint64
|
||||
Title, Contact, ContactMobile, Image, Content string
|
||||
BeginAt, FinishAt, JoinDeadline string
|
||||
ID, ApplyID, TenantID uint64
|
||||
Title, Contact, ContactMobile, Image, Description, Content string
|
||||
BeginAt, FinishAt, JoinDeadline string
|
||||
config.Area
|
||||
Industrys []string
|
||||
Amount float64
|
||||
@ -157,6 +157,7 @@ func (c *Instance) Form(params *InstanceParams) error {
|
||||
mActivityInstance.NotifyCrowd = params.NotifyCrowd
|
||||
mActivityInstance.IsHome = params.IsHome
|
||||
mActivityInstance.Sort = params.Sort
|
||||
mActivityInstance.Description = params.Description
|
||||
mActivityInstance.Content = params.Content
|
||||
mActivityInstance.Status = model2.ActivityInstanceStatus(params.Status)
|
||||
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"strings"
|
||||
"time"
|
||||
@ -20,40 +21,120 @@ type Instance struct {
|
||||
type InstanceHandle func(session *session.Admin, tenantID uint64) *Instance
|
||||
|
||||
type (
|
||||
// InstanceForCompany 公司企业信息
|
||||
InstanceForCompany struct {
|
||||
ID string `json:"id"`
|
||||
*model.ManageCompanyInfo
|
||||
Industrys []string `json:"industrys"`
|
||||
Area string `json:"area"`
|
||||
}
|
||||
// InstanceForCompanyDetail 公司企业详细信息
|
||||
InstanceForCompanyDetail struct {
|
||||
ID string `json:"id"`
|
||||
*model2.ManageCompany
|
||||
Industrys []string `json:"industrys"`
|
||||
Keywords []string `json:"keywords"`
|
||||
Directions []string `json:"directions"`
|
||||
Area string `json:"area"`
|
||||
}
|
||||
// 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"`
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Industrys []string `json:"industrys"`
|
||||
ResearchName string `json:"research_name"`
|
||||
LaboratoryName string `json:"laboratory_name"`
|
||||
Address string `json:"address"`
|
||||
ExamineStatus model2.ExamineStatusKind `json:"examine_status"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Area string `json:"area"`
|
||||
}
|
||||
// InstanceForExpertDetail 专家详细信息
|
||||
InstanceForExpertDetail struct {
|
||||
ID string `json:"id"`
|
||||
*model2.ManageExpert
|
||||
Industrys []string `json:"industrys"`
|
||||
Keywords []string `json:"keywords"`
|
||||
Researchs []string `json:"researchs"`
|
||||
Area string `json:"area"`
|
||||
}
|
||||
)
|
||||
|
||||
func (c *Instance) Company(name string, status int, page, pageSize int) {
|
||||
// Company 公司企业信息
|
||||
func (c *Instance) Company(tenantID uint64, name string, status int, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mManageCompany := model.NewManageCompany()
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
if name != "" {
|
||||
where = append(where, model2.NewWhereLike("name", name))
|
||||
if c.TenantID > 0 {
|
||||
where = append(where, model2.NewWhere("c.tenant_id", c.TenantID))
|
||||
}
|
||||
if tenantID > 0 {
|
||||
where = append(where, model2.NewWhere("c.tenant_id", tenantID))
|
||||
}
|
||||
if name != "" {
|
||||
where = append(where, model2.NewWhereLike("c.name", name))
|
||||
}
|
||||
if status > 0 {
|
||||
where = append(where, model2.NewWhere("c.examine_status", status))
|
||||
}
|
||||
|
||||
var count int64
|
||||
|
||||
mManageCompany.Companys(page, pageSize, &count)
|
||||
out, err := mManageCompany.Companys(page, pageSize, &count)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := make([]*InstanceForCompany, 0)
|
||||
|
||||
for _, v := range out {
|
||||
mManageCompany.Industry = v.Industry
|
||||
|
||||
list = append(list, &InstanceForCompany{
|
||||
ID: v.GetEncodeID(), ManageCompanyInfo: v, Industrys: mManageCompany.GetIndustryAttribute(), Area: v.FormatBasic(),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// CompanyDetail 公司企业详细信息
|
||||
func (c *Instance) CompanyDetail(id uint64) (*InstanceForCompanyDetail, error) {
|
||||
mManageCompany := model.NewManageCompany()
|
||||
|
||||
out, err := mManageCompany.Company(id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if out.ManageCompany == nil {
|
||||
return nil, errors.New("操作错误,公司企业信息不存在或已被删除")
|
||||
}
|
||||
return &InstanceForCompanyDetail{
|
||||
ID: out.GetEncodeID(),
|
||||
ManageCompany: out.ManageCompany,
|
||||
Industrys: out.GetIndustryAttribute(),
|
||||
Keywords: out.GetKeywordAttribute(),
|
||||
Area: out.FormatBasic(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Expert 专家信息
|
||||
func (c *Instance) Expert(name string, status int, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
func (c *Instance) Expert(tenantID uint64, name string, examineStatus int, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mManageExpert := model.NewManageExpert()
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
if c.TenantID > 0 {
|
||||
where = append(where, model2.NewWhere("e.tenant_id", c.TenantID))
|
||||
}
|
||||
if tenantID > 0 {
|
||||
where = append(where, model2.NewWhere("e.tenant_id", tenantID))
|
||||
}
|
||||
if name != "" {
|
||||
where = append(where, model2.NewWhereLike("name", name))
|
||||
where = append(where, model2.NewWhereLike("e.name", name))
|
||||
}
|
||||
if examineStatus > 0 {
|
||||
where = append(where, model2.NewWhere("e.examine_status", examineStatus))
|
||||
}
|
||||
var count int64
|
||||
|
||||
@ -65,27 +146,41 @@ func (c *Instance) Expert(name string, status int, page, pageSize int) (*control
|
||||
list := make([]*InstanceForExpert, 0)
|
||||
|
||||
for _, v := range out {
|
||||
industry := make([]string, 0)
|
||||
_industrys := make([]string, 0)
|
||||
|
||||
for _, v := range strings.Split(v.Industry, ";") {
|
||||
industry = append(industry, config.GetIndustryInfo(v, "-", "/"))
|
||||
_industrys = append(_industrys, 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,
|
||||
list = append(list, &InstanceForExpert{ID: v.GetEncodeID(), Name: v.Name, Industrys: _industrys,
|
||||
ResearchName: v.ResearchName, LaboratoryName: v.LaboratoryName, ExamineStatus: v.ExamineStatus,
|
||||
Address: v.FormatBasic(), CreatedAt: v.CreatedAt, Area: v.FormatBasic(),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// ExpertDetail 专家详细信息
|
||||
func (*Instance) ExpertDetail(id uint64) (*InstanceForExpertDetail, error) {
|
||||
mManageExpert := model.NewManageExpert()
|
||||
|
||||
out, err := mManageExpert.Expert(id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if out.ManageExpert == nil {
|
||||
return nil, errors.New("操作错误,专家信息不存在或已被删除")
|
||||
}
|
||||
return &InstanceForExpertDetail{
|
||||
ID: out.GetEncodeID(),
|
||||
ManageExpert: out.ManageExpert,
|
||||
Industrys: out.GetIndustryAttribute(),
|
||||
Keywords: out.GetKeywordAttribute(),
|
||||
Researchs: out.GetResearchAttribute(),
|
||||
Area: out.FormatBasic(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewInstance() InstanceHandle {
|
||||
return func(session *session.Admin, tenantID uint64) *Instance {
|
||||
return &Instance{
|
||||
|
Reference in New Issue
Block a user