Commit 5e325a41 by zhengqiuyun86

初始化

parent a760158c
package PagePlus
import (
"git.168cad.top/zhengqiuyun/rym-util/a/exception"
"git.168cad.top/zhengqiuyun/rym-util/a/page"
"git.168cad.top/zhengqiuyun/rym-util/a/util"
"git.168cad.top/zhengqiuyun/rym-util/exception"
page2 "git.168cad.top/zhengqiuyun/rym-util/page"
"gorm.io/gorm"
)
func Page(params []page.Param, pageNum int, pageSize int, m interface{}, data interface{}, orderBy string, db *gorm.DB) *page.Data {
var page = page.Data{}
func Page(params []page2.Param, pageNum int, pageSize int, m interface{}, data interface{}, orderBy string, db *gorm.DB) *page2.Data {
var page = page2.Data{}
page.PageSize = util.IfInt(pageSize == 0, 10, pageSize)
page.PageNum = util.IfInt(pageNum == 0, 1, pageNum)
tx := db.Session(&gorm.Session{PrepareStmt: true})
......
......@@ -3,7 +3,6 @@ package exception
import (
"errors"
"git.168cad.top/zhengqiuyun/rym-util/a/log"
"github.com/go-playground/validator/v10"
"reflect"
)
......
......@@ -2,8 +2,8 @@ package catch
import (
"fmt"
"git.168cad.top/zhengqiuyun/rym-util/a/exception"
"git.168cad.top/zhengqiuyun/rym-util/a/getWay"
"git.168cad.top/zhengqiuyun/rym-util/exception"
"git.168cad.top/zhengqiuyun/rym-util/getWay"
"github.com/gin-gonic/gin"
"runtime"
"strings"
......
......@@ -3,7 +3,6 @@ package generate
import (
"fmt"
"git.168cad.top/zhengqiuyun/rym-util/a/conf"
"github.com/deckarep/golang-set"
"github.com/iancoleman/strcase"
"io"
"os"
......
package generate
import (
"git.168cad.top/zhengqiuyun/rym-util/a/db/mysql"
)
func MysqlAllTables() []Table {
var tables []Table
//查询库中所有表
......
package generate
import (
"git.168cad.top/zhengqiuyun/rym-util/a/db/mysql"
)
func AllTables() []Table {
var tables []Table
//查询库中所有表
......
package getWay
import (
"git.168cad.top/zhengqiuyun/rym-util/a/exception"
"git.168cad.top/zhengqiuyun/rym-util/exception"
"github.com/gin-gonic/gin"
)
......
......@@ -8,6 +8,7 @@ import (
"git.168cad.top/zhengqiuyun/rym-util/a/db/redis"
"git.168cad.top/zhengqiuyun/rym-util/a/log"
"git.168cad.top/zhengqiuyun/rym-util/a/log/es"
conf2 "git.168cad.top/zhengqiuyun/rym-util/conf"
"github.com/gin-gonic/gin"
"net/http"
"time"
......@@ -85,14 +86,14 @@ func logEnd(c *gin.Context, data interface{}) {
rs := string(dataJson)
excludeUrl := []string{""}
if esSwitch {
if util.ArrayContains(excludeUrl, GetURL(c)) && len(rs) > conf.LogResponseLength {
responseStr = rs[0:conf.LogResponseLength] + "......"
if util.ArrayContains(excludeUrl, GetURL(c)) && len(rs) > conf2.LogResponseLength {
responseStr = rs[0:conf2.LogResponseLength] + "......"
} else {
responseStr = rs
}
} else {
if len(rs) > conf.LogResponseLength {
responseStr = rs[0:conf.LogResponseLength] + "......"
if len(rs) > conf2.LogResponseLength {
responseStr = rs[0:conf2.LogResponseLength] + "......"
} else {
responseStr = rs
}
......
This diff is collapsed. Click to expand it.
......@@ -8,8 +8,8 @@ import (
"encoding/json"
"fmt"
"git.168cad.top/zhengqiuyun/rym-util/a/conf"
"git.168cad.top/zhengqiuyun/rym-util/a/exception"
"git.168cad.top/zhengqiuyun/rym-util/a/log"
"git.168cad.top/zhengqiuyun/rym-util/exception"
"io"
"io/ioutil"
"net/http"
......
package log
package a
import (
"bytes"
"fmt"
"git.168cad.top/zhengqiuyun/rym-util/a/conf"
"git.168cad.top/zhengqiuyun/rym-util/conf"
"runtime"
"strconv"
"strings"
......@@ -44,14 +44,14 @@ func Print(tag, msg string, file string, line int) {
}
}
file = file[strings.LastIndex(file, "/")+1:]
fmt.Println(fmt.Sprintf(str, FormatDateMillTime(time.Now()), tag, GetGID(), file, line, msg))
fmt.Println(fmt.Sprintf(str, FormatDateMillTime(time.Now()), tag, getGID(), file, line, msg))
}
func FormatDateMillTime(dataTime time.Time) string {
return dataTime.Format("2006-01-02 15:04:05.000000")
}
func GetGID() uint64 {
func getGID() uint64 {
b := make([]byte, 64)
b = b[:runtime.Stack(b, false)]
b = bytes.TrimPrefix(b, []byte("goroutine "))
......
package rym_util
package log
import (
"git.168cad.top/zhengqiuyun/rym-util/a/conf"
"git.168cad.top/zhengqiuyun/rym-util/a/log"
"git.168cad.top/zhengqiuyun/rym-util/conf"
"git.168cad.top/zhengqiuyun/rym-util/log/a"
"runtime"
"strings"
)
......@@ -16,7 +16,7 @@ func DebugDo(f func()) {
func IsDebug() bool {
ok := false
switch strings.ToLower(conf.LogLevel) {
case strings.ToLower(log.DebugL):
case strings.ToLower(a.DebugL):
ok = true
break
}
......@@ -26,47 +26,47 @@ func IsDebug() bool {
func Debug(msg string) {
ok := false
switch strings.ToLower(conf.LogLevel) {
case strings.ToLower(log.DebugL):
case strings.ToLower(a.DebugL):
ok = true
break
}
if ok {
_, file, line, _ := runtime.Caller(1)
log.Print("Debug", msg, file, line)
a.Print("Debug", msg, file, line)
}
}
func Info(msg string) {
ok := false
switch strings.ToLower(conf.LogLevel) {
case strings.ToLower(log.DebugL):
case strings.ToLower(a.DebugL):
ok = true
break
case strings.ToLower(log.InfoL):
case strings.ToLower(a.InfoL):
ok = true
break
}
if ok {
_, file, line, _ := runtime.Caller(1)
log.Print("Info", msg, file, line)
a.Print("Info", msg, file, line)
}
}
func Error(msg string) {
ok := false
switch strings.ToLower(conf.LogLevel) {
case strings.ToLower(log.DebugL):
case strings.ToLower(a.DebugL):
ok = true
break
case strings.ToLower(log.InfoL):
case strings.ToLower(a.InfoL):
ok = true
break
case strings.ToLower(log.ErrorL):
case strings.ToLower(a.ErrorL):
ok = true
break
}
if ok {
_, file, line, _ := runtime.Caller(1)
log.Print("Error", msg, file, line)
a.Print("Error", msg, file, line)
}
}
package rym_util
package util
func ArrayContains(array []string, e string) bool {
for _, v := range array {
......
package rym_util
package util
import (
"time"
......
package rym_util
package util
func IfInt(isTrue bool, a, b int) int {
if isTrue {
......
package rym_util
package util
import (
"encoding/base64"
......
package rym_util
package util
import (
"bytes"
......@@ -9,7 +9,7 @@ import (
"crypto/sha256"
"encoding/base64"
"fmt"
"git.168cad.top/zhengqiuyun/rym-util/a/exception"
"git.168cad.top/zhengqiuyun/rym-util/exception"
"github.com/wechatpay-apiv3/wechatpay-go/utils"
"sort"
)
......
package rym_util
package util
import (
"encoding/json"
"git.168cad.top/zhengqiuyun/rym-util/a/exception"
"git.168cad.top/zhengqiuyun/rym-util/exception"
"net/url"
"sort"
"strconv"
......
package rym_util
package util
import (
"crypto/md5"
......
package rym_util
package util
import (
"os"
......
package rym_util
package util
func EncodePwd(loginPwd, loginPwdSalt string) string {
pingPwd := loginPwdSalt + loginPwd
......
package rym_util
package util
import (
"bytes"
......
package rym_util
package util
import (
"encoding/json"
"git.168cad.top/zhengqiuyun/rym-util/a/exception"
"git.168cad.top/zhengqiuyun/rym-util/exception"
"github.com/gin-gonic/gin"
"github.com/shopspring/decimal"
"math/rand"
......
......@@ -2,7 +2,7 @@ package main
import (
"fmt"
util "git.168cad.top/zhengqiuyun/rym-util/a/util/aes"
"git.168cad.top/zhengqiuyun/rym-util/util/aes"
)
func main() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment