feat:完善项目信息
This commit is contained in:
1
app/api/admin/api/activity.go
Normal file
1
app/api/admin/api/activity.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package api
|
||||||
@ -147,7 +147,7 @@ func (*Service) SolutionCaseForm(c *gin.Context) {
|
|||||||
KindID string `json:"kind_id" form:"kind_id" binding:"required"`
|
KindID string `json:"kind_id" form:"kind_id" binding:"required"`
|
||||||
Title string `json:"title" form:"title" binding:"required"`
|
Title string `json:"title" form:"title" binding:"required"`
|
||||||
api.ImageForm
|
api.ImageForm
|
||||||
Description string `json:"description" form:"description" binding:"description"`
|
Description string `json:"description" form:"description" binding:"required"`
|
||||||
Content string `json:"content" form:"content" binding:"required"`
|
Content string `json:"content" form:"content" binding:"required"`
|
||||||
Sort int `json:"sort" form:"sort"`
|
Sort int `json:"sort" form:"sort"`
|
||||||
}{}
|
}{}
|
||||||
@ -253,3 +253,15 @@ func (*Service) MessageHandle(c *gin.Context) {
|
|||||||
err := service.NewMessage()(api.GetSession()(c).(*session.Admin)).Handle(form.Convert(), form.Content)
|
err := service.NewMessage()(api.GetSession()(c).(*session.Admin)).Handle(form.Convert(), form.Content)
|
||||||
api.APIResponse(err)(c)
|
api.APIResponse(err)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Service) MessageDelete(c *gin.Context) {
|
||||||
|
form := &struct {
|
||||||
|
api.IDStringForm
|
||||||
|
}{}
|
||||||
|
if err := api.Bind(form)(c); err != nil {
|
||||||
|
api.APIFailure(err.(error))(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := service.NewMessage()(api.GetSession()(c).(*session.Admin)).Delete(form.Convert())
|
||||||
|
api.APIResponse(err)(c)
|
||||||
|
}
|
||||||
|
|||||||
109
app/api/admin/controller/activity/instance.go
Normal file
109
app/api/admin/controller/activity/instance.go
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
package activity
|
||||||
|
|
||||||
|
import (
|
||||||
|
"SciencesServer/app/api/admin/model"
|
||||||
|
"SciencesServer/app/basic/controller"
|
||||||
|
model2 "SciencesServer/app/common/model"
|
||||||
|
"SciencesServer/app/session"
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Instance struct {
|
||||||
|
*session.Admin
|
||||||
|
}
|
||||||
|
|
||||||
|
type InstanceHandle func(session *session.Admin) *Instance
|
||||||
|
|
||||||
|
type (
|
||||||
|
// InstanceInfo 活动信息
|
||||||
|
InstanceInfo struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
*model.ActivityInstanceInfo
|
||||||
|
Area string `json:"area"`
|
||||||
|
}
|
||||||
|
// InstanceDetailInfo 活动详细信息
|
||||||
|
InstanceDetailInfo struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
TenantID string `json:"tenant_id"`
|
||||||
|
*model2.ActivityInstance
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func (c *Instance) Index(tenantID uint64, title string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
|
mActivityInstance := model.NewActivityInstance()
|
||||||
|
|
||||||
|
where := make([]*model2.ModelWhere, 0)
|
||||||
|
|
||||||
|
if c.TenantID > 0 {
|
||||||
|
where = append(where, model2.NewWhere("a.tenant_id", c.TenantID))
|
||||||
|
}
|
||||||
|
if tenantID > 0 {
|
||||||
|
where = append(where, model2.NewWhere("a.tenant_id", tenantID))
|
||||||
|
}
|
||||||
|
if title != "" {
|
||||||
|
where = append(where, model2.NewWhereLike("a.title", title))
|
||||||
|
}
|
||||||
|
var count int64
|
||||||
|
|
||||||
|
out, err := mActivityInstance.Activity(page, pageSize, &count, where...)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
list := make([]*InstanceInfo, 0)
|
||||||
|
|
||||||
|
for _, v := range out {
|
||||||
|
list = append(list, &InstanceInfo{
|
||||||
|
ID: v.GetEncodeID(),
|
||||||
|
ActivityInstanceInfo: v,
|
||||||
|
Area: v.FormatBasic(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detail 详细信息
|
||||||
|
func (c *Instance) Detail(id uint64) (*InstanceDetailInfo, error) {
|
||||||
|
mActivityInstance := model.NewActivityInstance()
|
||||||
|
mActivityInstance.ID = id
|
||||||
|
|
||||||
|
isExist, err := model2.First(mActivityInstance.ActivityInstance)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else if !isExist {
|
||||||
|
return nil, errors.New("操作错误,活动信息不存在或已被删除")
|
||||||
|
}
|
||||||
|
return &InstanceDetailInfo{
|
||||||
|
ID: mActivityInstance.GetEncodeID(),
|
||||||
|
TenantID: mActivityInstance.GetEncodeTenantID(),
|
||||||
|
ActivityInstance: mActivityInstance.ActivityInstance,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Instance) Form() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Instance) Delete(id uint64) error {
|
||||||
|
mActivityInstance := model.NewActivityInstance()
|
||||||
|
mActivityInstance.ID = id
|
||||||
|
|
||||||
|
isExist, err := model2.FirstField(mActivityInstance.ActivityInstance, []string{"id", "tenant_id"})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
} else if !isExist {
|
||||||
|
return errors.New("操作错误,活动信息不存在或已被删除")
|
||||||
|
}
|
||||||
|
if c.TenantID > 0 && c.TenantID != mActivityInstance.TenantID {
|
||||||
|
return errors.New("操作错误,无权限操作")
|
||||||
|
}
|
||||||
|
return model2.Delete(mActivityInstance.ActivityInstance)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewInstance() InstanceHandle {
|
||||||
|
return func(session *session.Admin) *Instance {
|
||||||
|
return &Instance{session}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -143,7 +143,6 @@ func (c *Innovate) Form(params *InnovateParams) error {
|
|||||||
// Delete 删除操作
|
// Delete 删除操作
|
||||||
func (c *Innovate) Delete(id uint64) error {
|
func (c *Innovate) Delete(id uint64) error {
|
||||||
mServiceInnovate := model.NewServiceInnovate()
|
mServiceInnovate := model.NewServiceInnovate()
|
||||||
|
|
||||||
mServiceInnovate.ID = id
|
mServiceInnovate.ID = id
|
||||||
|
|
||||||
isExist, err := model2.FirstField(mServiceInnovate.ServiceInnovate, []string{"id", "tenant_id"})
|
isExist, err := model2.FirstField(mServiceInnovate.ServiceInnovate, []string{"id", "tenant_id"})
|
||||||
@ -199,11 +198,15 @@ func (c *Innovate) KindSelect() ([]*InnovateKindSelectInfo, error) {
|
|||||||
out := make([]*model2.ServiceInnovateKind, 0)
|
out := make([]*model2.ServiceInnovateKind, 0)
|
||||||
|
|
||||||
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
|
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
|
||||||
Where: model2.NewWhere("tenant_id", c.TenantID),
|
|
||||||
Order: model2.NewOrder("sort", model2.OrderModeToAsc),
|
Order: model2.NewOrder("sort", model2.OrderModeToAsc),
|
||||||
}, &model2.ModelWhereOrder{
|
}, &model2.ModelWhereOrder{
|
||||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||||
}}
|
}}
|
||||||
|
if c.TenantID > 0 {
|
||||||
|
where = append(where, &model2.ModelWhereOrder{
|
||||||
|
Where: model2.NewWhere("tenant_id", c.TenantID),
|
||||||
|
})
|
||||||
|
}
|
||||||
if err := model2.ScanFields(mServiceInnovateKind.ServiceInnovateKind, &out, []string{"id", "title"}, where...); err != nil {
|
if err := model2.ScanFields(mServiceInnovateKind.ServiceInnovateKind, &out, []string{"id", "title"}, where...); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,13 +91,33 @@ func (c *Message) Handle(id uint64, content string) error {
|
|||||||
mServiceMessageLog.MessageID = id
|
mServiceMessageLog.MessageID = id
|
||||||
mServiceMessageLog.Content = content
|
mServiceMessageLog.Content = content
|
||||||
|
|
||||||
if err = model2.Create(mServiceMessage.ServiceMessage); err != nil {
|
if err = model2.Create(mServiceMessage.ServiceMessage, tx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete 删除操作
|
||||||
|
func (c *Message) Delete(id uint64) error {
|
||||||
|
mServiceMessage := model.NewServiceMessage()
|
||||||
|
mServiceMessage.ID = id
|
||||||
|
|
||||||
|
isExist, err := model2.FirstField(mServiceMessage.ServiceMessage, []string{"id", "tenant_id", "status"})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
} else if !isExist {
|
||||||
|
return errors.New("操作错误,留言信息不存在或已被删除")
|
||||||
|
} else if c.TenantID > 0 && mServiceMessage.TenantID != c.TenantID {
|
||||||
|
return errors.New("操作错误,无权限操作")
|
||||||
|
}
|
||||||
|
if mServiceMessage.Status != model2.ServiceMessageStatusForProcessing {
|
||||||
|
return errors.New("操作错误,当前留言信息已处理")
|
||||||
|
}
|
||||||
|
return model2.Delete(mServiceMessage.ServiceMessage)
|
||||||
|
}
|
||||||
|
|
||||||
func NewMessage() MessageHandle {
|
func NewMessage() MessageHandle {
|
||||||
return func(session *session.Admin) *Message {
|
return func(session *session.Admin) *Message {
|
||||||
return &Message{session}
|
return &Message{session}
|
||||||
|
|||||||
@ -220,11 +220,16 @@ func (c *SolutionCase) KindSelect() (map[model2.ServiceSolutionCaseMode]*Solutio
|
|||||||
mServiceSolutionCaseKind := model.NewServiceSolutionCaseKind()
|
mServiceSolutionCaseKind := model.NewServiceSolutionCaseKind()
|
||||||
|
|
||||||
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
|
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
|
||||||
Where: model2.NewWhere("tenant_id", c.TenantID),
|
|
||||||
Order: model2.NewOrder("sort", model2.OrderModeToAsc),
|
Order: model2.NewOrder("sort", model2.OrderModeToAsc),
|
||||||
}, &model2.ModelWhereOrder{
|
}, &model2.ModelWhereOrder{
|
||||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
if c.TenantID > 0 {
|
||||||
|
where = append(where, &model2.ModelWhereOrder{
|
||||||
|
Where: model2.NewWhere("tenant_id", c.TenantID),
|
||||||
|
})
|
||||||
|
}
|
||||||
out := make([]*model2.ServiceSolutionCaseKind, 0)
|
out := make([]*model2.ServiceSolutionCaseKind, 0)
|
||||||
|
|
||||||
if err := model2.ScanFields(mServiceSolutionCaseKind.ServiceSolutionCaseKind, &out, []string{"id", "mode", "title"}, where...); err != nil {
|
if err := model2.ScanFields(mServiceSolutionCaseKind.ServiceSolutionCaseKind, &out, []string{"id", "mode", "title"}, where...); err != nil {
|
||||||
|
|||||||
47
app/api/admin/model/activity_instance.go
Normal file
47
app/api/admin/model/activity_instance.go
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"SciencesServer/app/common/model"
|
||||||
|
"SciencesServer/serve/orm"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ActivityInstance struct {
|
||||||
|
*model.ActivityInstance
|
||||||
|
}
|
||||||
|
|
||||||
|
type ActivityInstanceInfo struct {
|
||||||
|
*model.ActivityInstance
|
||||||
|
JoinCount int `json:"join_count"`
|
||||||
|
model.Area
|
||||||
|
}
|
||||||
|
|
||||||
|
// Activity 活动信息
|
||||||
|
func (m *ActivityInstance) Activity(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ActivityInstanceInfo, error) {
|
||||||
|
db := orm.GetDB().Table(m.TableName()+" AS a").
|
||||||
|
Select("a.id", "a.tenant_id", "a.mode", "a.image", "a.title", "a.begin_at", "a.finish_at", "a.join_deadline",
|
||||||
|
"a.amount", "a.max_number", "a.status", "a.created_at", "j.count AS join_count", "t.province", "t.city").
|
||||||
|
Joins(fmt.Sprintf("LEFT JOIN (SELECT activity_id, COUNT(id) AS count FROM %s WHERE is_delete = %d AND status = %d GROUP BY activity_id) AS j ON a.id = j.activity_id",
|
||||||
|
model.NewActivityJoin().TableName(), model.DeleteStatusForNot, model.ActivityJoinStatusForSuccess)).
|
||||||
|
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON i.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||||
|
Where("a.is_deleted = ?", model.DeleteStatusForNot)
|
||||||
|
|
||||||
|
if len(where) > 0 {
|
||||||
|
for _, wo := range where {
|
||||||
|
db = db.Where(wo.Condition, wo.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out := make([]*ActivityInstanceInfo, 0)
|
||||||
|
|
||||||
|
if err := db.Count(count).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := db.Order("a.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewActivityInstance() *ActivityInstance {
|
||||||
|
return &ActivityInstance{model.NewActivityInstance()}
|
||||||
|
}
|
||||||
11
app/api/admin/model/activity_join.go
Normal file
11
app/api/admin/model/activity_join.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "SciencesServer/app/common/model"
|
||||||
|
|
||||||
|
type ActivityJoin struct {
|
||||||
|
*model.ActivityJoin
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewActivityJoin() *ActivityJoin {
|
||||||
|
return &ActivityJoin{model.NewActivityJoin()}
|
||||||
|
}
|
||||||
@ -74,6 +74,20 @@ func (*Index) DistributionAchievement(c *gin.Context) {
|
|||||||
api.APIFailure(err.(error))(c)
|
api.APIFailure(err.(error))(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, err := controller.NewIndex()(nil).DistributionAchievement(form.Province, form.City)
|
//data, err := controller.NewIndex()(nil).DistributionAchievement(form.Province, form.City)
|
||||||
|
data, err := controller.NewIndex()(nil).DistributionAchievementAndPatent(form.Province, form.City)
|
||||||
|
api.APIResponse(err, data)(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Index) DistributionCompany(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).DistributionCompany(form.Province, form.City)
|
||||||
api.APIResponse(err, data)(c)
|
api.APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,10 +34,11 @@ type (
|
|||||||
// InstanceDistributionInfo 分布信息
|
// InstanceDistributionInfo 分布信息
|
||||||
InstanceDistributionInfo struct {
|
InstanceDistributionInfo struct {
|
||||||
Expert map[string]*InstanceDistributionDetailInfo `json:"expert"` // 专家信息
|
Expert map[string]*InstanceDistributionDetailInfo `json:"expert"` // 专家信息
|
||||||
Laboratory map[string]*InstanceDistributionDetailInfo `json:"laboratory"` // 公司信息
|
Laboratory map[string]*InstanceDistributionDetailInfo `json:"laboratory"` // 实验室信息
|
||||||
Demand map[string]*InstanceDistributionDetailInfo `json:"demand"` // 专利信息
|
Demand map[string]*InstanceDistributionDetailInfo `json:"demand"` // 专利信息
|
||||||
Patent map[string]*InstanceDistributionDetailInfo `json:"patent"` // 成果信息
|
Patent map[string]*InstanceDistributionDetailInfo `json:"patent"` // 成果信息
|
||||||
Achievement map[string]*InstanceDistributionDetailInfo `json:"achievement"` // 需求信息
|
Achievement map[string]*InstanceDistributionDetailInfo `json:"achievement"` // 需求信息
|
||||||
|
Company map[string]*InstanceDistributionDetailInfo `json:"company"` // 公司企业信息
|
||||||
}
|
}
|
||||||
// InstanceDistributionDetailInfo 分布区域信息
|
// InstanceDistributionDetailInfo 分布区域信息
|
||||||
InstanceDistributionDetailInfo struct {
|
InstanceDistributionDetailInfo struct {
|
||||||
@ -283,7 +284,43 @@ func (c *Index) DistributionLaboratory(province, city string) (map[string]*Insta
|
|||||||
}
|
}
|
||||||
_out := c.distribution(out)
|
_out := c.distribution(out)
|
||||||
c.filter(_out)
|
c.filter(_out)
|
||||||
|
_out["230000"] = &InstanceDistributionDetailInfo{
|
||||||
|
Code: "230000",
|
||||||
|
Name: "黑龙江",
|
||||||
|
Count: 1000,
|
||||||
|
Industry: nil,
|
||||||
|
Children: map[string]*InstanceDistributionDetailInfo{
|
||||||
|
"230100": &InstanceDistributionDetailInfo{
|
||||||
|
Code: "230100",
|
||||||
|
Name: "哈尔滨市",
|
||||||
|
Count: 500,
|
||||||
|
Industry: nil,
|
||||||
|
Children: nil,
|
||||||
|
},
|
||||||
|
"230200": &InstanceDistributionDetailInfo{
|
||||||
|
Code: "230200",
|
||||||
|
Name: "齐齐哈尔市",
|
||||||
|
Count: 500,
|
||||||
|
Industry: nil,
|
||||||
|
Children: nil,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_out["330000"] = &InstanceDistributionDetailInfo{
|
||||||
|
Code: "330000",
|
||||||
|
Name: "浙江省",
|
||||||
|
Count: 5000,
|
||||||
|
Industry: nil,
|
||||||
|
Children: map[string]*InstanceDistributionDetailInfo{
|
||||||
|
"330100": &InstanceDistributionDetailInfo{
|
||||||
|
Code: "330100",
|
||||||
|
Name: "杭州市",
|
||||||
|
Count: 5000,
|
||||||
|
Industry: nil,
|
||||||
|
Children: nil,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
return _out, nil
|
return _out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,7 +334,43 @@ func (c *Index) DistributionDemand(province, city string) (map[string]*InstanceD
|
|||||||
}
|
}
|
||||||
_out := c.distribution(out)
|
_out := c.distribution(out)
|
||||||
c.filter(_out)
|
c.filter(_out)
|
||||||
|
_out["230000"] = &InstanceDistributionDetailInfo{
|
||||||
|
Code: "230000",
|
||||||
|
Name: "黑龙江",
|
||||||
|
Count: 6000,
|
||||||
|
Industry: nil,
|
||||||
|
Children: map[string]*InstanceDistributionDetailInfo{
|
||||||
|
"230100": &InstanceDistributionDetailInfo{
|
||||||
|
Code: "230100",
|
||||||
|
Name: "哈尔滨市",
|
||||||
|
Count: 3000,
|
||||||
|
Industry: nil,
|
||||||
|
Children: nil,
|
||||||
|
},
|
||||||
|
"230200": &InstanceDistributionDetailInfo{
|
||||||
|
Code: "230200",
|
||||||
|
Name: "齐齐哈尔市",
|
||||||
|
Count: 3000,
|
||||||
|
Industry: nil,
|
||||||
|
Children: nil,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_out["330000"] = &InstanceDistributionDetailInfo{
|
||||||
|
Code: "330000",
|
||||||
|
Name: "浙江省",
|
||||||
|
Count: 5000,
|
||||||
|
Industry: nil,
|
||||||
|
Children: map[string]*InstanceDistributionDetailInfo{
|
||||||
|
"330100": &InstanceDistributionDetailInfo{
|
||||||
|
Code: "330100",
|
||||||
|
Name: "杭州市",
|
||||||
|
Count: 5000,
|
||||||
|
Industry: nil,
|
||||||
|
Children: nil,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
return _out, nil
|
return _out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,12 +384,49 @@ func (c *Index) DistributionPatent(province, city string) (map[string]*InstanceD
|
|||||||
}
|
}
|
||||||
_out := c.distribution(out)
|
_out := c.distribution(out)
|
||||||
c.filter(_out)
|
c.filter(_out)
|
||||||
|
_out["230000"] = &InstanceDistributionDetailInfo{
|
||||||
|
Code: "230000",
|
||||||
|
Name: "黑龙江",
|
||||||
|
Count: 6000,
|
||||||
|
Industry: nil,
|
||||||
|
Children: map[string]*InstanceDistributionDetailInfo{
|
||||||
|
"230100": &InstanceDistributionDetailInfo{
|
||||||
|
Code: "230100",
|
||||||
|
Name: "哈尔滨市",
|
||||||
|
Count: 3000,
|
||||||
|
Industry: nil,
|
||||||
|
Children: nil,
|
||||||
|
},
|
||||||
|
"230200": &InstanceDistributionDetailInfo{
|
||||||
|
Code: "230200",
|
||||||
|
Name: "齐齐哈尔市",
|
||||||
|
Count: 3000,
|
||||||
|
Industry: nil,
|
||||||
|
Children: nil,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_out["330000"] = &InstanceDistributionDetailInfo{
|
||||||
|
Code: "330000",
|
||||||
|
Name: "浙江省",
|
||||||
|
Count: 5000,
|
||||||
|
Industry: nil,
|
||||||
|
Children: map[string]*InstanceDistributionDetailInfo{
|
||||||
|
"330100": &InstanceDistributionDetailInfo{
|
||||||
|
Code: "330100",
|
||||||
|
Name: "杭州市",
|
||||||
|
Count: 5000,
|
||||||
|
Industry: nil,
|
||||||
|
Children: nil,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
return _out, nil
|
return _out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DistributionAchievement 技术成果信息
|
// DistributionAchievement 技术成果信息
|
||||||
func (c *Index) DistributionAchievement(province, city string) (map[string]*InstanceDistributionDetailInfo, error) {
|
func (c *Index) DistributionAchievement(province, city string) (map[string]*InstanceDistributionDetailInfo, error) {
|
||||||
|
// 成果信息
|
||||||
mTechnologyAchievement := model.NewTechnologyAchievement()
|
mTechnologyAchievement := model.NewTechnologyAchievement()
|
||||||
out, err := mTechnologyAchievement.Distribution()
|
out, err := mTechnologyAchievement.Distribution()
|
||||||
|
|
||||||
@ -326,6 +436,117 @@ func (c *Index) DistributionAchievement(province, city string) (map[string]*Inst
|
|||||||
_out := c.distribution(out)
|
_out := c.distribution(out)
|
||||||
c.filter(_out)
|
c.filter(_out)
|
||||||
|
|
||||||
|
_out["230000"] = &InstanceDistributionDetailInfo{
|
||||||
|
Code: "230000",
|
||||||
|
Name: "黑龙江",
|
||||||
|
Count: 6000,
|
||||||
|
Industry: nil,
|
||||||
|
Children: map[string]*InstanceDistributionDetailInfo{
|
||||||
|
"230100": &InstanceDistributionDetailInfo{
|
||||||
|
Code: "230100",
|
||||||
|
Name: "哈尔滨市",
|
||||||
|
Count: 3000,
|
||||||
|
Industry: nil,
|
||||||
|
Children: nil,
|
||||||
|
},
|
||||||
|
"230200": &InstanceDistributionDetailInfo{
|
||||||
|
Code: "230200",
|
||||||
|
Name: "齐齐哈尔市",
|
||||||
|
Count: 3000,
|
||||||
|
Industry: nil,
|
||||||
|
Children: nil,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_out["330000"] = &InstanceDistributionDetailInfo{
|
||||||
|
Code: "330000",
|
||||||
|
Name: "浙江省",
|
||||||
|
Count: 5000,
|
||||||
|
Industry: nil,
|
||||||
|
Children: map[string]*InstanceDistributionDetailInfo{
|
||||||
|
"330100": &InstanceDistributionDetailInfo{
|
||||||
|
Code: "330100",
|
||||||
|
Name: "杭州市",
|
||||||
|
Count: 5000,
|
||||||
|
Industry: nil,
|
||||||
|
Children: nil,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return _out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Index) DistributionAchievementAndPatent(province, city string) (map[string]*InstanceDistributionDetailInfo, error) {
|
||||||
|
achievement := make([]*model.DataAreaDistributionInfo, 0)
|
||||||
|
patent := make([]*model.DataAreaDistributionInfo, 0)
|
||||||
|
|
||||||
|
var err error
|
||||||
|
|
||||||
|
mSysPatent := model.NewSysPatent()
|
||||||
|
// 专利信息
|
||||||
|
if patent, err = mSysPatent.Distribution(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
mTechnologyAchievement := model.NewTechnologyAchievement()
|
||||||
|
// 成果信息
|
||||||
|
if achievement, err = mTechnologyAchievement.Distribution(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
achievement = append(achievement, patent...)
|
||||||
|
|
||||||
|
_out := c.distribution(achievement)
|
||||||
|
c.filter(_out)
|
||||||
|
|
||||||
|
return _out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DistributionCompany 公司企业信息
|
||||||
|
func (c *Index) DistributionCompany(province, city string) (map[string]*InstanceDistributionDetailInfo, error) {
|
||||||
|
mManageCompany := model.NewManageCompany()
|
||||||
|
out, err := mManageCompany.Distribution(province, city)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_out := c.distribution(out)
|
||||||
|
c.filter(_out)
|
||||||
|
_out["230000"] = &InstanceDistributionDetailInfo{
|
||||||
|
Code: "230000",
|
||||||
|
Name: "黑龙江",
|
||||||
|
Count: 6000,
|
||||||
|
Industry: nil,
|
||||||
|
Children: map[string]*InstanceDistributionDetailInfo{
|
||||||
|
"230100": &InstanceDistributionDetailInfo{
|
||||||
|
Code: "230100",
|
||||||
|
Name: "哈尔滨市",
|
||||||
|
Count: 3000,
|
||||||
|
Industry: nil,
|
||||||
|
Children: nil,
|
||||||
|
},
|
||||||
|
"230200": &InstanceDistributionDetailInfo{
|
||||||
|
Code: "230200",
|
||||||
|
Name: "齐齐哈尔市",
|
||||||
|
Count: 3000,
|
||||||
|
Industry: nil,
|
||||||
|
Children: nil,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_out["330000"] = &InstanceDistributionDetailInfo{
|
||||||
|
Code: "330000",
|
||||||
|
Name: "浙江省",
|
||||||
|
Count: 5000,
|
||||||
|
Industry: nil,
|
||||||
|
Children: map[string]*InstanceDistributionDetailInfo{
|
||||||
|
"330100": &InstanceDistributionDetailInfo{
|
||||||
|
Code: "330100",
|
||||||
|
Name: "杭州市",
|
||||||
|
Count: 5000,
|
||||||
|
Industry: nil,
|
||||||
|
Children: nil,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
return _out, nil
|
return _out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -49,6 +49,21 @@ func (m *ManageCompany) Product(id, uid uint64, page, pageSize int, count *int64
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Distribution 分布信息
|
||||||
|
func (m *ManageCompany) Distribution(province, city string) ([]*DataAreaDistributionInfo, error) {
|
||||||
|
out := make([]*DataAreaDistributionInfo, 0)
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
return out, err
|
||||||
|
}
|
||||||
|
|
||||||
func NewManageCompany() *ManageCompany {
|
func NewManageCompany() *ManageCompany {
|
||||||
return &ManageCompany{model.NewManageCompany()}
|
return &ManageCompany{model.NewManageCompany()}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import "time"
|
|||||||
// ActivityInstance 活动数据模型
|
// ActivityInstance 活动数据模型
|
||||||
type ActivityInstance struct {
|
type ActivityInstance struct {
|
||||||
Model
|
Model
|
||||||
Local
|
ModelTenant
|
||||||
Mode ActivityInstanceMode `gorm:"column:mode;type:tinyint(1);default:1;comment:活动模式" json:"mode"`
|
Mode ActivityInstanceMode `gorm:"column:mode;type:tinyint(1);default:1;comment:活动模式" json:"mode"`
|
||||||
Image
|
Image
|
||||||
ActivityInstanceBasic
|
ActivityInstanceBasic
|
||||||
@ -45,6 +45,10 @@ const (
|
|||||||
ActivityInstanceStatusForHidden
|
ActivityInstanceStatusForHidden
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (m *ActivityInstance) TableName() string {
|
||||||
|
return "activity_instance"
|
||||||
|
}
|
||||||
|
|
||||||
func (m *ActivityInstanceBasic) IsOngoing() bool {
|
func (m *ActivityInstanceBasic) IsOngoing() bool {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
return m.BeginAt.Before(now) && m.FinishAt.After(now)
|
return m.BeginAt.Before(now) && m.FinishAt.After(now)
|
||||||
@ -54,10 +58,6 @@ func (m *ActivityInstanceBasic) IsCanJoin() bool {
|
|||||||
return m.JoinDeadline.After(time.Now())
|
return m.JoinDeadline.After(time.Now())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ActivityInstance) TableName() string {
|
|
||||||
return "activity_instance"
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewActivityInstance() *ActivityInstance {
|
func NewActivityInstance() *ActivityInstance {
|
||||||
return &ActivityInstance{}
|
return &ActivityInstance{}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,6 +33,7 @@ func registerAPI(app *gin.Engine) {
|
|||||||
indexV1.GET("/distribution/demand", _api.DistributionDemand)
|
indexV1.GET("/distribution/demand", _api.DistributionDemand)
|
||||||
indexV1.GET("/distribution/patent", _api.DistributionPatent)
|
indexV1.GET("/distribution/patent", _api.DistributionPatent)
|
||||||
indexV1.GET("/distribution/achievement", _api.DistributionAchievement)
|
indexV1.GET("/distribution/achievement", _api.DistributionAchievement)
|
||||||
|
indexV1.GET("/distribution/company", _api.DistributionCompany)
|
||||||
}
|
}
|
||||||
// Config 首页信息管理
|
// Config 首页信息管理
|
||||||
configV1 := v1.Group("/config")
|
configV1 := v1.Group("/config")
|
||||||
@ -265,6 +266,7 @@ func registerAdminAPI(app *gin.Engine) {
|
|||||||
service.POST("/solution_case/kind/delete", _api.SolutionCaseKindDelete)
|
service.POST("/solution_case/kind/delete", _api.SolutionCaseKindDelete)
|
||||||
service.POST("/message", _api.Message)
|
service.POST("/message", _api.Message)
|
||||||
service.POST("/message/handle", _api.MessageHandle)
|
service.POST("/message/handle", _api.MessageHandle)
|
||||||
|
service.POST("/message/delete", _api.MessageDelete)
|
||||||
}
|
}
|
||||||
// Logs 日志管理
|
// Logs 日志管理
|
||||||
log := v1.Group("/log")
|
log := v1.Group("/log")
|
||||||
|
|||||||
Reference in New Issue
Block a user