mirror of
https://github.com/flipped-aurora/gin-vue-admin.git
synced 2026-09-21 20:35:16 +00:00
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:
committed by
GitHub
co-authored by
SliverHorn
songzhibin97
parent
b25c128051
commit
83141b3564
@@ -14,9 +14,9 @@ type FileUploadAndDownloadService struct{}
|
||||
//@function: FindOrCreateFile
|
||||
//@description: 上传文件时检测当前文件属性,如果没有文件则创建,有则返回文件的当前切片
|
||||
//@param: fileMd5 string, fileName string, chunkTotal int
|
||||
//@return: err error, file model.ExaFile
|
||||
//@return: file model.ExaFile, err error
|
||||
|
||||
func (e *FileUploadAndDownloadService) FindOrCreateFile(fileMd5 string, fileName string, chunkTotal int) (err error, file example.ExaFile) {
|
||||
func (e *FileUploadAndDownloadService) FindOrCreateFile(fileMd5 string, fileName string, chunkTotal int) (file example.ExaFile, err error) {
|
||||
var cfile example.ExaFile
|
||||
cfile.FileMd5 = fileMd5
|
||||
cfile.FileName = fileName
|
||||
@@ -24,12 +24,12 @@ func (e *FileUploadAndDownloadService) FindOrCreateFile(fileMd5 string, fileName
|
||||
|
||||
if errors.Is(global.GVA_DB.Where("file_md5 = ? AND is_finish = ?", fileMd5, true).First(&file).Error, gorm.ErrRecordNotFound) {
|
||||
err = global.GVA_DB.Where("file_md5 = ? AND file_name = ?", fileMd5, fileName).Preload("ExaFileChunk").FirstOrCreate(&file, cfile).Error
|
||||
return err, file
|
||||
return file, err
|
||||
}
|
||||
cfile.IsFinish = true
|
||||
cfile.FilePath = file.FilePath
|
||||
err = global.GVA_DB.Create(&cfile).Error
|
||||
return err, cfile
|
||||
return cfile, err
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
@@ -53,7 +53,7 @@ func (e *FileUploadAndDownloadService) CreateFileChunk(id uint, fileChunkPath st
|
||||
//@param: fileMd5 string, fileName string, filePath string
|
||||
//@return: error
|
||||
|
||||
func (e *FileUploadAndDownloadService) DeleteFileChunk(fileMd5 string, fileName string, filePath string) error {
|
||||
func (e *FileUploadAndDownloadService) DeleteFileChunk(fileMd5 string, filePath string) error {
|
||||
var chunks []example.ExaFileChunk
|
||||
var file example.ExaFile
|
||||
err := global.GVA_DB.Where("file_md5 = ? ", fileMd5).First(&file).Update("IsFinish", true).Update("file_path", filePath).Error
|
||||
|
||||
@@ -47,9 +47,9 @@ func (exa *CustomerService) UpdateExaCustomer(e *example.ExaCustomer) (err error
|
||||
//@function: GetExaCustomer
|
||||
//@description: 获取客户信息
|
||||
//@param: id uint
|
||||
//@return: err error, customer model.ExaCustomer
|
||||
//@return: customer model.ExaCustomer, err error
|
||||
|
||||
func (exa *CustomerService) GetExaCustomer(id uint) (err error, customer example.ExaCustomer) {
|
||||
func (exa *CustomerService) GetExaCustomer(id uint) (customer example.ExaCustomer, err error) {
|
||||
err = global.GVA_DB.Where("id = ?", id).First(&customer).Error
|
||||
return
|
||||
}
|
||||
@@ -58,15 +58,15 @@ func (exa *CustomerService) GetExaCustomer(id uint) (err error, customer example
|
||||
//@function: GetCustomerInfoList
|
||||
//@description: 分页获取客户列表
|
||||
//@param: sysUserAuthorityID string, info request.PageInfo
|
||||
//@return: err error, list interface{}, total int64
|
||||
//@return: list interface{}, total int64, err error
|
||||
|
||||
func (exa *CustomerService) GetCustomerInfoList(sysUserAuthorityID string, info request.PageInfo) (err error, list interface{}, total int64) {
|
||||
func (exa *CustomerService) GetCustomerInfoList(sysUserAuthorityID string, info request.PageInfo) (list interface{}, total int64, err error) {
|
||||
limit := info.PageSize
|
||||
offset := info.PageSize * (info.Page - 1)
|
||||
db := global.GVA_DB.Model(&example.ExaCustomer{})
|
||||
var a system.SysAuthority
|
||||
a.AuthorityId = sysUserAuthorityID
|
||||
err, auth := systemService.AuthorityServiceApp.GetAuthorityInfo(a)
|
||||
auth, err := systemService.AuthorityServiceApp.GetAuthorityInfo(a)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -77,9 +77,9 @@ func (exa *CustomerService) GetCustomerInfoList(sysUserAuthorityID string, info
|
||||
var CustomerList []example.ExaCustomer
|
||||
err = db.Where("sys_user_authority_id in ?", dataId).Count(&total).Error
|
||||
if err != nil {
|
||||
return err, CustomerList, total
|
||||
return CustomerList, total, err
|
||||
} else {
|
||||
err = db.Limit(limit).Offset(offset).Preload("SysUser").Where("sys_user_authority_id in ?", dataId).Find(&CustomerList).Error
|
||||
}
|
||||
return err, CustomerList, total
|
||||
return CustomerList, total, err
|
||||
}
|
||||
|
||||
@@ -25,12 +25,12 @@ func (e *FileUploadAndDownloadService) Upload(file example.ExaFileUploadAndDownl
|
||||
//@function: FindFile
|
||||
//@description: 查询文件记录
|
||||
//@param: id uint
|
||||
//@return: error, model.ExaFileUploadAndDownload
|
||||
//@return: model.ExaFileUploadAndDownload, error
|
||||
|
||||
func (e *FileUploadAndDownloadService) FindFile(id uint) (error, example.ExaFileUploadAndDownload) {
|
||||
func (e *FileUploadAndDownloadService) FindFile(id uint) (example.ExaFileUploadAndDownload, error) {
|
||||
var file example.ExaFileUploadAndDownload
|
||||
err := global.GVA_DB.Where("id = ?", id).First(&file).Error
|
||||
return err, file
|
||||
return file, err
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
@@ -41,7 +41,7 @@ func (e *FileUploadAndDownloadService) FindFile(id uint) (error, example.ExaFile
|
||||
|
||||
func (e *FileUploadAndDownloadService) DeleteFile(file example.ExaFileUploadAndDownload) (err error) {
|
||||
var fileFromDb example.ExaFileUploadAndDownload
|
||||
err, fileFromDb = e.FindFile(file.ID)
|
||||
fileFromDb, err = e.FindFile(file.ID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -63,9 +63,9 @@ func (e *FileUploadAndDownloadService) EditFileName(file example.ExaFileUploadAn
|
||||
//@function: GetFileRecordInfoList
|
||||
//@description: 分页获取数据
|
||||
//@param: info request.PageInfo
|
||||
//@return: err error, list interface{}, total int64
|
||||
//@return: list interface{}, total int64, err error
|
||||
|
||||
func (e *FileUploadAndDownloadService) GetFileRecordInfoList(info request.PageInfo) (err error, list interface{}, total int64) {
|
||||
func (e *FileUploadAndDownloadService) GetFileRecordInfoList(info request.PageInfo) (list interface{}, total int64, err error) {
|
||||
limit := info.PageSize
|
||||
offset := info.PageSize * (info.Page - 1)
|
||||
keyword := info.Keyword
|
||||
@@ -79,16 +79,16 @@ func (e *FileUploadAndDownloadService) GetFileRecordInfoList(info request.PageIn
|
||||
return
|
||||
}
|
||||
err = db.Limit(limit).Offset(offset).Order("updated_at desc").Find(&fileLists).Error
|
||||
return err, fileLists, total
|
||||
return fileLists, total, err
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
//@function: UploadFile
|
||||
//@description: 根据配置文件判断是文件上传到本地或者七牛云
|
||||
//@param: header *multipart.FileHeader, noSave string
|
||||
//@return: err error, file model.ExaFileUploadAndDownload
|
||||
//@return: file model.ExaFileUploadAndDownload, err error
|
||||
|
||||
func (e *FileUploadAndDownloadService) UploadFile(header *multipart.FileHeader, noSave string) (err error, file example.ExaFileUploadAndDownload) {
|
||||
func (e *FileUploadAndDownloadService) UploadFile(header *multipart.FileHeader, noSave string) (file example.ExaFileUploadAndDownload, err error) {
|
||||
oss := upload.NewOss()
|
||||
filePath, key, uploadErr := oss.UploadFile(header)
|
||||
if uploadErr != nil {
|
||||
@@ -102,7 +102,7 @@ func (e *FileUploadAndDownloadService) UploadFile(header *multipart.FileHeader,
|
||||
Tag: s[len(s)-1],
|
||||
Key: key,
|
||||
}
|
||||
return e.Upload(f), f
|
||||
return f, e.Upload(f)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -45,11 +45,11 @@ func (jwtService *JwtService) IsBlacklist(jwt string) bool {
|
||||
//@function: GetRedisJWT
|
||||
//@description: 从redis取jwt
|
||||
//@param: userName string
|
||||
//@return: err error, redisJWT string
|
||||
//@return: redisJWT string, err error
|
||||
|
||||
func (jwtService *JwtService) GetRedisJWT(userName string) (err error, redisJWT string) {
|
||||
func (jwtService *JwtService) GetRedisJWT(userName string) (redisJWT string, err error) {
|
||||
redisJWT, err = global.GVA_REDIS.Get(context.Background(), userName).Result()
|
||||
return err, redisJWT
|
||||
return redisJWT, err
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
|
||||
@@ -44,9 +44,9 @@ func (apiService *ApiService) DeleteApi(api system.SysApi) (err error) {
|
||||
//@function: GetAPIInfoList
|
||||
//@description: 分页获取数据,
|
||||
//@param: api model.SysApi, info request.PageInfo, order string, desc bool
|
||||
//@return: err error
|
||||
//@return: list interface{}, total int64, err error
|
||||
|
||||
func (apiService *ApiService) GetAPIInfoList(api system.SysApi, info request.PageInfo, order string, desc bool) (err error, list interface{}, total int64) {
|
||||
func (apiService *ApiService) GetAPIInfoList(api system.SysApi, info request.PageInfo, order string, desc bool) (list interface{}, total int64, err error) {
|
||||
limit := info.PageSize
|
||||
offset := info.PageSize * (info.Page - 1)
|
||||
db := global.GVA_DB.Model(&system.SysApi{})
|
||||
@@ -71,7 +71,7 @@ func (apiService *ApiService) GetAPIInfoList(api system.SysApi, info request.Pag
|
||||
err = db.Count(&total).Error
|
||||
|
||||
if err != nil {
|
||||
return err, apiList, total
|
||||
return apiList, total, err
|
||||
} else {
|
||||
db = db.Limit(limit).Offset(offset)
|
||||
if order != "" {
|
||||
@@ -92,7 +92,7 @@ func (apiService *ApiService) GetAPIInfoList(api system.SysApi, info request.Pag
|
||||
}
|
||||
} else { // didn't matched any order key in `orderMap`
|
||||
err = fmt.Errorf("非法的排序字段: %v", order)
|
||||
return err, apiList, total
|
||||
return apiList, total, err
|
||||
}
|
||||
|
||||
err = db.Order(OrderStr).Find(&apiList).Error
|
||||
@@ -100,15 +100,15 @@ func (apiService *ApiService) GetAPIInfoList(api system.SysApi, info request.Pag
|
||||
err = db.Order("api_group").Find(&apiList).Error
|
||||
}
|
||||
}
|
||||
return err, apiList, total
|
||||
return apiList, total, err
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
//@function: GetAllApis
|
||||
//@description: 获取所有的api
|
||||
//@return: err error, apis []model.SysApi
|
||||
//@return: apis []model.SysApi, err error
|
||||
|
||||
func (apiService *ApiService) GetAllApis() (err error, apis []system.SysApi) {
|
||||
func (apiService *ApiService) GetAllApis() (apis []system.SysApi, err error) {
|
||||
err = global.GVA_DB.Find(&apis).Error
|
||||
return
|
||||
}
|
||||
@@ -117,9 +117,9 @@ func (apiService *ApiService) GetAllApis() (err error, apis []system.SysApi) {
|
||||
//@function: GetApiById
|
||||
//@description: 根据id获取api
|
||||
//@param: id float64
|
||||
//@return: err error, api model.SysApi
|
||||
//@return: api model.SysApi, err error
|
||||
|
||||
func (apiService *ApiService) GetApiById(id int) (err error, api system.SysApi) {
|
||||
func (apiService *ApiService) GetApiById(id int) (api system.SysApi, err error) {
|
||||
err = global.GVA_DB.Where("id = ?", id).First(&api).Error
|
||||
return
|
||||
}
|
||||
|
||||
@@ -11,38 +11,40 @@ import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var ErrRoleExistence = errors.New("存在相同角色id")
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
//@function: CreateAuthority
|
||||
//@description: 创建一个角色
|
||||
//@param: auth model.SysAuthority
|
||||
//@return: err error, authority model.SysAuthority
|
||||
//@return: authority system.SysAuthority, err error
|
||||
|
||||
type AuthorityService struct{}
|
||||
|
||||
var AuthorityServiceApp = new(AuthorityService)
|
||||
|
||||
func (authorityService *AuthorityService) CreateAuthority(auth system.SysAuthority) (err error, authority system.SysAuthority) {
|
||||
func (authorityService *AuthorityService) CreateAuthority(auth system.SysAuthority) (authority system.SysAuthority, err error) {
|
||||
var authorityBox system.SysAuthority
|
||||
if !errors.Is(global.GVA_DB.Where("authority_id = ?", auth.AuthorityId).First(&authorityBox).Error, gorm.ErrRecordNotFound) {
|
||||
return errors.New("存在相同角色id"), auth
|
||||
return auth, ErrRoleExistence
|
||||
}
|
||||
err = global.GVA_DB.Create(&auth).Error
|
||||
return err, auth
|
||||
return auth, err
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
//@function: CopyAuthority
|
||||
//@description: 复制一个角色
|
||||
//@param: copyInfo response.SysAuthorityCopyResponse
|
||||
//@return: err error, authority model.SysAuthority
|
||||
//@return: authority system.SysAuthority, err error
|
||||
|
||||
func (authorityService *AuthorityService) CopyAuthority(copyInfo response.SysAuthorityCopyResponse) (err error, authority system.SysAuthority) {
|
||||
func (authorityService *AuthorityService) CopyAuthority(copyInfo response.SysAuthorityCopyResponse) (authority system.SysAuthority, err error) {
|
||||
var authorityBox system.SysAuthority
|
||||
if !errors.Is(global.GVA_DB.Where("authority_id = ?", copyInfo.Authority.AuthorityId).First(&authorityBox).Error, gorm.ErrRecordNotFound) {
|
||||
return errors.New("存在相同角色id"), authority
|
||||
return authority, ErrRoleExistence
|
||||
}
|
||||
copyInfo.Authority.Children = []system.SysAuthority{}
|
||||
err, menus := MenuServiceApp.GetMenuAuthority(&request.GetAuthorityId{AuthorityId: copyInfo.OldAuthorityId})
|
||||
menus, err := MenuServiceApp.GetMenuAuthority(&request.GetAuthorityId{AuthorityId: copyInfo.OldAuthorityId})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -79,18 +81,18 @@ func (authorityService *AuthorityService) CopyAuthority(copyInfo response.SysAut
|
||||
if err != nil {
|
||||
_ = authorityService.DeleteAuthority(©Info.Authority)
|
||||
}
|
||||
return err, copyInfo.Authority
|
||||
return copyInfo.Authority, err
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
//@function: UpdateAuthority
|
||||
//@description: 更改一个角色
|
||||
//@param: auth model.SysAuthority
|
||||
//@return: err error, authority model.SysAuthority
|
||||
//@return: authority system.SysAuthority, err error
|
||||
|
||||
func (authorityService *AuthorityService) UpdateAuthority(auth system.SysAuthority) (err error, authority system.SysAuthority) {
|
||||
func (authorityService *AuthorityService) UpdateAuthority(auth system.SysAuthority) (authority system.SysAuthority, err error) {
|
||||
err = global.GVA_DB.Where("authority_id = ?", auth.AuthorityId).First(&system.SysAuthority{}).Updates(&auth).Error
|
||||
return err, auth
|
||||
return auth, err
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
@@ -139,9 +141,9 @@ func (authorityService *AuthorityService) DeleteAuthority(auth *system.SysAuthor
|
||||
//@function: GetAuthorityInfoList
|
||||
//@description: 分页获取数据
|
||||
//@param: info request.PageInfo
|
||||
//@return: err error, list interface{}, total int64
|
||||
//@return: list interface{}, total int64, err error
|
||||
|
||||
func (authorityService *AuthorityService) GetAuthorityInfoList(info request.PageInfo) (err error, list interface{}, total int64) {
|
||||
func (authorityService *AuthorityService) GetAuthorityInfoList(info request.PageInfo) (list interface{}, total int64, err error) {
|
||||
limit := info.PageSize
|
||||
offset := info.PageSize * (info.Page - 1)
|
||||
db := global.GVA_DB.Model(&system.SysAuthority{})
|
||||
@@ -153,18 +155,18 @@ func (authorityService *AuthorityService) GetAuthorityInfoList(info request.Page
|
||||
err = authorityService.findChildrenAuthority(&authority[k])
|
||||
}
|
||||
}
|
||||
return err, authority, total
|
||||
return authority, total, err
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
//@function: GetAuthorityInfo
|
||||
//@description: 获取所有角色信息
|
||||
//@param: auth model.SysAuthority
|
||||
//@return: err error, sa model.SysAuthority
|
||||
//@return: sa system.SysAuthority, err error
|
||||
|
||||
func (authorityService *AuthorityService) GetAuthorityInfo(auth system.SysAuthority) (err error, sa system.SysAuthority) {
|
||||
func (authorityService *AuthorityService) GetAuthorityInfo(auth system.SysAuthority) (sa system.SysAuthority, err error) {
|
||||
err = global.GVA_DB.Preload("DataAuthorityId").Where("authority_id = ?", auth.AuthorityId).First(&sa).Error
|
||||
return err, sa
|
||||
return sa, err
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
type AuthorityBtnService struct{}
|
||||
|
||||
func (a *AuthorityBtnService) GetAuthorityBtn(req request.SysAuthorityBtnReq) (err error, res response.SysAuthorityBtnRes) {
|
||||
func (a *AuthorityBtnService) GetAuthorityBtn(req request.SysAuthorityBtnReq) (res response.SysAuthorityBtnRes, err error) {
|
||||
var authorityBtn []system.SysAuthorityBtn
|
||||
err = global.GVA_DB.Find(&authorityBtn, "authority_id = ? and sys_menu_id = ?", req.AuthorityId, req.MenuID).Error
|
||||
if err != nil {
|
||||
@@ -22,7 +22,7 @@ func (a *AuthorityBtnService) GetAuthorityBtn(req request.SysAuthorityBtnReq) (e
|
||||
selected = append(selected, v.SysBaseMenuBtnID)
|
||||
}
|
||||
res.Selected = selected
|
||||
return err, res
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (a *AuthorityBtnService) SetAuthorityBtn(req request.SysAuthorityBtnReq) (err error) {
|
||||
|
||||
@@ -795,7 +795,7 @@ func ImportReference(filepath, importCode, structName, packageName, groupName st
|
||||
return ioutil.WriteFile(filepath, buffer.Bytes(), 0o600)
|
||||
}
|
||||
|
||||
// 自动创建插件模板
|
||||
// CreatePlug 自动创建插件模板
|
||||
func (autoCodeService *AutoCodeService) CreatePlug(plug system.AutoPlugReq) error {
|
||||
// 检查列表参数是否有效
|
||||
plug.CheckList()
|
||||
|
||||
@@ -97,7 +97,7 @@ func (autoCodeHistoryService *AutoCodeHistoryService) RollBack(info *systemReq.R
|
||||
}
|
||||
err = utils.FileMove(path, nPath)
|
||||
if err != nil {
|
||||
fmt.Println(">>>>>>>>>>>>>>>>>>>", err)
|
||||
global.GVA_LOG.Error("file move err ", zap.Error(err))
|
||||
}
|
||||
//_ = utils.DeLFile(path)
|
||||
}
|
||||
|
||||
@@ -116,9 +116,9 @@ func (baseMenuService *BaseMenuService) UpdateBaseMenu(menu system.SysBaseMenu)
|
||||
//@function: GetBaseMenuById
|
||||
//@description: 返回当前选中menu
|
||||
//@param: id float64
|
||||
//@return: err error, menu model.SysBaseMenu
|
||||
//@return: menu system.SysBaseMenu, err error
|
||||
|
||||
func (baseMenuService *BaseMenuService) GetBaseMenuById(id int) (err error, menu system.SysBaseMenu) {
|
||||
func (baseMenuService *BaseMenuService) GetBaseMenuById(id int) (menu system.SysBaseMenu, err error) {
|
||||
err = global.GVA_DB.Preload("MenuBtn").Preload("Parameters").Where("id = ?", id).First(&menu).Error
|
||||
return
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ func (dictionaryService *DictionaryService) UpdateSysDictionary(sysDictionary *s
|
||||
//@param: Type string, Id uint
|
||||
//@return: err error, sysDictionary model.SysDictionary
|
||||
|
||||
func (dictionaryService *DictionaryService) GetSysDictionary(Type string, Id uint) (err error, sysDictionary system.SysDictionary) {
|
||||
func (dictionaryService *DictionaryService) GetSysDictionary(Type string, Id uint) (sysDictionary system.SysDictionary, err error) {
|
||||
err = global.GVA_DB.Where("type = ? OR id = ? and status = ?", Type, Id, true).Preload("SysDictionaryDetails", "status = ?", true).First(&sysDictionary).Error
|
||||
return
|
||||
}
|
||||
@@ -92,7 +92,7 @@ func (dictionaryService *DictionaryService) GetSysDictionary(Type string, Id uin
|
||||
//@param: info request.SysDictionarySearch
|
||||
//@return: err error, list interface{}, total int64
|
||||
|
||||
func (dictionaryService *DictionaryService) GetSysDictionaryInfoList(info request.SysDictionarySearch) (err error, list interface{}, total int64) {
|
||||
func (dictionaryService *DictionaryService) GetSysDictionaryInfoList(info request.SysDictionarySearch) (list interface{}, total int64, err error) {
|
||||
limit := info.PageSize
|
||||
offset := info.PageSize * (info.Page - 1)
|
||||
// 创建db
|
||||
@@ -116,5 +116,5 @@ func (dictionaryService *DictionaryService) GetSysDictionaryInfoList(info reques
|
||||
return
|
||||
}
|
||||
err = db.Limit(limit).Offset(offset).Find(&sysDictionarys).Error
|
||||
return err, sysDictionarys, total
|
||||
return sysDictionarys, total, err
|
||||
}
|
||||
|
||||
@@ -45,9 +45,9 @@ func (dictionaryDetailService *DictionaryDetailService) UpdateSysDictionaryDetai
|
||||
//@function: GetSysDictionaryDetail
|
||||
//@description: 根据id获取字典详情单条数据
|
||||
//@param: id uint
|
||||
//@return: err error, sysDictionaryDetail model.SysDictionaryDetail
|
||||
//@return: sysDictionaryDetail system.SysDictionaryDetail, err error
|
||||
|
||||
func (dictionaryDetailService *DictionaryDetailService) GetSysDictionaryDetail(id uint) (err error, sysDictionaryDetail system.SysDictionaryDetail) {
|
||||
func (dictionaryDetailService *DictionaryDetailService) GetSysDictionaryDetail(id uint) (sysDictionaryDetail system.SysDictionaryDetail, err error) {
|
||||
err = global.GVA_DB.Where("id = ?", id).First(&sysDictionaryDetail).Error
|
||||
return
|
||||
}
|
||||
@@ -56,9 +56,9 @@ func (dictionaryDetailService *DictionaryDetailService) GetSysDictionaryDetail(i
|
||||
//@function: GetSysDictionaryDetailInfoList
|
||||
//@description: 分页获取字典详情列表
|
||||
//@param: info request.SysDictionaryDetailSearch
|
||||
//@return: err error, list interface{}, total int64
|
||||
//@return: list interface{}, total int64, err error
|
||||
|
||||
func (dictionaryDetailService *DictionaryDetailService) GetSysDictionaryDetailInfoList(info request.SysDictionaryDetailSearch) (err error, list interface{}, total int64) {
|
||||
func (dictionaryDetailService *DictionaryDetailService) GetSysDictionaryDetailInfoList(info request.SysDictionaryDetailSearch) (list interface{}, total int64, err error) {
|
||||
limit := info.PageSize
|
||||
offset := info.PageSize * (info.Page - 1)
|
||||
// 创建db
|
||||
@@ -82,5 +82,5 @@ func (dictionaryDetailService *DictionaryDetailService) GetSysDictionaryDetailIn
|
||||
return
|
||||
}
|
||||
err = db.Limit(limit).Offset(offset).Find(&sysDictionaryDetails).Error
|
||||
return err, sysDictionaryDetails, total
|
||||
return sysDictionaryDetails, total, err
|
||||
}
|
||||
|
||||
@@ -14,13 +14,13 @@ import (
|
||||
//@function: getMenuTreeMap
|
||||
//@description: 获取路由总树map
|
||||
//@param: authorityId string
|
||||
//@return: err error, treeMap map[string][]model.SysMenu
|
||||
//@return: treeMap map[string][]system.SysMenu, err error
|
||||
|
||||
type MenuService struct{}
|
||||
|
||||
var MenuServiceApp = new(MenuService)
|
||||
|
||||
func (menuService *MenuService) getMenuTreeMap(authorityId string) (err error, treeMap map[string][]system.SysMenu) {
|
||||
func (menuService *MenuService) getMenuTreeMap(authorityId string) (treeMap map[string][]system.SysMenu, err error) {
|
||||
var allMenus []system.SysMenu
|
||||
var btns []system.SysAuthorityBtn
|
||||
treeMap = make(map[string][]system.SysMenu)
|
||||
@@ -43,22 +43,22 @@ func (menuService *MenuService) getMenuTreeMap(authorityId string) (err error, t
|
||||
v.Btns = btnMap[v.ID]
|
||||
treeMap[v.ParentId] = append(treeMap[v.ParentId], v)
|
||||
}
|
||||
return err, treeMap
|
||||
return treeMap, err
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
//@function: GetMenuTree
|
||||
//@description: 获取动态菜单树
|
||||
//@param: authorityId string
|
||||
//@return: err error, menus []model.SysMenu
|
||||
//@return: menus []system.SysMenu, err error
|
||||
|
||||
func (menuService *MenuService) GetMenuTree(authorityId string) (err error, menus []system.SysMenu) {
|
||||
err, menuTree := menuService.getMenuTreeMap(authorityId)
|
||||
func (menuService *MenuService) GetMenuTree(authorityId string) (menus []system.SysMenu, err error) {
|
||||
menuTree, err := menuService.getMenuTreeMap(authorityId)
|
||||
menus = menuTree["0"]
|
||||
for i := 0; i < len(menus); i++ {
|
||||
err = menuService.getChildrenList(&menus[i], menuTree)
|
||||
}
|
||||
return err, menus
|
||||
return menus, err
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
@@ -78,16 +78,16 @@ func (menuService *MenuService) getChildrenList(menu *system.SysMenu, treeMap ma
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
//@function: GetInfoList
|
||||
//@description: 获取路由分页
|
||||
//@return: err error, list interface{}, total int64
|
||||
//@return: list interface{}, total int64,err error
|
||||
|
||||
func (menuService *MenuService) GetInfoList() (err error, list interface{}, total int64) {
|
||||
func (menuService *MenuService) GetInfoList() (list interface{}, total int64, err error) {
|
||||
var menuList []system.SysBaseMenu
|
||||
err, treeMap := menuService.getBaseMenuTreeMap()
|
||||
treeMap, err := menuService.getBaseMenuTreeMap()
|
||||
menuList = treeMap["0"]
|
||||
for i := 0; i < len(menuList); i++ {
|
||||
err = menuService.getBaseChildrenList(&menuList[i], treeMap)
|
||||
}
|
||||
return err, menuList, total
|
||||
return menuList, total, err
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
@@ -120,30 +120,30 @@ func (menuService *MenuService) AddBaseMenu(menu system.SysBaseMenu) error {
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
//@function: getBaseMenuTreeMap
|
||||
//@description: 获取路由总树map
|
||||
//@return: err error, treeMap map[string][]model.SysBaseMenu
|
||||
//@return: treeMap map[string][]system.SysBaseMenu, err error
|
||||
|
||||
func (menuService *MenuService) getBaseMenuTreeMap() (err error, treeMap map[string][]system.SysBaseMenu) {
|
||||
func (menuService *MenuService) getBaseMenuTreeMap() (treeMap map[string][]system.SysBaseMenu, err error) {
|
||||
var allMenus []system.SysBaseMenu
|
||||
treeMap = make(map[string][]system.SysBaseMenu)
|
||||
err = global.GVA_DB.Order("sort").Preload("MenuBtn").Preload("Parameters").Find(&allMenus).Error
|
||||
for _, v := range allMenus {
|
||||
treeMap[v.ParentId] = append(treeMap[v.ParentId], v)
|
||||
}
|
||||
return err, treeMap
|
||||
return treeMap, err
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
//@function: GetBaseMenuTree
|
||||
//@description: 获取基础路由树
|
||||
//@return: err error, menus []model.SysBaseMenu
|
||||
//@return: menus []system.SysBaseMenu, err error
|
||||
|
||||
func (menuService *MenuService) GetBaseMenuTree() (err error, menus []system.SysBaseMenu) {
|
||||
err, treeMap := menuService.getBaseMenuTreeMap()
|
||||
func (menuService *MenuService) GetBaseMenuTree() (menus []system.SysBaseMenu, err error) {
|
||||
treeMap, err := menuService.getBaseMenuTreeMap()
|
||||
menus = treeMap["0"]
|
||||
for i := 0; i < len(menus); i++ {
|
||||
err = menuService.getBaseChildrenList(&menus[i], treeMap)
|
||||
}
|
||||
return err, menus
|
||||
return menus, err
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
@@ -164,11 +164,11 @@ func (menuService *MenuService) AddMenuAuthority(menus []system.SysBaseMenu, aut
|
||||
//@function: GetMenuAuthority
|
||||
//@description: 查看当前角色树
|
||||
//@param: info *request.GetAuthorityId
|
||||
//@return: err error, menus []model.SysMenu
|
||||
//@return: menus []system.SysMenu, err error
|
||||
|
||||
func (menuService *MenuService) GetMenuAuthority(info *request.GetAuthorityId) (err error, menus []system.SysMenu) {
|
||||
func (menuService *MenuService) GetMenuAuthority(info *request.GetAuthorityId) (menus []system.SysMenu, err error) {
|
||||
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
|
||||
return err, menus
|
||||
return menus, err
|
||||
}
|
||||
|
||||
@@ -47,9 +47,9 @@ func (operationRecordService *OperationRecordService) DeleteSysOperationRecord(s
|
||||
//@function: DeleteSysOperationRecord
|
||||
//@description: 根据id获取单条操作记录
|
||||
//@param: id uint
|
||||
//@return: err error, sysOperationRecord model.SysOperationRecord
|
||||
//@return: sysOperationRecord system.SysOperationRecord, err error
|
||||
|
||||
func (operationRecordService *OperationRecordService) GetSysOperationRecord(id uint) (err error, sysOperationRecord system.SysOperationRecord) {
|
||||
func (operationRecordService *OperationRecordService) GetSysOperationRecord(id uint) (sysOperationRecord system.SysOperationRecord, err error) {
|
||||
err = global.GVA_DB.Where("id = ?", id).First(&sysOperationRecord).Error
|
||||
return
|
||||
}
|
||||
@@ -59,9 +59,9 @@ func (operationRecordService *OperationRecordService) GetSysOperationRecord(id u
|
||||
//@function: GetSysOperationRecordInfoList
|
||||
//@description: 分页获取操作记录列表
|
||||
//@param: info systemReq.SysOperationRecordSearch
|
||||
//@return: err error, list interface{}, total int64
|
||||
//@return: list interface{}, total int64, err error
|
||||
|
||||
func (operationRecordService *OperationRecordService) GetSysOperationRecordInfoList(info systemReq.SysOperationRecordSearch) (err error, list interface{}, total int64) {
|
||||
func (operationRecordService *OperationRecordService) GetSysOperationRecordInfoList(info systemReq.SysOperationRecordSearch) (list interface{}, total int64, err error) {
|
||||
limit := info.PageSize
|
||||
offset := info.PageSize * (info.Page - 1)
|
||||
// 创建db
|
||||
@@ -82,5 +82,5 @@ func (operationRecordService *OperationRecordService) GetSysOperationRecordInfoL
|
||||
return
|
||||
}
|
||||
err = db.Order("id desc").Limit(limit).Offset(offset).Preload("User").Find(&sysOperationRecords).Error
|
||||
return err, sysOperationRecords, total
|
||||
return sysOperationRecords, total, err
|
||||
}
|
||||
|
||||
@@ -11,12 +11,12 @@ import (
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
//@function: GetSystemConfig
|
||||
//@description: 读取配置文件
|
||||
//@return: err error, conf config.Server
|
||||
//@return: conf config.Server, err error
|
||||
|
||||
type SystemConfigService struct{}
|
||||
|
||||
func (systemConfigService *SystemConfigService) GetSystemConfig() (err error, conf config.Server) {
|
||||
return nil, global.GVA_CONFIG
|
||||
func (systemConfigService *SystemConfigService) GetSystemConfig() (conf config.Server, err error) {
|
||||
return global.GVA_CONFIG, nil
|
||||
}
|
||||
|
||||
// @description set system config,
|
||||
|
||||
@@ -15,20 +15,20 @@ import (
|
||||
//@function: Register
|
||||
//@description: 用户注册
|
||||
//@param: u model.SysUser
|
||||
//@return: err error, userInter model.SysUser
|
||||
//@return: userInter system.SysUser, err error
|
||||
|
||||
type UserService struct{}
|
||||
|
||||
func (userService *UserService) Register(u system.SysUser) (err error, userInter system.SysUser) {
|
||||
func (userService *UserService) Register(u system.SysUser) (userInter system.SysUser, err error) {
|
||||
var user system.SysUser
|
||||
if !errors.Is(global.GVA_DB.Where("username = ?", u.Username).First(&user).Error, gorm.ErrRecordNotFound) { // 判断用户名是否注册
|
||||
return errors.New("用户名已注册"), userInter
|
||||
return userInter, errors.New("用户名已注册")
|
||||
}
|
||||
// 否则 附加uuid 密码hash加密 注册
|
||||
u.Password = utils.BcryptHash(u.Password)
|
||||
u.UUID = uuid.NewV4()
|
||||
err = global.GVA_DB.Create(&u).Error
|
||||
return err, u
|
||||
return u, err
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
@@ -37,16 +37,16 @@ func (userService *UserService) Register(u system.SysUser) (err error, userInter
|
||||
//@param: u *model.SysUser
|
||||
//@return: err error, userInter *model.SysUser
|
||||
|
||||
func (userService *UserService) Login(u *system.SysUser) (err error, userInter *system.SysUser) {
|
||||
func (userService *UserService) Login(u *system.SysUser) (userInter *system.SysUser, err error) {
|
||||
if nil == global.GVA_DB {
|
||||
return fmt.Errorf("db not init"), nil
|
||||
return nil, fmt.Errorf("db not init")
|
||||
}
|
||||
|
||||
var user system.SysUser
|
||||
err = global.GVA_DB.Where("username = ?", u.Username).Preload("Authorities").Preload("Authority").First(&user).Error
|
||||
if err == nil {
|
||||
if ok := utils.BcryptCheck(u.Password, user.Password); !ok {
|
||||
return errors.New("密码错误"), nil
|
||||
return nil, errors.New("密码错误")
|
||||
}
|
||||
var am system.SysMenu
|
||||
ferr := global.GVA_DB.First(&am, "name = ? AND authority_id = ?", user.Authority.DefaultRouter, user.AuthorityId).Error
|
||||
@@ -55,27 +55,27 @@ func (userService *UserService) Login(u *system.SysUser) (err error, userInter *
|
||||
}
|
||||
}
|
||||
|
||||
return err, &user
|
||||
return &user, err
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
//@function: ChangePassword
|
||||
//@description: 修改用户密码
|
||||
//@param: u *model.SysUser, newPassword string
|
||||
//@return: err error, userInter *model.SysUser
|
||||
//@return: userInter *model.SysUser,err error
|
||||
|
||||
func (userService *UserService) ChangePassword(u *system.SysUser, newPassword string) (err error, userInter *system.SysUser) {
|
||||
func (userService *UserService) ChangePassword(u *system.SysUser, newPassword string) (userInter *system.SysUser, err error) {
|
||||
var user system.SysUser
|
||||
err = global.GVA_DB.Where("username = ?", u.Username).First(&user).Error
|
||||
if err != nil {
|
||||
return err, nil
|
||||
return nil, err
|
||||
}
|
||||
if ok := utils.BcryptCheck(u.Password, user.Password); !ok {
|
||||
return errors.New("原密码错误"), nil
|
||||
return nil, errors.New("原密码错误")
|
||||
}
|
||||
user.Password = utils.BcryptHash(newPassword)
|
||||
err = global.GVA_DB.Save(&user).Error
|
||||
return err, &user
|
||||
return &user, err
|
||||
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ func (userService *UserService) ChangePassword(u *system.SysUser, newPassword st
|
||||
//@param: info request.PageInfo
|
||||
//@return: err error, list interface{}, total int64
|
||||
|
||||
func (userService *UserService) GetUserInfoList(info request.PageInfo) (err error, list interface{}, total int64) {
|
||||
func (userService *UserService) GetUserInfoList(info request.PageInfo) (list interface{}, total int64, err error) {
|
||||
limit := info.PageSize
|
||||
offset := info.PageSize * (info.Page - 1)
|
||||
db := global.GVA_DB.Model(&system.SysUser{})
|
||||
@@ -95,7 +95,7 @@ func (userService *UserService) GetUserInfoList(info request.PageInfo) (err erro
|
||||
return
|
||||
}
|
||||
err = db.Limit(limit).Offset(offset).Preload("Authorities").Preload("Authority").Find(&userList).Error
|
||||
return err, userList, total
|
||||
return userList, total, err
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
@@ -176,18 +176,18 @@ func (userService *UserService) SetUserInfo(req system.SysUser) error {
|
||||
//@param: uuid uuid.UUID
|
||||
//@return: err error, user system.SysUser
|
||||
|
||||
func (userService *UserService) GetUserInfo(uuid uuid.UUID) (err error, user system.SysUser) {
|
||||
func (userService *UserService) GetUserInfo(uuid uuid.UUID) (user system.SysUser, err error) {
|
||||
var reqUser system.SysUser
|
||||
err = global.GVA_DB.Preload("Authorities").Preload("Authority").First(&reqUser, "uuid = ?", uuid).Error
|
||||
if err != nil {
|
||||
return err, reqUser
|
||||
return reqUser, err
|
||||
}
|
||||
var am system.SysMenu
|
||||
ferr := global.GVA_DB.First(&am, "name = ? AND authority_id = ?", reqUser.Authority.DefaultRouter, reqUser.AuthorityId).Error
|
||||
if errors.Is(ferr, gorm.ErrRecordNotFound) {
|
||||
reqUser.Authority.DefaultRouter = "404"
|
||||
}
|
||||
return err, reqUser
|
||||
return reqUser, err
|
||||
}
|
||||
|
||||
//@author: [SliverHorn](https://github.com/SliverHorn)
|
||||
@@ -196,10 +196,10 @@ func (userService *UserService) GetUserInfo(uuid uuid.UUID) (err error, user sys
|
||||
//@param: id int
|
||||
//@return: err error, user *model.SysUser
|
||||
|
||||
func (userService *UserService) FindUserById(id int) (err error, user *system.SysUser) {
|
||||
func (userService *UserService) FindUserById(id int) (user *system.SysUser, err error) {
|
||||
var u system.SysUser
|
||||
err = global.GVA_DB.Where("`id` = ?", id).First(&u).Error
|
||||
return err, &u
|
||||
return &u, err
|
||||
}
|
||||
|
||||
//@author: [SliverHorn](https://github.com/SliverHorn)
|
||||
@@ -208,12 +208,12 @@ func (userService *UserService) FindUserById(id int) (err error, user *system.Sy
|
||||
//@param: uuid string
|
||||
//@return: err error, user *model.SysUser
|
||||
|
||||
func (userService *UserService) FindUserByUuid(uuid string) (err error, user *system.SysUser) {
|
||||
func (userService *UserService) FindUserByUuid(uuid string) (user *system.SysUser, err error) {
|
||||
var u system.SysUser
|
||||
if err = global.GVA_DB.Where("`uuid` = ?", uuid).First(&u).Error; err != nil {
|
||||
return errors.New("用户不存在"), &u
|
||||
return &u, errors.New("用户不存在")
|
||||
}
|
||||
return nil, &u
|
||||
return &u, nil
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
|
||||
Reference in New Issue
Block a user