parent
136eacfacf
commit
bd09b189f1
3 changed files with 44 additions and 8 deletions
|
|
@ -78,7 +78,7 @@ type Recipe01 struct {
|
|||
MenuStatus int `json:"MenuStatus"`
|
||||
StringParam string `json:"StringParam"`
|
||||
TextForWarningBeforePay []string `json:"TextForWarningBeforePay"`
|
||||
CashPrice int `json:"cashPrice"`
|
||||
CashPrice float64 `json:"cashPrice"`
|
||||
Changerecipe string `json:"changerecipe"`
|
||||
Disable bool `json:"disable"`
|
||||
Disable_by_cup bool `json:"disable_by_cup"`
|
||||
|
|
@ -88,7 +88,7 @@ type Recipe01 struct {
|
|||
IsUse bool `json:"isUse"`
|
||||
IsShow bool `json:"isShow"`
|
||||
Name string `json:"name"`
|
||||
NonCashPrice int `json:"nonCashPrice"`
|
||||
NonCashPrice float64 `json:"nonCashPrice"`
|
||||
OtherDescription string `json:"otherDescription"`
|
||||
OtherName string `json:"otherName"`
|
||||
ProductCode string `json:"productCode"`
|
||||
|
|
@ -99,7 +99,7 @@ type Recipe01 struct {
|
|||
Total_weight int `json:"total_weight"`
|
||||
UriData string `json:"uriData"`
|
||||
UseGram bool `json:"useGram"`
|
||||
Weight_float int `json:"weight_float"`
|
||||
Weight_float float64 `json:"weight_float"`
|
||||
}
|
||||
|
||||
func (r *Recipe01) ToMap() map[string]interface{} {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import (
|
|||
"recipe-manager/config"
|
||||
"recipe-manager/data"
|
||||
"recipe-manager/enums/permissions"
|
||||
|
||||
// graph "recipe-manager/graphql"
|
||||
"recipe-manager/helpers"
|
||||
"recipe-manager/middlewares"
|
||||
"recipe-manager/models"
|
||||
|
|
@ -20,16 +22,18 @@ import (
|
|||
"recipe-manager/services/sheet"
|
||||
"recipe-manager/services/user"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/redis/go-redis/v9"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/cors"
|
||||
"github.com/go-co-op/gocron"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
const VERSION = "1.0.35"
|
||||
const VERSION = "1.0.38"
|
||||
|
||||
type Server struct {
|
||||
server *http.Server
|
||||
|
|
@ -119,6 +123,7 @@ func (s *Server) createHandler() {
|
|||
_ = userService.CreateNewUser(context.WithValue(context.Background(), "user", &models.User{Email: "system"}), "wanlop", "wanlop.r@forth.co.th", "", permissions.Permission(superPerm))
|
||||
_ = userService.CreateNewUser(context.WithValue(context.Background(), "user", &models.User{Email: "system"}), "dawit", "dawit.o@forth.co.th", "", permissions.Permission(superPerm))
|
||||
_ = userService.CreateNewUser(context.WithValue(context.Background(), "user", &models.User{Email: "system"}), "narisara", "narisara.k@tao-bin.com", "", permissions.Permission(superPerm))
|
||||
_ = userService.CreateNewUser(context.WithValue(context.Background(), "user", &models.User{Email: "system"}), "Chawin", "Chawin.l@forth.co.th", "", permissions.Permission(superPerm))
|
||||
|
||||
// Auth Router
|
||||
r.Group(func(r chi.Router) {
|
||||
|
|
@ -164,6 +169,12 @@ func (s *Server) createHandler() {
|
|||
|
||||
// //fmt.Println("routers", r.Routes())
|
||||
|
||||
// Graph API
|
||||
// NOTE: some path will be used instead of REST,
|
||||
// but REST endpoints will still not migrate yet.
|
||||
// graphApi := graph.NewGraphQLRouter(s.taoLogger)
|
||||
// graphApi.Route(r)
|
||||
|
||||
})
|
||||
|
||||
// Protected Group V2
|
||||
|
|
@ -207,6 +218,25 @@ func (s *Server) createHandler() {
|
|||
})
|
||||
})
|
||||
|
||||
cron := gocron.NewScheduler(time.UTC)
|
||||
|
||||
cron.Every("24h").Do(func() {
|
||||
//
|
||||
client := http.Client{}
|
||||
resp, err := client.Get("http://localhost:36528/job_status")
|
||||
|
||||
if err != nil {
|
||||
s.taoLogger.Log.Error("Error while trying to get job status", zap.Error(err))
|
||||
return
|
||||
}
|
||||
|
||||
if resp.StatusCode == 200 {
|
||||
s.taoLogger.Log.Info("Job is running")
|
||||
} else {
|
||||
s.taoLogger.Log.Info("Job is not running")
|
||||
}
|
||||
})
|
||||
|
||||
// display all routes [DEBUG]
|
||||
// chi.Walk(r, func(method string, route string, handler http.Handler, middlewares ...func(http.Handler) http.Handler) error {
|
||||
// //fmt.Println(method, " ---> ", route)
|
||||
|
|
|
|||
|
|
@ -3,15 +3,17 @@ package logger
|
|||
import (
|
||||
"os"
|
||||
"recipe-manager/config"
|
||||
"time"
|
||||
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
)
|
||||
|
||||
type TaoLogger struct {
|
||||
cfg *config.ServerConfig
|
||||
enableDebug bool
|
||||
Log *zap.Logger
|
||||
cfg *config.ServerConfig
|
||||
enableDebug bool
|
||||
Log *zap.Logger
|
||||
LastTimeStamp time.Time
|
||||
}
|
||||
|
||||
func (tl *TaoLogger) initConfig() *zap.Logger {
|
||||
|
|
@ -50,7 +52,7 @@ func (tl *TaoLogger) initConfig() *zap.Logger {
|
|||
}
|
||||
|
||||
func NewTaoLogger(cfg *config.ServerConfig) *TaoLogger {
|
||||
logger := &TaoLogger{cfg, false, nil}
|
||||
logger := &TaoLogger{cfg, false, nil, time.Now()}
|
||||
logger.Log = logger.initConfig()
|
||||
|
||||
if cfg.Debug {
|
||||
|
|
@ -61,3 +63,7 @@ func NewTaoLogger(cfg *config.ServerConfig) *TaoLogger {
|
|||
|
||||
return logger
|
||||
}
|
||||
|
||||
func (tl *TaoLogger) UpdateTimestamp() {
|
||||
tl.LastTimeStamp = time.Now()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue