feat:完善项目信息
This commit is contained in:
@ -1 +1,21 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/website/controller"
|
||||
"SciencesServer/app/basic/api"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type Config struct{}
|
||||
|
||||
func (*Config) Area(c *gin.Context) {
|
||||
form := &struct {
|
||||
Code string `json:"code" form:"code"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data := controller.NewConfig()(nil).Area(form.Code)
|
||||
api.APIResponse(nil, data)(c)
|
||||
}
|
||||
|
||||
@ -9,6 +9,71 @@ import (
|
||||
type Index struct{}
|
||||
|
||||
func (*Index) Instance(c *gin.Context) {
|
||||
data, err := controller.NewIndex()(nil, "").Instance()
|
||||
data, err := controller.NewIndex()(nil).Instance()
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Index) DistributionExpert(c *gin.Context) {
|
||||
form := &struct {
|
||||
Province string `json:"province" form:"province"`
|
||||
City string `json:"city" form:"city"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := controller.NewIndex()(nil).DistributionExpert(form.Province, form.City)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Index) DistributionLaboratory(c *gin.Context) {
|
||||
form := &struct {
|
||||
Province string `json:"province" form:"province"`
|
||||
City string `json:"city" form:"city"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := controller.NewIndex()(nil).DistributionLaboratory(form.Province, form.City)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Index) DistributionDemand(c *gin.Context) {
|
||||
form := &struct {
|
||||
Province string `json:"province" form:"province"`
|
||||
City string `json:"city" form:"city"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := controller.NewIndex()(nil).DistributionDemand(form.Province, form.City)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Index) DistributionPatent(c *gin.Context) {
|
||||
form := &struct {
|
||||
Province string `json:"province" form:"province"`
|
||||
City string `json:"city" form:"city"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := controller.NewIndex()(nil).DistributionPatent(form.Province, form.City)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Index) DistributionAchievement(c *gin.Context) {
|
||||
form := &struct {
|
||||
Province string `json:"province" form:"province"`
|
||||
City string `json:"city" form:"city"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := controller.NewIndex()(nil).DistributionAchievement(form.Province, form.City)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
@ -1,19 +1,29 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/session"
|
||||
config2 "SciencesServer/config"
|
||||
)
|
||||
|
||||
type Config struct{ *service.Session }
|
||||
type Config struct{ *session.Admin }
|
||||
|
||||
type ConfigHandle func(session *service.Session) *Config
|
||||
type ConfigHandle func(session *session.Admin) *Config
|
||||
|
||||
func (c *Config) Basic() {
|
||||
|
||||
}
|
||||
|
||||
// Area 区域信息
|
||||
func (c *Config) Area(key string) map[string]string {
|
||||
if key == "" {
|
||||
key = config2.DefaultChinaAreaCode
|
||||
}
|
||||
return config.MemoryForAreaInfo[key]
|
||||
}
|
||||
|
||||
func NewConfig() ConfigHandle {
|
||||
return func(session *service.Session) *Config {
|
||||
return &Config{Session: session}
|
||||
return func(session *session.Admin) *Config {
|
||||
return &Config{Admin: session}
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,10 +12,9 @@ import (
|
||||
|
||||
type Index struct {
|
||||
*service.Session
|
||||
local string
|
||||
}
|
||||
|
||||
type IndexHandle func(session *service.Session, local string) *Index
|
||||
type IndexHandle func(session *service.Session) *Index
|
||||
|
||||
type (
|
||||
// InstanceInfo 首页信息
|
||||
@ -152,10 +151,10 @@ func (c *Index) static() (*InstanceStaticInfo, error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// distributionExpert 专家分布
|
||||
func (c *Index) distributionExpert() (map[string]*InstanceDistributionDetailInfo, error) {
|
||||
// DistributionExpert 专家分布
|
||||
func (c *Index) DistributionExpert(province, city string) (map[string]*InstanceDistributionDetailInfo, error) {
|
||||
mManageExpert := model.NewManageExpert()
|
||||
out, err := mManageExpert.Distribution()
|
||||
out, err := mManageExpert.Distribution(province, city)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -163,8 +162,8 @@ func (c *Index) distributionExpert() (map[string]*InstanceDistributionDetailInfo
|
||||
return c.distribution(out), nil
|
||||
}
|
||||
|
||||
// distributionLaboratory 实验室分布
|
||||
func (c *Index) distributionLaboratory() (map[string]*InstanceDistributionDetailInfo, error) {
|
||||
// DistributionLaboratory 实验室分布
|
||||
func (c *Index) DistributionLaboratory(province, city string) (map[string]*InstanceDistributionDetailInfo, error) {
|
||||
mManageLaboratory := model.NewManageLaboratory()
|
||||
out, err := mManageLaboratory.Distribution()
|
||||
|
||||
@ -174,8 +173,8 @@ func (c *Index) distributionLaboratory() (map[string]*InstanceDistributionDetail
|
||||
return c.distribution(out), nil
|
||||
}
|
||||
|
||||
// distributionDemand 需求信息
|
||||
func (c *Index) distributionDemand() (map[string]*InstanceDistributionDetailInfo, error) {
|
||||
// DistributionDemand 需求信息
|
||||
func (c *Index) DistributionDemand(province, city string) (map[string]*InstanceDistributionDetailInfo, error) {
|
||||
mTechnologyDemand := model.NewTechnologyDemand()
|
||||
out, err := mTechnologyDemand.Distribution()
|
||||
|
||||
@ -185,8 +184,8 @@ func (c *Index) distributionDemand() (map[string]*InstanceDistributionDetailInfo
|
||||
return c.distribution(out), nil
|
||||
}
|
||||
|
||||
// distributionPatent 专利信息
|
||||
func (c *Index) distributionPatent() (map[string]*InstanceDistributionDetailInfo, error) {
|
||||
// DistributionPatent 专利信息
|
||||
func (c *Index) DistributionPatent(province, city string) (map[string]*InstanceDistributionDetailInfo, error) {
|
||||
mSysPatent := model.NewSysPatent()
|
||||
out, err := mSysPatent.Distribution()
|
||||
|
||||
@ -196,8 +195,8 @@ func (c *Index) distributionPatent() (map[string]*InstanceDistributionDetailInfo
|
||||
return c.distribution(out), nil
|
||||
}
|
||||
|
||||
// distributionAchievement 技术成果信息
|
||||
func (c *Index) distributionAchievement() (map[string]*InstanceDistributionDetailInfo, error) {
|
||||
// DistributionAchievement 技术成果信息
|
||||
func (c *Index) DistributionAchievement(province, city string) (map[string]*InstanceDistributionDetailInfo, error) {
|
||||
mSysPatent := model.NewSysPatent()
|
||||
out, err := mSysPatent.Distribution()
|
||||
|
||||
@ -218,34 +217,13 @@ func (c *Index) Instance() (*InstanceInfo, 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
|
||||
}
|
||||
|
||||
func NewIndex() IndexHandle {
|
||||
return func(session *service.Session, local string) *Index {
|
||||
return func(session *service.Session) *Index {
|
||||
return &Index{
|
||||
Session: session,
|
||||
local: local,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,13 +74,14 @@ FROM %s AS u LEFT JOIN %s AS p ON u.parent_id = p.id WHERE u.is_deleted = %d AND
|
||||
}
|
||||
|
||||
// Distribution 分布信息
|
||||
func (m *ManageExpert) Distribution() ([]*DataAreaDistributionInfo, error) {
|
||||
func (m *ManageExpert) Distribution(province, city string) ([]*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).
|
||||
db := orm.GetDB().Table(m.TableName()).
|
||||
Select("province", "city", "district", "GROUP_CONCAT(industry SEPARATOR '&') AS industry").
|
||||
Group("province").Group("city").Group("district")
|
||||
|
||||
err := db.Order("province "+model.OrderModeToAsc).Order("city "+model.OrderModeToAsc).Order("district "+model.OrderModeToAsc).
|
||||
Where("examine_status = ?", model.ExamineStatusForAgree).
|
||||
Scan(&out).Error
|
||||
|
||||
|
||||
Reference in New Issue
Block a user