style: linker
This commit is contained in:
@@ -11,8 +11,10 @@ import (
|
||||
// 前端发送每片多大
|
||||
// 前端告知是否为最后一片且是否完成
|
||||
|
||||
const breakpointDir = "./breakpointDir/"
|
||||
const finishDir = "./fileDir/"
|
||||
const (
|
||||
breakpointDir = "./breakpointDir/"
|
||||
finishDir = "./fileDir/"
|
||||
)
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
//@function: BreakPointContinue
|
||||
@@ -28,7 +30,6 @@ func BreakPointContinue(content []byte, fileName string, contentNumber int, cont
|
||||
}
|
||||
err, pathc := makeFileContent(content, fileName, path, contentNumber)
|
||||
return err, pathc
|
||||
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
@@ -79,7 +80,7 @@ func MakeFile(fileName string, FileMd5 string) (error, string) {
|
||||
return err, finishDir + fileName
|
||||
}
|
||||
_ = os.MkdirAll(finishDir, os.ModePerm)
|
||||
fd, err := os.OpenFile(finishDir+fileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
|
||||
fd, err := os.OpenFile(finishDir+fileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0o644)
|
||||
if err != nil {
|
||||
return err, finishDir + fileName
|
||||
}
|
||||
|
||||
@@ -2,10 +2,11 @@ package captcha
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/mojocn/base64Captcha"
|
||||
"go.uber.org/zap"
|
||||
"time"
|
||||
)
|
||||
|
||||
func NewDefaultRedisStore() *RedisStore {
|
||||
|
||||
+10
-11
@@ -7,37 +7,36 @@ import (
|
||||
uuid "github.com/satori/go.uuid"
|
||||
)
|
||||
|
||||
func GetClaims(c *gin.Context) (*systemReq.CustomClaims,error) {
|
||||
func GetClaims(c *gin.Context) (*systemReq.CustomClaims, error) {
|
||||
token := c.Request.Header.Get("x-token")
|
||||
j := NewJWT()
|
||||
claims, err := j.ParseToken(token)
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("从Gin的Context中获取从jwt解析信息失败, 请检查请求头是否存在x-token且claims是否为规定结构")
|
||||
}
|
||||
return claims,err
|
||||
return claims, err
|
||||
}
|
||||
|
||||
// 从Gin的Context中获取从jwt解析出来的用户ID
|
||||
func GetUserID(c *gin.Context) uint {
|
||||
if claims, exists := c.Get("claims"); !exists {
|
||||
if cl,err:= GetClaims(c);err!=nil{
|
||||
if cl, err := GetClaims(c); err != nil {
|
||||
return 0
|
||||
}else{
|
||||
} else {
|
||||
return cl.ID
|
||||
}
|
||||
} else {
|
||||
waitUse := claims.(*systemReq.CustomClaims)
|
||||
return waitUse.ID
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 从Gin的Context中获取从jwt解析出来的用户UUID
|
||||
func GetUserUuid(c *gin.Context) uuid.UUID {
|
||||
if claims, exists := c.Get("claims"); !exists {
|
||||
if cl,err:= GetClaims(c);err!=nil{
|
||||
if cl, err := GetClaims(c); err != nil {
|
||||
return uuid.UUID{}
|
||||
}else{
|
||||
} else {
|
||||
return cl.UUID
|
||||
}
|
||||
} else {
|
||||
@@ -49,9 +48,9 @@ func GetUserUuid(c *gin.Context) uuid.UUID {
|
||||
// 从Gin的Context中获取从jwt解析出来的用户角色id
|
||||
func GetUserAuthorityId(c *gin.Context) string {
|
||||
if claims, exists := c.Get("claims"); !exists {
|
||||
if cl,err:= GetClaims(c);err!=nil{
|
||||
if cl, err := GetClaims(c); err != nil {
|
||||
return ""
|
||||
}else{
|
||||
} else {
|
||||
return cl.AuthorityId
|
||||
}
|
||||
} else {
|
||||
@@ -63,9 +62,9 @@ func GetUserAuthorityId(c *gin.Context) string {
|
||||
// 从Gin的Context中获取从jwt解析出来的用户角色id
|
||||
func GetUserInfo(c *gin.Context) *systemReq.CustomClaims {
|
||||
if claims, exists := c.Get("claims"); !exists {
|
||||
if cl,err:= GetClaims(c);err!=nil{
|
||||
if cl, err := GetClaims(c); err != nil {
|
||||
return nil
|
||||
}else{
|
||||
} else {
|
||||
return cl
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -25,12 +25,12 @@ func FileMove(src string, dst string) (err error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var revoke = false
|
||||
revoke := false
|
||||
dir := filepath.Dir(dst)
|
||||
Redirect:
|
||||
_, err = os.Stat(dir)
|
||||
if err != nil {
|
||||
err = os.MkdirAll(dir, 0755)
|
||||
err = os.MkdirAll(dir, 0o755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ func StructToMap(obj interface{}) map[string]interface{} {
|
||||
obj1 := reflect.TypeOf(obj)
|
||||
obj2 := reflect.ValueOf(obj)
|
||||
|
||||
var data = make(map[string]interface{})
|
||||
data := make(map[string]interface{})
|
||||
for i := 0; i < obj1.NumField(); i++ {
|
||||
if obj1.Field(i).Tag.Get("mapstructure") != "" {
|
||||
data[obj1.Field(i).Tag.Get("mapstructure")] = obj2.Field(i).Interface()
|
||||
|
||||
@@ -39,12 +39,12 @@ func AutoInjectionCode(filepath string, funcName string, codeData string) error
|
||||
return err
|
||||
}
|
||||
codeData = strings.TrimSpace(codeData)
|
||||
var codeStartPos = -1
|
||||
var codeEndPos = srcDataLen
|
||||
codeStartPos := -1
|
||||
codeEndPos := srcDataLen
|
||||
var expectedFunction *ast.FuncDecl
|
||||
|
||||
var startCommentPos = -1
|
||||
var endCommentPos = srcDataLen
|
||||
startCommentPos := -1
|
||||
endCommentPos := srcDataLen
|
||||
|
||||
// 如果指定了函数名,先寻找对应函数
|
||||
if funcName != "" {
|
||||
@@ -113,7 +113,7 @@ func AutoInjectionCode(filepath string, funcName string, codeData string) error
|
||||
srcData = append(append(srcData[:indexPos], insertData...), remainData...)
|
||||
|
||||
// 写回数据
|
||||
return ioutil.WriteFile(filepath, srcData, 0600)
|
||||
return ioutil.WriteFile(filepath, srcData, 0o600)
|
||||
}
|
||||
|
||||
func checkExist(srcData *[]byte, startPos int, endPos int, blockStmt *ast.BlockStmt, target string) bool {
|
||||
@@ -161,7 +161,7 @@ func AutoClearCode(filepath string, codeData string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ioutil.WriteFile(filepath, srcData, 0600)
|
||||
return ioutil.WriteFile(filepath, srcData, 0o600)
|
||||
}
|
||||
|
||||
func cleanCode(clearCode string, srcData string) ([]byte, error) {
|
||||
|
||||
+2
-3
@@ -2,10 +2,11 @@ package utils
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/dgrijalva/jwt-go"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
|
||||
"time"
|
||||
)
|
||||
|
||||
type JWT struct {
|
||||
@@ -79,7 +80,5 @@ func (j *JWT) ParseToken(tokenString string) (*request.CustomClaims, error) {
|
||||
|
||||
} else {
|
||||
return nil, TokenInvalid
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/natefinch/lumberjack"
|
||||
"go.uber.org/zap/zapcore"
|
||||
"os"
|
||||
)
|
||||
|
||||
//@author: [SliverHorn](https://github.com/SliverHorn)
|
||||
@@ -14,11 +15,11 @@ import (
|
||||
|
||||
func GetWriteSyncer(file string) zapcore.WriteSyncer {
|
||||
lumberJackLogger := &lumberjack.Logger{
|
||||
Filename: file, //日志文件的位置
|
||||
MaxSize: 10, //在进行切割之前,日志文件的最大大小(以MB为单位)
|
||||
MaxBackups: 200, //保留旧文件的最大个数
|
||||
MaxAge: 30, //保留旧文件的最大天数
|
||||
Compress: true, //是否压缩/归档旧文件
|
||||
Filename: file, // 日志文件的位置
|
||||
MaxSize: 10, // 在进行切割之前,日志文件的最大大小(以MB为单位)
|
||||
MaxBackups: 200, // 保留旧文件的最大个数
|
||||
MaxAge: 30, // 保留旧文件的最大天数
|
||||
Compress: true, // 是否压缩/归档旧文件
|
||||
}
|
||||
|
||||
if global.GVA_CONFIG.Zap.LogInConsole {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/shirou/gopsutil/cpu"
|
||||
"github.com/shirou/gopsutil/disk"
|
||||
"github.com/shirou/gopsutil/mem"
|
||||
"runtime"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -15,10 +15,12 @@ type mockJob struct{}
|
||||
func (job mockJob) Run() {
|
||||
mockFunc()
|
||||
}
|
||||
|
||||
func mockFunc() {
|
||||
time.Sleep(time.Second)
|
||||
fmt.Println("1s...")
|
||||
}
|
||||
|
||||
func TestNewTimerTask(t *testing.T) {
|
||||
tm := NewTimerTask()
|
||||
_tm := tm.(*timer)
|
||||
|
||||
@@ -27,7 +27,7 @@ func (*AliyunOSS) UploadFile(file *multipart.FileHeader) (string, string, error)
|
||||
}
|
||||
defer f.Close() // 创建文件 defer 关闭
|
||||
// 上传阿里云路径 文件名格式 自己可以改 建议保证唯一性
|
||||
//yunFileTmpPath := filepath.Join("uploads", time.Now().Format("2006-01-02")) + "/" + file.Filename
|
||||
// yunFileTmpPath := filepath.Join("uploads", time.Now().Format("2006-01-02")) + "/" + file.Filename
|
||||
yunFileTmpPath := global.GVA_CONFIG.AliyunOSS.BasePath + "/" + "uploads" + "/" + time.Now().Format("2006-01-02") + "/" + file.Filename
|
||||
|
||||
// 上传文件流。
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
//@return: error
|
||||
|
||||
func ZipFiles(filename string, files []string, oldForm, newForm string) error {
|
||||
|
||||
newZipFile, err := os.Create(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user