generated from pkg/go-template
feat : journey
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
da57f02191
commit
75c08d02f8
|
@ -0,0 +1,27 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/error_process"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/service"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
ctxLogger "github.com/luizsuper/ctxLoggers"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func GetJourneyH(ctx *fiber.Ctx) error {
|
||||
journey, err := service.GetJourney(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
ctxLogger.FError(ctx, error_process.ServiceErr, zap.String("", fmt.Sprintf("%+v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
|
||||
return ctx.JSON(success(&Data{
|
||||
Elements: journey,
|
||||
Total: 64,
|
||||
}))
|
||||
}
|
|
@ -1,4 +1,28 @@
|
|||
package model
|
||||
|
||||
type model struct {
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Journey struct {
|
||||
ID int `json:"id" gorm:"column:id"`
|
||||
Shop Shop `gorm:"foreignKey:MID;references:ShopID"`
|
||||
Scripts Scripts `gorm:"foreignKey:Uuid;references:ScriptID"`
|
||||
Persons strs `json:"persons" gorm:"column:persons"`
|
||||
ScriptID string `json:"script_id" gorm:"column:script_id"`
|
||||
Owner string `json:"owner" gorm:"column:owner"`
|
||||
ShopID string `json:"shop_id" gorm:"column:shop_id"`
|
||||
Status int `json:"status" gorm:"column:status"` // 1:进行中 2:已开始 3:已结束
|
||||
}
|
||||
|
||||
func (m *Journey) TableName() string {
|
||||
return "journey"
|
||||
}
|
||||
|
||||
func GetJourneyM(db *gorm.DB) (*Journey, error) {
|
||||
j := new(Journey)
|
||||
|
||||
db.Joins("Shop").Joins("Scripts").First(j)
|
||||
|
||||
return j, nil
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package model
|
||||
|
||||
type Shop struct {
|
||||
ShopName string `json:"shop_name" gorm:"column:shop_name"`
|
||||
ShopAddr string `json:"shop_addr" gorm:"column:shop_addr"`
|
||||
ShopScore float64 `json:"shop_score" gorm:"column:shop_score"`
|
||||
Numone string `json:"numone" gorm:"column:numone"`
|
||||
Numtwo string `json:"numtwo" gorm:"column:numtwo"`
|
||||
ShopLogo string `json:"shop_logo" gorm:"column:shop_logo"`
|
||||
ShopCover string `json:"shop_cover" gorm:"column:shop_cover"`
|
||||
MID string `json:"m_id" gorm:"column:m_id"`
|
||||
Longtitude float64 `json:"longtitude" gorm:"column:longtitude"`
|
||||
Latitude float64 `json:"latitude" gorm:"column:latitude"`
|
||||
ID int `json:"id" gorm:"column:id"`
|
||||
}
|
||||
|
||||
func (m *Shop) TableName() string {
|
||||
return "shop"
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/gorm_helper"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/model"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func GetJourney(ctx *fiber.Ctx) (*model.Journey, error) {
|
||||
var (
|
||||
db *gorm.DB
|
||||
err error
|
||||
)
|
||||
if db, err = gorm_helper.GetContextDB(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model.GetJourneyM(db)
|
||||
}
|
|
@ -4,9 +4,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/model"
|
||||
"git.icechen.cn/monorepo/backend/pkg/config"
|
||||
"git.icechen.cn/monorepo/backend/pkg/wx"
|
||||
ctxLogger "github.com/luizsuper/ctxLoggers"
|
||||
"math/rand"
|
||||
"strconv"
|
||||
"time"
|
||||
|
@ -15,15 +13,15 @@ import (
|
|||
var appMap = make(map[string]Applet)
|
||||
|
||||
func init() {
|
||||
a := new(AppletConfig)
|
||||
err := config.GetConfig(a)
|
||||
if err != nil {
|
||||
ctxLogger.Error(nil, err.Error())
|
||||
panic(err)
|
||||
}
|
||||
for _, v := range a.Apps {
|
||||
appMap[v.Type] = v
|
||||
}
|
||||
//a := new(AppletConfig)
|
||||
//err := config.GetConfig(a)
|
||||
//if err != nil {
|
||||
// ctxLogger.Error(nil, err.Error())
|
||||
// panic(err)
|
||||
//}
|
||||
//for _, v := range a.Apps {
|
||||
// appMap[v.Type] = v
|
||||
//}
|
||||
}
|
||||
|
||||
type AppletConfig struct {
|
||||
|
|
|
@ -21,6 +21,7 @@ const (
|
|||
scripts = "/scripts"
|
||||
script = "/script"
|
||||
userInfo = "/userInfo"
|
||||
journey = "/js"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -120,6 +121,11 @@ func routerInit() {
|
|||
return handler.Login(ctx)
|
||||
})
|
||||
|
||||
journeyGroup := app.Group(journey)
|
||||
journeyGroup.Get("", func(ctx *fiber.Ctx) error {
|
||||
return handler.GetJourneyH(ctx)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func serverStart() {
|
||||
|
|
Loading…
Reference in New Issue