feat:完善网站信息

This commit is contained in:
henry
2021-12-22 14:11:14 +08:00
parent b0a9ef3569
commit 332f67d1c1
14 changed files with 637 additions and 28 deletions

View File

@ -0,0 +1,121 @@
package manage
import (
"SciencesServer/app/api/website/model"
"SciencesServer/app/basic/config"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/service"
"errors"
)
type Search struct{}
type SearchHandle func() *Search
type (
// SearchParams 搜索参数
SearchParams struct {
}
)
// searchIdentityHandle 搜索信息处理
var searchIdentityHandle = map[int]func(ids []uint64) (interface{}, error){
config.TenantUserIdentityForCompany: company,
config.TenantUserIdentityForExpert: company,
config.TenantUserIdentityForResearch: company,
config.TenantUserIdentityForLaboratory: company,
config.TenantUserIdentityForAgent: company,
}
func company(ids []uint64) (interface{}, error) {
mManageCompany := model.NewManageCompany()
out := make([]*model2.ManageCompany, 0)
if err := model2.ScanFields(mManageCompany.ManageCompany, &out, []string{}, &model2.ModelWhereOrder{
Where: model2.NewWhereIn("id", ids),
Order: model2.NewOrder("id", model2.OrderModeToDesc),
}, &model2.ModelWhereOrder{
Where: model2.NewWhere("examine_status", model2.ExamineStatusForAgree),
}); err != nil {
return nil, err
}
return out, nil
}
func expert(ids []uint64) (interface{}, error) {
mManageCompany := model.NewManageCompany()
out := make([]*model2.ManageCompany, 0)
if err := model2.ScanFields(mManageCompany.ManageCompany, &out, []string{}, &model2.ModelWhereOrder{
Where: model2.NewWhereIn("id", ids),
Order: model2.NewOrder("id", model2.OrderModeToDesc),
}, &model2.ModelWhereOrder{
Where: model2.NewWhere("examine_status", model2.ExamineStatusForAgree),
}); err != nil {
return nil, err
}
return out, nil
}
func research(ids []uint64) (interface{}, error) {
mManageCompany := model.NewManageCompany()
out := make([]*model2.ManageCompany, 0)
if err := model2.ScanFields(mManageCompany.ManageCompany, &out, []string{}, &model2.ModelWhereOrder{
Where: model2.NewWhereIn("id", ids),
Order: model2.NewOrder("id", model2.OrderModeToDesc),
}, &model2.ModelWhereOrder{
Where: model2.NewWhere("examine_status", model2.ExamineStatusForAgree),
}); err != nil {
return nil, err
}
return out, nil
}
func laboratory(ids []uint64) (interface{}, error) {
mManageCompany := model.NewManageCompany()
out := make([]*model2.ManageCompany, 0)
if err := model2.ScanFields(mManageCompany.ManageCompany, &out, []string{}, &model2.ModelWhereOrder{
Where: model2.NewWhereIn("id", ids),
Order: model2.NewOrder("id", model2.OrderModeToDesc),
}, &model2.ModelWhereOrder{
Where: model2.NewWhere("examine_status", model2.ExamineStatusForAgree),
}); err != nil {
return nil, err
}
return out, nil
}
func (c *Search) Launch(identity int, params string) (interface{}, error) {
manage := service.NewManage()
_params := map[string]interface{}{
"title": params, "keyword": params, "research": params,
}
data, err := manage.Search(_params)
if err != nil {
return nil, err
}
ids := make([]uint64, 0)
for _, v := range data.([]*service.Manage) {
if v.Identity != identity {
continue
}
ids = append(ids, v.ID)
}
handle, has := searchIdentityHandle[identity]
if !has {
return nil, errors.New("操作错误,未知的身份信息")
}
return handle(ids)
}
func NewSearch() SearchHandle {
return func() *Search {
return &Search{}
}
}

View File

