From ba62a25e4b60087a258c80158fb850a564a272bb Mon Sep 17 00:00:00 2001 From: henry Date: Wed, 15 Dec 2021 14:31:14 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=AE=8C=E5=96=84=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E7=AE=A1=E7=90=86=EF=BC=8C=E5=A2=9E=E5=8A=A0=E7=BD=91?= =?UTF-8?q?=E7=AB=99=E9=A6=96=E9=A1=B5=E6=8E=A5=E5=8F=A3=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../enterprise/controller/account/instance.go | 6 +- app/api/enterprise/model/activity_instance.go | 4 +- app/api/website/api/docking.go | 1 + app/api/website/api/index.go | 11 +- app/api/website/controller/docking.go | 13 ++ app/api/website/controller/index.go | 186 +++++++++++++++++- app/api/website/model/base.go | 8 + app/api/website/model/manage_expert.go | 19 +- app/api/website/model/manage_laboratory.go | 28 +++ app/api/website/model/service_docking.go | 11 ++ app/api/website/model/sys_patent.go | 34 ++++ app/api/website/model/sys_patent_classify.go | 11 ++ .../website/model/technology_achievement.go | 32 +++ app/api/website/model/technology_demand.go | 31 +++ app/common/init.go | 9 + app/common/model/service_docking.go | 17 ++ app/common/model/sys_patent.go | 12 +- app/common/model/sys_patent_classify.go | 19 ++ cmd/serve/serve.go | 3 +- router/address.go | 64 +++--- router/router.go | 2 +- 21 files changed, 471 insertions(+), 50 deletions(-) create mode 100644 app/api/website/api/docking.go create mode 100644 app/api/website/controller/docking.go create mode 100644 app/api/website/model/base.go create mode 100644 app/api/website/model/manage_laboratory.go create mode 100644 app/api/website/model/service_docking.go create mode 100644 app/api/website/model/sys_patent.go create mode 100644 app/api/website/model/sys_patent_classify.go create mode 100644 app/api/website/model/technology_achievement.go create mode 100644 app/api/website/model/technology_demand.go create mode 100644 app/common/model/service_docking.go create mode 100644 app/common/model/sys_patent_classify.go diff --git a/app/api/enterprise/controller/account/instance.go b/app/api/enterprise/controller/account/instance.go index 4d395a1..70cd3a4 100644 --- a/app/api/enterprise/controller/account/instance.go +++ b/app/api/enterprise/controller/account/instance.go @@ -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} } } diff --git a/app/api/enterprise/model/activity_instance.go b/app/api/enterprise/model/activity_instance.go index 3de196c..ccfb9d4 100644 --- a/app/api/enterprise/model/activity_instance.go +++ b/app/api/enterprise/model/activity_instance.go @@ -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 { diff --git a/app/api/website/api/docking.go b/app/api/website/api/docking.go new file mode 100644 index 0000000..778f64e --- /dev/null +++ b/app/api/website/api/docking.go @@ -0,0 +1 @@ +package api diff --git a/app/api/website/api/index.go b/app/api/website/api/index.go index 0288451..73435be 100644 --- a/app/api/website/api/index.go +++ b/app/api/website/api/index.go @@ -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) } diff --git a/app/api/website/controller/docking.go b/app/api/website/controller/docking.go new file mode 100644 index 0000000..a86b11e --- /dev/null +++ b/app/api/website/controller/docking.go @@ -0,0 +1,13 @@ +package controller + +type Docking struct{} + +type DockingHandle func() + +func (c *Docking) Message() { + +} + +func NewDocking() DockingHandle { + return nil +} diff --git a/app/api/website/controller/index.go b/app/api/website/controller/index.go index 66094d2..b6d85eb 100644 --- a/app/api/website/controller/index.go +++ b/app/api/website/controller/index.go @@ -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 } diff --git a/app/api/website/model/base.go b/app/api/website/model/base.go new file mode 100644 index 0000000..59fe3f9 --- /dev/null +++ b/app/api/website/model/base.go @@ -0,0 +1,8 @@ +package model + +// DataAreaDistributionInfo 数据区域分期 +type DataAreaDistributionInfo struct { + Province string `json:"province"` + City string `json:"city"` + Industry string `json:"industry"` +} diff --git a/app/api/website/model/manage_expert.go b/app/api/website/model/manage_expert.go index 6de19ca..c0317d4 100644 --- a/app/api/website/model/manage_expert.go +++ b/app/api/website/model/manage_expert.go @@ -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()} } diff --git a/app/api/website/model/manage_laboratory.go b/app/api/website/model/manage_laboratory.go new file mode 100644 index 0000000..df574cb --- /dev/null +++ b/app/api/website/model/manage_laboratory.go @@ -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()} +} diff --git a/app/api/website/model/service_docking.go b/app/api/website/model/service_docking.go new file mode 100644 index 0000000..b591a8b --- /dev/null +++ b/app/api/website/model/service_docking.go @@ -0,0 +1,11 @@ +package model + +import "SciencesServer/app/common/model" + +type ServiceDocking struct { + *model.ServiceDocking +} + +func NewServiceDocking() *ServiceDocking { + return &ServiceDocking{model.NewServiceDocking()} +} diff --git a/app/api/website/model/sys_patent.go b/app/api/website/model/sys_patent.go new file mode 100644 index 0000000..f8df747 --- /dev/null +++ b/app/api/website/model/sys_patent.go @@ -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()} +} diff --git a/app/api/website/model/sys_patent_classify.go b/app/api/website/model/sys_patent_classify.go new file mode 100644 index 0000000..e8d5caa --- /dev/null +++ b/app/api/website/model/sys_patent_classify.go @@ -0,0 +1,11 @@ +package model + +import "SciencesServer/app/common/model" + +type SysPatentClassify struct { + *model.SysPatentClassify +} + +func NewSysPatentClassify() *SysPatentClassify { + return &SysPatentClassify{model.NewSysPatentClassify()} +} diff --git a/app/api/website/model/technology_achievement.go b/app/api/website/model/technology_achievement.go new file mode 100644 index 0000000..fb7460e --- /dev/null +++ b/app/api/website/model/technology_achievement.go @@ -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()} +} diff --git a/app/api/website/model/technology_demand.go b/app/api/website/model/technology_demand.go new file mode 100644 index 0000000..fe3a39f --- /dev/null +++ b/app/api/website/model/technology_demand.go @@ -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()} +} diff --git a/app/common/init.go b/app/common/init.go index e2e6cce..d567da1 100644 --- a/app/common/init.go +++ b/app/common/init.go @@ -57,6 +57,7 @@ func initModel() { &synchronized{iModel: model.NewSysPatent(), iValues: func() interface{} { return nil }}, + &synchronized{iModel: model.NewSysPatentClassify()}, &synchronized{iModel: model.NewSysIdentity(), iValues: func() interface{} { out := make([]*model.SysIdentity, 0) @@ -116,6 +117,7 @@ func initModel() { &synchronized{iModel: model.NewSysLog()}, &synchronized{iModel: model.NewSysUserLoginLog()}, // 用户管理 &synchronized{iModel: model.NewUserInstance()}, &synchronized{iModel: model.NewUserIdentity()}, + &synchronized{iModel: model.NewUserAssets()}, &synchronized{iModel: model.NewUserPatent()}, &synchronized{iModel: model.NewUserBank()}, &synchronized{iModel: model.NewUserCompany()}, &synchronized{iModel: model.NewUserExpert()}, &synchronized{iModel: model.NewUserLaboratory()}, &synchronized{iModel: model.NewUserResearch()}, @@ -125,6 +127,13 @@ func initModel() { &synchronized{iModel: model.NewManageLaboratory()}, &synchronized{iModel: model.NewManageResearch()}, &synchronized{iModel: model.NewManageAgent()}, // 数据管理 + &synchronized{iModel: model.NewManageCompany()}, &synchronized{iModel: model.NewManageExpert()}, + &synchronized{iModel: model.NewManageLaboratory()}, &synchronized{iModel: model.NewManageResearch()}, + &synchronized{iModel: model.NewManageAgent()}, + &synchronized{iModel: model.NewTechnologyAchievement()}, &synchronized{iModel: model.NewTechnologyDemand()}, + &synchronized{iModel: model.NewTechnologyPaper()}, &synchronized{iModel: model.NewTechnologyProduct()}, + &synchronized{iModel: model.NewTechnologyProject()}, &synchronized{iModel: model.NewTechnologyTopic()}, + &synchronized{iModel: model.NewServiceDocking()}, ) } func initCacheMode() { diff --git a/app/common/model/service_docking.go b/app/common/model/service_docking.go new file mode 100644 index 0000000..21a3e24 --- /dev/null +++ b/app/common/model/service_docking.go @@ -0,0 +1,17 @@ +package model + +// ServiceDocking 对接信息数据模型 +type ServiceDocking struct { + Model + UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"` + ModelDeleted + ModelAt +} + +func (m *ServiceDocking) TableName() string { + return "service_docking" +} + +func NewServiceDocking() *ServiceDocking { + return &ServiceDocking{} +} diff --git a/app/common/model/sys_patent.go b/app/common/model/sys_patent.go index cc277f3..5534bcf 100644 --- a/app/common/model/sys_patent.go +++ b/app/common/model/sys_patent.go @@ -4,18 +4,18 @@ package model type SysPatent struct { Model Kind SysParentKind `gorm:"column:kind;type:tinyint(1);default:0;comment:专利类型" json:"kind"` - Title string `gorm:"column:title;type:varchar(255);default:'';comment:名称标题" json:"title"` + Title string `gorm:"column:title;type:varchar(100);default:'';comment:名称标题" json:"title"` FileUrl string `gorm:"column:file_url;type:varchar(255);default:'';comment:文件地址" json:"file_url"` - ApplyCode string `gorm:"column:apply_code;type:varchar(50);default:'';comment:申请号" json:"apply_code"` - ApplyAt string `gorm:"column:apply_at;type:varchar(30);default:'';comment:申请日" json:"apply_at"` - OpenCode string `gorm:"column:open_code;type:varchar(50);default:'';comment:公开(公告)号" json:"open_code"` - OpenAt string `gorm:"column:open_at;type:varchar(30);default:'';comment:公开(公告)日" json:"open_at"` + ApplyCode string `gorm:"column:apply_code;type:varchar(30);default:'';comment:申请号" json:"apply_code"` + ApplyAt string `gorm:"column:apply_at;type:varchar(10);default:'';comment:申请日" json:"apply_at"` + OpenCode string `gorm:"column:open_code;type:varchar(30);default:'';comment:公开(公告)号" json:"open_code"` + OpenAt string `gorm:"column:open_at;type:varchar(10);default:'';comment:公开(公告)日" json:"open_at"` ApplyName string `gorm:"column:apply_name;type:varchar(255);default:'';comment:申请(专利权)人" json:"apply_name"` ApplyAddress string `gorm:"column:apply_address;type:varchar(255);default:'';comment:申请人地址" json:"apply_address"` Inventor string `gorm:"column:inventor;type:varchar(255);default:'';comment:发明人" json:"inventor"` Description string `gorm:"column:description;type:text;comment:摘要" json:"description"` PrincipalClaim string `gorm:"column:principal_claim;type:text;comment:主权项" json:"principal_claim"` - IPCCode string `gorm:"column:ipc_code;type:varchar(50);default:'';comment:IPC主分类号" json:"ipc_code"` + IPCCode string `gorm:"column:ipc_code;type:varchar(30);default:'';comment:IPC主分类号" json:"ipc_code"` Shelf Status SysParentStatus `gorm:"column:status;type:tinyint(1);default:1;comment:专利状态(1:授权,2:实审,3:公开)" json:"-"` ModelDeleted diff --git a/app/common/model/sys_patent_classify.go b/app/common/model/sys_patent_classify.go new file mode 100644 index 0000000..e285a35 --- /dev/null +++ b/app/common/model/sys_patent_classify.go @@ -0,0 +1,19 @@ +package model + +// SysPatentClassify 专利分类信息数据模型 +type SysPatentClassify struct { + Model + IPC string `gorm:"column:ipc;type:varchar(18);default:'';comment:IPC主分类号" json:"ipc"` + Industry string `gorm:"column:industry;type:varchar(255);default:'';comment:行业领域" json:"industry"` + IndustryDetail string `gorm:"column:industry_detail;type:varchar(255);default:'';comment:详细行业领域,包含父级领域信息" json:"industry_detail"` + ModelDeleted + ModelAt +} + +func (m *SysPatentClassify) TableName() string { + return "sys_patent_classify" +} + +func NewSysPatentClassify() *SysPatentClassify { + return &SysPatentClassify{} +} diff --git a/cmd/serve/serve.go b/cmd/serve/serve.go index d00bcad..5043325 100644 --- a/cmd/serve/serve.go +++ b/cmd/serve/serve.go @@ -7,7 +7,6 @@ import ( "SciencesServer/cron" "SciencesServer/router" "SciencesServer/serve/cache" - "SciencesServer/serve/es" "SciencesServer/serve/logger" "SciencesServer/serve/orm" "SciencesServer/serve/orm/logic" @@ -69,7 +68,7 @@ func (this *Serve) Run() { app.Init() tools.Init() // 开启Elasticsearch - es.NewInstance(es.WithEsAddress([]string{"http://192.168.0.188:9200"})).Init().Local() + //es.NewInstance(es.WithEsAddress([]string{"http://192.168.0.188:9200"})).Init().Local() // 开启web web.NewWeb()(&web.WebConfig{ Port: config.SettingInfo.Server.Port, ReadTimeout: config.SettingInfo.Server.ReadTimeout, diff --git a/router/address.go b/router/address.go index 228be0a..8c17cf6 100644 --- a/router/address.go +++ b/router/address.go @@ -1,21 +1,31 @@ package router import ( - api2 "SciencesServer/app/api/enterprise/api" - "SciencesServer/app/api/manage/api" - api3 "SciencesServer/app/basic/api" + api3 "SciencesServer/app/api/enterprise/api" + api1 "SciencesServer/app/api/manage/api" + api2 "SciencesServer/app/api/website/api" + "SciencesServer/app/basic/api" "SciencesServer/app/session" "github.com/gin-gonic/gin" ) // registerAPI 注册API func registerAPI(app *gin.Engine) { + apiPrefix := "/api" + g := app.Group(apiPrefix) + v1 := g.Group("/v1") + // Index 首页信息管理 + indexV1 := v1.Group("/index") + { + _api := new(api2.Index) + indexV1.GET("", _api.Instance) + } } -// registerManageAPI 注册API -func registerManageAPI(app *gin.Engine) { - apiPrefix := "/manage" +// registerAdminAPI 注册API +func registerAdminAPI(app *gin.Engine) { + apiPrefix := "/admin" g := app.Group(apiPrefix) // 登录验证 @@ -31,20 +41,20 @@ func registerManageAPI(app *gin.Engine) { // apiPrefix + "/account/logout", //}...))) // Captcha 验证码 - g.GET("/captcha", new(api.Captcha).Captcha) + g.GET("/captcha", new(api1.Captcha).Captcha) // Upload 上传管理 - g.POST("/upload", new(api3.Upload).Upload) + g.POST("/upload", new(api.Upload).Upload) // Account 账户管理 account := g.Group("/account") { - _api := new(api.Account) + _api := new(api1.Account) account.POST("/login", _api.Login) account.POST("/logout", _api.Logout) } // User 用户管理 user := g.Group("/user") { - _api := new(api.User) + _api := new(api1.User) user.GET("/info", _api.Info) user.GET("/menu", _api.Menu) user.POST("/list", _api.List) @@ -59,7 +69,7 @@ func registerManageAPI(app *gin.Engine) { // Tenant 租户管理 tenant := g.Group("/tenant") { - _api := new(api.Tenant) + _api := new(api1.Tenant) tenant.POST("/list", _api.List) tenant.POST("/add", _api.Add) tenant.POST("/edit", _api.Edit) @@ -76,7 +86,7 @@ func registerManageAPI(app *gin.Engine) { // Menu 菜单管理 menu := g.Group("/menu") { - _api := new(api.Menu) + _api := new(api1.Menu) menu.GET("/list", _api.List) menu.POST("/add", _api.Add) menu.POST("/edit", _api.Edit) @@ -86,13 +96,13 @@ func registerManageAPI(app *gin.Engine) { // Auth 权限管理 auth := g.Group("/auth") { - _api := new(api.Auth) + _api := new(api1.Auth) auth.POST("/list", _api.List) } // Department 部门管理 department := g.Group("/department") { - _api := new(api.Department) + _api := new(api1.Department) department.GET("/list", _api.List) department.GET("/select", _api.Select) department.POST("/add", _api.Add) @@ -102,7 +112,7 @@ func registerManageAPI(app *gin.Engine) { // Role 角色管理 role := g.Group("/role") { - _api := new(api.Role) + _api := new(api1.Role) role.POST("/list", _api.List) role.POST("/select", _api.Select) role.POST("/add", _api.Add) @@ -117,7 +127,7 @@ func registerManageAPI(app *gin.Engine) { // Logs 日志管理 log := g.Group("/log") { - _api := new(api.Log) + _api := new(api1.Log) log.POST("/login", _api.Login) } } @@ -136,11 +146,11 @@ func registerEnterpriseAPI(app *gin.Engine) { v1 := g.Group("/v1") // Upload 上传管理 - v1.POST("/upload", new(api3.Upload).Upload) + v1.POST("/upload", new(api.Upload).Upload) // Config 配置管理 configV1 := v1.Group("/config") { - _api := new(api2.Config) + _api := new(api3.Config) configV1.GET("/area", _api.Area) configV1.GET("/identity", _api.Identity) configV1.GET("/industry", _api.Industry) @@ -148,7 +158,7 @@ func registerEnterpriseAPI(app *gin.Engine) { // Account 账号管理 accountV1 := v1.Group("/account") { - _api := new(api2.Account) + _api := new(api3.Account) accountV1.POST("/login", _api.Login) accountV1.POST("/register", _api.Register) accountV1.POST("/authorize", _api.Authorize) @@ -157,26 +167,26 @@ func registerEnterpriseAPI(app *gin.Engine) { // User 用户管理 userV1 := v1.Group("/user") { - _api := new(api2.User) + _api := new(api3.User) userV1.GET("/info", _api.Info) userV1.GET("/patent", _api.Patent) } // Home 首页管理 homeV1 := v1.Group("/home") { - _api := new(api2.Home) + _api := new(api3.Home) homeV1.GET("", _api.Instance) } // Sys 配置管理 sysV1 := v1.Group("/sys") { - _api := new(api2.Sys) + _api := new(api3.Sys) sysV1.POST("/patent", _api.Patent) } // Settled 入驻管理 settledV1 := v1.Group("/settled") { - _api := new(api2.Settled) + _api := new(api3.Settled) settledV1.GET("", _api.Index) settledV1.POST("/company", _api.Company) settledV1.POST("/company/get", _api.CompanyGet) @@ -188,7 +198,7 @@ func registerEnterpriseAPI(app *gin.Engine) { // Technology 技术管理 technologyV1 := g.Group("/technology") { - _api := new(api2.Technology) + _api := new(api3.Technology) technologyV1.POST("/paper", _api.Paper) technologyV1.POST("/paper/add", _api.PaperAdd) technologyV1.POST("/paper/edit", _api.PaperEdit) @@ -227,7 +237,7 @@ func registerEnterpriseAPI(app *gin.Engine) { // Service 服务信息 serviceV1 := v1.Group("/service") { - _api := new(api2.Service) + _api := new(api3.Service) serviceV1.POST("/demand", _api.Demand) serviceV1.POST("/demand/detail", _api.DemandDetail) serviceV1.POST("/demand/add", _api.DemandAdd) @@ -237,7 +247,7 @@ func registerEnterpriseAPI(app *gin.Engine) { // Manage 管理信息 manageV1 := v1.Group("/manage") { - _api := new(api2.Manage) + _api := new(api3.Manage) manageV1.POST("/enterprise", _api.Enterprise) manageV1.POST("/enterprise/add", _api.EnterpriseAdd) manageV1.POST("/enterprise/edit", _api.EnterpriseEdit) @@ -255,7 +265,7 @@ func registerEnterpriseAPI(app *gin.Engine) { // Activity 活动信息 activityV1 := v1.Group("/activity") { - _api := new(api2.Activity) + _api := new(api3.Activity) activityV1.POST("/apply", _api.Applys) activityV1.POST("/apply/revoke", _api.ApplyRevoke) activityV1.POST("/apply/delete", _api.ApplyDelete) diff --git a/router/router.go b/router/router.go index 397870e..7491a9d 100644 --- a/router/router.go +++ b/router/router.go @@ -57,7 +57,7 @@ func (this *Router) Init() *gin.Engine { app.StaticFS("/upload", http.Dir("./upload")) // 注册路由 registerAPI(app) - registerManageAPI(app) + registerAdminAPI(app) registerEnterpriseAPI(app) app.MaxMultipartMemory = 4 << 20