V2.5.2beta (#1101)

* fix: zap无法在运行时进行切割日志, config.docker.yaml与config.yaml同步 #1094

* feat: 为定时任务增加秒级控制

* feat: 调整代码结构,err更改为后置

* css 样式调整

Co-authored-by: SliverHorn <503551462@qq.com>
Co-authored-by: songzhibin97 <718428482@qq.com>
This commit is contained in:
奇淼(piexlmax
2022-05-28 19:22:23 +08:00
committed by GitHub
parent b25c128051
commit 83141b3564
49 changed files with 490 additions and 456 deletions

View File

@@ -24,7 +24,7 @@ import (
// @Param file formData file true "an example for breakpoint resume, 断点续传示例"
// @Success 200 {object} response.Response{msg=string} "断点续传到服务器"
// @Router /fileUploadAndDownload/breakpointContinue [post]
func (u *FileUploadAndDownloadApi) BreakpointContinue(c *gin.Context) {
func (b *FileUploadAndDownloadApi) BreakpointContinue(c *gin.Context) {
fileMd5 := c.Request.FormValue("fileMd5")
fileName := c.Request.FormValue("fileName")
chunkMd5 := c.Request.FormValue("chunkMd5")
@@ -54,20 +54,20 @@ func (u *FileUploadAndDownloadApi) BreakpointContinue(c *gin.Context) {
response.FailWithMessage("检查md5失败", c)
return
}
err, file := fileUploadAndDownloadService.FindOrCreateFile(fileMd5, fileName, chunkTotal)
file, err := fileUploadAndDownloadService.FindOrCreateFile(fileMd5, fileName, chunkTotal)
if err != nil {
global.GVA_LOG.Error("查找或创建记录失败!", zap.Error(err))
response.FailWithMessage("查找或创建记录失败", c)
return
}
err, pathc := utils.BreakPointContinue(cen, fileName, chunkNumber, chunkTotal, fileMd5)
pathC, err := utils.BreakPointContinue(cen, fileName, chunkNumber, chunkTotal, fileMd5)
if err != nil {
global.GVA_LOG.Error("断点续传失败!", zap.Error(err))
response.FailWithMessage("断点续传失败", c)
return
}
if err = fileUploadAndDownloadService.CreateFileChunk(file.ID, pathc, chunkNumber); err != nil {
if err = fileUploadAndDownloadService.CreateFileChunk(file.ID, pathC, chunkNumber); err != nil {
global.GVA_LOG.Error("创建文件记录失败!", zap.Error(err))
response.FailWithMessage("创建文件记录失败", c)
return
@@ -83,11 +83,11 @@ func (u *FileUploadAndDownloadApi) BreakpointContinue(c *gin.Context) {
// @Param file formData file true "Find the file, 查找文件"
// @Success 200 {object} response.Response{data=exampleRes.FileResponse,msg=string} "查找文件,返回包括文件详情"
// @Router /fileUploadAndDownload/findFile [post]
func (u *FileUploadAndDownloadApi) FindFile(c *gin.Context) {
func (b *FileUploadAndDownloadApi) FindFile(c *gin.Context) {
fileMd5 := c.Query("fileMd5")
fileName := c.Query("fileName")
chunkTotal, _ := strconv.Atoi(c.Query("chunkTotal"))
err, file := fileUploadAndDownloadService.FindOrCreateFile(fileMd5, fileName, chunkTotal)
file, err := fileUploadAndDownloadService.FindOrCreateFile(fileMd5, fileName, chunkTotal)
if err != nil {
global.GVA_LOG.Error("查找失败!", zap.Error(err))
response.FailWithMessage("查找失败", c)
@@ -107,7 +107,7 @@ func (u *FileUploadAndDownloadApi) FindFile(c *gin.Context) {
func (b *FileUploadAndDownloadApi) BreakpointContinueFinish(c *gin.Context) {
fileMd5 := c.Query("fileMd5")
fileName := c.Query("fileName")
err, filePath := utils.MakeFile(fileName, fileMd5)
filePath, err := utils.MakeFile(fileName, fileMd5)
if err != nil {
global.GVA_LOG.Error("文件创建失败!", zap.Error(err))
response.FailWithDetailed(exampleRes.FilePathResponse{FilePath: filePath}, "文件创建失败", c)
@@ -124,15 +124,15 @@ func (b *FileUploadAndDownloadApi) BreakpointContinueFinish(c *gin.Context) {
// @Param file formData file true "删除缓存切片"
// @Success 200 {object} response.Response{msg=string} "删除切片"
// @Router /fileUploadAndDownload/removeChunk [post]
func (u *FileUploadAndDownloadApi) RemoveChunk(c *gin.Context) {
func (b *FileUploadAndDownloadApi) RemoveChunk(c *gin.Context) {
var file example.ExaFile
c.ShouldBindJSON(&file)
_ = c.ShouldBindJSON(&file)
err := utils.RemoveChunk(file.FileMd5)
if err != nil {
global.GVA_LOG.Error("缓存切片删除失败!", zap.Error(err))
return
}
err = fileUploadAndDownloadService.DeleteFileChunk(file.FileMd5, file.FileName, file.FilePath)
err = fileUploadAndDownloadService.DeleteFileChunk(file.FileMd5, file.FilePath)
if err != nil {
global.GVA_LOG.Error(err.Error(), zap.Error(err))
response.FailWithMessage(err.Error(), c)

View File

@@ -103,7 +103,7 @@ func (e *CustomerApi) GetExaCustomer(c *gin.Context) {
response.FailWithMessage(err.Error(), c)
return
}
err, data := customerService.GetExaCustomer(customer.ID)
data, err := customerService.GetExaCustomer(customer.ID)
if err != nil {
global.GVA_LOG.Error("获取失败!", zap.Error(err))
response.FailWithMessage("获取失败", c)
@@ -127,7 +127,7 @@ func (e *CustomerApi) GetExaCustomerList(c *gin.Context) {
response.FailWithMessage(err.Error(), c)
return
}
err, customerList, total := customerService.GetCustomerInfoList(utils.GetUserAuthorityId(c), pageInfo)
customerList, total, err := customerService.GetCustomerInfoList(utils.GetUserAuthorityId(c), pageInfo)
if err != nil {
global.GVA_LOG.Error("获取失败!", zap.Error(err))
response.FailWithMessage("获取失败"+err.Error(), c)

View File

@@ -20,7 +20,7 @@ type FileUploadAndDownloadApi struct{}
// @Param file formData file true "上传文件示例"
// @Success 200 {object} response.Response{data=exampleRes.ExaFileResponse,msg=string} "上传文件示例,返回包括文件详情"
// @Router /fileUploadAndDownload/upload [post]
func (u *FileUploadAndDownloadApi) UploadFile(c *gin.Context) {
func (b *FileUploadAndDownloadApi) UploadFile(c *gin.Context) {
var file example.ExaFileUploadAndDownload
noSave := c.DefaultQuery("noSave", "0")
_, header, err := c.Request.FormFile("file")
@@ -29,7 +29,7 @@ func (u *FileUploadAndDownloadApi) UploadFile(c *gin.Context) {
response.FailWithMessage("接收文件失败", c)
return
}
err, file = fileUploadAndDownloadService.UploadFile(header, noSave) // 文件上传后拿到文件路径
file, err = fileUploadAndDownloadService.UploadFile(header, noSave) // 文件上传后拿到文件路径
if err != nil {
global.GVA_LOG.Error("修改数据库链接失败!", zap.Error(err))
response.FailWithMessage("修改数据库链接失败", c)
@@ -39,7 +39,7 @@ func (u *FileUploadAndDownloadApi) UploadFile(c *gin.Context) {
}
// EditFileName 编辑文件名或者备注
func (u *FileUploadAndDownloadApi) EditFileName(c *gin.Context) {
func (b *FileUploadAndDownloadApi) EditFileName(c *gin.Context) {
var file example.ExaFileUploadAndDownload
_ = c.ShouldBindJSON(&file)
if err := fileUploadAndDownloadService.EditFileName(file); err != nil {
@@ -57,7 +57,7 @@ func (u *FileUploadAndDownloadApi) EditFileName(c *gin.Context) {
// @Param data body example.ExaFileUploadAndDownload true "传入文件里面id即可"
// @Success 200 {object} response.Response{msg=string} "删除文件"
// @Router /fileUploadAndDownload/deleteFile [post]
func (u *FileUploadAndDownloadApi) DeleteFile(c *gin.Context) {
func (b *FileUploadAndDownloadApi) DeleteFile(c *gin.Context) {
var file example.ExaFileUploadAndDownload
_ = c.ShouldBindJSON(&file)
if err := fileUploadAndDownloadService.DeleteFile(file); err != nil {
@@ -76,10 +76,10 @@ func (u *FileUploadAndDownloadApi) DeleteFile(c *gin.Context) {
// @Param data body request.PageInfo true "页码, 每页大小"
// @Success 200 {object} response.Response{data=response.PageResult,msg=string} "分页文件列表,返回包括列表,总数,页码,每页数量"
// @Router /fileUploadAndDownload/getFileList [post]
func (u *FileUploadAndDownloadApi) GetFileList(c *gin.Context) {
func (b *FileUploadAndDownloadApi) GetFileList(c *gin.Context) {
var pageInfo request.PageInfo
_ = c.ShouldBindJSON(&pageInfo)
err, list, total := fileUploadAndDownloadService.GetFileRecordInfoList(pageInfo)
list, total, err := fileUploadAndDownloadService.GetFileRecordInfoList(pageInfo)
if err != nil {
global.GVA_LOG.Error("获取失败!", zap.Error(err))
response.FailWithMessage("获取失败", c)

View File

@@ -76,7 +76,7 @@ func (s *SystemApiApi) GetApiList(c *gin.Context) {
response.FailWithMessage(err.Error(), c)
return
}
if err, list, total := apiService.GetAPIInfoList(pageInfo.SysApi, pageInfo.PageInfo, pageInfo.OrderKey, pageInfo.Desc); err != nil {
if list, total, err := apiService.GetAPIInfoList(pageInfo.SysApi, pageInfo.PageInfo, pageInfo.OrderKey, pageInfo.Desc); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Error(err))
response.FailWithMessage("获取失败", c)
} else {
@@ -89,7 +89,6 @@ func (s *SystemApiApi) GetApiList(c *gin.Context) {
}
}
// todo
// @Tags SysApi
// @Summary 根据id获取api
// @Security ApiKeyAuth
@@ -105,7 +104,7 @@ func (s *SystemApiApi) GetApiById(c *gin.Context) {
response.FailWithMessage(err.Error(), c)
return
}
err, api := apiService.GetApiById(idInfo.ID)
api, err := apiService.GetApiById(idInfo.ID)
if err != nil {
global.GVA_LOG.Error("获取失败!", zap.Error(err))
response.FailWithMessage("获取失败", c)
@@ -145,7 +144,7 @@ func (s *SystemApiApi) UpdateApi(c *gin.Context) {
// @Success 200 {object} response.Response{data=systemRes.SysAPIListResponse,msg=string} "获取所有的Api 不分页,返回包括api列表"
// @Router /api/getAllApis [post]
func (s *SystemApiApi) GetAllApis(c *gin.Context) {
if err, apis := apiService.GetAllApis(); err != nil {
if apis, err := apiService.GetAllApis(); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Error(err))
response.FailWithMessage("获取失败", c)
} else {

View File

@@ -30,7 +30,7 @@ func (a *AuthorityApi) CreateAuthority(c *gin.Context) {
response.FailWithMessage(err.Error(), c)
return
}
if err, authBack := authorityService.CreateAuthority(authority); err != nil {
if authBack, err := authorityService.CreateAuthority(authority); err != nil {
global.GVA_LOG.Error("创建失败!", zap.Error(err))
response.FailWithMessage("创建失败"+err.Error(), c)
} else {
@@ -59,7 +59,7 @@ func (a *AuthorityApi) CopyAuthority(c *gin.Context) {
response.FailWithMessage(err.Error(), c)
return
}
if err, authBack := authorityService.CopyAuthority(copyInfo); err != nil {
if authBack, err := authorityService.CopyAuthority(copyInfo); err != nil {
global.GVA_LOG.Error("拷贝失败!", zap.Error(err))
response.FailWithMessage("拷贝失败"+err.Error(), c)
} else {
@@ -105,7 +105,7 @@ func (a *AuthorityApi) UpdateAuthority(c *gin.Context) {
response.FailWithMessage(err.Error(), c)
return
}
if err, authority := authorityService.UpdateAuthority(auth); err != nil {
if authority, err := authorityService.UpdateAuthority(auth); err != nil {
global.GVA_LOG.Error("更新失败!", zap.Error(err))
response.FailWithMessage("更新失败"+err.Error(), c)
} else {
@@ -128,7 +128,7 @@ func (a *AuthorityApi) GetAuthorityList(c *gin.Context) {
response.FailWithMessage(err.Error(), c)
return
}
if err, list, total := authorityService.GetAuthorityInfoList(pageInfo); err != nil {
if list, total, err := authorityService.GetAuthorityInfoList(pageInfo); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Error(err))
response.FailWithMessage("获取失败"+err.Error(), c)
} else {

View File

@@ -21,7 +21,7 @@ type AuthorityBtnApi struct{}
func (a *AuthorityBtnApi) GetAuthorityBtn(c *gin.Context) {
var req request.SysAuthorityBtnReq
_ = c.ShouldBindJSON(&req)
if err, res := authorityBtnService.GetAuthorityBtn(req); err != nil {
if res, err := authorityBtnService.GetAuthorityBtn(req); err != nil {
global.GVA_LOG.Error("查询失败!", zap.Error(err))
response.FailWithMessage("查询失败", c)
} else {

View File

@@ -218,7 +218,7 @@ func (autoApi *AutoCodeApi) DelPackage(c *gin.Context) {
}
}
// DelPackage
// AutoPlug
// @Tags AutoCode
// @Summary 创建插件模板
// @Security ApiKeyAuth

View File

@@ -80,7 +80,7 @@ func (s *DictionaryApi) UpdateSysDictionary(c *gin.Context) {
func (s *DictionaryApi) FindSysDictionary(c *gin.Context) {
var dictionary system.SysDictionary
_ = c.ShouldBindQuery(&dictionary)
if err, sysDictionary := dictionaryService.GetSysDictionary(dictionary.Type, dictionary.ID); err != nil {
if sysDictionary, err := dictionaryService.GetSysDictionary(dictionary.Type, dictionary.ID); err != nil {
global.GVA_LOG.Error("查询失败!", zap.Error(err))
response.FailWithMessage("查询失败", c)
} else {
@@ -103,7 +103,7 @@ func (s *DictionaryApi) GetSysDictionaryList(c *gin.Context) {
response.FailWithMessage(err.Error(), c)
return
}
if err, list, total := dictionaryService.GetSysDictionaryInfoList(pageInfo); err != nil {
if list, total, err := dictionaryService.GetSysDictionaryInfoList(pageInfo); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Error(err))
response.FailWithMessage("获取失败", c)
} else {

View File

@@ -84,11 +84,11 @@ func (s *DictionaryDetailApi) FindSysDictionaryDetail(c *gin.Context) {
response.FailWithMessage(err.Error(), c)
return
}
if err, resysDictionaryDetail := dictionaryDetailService.GetSysDictionaryDetail(detail.ID); err != nil {
if reSysDictionaryDetail, err := dictionaryDetailService.GetSysDictionaryDetail(detail.ID); err != nil {
global.GVA_LOG.Error("查询失败!", zap.Error(err))
response.FailWithMessage("查询失败", c)
} else {
response.OkWithDetailed(gin.H{"resysDictionaryDetail": resysDictionaryDetail}, "查询成功", c)
response.OkWithDetailed(gin.H{"reSysDictionaryDetail": reSysDictionaryDetail}, "查询成功", c)
}
}
@@ -103,7 +103,7 @@ func (s *DictionaryDetailApi) FindSysDictionaryDetail(c *gin.Context) {
func (s *DictionaryDetailApi) GetSysDictionaryDetailList(c *gin.Context) {
var pageInfo request.SysDictionaryDetailSearch
_ = c.ShouldBindQuery(&pageInfo)
if err, list, total := dictionaryDetailService.GetSysDictionaryDetailInfoList(pageInfo); err != nil {
if list, total, err := dictionaryDetailService.GetSysDictionaryDetailInfoList(pageInfo); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Error(err))
response.FailWithMessage("获取失败", c)
} else {

View File

@@ -23,7 +23,7 @@ type AuthorityMenuApi struct{}
// @Success 200 {object} response.Response{data=systemRes.SysMenusResponse,msg=string} "获取用户动态路由,返回包括系统菜单详情列表"
// @Router /menu/getMenu [post]
func (a *AuthorityMenuApi) GetMenu(c *gin.Context) {
if err, menus := menuService.GetMenuTree(utils.GetUserAuthorityId(c)); err != nil {
if menus, err := menuService.GetMenuTree(utils.GetUserAuthorityId(c)); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Error(err))
response.FailWithMessage("获取失败", c)
} else {
@@ -42,7 +42,7 @@ func (a *AuthorityMenuApi) GetMenu(c *gin.Context) {
// @Success 200 {object} response.Response{data=systemRes.SysBaseMenusResponse,msg=string} "获取用户动态路由,返回包括系统菜单列表"
// @Router /menu/getBaseMenuTree [post]
func (a *AuthorityMenuApi) GetBaseMenuTree(c *gin.Context) {
if err, menus := menuService.GetBaseMenuTree(); err != nil {
if menus, err := menuService.GetBaseMenuTree(); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Error(err))
response.FailWithMessage("获取失败", c)
} else {
@@ -88,7 +88,7 @@ func (a *AuthorityMenuApi) GetMenuAuthority(c *gin.Context) {
response.FailWithMessage(err.Error(), c)
return
}
if err, menus := menuService.GetMenuAuthority(&param); err != nil {
if menus, err := menuService.GetMenuAuthority(&param); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Error(err))
response.FailWithDetailed(systemRes.SysMenusResponse{Menus: menus}, "获取失败", c)
} else {
@@ -189,7 +189,7 @@ func (a *AuthorityMenuApi) GetBaseMenuById(c *gin.Context) {
response.FailWithMessage(err.Error(), c)
return
}
if err, menu := baseMenuService.GetBaseMenuById(idInfo.ID); err != nil {
if menu, err := baseMenuService.GetBaseMenuById(idInfo.ID); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Error(err))
response.FailWithMessage("获取失败", c)
} else {
@@ -212,7 +212,7 @@ func (a *AuthorityMenuApi) GetMenuList(c *gin.Context) {
response.FailWithMessage(err.Error(), c)
return
}
if err, menuList, total := menuService.GetInfoList(); err != nil {
if menuList, total, err := menuService.GetInfoList(); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Error(err))
response.FailWithMessage("获取失败", c)
} else {

View File

@@ -85,11 +85,11 @@ func (s *OperationRecordApi) FindSysOperationRecord(c *gin.Context) {
response.FailWithMessage(err.Error(), c)
return
}
if err, resysOperationRecord := operationRecordService.GetSysOperationRecord(sysOperationRecord.ID); err != nil {
if reSysOperationRecord, err := operationRecordService.GetSysOperationRecord(sysOperationRecord.ID); err != nil {
global.GVA_LOG.Error("查询失败!", zap.Error(err))
response.FailWithMessage("查询失败", c)
} else {
response.OkWithDetailed(gin.H{"resysOperationRecord": resysOperationRecord}, "查询成功", c)
response.OkWithDetailed(gin.H{"reSysOperationRecord": reSysOperationRecord}, "查询成功", c)
}
}
@@ -104,7 +104,7 @@ func (s *OperationRecordApi) FindSysOperationRecord(c *gin.Context) {
func (s *OperationRecordApi) GetSysOperationRecordList(c *gin.Context) {
var pageInfo systemReq.SysOperationRecordSearch
_ = c.ShouldBindQuery(&pageInfo)
if err, list, total := operationRecordService.GetSysOperationRecordInfoList(pageInfo); err != nil {
if list, total, err := operationRecordService.GetSysOperationRecordInfoList(pageInfo); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Error(err))
response.FailWithMessage("获取失败", c)
} else {

View File

@@ -20,7 +20,7 @@ type SystemApi struct{}
// @Success 200 {object} response.Response{data=systemRes.SysConfigResponse,msg=string} "获取配置文件内容,返回包括系统配置"
// @Router /system/getSystemConfig [post]
func (s *SystemApi) GetSystemConfig(c *gin.Context) {
if err, config := systemConfigService.GetSystemConfig(); err != nil {
if config, err := systemConfigService.GetSystemConfig(); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Error(err))
response.FailWithMessage("获取失败", c)
} else {

View File

@@ -31,7 +31,7 @@ func (b *BaseApi) Login(c *gin.Context) {
}
if store.Verify(l.CaptchaId, l.Captcha, true) {
u := &system.SysUser{Username: l.Username, Password: l.Password}
if err, user := userService.Login(u); err != nil {
if user, err := userService.Login(u); err != nil {
global.GVA_LOG.Error("登陆失败! 用户名不存在或者密码错误!", zap.Error(err))
response.FailWithMessage("用户名不存在或者密码错误", c)
} else {
@@ -67,7 +67,7 @@ func (b *BaseApi) tokenNext(c *gin.Context, user system.SysUser) {
return
}
if err, jwtStr := jwtService.GetRedisJWT(user.Username); err == redis.Nil {
if jwtStr, err := jwtService.GetRedisJWT(user.Username); err == redis.Nil {
if err := jwtService.SetRedisJWT(token, user.Username); err != nil {
global.GVA_LOG.Error("设置登录状态失败!", zap.Error(err))
response.FailWithMessage("设置登录状态失败", c)
@@ -120,7 +120,7 @@ func (b *BaseApi) Register(c *gin.Context) {
})
}
user := &system.SysUser{Username: r.Username, NickName: r.NickName, Password: r.Password, HeaderImg: r.HeaderImg, AuthorityId: r.AuthorityId, Authorities: authorities}
err, userReturn := userService.Register(*user)
userReturn, err := userService.Register(*user)
if err != nil {
global.GVA_LOG.Error("注册失败!", zap.Error(err))
response.FailWithDetailed(systemRes.SysUserResponse{User: userReturn}, "注册失败", c)
@@ -144,7 +144,7 @@ func (b *BaseApi) ChangePassword(c *gin.Context) {
return
}
u := &system.SysUser{Username: user.Username, Password: user.Password}
if err, _ := userService.ChangePassword(u, user.NewPassword); err != nil {
if _, err := userService.ChangePassword(u, user.NewPassword); err != nil {
global.GVA_LOG.Error("修改失败!", zap.Error(err))
response.FailWithMessage("修改失败,原密码与当前账户不符", c)
} else {
@@ -167,7 +167,7 @@ func (b *BaseApi) GetUserList(c *gin.Context) {
response.FailWithMessage(err.Error(), c)
return
}
if err, list, total := userService.GetUserInfoList(pageInfo); err != nil {
if list, total, err := userService.GetUserInfoList(pageInfo); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Error(err))
response.FailWithMessage("获取失败", c)
} else {
@@ -342,7 +342,7 @@ func (b *BaseApi) SetSelfInfo(c *gin.Context) {
// @Router /user/getUserInfo [get]
func (b *BaseApi) GetUserInfo(c *gin.Context) {
uuid := utils.GetUserUuid(c)
if err, ReqUser := userService.GetUserInfo(uuid); err != nil {
if ReqUser, err := userService.GetUserInfo(uuid); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Error(err))
response.FailWithMessage("获取失败", c)
} else {