@ -0,0 +1,100 @@
package technology
import (
"SciencesServer/app/api/website/model"
"SciencesServer/app/basic/controller"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/session"
"errors"
"fmt"
"time"
)
type Demand struct {
*session.Enterprise
}
type DemandHandle func(session *session.Enterprise) *Demand
type (
// DemandInfo 需求基本信息
DemandInfo struct {
ID string `json:"id"`
Kinds []string `json:"kinds"`
Industrys []string `json:"industrys"`
Deadline time.Time `json:"deadline"`
}
// DemandDetailInfo 需求详细信息
DemandDetailInfo struct {
ID string `json:"id"`
*model2.TechnologyDemand
Kinds []string `json:"kinds"`
Industrys []string `json:"industrys"`
}
)
// Instance 需求信息
func (c *Demand) Instance(title, industry, kind string, page, pageSize int) (*controller.ReturnPages, error) {
mTechnologyDemand := model.NewTechnologyDemand()
out := make([]*model2.TechnologyDemand, 0)
var count int64
where := []*model2.ModelWhereOrder{
&model2.ModelWhereOrder{
Where: model2.NewWhere("status", model2.TechnologyDemandStatusForAgree),
Order: model2.NewOrder("id", model2.OrderModeToDesc),
},
}
if title != "" {
where = append(where, &model2.ModelWhereOrder{Where: model2.NewWhere("title", title)})
}
if industry != "" {
where = append(where, &model2.ModelWhereOrder{Where: model2.NewWhereCondition("industry", "LIKE",
"%"+fmt.Sprintf(`"%v`, industry)+"%")})
}
if kind != "" {
where = append(where, &model2.ModelWhereOrder{Where: model2.NewWhereLike("kind", kind)})
}
err := model2.PagesFields(mTechnologyDemand.TechnologyDemand, &out, []string{}, page, pageSize, &count, where...)
if err != nil {
return nil, err
}
list := make([]*DemandInfo, 0)
for _, v := range out {
list = append(list, &DemandInfo{
ID: v.GetEncodeID(), Kinds: v.GetKindAttribute(),
Industrys: v.GetIndustryAttribute(), Deadline: v.Deadline,
})
}
return &controller.ReturnPages{Data: list, Count: count}, nil
}
// Detail 详细信息
func (c *Demand) Detail(id uint64) (*DemandDetailInfo, error) {
mTechnologyDemand := model.NewTechnologyDemand()
mTechnologyDemand.ID = id
isExist, err := model2.First(mTechnologyDemand.TechnologyDemand)
if err != nil {
return nil, err
} else if !isExist {
return nil, errors.New("操作错误,需求信息不存在或已被删除")
}
return &DemandDetailInfo{
ID: mTechnologyDemand.GetEncodeID(),
TechnologyDemand: mTechnologyDemand.TechnologyDemand,
Kinds: mTechnologyDemand.GetKindAttribute(),
Industrys: mTechnologyDemand.GetIndustryAttribute(),
}, nil
}
func NewDemand() DemandHandle {
return func(session *session.Enterprise) *Demand {
return &Demand{Enterprise: session}
}
}

View File

@ -0,0 +1,78 @@
package technology
import (
"SciencesServer/app/api/website/model"
"SciencesServer/app/basic/controller"
model2 "SciencesServer/app/common/model"
"errors"
"fmt"
)
type Patent struct{}
type PatentHandle func() *Patent
type (
// PatentInfo 专利信息
PatentInfo struct {
ID string `json:"id"`
*model.SysPatentInfo
}
// PatentDetailInfo 专利详细信息
PatentDetailInfo struct {
ID string `json:"id"`
*model2.SysPatent
}
)
// Instance 查询信息
func (c *Patent) Instance(title, industry string, page, pageSize int) (*controller.ReturnPages, error) {
mSysPatent := model.NewSysPatent()
where := make([]*model2.ModelWhere, 0)
if title != "" {
where = append(where, model2.NewWhereLike("p.title", title))
}
if industry != "" {
where = append(where, model2.NewWhereCondition("c.industry_detail", "LIKE",
"%"+fmt.Sprintf(`"%v`, industry)+"%"))
}
var count int64
out, err := mSysPatent.Patent(page, pageSize, &count, where...)
if err != nil {
return nil, err
}
list := make([]*PatentInfo, 0)
for _, v := range out {
list = append(list, &PatentInfo{
ID: v.GetEncodeID(),
SysPatentInfo: v,
})
}
return &controller.ReturnPages{Data: list, Count: count}, nil
}
// Detail 详细信息
func (c *Patent) Detail(id uint64) (*PatentDetailInfo, error) {
mSysPatent := model.NewSysPatent()
mSysPatent.ID = id
isExist, err := model2.First(mSysPatent.SysPatent)
if err != nil {
return nil, err
} else if !isExist {
return nil, errors.New("操作错误,专利信息不存在或已被删除")
}
return &PatentDetailInfo{ID: mSysPatent.GetEncodeID(), SysPatent: mSysPatent.SysPatent}, nil
}
func NewPatent() PatentHandle {
return func() *Patent {
return &Patent{}
}
}