feat: 初始化项目

初始化项目
This commit is contained in:
yaoyilin
2022-10-31 23:08:33 +08:00
parent 1b36bd8fbe
commit d3dcba6489
7 changed files with 23 additions and 14 deletions

View File

@@ -6,6 +6,7 @@
*/
package controller
/*
import (
"easygoadmin/app/dto"
"easygoadmin/app/service"
@@ -101,3 +102,6 @@ func (c *customerCtl) RechargeRefund(ctx *gin.Context) {
Msg: "退款成功",
})
}
*/

View File

@@ -13,7 +13,6 @@ import (
"easygoadmin/app/vo"
"easygoadmin/utils"
"easygoadmin/utils/common"
"easygoadmin/utils/gconv"
"easygoadmin/utils/response"
"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
@@ -32,12 +31,12 @@ func (c *indexCtl) None(ctx *gin.Context) {
ctx.String(http.StatusOK, "")
return
}
res := service.PbShortLink.GetInfoById(ctx, gconv.Int64(id))
if res.Id == 0 || res.Url == "" {
ctx.String(http.StatusOK, "")
return
}
ctx.Redirect(http.StatusTemporaryRedirect, res.Url)
//res := service.PbShortLink.GetInfoById(ctx, gconv.Int64(id))
//if res.Id == 0 || res.Url == "" {
// ctx.String(http.StatusOK, "")
// return
//}
//ctx.Redirect(http.StatusTemporaryRedirect, res.Url)
return
}

View File

@@ -2,12 +2,15 @@ package model
import (
"database/sql/driver"
"easygoadmin/utils"
"fmt"
"time"
)
type LocalTime time.Time
const localDateTimeFormat = utils.LocalDateTimeFormat
func (l LocalTime) MarshalJSON() ([]byte, error) {
b := make([]byte, 0, len(localDateTimeFormat)+2)
b = append(b, '"')

View File

@@ -6,6 +6,7 @@
*/
package service
/*
import (
"easygoadmin/app/dto"
"easygoadmin/app/model"
@@ -162,3 +163,5 @@ func (s *customerService) RechargeRefund(req *dto.CustomerCouponRefundReq, workI
}
}
*/

View File

@@ -17,8 +17,8 @@ import (
func main() {
// 开始调试模式
gin.SetMode(gin.ReleaseMode)
//gin.SetMode(gin.ReleaseMode)
gin.SetMode("debug")
// 实例化配置
config := cfg.Instance()
if config == nil {

View File

@@ -21,7 +21,7 @@ import (
)
func init() {
gin.SetMode(gin.ReleaseMode)
//gin.SetMode(gin.ReleaseMode)
//gin.SetMode(gin.DebugMode)
//fmt.Println("路由已加载")
// 初始化

View File

@@ -8,20 +8,20 @@ package utils
import "time"
const localDateTimeFormat string = "2006-01-02 15:04:05"
const LocalDateTimeFormat string = "2006-01-02 15:04:05"
type LocalTime time.Time
func (l LocalTime) MarshalJSON() ([]byte, error) {
b := make([]byte, 0, len(localDateTimeFormat)+2)
b := make([]byte, 0, len(LocalDateTimeFormat)+2)
b = append(b, '"')
b = time.Time(l).AppendFormat(b, localDateTimeFormat)
b = time.Time(l).AppendFormat(b, LocalDateTimeFormat)
b = append(b, '"')
return b, nil
}
func (l *LocalTime) UnmarshalJSON(b []byte) error {
now, err := time.ParseInLocation(`"`+localDateTimeFormat+`"`, string(b), time.Local)
now, err := time.ParseInLocation(`"`+LocalDateTimeFormat+`"`, string(b), time.Local)
*l = LocalTime(now)
return err
}