feat:完善项目管理,增加网站首页接口信息
This commit is contained in:
@ -27,8 +27,8 @@ type (
|
||||
Status model.AccountStatusKind
|
||||
}
|
||||
InstanceLoginReturn struct {
|
||||
Token string `json:"token"`
|
||||
EffectTime int `json:"effect_time"`
|
||||
Token string `json:"token"`
|
||||
TokenEffectTime int `json:"token_effect_time"`
|
||||
}
|
||||
)
|
||||
|
||||
@ -51,7 +51,7 @@ func (c *Instance) Login() InstanceLoginCallback {
|
||||
|
||||
service.Publish(config.EventForRedisHashProduce, config.RedisKeyForAccount, _session.UIDToString(), _session)
|
||||
|
||||
return &InstanceLoginReturn{Token: token, EffectTime: config.SettingInfo.TokenEffectTime}
|
||||
return &InstanceLoginReturn{Token: token, TokenEffectTime: config.SettingInfo.TokenEffectTime}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ func (m *ActivityInstance) Joins(page, pageSize int, count *int64, where ...*mod
|
||||
Where("j.status = ?", model.ActivityJoinStatusForSuccess)
|
||||
|
||||
if len(where) > 0 {
|
||||
` for _, v := range where {
|
||||
for _, v := range where {
|
||||
db = db.Where(v.Condition, v.Value)
|
||||
}
|
||||
}
|
||||
@ -39,7 +39,7 @@ func (m *ActivityInstance) Joins(page, pageSize int, count *int64, where ...*mod
|
||||
if err := db.Order("j.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil`
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func NewActivityInstance() *ActivityInstance {
|
||||
|
1
app/api/website/api/docking.go
Normal file
1
app/api/website/api/docking.go
Normal file
@ -0,0 +1 @@
|
||||
package api
|
@ -1,7 +1,14 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/website/controller"
|
||||
"SciencesServer/app/basic/api"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type Index struct{}
|
||||
|
||||
func (*Index) Instance() {
|
||||
|
||||
func (*Index) Instance(c *gin.Context) {
|
||||
data, err := controller.NewIndex()(nil, "").Instance()
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
13
app/api/website/controller/docking.go
Normal file
13
app/api/website/controller/docking.go
Normal file
@ -0,0 +1,13 @@
|
||||
package controller
|
||||
|
||||
type Docking struct{}
|
||||
|
||||
type DockingHandle func()
|
||||
|
||||
func (c *Docking) Message() {
|
||||
|
||||
}
|
||||
|
||||
func NewDocking() DockingHandle {
|
||||
return nil
|
||||
}
|
@ -4,6 +4,9 @@ import (
|
||||
"SciencesServer/app/api/website/model"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/config"
|
||||
"SciencesServer/utils"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Index struct {
|
||||
@ -17,18 +20,91 @@ type (
|
||||
// InstanceInfo 首页信息
|
||||
InstanceInfo struct {
|
||||
*InstanceStaticInfo
|
||||
Distribution map[string]*InstanceDistributionInfo `json:"distribution"`
|
||||
Distribution *InstanceDistributionInfo `json:"distribution"`
|
||||
}
|
||||
// InstanceStaticInfo 统计信息
|
||||
InstanceStaticInfo struct {
|
||||
ExpertCount int64 `json:"expert_count"`
|
||||
CompanyCount int64 `json:"company_count"`
|
||||
ExpertCount int64 `json:"expert_count"` // 专家数量
|
||||
CompanyCount int64 `json:"company_count"` // 公司数量
|
||||
PatentCount int64 `json:"patent_count"` // 专利数量
|
||||
AchievementCount int64 `json:"achievement_count"` // 成果数量
|
||||
DemandCount int64 `json:"demand_count"` // 需求数量
|
||||
DockingCount int64 `json:"docking_count"` // 对接数量
|
||||
}
|
||||
// InstanceDistributionInfo 分布信息
|
||||
InstanceDistributionInfo struct {
|
||||
Expert map[string]*InstanceDistributionDetailInfo `json:"expert"` // 专家信息
|
||||
Laboratory map[string]*InstanceDistributionDetailInfo `json:"laboratory"` // 公司信息
|
||||
Demand map[string]*InstanceDistributionDetailInfo `json:"demand"` // 专利信息
|
||||
Patent map[string]*InstanceDistributionDetailInfo `json:"patent"` // 成果信息
|
||||
Achievement map[string]*InstanceDistributionDetailInfo `json:"achievement"` // 需求信息
|
||||
}
|
||||
// InstanceDistributionDetailInfo 分布区域信息
|
||||
InstanceDistributionDetailInfo struct {
|
||||
Code string `json:"code"` // 区域编码
|
||||
Name string `json:"name"` // 区域名称
|
||||
Count int `json:"count"` // 数量
|
||||
Industry map[string]int `json:"industry"` // 行业领域
|
||||
Children map[string]*InstanceDistributionDetailInfo `json:"children"` // 子集信息
|
||||
}
|
||||
)
|
||||
|
||||
// industry 所属行业信息
|
||||
func (c *Index) industry(src, sep string) map[string]int {
|
||||
values := strings.Split(src, sep)
|
||||
|
||||
out := make(map[string]int, 0)
|
||||
|
||||
for _, value := range values {
|
||||
_values := make([]string, 0)
|
||||
_ = utils.FromJSON(value, &_values)
|
||||
|
||||
for _, v := range _values {
|
||||
if _, has := out[v]; has {
|
||||
out[v]++
|
||||
continue
|
||||
}
|
||||
out[v] = 1
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// distribution 分布统计
|
||||
func (c *Index) distribution(src []*model.DataAreaDistributionInfo) map[string]*InstanceDistributionDetailInfo {
|
||||
out := make(map[string]*InstanceDistributionDetailInfo, 0)
|
||||
|
||||
for _, v := range src {
|
||||
industrys := c.industry(v.Industry, "&")
|
||||
|
||||
_, has := out[v.Province]
|
||||
|
||||
if !has {
|
||||
out[v.Province] = &InstanceDistributionDetailInfo{
|
||||
Code: v.Province,
|
||||
Name: config.SettingAreaInfo[config.DefaultChinaAreaCode][v.Province],
|
||||
Industry: nil,
|
||||
Count: 1,
|
||||
Children: make(map[string]*InstanceDistributionDetailInfo, 0),
|
||||
}
|
||||
goto NEXT
|
||||
}
|
||||
out[v.Province].Count++
|
||||
NEXT:
|
||||
if _, has = out[v.Province].Children[v.City]; !has {
|
||||
out[v.Province].Children[v.City] = &InstanceDistributionDetailInfo{
|
||||
Code: v.City,
|
||||
Count: 1,
|
||||
Name: config.SettingAreaInfo[v.Province][v.City],
|
||||
Industry: industrys,
|
||||
}
|
||||
continue
|
||||
}
|
||||
out[v.Province].Children[v.City].Count++
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// static 数量统计
|
||||
func (c *Index) static() (*InstanceStaticInfo, error) {
|
||||
out := new(InstanceStaticInfo)
|
||||
@ -40,29 +116,127 @@ func (c *Index) static() (*InstanceStaticInfo, error) {
|
||||
return nil, err
|
||||
}
|
||||
// 专利信息
|
||||
mSysPatent := model.NewSysPatent()
|
||||
|
||||
if err = model2.Count(mSysPatent.SysPatent, &out.PatentCount, model2.NewWhere("shelf_status", model2.ShelfStatusForUp)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//成果信息
|
||||
mTechnologyAchievement := model.NewTechnologyAchievement()
|
||||
|
||||
if err = model2.Count(mTechnologyAchievement.TechnologyAchievement, &out.AchievementCount, model2.NewWhere("shelf_status", model2.ShelfStatusForUp),
|
||||
model2.NewWhere("status", model2.TechnologyAchievementStatusForAgree)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 公司信息
|
||||
mManageCompany := model.NewManageCompany()
|
||||
|
||||
if err = model2.Count(mManageCompany.ManageCompany, &out.CompanyCount, model2.NewWhere("examine_status", model2.ExamineStatusForAgree)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 需求信息
|
||||
mTechnologyDemand := model.NewTechnologyDemand()
|
||||
|
||||
if err = model2.Count(mTechnologyDemand.TechnologyDemand, &out.DemandCount,
|
||||
model2.NewWhere("status", model2.TechnologyDemandStatusForAgree)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 对接信息
|
||||
mServiceDocking := model.NewServiceDocking()
|
||||
|
||||
if err = model2.Count(mServiceDocking.ServiceDocking, &out.DockingCount); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *Index) distributionExpert() {
|
||||
// distributionExpert 专家分布
|
||||
func (c *Index) distributionExpert() (map[string]*InstanceDistributionDetailInfo, error) {
|
||||
mManageExpert := model.NewManageExpert()
|
||||
out, err := mManageExpert.Distribution()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c.distribution(out), nil
|
||||
}
|
||||
|
||||
// distributionLaboratory 实验室分布
|
||||
func (c *Index) distributionLaboratory() (map[string]*InstanceDistributionDetailInfo, error) {
|
||||
mManageLaboratory := model.NewManageLaboratory()
|
||||
out, err := mManageLaboratory.Distribution()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c.distribution(out), nil
|
||||
}
|
||||
|
||||
// distributionDemand 需求信息
|
||||
func (c *Index) distributionDemand() (map[string]*InstanceDistributionDetailInfo, error) {
|
||||
mTechnologyDemand := model.NewTechnologyDemand()
|
||||
out, err := mTechnologyDemand.Distribution()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c.distribution(out), nil
|
||||
}
|
||||
|
||||
// distributionPatent 专利信息
|
||||
func (c *Index) distributionPatent() (map[string]*InstanceDistributionDetailInfo, error) {
|
||||
mSysPatent := model.NewSysPatent()
|
||||
out, err := mSysPatent.Distribution()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c.distribution(out), nil
|
||||
}
|
||||
|
||||
// distributionAchievement 技术成果信息
|
||||
func (c *Index) distributionAchievement() (map[string]*InstanceDistributionDetailInfo, error) {
|
||||
mSysPatent := model.NewSysPatent()
|
||||
out, err := mSysPatent.Distribution()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c.distribution(out), nil
|
||||
}
|
||||
|
||||
// Instance 首页信息
|
||||
func (c *Index) Instance() (*InstanceInfo, error) {
|
||||
out := new(InstanceInfo)
|
||||
out := &InstanceInfo{
|
||||
InstanceStaticInfo: new(InstanceStaticInfo),
|
||||
Distribution: new(InstanceDistributionInfo),
|
||||
}
|
||||
var err error
|
||||
|
||||
// 数量统计信息
|
||||
if out.InstanceStaticInfo, err = c.static(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 专家区域分布信息
|
||||
if out.Distribution.Expert, err = c.distributionExpert(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 实验室区域分布信息
|
||||
if out.Distribution.Laboratory, err = c.distributionLaboratory(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 需求信息区域分布信息
|
||||
if out.Distribution.Demand, err = c.distributionDemand(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 专利信息区域分布信息
|
||||
if out.Distribution.Patent, err = c.distributionPatent(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 成果信息区域分布信息
|
||||
if out.Distribution.Achievement, err = c.distributionAchievement(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
|
8
app/api/website/model/base.go
Normal file
8
app/api/website/model/base.go
Normal file
@ -0,0 +1,8 @@
|
||||
package model
|
||||
|
||||
// DataAreaDistributionInfo 数据区域分期
|
||||
type DataAreaDistributionInfo struct {
|
||||
Province string `json:"province"`
|
||||
City string `json:"city"`
|
||||
Industry string `json:"industry"`
|
||||
}
|
@ -1,11 +1,28 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
)
|
||||
|
||||
type ManageExpert struct {
|
||||
*model.ManageExpert
|
||||
}
|
||||
|
||||
// Distribution 分布信息
|
||||
func (m *ManageExpert) Distribution() ([]*DataAreaDistributionInfo, error) {
|
||||
out := make([]*DataAreaDistributionInfo, 0)
|
||||
|
||||
err := orm.GetDB().Table(m.TableName()).
|
||||
Select("province", "city", "GROUP_CONCAT(industry SEPARATOR '&') AS industry").
|
||||
Group("province").Group("city").
|
||||
Order("province "+model.OrderModeToAsc).Order("city "+model.OrderModeToAsc).
|
||||
Where("examine_status = ?", model.ExamineStatusForAgree).
|
||||
Scan(&out).Error
|
||||
|
||||
return out, err
|
||||
}
|
||||
|
||||
func NewManageExpert() *ManageExpert {
|
||||
return &ManageExpert{model.NewManageExpert()}
|
||||
}
|
||||
|
28
app/api/website/model/manage_laboratory.go
Normal file
28
app/api/website/model/manage_laboratory.go
Normal file
@ -0,0 +1,28 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
)
|
||||
|
||||
type ManageLaboratory struct {
|
||||
*model.ManageLaboratory
|
||||
}
|
||||
|
||||
// Distribution 分布信息
|
||||
func (m *ManageLaboratory) Distribution() ([]*DataAreaDistributionInfo, error) {
|
||||
out := make([]*DataAreaDistributionInfo, 0)
|
||||
|
||||
err := orm.GetDB().Table(m.TableName()).
|
||||
Select("province", "city", "GROUP_CONCAT(industry SEPARATOR '&') AS industry").
|
||||
Group("province").Group("city").
|
||||
Order("province "+model.OrderModeToAsc).Order("city "+model.OrderModeToAsc).
|
||||
Where("examine_status = ?", model.ExamineStatusForAgree).
|
||||
Scan(&out).Error
|
||||
|
||||
return out, err
|
||||
}
|
||||
|
||||
func NewManageLaboratory() *ManageLaboratory {
|
||||
return &ManageLaboratory{model.NewManageLaboratory()}
|
||||
}
|
11
app/api/website/model/service_docking.go
Normal file
11
app/api/website/model/service_docking.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type ServiceDocking struct {
|
||||
*model.ServiceDocking
|
||||
}
|
||||
|
||||
func NewServiceDocking() *ServiceDocking {
|
||||
return &ServiceDocking{model.NewServiceDocking()}
|
||||
}
|
34
app/api/website/model/sys_patent.go
Normal file
34
app/api/website/model/sys_patent.go
Normal file
@ -0,0 +1,34 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type SysPatent struct {
|
||||
*model.SysPatent
|
||||
}
|
||||
|
||||
// Distribution 分布信息
|
||||
func (m *SysPatent) Distribution() ([]*DataAreaDistributionInfo, error) {
|
||||
out := make([]*DataAreaDistributionInfo, 0)
|
||||
|
||||
err := orm.GetDB().Table(m.TableName()+" AS p").
|
||||
Select("e.province", "e.city", "GROUP_CONCAT(p_c.industry_detail SEPARATOR '&') AS industry").
|
||||
Joins(fmt.Sprintf("RIGHT JOIN %s AS p_c ON p.ipc_code = p_c.ipc AND p_c.is_deleted = %d",
|
||||
model.NewSysPatentClassify().TableName(), model.DeleteStatusForNot)).
|
||||
Joins(fmt.Sprintf("RIGHT JOIN %s AS u_p ON p.id = u_p.patent_id AND u_p.is_deleted = %d",
|
||||
model.NewUserPatent().TableName(), model.DeleteStatusForNot)).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u_e ON u_p.uid = u_e.uid", model.NewUserExpert().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS e ON u_e.expert_id = e.id", model.NewManageExpert().TableName())).
|
||||
Where("p.is_deleted = ?", model.DeleteStatusForNot).
|
||||
Where("p.shelf_status = ?", model.ShelfStatusForUp).
|
||||
Group("e.province").Group("e.city").
|
||||
Order("e.province " + model.OrderModeToAsc).Order("e.city " + model.OrderModeToAsc).Scan(&out).Error
|
||||
return out, err
|
||||
}
|
||||
|
||||
func NewSysPatent() *SysPatent {
|
||||
return &SysPatent{model.NewSysPatent()}
|
||||
}
|
11
app/api/website/model/sys_patent_classify.go
Normal file
11
app/api/website/model/sys_patent_classify.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type SysPatentClassify struct {
|
||||
*model.SysPatentClassify
|
||||
}
|
||||
|
||||
func NewSysPatentClassify() *SysPatentClassify {
|
||||
return &SysPatentClassify{model.NewSysPatentClassify()}
|
||||
}
|
32
app/api/website/model/technology_achievement.go
Normal file
32
app/api/website/model/technology_achievement.go
Normal file
@ -0,0 +1,32 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type TechnologyAchievement struct {
|
||||
*model.TechnologyAchievement
|
||||
}
|
||||
|
||||
// Distribution 分布信息
|
||||
func (m *TechnologyAchievement) Distribution() ([]*DataAreaDistributionInfo, error) {
|
||||
out := make([]*DataAreaDistributionInfo, 0)
|
||||
|
||||
err := orm.GetDB().Table(m.TableName()+" AS a").
|
||||
Select("e.province", "e.city", "GROUP_CONCAT(a.industry SEPARATOR '&') AS industry").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u_e ON a.uid = u_e.uid", model.NewUserExpert().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS e ON u_e.expert_id = e.id", model.NewManageExpert().TableName())).
|
||||
Group("e.province").Group("e.city").
|
||||
Order("e.province "+model.OrderModeToAsc).Order("e.city "+model.OrderModeToAsc).
|
||||
Where("a.status = ?", model.TechnologyAchievementStatusForAgree).
|
||||
Where("a.shelf_status = ?", model.ShelfStatusForUp).
|
||||
Scan(&out).Error
|
||||
|
||||
return out, err
|
||||
}
|
||||
|
||||
func NewTechnologyAchievement() *TechnologyAchievement {
|
||||
return &TechnologyAchievement{model.NewTechnologyAchievement()}
|
||||
}
|
31
app/api/website/model/technology_demand.go
Normal file
31
app/api/website/model/technology_demand.go
Normal file
@ -0,0 +1,31 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type TechnologyDemand struct {
|
||||
*model.TechnologyDemand
|
||||
}
|
||||
|
||||
// Distribution 分布信息
|
||||
func (m *TechnologyDemand) Distribution() ([]*DataAreaDistributionInfo, error) {
|
||||
out := make([]*DataAreaDistributionInfo, 0)
|
||||
|
||||
err := orm.GetDB().Table(m.TableName()+" AS d").
|
||||
Select("e.province", "e.city", "GROUP_CONCAT(d.industry SEPARATOR '&') AS industry").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u_e ON d.uid = u_e.uid", model.NewUserExpert().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS e ON u_e.expert_id = e.id", model.NewManageExpert().TableName())).
|
||||
Group("e.province").Group("e.city").
|
||||
Order("e.province "+model.OrderModeToAsc).Order("e.city "+model.OrderModeToAsc).
|
||||
Where("d.status = ?", model.TechnologyDemandStatusForAgree).
|
||||
Scan(&out).Error
|
||||
|
||||
return out, err
|
||||
}
|
||||
|
||||
func NewTechnologyDemand() *TechnologyDemand {
|
||||
return &TechnologyDemand{model.NewTechnologyDemand()}
|
||||
}
|
Reference in New Issue
Block a user