This commit is contained in:
vilet.yy 2021-06-10 16:01:23 +08:00
parent 2d53f4558b
commit d959f74261
4 changed files with 14 additions and 13 deletions

View File

@ -1,7 +1,7 @@
/* /*
* @Date: 2021-03-22 10:12:38 * @Date: 2021-03-22 10:12:38
* @LastEditors: viletyy * @LastEditors: viletyy
* @LastEditTime: 2021-06-10 10:54:40 * @LastEditTime: 2021-06-10 15:43:12
* @FilePath: /potato/initialize/gorm.go * @FilePath: /potato/initialize/gorm.go
*/ */
package initialize package initialize
@ -13,8 +13,8 @@ import (
_ "github.com/jinzhu/gorm/dialects/mysql" _ "github.com/jinzhu/gorm/dialects/mysql"
_ "github.com/jinzhu/gorm/dialects/postgres" _ "github.com/jinzhu/gorm/dialects/postgres"
"github.com/viletyy/potato/global" "github.com/viletyy/potato/global"
"github.com/viletyy/potato/models" "github.com/viletyy/potato/internal/model"
"github.com/viletyy/potato/models/basic" "github.com/viletyy/potato/internal/model/basic"
) )
func Gorm() *gorm.DB { func Gorm() *gorm.DB {
@ -62,7 +62,7 @@ func GormSet(db *gorm.DB) {
basic.Vendor{}, basic.Vendor{},
basic.Business{}, basic.Business{},
basic.MetaDatabase{}, basic.MetaDatabase{},
models.User{}, model.User{},
) )
// 设置空闲连接池中的最大连接数 // 设置空闲连接池中的最大连接数

View File

@ -1,7 +1,7 @@
/* /*
* @Date: 2021-03-22 17:03:27 * @Date: 2021-03-22 17:03:27
* @LastEditors: viletyy * @LastEditors: viletyy
* @LastEditTime: 2021-04-06 17:47:11 * @LastEditTime: 2021-06-10 15:43:37
* @FilePath: /potato/initialize/server.go * @FilePath: /potato/initialize/server.go
*/ */
package initialize package initialize
@ -15,11 +15,12 @@ import (
"time" "time"
"github.com/viletyy/potato/global" "github.com/viletyy/potato/global"
"github.com/viletyy/potato/routers" "github.com/viletyy/potato/internal/routers"
"github.com/viletyy/potato/pkg"
) )
func RunServer() { func RunServer() {
if err := utils.InitTrans("zh"); err != nil { if err := pkg.InitTrans("zh"); err != nil {
fmt.Printf("init trans failed, err:%v\n", err) fmt.Printf("init trans failed, err:%v\n", err)
return return
} }

View File

@ -1,7 +1,7 @@
/* /*
* @Date: 2021-03-22 10:13:04 * @Date: 2021-03-22 10:13:04
* @LastEditors: viletyy * @LastEditors: viletyy
* @LastEditTime: 2021-06-10 15:01:09 * @LastEditTime: 2021-06-10 15:44:06
* @FilePath: /potato/initialize/zap.go * @FilePath: /potato/initialize/zap.go
*/ */
package initialize package initialize
@ -11,7 +11,7 @@ import (
"time" "time"
"github.com/viletyy/potato/global" "github.com/viletyy/potato/global"
"github.com/viletyy/potato/utils" "github.com/viletyy/potato/pkg"
"github.com/viletyy/yolk/directory" "github.com/viletyy/yolk/directory"
"go.uber.org/zap" "go.uber.org/zap"
"go.uber.org/zap/zapcore" "go.uber.org/zap/zapcore"
@ -56,7 +56,7 @@ func Zap() (logger *zap.Logger) {
} }
func getEncoderCore() (core zapcore.Core) { func getEncoderCore() (core zapcore.Core) {
writer, err := utils.GetWriteSyncer() // 使用file-rotatelogs进行日志分割 writer, err := pkg.GetWriteSyncer() // 使用file-rotatelogs进行日志分割
if err != nil { if err != nil {
fmt.Printf("Get Write Syncer Failed err: %v", err.Error()) fmt.Printf("Get Write Syncer Failed err: %v", err.Error())
return return

View File

@ -1,7 +1,7 @@
/* /*
* @Date: 2021-06-10 15:27:36 * @Date: 2021-06-10 15:27:36
* @LastEditors: viletyy * @LastEditors: viletyy
* @LastEditTime: 2021-06-10 15:30:56 * @LastEditTime: 2021-06-10 15:52:48
* @FilePath: /potato/pkg/paginator.go * @FilePath: /potato/pkg/paginator.go
*/ */
package pkg package pkg
@ -12,7 +12,7 @@ import (
) )
func GetPageInfo(c *gin.Context) (page, pageSize int) { func GetPageInfo(c *gin.Context) (page, pageSize int) {
page = convert.ToString(c.DefaultQuery("page", "1")).Int() page, _ = convert.StrTo(c.DefaultQuery("page", "1")).Int()
pageSize = convert.ToString(c.DefaultQuery("page_size", "10")).Int() pageSize, _ = convert.StrTo(c.DefaultQuery("page_size", "10")).Int()
return return
} }