feat:完善项目
This commit is contained in:
@ -2,6 +2,7 @@ package controller
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/website/model"
|
||||
config2 "SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
@ -9,6 +10,7 @@ import (
|
||||
"SciencesServer/config"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -31,7 +33,8 @@ type (
|
||||
ActivityDetail struct {
|
||||
ID string `json:"id"`
|
||||
*model.ActivityInstanceDetail
|
||||
JoinStatus bool `json:"join_status"`
|
||||
Industry string `json:"industry"`
|
||||
IsJoin bool `json:"is_join"`
|
||||
}
|
||||
)
|
||||
|
||||
@ -70,21 +73,21 @@ func (c *Activity) Instance(title, industry string, status, page, pageSize int)
|
||||
list := make([]*ActivityInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
v.Image.Image = v.Image.Analysis(config.SystemConfig[config.SysImageDomain])
|
||||
|
||||
data := &ActivityInfo{
|
||||
ID: v.GetEncodeID(), ActivityInstanceInfo: v, IsJoin: v.JoinID > 0, Status: 2,
|
||||
}
|
||||
|
||||
if now.After(v.BeginAt) {
|
||||
if now.Before(v.BeginAt) {
|
||||
data.Status = 1
|
||||
goto CONTINUE
|
||||
}
|
||||
|
||||
if now.Before(v.FinishAt) {
|
||||
if now.After(v.FinishAt) {
|
||||
data.Status = 3
|
||||
goto CONTINUE
|
||||
}
|
||||
CONTINUE:
|
||||
|
||||
list = append(list, data)
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
@ -99,12 +102,19 @@ func (c *Activity) Detail(id uint64) (*ActivityDetail, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mActivityInstance.Image.Image = mActivityInstance.Image.Analysis(config.SystemConfig[config.SysImageDomain])
|
||||
out.Image.Image = out.Image.Analysis(config.SystemConfig[config.SysImageDomain])
|
||||
|
||||
industrys := make([]string, 0)
|
||||
|
||||
for _, v := range out.GetIndustryAttribute() {
|
||||
industrys = append(industrys, config2.GetIndustryInfo(v, "-", "-"))
|
||||
}
|
||||
|
||||
return &ActivityDetail{
|
||||
ID: out.GetEncodeID(),
|
||||
ActivityInstanceDetail: out,
|
||||
JoinStatus: out.JoinID > 0.,
|
||||
Industry: strings.Join(industrys, ";"),
|
||||
IsJoin: out.JoinID > 0.,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
59
app/api/website/controller/search.go
Normal file
59
app/api/website/controller/search.go
Normal file
@ -0,0 +1,59 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/service"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type Search struct{}
|
||||
|
||||
type SearchHandle func() *Search
|
||||
|
||||
var searchHandle = map[int]func(int, int, string, string) (interface{}, error){
|
||||
1: searchCompany,
|
||||
}
|
||||
|
||||
// searchCompany 公司搜索
|
||||
func searchCompany(page, pageSize int, keyword, industry string) (interface{}, error) {
|
||||
manage := service.NewESManage(
|
||||
service.WithManageIdentity(config.TenantUserIdentityForCompany),
|
||||
service.WithManageTitle(keyword),
|
||||
service.WithManageKeyword(keyword),
|
||||
service.WithManageResearch(keyword),
|
||||
)
|
||||
if industry != "" {
|
||||
manage.Industry = industry
|
||||
}
|
||||
out, err := manage.Search(page, pageSize, nil)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ids := make([]uint64, 0)
|
||||
|
||||
for _, v := range out.([]interface{}) {
|
||||
val := v.(*service.ESManage)
|
||||
ids = append(ids, val.ID)
|
||||
}
|
||||
if len(ids) <= 0 {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Launch 发起搜索
|
||||
func (c *Search) Launch(mode int, keyword, industry string, page, pageSize int) (interface{}, error) {
|
||||
handle, has := searchHandle[mode]
|
||||
|
||||
if !has {
|
||||
return nil, errors.New("操作错误,未知的搜索模式")
|
||||
}
|
||||
return handle(page, pageSize, keyword, industry)
|
||||
}
|
||||
|
||||
func NewSearch() SearchHandle {
|
||||
return func() *Search {
|
||||
return &Search{}
|
||||
}
|
||||
}
|
@ -14,9 +14,10 @@ type AboutHandle func(tenantID uint64) *About
|
||||
type (
|
||||
// AboutInfo 基本信息
|
||||
AboutInfo struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
Children []*AboutInfo `json:"children"`
|
||||
}
|
||||
// AboutNavigationInfo 导航栏信息
|
||||
AboutNavigationInfo struct {
|
||||
@ -25,17 +26,32 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func (c *About) tree(src []*model2.SysAbout, parentID uint64) []*AboutInfo {
|
||||
out := make([]*AboutInfo, 0)
|
||||
|
||||
for _, v := range src {
|
||||
if v.ParentID == parentID {
|
||||
out = append(out, &AboutInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
Title: v.Title,
|
||||
Content: v.Content,
|
||||
Children: nil,
|
||||
})
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// Instance 关于信息
|
||||
func (c *About) Instance(parentID uint64) (*AboutInfo, error) {
|
||||
func (c *About) Instance() ([]*AboutInfo, error) {
|
||||
mSysAbout := model.NewSysAbout()
|
||||
|
||||
if isExist, err := model2.FirstField(mSysAbout.SysAbout, []string{"id", "title", "content"},
|
||||
model2.NewWhere("parent_id", parentID)); err != nil {
|
||||
out := make([]*model2.SysAbout, 0)
|
||||
|
||||
if err := model2.ScanFields(mSysAbout.SysAbout, &out, []string{"id", "title", "content"}); err != nil {
|
||||
return nil, err
|
||||
} else if !isExist {
|
||||
return nil, nil
|
||||
}
|
||||
return &AboutInfo{ID: mSysAbout.GetEncodeID(), Title: mSysAbout.Title, Content: mSysAbout.Content}, nil
|
||||
return c.tree(out, 0), nil
|
||||
}
|
||||
|
||||
// Navigation 导航栏
|
||||
|
Reference in New Issue
Block a user