提交 e10b4223 编写于 作者: m0_50812349's avatar m0_50812349

service层注释规范化

上级 9576ae98
......@@ -15,7 +15,7 @@ import (
// @Security ApiKeyAuth
// @accept multipart/form-data
// @Produce application/json
// TODO @Param file formData file true "断点续传插件版示例"
// @Param file formData file true "断点续传插件版示例"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"切片创建成功"}"
// @Router /simpleUploader/upload [post]
func SimpleUploaderUpload(c *gin.Context) {
......
......@@ -18,7 +18,7 @@ import (
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// TODO @Param data body model.AutoCodeStruct true "创建自动代码"
// @Param data body model.AutoCodeStruct true "创建自动代码"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
// @Router /autoCode/createTemp [post]
func CreateTemp(c *gin.Context) {
......
......@@ -62,7 +62,6 @@ func DeleteSysOperationRecordByIds(c *gin.Context) {
_ = c.ShouldBindJSON(&IDS)
if err := service.DeleteSysOperationRecordByIds(IDS); err != nil {
global.GVA_LOG.Error("批量删除失败!", zap.Any("err", err))
response.FailWithMessage("批量删除失败", c)
} else {
response.OkWithMessage("批量删除成功", c)
......
......@@ -7,15 +7,11 @@ import (
"gorm.io/gorm"
)
// @title FindOrCreateFile
// @description Check your file if it does not exist, or return current slice of the file
// 上传文件时检测当前文件属性,如果没有文件则创建,有则返回文件的当前切片
// @auth (2020/04/05 20:22)
// @param fileMd5 string
// @param fileName string
// @param chunkTotal int
// @return err error
// @return file ExaFile
//@author: [piexlmax](https://github.com/piexlmax)
//@function: FindOrCreateFile
//@description: 上传文件时检测当前文件属性,如果没有文件则创建,有则返回文件的当前切片
//@param: fileMd5 string, fileName string, chunkTotal int
//@return: err error, file model.ExaFile
func FindOrCreateFile(fileMd5 string, fileName string, chunkTotal int) (err error, file model.ExaFile) {
var cfile model.ExaFile
......@@ -33,13 +29,11 @@ func FindOrCreateFile(fileMd5 string, fileName string, chunkTotal int) (err erro
return err, cfile
}
// @title CreateFileChunk
// @description create a chunk of the file, 创建文件切片记录
// @auth (2020/04/05 20:22)
// @param id unit
// @param fileChunkPath string
// @param fileChunkNumber int
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: CreateFileChunk
//@description: 创建文件切片记录
//@param: id uint, fileChunkPath string, fileChunkNumber int
//@return: error
func CreateFileChunk(id uint, fileChunkPath string, fileChunkNumber int) error {
var chunk model.ExaFileChunk
......@@ -50,13 +44,11 @@ func CreateFileChunk(id uint, fileChunkPath string, fileChunkNumber int) error {
return err
}
// @title DeleteFileChunk
// @description delete a chuck of the file, 删除文件切片记录
// @auth (2020/04/05 20:22)
// @param FileMd5 string
// @param FileName string
// @param FilePath string
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: DeleteFileChunk
//@description: 删除文件切片记录
//@param: fileMd5 string, fileName string, filePath string
//@return: error
func DeleteFileChunk(fileMd5 string, fileName string, filePath string) error {
var chunks []model.ExaFileChunk
......
......@@ -6,57 +6,55 @@ import (
"gin-vue-admin/model/request"
)
// @title CreateExaCustomer
// @description create a customer, 创建用户
// @param e model.ExaCustomer
// @auth (2020/04/05 20:22)
// @return err error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: CreateExaCustomer
//@description: 创建客户
//@param: e model.ExaCustomer
//@return: err error
func CreateExaCustomer(e model.ExaCustomer) (err error) {
err = global.GVA_DB.Create(&e).Error
return err
}
// @title DeleteFileChunk
// @description delete a customer, 删除用户
// @auth (2020/04/05 20:22)
// @param e model.ExaCustomer
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: DeleteFileChunk
//@description: 删除客户
//@param: e model.ExaCustomer
//@return: err error
func DeleteExaCustomer(e model.ExaCustomer) (err error) {
err = global.GVA_DB.Delete(e).Error
return err
}
// @title UpdateExaCustomer
// @description update a customer, 更新用户
// @param e *model.ExaCustomer
// @auth (2020/04/05 20:22)
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: UpdateExaCustomer
//@description: 更新客户
//@param: e *model.ExaCustomer
//@return: err error
func UpdateExaCustomer(e *model.ExaCustomer) (err error) {
err = global.GVA_DB.Save(e).Error
return err
}
// @title GetExaCustomer
// @description get the info of a costumer , 获取用户信息
// @auth (2020/04/05 20:22)
// @param id uint
// @return error
// @return customer ExaCustomer
//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetExaCustomer
//@description: 获取客户信息
//@param: id uint
//@return: err error, customer model.ExaCustomer
func GetExaCustomer(id uint) (err error, customer model.ExaCustomer) {
err = global.GVA_DB.Where("id = ?", id).First(&customer).Error
return
}
// @title GetCustomerInfoList
// @description get customer list by pagination, 分页获取用户列表
// @auth (2020/04/05 20:22)
// @param sysUserAuthorityID string
// @param info PageInfo
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetCustomerInfoList
//@description: 分页获取客户列表
//@param: sysUserAuthorityID string, info request.PageInfo
//@return: err error, list interface{}, total int64
func GetCustomerInfoList(sysUserAuthorityID string, info request.PageInfo) (err error, list interface{}, total int64) {
limit := info.PageSize
......
......@@ -10,22 +10,21 @@ import (
"strings"
)
// @title Upload
// @description 创建文件上传记录
// @param file model.ExaFileUploadAndDownload
// @auth (2020/04/05 20:22)
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: Upload
//@description: 创建文件上传记录
//@param: file model.ExaFileUploadAndDownload
//@return: error
func Upload(file model.ExaFileUploadAndDownload) error {
err := global.GVA_DB.Create(&file).Error
return err
return global.GVA_DB.Create(&file).Error
}
// @title FindFile
// @description 删除文件切片记录
// @auth (2020/04/05 20:22)
// @param id uint
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: FindFile
//@description: 删除文件切片记录
//@param: id uint
//@return: error, model.ExaFileUploadAndDownload
func FindFile(id uint) (error, model.ExaFileUploadAndDownload) {
var file model.ExaFileUploadAndDownload
......@@ -33,11 +32,11 @@ func FindFile(id uint) (error, model.ExaFileUploadAndDownload) {
return err, file
}
// @title DeleteFile
// @description 删除文件记录
// @auth (2020/04/05 20:22)
// @param file model.ExaFileUploadAndDownload
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: DeleteFile
//@description: 删除文件记录
//@param: file model.ExaFileUploadAndDownload
//@return: err error
func DeleteFile(file model.ExaFileUploadAndDownload) (err error) {
var fileFromDb model.ExaFileUploadAndDownload
......@@ -50,13 +49,11 @@ func DeleteFile(file model.ExaFileUploadAndDownload) (err error) {
return err
}
// @title GetFileRecordInfoList
// @description 分页获取数据
// @auth (2020/04/05 20:22)
// @param info PageInfo
// @return err error
// @return list error
// @return total error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetFileRecordInfoList
//@description: 分页获取数据
//@param: info request.PageInfo
//@return: err error, list interface{}, total int64
func GetFileRecordInfoList(info request.PageInfo) (err error, list interface{}, total int64) {
limit := info.PageSize
......@@ -68,13 +65,11 @@ func GetFileRecordInfoList(info request.PageInfo) (err error, list interface{},
return err, fileLists, total
}
// @title UploadFile
// @description 根据配置文件判断是文件上传到本地或者七牛云
// @auth (2020/04/05 20:22)
// @param header *multipart.FileHeader
// @param noSave string
// @return err error
// @return file file model.ExaFileUploadAndDownload
//@author: [piexlmax](https://github.com/piexlmax)
//@function: UploadFile
//@description: 根据配置文件判断是文件上传到本地或者七牛云
//@param: header *multipart.FileHeader, noSave string
//@return: err error, file model.ExaFileUploadAndDownload
func UploadFile(header *multipart.FileHeader, noSave string) (err error, file model.ExaFileUploadAndDownload) {
oss := upload.NewOss()
......
......@@ -11,19 +11,34 @@ import (
"strconv"
)
// 保存文件切片路径
//@author: [piexlmax](https://github.com/piexlmax)
//@function: SaveChunk
//@description: 保存文件切片路径
//@param: uploader model.ExaSimpleUploader
//@return: err error
func SaveChunk(uploader model.ExaSimpleUploader) (err error) {
return global.GVA_DB.Create(uploader).Error
}
// 检查文件是否已经上传过
//@author: [piexlmax](https://github.com/piexlmax)
//@function: CheckFileMd5
//@description: 检查文件是否已经上传过
//@param: md5 string
//@return: err error, uploads []model.ExaSimpleUploader, isDone bool
func CheckFileMd5(md5 string) (err error, uploads []model.ExaSimpleUploader, isDone bool) {
err = global.GVA_DB.Find(&uploads, "identifier = ? AND is_done = ?", md5, false).Error
isDone = errors.Is(global.GVA_DB.First(&model.ExaSimpleUploader{}, "identifier = ? AND is_done = ?", md5, true).Error, gorm.ErrRecordNotFound)
return err, uploads, !isDone
}
// 合并文件
//@author: [piexlmax](https://github.com/piexlmax)
//@function: MergeFileMd5
//@description: 合并文件
//@param: md5 string, fileName string
//@return: err error
func MergeFileMd5(md5 string, fileName string) (err error) {
finishDir := "./finish/"
dir := "./chunk/" + md5
......
......@@ -8,47 +8,44 @@ import (
"time"
)
// @title JsonInBlacklist
// @description create jwt blacklist
// @param jwtList model.JwtBlacklist
// @auth (2020/04/05 20:22)
// @return err error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: JsonInBlacklist
//@description: 拉黑jwt
//@param: jwtList model.JwtBlacklist
//@return: err error
func JsonInBlacklist(jwtList model.JwtBlacklist) (err error) {
err = global.GVA_DB.Create(&jwtList).Error
return
}
// @title IsBlacklist
// @description check if the Jwt is in the blacklist or not, 判断JWT是否在黑名单内部
// @auth (2020/04/05 20:22)
// @param jwt string
// @param jwtList model.JwtBlacklist
// @return err error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: IsBlacklist
//@description: 判断JWT是否在黑名单内部
//@param: jwt string
//@return: bool
func IsBlacklist(jwt string) bool {
isNotFound := errors.Is(global.GVA_DB.Where("jwt = ?", jwt).First(&model.JwtBlacklist{}).Error, gorm.ErrRecordNotFound)
return !isNotFound
}
// @title GetRedisJWT
// @description Get user info in redis
// @auth (2020/04/05 20:22)
// @param userName string
// @return err error
// @return redisJWT string
//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetRedisJWT
//@description: 从redis取jwt
//@param: userName string
//@return: err error, redisJWT string
func GetRedisJWT(userName string) (err error, redisJWT string) {
redisJWT, err = global.GVA_REDIS.Get(userName).Result()
return err, redisJWT
}
// @title SetRedisJWT
// @description set jwt into the Redis
// @auth (2020/04/05 20:22)
// @param jwtList model.JwtBlacklist
// @param userName string
// @return err error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: SetRedisJWT
//@description: jwt存入redis并设置过期时间
//@param: userName string
//@return: err error, redisJWT string
func SetRedisJWT(jwt string, userName string) (err error) {
// 此处过期时间等于jwt过期时间
......
......@@ -8,25 +8,24 @@ import (
"gorm.io/gorm"
)
// @title CreateApi
// @description create base apis, 新增基础api
// @auth (2020/04/05 20:22)
// @param api model.SysApi
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: CreateApi
//@description: 新增基础api
//@param: api model.SysApi
//@return: err error
func CreateApi(api model.SysApi) (err error) {
if !errors.Is(global.GVA_DB.Where("path = ? AND method = ?", api.Path, api.Method).First(&model.SysApi{}).Error, gorm.ErrRecordNotFound) {
return errors.New("存在相同api")
}
return global.GVA_DB.Create(&api).Error
}
// @title DeleteApi
// @description delete a base api, 删除基础api
// @param api model.SysApi
// @auth (2020/04/05 20:22)
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: DeleteApi
//@description: 删除基础api
//@param: api model.SysApi
//@return: err error
func DeleteApi(api model.SysApi) (err error) {
err = global.GVA_DB.Delete(api).Error
......@@ -34,11 +33,11 @@ func DeleteApi(api model.SysApi) (err error) {
return err
}
// @title AutoCreateApi
// @description delete a base api by path and method, 删除基础api
// @param api model.SysApi
// @auth (2020/04/05 20:22)
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: CreateApi
//@description: 自动创建api数据,
//@param: api model.SysApi
//@return: err error
func AutoCreateApi(api model.SysApi) (err error) {
err = global.GVA_DB.Transaction(func(tx *gorm.DB) error {
......@@ -56,16 +55,11 @@ func AutoCreateApi(api model.SysApi) (err error) {
return err
}
// @title GetInfoList
// @description get apis by pagination, 分页获取数据
// @auth (2020/04/05 20:22)
// @param api model.SysApi
// @param info request.PageInfo
// @param order string
// @param desc bool
// @return err error
// @return list interface{}
// @return total int
//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetAPIInfoList
//@description: 分页获取数据,
//@param: api model.SysApi, info request.PageInfo, order string, desc bool
//@return: err error
func GetAPIInfoList(api model.SysApi, info request.PageInfo, order string, desc bool) (err error, list interface{}, total int64) {
limit := info.PageSize
......@@ -110,40 +104,36 @@ func GetAPIInfoList(api model.SysApi, info request.PageInfo, order string, desc
return err, apiList, total
}
// @title GetAllApis
// @description get all apis, 获取所有的api
// @auth (2020/04/05 20:22)
// @return err error
// @return apis []SysApi
//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetAllApis
//@description: 获取所有的api
//@return: err error, apis []model.SysApi
func GetAllApis() (err error, apis []model.SysApi) {
err = global.GVA_DB.Find(&apis).Error
return
}
// @title GetApiById
// @description 根据id获取api
// @auth (2020/04/05 20:22)
// @param api model.SysApi
// @param id float64
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetApiById
//@description: 根据id获取api
//@param: id float64
//@return: err error, api model.SysApi
func GetApiById(id float64) (err error, api model.SysApi) {
err = global.GVA_DB.Where("id = ?", id).First(&api).Error
return
}
// @title UpdateApi
// @description update a base api, update api
// @auth (2020/04/05 20:22)
// @param api model.SysApi
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: UpdateApi
//@description: 根据id更新api
//@param: api model.SysApi
//@return: err error
func UpdateApi(api model.SysApi) (err error) {
var oldA model.SysApi
err = global.GVA_DB.Where("id = ?", api.ID).First(&oldA).Error
if oldA.Path != api.Path || oldA.Method != api.Method {
if !errors.Is(global.GVA_DB.Where("path = ? AND method = ?", api.Path, api.Method).First(&model.SysApi{}).Error, gorm.ErrRecordNotFound) {
return errors.New("存在相同api路径")
......
......@@ -10,12 +10,11 @@ import (
"strconv"
)
// @title CreateAuthority
// @description 创建一个角色
// @auth (2020/04/05 20:22)
// @param auth model.SysAuthority
// @return error
// @return authority model.SysAuthority
//@author: [piexlmax](https://github.com/piexlmax)
//@function: CreateAuthority
//@description: 创建一个角色
//@param: auth model.SysAuthority
//@return: err error, authority model.SysAuthority
func CreateAuthority(auth model.SysAuthority) (err error, authority model.SysAuthority) {
var authorityBox model.SysAuthority
......@@ -26,12 +25,11 @@ func CreateAuthority(auth model.SysAuthority) (err error, authority model.SysAut
return err, auth
}
// @title CopyAuthority
// @description 复制一个角色
// @auth (2020/04/05 20:22)
// @param copyInfo response.SysAuthorityCopyResponse
// @return error
// @return authority model.SysAuthority
//@author: [piexlmax](https://github.com/piexlmax)
//@function: CopyAuthority
//@description: 复制一个角色
//@param: copyInfo response.SysAuthorityCopyResponse
//@return: err error, authority model.SysAuthority
func CopyAuthority(copyInfo response.SysAuthorityCopyResponse) (err error, authority model.SysAuthority) {
var authorityBox model.SysAuthority
......@@ -57,24 +55,22 @@ func CopyAuthority(copyInfo response.SysAuthorityCopyResponse) (err error, autho
return err, copyInfo.Authority
}
// @title UpdateAuthority
// @description 更改一个角色
// @auth (2020/04/05 20:22)
// @param auth model.SysAuthority
// @return error
// @return authority model.SysAuthority
//@author: [piexlmax](https://github.com/piexlmax)
//@function: UpdateAuthority
//@description: 更改一个角色
//@param: auth model.SysAuthority
//@return:err error, authority model.SysAuthority
func UpdateAuthority(auth model.SysAuthority) (err error, authority model.SysAuthority) {
err = global.GVA_DB.Where("authority_id = ?", auth.AuthorityId).First(&model.SysAuthority{}).Updates(&auth).Error
return err, auth
}
// @title DeleteAuthority
// @description 删除角色
// @auth (2020/04/05 20:22)
// @param auth model.SysAuthority
// @return error
// 删除角色
//@author: [piexlmax](https://github.com/piexlmax)
//@function: DeleteAuthority
//@description: 删除角色
//@param: auth *model.SysAuthority
//@return: err error
func DeleteAuthority(auth *model.SysAuthority) (err error) {
if !errors.Is(global.GVA_DB.Where("authority_id = ?", auth.AuthorityId).First(&model.SysUser{}).Error, gorm.ErrRecordNotFound) {
......@@ -95,12 +91,11 @@ func DeleteAuthority(auth *model.SysAuthority) (err error) {
return err
}
// @title GetInfoList
// @description 删除文件切片记录
// @auth (2020/04/05 20:22)
// @param info request.PaveInfo
// @return error
// 分页获取数据
//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetAuthorityInfoList
//@description: 分页获取数据
//@param: info request.PageInfo
//@return: err error, list interface{}, total int64
func GetAuthorityInfoList(info request.PageInfo) (err error, list interface{}, total int64) {
limit := info.PageSize
......@@ -116,23 +111,22 @@ func GetAuthorityInfoList(info request.PageInfo) (err error, list interface{}, t
return err, authority, total
}
// @title GetAuthorityInfo
// @description 获取所有角色信息
// @auth (2020/04/05 20:22)
// @param auth model.SysAuthority
// @return error
// @param authority model.SysAuthority
//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetAuthorityInfo
//@description: 获取所有角色信息
//@param: auth model.SysAuthority
//@return: err error, sa model.SysAuthority
func GetAuthorityInfo(auth model.SysAuthority) (err error, sa model.SysAuthority) {
err = global.GVA_DB.Preload("DataAuthorityId").Where("authority_id = ?", auth.AuthorityId).First(&sa).Error
return err, sa
}
// @title SetDataAuthority
// @description 设置角色资源权限
// @auth (2020/04/05 20:22)
// @param auth model.SysAuthority
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: SetDataAuthority
//@description: 设置角色资源权限
//@param: auth model.SysAuthority
//@return:error
func SetDataAuthority(auth model.SysAuthority) error {
var s model.SysAuthority
......@@ -141,11 +135,11 @@ func SetDataAuthority(auth model.SysAuthority) error {
return err
}
// @title SetMenuAuthority
// @description 菜单与角色绑定
// @auth (2020/04/05 20:22)
// @param auth *model.SysAuthority
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: SetMenuAuthority
//@description: 菜单与角色绑定
//@param: auth *model.SysAuthority
//@return: error
func SetMenuAuthority(auth *model.SysAuthority) error {
var s model.SysAuthority
......@@ -154,11 +148,11 @@ func SetMenuAuthority(auth *model.SysAuthority) error {
return err
}
// @title findChildrenAuthority
// @description 查询子角色
// @auth (2020/04/05 20:22)
// @param auth *model.SysAuthority
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: findChildrenAuthority
//@description: 查询子角色
//@param: authority *model.SysAuthority
//@return: err error
func findChildrenAuthority(authority *model.SysAuthority) (err error) {
err = global.GVA_DB.Preload("DataAuthorityId").Where("parent_id = ?", authority.AuthorityId).Find(&authority.Children).Error
......
......@@ -21,11 +21,11 @@ type tplData struct {
autoMoveFilePath string
}
// @title CreateTemp
// @description 函数的详细描述
// @auth (2020/04/05 20:22)
// @param autoCode model.AutoCodeStruct
// @return err error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: CreateTemp
//@description: 创建代码
//@param: model.AutoCodeStruct
//@return: error
func CreateTemp(autoCode model.AutoCodeStruct) (err error) {
basePath := "resource/template"
......@@ -116,7 +116,12 @@ func CreateTemp(autoCode model.AutoCodeStruct) (err error) {
return nil
}
// GetAllTplFile 用来获取 pathName 文件夹下所有 tpl 文件
//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetAllTplFile
//@description: 获取 pathName 文件夹下所有 tpl 文件
//@param: pathName string, fileList []string
//@return: []string, error
func GetAllTplFile(pathName string, fileList []string) ([]string, error) {
files, err := ioutil.ReadDir(pathName)
for _, fi := range files {
......@@ -134,52 +139,48 @@ func GetAllTplFile(pathName string, fileList []string) ([]string, error) {
return fileList, err
}
//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetTables
//@description: 获取数据库的所有表名
//@param: pathName string
//@param: fileList []string
//@return: []string, error
func GetTables(dbName string) (err error, TableNames []request.TableReq) {
err = global.GVA_DB.Raw("select table_name as table_name from information_schema.tables where table_schema = ?", dbName).Scan(&TableNames).Error
return err, TableNames
}
//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetDB
//@description: 获取数据库的所有数据库名
//@param: pathName string
//@param: fileList []string
//@return: []string, error
func GetDB() (err error, DBNames []request.DBReq) {
err = global.GVA_DB.Raw("SELECT SCHEMA_NAME AS `database` FROM INFORMATION_SCHEMA.SCHEMATA;").Scan(&DBNames).Error
return err, DBNames
}
//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetDB
//@description: 获取指定数据库和指定数据表的所有字段名,类型值等
//@param: pathName string
//@param: fileList []string
//@return: []string, error
func GetColumn(tableName string, dbName string) (err error, Columns []request.ColumnReq) {
err = global.GVA_DB.Raw("SELECT COLUMN_NAME column_name,DATA_TYPE data_type,CASE DATA_TYPE WHEN 'longtext' THEN c.CHARACTER_MAXIMUM_LENGTH WHEN 'varchar' THEN c.CHARACTER_MAXIMUM_LENGTH WHEN 'double' THEN CONCAT_WS( ',', c.NUMERIC_PRECISION, c.NUMERIC_SCALE ) WHEN 'decimal' THEN CONCAT_WS( ',', c.NUMERIC_PRECISION, c.NUMERIC_SCALE ) WHEN 'int' THEN c.NUMERIC_PRECISION WHEN 'bigint' THEN c.NUMERIC_PRECISION ELSE '' END AS data_type_long,COLUMN_COMMENT column_comment FROM INFORMATION_SCHEMA.COLUMNS c WHERE table_name = ? AND table_schema = ?", tableName, dbName).Scan(&Columns).Error
return err, Columns
}
//func addAutoMoveFile(data *tplData) {
// if strings.Contains(data.autoCodePath, "server") {
// if strings.Contains(data.autoCodePath, "router") {
// apiList := strings.Split(data.autoCodePath, "/")
// data.autoMoveFilePath = filepath.Join(apiList[len(apiList)-2], apiList[len(apiList)-1])
// } else if strings.Contains(data.autoCodePath, "api") {
// apiList := strings.Split(data.autoCodePath, "/")
// data.autoMoveFilePath = filepath.Join(apiList[len(apiList)-2], "v1", apiList[len(apiList)-1])
// } else if strings.Contains(data.autoCodePath, "service") {
// serviceList := strings.Split(data.autoCodePath, "/")
// data.autoMoveFilePath = filepath.Join(serviceList[len(serviceList)-2], serviceList[len(serviceList)-1])
// } else if strings.Contains(data.autoCodePath, "model") {
// modelList := strings.Split(data.autoCodePath, "/")
// data.autoMoveFilePath = filepath.Join(modelList[len(modelList)-2], modelList[len(modelList)-1])
// } else if strings.Contains(data.autoCodePath, "request") {
// requestList := strings.Split(data.autoCodePath, "/")
// data.autoMoveFilePath = filepath.Join("model", requestList[len(requestList)-2], requestList[len(requestList)-1])
// }
// } else if strings.Contains(data.autoCodePath, "web") {
// if strings.Contains(data.autoCodePath, "js") {
// jsList := strings.Split(data.autoCodePath, "/")
// data.autoMoveFilePath = filepath.Join("../", "web", "src", jsList[len(jsList)-2], jsList[len(jsList)-1])
// } else if strings.Contains(data.autoCodePath, "form") {
// formList := strings.Split(data.autoCodePath, "/")
// data.autoMoveFilePath = filepath.Join("../", "web", "src", "view", formList[len(formList)-3], strings.Split(formList[len(formList)-1], ".")[0]+"From.vue")
// } else if strings.Contains(data.autoCodePath, "table") {
// vueList := strings.Split(data.autoCodePath, "/")
// data.autoMoveFilePath = filepath.Join("../", "web", "src", "view", vueList[len(vueList)-3], vueList[len(vueList)-1])
// }
// }
//}
//@author: [SliverHorn](https://github.com/SliverHorn)
//@author: [songzhibin97](https://github.com/songzhibin97)
//@function: addAutoMoveFile
//@description: 生成对应的迁移文件路径
//@param: *tplData
//@return: null
func addAutoMoveFile(data *tplData) {
dir := filepath.Base(filepath.Dir(data.autoCodePath))
......
......@@ -7,11 +7,11 @@ import (
"gorm.io/gorm"
)
// @title DeleteBaseMenu
// @description 删除基础路由
// @auth (2020/04/05 20:22)
// @param id float64
// @return err error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: DeleteBaseMenu
//@description: 删除基础路由
//@param: id float64
//@return: err error
func DeleteBaseMenu(id float64) (err error) {
err = global.GVA_DB.Preload("Parameters").Where("parent_id = ?", id).First(&model.SysBaseMenu{}).Error
......@@ -30,11 +30,11 @@ func DeleteBaseMenu(id float64) (err error) {
return err
}
// @title UpdateBaseMenu
// @description 更新路由
// @auth (2020/04/05 20:22)
// @param menu model.SysBaseMenu
// @return err errorgetMenu
//@author: [piexlmax](https://github.com/piexlmax)
//@function: UpdateBaseMenu
//@description: 更新路由
//@param: menu model.SysBaseMenu
//@return:err error
func UpdateBaseMenu(menu model.SysBaseMenu) (err error) {
var oldMenu model.SysBaseMenu
......@@ -62,11 +62,11 @@ func UpdateBaseMenu(menu model.SysBaseMenu) (err error) {
return err
}
// @title GetBaseMenuById
// @description get current menus, 返回当前选中menu
// @auth (2020/04/05 20:22)
// @param id float64
// @return err error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetBaseMenuById
//@description: 返回当前选中menu
//@param: id float64
//@return: err error, menu model.SysBaseMenu
func GetBaseMenuById(id float64) (err error, menu model.SysBaseMenu) {
err = global.GVA_DB.Preload("Parameters").Where("id = ?", id).First(&menu).Error
......
......@@ -12,12 +12,11 @@ import (
"strings"
)
// @title UpdateCasbin
// @description update casbin authority, 更新casbin权限
// @auth (2020/04/05 20:22)
// @param authorityId string
// @param casbinInfos []CasbinInfo
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: UpdateCasbin
//@description: 更新casbin权限
//@param: authorityId string, casbinInfos []request.CasbinInfo
//@return: error
func UpdateCasbin(authorityId string, casbinInfos []request.CasbinInfo) error {
ClearCasbin(0, authorityId)
......@@ -39,14 +38,11 @@ func UpdateCasbin(authorityId string, casbinInfos []request.CasbinInfo) error {
return nil
}
// @title UpdateCasbinApi
// @description update casbin apis, API更新随动
// @auth (2020/04/05 20:22)
// @param oldPath string
// @param newPath string
// @param oldMethod string
// @param newMethod string
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: UpdateCasbinApi
//@description: API更新随动
//@param: oldPath string, newPath string, oldMethod string, newMethod string
//@return: error
func UpdateCasbinApi(oldPath string, newPath string, oldMethod string, newMethod string) error {
err := global.GVA_DB.Table("casbin_rule").Model(&model.CasbinModel{}).Where("v1 = ? AND v2 = ?", oldPath, oldMethod).Updates(map[string]interface{}{
......@@ -56,11 +52,12 @@ func UpdateCasbinApi(oldPath string, newPath string, oldMethod string, newMethod
return err
}
// @title GetPolicyPathByAuthorityId
// @description get policy path by authorityId, 获取权限列表
// @auth (2020/04/05 20:22)
// @param authorityId string
// @return []string
//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetPolicyPathByAuthorityId
//@description: 获取权限列表
//@param: authorityId string
//@return: pathMaps []request.CasbinInfo
func GetPolicyPathByAuthorityId(authorityId string) (pathMaps []request.CasbinInfo) {
e := Casbin()
......@@ -74,12 +71,11 @@ func GetPolicyPathByAuthorityId(authorityId string) (pathMaps []request.CasbinIn
return pathMaps
}
// @title ClearCasbin
// @description 清除匹配的权限
// @auth (2020/04/05 20:22)
// @param v int
// @param p string
// @return bool
//@author: [piexlmax](https://github.com/piexlmax)
//@function: ClearCasbin
//@description: 清除匹配的权限
//@param: v int, p ...string
//@return: bool
func ClearCasbin(v int, p ...string) bool {
e := Casbin()
......@@ -88,9 +84,10 @@ func ClearCasbin(v int, p ...string) bool {
}
// @title Casbin
// @description store to DB, 持久化到数据库 引入自定义规则
// @auth (2020/04/05 20:22)
//@author: [piexlmax](https://github.com/piexlmax)
//@function: Casbin
//@description: 持久化到数据库 引入自定义规则
//@return: *casbin.Enforcer
func Casbin() *casbin.Enforcer {
admin := global.GVA_CONFIG.Mysql
......@@ -101,12 +98,11 @@ func Casbin() *casbin.Enforcer {
return e
}
// @title ParamsMatch
// @description customized rule, 自定义规则函数
// @auth (2020/04/05 20:22)
// @param fullNameKey1 string
// @param key2 string
// @return bool
//@author: [piexlmax](https://github.com/piexlmax)
//@function: ParamsMatch
//@description: 自定义规则函数
//@param: fullNameKey1 string, key2 string
//@return: bool
func ParamsMatch(fullNameKey1 string, key2 string) bool {
key1 := strings.Split(fullNameKey1, "?")[0]
......@@ -114,12 +110,11 @@ func ParamsMatch(fullNameKey1 string, key2 string) bool {
return util.KeyMatch2(key1, key2)
}
// @title ParamsMatchFunc
// @description customized function, 自定义规则函数
// @auth (2020/04/05 20:22)
// @param args ...interface{}
// @return interface{}
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: ParamsMatchFunc
//@description: 自定义规则函数
//@param: args ...interface{}
//@return: interface{}, error
func ParamsMatchFunc(args ...interface{}) (interface{}, error) {
name1 := args[0].(string)
......
......@@ -8,11 +8,11 @@ import (
"gorm.io/gorm"
)
// @title CreateSysDictionary
// @description create a SysDictionary
// @param sysDictionary model.SysDictionary
// @auth (2020/04/05 20:22)
// @return err error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: DeleteSysDictionary
//@description: 创建字典数据
//@param: sysDictionary model.SysDictionary
//@return: err error
func CreateSysDictionary(sysDictionary model.SysDictionary) (err error) {
if (!errors.Is(global.GVA_DB.First(&model.SysDictionary{}, "type = ?", sysDictionary.Type).Error, gorm.ErrRecordNotFound)) {
......@@ -22,22 +22,22 @@ func CreateSysDictionary(sysDictionary model.SysDictionary) (err error) {
return err
}
// @title DeleteSysDictionary
// @description delete a SysDictionary
// @auth (2020/04/05 20:22)
// @param sysDictionary model.SysDictionary
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: DeleteSysDictionary
//@description: 删除字典数据
//@param: sysDictionary model.SysDictionary
//@return: err error
func DeleteSysDictionary(sysDictionary model.SysDictionary) (err error) {
err = global.GVA_DB.Delete(sysDictionary).Delete(&sysDictionary.SysDictionaryDetails).Error
return err
}
// @title UpdateSysDictionary
// @description update a SysDictionary
// @param sysDictionary *model.SysDictionary
// @auth (2020/04/05 20:22)
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: UpdateSysDictionary
//@description: 更新字典数据
//@param: sysDictionary *model.SysDictionary
//@return: err error
func UpdateSysDictionary(sysDictionary *model.SysDictionary) (err error) {
var dict model.SysDictionary
......@@ -60,23 +60,23 @@ func UpdateSysDictionary(sysDictionary *model.SysDictionary) (err error) {
return err
}
// @title GetSysDictionary
// @description get the info of a SysDictionary
// @auth (2020/04/05 20:22)
// @param id uint
// @return error
// @return SysDictionary SysDictionary
//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetSysDictionary
//@description: 根据id或者type获取字典单条数据
//@param: Type string, Id uint
//@return: err error, sysDictionary model.SysDictionary
func GetSysDictionary(Type string, Id uint) (err error, sysDictionary model.SysDictionary) {
err = global.GVA_DB.Where("type = ? OR id = ?", Type, Id).Preload("SysDictionaryDetails").First(&sysDictionary).Error
return
}
// @title GetSysDictionaryInfoList
// @description get SysDictionary list by pagination, 分页获取用户列表
// @auth (2020/04/05 20:22)
// @param info PageInfo
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@author: [SliverHorn](https://github.com/SliverHorn)
//@function: GetSysDictionaryInfoList
//@description: 分页获取字典列表
//@param: info request.SysDictionarySearch
//@return: err error, list interface{}, total int64
func GetSysDictionaryInfoList(info request.SysDictionarySearch) (err error, list interface{}, total int64) {
limit := info.PageSize
......
......@@ -6,56 +6,55 @@ import (
"gin-vue-admin/model/request"
)
// @title CreateSysDictionaryDetail
// @description create a SysDictionaryDetail
// @param sysDictionaryDetail model.SysDictionaryDetail
// @auth (2020/04/05 20:22)
// @return err error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: CreateSysDictionaryDetail
//@description: 创建字典详情数据
//@param: sysDictionaryDetail model.SysDictionaryDetail
//@return: err error
func CreateSysDictionaryDetail(sysDictionaryDetail model.SysDictionaryDetail) (err error) {
err = global.GVA_DB.Create(&sysDictionaryDetail).Error
return err
}
// @title DeleteSysDictionaryDetail
// @description delete a SysDictionaryDetail
// @auth (2020/04/05 20:22)
// @param sysDictionaryDetail model.SysDictionaryDetail
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: DeleteSysDictionaryDetail
//@description: 删除字典详情数据
//@param: sysDictionaryDetail model.SysDictionaryDetail
//@return: err error
func DeleteSysDictionaryDetail(sysDictionaryDetail model.SysDictionaryDetail) (err error) {
err = global.GVA_DB.Delete(sysDictionaryDetail).Error
return err
}
// @title UpdateSysDictionaryDetail
// @description update a SysDictionaryDetail
// @param sysDictionaryDetail *model.SysDictionaryDetail
// @auth (2020/04/05 20:22)
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: UpdateSysDictionaryDetail
//@description: 更新字典详情数据
//@param: sysDictionaryDetail *model.SysDictionaryDetail
//@return: err error
func UpdateSysDictionaryDetail(sysDictionaryDetail *model.SysDictionaryDetail) (err error) {
err = global.GVA_DB.Save(sysDictionaryDetail).Error
return err
}
// @title GetSysDictionaryDetail
// @description get the info of a SysDictionaryDetail
// @auth (2020/04/05 20:22)
// @param id uint
// @return error
// @return SysDictionaryDetail SysDictionaryDetail
//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetSysDictionaryDetail
//@description: 根据id获取字典详情单条数据
//@param: id uint
//@return: err error, sysDictionaryDetail model.SysDictionaryDetail
func GetSysDictionaryDetail(id uint) (err error, sysDictionaryDetail model.SysDictionaryDetail) {
err = global.GVA_DB.Where("id = ?", id).First(&sysDictionaryDetail).Error
return
}
// @title GetSysDictionaryDetailInfoList
// @description get SysDictionaryDetail list by pagination, 分页获取用户列表
// @auth (2020/04/05 20:22)
// @param info PageInfo
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetSysDictionaryDetailInfoList
//@description: 分页获取字典详情列表
//@param: info request.SysDictionaryDetailSearch
//@return: err error
func GetSysDictionaryDetailInfoList(info request.SysDictionaryDetailSearch) (err error, list interface{}, total int64) {
limit := info.PageSize
......
......@@ -4,10 +4,10 @@ import (
"gin-vue-admin/utils"
)
// @title EmailTest
// @description 发送邮件测试
// @auth (2020/09/08 13:58
// @return err error
//@author: [maplepie](https://github.com/maplepie)
//@function: EmailTest
//@description: 发送邮件测试
//@return: err error
func EmailTest() (err error) {
subject := "test"
......
......@@ -9,11 +9,11 @@ import (
"strconv"
)
// @title getMenuTreeMap
// @description 获取路由总树map
// @auth qm (2020/05/06 10:26)
// @return err error
// @return menusMsp map{string}[]SysBaseMenu
//@author: [piexlmax](https://github.com/piexlmax)
//@function: getMenuTreeMap
//@description: 获取路由总树map
//@param: authorityId string
//@return: err error, treeMap map[string][]model.SysMenu
func getMenuTreeMap(authorityId string) (err error, treeMap map[string][]model.SysMenu) {
var allMenus []model.SysMenu
......@@ -25,12 +25,11 @@ func getMenuTreeMap(authorityId string) (err error, treeMap map[string][]model.S
return err, treeMap
}
// @title GetMenuTree
// @description 获取动态菜单树
// @auth (2020/04/05 20:22)
// @param authorityId string
// @return err error
// @return menus []model.SysMenu
//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetMenuTree
//@description: 获取动态菜单树
//@param: authorityId string
//@return: err error, menus []model.SysMenu
func GetMenuTree(authorityId string) (err error, menus []model.SysMenu) {
err, menuTree := getMenuTreeMap(authorityId)
......@@ -41,12 +40,11 @@ func GetMenuTree(authorityId string) (err error, menus []model.SysMenu) {
return err, menus
}
// @title getChildrenList
// @description 获取子菜单
// @auth (2020/04/05 20:22)
// @param menu *model.SysMenu
// @param sql string
// @return err error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: getChildrenList
//@description: 获取子菜单
//@param: menu *model.SysMenu, treeMap map[string][]model.SysMenu
//@return: err error
func getChildrenList(menu *model.SysMenu, treeMap map[string][]model.SysMenu) (err error) {
menu.Children = treeMap[menu.MenuId]
......@@ -56,13 +54,10 @@ func getChildrenList(menu *model.SysMenu, treeMap map[string][]model.SysMenu) (e
return err
}
// @title GetInfoList
// @description 获取路由分页
// @auth (2020/04/05 20:22)
// @param info request.PageInfo
// @return err error
// @return list interface{}
// @return total int
//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetInfoList
//@description: 获取路由分页
//@return: err error, list interface{}, total int64
func GetInfoList() (err error, list interface{}, total int64) {
var menuList []model.SysBaseMenu
......@@ -74,11 +69,11 @@ func GetInfoList() (err error, list interface{}, total int64) {
return err, menuList, total
}
// @title getBaseChildrenList
// @description get children of menu, 获取菜单的子菜单
// @auth (2020/04/05 20:22)
// @param menu *model.SysBaseMenu
// @return err error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: getBaseChildrenList
//@description: 获取菜单的子菜单
//@param: menu *model.SysBaseMenu, treeMap map[string][]model.SysBaseMenu
//@return: err error
func getBaseChildrenList(menu *model.SysBaseMenu, treeMap map[string][]model.SysBaseMenu) (err error) {
menu.Children = treeMap[strconv.Itoa(int(menu.ID))]
......@@ -88,12 +83,11 @@ func getBaseChildrenList(menu *model.SysBaseMenu, treeMap map[string][]model.Sys
return err
}
// @title AddBaseMenu
// @description 函数的详细描述
// @auth (2020/04/05 20:22)
// @param menu *model.SysBaseMenu
// @return err error
// 增加基础路由
//@author: [piexlmax](https://github.com/piexlmax)
//@function: AddBaseMenu
//@description: 添加基础路由
//@param: menu model.SysBaseMenu
//@return: err error
func AddBaseMenu(menu model.SysBaseMenu) (err error) {
if !errors.Is(global.GVA_DB.Where("name = ?", menu.Name).First(&model.SysBaseMenu{}).Error, gorm.ErrRecordNotFound) {
......@@ -103,11 +97,10 @@ func AddBaseMenu(menu model.SysBaseMenu) (err error) {
return err
}
// @title getBaseMenuTreeMap
// @description 获取路由总树map
// @auth qm (2020/05/06 10:26)
// @return err error
// @return menusMsp map{string}[]SysBaseMenu
//@author: [piexlmax](https://github.com/piexlmax)
//@function: getBaseMenuTreeMap
//@description: 获取路由总树map
//@return: err error, treeMap map[string][]model.SysBaseMenu
func getBaseMenuTreeMap() (err error, treeMap map[string][]model.SysBaseMenu) {
var allMenus []model.SysBaseMenu
......@@ -119,11 +112,10 @@ func getBaseMenuTreeMap() (err error, treeMap map[string][]model.SysBaseMenu) {
return err, treeMap
}
// @title GetBaseMenuTree
// @description 获取基础路由树
// @auth (2020/04/05 20:22)
// @return err error
// @return menus []SysBaseMenu
//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetBaseMenuTree
//@description: 获取基础路由树
//@return: err error, menus []model.SysBaseMenu
func GetBaseMenuTree() (err error, menus []model.SysBaseMenu) {
err, treeMap := getBaseMenuTreeMap()
......@@ -134,12 +126,11 @@ func GetBaseMenuTree() (err error, menus []model.SysBaseMenu) {
return err, menus
}
// @title AddMenuAuthority
// @description 为角色增加menu树
// @auth (2020/04/05 20:22)
// @param menus []model.SysBaseMenu
// @param authorityId string
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: AddMenuAuthority
//@description: 为角色增加menu树
//@param: menus []model.SysBaseMenu, authorityId string
//@return: err error
func AddMenuAuthority(menus []model.SysBaseMenu, authorityId string) (err error) {
var auth model.SysAuthority
......@@ -149,12 +140,11 @@ func AddMenuAuthority(menus []model.SysBaseMenu, authorityId string) (err error)
return err
}
// @title GetMenuAuthority
// @description 查看当前角色树
// @auth (2020/04/05 20:22)
// @param authorityId string
// @return err error
// @return menus []SysBaseMenu
//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetMenuAuthority
//@description: 查看当前角色树
//@param: info *request.GetAuthorityId
//@return: err error, menus []model.SysMenu
func GetMenuAuthority(info *request.GetAuthorityId) (err error, menus []model.SysMenu) {
err = global.GVA_DB.Where("authority_id = ? ", info.AuthorityId).Order("sort").Find(&menus).Error
......
......@@ -6,56 +6,57 @@ import (
"gin-vue-admin/model/request"
)
// @title CreateSysOperationRecord
// @description create a SysOperationRecord
// @param sysOperationRecord model.SysOperationRecord
// @auth (2020/04/05 20:22)
// @return err error
//@author: [granty1](https://github.com/granty1)
//@function: CreateSysOperationRecord
//@description: 创建记录
//@param: sysOperationRecord model.SysOperationRecord
//@return: err error
func CreateSysOperationRecord(sysOperationRecord model.SysOperationRecord) (err error) {
err = global.GVA_DB.Create(&sysOperationRecord).Error
return err
}
// @title DeleteSysOperationRecord
// @description delete SysOperationRecords
// @auth (2020/04/05 20:22)
// @param sysOperationRecord request.IdsReq
// @return error
//@author: [granty1](https://github.com/granty1)
//@author: [piexlmax](https://github.com/piexlmax)
//@function: DeleteSysOperationRecordByIds
//@description: 批量删除记录
//@param: ids request.IdsReq
//@return: err error
func DeleteSysOperationRecordByIds(ids request.IdsReq) (err error) {
err = global.GVA_DB.Delete(&[]model.SysOperationRecord{}, "id in (?)", ids.Ids).Error
return err
}
// @title DeleteSysOperationRecord
// @description delete a SysOperationRecord
// @auth (2020/04/05 20:22)
// @param sysOperationRecord model.SysOperationRecord
// @return error
//@author: [granty1](https://github.com/granty1)
//@function: DeleteSysOperationRecord
//@description: 删除操作记录
//@param: sysOperationRecord model.SysOperationRecord
//@return: err error
func DeleteSysOperationRecord(sysOperationRecord model.SysOperationRecord) (err error) {
err = global.GVA_DB.Delete(sysOperationRecord).Error
return err
}
// @title GetSysOperationRecord
// @description get the info of a SysOperationRecord
// @auth (2020/04/05 20:22)
// @param id uint
// @return error
// @return SysOperationRecord SysOperationRecord
//@author: [granty1](https://github.com/granty1)
//@function: DeleteSysOperationRecord
//@description: 根据id获取单条操作记录
//@param: id uint
//@return: err error, sysOperationRecord model.SysOperationRecord
func GetSysOperationRecord(id uint) (err error, sysOperationRecord model.SysOperationRecord) {
err = global.GVA_DB.Where("id = ?", id).First(&sysOperationRecord).Error
return
}
// @title GetSysOperationRecordInfoList
// @description get SysOperationRecord list by pagination, 分页获取用户列表
// @auth (2020/04/05 20:22)
// @param info PageInfo
// @return error
//@author: [granty1](https://github.com/granty1)
//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetSysOperationRecordInfoList
//@description: 分页获取操作记录列表
//@param: info request.SysOperationRecordSearch
//@return: err error, list interface{}, total int64
func GetSysOperationRecordInfoList(info request.SysOperationRecordSearch) (err error, list interface{}, total int64) {
limit := info.PageSize
......
......@@ -8,21 +8,21 @@ import (
"go.uber.org/zap"
)
// @title GetSystemConfig
// @description 读取配置文件
// @auth (2020/04/05 20:22)
// @return err error
// @return conf Server
//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetSystemConfig
//@description: 读取配置文件
//@return: err error, conf config.Server
func GetSystemConfig() (err error, conf config.Server) {
return nil, global.GVA_CONFIG
}
// @title SetSystemConfig
// @description set system config, 设置配置文件
// @auth (2020/04/05 20:22)
// @param system model.System
// @return err error
// @description set system config,
//@author: [piexlmax](https://github.com/piexlmax)
//@function: SetSystemConfig
//@description: 设置配置文件
//@param: system model.System
//@return: err error
func SetSystemConfig(system model.System) (err error) {
cs := utils.StructToMap(system.Config)
......@@ -33,12 +33,10 @@ func SetSystemConfig(system model.System) (err error) {
return err
}
// @title GetServerInfo
// @description get server info , 获取服务器信息
// @auth (2020/04/05 20:22)
// @return server *utils.Server
// @return err error
//@author: [SliverHorn](https://github.com/SliverHorn)
//@function: GetServerInfo
//@description: 获取服务器信息
//@return: server *utils.Server, err error
func GetServerInfo() (server *utils.Server, err error) {
var s utils.Server
......
......@@ -10,12 +10,12 @@ import (
"gorm.io/gorm"
)
// @title Register
// @description register, 用户注册
// @auth (2020/04/05 20:22)
// @param u model.SysUser
// @return err error
// @return userInter *SysUser
//@author: [piexlmax](https://github.com/piexlmax)
//@function: Register
//@description: 用户注册
//@param: u model.SysUser
//@return: err error, userInter model.SysUser
func Register(u model.SysUser) (err error, userInter model.SysUser) {
var user model.SysUser
......@@ -29,12 +29,11 @@ func Register(u model.SysUser) (err error, userInter model.SysUser) {
return err, u
}
// @title Login
// @description login, 用户登录
// @auth (2020/04/05 20:22)
// @param u *model.SysUser
// @return err error
// @return userInter *SysUser
//@author: [piexlmax](https://github.com/piexlmax)
//@function: Login
//@description: 用户登录
//@param: u *model.SysUser
//@return: err error, userInter *model.SysUser
func Login(u *model.SysUser) (err error, userInter *model.SysUser) {
var user model.SysUser
......@@ -43,13 +42,11 @@ func Login(u *model.SysUser) (err error, userInter *model.SysUser) {
return err, &user
}
// @title ChangePassword
// @description change the password of a certain user, 修改用户密码
// @auth (2020/04/05 20:22)
// @param u *model.SysUser
// @param newPassword string
// @return err error
// @return userInter *SysUser
//@author: [piexlmax](https://github.com/piexlmax)
//@function: ChangePassword
//@description: 修改用户密码
//@param: u *model.SysUser, newPassword string
//@return: err error, userInter *model.SysUser
func ChangePassword(u *model.SysUser, newPassword string) (err error, userInter *model.SysUser) {
var user model.SysUser
......@@ -58,13 +55,11 @@ func ChangePassword(u *model.SysUser, newPassword string) (err error, userInter
return err, u
}
// @title GetInfoList
// @description get user list by pagination, 分页获取数据
// @auth (2020/04/05 20:22)
// @param info request.PageInfo
// @return err error
// @return list interface{}
// @return total int
//@author: [piexlmax](https://github.com/piexlmax)
//@function: GetUserInfoList
//@description: 分页获取数据
//@param: info request.PageInfo
//@return: err error, list interface{}, total int64
func GetUserInfoList(info request.PageInfo) (err error, list interface{}, total int64) {
limit := info.PageSize
......@@ -76,24 +71,22 @@ func GetUserInfoList(info request.PageInfo) (err error, list interface{}, total
return err, userList, total
}
// @title SetUserAuthority
// @description set the authority of a certain user, 设置一个用户的权限
// @auth (2020/04/05 20:22)
// @param uuid UUID
// @param authorityId string
// @return err error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: SetUserAuthority
//@description: 设置一个用户的权限
//@param: uuid uuid.UUID, authorityId string
//@return: err error
func SetUserAuthority(uuid uuid.UUID, authorityId string) (err error) {
err = global.GVA_DB.Where("uuid = ?", uuid).First(&model.SysUser{}).Update("authority_id", authorityId).Error
return err
}
// @title SetUserAuthority
// @description set the authority of a certain user, 设置一个用户的权限
// @auth (2020/04/05 20:22)
// @param uuid UUID
// @param authorityId string
// @return err error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: DeleteUser
//@description: 删除用户
//@param: id float64
//@return: err error
func DeleteUser(id float64) (err error) {
var user model.SysUser
......@@ -101,24 +94,22 @@ func DeleteUser(id float64) (err error) {
return err
}
// @title SetUserInfo
// @description set the authority of a certain user, 设置用户信息
// @auth (2020/04/05 20:22)
// @param uuid UUID
// @param authorityId string
// @return err error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: SetUserInfo
//@description: 设置用户信息
//@param: reqUser model.SysUser
//@return: err error, user model.SysUser
func SetUserInfo(reqUser model.SysUser) (err error, user model.SysUser) {
err = global.GVA_DB.Updates(&reqUser).Error
return err, reqUser
}
// @title FindUserById
// @description Get user information by id, 通过id获取用户信息
// @auth (2020/04/05 20:22)
// @param id int
// @return err error
// @return user *model.SysUser
//@author: [SliverHorn](https://github.com/SliverHorn)
//@function: FindUserById
//@description: 通过id获取用户信息
//@param: id int
//@return: err error, user *model.SysUser
func FindUserById(id int) (err error, user *model.SysUser) {
var u model.SysUser
......@@ -126,12 +117,11 @@ func FindUserById(id int) (err error, user *model.SysUser) {
return err, &u
}
// @title FindUserByUuid
// @description Get user information by uuid, 通过uuid获取用户信息
// @auth (2020/04/05 20:22)
// @param uuid string
// @return err error
// @return user *model.SysUser
//@author: [SliverHorn](https://github.com/SliverHorn)
//@function: FindUserByUuid
//@description: 通过uuid获取用户信息
//@param: uuid string
//@return: err error, user *model.SysUser
func FindUserByUuid(uuid string) (err error, user *model.SysUser) {
var u model.SysUser
......
......@@ -5,11 +5,11 @@ import (
"gin-vue-admin/model"
)
// @title Create
// @description create a workflow, 创建工作流
// @auth (2020/04/05 20:22)
// @param wk model.SysWorkflow
// @return error
//@author: [piexlmax](https://github.com/piexlmax)
//@function: Create
//@description: 创建工作流
//@param: wk model.SysWorkflow
//@return: error
func Create(wk model.SysWorkflow) error {
err := global.GVA_DB.Create(&wk).Error
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册