提交 8f7113f1 编写于 作者: Mr.奇淼('s avatar Mr.奇淼(

swagger修复完成

上级 c07a3701
......@@ -95,7 +95,7 @@ func GetExaCustomer(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.PageInfo true "获取权限客户列表"
// @Param data body request.PageInfo true "获取权限客户列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /customer/customerList [get]
func GetExaCustomerList(c *gin.Context) {
......
......@@ -85,7 +85,7 @@ func DeleteFile(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.PageInfo true "分页获取文件户列表"
// @Param data body request.PageInfo true "分页获取文件户列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /fileUploadAndDownload/getFileList [post]
func GetFileList(c *gin.Context) {
......
......@@ -55,7 +55,7 @@ func DeleteApi(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.SearchApiParams true "分页获取API列表"
// @Param data body request.SearchApiParams true "分页获取API列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /api/getApiList [post]
func GetApiList(c *gin.Context) {
......@@ -80,7 +80,7 @@ func GetApiList(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.GetById true "根据id获取api"
// @Param data body request.GetById true "根据id获取api"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /api/getApiById [post]
func GetApiById(c *gin.Context) {
......
......@@ -54,7 +54,7 @@ func DeleteAuthority(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.PageInfo true "分页获取用户列表"
// @Param data body request.PageInfo true "分页获取用户列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /authority/getAuthorityList [post]
func GetAuthorityList(c *gin.Context) {
......
......@@ -14,7 +14,7 @@ import (
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.CasbinInReceive true "更改角色api权限"
// @Param data body request.CasbinInReceive true "更改角色api权限"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /casbin/UpdateCasbin [post]
func UpdateCasbin(c *gin.Context) {
......@@ -33,7 +33,7 @@ func UpdateCasbin(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.CasbinInReceive true "获取权限列表"
// @Param data body request.CasbinInReceive true "获取权限列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /casbin/getPolicyPathByAuthorityId [post]
func GetPolicyPathByAuthorityId(c *gin.Context) {
......@@ -48,7 +48,7 @@ func GetPolicyPathByAuthorityId(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.CasbinInReceive true "获取权限列表"
// @Param data body request.CasbinInReceive true "获取权限列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /casbin/CasbinTest [get]
func CasbinTest(c *gin.Context) {
......
......@@ -14,7 +14,7 @@ import (
// @Summary 获取用户动态路由
// @Security ApiKeyAuth
// @Produce application/json
// @Param data body api.RegisterAndLoginStruct true "可以什么都不填"
// @Param data body request.RegisterAndLoginStruct true "可以什么都不填"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
// @Router /menu/getMenu [post]
func GetMenu(c *gin.Context) {
......@@ -33,7 +33,7 @@ func GetMenu(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.PageInfo true "分页获取基础menu列表"
// @Param data body request.PageInfo true "分页获取基础menu列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /menu/getMenuList [post]
func GetMenuList(c *gin.Context) {
......@@ -75,7 +75,7 @@ func AddBaseMenu(c *gin.Context) {
// @Summary 获取用户动态路由
// @Security ApiKeyAuth
// @Produce application/json
// @Param data body api.RegisterAndLoginStruct true "可以什么都不填"
// @Param data body request.RegisterAndLoginStruct true "可以什么都不填"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
// @Router /menu/getBaseMenuTree [post]
func GetBaseMenuTree(c *gin.Context) {
......@@ -93,7 +93,7 @@ func GetBaseMenuTree(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.AddMenuAuthorityInfo true "增加menu和角色关联关系"
// @Param data body request.AddMenuAuthorityInfo true "增加menu和角色关联关系"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /menu/addMenuAuthority [post]
func AddMenuAuthority(c *gin.Context) {
......@@ -113,7 +113,7 @@ func AddMenuAuthority(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.AuthorityIdInfo true "增加menu和角色关联关系"
// @Param data body request.AuthorityIdInfo true "增加menu和角色关联关系"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /menu/GetMenuAuthority [post]
func GetMenuAuthority(c *gin.Context) {
......@@ -132,7 +132,7 @@ func GetMenuAuthority(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.GetById true "删除菜单"
// @Param data body request.GetById true "删除菜单"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /menu/deleteBaseMenu [post]
func DeleteBaseMenu(c *gin.Context) {
......@@ -171,7 +171,7 @@ func UpdateBaseMenu(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.GetById true "根据id获取菜单"
// @Param data body request.GetById true "根据id获取菜单"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /menu/getBaseMenuById [post]
func GetBaseMenuById(c *gin.Context) {
......
......@@ -44,7 +44,7 @@ func Register(c *gin.Context) {
// @Tags Base
// @Summary 用户登录
// @Produce application/json
// @Param data body model.RegisterAndLoginStruct true "用户登录接口"
// @Param data body request.RegisterAndLoginStruct true "用户登录接口"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"登陆成功"}"
// @Router /base/login [post]
func Login(c *gin.Context) {
......@@ -133,7 +133,7 @@ func tokenNext(c *gin.Context, user model.SysUser) {
// @Summary 用户修改密码
// @Security ApiKeyAuth
// @Produce application/json
// @Param data body model.ChangePasswordStutrc true "用户修改密码"
// @Param data body request.ChangePasswordStruct true "用户修改密码"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
// @Router /user/changePassword [put]
func ChangePassword(c *gin.Context) {
......@@ -192,7 +192,7 @@ func UploadHeaderImg(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.PageInfo true "分页获取用户列表"
// @Param data body request.PageInfo true "分页获取用户列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /user/getUserList [post]
func GetUserList(c *gin.Context) {
......@@ -216,7 +216,7 @@ func GetUserList(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.SetUserAuth true "设置用户权限"
// @Param data body request.SetUserAuth true "设置用户权限"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
// @Router /user/setUserAuthority [post]
func SetUserAuthority(c *gin.Context) {
......
......@@ -11,7 +11,7 @@ import (
// @Tags workflow
// @Summary 注册工作流
// @Produce application/json
// @Param data body sysModel.SysWorkflow true "注册工作流接口"
// @Param data body model.SysWorkflow true "注册工作流接口"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"注册成功"}"
// @Router /workflow/createWorkFlow [post]
func CreateWorkFlow(c *gin.Context) {
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -72,7 +72,7 @@ export const create{{.StructName}} = (data) => {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.PageInfo true "分页获取{{.StructName}}列表"
// @Param data body request.PageInfo true "分页获取{{.StructName}}列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /{{.Abbreviation}}/get{{.StructName}}List [post]
export const get{{.StructName}}List = (data) => {
......
......@@ -97,11 +97,11 @@ func Find{{.StructName}}(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.PageInfo true "分页获取{{.StructName}}列表"
// @Param data body request.PageInfo true "分页获取{{.StructName}}列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /{{.Abbreviation}}/get{{.StructName}}List [post]
func Get{{.StructName}}List(c *gin.Context) {
var pageInfo model.PageInfo
var pageInfo request.PageInfo
_ = c.ShouldBindJSON(&pageInfo)
err, list, total := new({{.PackageName}}.{{.StructName}}).GetInfoList(pageInfo)
if err != nil {
......
......@@ -14,7 +14,8 @@ import (
// @param chunkTotal int
// @return err error
// @return file ExaFile
func FindOrCreateFile(fileMd5 string, fileName string, chunkTotal int) (err error, file model.ExaFile) {
func FindOrCreateFile(fileMd5 string, fileName string, chunkTotal int) (err error, file model.ExaFile) {
var cfile model.ExaFile
cfile.FileMd5 = fileMd5
cfile.FileName = fileName
......@@ -31,7 +32,6 @@ func FindOrCreateFile(fileMd5 string, fileName string, chunkTotal int) (err err
}
}
// @title CreateFileChunk
// @description create a chunk of the file, 创建文件切片记录
// @auth (2020/04/05 20:22)
......@@ -39,6 +39,7 @@ func FindOrCreateFile(fileMd5 string, fileName string, chunkTotal int) (err err
// @param fileChunkPath string
// @param fileChunkNumber int
// @return error
func CreateFileChunk(id uint, fileChunkPath string, fileChunkNumber int) error {
var chunk model.ExaFileChunk
chunk.FileChunkPath = fileChunkPath
......@@ -55,6 +56,7 @@ func CreateFileChunk(id uint, fileChunkPath string, fileChunkNumber int) error {
// @param fileName string
// @param filePath string
// @return error
func FileCreateComplete(fileMd5 string, fileName string, filePath string) error {
var file model.ExaFile
upDateFile := make(map[string]interface{})
......@@ -71,6 +73,7 @@ func FileCreateComplete(fileMd5 string, fileName string, filePath string) error
// @param FileName string
// @param FilePath string
// @return error
func DeleteFileChunk(fileMd5 string, fileName string, filePath string) error {
var chunks []model.ExaFileChunk
var file model.ExaFile
......
......@@ -11,6 +11,7 @@ import (
// @param e model.ExaCustomer
// @auth (2020/04/05 20:22)
// @return err error
func CreateExaCustomer(e model.ExaCustomer) (err error) {
err = global.GVA_DB.Create(&e).Error
return err
......@@ -21,6 +22,7 @@ func CreateExaCustomer(e model.ExaCustomer) (err error) {
// @auth (2020/04/05 20:22)
// @param e *model.ExaCustomer
// @return error
func DeleteExaCustomer(e model.ExaCustomer) (err error) {
err = global.GVA_DB.Delete(e).Error
return err
......@@ -31,6 +33,7 @@ func DeleteExaCustomer(e model.ExaCustomer) (err error) {
// @param e *model.ExaCustomer
// @auth (2020/04/05 20:22)
// @return error
func UpdateExaCustomer(e *model.ExaCustomer) (err error) {
err = global.GVA_DB.Save(e).Error
return err
......@@ -42,6 +45,7 @@ func UpdateExaCustomer(e *model.ExaCustomer) (err error) {
// @param id uint
// @return error
// @return customer ExaCustomer
func GetExaCustomer(id uint) (err error, customer model.ExaCustomer) {
err = global.GVA_DB.Where("id = ?", id).First(&customer).Error
return
......@@ -53,6 +57,7 @@ func GetExaCustomer(id uint) (err error, customer model.ExaCustomer) {
// @param sysUserAuthorityID string
// @param info PageInfo
// @return error
func GetCustomerInfoList(sysUserAuthorityID string, info request.PageInfo) (err error, list interface{}, total int) {
limit := info.PageSize
offset := info.PageSize * (info.Page - 1)
......
......@@ -11,6 +11,7 @@ import (
// @param file model.ExaFileUploadAndDownload
// @auth (2020/04/05 20:22)
// @return error
func Upload(file model.ExaFileUploadAndDownload) error {
err := global.GVA_DB.Create(&file).Error
return err
......@@ -21,6 +22,7 @@ func Upload(file model.ExaFileUploadAndDownload) error {
// @auth (2020/04/05 20:22)
// @param id uint
// @return error
func FindFile(id uint) (error, model.ExaFileUploadAndDownload) {
var file model.ExaFileUploadAndDownload
err := global.GVA_DB.Where("id = ?", id).First(&file).Error
......@@ -32,6 +34,7 @@ func FindFile(id uint) (error, model.ExaFileUploadAndDownload) {
// @auth (2020/04/05 20:22)
// @param file model.ExaFileUploadAndDownload
// @return error
func DeleteFile(file model.ExaFileUploadAndDownload) error {
err := global.GVA_DB.Where("id = ?", file.ID).Unscoped().Delete(file).Error
return err
......@@ -44,6 +47,7 @@ func DeleteFile(file model.ExaFileUploadAndDownload) error {
// @return err error
// @return list error
// @return total error
func GetFileRecordInfoList(info request.PageInfo) (err error, list interface{}, total int) {
limit := info.PageSize
offset := info.PageSize * (info.Page - 1)
......
......@@ -10,6 +10,7 @@ import (
// @param jwtList model.JwtBlacklist
// @auth (2020/04/05 20:22)
// @return err error
func JsonInBlacklist(jwtList model.JwtBlacklist) (err error) {
err = global.GVA_DB.Create(&jwtList).Error
return
......@@ -21,6 +22,7 @@ func JsonInBlacklist(jwtList model.JwtBlacklist) (err error) {
// @param jwt string
// @param jwtList model.JwtBlacklist
// @return err error
func IsBlacklist(jwt string, jwtList model.JwtBlacklist) bool {
isNotFound := global.GVA_DB.Where("jwt = ?", jwt).First(&jwtList).RecordNotFound()
return !isNotFound
......@@ -32,6 +34,7 @@ func IsBlacklist(jwt string, jwtList model.JwtBlacklist) bool {
// @param userName string
// @return err error
// @return redisJWT string
func GetRedisJWT(userName string) (err error, redisJWT string) {
redisJWT, err = global.GVA_REDIS.Get(userName).Result()
return err, redisJWT
......@@ -43,6 +46,7 @@ func GetRedisJWT(userName string) (err error, redisJWT string) {
// @param jwtList model.JwtBlacklist
// @param userName string
// @return err error
func SetRedisJWT(jwtList model.JwtBlacklist, userName string) (err error) {
err = global.GVA_REDIS.Set(userName, jwtList.Jwt, 1000*1000*1000*60*60*24*7).Err()
return err
......
......@@ -12,6 +12,7 @@ import (
// @auth (2020/04/05 20:22)
// @param api model.SysApi
// @return error
func CreateApi(api model.SysApi) (err error) {
findOne := global.GVA_DB.Where("path = ? AND method = ?", api.Path, api.Method).Find(&model.SysApi{}).Error
if findOne == nil {
......@@ -27,6 +28,7 @@ func CreateApi(api model.SysApi) (err error) {
// @param api model.SysApi
// @auth (2020/04/05 20:22)
// @return error
func DeleteApi(api model.SysApi) (err error) {
err = global.GVA_DB.Delete(api).Error
ClearCasbin(1, api.Path, api.Method)
......@@ -43,6 +45,7 @@ func DeleteApi(api model.SysApi) (err error) {
// @return err error
// @return list interface{}
// @return total int
func GetAPIInfoList(api model.SysApi, info request.PageInfo, order string, desc bool) (err error, list interface{}, total int) {
limit := info.PageSize
offset := info.PageSize * (info.Page - 1)
......@@ -91,6 +94,7 @@ func GetAPIInfoList(api model.SysApi, info request.PageInfo, order string, desc
// @auth (2020/04/05 20:22)
// @return err error
// @return apis []SysApi
func GetAllApis() (err error, apis []model.SysApi) {
err = global.GVA_DB.Find(&apis).Error
return
......@@ -102,6 +106,7 @@ func GetAllApis() (err error, apis []model.SysApi) {
// @param api model.SysApi
// @param id float64
// @return error
func GetApiById(id float64) (err error, api model.SysApi) {
err = global.GVA_DB.Where("id = ?", id).First(&api).Error
return
......@@ -112,6 +117,7 @@ func GetApiById(id float64) (err error, api model.SysApi) {
// @auth (2020/04/05 20:22)
// @param api model.SysApi
// @return error
func UpdateApi(api model.SysApi) (err error) {
var oldA model.SysApi
......
......@@ -13,6 +13,7 @@ import (
// @param auth model.SysAuthority
// @return error
// @return authority model.SysAuthority
func CreateAuthority(auth model.SysAuthority) (err error, authority model.SysAuthority) {
err = global.GVA_DB.Create(&auth).Error
return err, auth
......@@ -24,6 +25,7 @@ func CreateAuthority(auth model.SysAuthority) (err error, authority model.SysAut
// @param auth model.SysAuthority
// @return error
// 删除角色
func DeleteAuthority(auth *model.SysAuthority) (err error) {
err = global.GVA_DB.Where("authority_id = ?", auth.AuthorityId).Find(&model.SysUser{}).Error
if err == nil {
......@@ -51,6 +53,7 @@ func DeleteAuthority(auth *model.SysAuthority) (err error) {
// @param info request.PaveInfo
// @return error
// 分页获取数据
func GetAuthorityInfoList(info request.PageInfo) (err error, list interface{}, total int) {
limit := info.PageSize
offset := info.PageSize * (info.Page - 1)
......@@ -71,6 +74,7 @@ func GetAuthorityInfoList(info request.PageInfo) (err error, list interface{}, t
// @param auth model.SysAuthority
// @return error
// @param authority 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
......@@ -81,6 +85,7 @@ func GetAuthorityInfo(auth model.SysAuthority) (err error, sa model.SysAuthority
// @auth (2020/04/05 20:22)
// @param auth model.SysAuthority
// @return error
func SetDataAuthority(auth model.SysAuthority) error {
var s model.SysAuthority
global.GVA_DB.Preload("DataAuthorityId").First(&s, "authority_id = ?", auth.AuthorityId)
......@@ -93,6 +98,7 @@ func SetDataAuthority(auth model.SysAuthority) error {
// @auth (2020/04/05 20:22)
// @param auth *model.SysAuthority
// @return error
func SetMenuAuthority(auth *model.SysAuthority) error {
var s model.SysAuthority
global.GVA_DB.Preload("SysBaseMenus").First(&s, "authority_id = ?", auth.AuthorityId)
......@@ -105,6 +111,7 @@ func SetMenuAuthority(auth *model.SysAuthority) error {
// @auth (2020/04/05 20:22)
// @param auth *model.SysAuthority
// @return error
func findChildrenAuthority(authority *model.SysAuthority) (err error) {
err = global.GVA_DB.Preload("DataAuthorityId").Where("parent_id = ?", authority.AuthorityId).Find(&authority.Children).Error
if len(authority.Children) > 0 {
......
......@@ -12,6 +12,7 @@ import (
// @auth (2020/04/05 20:22)
// @param autoCode model.AutoCodeStruct
// @return err error
func CreateTemp(autoCode model.AutoCodeStruct) (err error) {
basePath := "./resource/template"
modelTmpl, err := template.ParseFiles(basePath + "/te/model.go.tpl")
......
......@@ -11,7 +11,8 @@ import (
// @auth (2020/04/05 20:22)
// @param id float64
// @return err error
func DeleteBaseMenu(id float64) (err error) {
func DeleteBaseMenu(id float64) (err error) {
err = global.GVA_DB.Where("parent_id = ?", id).First(&model.SysBaseMenu{}).Error
if err != nil {
var menu model.SysBaseMenu
......@@ -32,7 +33,8 @@ func DeleteBaseMenu(id float64) (err error) {
// @auth (2020/04/05 20:22)
// @param menu model.SysBaseMenu
// @return err error
func UpdateBaseMenu(menu model.SysBaseMenu) (err error) {
func UpdateBaseMenu(menu model.SysBaseMenu) (err error) {
upDateMap := make(map[string]interface{})
upDateMap["parent_id"] = menu.ParentId
upDateMap["path"] = menu.Path
......@@ -52,6 +54,7 @@ func UpdateBaseMenu(menu model.SysBaseMenu) (err error) {
// @auth (2020/04/05 20:22)
// @param id float64
// @return err error
func GetBaseMenuById(id float64) (err error, menu model.SysBaseMenu) {
err = global.GVA_DB.Where("id = ?", id).First(&menu).Error
return
......
......@@ -17,6 +17,7 @@ import (
// @param authorityId string
// @param casbinInfos []CasbinInfo
// @return error
func UpdateCasbin(authorityId string, casbinInfos []request.CasbinInfo) error {
ClearCasbin(0, authorityId)
for _, v := range casbinInfos {
......@@ -40,6 +41,7 @@ func UpdateCasbin(authorityId string, casbinInfos []request.CasbinInfo) error {
// @auth (2020/04/05 20:22)
// @param cm model.CasbinModel
// @return bool
func AddCasbin(cm model.CasbinModel) bool {
e := Casbin()
return e.AddPolicy(cm.AuthorityId, cm.Path, cm.Method)
......@@ -53,6 +55,7 @@ func AddCasbin(cm model.CasbinModel) bool {
// @param oldMethod string
// @param newMethod string
// @return error
func UpdateCasbinApi(oldPath string, newPath string, oldMethod string, newMethod string) error {
var cs []model.CasbinModel
err := global.GVA_DB.Table("casbin_rule").Where("v1 = ? AND v2 = ?", oldPath, oldMethod).Find(&cs).Updates(map[string]string{
......@@ -67,6 +70,7 @@ func UpdateCasbinApi(oldPath string, newPath string, oldMethod string, newMethod
// @auth (2020/04/05 20:22)
// @param authorityId string
// @return []string
func GetPolicyPathByAuthorityId(authorityId string) (pathMaps []map[string]string) {
e := Casbin()
list := e.GetFilteredPolicy(0, authorityId)
......@@ -85,6 +89,7 @@ func GetPolicyPathByAuthorityId(authorityId string) (pathMaps []map[string]strin
// @param v int
// @param p string
// @return bool
func ClearCasbin(v int, p ...string) bool {
e := Casbin()
return e.RemoveFilteredPolicy(v, p...)
......@@ -94,6 +99,7 @@ func ClearCasbin(v int, p ...string) bool {
// @title Casbin
// @description store to DB, 持久化到数据库 引入自定义规则
// @auth (2020/04/05 20:22)
func Casbin() *casbin.Enforcer {
a := gormadapter.NewAdapterByDB(global.GVA_DB)
e := casbin.NewEnforcer(global.GVA_CONFIG.Casbin.ModelPath, a)
......@@ -108,6 +114,7 @@ func Casbin() *casbin.Enforcer {
// @param fullNameKey1 string
// @param key2 string
// @return bool
func ParamsMatch(fullNameKey1 string, key2 string) bool {
key1 := strings.Split(fullNameKey1, "?")[0]
//剥离路径后再使用casbin的keyMatch2
......@@ -120,6 +127,7 @@ func ParamsMatch(fullNameKey1 string, key2 string) bool {
// @param args ...interface{}
// @return interface{}
// @return error
func ParamsMatchFunc(args ...interface{}) (interface{}, error) {
name1 := args[0].(string)
name2 := args[1].(string)
......
......@@ -13,6 +13,7 @@ import (
// @param authorityId string
// @return err error
// @return menus []model.SysMenu
func GetMenuTree(authorityId string) (err error, menus []model.SysMenu) {
sql := "SELECT 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 = ? AND authority_menu.parent_id = ?"
......@@ -29,6 +30,7 @@ func GetMenuTree(authorityId string) (err error, menus []model.SysMenu) {
// @param menu *model.SysMenu
// @param sql string
// @return err error
func getChildrenList(menu *model.SysMenu, sql string) (err error) {
err = global.GVA_DB.Raw(sql, menu.AuthorityId, menu.MenuId).Scan(&menu.Children).Error
for i := 0; i < len(menu.Children); i++ {
......@@ -44,6 +46,7 @@ func getChildrenList(menu *model.SysMenu, sql string) (err error) {
// @return err error
// @return list interface{}
// @return total int
func GetInfoList(info request.PageInfo) (err error, list interface{}, total int) {
limit := info.PageSize
offset := info.PageSize * (info.Page - 1)
......@@ -61,6 +64,7 @@ func GetInfoList(info request.PageInfo) (err error, list interface{}, total int)
// @auth (2020/04/05 20:22)
// @param menu *model.SysBaseMenu
// @return err error
func getBaseChildrenList(menu *model.SysBaseMenu) (err error) {
err = global.GVA_DB.Where("parent_id = ?", menu.ID).Order("sort", true).Find(&menu.Children).Error
for i := 0; i < len(menu.Children); i++ {
......@@ -75,6 +79,7 @@ func getBaseChildrenList(menu *model.SysBaseMenu) (err error) {
// @param menu *model.SysBaseMenu
// @return err error
//增加基础路由
func AddBaseMenu(menu model.SysBaseMenu) (err error) {
findOne := global.GVA_DB.Where("name = ?", menu.Name).Find(&model.SysBaseMenu{}).Error
if findOne != nil {
......@@ -90,6 +95,7 @@ func AddBaseMenu(menu model.SysBaseMenu) (err error) {
// @auth (2020/04/05 20:22)
// @return err error
// @return menus []SysBaseMenu
func GetBaseMenuTree() (err error, menus []model.SysBaseMenu) {
err = global.GVA_DB.Where(" parent_id = ?", 0).Order("sort", true).Find(&menus).Error
for i := 0; i < len(menus); i++ {
......@@ -104,6 +110,7 @@ func GetBaseMenuTree() (err error, menus []model.SysBaseMenu) {
// @param menus []model.SysBaseMenu
// @param authorityId string
// @return error
func AddMenuAuthority(menus []model.SysBaseMenu, authorityId string) (err error) {
var auth model.SysAuthority
auth.AuthorityId = authorityId
......@@ -118,6 +125,7 @@ func AddMenuAuthority(menus []model.SysBaseMenu, authorityId string) (err error)
// @param authorityId string
// @return err error
// @return menus []SysBaseMenu
func GetMenuAuthority(authorityId string) (err error, menus []model.SysMenu) {
sql := "SELECT 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 = ?"
err = global.GVA_DB.Raw(sql, authorityId).Scan(&menus).Error
......
......@@ -12,16 +12,17 @@ import (
// @auth (2020/04/05 20:22)
// @return err error
// @return conf 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
func SetSystemConfig(system model.System) (err error) {
cs := utils.StructToMap(system.Config)
for k, v := range cs {
......@@ -29,4 +30,4 @@ func SetSystemConfig(system model.System) (err error) {
}
err = global.GVA_VP.WriteConfig()
return err
}
\ No newline at end of file
}
......@@ -15,6 +15,7 @@ import (
// @param u model.SysUser
// @return err error
// @return userInter *SysUser
func Register(u model.SysUser) (err error, userInter model.SysUser) {
var user model.SysUser
//判断用户名是否注册
......@@ -37,6 +38,7 @@ func Register(u model.SysUser) (err error, userInter model.SysUser) {
// @param u *model.SysUser
// @return err error
// @return userInter *SysUser
func Login(u *model.SysUser) (err error, userInter *model.SysUser) {
var user model.SysUser
u.Password = utils.MD5V([]byte(u.Password))
......@@ -55,6 +57,7 @@ func Login(u *model.SysUser) (err error, userInter *model.SysUser) {
// @param newPassword string
// @return err error
// @return userInter *SysUser
func ChangePassword(u *model.SysUser, newPassword string) (err error, userInter *model.SysUser) {
var user model.SysUser
//后期修改jwt+password模式
......@@ -70,6 +73,7 @@ func ChangePassword(u *model.SysUser, newPassword string) (err error, userInter
// @return err error
// @return list interface{}
// @return total int
func GetUserInfoList(info request.PageInfo) (err error, list interface{}, total int) {
limit := info.PageSize
offset := info.PageSize * (info.Page - 1)
......@@ -85,6 +89,7 @@ func GetUserInfoList(info request.PageInfo) (err error, list interface{}, total
// @param uuid UUID
// @param 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
......@@ -97,6 +102,7 @@ func SetUserAuthority(uuid uuid.UUID, authorityId string) (err error) {
// @param filePath string
// @return err error
// @return userInter *SysUser
func UploadHeaderImg(uuid uuid.UUID, filePath string) (err error, userInter *model.SysUser) {
var user model.SysUser
err = global.GVA_DB.Where("uuid = ?", uuid).First(&user).Update("header_img", filePath).First(&user).Error
......
......@@ -10,6 +10,7 @@ import (
// @auth (2020/04/05 20:22)
// @param wk model.SysWorkflow
// @return error
func Create(wk model.SysWorkflow) error {
err := global.GVA_DB.Create(&wk).Error
return err
......
......@@ -10,6 +10,7 @@ import (
// @auth (2020/04/05 20:22)
// @param path string
// @return err error
func PathExists(path string) (bool, error) {
_, err := os.Stat(path)
if err == nil {
......@@ -26,6 +27,7 @@ func PathExists(path string) (bool, error) {
// @auth (2020/04/05 20:22)
// @param dirs string
// @return err error
func CreateDir(dirs ...string) (err error) {
for _, v := range dirs {
exist, err := PathExists(v)
......@@ -48,9 +50,11 @@ func CreateDir(dirs ...string) (err error) {
}
return err
}
// @title cwd
// @description 获取当前工作目录
// @return string
func CWD() string {
path, err := os.Executable()
if err != nil {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册