feat:完善项目
This commit is contained in:
@ -1,26 +0,0 @@
|
|||||||
package api
|
|
||||||
|
|
||||||
import (
|
|
||||||
"SciencesServer/app/api/website/controller"
|
|
||||||
"SciencesServer/app/basic/api"
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
)
|
|
||||||
|
|
||||||
type About struct{}
|
|
||||||
|
|
||||||
func (*About) Instance(c *gin.Context) {
|
|
||||||
form := &struct {
|
|
||||||
NavigationID string `json:"navigation_id" form:"navigation_id"`
|
|
||||||
}{}
|
|
||||||
if err := api.Bind(form)(c); err != nil {
|
|
||||||
api.APIFailure(err.(error))(c)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
data, err := controller.NewAbout()().Instance((&api.IDStringForm{ID: form.NavigationID}).Convert())
|
|
||||||
api.APIResponse(err, data)(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*About) Navigation(c *gin.Context) {
|
|
||||||
data, err := controller.NewAbout()().Navigation()
|
|
||||||
api.APIResponse(err, data)(c)
|
|
||||||
}
|
|
@ -18,7 +18,7 @@ func (*Activity) Instance(c *gin.Context) {
|
|||||||
api.APIFailure(err.(error))(c)
|
api.APIFailure(err.(error))(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, err := controller.NewActivity()(getSession(c)).Instance(form.Title, form.Mode, form.Page, form.PageSize)
|
data, err := controller.NewActivity()(getSession(c), api.GetTenantID()(c).(uint64)).Instance(form.Title, form.Mode, form.Page, form.PageSize)
|
||||||
api.APIResponse(err, data)(c)
|
api.APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ func (*Activity) Detail(c *gin.Context) {
|
|||||||
api.APIFailure(err.(error))(c)
|
api.APIFailure(err.(error))(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, err := controller.NewActivity()(getSession(c)).Detail(form.Convert())
|
data, err := controller.NewActivity()(getSession(c), api.GetTenantID()(c).(uint64)).Detail(form.Convert())
|
||||||
api.APIResponse(err, data)(c)
|
api.APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,6 +42,6 @@ func (*Activity) Join(c *gin.Context) {
|
|||||||
api.APIFailure(err.(error))(c)
|
api.APIFailure(err.(error))(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := controller.NewActivity()(getSession(c)).Join(form.Convert())
|
err := controller.NewActivity()(getSession(c), api.GetTenantID()(c).(uint64)).Join(form.Convert())
|
||||||
api.APIResponse(err)(c)
|
api.APIResponse(err)(c)
|
||||||
}
|
}
|
||||||
|
@ -15,12 +15,29 @@ func (*Sys) Platform(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (*Sys) Navigation(c *gin.Context) {
|
func (*Sys) Navigation(c *gin.Context) {
|
||||||
data, err := controller.NewNavigation()().Instance()
|
data, err := sys.NewNavigation()(api.GetTenantID()(c).(uint64)).Instance()
|
||||||
|
api.APIResponse(err, data)(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Sys) About(c *gin.Context) {
|
||||||
|
form := &struct {
|
||||||
|
NavigationID string `json:"navigation_id" form:"navigation_id"`
|
||||||
|
}{}
|
||||||
|
if err := api.Bind(form)(c); err != nil {
|
||||||
|
api.APIFailure(err.(error))(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data, err := sys.NewAbout()(api.GetTenantID()(c).(uint64)).Instance((&api.IDStringForm{ID: form.NavigationID}).Convert())
|
||||||
|
api.APIResponse(err, data)(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Sys) AboutNavigation(c *gin.Context) {
|
||||||
|
data, err := sys.NewAbout()(api.GetTenantID()(c).(uint64)).Navigation()
|
||||||
api.APIResponse(err, data)(c)
|
api.APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Sys) Agreement(c *gin.Context) {
|
func (*Sys) Agreement(c *gin.Context) {
|
||||||
data, err := sys.NewAgreement()(getSession(c), api.GetTenantID()(c).(uint64)).Instance()
|
data, err := sys.NewAgreement()(api.GetTenantID()(c).(uint64)).Instance()
|
||||||
api.APIResponse(err, data)(c)
|
api.APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,6 +48,6 @@ func (*Sys) AgreementDetail(c *gin.Context) {
|
|||||||
api.APIFailure(err.(error))(c)
|
api.APIFailure(err.(error))(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, err := sys.NewAgreement()(getSession(c), 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)
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,10 @@ import (
|
|||||||
|
|
||||||
type Activity struct {
|
type Activity struct {
|
||||||
*session.Enterprise
|
*session.Enterprise
|
||||||
|
tenantID uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
type ActivityHandle func(session *session.Enterprise) *Activity
|
type ActivityHandle func(session *session.Enterprise, tenantID uint64) *Activity
|
||||||
|
|
||||||
type (
|
type (
|
||||||
// ActivityInfo 活动信息
|
// ActivityInfo 活动信息
|
||||||
@ -37,7 +38,7 @@ func (c *Activity) Instance(title string, mode, page, pageSize int) (*controller
|
|||||||
|
|
||||||
var count int64
|
var count int64
|
||||||
|
|
||||||
where := make([]*model2.ModelWhere, 0)
|
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))
|
||||||
@ -82,7 +83,7 @@ func (c *Activity) Join(id uint64) error {
|
|||||||
mActivityInstance := model.NewActivityInstance()
|
mActivityInstance := model.NewActivityInstance()
|
||||||
|
|
||||||
isExist, err := model2.FirstField(mActivityInstance.ActivityInstance, []string{"id", "mode", "join_deadline"},
|
isExist, err := model2.FirstField(mActivityInstance.ActivityInstance, []string{"id", "mode", "join_deadline"},
|
||||||
model2.NewWhere("status", model2.NewWhere("id", id)),
|
model2.NewWhere("id", id), model2.NewWhere("tenant_id", c.tenantID),
|
||||||
model2.NewWhere("status", model2.ActivityInstanceStatusForShow))
|
model2.NewWhere("status", model2.ActivityInstanceStatusForShow))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -115,7 +116,7 @@ func (c *Activity) Join(id uint64) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewActivity() ActivityHandle {
|
func NewActivity() ActivityHandle {
|
||||||
return func(session *session.Enterprise) *Activity {
|
return func(session *session.Enterprise, tenantID uint64) *Activity {
|
||||||
return &Activity{session}
|
return &Activity{Enterprise: session, tenantID: tenantID}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
package controller
|
package sys
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"SciencesServer/app/api/website/model"
|
"SciencesServer/app/api/website/model"
|
||||||
model2 "SciencesServer/app/common/model"
|
model2 "SciencesServer/app/common/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
type About struct{}
|
type About struct {
|
||||||
|
tenantID uint64
|
||||||
|
}
|
||||||
|
|
||||||
type AboutHandle func() *About
|
type AboutHandle func(tenantID uint64) *About
|
||||||
|
|
||||||
type (
|
type (
|
||||||
// AboutInfo 基本信息
|
// AboutInfo 基本信息
|
||||||
@ -45,6 +47,7 @@ func (c *About) Navigation() ([]*AboutNavigationInfo, error) {
|
|||||||
Where: model2.NewWhere("parent_id", 0),
|
Where: model2.NewWhere("parent_id", 0),
|
||||||
Order: model2.NewOrder("sort", model2.OrderModeToDesc),
|
Order: model2.NewOrder("sort", model2.OrderModeToDesc),
|
||||||
}, &model2.ModelWhereOrder{
|
}, &model2.ModelWhereOrder{
|
||||||
|
Where: model2.NewWhere("tenant_id", c.tenantID),
|
||||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -60,7 +63,7 @@ func (c *About) Navigation() ([]*AboutNavigationInfo, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewAbout() AboutHandle {
|
func NewAbout() AboutHandle {
|
||||||
return func() *About {
|
return func(tenantID uint64) *About {
|
||||||
return &About{}
|
return &About{tenantID: tenantID}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,17 +3,15 @@ package sys
|
|||||||
import (
|
import (
|
||||||
"SciencesServer/app/api/website/model"
|
"SciencesServer/app/api/website/model"
|
||||||
model2 "SciencesServer/app/common/model"
|
model2 "SciencesServer/app/common/model"
|
||||||
"SciencesServer/app/session"
|
|
||||||
"errors"
|
"errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Agreement 协议信息
|
// Agreement 协议信息
|
||||||
type Agreement struct {
|
type Agreement struct {
|
||||||
*session.Enterprise
|
|
||||||
tenantID uint64
|
tenantID uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
type AgreementHandle func(session *session.Enterprise, tenantID uint64) *Agreement
|
type AgreementHandle func(tenantID uint64) *Agreement
|
||||||
|
|
||||||
type (
|
type (
|
||||||
// AgreementInfo 协议信息
|
// AgreementInfo 协议信息
|
||||||
@ -68,9 +66,8 @@ func (c *Agreement) Detail(id uint64) (*AgreementDetailInfo, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewAgreement() AgreementHandle {
|
func NewAgreement() AgreementHandle {
|
||||||
return func(session *session.Enterprise, tenantID uint64) *Agreement {
|
return func(tenantID uint64) *Agreement {
|
||||||
return &Agreement{
|
return &Agreement{
|
||||||
Enterprise: session,
|
|
||||||
tenantID: tenantID,
|
tenantID: tenantID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
package controller
|
package sys
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"SciencesServer/app/api/website/model"
|
"SciencesServer/app/api/website/model"
|
||||||
model2 "SciencesServer/app/common/model"
|
model2 "SciencesServer/app/common/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Navigation struct{}
|
type Navigation struct {
|
||||||
|
tenantID uint64
|
||||||
|
}
|
||||||
|
|
||||||
type NavigationHandle func() *Navigation
|
type NavigationHandle func(tenantID uint64) *Navigation
|
||||||
|
|
||||||
type NavigationInfo struct {
|
type NavigationInfo struct {
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
@ -36,7 +38,7 @@ func (c *Navigation) tree(src []*model2.SysNavigation, parentID uint64) []*Navig
|
|||||||
// Instance 导航栏信息
|
// Instance 导航栏信息
|
||||||
func (c *Navigation) Instance() ([]*NavigationInfo, error) {
|
func (c *Navigation) Instance() ([]*NavigationInfo, error) {
|
||||||
mSysNavigation := model.NewSysNavigation()
|
mSysNavigation := model.NewSysNavigation()
|
||||||
out, err := mSysNavigation.Navigation()
|
out, err := mSysNavigation.Navigation(model2.NewWhere("tenant_id", c.tenantID))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -45,7 +47,7 @@ func (c *Navigation) Instance() ([]*NavigationInfo, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewNavigation() NavigationHandle {
|
func NewNavigation() NavigationHandle {
|
||||||
return func() *Navigation {
|
return func(tenantID uint64) *Navigation {
|
||||||
return &Navigation{}
|
return &Navigation{tenantID: tenantID}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,15 +10,20 @@ type SysNavigation struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Navigation 导航信息
|
// Navigation 导航信息
|
||||||
func (m *SysNavigation) Navigation() ([]*model.SysNavigation, error) {
|
func (m *SysNavigation) Navigation(where ...*model.ModelWhere) ([]*model.SysNavigation, error) {
|
||||||
out := make([]*model.SysNavigation, 0)
|
out := make([]*model.SysNavigation, 0)
|
||||||
|
|
||||||
err := orm.GetDB().Table(m.TableName()).
|
db := orm.GetDB().Table(m.TableName()).
|
||||||
Select("id", "parent_id", "title", "link").
|
Select("id", "parent_id", "title", "link").
|
||||||
Where("status = ?", model.SysNavigationStatusForShow).
|
Where("status = ?", model.SysNavigationStatusForShow).
|
||||||
Where("is_deleted = ?", model.DeleteStatusForNot).
|
Where("is_deleted = ?", model.DeleteStatusForNot)
|
||||||
Order("sort " + model.OrderModeToDesc).
|
|
||||||
Scan(&out).Error
|
if len(where) > 0 {
|
||||||
|
for _, v := range where {
|
||||||
|
db = db.Where(v.Condition, v.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
err := db.Order("sort " + model.OrderModeToDesc).Scan(&out).Error
|
||||||
|
|
||||||
return out, err
|
return out, err
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ func (this *Instance) Handle() {
|
|||||||
}
|
}
|
||||||
return out
|
return out
|
||||||
}},
|
}},
|
||||||
&synchronized{iModel: model.NewSysNavigation()},
|
&synchronized{iModel: model.NewSysNavigation()}, &synchronized{iModel: model.NewSysAbout()},
|
||||||
&synchronized{iModel: model.NewSysBanner()}, &synchronized{iModel: model.NewSysAgreement()},
|
&synchronized{iModel: model.NewSysBanner()}, &synchronized{iModel: model.NewSysAgreement()},
|
||||||
// 日志管理
|
// 日志管理
|
||||||
&synchronized{iModel: model.NewSysLog()}, &synchronized{iModel: model.NewSysUserLoginLog()},
|
&synchronized{iModel: model.NewSysLog()}, &synchronized{iModel: model.NewSysUserLoginLog()},
|
||||||
|
@ -65,6 +65,8 @@ func registerAPI(app *gin.Engine) {
|
|||||||
sysV1.GET("/navigation", _api.Navigation)
|
sysV1.GET("/navigation", _api.Navigation)
|
||||||
sysV1.GET("/agreement", _api.Agreement)
|
sysV1.GET("/agreement", _api.Agreement)
|
||||||
sysV1.GET("/agreement/detail", _api.AgreementDetail)
|
sysV1.GET("/agreement/detail", _api.AgreementDetail)
|
||||||
|
sysV1.POST("/about", _api.About)
|
||||||
|
sysV1.GET("/about/navigation", _api.AboutNavigation)
|
||||||
}
|
}
|
||||||
// Docking 对接信息管理
|
// Docking 对接信息管理
|
||||||
dockingV1 := v1.Group("/docking")
|
dockingV1 := v1.Group("/docking")
|
||||||
@ -123,13 +125,6 @@ func registerAPI(app *gin.Engine) {
|
|||||||
technologyV1.POST("/achievement", _api.Achievement)
|
technologyV1.POST("/achievement", _api.Achievement)
|
||||||
technologyV1.POST("/achievement/detail", _api.AchievementDetail)
|
technologyV1.POST("/achievement/detail", _api.AchievementDetail)
|
||||||
}
|
}
|
||||||
// About 关于我们管理
|
|
||||||
aboutV1 := v1.Group("/about")
|
|
||||||
{
|
|
||||||
_api := new(api2.About)
|
|
||||||
aboutV1.POST("", _api.Instance)
|
|
||||||
aboutV1.GET("/navigation", _api.Navigation)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// registerAdminAPI 注册API
|
// registerAdminAPI 注册API
|
||||||
|
Reference in New Issue
Block a user