提交 9a3ea5c1 编写于 作者: S songzhibin97

Merge branch 'pr/829'

......@@ -11,8 +11,7 @@ import (
"go.uber.org/zap"
)
type AutoCodeExampleApi struct {
}
type AutoCodeExampleApi struct{}
var autoCodeExampleService = service.ServiceGroupApp.AutoCodeServiceGroup.AutoCodeExampleService
......
......@@ -8,6 +8,8 @@ type ApiGroup struct {
FileUploadAndDownloadApi
}
var excelService = service.ServiceGroupApp.ExampleServiceGroup.ExcelService
var customerService = service.ServiceGroupApp.ExampleServiceGroup.CustomerService
var fileUploadAndDownloadService = service.ServiceGroupApp.ExampleServiceGroup.FileUploadAndDownloadService
var (
excelService = service.ServiceGroupApp.ExampleServiceGroup.ExcelService
customerService = service.ServiceGroupApp.ExampleServiceGroup.CustomerService
fileUploadAndDownloadService = service.ServiceGroupApp.ExampleServiceGroup.FileUploadAndDownloadService
)
......@@ -11,8 +11,7 @@ import (
"go.uber.org/zap"
)
type CustomerApi struct {
}
type CustomerApi struct{}
// @Tags ExaCustomer
// @Summary 创建客户
......
......@@ -9,8 +9,7 @@ import (
"go.uber.org/zap"
)
type ExcelApi struct {
}
type ExcelApi struct{}
// /excel/importExcel 接口,与upload接口作用类似,只是把文件存到resource/excel目录下,用于导入Excel时存放Excel文件(ExcelImport.xlsx)
// /excel/loadExcel接口,用于读取resource/excel目录下的文件((ExcelImport.xlsx)并加载为[]model.SysBaseMenu类型的示例数据
......
......@@ -10,8 +10,7 @@ import (
"go.uber.org/zap"
)
type FileUploadAndDownloadApi struct {
}
type FileUploadAndDownloadApi struct{}
// @Tags ExaFileUploadAndDownload
// @Summary 上传文件示例
......
......@@ -18,17 +18,19 @@ type ApiGroup struct {
DictionaryDetailApi
}
var apiService = service.ServiceGroupApp.SystemServiceGroup.ApiService
var jwtService = service.ServiceGroupApp.SystemServiceGroup.JwtService
var menuService = service.ServiceGroupApp.SystemServiceGroup.MenuService
var userService = service.ServiceGroupApp.SystemServiceGroup.UserService
var initDBService = service.ServiceGroupApp.SystemServiceGroup.InitDBService
var casbinService = service.ServiceGroupApp.SystemServiceGroup.CasbinService
var autoCodeService = service.ServiceGroupApp.SystemServiceGroup.AutoCodeService
var baseMenuService = service.ServiceGroupApp.SystemServiceGroup.BaseMenuService
var authorityService = service.ServiceGroupApp.SystemServiceGroup.AuthorityService
var dictionaryService = service.ServiceGroupApp.SystemServiceGroup.DictionaryService
var systemConfigService = service.ServiceGroupApp.SystemServiceGroup.SystemConfigService
var operationRecordService = service.ServiceGroupApp.SystemServiceGroup.OperationRecordService
var autoCodeHistoryService = service.ServiceGroupApp.SystemServiceGroup.AutoCodeHistoryService
var dictionaryDetailService = service.ServiceGroupApp.SystemServiceGroup.DictionaryDetailService
var (
apiService = service.ServiceGroupApp.SystemServiceGroup.ApiService
jwtService = service.ServiceGroupApp.SystemServiceGroup.JwtService
menuService = service.ServiceGroupApp.SystemServiceGroup.MenuService
userService = service.ServiceGroupApp.SystemServiceGroup.UserService
initDBService = service.ServiceGroupApp.SystemServiceGroup.InitDBService
casbinService = service.ServiceGroupApp.SystemServiceGroup.CasbinService
autoCodeService = service.ServiceGroupApp.SystemServiceGroup.AutoCodeService
baseMenuService = service.ServiceGroupApp.SystemServiceGroup.BaseMenuService
authorityService = service.ServiceGroupApp.SystemServiceGroup.AuthorityService
dictionaryService = service.ServiceGroupApp.SystemServiceGroup.DictionaryService
systemConfigService = service.ServiceGroupApp.SystemServiceGroup.SystemConfigService
operationRecordService = service.ServiceGroupApp.SystemServiceGroup.OperationRecordService
autoCodeHistoryService = service.ServiceGroupApp.SystemServiceGroup.AutoCodeHistoryService
dictionaryDetailService = service.ServiceGroupApp.SystemServiceGroup.DictionaryDetailService
)
......@@ -13,8 +13,7 @@ import (
"go.uber.org/zap"
)
type SystemApiApi struct {
}
type SystemApiApi struct{}
// @Tags SysApi
// @Summary 创建基础api
......
......@@ -13,8 +13,7 @@ import (
"go.uber.org/zap"
)
type AuthorityApi struct {
}
type AuthorityApi struct{}
// @Tags Authority
// @Summary 创建角色
......
......@@ -10,11 +10,10 @@ import (
)
// 当开启多服务器部署时,替换下面的配置,使用redis共享存储验证码
//var store = captcha.NewDefaultRedisStore()
// var store = captcha.NewDefaultRedisStore()
var store = base64Captcha.DefaultMemStore
type BaseApi struct {
}
type BaseApi struct{}
// @Tags Base
// @Summary 生成验证码
......@@ -27,7 +26,7 @@ func (b *BaseApi) Captcha(c *gin.Context) {
// 字符,公式,验证码配置
// 生成默认数字的driver
driver := base64Captcha.NewDriverDigit(global.GVA_CONFIG.Captcha.ImgHeight, global.GVA_CONFIG.Captcha.ImgWidth, global.GVA_CONFIG.Captcha.KeyLong, 0.7, 80)
//cp := base64Captcha.NewCaptcha(driver, store.UseWithCtx(c)) // v8下使用redis
// cp := base64Captcha.NewCaptcha(driver, store.UseWithCtx(c)) // v8下使用redis
cp := base64Captcha.NewCaptcha(driver, store)
if id, b64s, err := cp.Generate(); err != nil {
global.GVA_LOG.Error("验证码获取失败!", zap.Error(err))
......
......@@ -10,8 +10,7 @@ import (
"go.uber.org/zap"
)
type CasbinApi struct {
}
type CasbinApi struct{}
// @Tags Casbin
// @Summary 更新角色api权限
......
......@@ -10,8 +10,7 @@ import (
"go.uber.org/zap"
)
type DictionaryApi struct {
}
type DictionaryApi struct{}
// @Tags SysDictionary
// @Summary 创建SysDictionary
......
......@@ -10,8 +10,7 @@ import (
"go.uber.org/zap"
)
type DictionaryDetailApi struct {
}
type DictionaryDetailApi struct{}
// @Tags SysDictionaryDetail
// @Summary 创建SysDictionaryDetail
......
......@@ -8,8 +8,7 @@ import (
"go.uber.org/zap"
)
type JwtApi struct {
}
type JwtApi struct{}
// @Tags Jwt
// @Summary jwt加入黑名单
......
......@@ -13,8 +13,7 @@ import (
"go.uber.org/zap"
)
type AuthorityMenuApi struct {
}
type AuthorityMenuApi struct{}
// @Tags AuthorityMenu
// @Summary 获取用户动态路由
......
......@@ -11,8 +11,7 @@ import (
"go.uber.org/zap"
)
type OperationRecordApi struct {
}
type OperationRecordApi struct{}
// @Tags SysOperationRecord
// @Summary 创建SysOperationRecord
......
......@@ -11,8 +11,7 @@ import (
"go.uber.org/zap"
)
type SystemApi struct {
}
type SystemApi struct{}
// @Tags System
// @Summary 获取配置文件内容
......
package system
import (
"strconv"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
......@@ -8,7 +10,6 @@ import (
systemReq "github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
systemRes "github.com/flipped-aurora/gin-vue-admin/server/model/system/response"
"github.com/flipped-aurora/gin-vue-admin/server/utils"
"strconv"
"github.com/gin-gonic/gin"
"github.com/go-redis/redis/v8"
......
......@@ -22,6 +22,7 @@ type AliyunOSS struct {
BucketUrl string `mapstructure:"bucket-url" json:"bucketUrl" yaml:"bucket-url"`
BasePath string `mapstructure:"base-path" json:"basePath" yaml:"base-path"`
}
type TencentCOS struct {
Bucket string `mapstructure:"bucket" json:"bucket" yaml:"bucket"`
Region string `mapstructure:"region" json:"region" yaml:"region"`
......
......@@ -4,9 +4,10 @@
package core
import (
"github.com/gin-gonic/gin"
"net/http"
"time"
"github.com/gin-gonic/gin"
)
func initServer(address string, router *gin.Engine) server {
......
......@@ -20,7 +20,7 @@ var (
GVA_REDIS *redis.Client
GVA_CONFIG config.Server
GVA_VP *viper.Viper
//GVA_LOG *oplogging.Logger
// GVA_LOG *oplogging.Logger
GVA_LOG *zap.Logger
GVA_Timer timer.Timer = timer.NewTimerTask()
GVA_Concurrency_Control = &singleflight.Group{}
......
package global
import (
"gorm.io/gorm"
"time"
"gorm.io/gorm"
)
type GVA_MODEL struct {
......
package initialize
import (
"os"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/autocode"
"github.com/flipped-aurora/gin-vue-admin/server/model/example"
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
"os"
"go.uber.org/zap"
"gorm.io/gorm"
......@@ -51,7 +52,6 @@ func RegisterTables(db *gorm.DB) {
autocode.AutoCodeExample{},
// Code generated by github.com/flipped-aurora/gin-vue-admin/server End; DO NOT EDIT.
)
if err != nil {
global.GVA_LOG.Error("register table failed", zap.Error(err))
os.Exit(0)
......
package internal
import (
"github.com/flipped-aurora/gin-vue-admin/server/global"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"log"
"os"
"time"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"gorm.io/gorm"
"gorm.io/gorm/logger"
)
var Gorm = new(_gorm)
......
......@@ -2,6 +2,7 @@ package internal
import (
"fmt"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"gorm.io/gorm/logger"
)
......
......@@ -31,5 +31,4 @@ func InstallPlugin(PublicGroup *gin.RouterGroup, PrivateGroup *gin.RouterGroup)
global.GVA_CONFIG.Email.Port,
global.GVA_CONFIG.Email.IsSSL,
))
}
......@@ -15,28 +15,28 @@ import (
// 初始化总路由
func Routers() *gin.Engine {
var Router = gin.Default()
Router := gin.Default()
// 如果想要不使用nginx代理前端网页,可以修改 web/.env.production 下的
// VUE_APP_BASE_API = /
// VUE_APP_BASE_PATH = http://localhost
// 然后执行打包命令 npm run build。在打开下面4行注释
//Router.LoadHTMLGlob("./dist/*.html") // npm打包成dist的路径
//Router.Static("/favicon.ico", "./dist/favicon.ico")
//Router.Static("/static", "./dist/assets") // dist里面的静态资源
//Router.StaticFile("/", "./dist/index.html") // 前端网页入口页面
// Router.LoadHTMLGlob("./dist/*.html") // npm打包成dist的路径
// Router.Static("/favicon.ico", "./dist/favicon.ico")
// Router.Static("/static", "./dist/assets") // dist里面的静态资源
// Router.StaticFile("/", "./dist/index.html") // 前端网页入口页面
Router.StaticFS(global.GVA_CONFIG.Local.Path, http.Dir(global.GVA_CONFIG.Local.Path)) // 为用户头像和文件提供静态地址
// Router.Use(middleware.LoadTls()) // 打开就能玩https了
global.GVA_LOG.Info("use middleware logger")
// 跨域
//Router.Use(middleware.Cors()) // 如需跨域可以打开
// Router.Use(middleware.Cors()) // 如需跨域可以打开
global.GVA_LOG.Info("use middleware cors")
Router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
global.GVA_LOG.Info("register swagger handler")
// 方便统一添加路由组前缀 多服务器上线使用
//获取路由组实例
// 获取路由组实例
systemRouter := router.RouterGroupApp.System
exampleRouter := router.RouterGroupApp.Example
autocodeRouter := router.RouterGroupApp.Autocode
......
package middleware
import (
"github.com/gin-gonic/gin"
"net/http"
"github.com/gin-gonic/gin"
)
// 处理跨域请求,支持options访问
......
package middleware
import (
"github.com/flipped-aurora/gin-vue-admin/server/plugin/email/utils"
utils2 "github.com/flipped-aurora/gin-vue-admin/server/utils"
"io/ioutil"
"strconv"
"time"
"github.com/flipped-aurora/gin-vue-admin/server/plugin/email/utils"
utils2 "github.com/flipped-aurora/gin-vue-admin/server/utils"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
"github.com/flipped-aurora/gin-vue-admin/server/service"
......
package middleware
import (
"github.com/flipped-aurora/gin-vue-admin/server/utils"
"strconv"
"time"
"github.com/flipped-aurora/gin-vue-admin/server/utils"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
......
......@@ -48,10 +48,8 @@ func DefaultCheckOrMark(key string, expire int, limit int) (err error) {
}
if err = SetLimitWithTime(key, limit, time.Duration(expire)*time.Second); err != nil {
global.GVA_LOG.Error("limit", zap.Error(err))
}
return err
}
func DefaultLimit() gin.HandlerFunc {
......@@ -76,7 +74,7 @@ func SetLimitWithTime(key string, limit int, expiration time.Duration) error {
_, err = pipe.Exec(context.Background())
return err
} else {
//次数
// 次数
if times, err := global.GVA_REDIS.Get(context.Background(), key).Int(); err != nil {
return err
} else {
......
......@@ -2,6 +2,7 @@ package middleware
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/unrolled/secure"
)
......
......@@ -2,12 +2,13 @@ package middleware
import (
"bytes"
"github.com/flipped-aurora/gin-vue-admin/server/utils"
"io/ioutil"
"net/http"
"strconv"
"time"
"github.com/flipped-aurora/gin-vue-admin/server/utils"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
"github.com/flipped-aurora/gin-vue-admin/server/service"
......
package response
import (
"github.com/gin-gonic/gin"
"net/http"
"github.com/gin-gonic/gin"
)
type Response struct {
......
......@@ -2,6 +2,7 @@ package request
import (
"fmt"
"github.com/flipped-aurora/gin-vue-admin/server/config"
)
......
package system
import (
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
"strconv"
"strings"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
)
// SysAutoCodeHistory 自动迁移代码记录,用于回滚,重放使用
......
......@@ -9,8 +9,7 @@ import (
"go.uber.org/zap"
)
type EmailApi struct {
}
type EmailApi struct{}
// @Tags System
// @Summary 发送测试邮件
......
......@@ -6,8 +6,7 @@ import (
"github.com/gin-gonic/gin"
)
type emailPlugin struct {
}
type emailPlugin struct{}
func CreateEmailPlug(To, From, Host, Secret, Nickname string, Port int, IsSSL bool) *emailPlugin {
global.GlobalConfig.To = To
......
......@@ -6,13 +6,12 @@ import (
"github.com/gin-gonic/gin"
)
type EmailRouter struct {
}
type EmailRouter struct{}
func (s *EmailRouter) InitEmailRouter(Router *gin.RouterGroup) {
emailRouter := Router.Use(middleware.OperationRecord())
var EmailApi = api.ApiGroupApp.EmailApi.EmailTest
var SendEmail = api.ApiGroupApp.EmailApi.SendEmail
EmailApi := api.ApiGroupApp.EmailApi.EmailTest
SendEmail := api.ApiGroupApp.EmailApi.SendEmail
{
emailRouter.POST("emailTest", EmailApi) // 发送测试邮件
emailRouter.POST("sendEmail", SendEmail) // 发送邮件
......
......@@ -4,8 +4,7 @@ import (
"github.com/flipped-aurora/gin-vue-admin/server/plugin/email/utils"
)
type EmailService struct {
}
type EmailService struct{}
//@author: [maplepie](https://github.com/maplepie)
//@function: EmailTest
......
......@@ -6,8 +6,7 @@ import (
var ExamplePlugin = new(pluginExample)
type pluginExample struct {
}
type pluginExample struct{}
func (*pluginExample) Register(group *gin.RouterGroup) {
//如需细分权限 可以在此处use中间件 gva项目包名已改为github模式
......
......@@ -58,7 +58,6 @@ func (w *wsPlugin) Register(g *gin.RouterGroup) {
InsecureSkipVerify: true,
}))
g.POST("/sendMsg", w.adminCase.SendMsg("gva_ws"))
}
func (w *wsPlugin) RouterPath() string {
......@@ -78,6 +77,8 @@ func GenerateWs(logger *zap.Logger, manageBuf int64, checkMap map[string]biz.Che
for key, handler := range registeredMsgHandler {
admin.RegisteredMsgHandler(key, handler)
}
return &wsPlugin{logger: logger, manageBuf: manageBuf,
registeredMsgHandler: registeredMsgHandler, checkMap: checkMap, admin: admin, adminCase: biz.NewAdmin(admin)}
return &wsPlugin{
logger: logger, manageBuf: manageBuf,
registeredMsgHandler: registeredMsgHandler, checkMap: checkMap, admin: admin, adminCase: biz.NewAdmin(admin),
}
}
......@@ -6,13 +6,12 @@ import (
"github.com/gin-gonic/gin"
)
type AutoCodeExampleRouter struct {
}
type AutoCodeExampleRouter struct{}
func (s *AutoCodeExampleRouter) InitSysAutoCodeExampleRouter(Router *gin.RouterGroup) {
autoCodeExampleRouter := Router.Group("autoCodeExample").Use(middleware.OperationRecord())
autoCodeExampleRouterWithoutRecord := Router.Group("autoCodeExample")
var autoCodeExampleApi = v1.ApiGroupApp.AutoCodeApiGroup.AutoCodeExampleApi
autoCodeExampleApi := v1.ApiGroupApp.AutoCodeApiGroup.AutoCodeExampleApi
{
autoCodeExampleRouter.POST("createSysAutoCodeExample", autoCodeExampleApi.CreateAutoCodeExample) // 新建AutoCodeExample
autoCodeExampleRouter.DELETE("deleteSysAutoCodeExample", autoCodeExampleApi.DeleteAutoCodeExample) // 删除AutoCodeExample
......
......@@ -6,13 +6,12 @@ import (
"github.com/gin-gonic/gin"
)
type CustomerRouter struct {
}
type CustomerRouter struct{}
func (e *CustomerRouter) InitCustomerRouter(Router *gin.RouterGroup) {
customerRouter := Router.Group("customer").Use(middleware.OperationRecord())
customerRouterWithoutRecord := Router.Group("customer")
var exaCustomerApi = v1.ApiGroupApp.ExampleApiGroup.CustomerApi
exaCustomerApi := v1.ApiGroupApp.ExampleApiGroup.CustomerApi
{
customerRouter.POST("customer", exaCustomerApi.CreateExaCustomer) // 创建客户
customerRouter.PUT("customer", exaCustomerApi.UpdateExaCustomer) // 更新客户
......
......@@ -5,12 +5,11 @@ import (
"github.com/gin-gonic/gin"
)
type ExcelRouter struct {
}
type ExcelRouter struct{}
func (e *ExcelRouter) InitExcelRouter(Router *gin.RouterGroup) {
excelRouter := Router.Group("excel")
var exaExcelApi = v1.ApiGroupApp.ExampleApiGroup.ExcelApi
exaExcelApi := v1.ApiGroupApp.ExampleApiGroup.ExcelApi
{
excelRouter.POST("importExcel", exaExcelApi.ImportExcel) // 导入Excel
excelRouter.GET("loadExcel", exaExcelApi.LoadExcel) // 加载Excel数据
......
......@@ -5,12 +5,11 @@ import (
"github.com/gin-gonic/gin"
)
type FileUploadAndDownloadRouter struct {
}
type FileUploadAndDownloadRouter struct{}
func (e *FileUploadAndDownloadRouter) InitFileUploadAndDownloadRouter(Router *gin.RouterGroup) {
fileUploadAndDownloadRouter := Router.Group("fileUploadAndDownload")
var exaFileUploadAndDownloadApi = v1.ApiGroupApp.ExampleApiGroup.FileUploadAndDownloadApi
exaFileUploadAndDownloadApi := v1.ApiGroupApp.ExampleApiGroup.FileUploadAndDownloadApi
{
fileUploadAndDownloadRouter.POST("upload", exaFileUploadAndDownloadApi.UploadFile) // 上传文件
fileUploadAndDownloadRouter.POST("getFileList", exaFileUploadAndDownloadApi.GetFileList) // 获取上传文件列表
......
......@@ -6,13 +6,12 @@ import (
"github.com/gin-gonic/gin"
)
type ApiRouter struct {
}
type ApiRouter struct{}
func (s *ApiRouter) InitApiRouter(Router *gin.RouterGroup) {
apiRouter := Router.Group("api").Use(middleware.OperationRecord())
apiRouterWithoutRecord := Router.Group("api")
var apiRouterApi = v1.ApiGroupApp.SystemApiGroup.SystemApiApi
apiRouterApi := v1.ApiGroupApp.SystemApiGroup.SystemApiApi
{
apiRouter.POST("createApi", apiRouterApi.CreateApi) // 创建Api
apiRouter.POST("deleteApi", apiRouterApi.DeleteApi) // 删除Api
......
......@@ -6,13 +6,12 @@ import (
"github.com/gin-gonic/gin"
)
type AuthorityRouter struct {
}
type AuthorityRouter struct{}
func (s *AuthorityRouter) InitAuthorityRouter(Router *gin.RouterGroup) {
authorityRouter := Router.Group("authority").Use(middleware.OperationRecord())
authorityRouterWithoutRecord := Router.Group("authority")
var authorityApi = v1.ApiGroupApp.SystemApiGroup.AuthorityApi
authorityApi := v1.ApiGroupApp.SystemApiGroup.AuthorityApi
{
authorityRouter.POST("createAuthority", authorityApi.CreateAuthority) // 创建角色
authorityRouter.POST("deleteAuthority", authorityApi.DeleteAuthority) // 删除角色
......
......@@ -5,12 +5,11 @@ import (
"github.com/gin-gonic/gin"
)
type BaseRouter struct {
}
type BaseRouter struct{}
func (s *BaseRouter) InitBaseRouter(Router *gin.RouterGroup) (R gin.IRoutes) {
baseRouter := Router.Group("base")
var baseApi = v1.ApiGroupApp.SystemApiGroup.BaseApi
baseApi := v1.ApiGroupApp.SystemApiGroup.BaseApi
{
baseRouter.POST("login", baseApi.Login)
baseRouter.POST("captcha", baseApi.Captcha)
......
......@@ -6,13 +6,12 @@ import (
"github.com/gin-gonic/gin"
)
type CasbinRouter struct {
}
type CasbinRouter struct{}
func (s *CasbinRouter) InitCasbinRouter(Router *gin.RouterGroup) {
casbinRouter := Router.Group("casbin").Use(middleware.OperationRecord())
casbinRouterWithoutRecord := Router.Group("casbin")
var casbinApi = v1.ApiGroupApp.SystemApiGroup.CasbinApi
casbinApi := v1.ApiGroupApp.SystemApiGroup.CasbinApi
{
casbinRouter.POST("updateCasbin", casbinApi.UpdateCasbin)
}
......
......@@ -6,13 +6,12 @@ import (
"github.com/gin-gonic/gin"
)
type DictionaryRouter struct {
}
type DictionaryRouter struct{}
func (s *DictionaryRouter) InitSysDictionaryRouter(Router *gin.RouterGroup) {
sysDictionaryRouter := Router.Group("sysDictionary").Use(middleware.OperationRecord())
sysDictionaryRouterWithoutRecord := Router.Group("sysDictionary")
var sysDictionaryApi = v1.ApiGroupApp.SystemApiGroup.DictionaryApi
sysDictionaryApi := v1.ApiGroupApp.SystemApiGroup.DictionaryApi
{
sysDictionaryRouter.POST("createSysDictionary", sysDictionaryApi.CreateSysDictionary) // 新建SysDictionary
sysDictionaryRouter.DELETE("deleteSysDictionary", sysDictionaryApi.DeleteSysDictionary) // 删除SysDictionary
......
......@@ -6,13 +6,12 @@ import (
"github.com/gin-gonic/gin"
)
type DictionaryDetailRouter struct {
}
type DictionaryDetailRouter struct{}
func (s *DictionaryDetailRouter) InitSysDictionaryDetailRouter(Router *gin.RouterGroup) {
dictionaryDetailRouter := Router.Group("sysDictionaryDetail").Use(middleware.OperationRecord())
dictionaryDetailRouterWithoutRecord := Router.Group("sysDictionaryDetail")
var sysDictionaryDetailApi = v1.ApiGroupApp.SystemApiGroup.DictionaryDetailApi
sysDictionaryDetailApi := v1.ApiGroupApp.SystemApiGroup.DictionaryDetailApi
{
dictionaryDetailRouter.POST("createSysDictionaryDetail", sysDictionaryDetailApi.CreateSysDictionaryDetail) // 新建SysDictionaryDetail
dictionaryDetailRouter.DELETE("deleteSysDictionaryDetail", sysDictionaryDetailApi.DeleteSysDictionaryDetail) // 删除SysDictionaryDetail
......
......@@ -5,12 +5,11 @@ import (
"github.com/gin-gonic/gin"
)
type InitRouter struct {
}
type InitRouter struct{}
func (s *InitRouter) InitInitRouter(Router *gin.RouterGroup) {
initRouter := Router.Group("init")
var dbApi = v1.ApiGroupApp.SystemApiGroup.DBApi
dbApi := v1.ApiGroupApp.SystemApiGroup.DBApi
{
initRouter.POST("initdb", dbApi.InitDB) // 创建Api
initRouter.POST("checkdb", dbApi.CheckDB) // 创建Api
......
......@@ -5,12 +5,11 @@ import (
"github.com/gin-gonic/gin"
)
type JwtRouter struct {
}
type JwtRouter struct{}
func (s *JwtRouter) InitJwtRouter(Router *gin.RouterGroup) {
jwtRouter := Router.Group("jwt")
var jwtApi = v1.ApiGroupApp.SystemApiGroup.JwtApi
jwtApi := v1.ApiGroupApp.SystemApiGroup.JwtApi
{
jwtRouter.POST("jsonInBlacklist", jwtApi.JsonInBlacklist) // jwt加入黑名单
}
......
......@@ -6,13 +6,12 @@ import (
"github.com/gin-gonic/gin"
)
type MenuRouter struct {
}
type MenuRouter struct{}
func (s *MenuRouter) InitMenuRouter(Router *gin.RouterGroup) (R gin.IRoutes) {
menuRouter := Router.Group("menu").Use(middleware.OperationRecord())
menuRouterWithoutRecord := Router.Group("menu")
var authorityMenuApi = v1.ApiGroupApp.SystemApiGroup.AuthorityMenuApi
authorityMenuApi := v1.ApiGroupApp.SystemApiGroup.AuthorityMenuApi
{
menuRouter.POST("addBaseMenu", authorityMenuApi.AddBaseMenu) // 新增菜单
menuRouter.POST("addMenuAuthority", authorityMenuApi.AddMenuAuthority) // 增加menu和角色关联关系
......
......@@ -5,12 +5,11 @@ import (
"github.com/gin-gonic/gin"
)
type OperationRecordRouter struct {
}
type OperationRecordRouter struct{}
func (s *OperationRecordRouter) InitSysOperationRecordRouter(Router *gin.RouterGroup) {
operationRecordRouter := Router.Group("sysOperationRecord")
var authorityMenuApi = v1.ApiGroupApp.SystemApiGroup.OperationRecordApi
authorityMenuApi := v1.ApiGroupApp.SystemApiGroup.OperationRecordApi
{
operationRecordRouter.POST("createSysOperationRecord", authorityMenuApi.CreateSysOperationRecord) // 新建SysOperationRecord
operationRecordRouter.DELETE("deleteSysOperationRecord", authorityMenuApi.DeleteSysOperationRecord) // 删除SysOperationRecord
......
......@@ -6,12 +6,11 @@ import (
"github.com/gin-gonic/gin"
)
type SysRouter struct {
}
type SysRouter struct{}
func (s *SysRouter) InitSystemRouter(Router *gin.RouterGroup) {
sysRouter := Router.Group("system").Use(middleware.OperationRecord())
var systemApi = v1.ApiGroupApp.SystemApiGroup.SystemApi
systemApi := v1.ApiGroupApp.SystemApiGroup.SystemApi
{
sysRouter.POST("getSystemConfig", systemApi.GetSystemConfig) // 获取配置文件内容
sysRouter.POST("setSystemConfig", systemApi.SetSystemConfig) // 设置配置文件内容
......
......@@ -6,13 +6,12 @@ import (
"github.com/gin-gonic/gin"
)
type UserRouter struct {
}
type UserRouter struct{}
func (s *UserRouter) InitUserRouter(Router *gin.RouterGroup) {
userRouter := Router.Group("user").Use(middleware.OperationRecord())
userRouterWithoutRecord := Router.Group("user")
var baseApi = v1.ApiGroupApp.SystemApiGroup.BaseApi
baseApi := v1.ApiGroupApp.SystemApiGroup.BaseApi
{
userRouter.POST("register", baseApi.Register) // 用户注册账号
userRouter.POST("changePassword", baseApi.ChangePassword) // 用户修改密码
......
......@@ -6,8 +6,7 @@ import (
"github.com/flipped-aurora/gin-vue-admin/server/model/autocode/request"
)
type AutoCodeExampleService struct {
}
type AutoCodeExampleService struct{}
//@author: [piexlmax](https://github.com/piexlmax)
//@function: CreateAutoCodeExample
......@@ -16,7 +15,6 @@ type AutoCodeExampleService struct {
//@return: err error
func (autoCodeExampleService *AutoCodeExampleService) CreateAutoCodeExample(autoCodeExample autocode.AutoCodeExample) (err error) {
err = global.GVA_DB.Create(&autoCodeExample).Error
return err
}
......
......@@ -8,8 +8,7 @@ import (
"gorm.io/gorm"
)
type FileUploadAndDownloadService struct {
}
type FileUploadAndDownloadService struct{}
//@author: [piexlmax](https://github.com/piexlmax)
//@function: FindOrCreateFile
......
......@@ -8,8 +8,7 @@ import (
systemService "github.com/flipped-aurora/gin-vue-admin/server/service/system"
)
type CustomerService struct {
}
type CustomerService struct{}
//@author: [piexlmax](https://github.com/piexlmax)
//@function: CreateExaCustomer
......
......@@ -10,8 +10,7 @@ import (
"github.com/xuri/excelize/v2"
)
type ExcelService struct {
}
type ExcelService struct{}
func (exa *ExcelService) ParseInfoList2Excel(infoList []system.SysBaseMenu, filePath string) error {
excel := excelize.NewFile()
......
......@@ -2,15 +2,15 @@ package system
import (
"context"
"go.uber.org/zap"
"time"
"go.uber.org/zap"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
)
type JwtService struct {
}
type JwtService struct{}
//@author: [piexlmax](https://github.com/piexlmax)
//@function: JsonInBlacklist
......@@ -36,9 +36,9 @@ func (jwtService *JwtService) JsonInBlacklist(jwtList system.JwtBlacklist) (err
func (jwtService *JwtService) IsBlacklist(jwt string) bool {
_, ok := global.BlackCache.Get(jwt)
return ok
//err := global.GVA_DB.Where("jwt = ?", jwt).First(&system.JwtBlacklist{}).Error
//isNotFound := errors.Is(err, gorm.ErrRecordNotFound)
//return !isNotFound
// err := global.GVA_DB.Where("jwt = ?", jwt).First(&system.JwtBlacklist{}).Error
// isNotFound := errors.Is(err, gorm.ErrRecordNotFound)
// return !isNotFound
}
//@author: [piexlmax](https://github.com/piexlmax)
......
......@@ -16,8 +16,7 @@ import (
//@param: api model.SysApi
//@return: err error
type ApiService struct {
}
type ApiService struct{}
var ApiServiceApp = new(ApiService)
......
......@@ -17,8 +17,7 @@ import (
//@param: auth model.SysAuthority
//@return: err error, authority model.SysAuthority
type AuthorityService struct {
}
type AuthorityService struct{}
var AuthorityServiceApp = new(AuthorityService)
......@@ -100,7 +99,7 @@ func (authorityService *AuthorityService) DeleteAuthority(auth *system.SysAuthor
if err != nil {
return
}
//err = db.Association("SysBaseMenus").Delete(&auth)
// err = db.Association("SysBaseMenus").Delete(&auth)
} else {
err = db.Error
if err != nil {
......
......@@ -76,8 +76,7 @@ type tplData struct {
autoMoveFilePath string
}
type AutoCodeService struct {
}
type AutoCodeService struct{}
var AutoCodeServiceApp = new(AutoCodeService)
......@@ -108,7 +107,7 @@ func (autoCodeService *AutoCodeService) PreviewTemp(autoCode system.AutoCodeStru
if ext = filepath.Ext(value.autoCodePath); ext == ".txt" {
continue
}
f, err := os.OpenFile(value.autoCodePath, os.O_CREATE|os.O_WRONLY, 0755)
f, err := os.OpenFile(value.autoCodePath, os.O_CREATE|os.O_WRONLY, 0o755)
if err != nil {
return nil, err
}
......@@ -116,7 +115,7 @@ func (autoCodeService *AutoCodeService) PreviewTemp(autoCode system.AutoCodeStru
return nil, err
}
_ = f.Close()
f, err = os.OpenFile(value.autoCodePath, os.O_CREATE|os.O_RDONLY, 0755)
f, err = os.OpenFile(value.autoCodePath, os.O_CREATE|os.O_RDONLY, 0o755)
if err != nil {
return nil, err
}
......@@ -155,7 +154,7 @@ func makeDictTypes(autoCode *system.AutoCodeStruct) {
}
}
for k, _ := range DictTypeM {
for k := range DictTypeM {
autoCode.DictTypes = append(autoCode.DictTypes, k)
}
}
......@@ -184,7 +183,7 @@ func (autoCodeService *AutoCodeService) CreateTemp(autoCode system.AutoCodeStruc
// 生成文件
for _, value := range dataList {
f, err := os.OpenFile(value.autoCodePath, os.O_CREATE|os.O_WRONLY, 0755)
f, err := os.OpenFile(value.autoCodePath, os.O_CREATE|os.O_WRONLY, 0o755)
if err != nil {
return err
}
......@@ -274,7 +273,6 @@ func (autoCodeService *AutoCodeService) CreateTemp(autoCode system.AutoCodeStruc
return system.AutoMoveErr
}
return nil
}
//@author: [piexlmax](https://github.com/piexlmax)
......@@ -363,7 +361,7 @@ func (autoCodeService *AutoCodeService) addAutoMoveFile(data *tplData) {
//@return: err error
func (autoCodeService *AutoCodeService) AutoCreateApi(a *system.AutoCodeStruct) (ids []uint, err error) {
var apiList = []system.SysApi{
apiList := []system.SysApi{
{
Path: "/" + a.Abbreviation + "/" + "create" + a.StructName,
Description: "新增" + a.Description,
......@@ -402,7 +400,6 @@ func (autoCodeService *AutoCodeService) AutoCreateApi(a *system.AutoCodeStruct)
},
}
err = global.GVA_DB.Transaction(func(tx *gorm.DB) error {
for _, v := range apiList {
var api system.SysApi
if errors.Is(tx.Where("path = ? AND method = ?", v.Path, v.Method).First(&api).Error, gorm.ErrRecordNotFound) {
......
package system
import (
"strings"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/system/response"
"github.com/pkg/errors"
"gorm.io/driver/postgres"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"strings"
)
var AutoCodePgsql = new(autoCodePgsql)
......
......@@ -3,11 +3,12 @@ package system
import (
"errors"
"fmt"
"github.com/flipped-aurora/gin-vue-admin/server/model/system/response"
"path/filepath"
"strings"
"time"
"github.com/flipped-aurora/gin-vue-admin/server/model/system/response"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
......@@ -79,7 +80,6 @@ func (autoCodeHistoryService *AutoCodeHistoryService) RollBack(info *request.Get
// 删除表
if err = AutoCodeServiceApp.DropTable(name.TableName); err != nil {
global.GVA_LOG.Error("ClearTag DropTable:", zap.Error(err))
}
}
}
......
......@@ -8,8 +8,7 @@ import (
"gorm.io/gorm"
)
type BaseMenuService struct {
}
type BaseMenuService struct{}
//@author: [piexlmax](https://github.com/piexlmax)
//@function: DeleteBaseMenu
......
......@@ -18,8 +18,7 @@ import (
//@param: authorityId string, casbinInfos []request.CasbinInfo
//@return: error
type CasbinService struct {
}
type CasbinService struct{}
var CasbinServiceApp = new(CasbinService)
......@@ -85,7 +84,6 @@ func (casbinService *CasbinService) ClearCasbin(v int, p ...string) bool {
e := casbinService.Casbin()
success, _ := e.RemoveFilteredPolicy(v, p...)
return success
}
//@author: [piexlmax](https://github.com/piexlmax)
......
......@@ -15,8 +15,7 @@ import (
//@param: sysDictionary model.SysDictionary
//@return: err error
type DictionaryService struct {
}
type DictionaryService struct{}
func (dictionaryService *DictionaryService) CreateSysDictionary(sysDictionary system.SysDictionary) (err error) {
if (!errors.Is(global.GVA_DB.First(&system.SysDictionary{}, "type = ?", sysDictionary.Type).Error, gorm.ErrRecordNotFound)) {
......
......@@ -12,8 +12,7 @@ import (
//@param: sysDictionaryDetail model.SysDictionaryDetail
//@return: err error
type DictionaryDetailService struct {
}
type DictionaryDetailService struct{}
func (dictionaryDetailService *DictionaryDetailService) CreateSysDictionaryDetail(sysDictionaryDetail system.SysDictionaryDetail) (err error) {
err = global.GVA_DB.Create(&sysDictionaryDetail).Error
......
......@@ -3,6 +3,7 @@ package system
import (
"database/sql"
"fmt"
adapter "github.com/casbin/gorm-adapter/v3"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/example"
......@@ -49,7 +50,6 @@ func (initDBService *InitDBService) initTables() error {
example.ExaFileChunk{},
example.ExaFileUploadAndDownload{},
)
}
// createDatabase 创建数据库(mysql)
......
......@@ -2,6 +2,8 @@ package system
import (
"fmt"
"path/filepath"
"github.com/flipped-aurora/gin-vue-admin/server/config"
"github.com/flipped-aurora/gin-vue-admin/server/global"
model "github.com/flipped-aurora/gin-vue-admin/server/model/system"
......@@ -12,7 +14,6 @@ import (
uuid "github.com/satori/go.uuid"
"gorm.io/driver/mysql"
"gorm.io/gorm"
"path/filepath"
)
// writeMysqlConfig mysql回写配置
......
package system
import (
"path/filepath"
"github.com/flipped-aurora/gin-vue-admin/server/config"
"github.com/flipped-aurora/gin-vue-admin/server/global"
model "github.com/flipped-aurora/gin-vue-admin/server/model/system"
......@@ -11,7 +13,6 @@ import (
uuid "github.com/satori/go.uuid"
"gorm.io/driver/postgres"
"gorm.io/gorm"
"path/filepath"
)
// writePgsqlConfig pgsql 回写配置
......
......@@ -16,8 +16,7 @@ import (
//@param: authorityId string
//@return: err error, treeMap map[string][]model.SysMenu
type MenuService struct {
}
type MenuService struct{}
var MenuServiceApp = new(MenuService)
......@@ -153,7 +152,7 @@ func (menuService *MenuService) AddMenuAuthority(menus []system.SysBaseMenu, aut
func (menuService *MenuService) GetMenuAuthority(info *request.GetAuthorityId) (err error, menus []system.SysMenu) {
err = global.GVA_DB.Where("authority_id = ? ", info.AuthorityId).Order("sort").Find(&menus).Error
//sql := "SELECT authority_menu.keep_alive,authority_menu.default_menu,authority_menu.created_at,authority_menu.updated_at,authority_menu.deleted_at,authority_menu.menu_level,authority_menu.parent_id,authority_menu.path,authority_menu.`name`,authority_menu.hidden,authority_menu.component,authority_menu.title,authority_menu.icon,authority_menu.sort,authority_menu.menu_id,authority_menu.authority_id FROM authority_menu WHERE authority_menu.authority_id = ? ORDER BY authority_menu.sort ASC"
//err = global.GVA_DB.Raw(sql, authorityId).Scan(&menus).Error
// sql := "SELECT authority_menu.keep_alive,authority_menu.default_menu,authority_menu.created_at,authority_menu.updated_at,authority_menu.deleted_at,authority_menu.menu_level,authority_menu.parent_id,authority_menu.path,authority_menu.`name`,authority_menu.hidden,authority_menu.component,authority_menu.title,authority_menu.icon,authority_menu.sort,authority_menu.menu_id,authority_menu.authority_id FROM authority_menu WHERE authority_menu.authority_id = ? ORDER BY authority_menu.sort ASC"
// err = global.GVA_DB.Raw(sql, authorityId).Scan(&menus).Error
return err, menus
}
......@@ -13,8 +13,7 @@ import (
//@param: sysOperationRecord model.SysOperationRecord
//@return: err error
type OperationRecordService struct {
}
type OperationRecordService struct{}
func (operationRecordService *OperationRecordService) CreateSysOperationRecord(sysOperationRecord system.SysOperationRecord) (err error) {
err = global.GVA_DB.Create(&sysOperationRecord).Error
......
......@@ -13,8 +13,7 @@ import (
//@description: 读取配置文件
//@return: err error, conf config.Server
type SystemConfigService struct {
}
type SystemConfigService struct{}
func (systemConfigService *SystemConfigService) GetSystemConfig() (err error, conf config.Server) {
return nil, global.GVA_CONFIG
......
......@@ -18,8 +18,7 @@ import (
//@param: u model.SysUser
//@return: err error, userInter model.SysUser
type UserService struct {
}
type UserService struct{}
func (userService *UserService) Register(u system.SysUser) (err error, userInter system.SysUser) {
var user system.SysUser
......
......@@ -16,7 +16,8 @@ func (a *api) TableName() string {
}
func (a *api) Initialize() error {
entities := []system.SysApi{{ApiGroup: "base", Method: "POST", Path: "/base/login", Description: "用户登录(必选)"},
entities := []system.SysApi{
{ApiGroup: "base", Method: "POST", Path: "/base/login", Description: "用户登录(必选)"},
{ApiGroup: "jwt", Method: "POST", Path: "/jwt/jsonInBlacklist", Description: "jwt加入黑名单(退出,必选)"},
......
package system
import (
"reflect"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
"github.com/pkg/errors"
"gorm.io/gorm"
"gorm.io/gorm/schema"
"reflect"
)
var AuthoritiesMenus = new(authoritiesMenus)
......
package system
import (
"reflect"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
"github.com/pkg/errors"
"gorm.io/gorm"
"gorm.io/gorm/schema"
"reflect"
)
var DataAuthorities = new(dataAuthorities)
......
......@@ -2,10 +2,11 @@ package system
import (
"fmt"
"strings"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
"github.com/pkg/errors"
"strings"
)
var ViewAuthorityMenuMysql = new(viewAuthorityMenuMysql)
......
......@@ -2,10 +2,11 @@ package system
import (
"fmt"
"strings"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
"github.com/pkg/errors"
"strings"
)
var ViewAuthorityMenuPostgres = new(viewAuthorityMenuPostgres)
......
......@@ -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 {
......
......@@ -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,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
}
}
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 {
......
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册