feat:完善项目
This commit is contained in:
@ -237,3 +237,15 @@ func (*Technology) AchievementDelete(c *gin.Context) {
|
|||||||
err := technology.NewAchievement()(api.GetSession()(c).(*session.Admin)).Delete(form.Convert())
|
err := technology.NewAchievement()(api.GetSession()(c).(*session.Admin)).Delete(form.Convert())
|
||||||
api.APIResponse(err)(c)
|
api.APIResponse(err)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Technology) Demand(c *gin.Context) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Technology) DemandDetail(c *gin.Context) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Technology) DemandDelete() {
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
package technology
|
package technology
|
||||||
|
|
||||||
import "SciencesServer/app/session"
|
import (
|
||||||
|
"SciencesServer/app/api/admin/model"
|
||||||
|
"SciencesServer/app/basic/controller"
|
||||||
|
model2 "SciencesServer/app/common/model"
|
||||||
|
"SciencesServer/app/session"
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
type Demand struct {
|
type Demand struct {
|
||||||
*session.Admin
|
*session.Admin
|
||||||
@ -8,12 +14,92 @@ type Demand struct {
|
|||||||
|
|
||||||
type DemandHandle func(session *session.Admin) *Demand
|
type DemandHandle func(session *session.Admin) *Demand
|
||||||
|
|
||||||
func (c *Demand) Instance(tenantID uint64, page, pageSize int) {
|
type (
|
||||||
|
// DemandInfo 需求信息
|
||||||
|
DemandInfo struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
*model.TechnologyDemandInfo
|
||||||
|
Area string `json:"area"`
|
||||||
|
}
|
||||||
|
// DemandDetailInfo 需求详细信息
|
||||||
|
DemandDetailInfo struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
TenantID string `json:"tenant_id"`
|
||||||
|
*model2.TechnologyDemand
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Instance 首页信息
|
||||||
|
func (c *Demand) Instance(tenantID uint64, title string, kind, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
|
mTechnologyDemand := model.NewTechnologyDemand()
|
||||||
|
|
||||||
|
where := make([]*model2.ModelWhere, 0)
|
||||||
|
|
||||||
|
if c.TenantID > 0 {
|
||||||
|
where = append(where, model2.NewWhere("d.tenant_id", c.TenantID))
|
||||||
|
}
|
||||||
|
if tenantID > 0 {
|
||||||
|
where = append(where, model2.NewWhere("d.tenant_id", tenantID))
|
||||||
|
}
|
||||||
|
if title != "" {
|
||||||
|
where = append(where, model2.NewWhereLike("d.title", title))
|
||||||
|
}
|
||||||
|
if kind > 0 {
|
||||||
|
where = append(where, model2.NewWhere("d.kind", kind))
|
||||||
|
}
|
||||||
|
var count int64
|
||||||
|
|
||||||
|
out, err := mTechnologyDemand.Demand(page, pageSize, &count, where...)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
list := make([]*DemandInfo, 0)
|
||||||
|
|
||||||
|
for _, v := range out {
|
||||||
|
list = append(list, &DemandInfo{
|
||||||
|
ID: v.GetEncodeID(),
|
||||||
|
TechnologyDemandInfo: v,
|
||||||
|
Area: v.FormatBasic(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Demand) Delete() {
|
// Detail 详细信息
|
||||||
|
func (c *Demand) Detail(id uint64) (*DemandDetailInfo, error) {
|
||||||
|
mTechnologyDemand := model.NewTechnologyDemand()
|
||||||
|
mTechnologyDemand.ID = id
|
||||||
|
|
||||||
|
isExist, err := model2.First(mTechnologyDemand.TechnologyDemand)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else if !isExist {
|
||||||
|
return nil, errors.New("操作错误,需求信息不存在或已被删除")
|
||||||
|
}
|
||||||
|
return &DemandDetailInfo{
|
||||||
|
ID: mTechnologyDemand.GetEncodeID(),
|
||||||
|
TenantID: mTechnologyDemand.GetEncodeTenantID(),
|
||||||
|
TechnologyDemand: mTechnologyDemand.TechnologyDemand,
|
||||||
|
}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete 删除操作
|
||||||
|
func (c *Demand) Delete(id uint64) error {
|
||||||
|
mTechnologyDemand := model.NewTechnologyDemand()
|
||||||
|
mTechnologyDemand.ID = id
|
||||||
|
|
||||||
|
isExist, err := model2.FirstField(mTechnologyDemand.TechnologyDemand, []string{"id", "tenant_id"})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
} else if !isExist {
|
||||||
|
return errors.New("操作错误,需求信息不存在或已被删除")
|
||||||
|
} else if c.TenantID > 0 && mTechnologyDemand.TenantID != c.TenantID {
|
||||||
|
return errors.New("操作错误,无权限操作")
|
||||||
|
}
|
||||||
|
return model2.Delete(mTechnologyDemand.TechnologyDemand)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDemand() DemandHandle {
|
func NewDemand() DemandHandle {
|
||||||
|
@ -1,12 +1,48 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import "SciencesServer/app/common/model"
|
import (
|
||||||
|
"SciencesServer/app/common/model"
|
||||||
|
"SciencesServer/serve/orm"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
// TechnologyDemand 技术需求
|
// TechnologyDemand 技术需求
|
||||||
type TechnologyDemand struct {
|
type TechnologyDemand struct {
|
||||||
*model.TechnologyDemand
|
*model.TechnologyDemand
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TechnologyDemandInfo struct {
|
||||||
|
*model.ServiceDemand
|
||||||
|
model.Area
|
||||||
|
}
|
||||||
|
|
||||||
|
// Demand 需求信息
|
||||||
|
func (m *TechnologyDemand) Demand(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyDemandInfo, error) {
|
||||||
|
db := orm.GetDB().Table(m.TableName()+" AS d").
|
||||||
|
Select("d.*", "t.province", "t.city").
|
||||||
|
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON ", model.NewSysTenant().TableName())).
|
||||||
|
Where("d.is_deleted = ?", model.DeleteStatusForNot).
|
||||||
|
Where("d.status IN (?)", []model.ServiceDemandStatus{
|
||||||
|
model.ServiceDemandStatusForPublish, model.ServiceDemandStatusForAcceptance,
|
||||||
|
model.ServiceDemandStatusForComplete,
|
||||||
|
})
|
||||||
|
|
||||||
|
if len(where) > 0 {
|
||||||
|
for _, v := range where {
|
||||||
|
db = db.Where(v.Condition, v.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out := make([]*TechnologyDemandInfo, 0)
|
||||||
|
|
||||||
|
if err := db.Count(count).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := db.Order("d.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
func NewTechnologyDemand() *TechnologyDemand {
|
func NewTechnologyDemand() *TechnologyDemand {
|
||||||
return &TechnologyDemand{model.NewTechnologyDemand()}
|
return &TechnologyDemand{model.NewTechnologyDemand()}
|
||||||
}
|
}
|
||||||
|
@ -10,14 +10,17 @@ type Activity struct{}
|
|||||||
|
|
||||||
func (*Activity) Instance(c *gin.Context) {
|
func (*Activity) Instance(c *gin.Context) {
|
||||||
form := &struct {
|
form := &struct {
|
||||||
Title string `json:"title" form:"title"`
|
Title string `json:"title" form:"title"`
|
||||||
|
Industry string `json:"industry" form:"industry"`
|
||||||
|
Status int `json:"status" form:"status"`
|
||||||
api.PageForm
|
api.PageForm
|
||||||
}{}
|
}{}
|
||||||
if err := api.Bind(form)(c); err != nil {
|
if err := api.Bind(form)(c); err != nil {
|
||||||
api.APIFailure(err.(error))(c)
|
api.APIFailure(err.(error))(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, err := controller.NewActivity()(getSession(c), api.GetTenantID()(c).(uint64)).Instance(form.Title, form.Page, form.PageSize)
|
data, err := controller.NewActivity()(getSession(c), api.GetTenantID()(c).(uint64)).Instance(form.Title, form.Industry,
|
||||||
|
form.Status, form.Page, form.PageSize)
|
||||||
api.APIResponse(err, data)(c)
|
api.APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,3 +62,8 @@ func (*Sys) AgreementDetail(c *gin.Context) {
|
|||||||
data, err := sys.NewAgreement()(api.GetTenantID()(c).(uint64)).Detail(form.Convert())
|
data, err := sys.NewAgreement()(api.GetTenantID()(c).(uint64)).Detail(form.Convert())
|
||||||
api.APIResponse(err, data)(c)
|
api.APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Sys) Industry(c *gin.Context) {
|
||||||
|
data, err := sys.NewIndustry()().Instance()
|
||||||
|
api.APIResponse(err, data)(c)
|
||||||
|
}
|
||||||
|
@ -8,6 +8,8 @@ import (
|
|||||||
"SciencesServer/app/session"
|
"SciencesServer/app/session"
|
||||||
"SciencesServer/config"
|
"SciencesServer/config"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Activity struct {
|
type Activity struct {
|
||||||
@ -22,7 +24,8 @@ type (
|
|||||||
ActivityInfo struct {
|
ActivityInfo struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
*model.ActivityInstanceInfo
|
*model.ActivityInstanceInfo
|
||||||
JoinStatus bool `json:"join_status"`
|
IsJoin bool `json:"is_join"`
|
||||||
|
Status int `json:"status"` // 状态(1:未开始,2:进行中,3:已结束)
|
||||||
}
|
}
|
||||||
// ActivityDetail 详细信息
|
// ActivityDetail 详细信息
|
||||||
ActivityDetail struct {
|
ActivityDetail struct {
|
||||||
@ -33,16 +36,30 @@ type (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Instance 活动信息
|
// Instance 活动信息
|
||||||
func (c *Activity) Instance(title string, page, pageSize int) (*controller.ReturnPages, error) {
|
func (c *Activity) Instance(title, industry string, status, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
mActivityInstance := model.NewActivityInstance()
|
mActivityInstance := model.NewActivityInstance()
|
||||||
|
|
||||||
var count int64
|
now := time.Now()
|
||||||
|
|
||||||
where := []*model2.ModelWhere{model2.NewWhere("a.tenant_id", c.tenantID)}
|
where := []*model2.ModelWhere{model2.NewWhere("a.tenant_id", c.tenantID)}
|
||||||
|
|
||||||
if title != "" {
|
if title != "" {
|
||||||
where = append(where, model2.NewWhereLike("a.title", title))
|
where = append(where, model2.NewWhereLike("a.title", title))
|
||||||
}
|
}
|
||||||
|
if industry != "" {
|
||||||
|
where = append(where, model2.NewWhereCondition("a.industry", "LIKE", "%"+fmt.Sprintf(`"%v`, industry)+"%"))
|
||||||
|
}
|
||||||
|
if status > 0 {
|
||||||
|
if status == 1 {
|
||||||
|
where = append(where, model2.NewWhereCondition("a.begin_at", ">", now))
|
||||||
|
} else if status == 2 {
|
||||||
|
where = append(where, model2.NewWhereCondition("a.begin_at", "<=", now),
|
||||||
|
model2.NewWhereCondition("a.finish_at", ">=", now))
|
||||||
|
} else {
|
||||||
|
where = append(where, model2.NewWhereCondition("a.finish_at", "<", now))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var count int64
|
||||||
|
|
||||||
out, err := mActivityInstance.Activity(c.UID, c.SelectIdentity, page, pageSize, &count, where...)
|
out, err := mActivityInstance.Activity(c.UID, c.SelectIdentity, page, pageSize, &count, where...)
|
||||||
|
|
||||||
@ -53,9 +70,22 @@ func (c *Activity) Instance(title string, page, pageSize int) (*controller.Retur
|
|||||||
list := make([]*ActivityInfo, 0)
|
list := make([]*ActivityInfo, 0)
|
||||||
|
|
||||||
for _, v := range out {
|
for _, v := range out {
|
||||||
list = append(list, &ActivityInfo{
|
data := &ActivityInfo{
|
||||||
ID: v.GetEncodeID(), ActivityInstanceInfo: v, JoinStatus: v.JoinID > 0,
|
ID: v.GetEncodeID(), ActivityInstanceInfo: v, IsJoin: v.JoinID > 0, Status: 2,
|
||||||
})
|
}
|
||||||
|
|
||||||
|
if now.After(v.BeginAt) {
|
||||||
|
data.Status = 1
|
||||||
|
goto CONTINUE
|
||||||
|
}
|
||||||
|
|
||||||
|
if now.Before(v.FinishAt) {
|
||||||
|
data.Status = 3
|
||||||
|
goto CONTINUE
|
||||||
|
}
|
||||||
|
CONTINUE:
|
||||||
|
|
||||||
|
list = append(list, data)
|
||||||
}
|
}
|
||||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||||
}
|
}
|
||||||
|
55
app/api/website/controller/sys/industry.go
Normal file
55
app/api/website/controller/sys/industry.go
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
package sys
|
||||||
|
|
||||||
|
import (
|
||||||
|
"SciencesServer/app/api/admin/model"
|
||||||
|
model2 "SciencesServer/app/common/model"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Industry struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type IndustryHandle func() *Industry
|
||||||
|
|
||||||
|
type (
|
||||||
|
// IndustryInfo 行业领域信息
|
||||||
|
IndustryInfo struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
ParentID string `json:"parent_id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Children []*IndustryInfo `json:"children"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func (c *Industry) tree(src []*model2.SysIndustry, parentID uint64) []*IndustryInfo {
|
||||||
|
out := make([]*IndustryInfo, 0)
|
||||||
|
|
||||||
|
for _, v := range src {
|
||||||
|
if v.ParentID == parentID {
|
||||||
|
out = append(out, &IndustryInfo{
|
||||||
|
ID: fmt.Sprintf("%d", v.ID),
|
||||||
|
ParentID: fmt.Sprintf("%d", v.ParentID),
|
||||||
|
Name: v.Name,
|
||||||
|
Children: c.tree(src, v.ID),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// Instance 首页信息
|
||||||
|
func (c *Industry) Instance() ([]*IndustryInfo, error) {
|
||||||
|
mSysIndustry := model.NewSysIndustry()
|
||||||
|
out := make([]*model2.SysIndustry, 0)
|
||||||
|
|
||||||
|
if err := model2.ScanFields(mSysIndustry.SysIndustry, &out, []string{"id", "parent_id", "name"}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return c.tree(out, 0), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewIndustry() IndustryHandle {
|
||||||
|
return func() *Industry {
|
||||||
|
return &Industry{}
|
||||||
|
}
|
||||||
|
}
|
@ -73,6 +73,7 @@ func registerAPI(app *gin.Engine) {
|
|||||||
sysV1.GET("/agreement/detail", _api.AgreementDetail)
|
sysV1.GET("/agreement/detail", _api.AgreementDetail)
|
||||||
sysV1.POST("/about", _api.About)
|
sysV1.POST("/about", _api.About)
|
||||||
sysV1.GET("/about/navigation", _api.AboutNavigation)
|
sysV1.GET("/about/navigation", _api.AboutNavigation)
|
||||||
|
sysV1.GET("/industry", _api.Industry)
|
||||||
}
|
}
|
||||||
// Docking 对接信息管理
|
// Docking 对接信息管理
|
||||||
dockingV1 := v1.Group("/docking")
|
dockingV1 := v1.Group("/docking")
|
||||||
|
Reference in New Issue
Block a user