correct all comments of functions in service
This commit is contained in:
@@ -9,51 +9,46 @@ import (
|
||||
|
||||
// @title CreateAuthority
|
||||
// @description 创建一个角色
|
||||
// @auth (2020/04/05 20:22 )
|
||||
// @param FileMd5 string
|
||||
// @param FileName string
|
||||
// @param FilePath string
|
||||
// @auth (2020/04/05 20:22)
|
||||
// @param auth model.SysAuthority
|
||||
// @return error
|
||||
func CreateAuthority(a model.SysAuthority) (err error, authority model.SysAuthority) {
|
||||
err = global.GVA_DB.Create(&a).Error
|
||||
return err, a
|
||||
// @return authority model.SysAuthority
|
||||
func CreateAuthority(auth model.SysAuthority) (err error, authority model.SysAuthority) {
|
||||
err = global.GVA_DB.Create(&auth).Error
|
||||
return err, auth
|
||||
}
|
||||
|
||||
// @title DeleteAuthority
|
||||
// @description 删除角色
|
||||
// @auth (2020/04/05 20:22 )
|
||||
// @param FileMd5 string
|
||||
// @param FileName string
|
||||
// @param FilePath string
|
||||
// @auth (2020/04/05 20:22)
|
||||
// @param auth model.SysAuthority
|
||||
// @return error
|
||||
// 删除角色
|
||||
func DeleteAuthority(a model.SysAuthority) (err error) {
|
||||
err = global.GVA_DB.Where("authority_id = ?", a.AuthorityId).Find(&model.SysUser{}).Error
|
||||
func DeleteAuthority(auth model.SysAuthority) (err error) {
|
||||
err = global.GVA_DB.Where("authority_id = ?", auth.AuthorityId).Find(&model.SysUser{}).Error
|
||||
if err == nil {
|
||||
err = errors.New("此角色有用户正在使用禁止删除")
|
||||
return
|
||||
}
|
||||
err = global.GVA_DB.Where("parent_id = ?", a.AuthorityId).Find(&model.SysAuthority{}).Error
|
||||
err = global.GVA_DB.Where("parent_id = ?", auth.AuthorityId).Find(&model.SysAuthority{}).Error
|
||||
if err == nil {
|
||||
err = errors.New("此角色存在子角色不允许删除")
|
||||
return
|
||||
}
|
||||
db := global.GVA_DB.Preload("SysBaseMenus").Where("authority_id = ?", a.AuthorityId).First(a).Unscoped().Delete(a)
|
||||
if len(a.SysBaseMenus) > 0 {
|
||||
err = db.Association("SysBaseMenus").Delete(a.SysBaseMenus).Error
|
||||
db := global.GVA_DB.Preload("SysBaseMenus").Where("authority_id = ?", auth.AuthorityId).First(auth).Unscoped().Delete(auth)
|
||||
if len(auth.SysBaseMenus) > 0 {
|
||||
err = db.Association("SysBaseMenus").Delete(auth.SysBaseMenus).Error
|
||||
} else {
|
||||
err = db.Error
|
||||
}
|
||||
ClearCasbin(0, a.AuthorityId)
|
||||
ClearCasbin(0, auth.AuthorityId)
|
||||
return err
|
||||
}
|
||||
|
||||
// @title GetInfoList
|
||||
// @description 删除文件切片记录
|
||||
// @auth (2020/04/05 20:22 )
|
||||
// @param FileMd5 string
|
||||
// @param FileName string
|
||||
// @param FilePath string
|
||||
// @auth (2020/04/05 20:22)
|
||||
// @param info request.PaveInfo
|
||||
// @return error
|
||||
// 分页获取数据
|
||||
func GetAuthorityInfoList(info request.PageInfo) (err error, list interface{}, total int) {
|
||||
@@ -72,50 +67,43 @@ func GetAuthorityInfoList(info request.PageInfo) (err error, list interface{}, t
|
||||
|
||||
// @title GetAuthorityInfo
|
||||
// @description 获取所有角色信息
|
||||
// @auth (2020/04/05 20:22 )
|
||||
// @param FileMd5 string
|
||||
// @param FileName string
|
||||
// @param FilePath string
|
||||
// @auth (2020/04/05 20:22)
|
||||
// @param auth model.SysAuthority
|
||||
// @return error
|
||||
func GetAuthorityInfo(a model.SysAuthority) (err error, sa model.SysAuthority) {
|
||||
err = global.GVA_DB.Preload("DataAuthorityId").Where("authority_id = ?", a.AuthorityId).First(&sa).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
|
||||
}
|
||||
|
||||
// @title SetDataAuthority
|
||||
// @description 设置角色资源权限
|
||||
// @auth (2020/04/05 20:22 )
|
||||
// @param FileMd5 string
|
||||
// @param FileName string
|
||||
// @param FilePath string
|
||||
// @auth (2020/04/05 20:22)
|
||||
// @param auth model.SysAuthority
|
||||
// @return error
|
||||
func SetDataAuthority(a model.SysAuthority) error {
|
||||
func SetDataAuthority(auth model.SysAuthority) error {
|
||||
var s model.SysAuthority
|
||||
global.GVA_DB.Preload("DataAuthorityId").First(&s, "authority_id = ?", a.AuthorityId)
|
||||
err := global.GVA_DB.Model(&s).Association("DataAuthorityId").Replace(&a.DataAuthorityId).Error
|
||||
global.GVA_DB.Preload("DataAuthorityId").First(&s, "authority_id = ?", auth.AuthorityId)
|
||||
err := global.GVA_DB.Model(&s).Association("DataAuthorityId").Replace(&auth.DataAuthorityId).Error
|
||||
return err
|
||||
}
|
||||
|
||||
// @title SetMenuAuthority
|
||||
// @description 菜单与角色绑定
|
||||
// @auth (2020/04/05 20:22 )
|
||||
// @param FileMd5 string
|
||||
// @param FileName string
|
||||
// @param FilePath string
|
||||
// @auth (2020/04/05 20:22)
|
||||
// @param auth *model.SysAuthority
|
||||
// @return error
|
||||
func SetMenuAuthority(a *model.SysAuthority) error {
|
||||
func SetMenuAuthority(auth *model.SysAuthority) error {
|
||||
var s model.SysAuthority
|
||||
global.GVA_DB.Preload("SysBaseMenus").First(&s, "authority_id = ?", a.AuthorityId)
|
||||
err := global.GVA_DB.Model(&s).Association("SysBaseMenus").Replace(&a.SysBaseMenus).Error
|
||||
global.GVA_DB.Preload("SysBaseMenus").First(&s, "authority_id = ?", auth.AuthorityId)
|
||||
err := global.GVA_DB.Model(&s).Association("SysBaseMenus").Replace(&auth.SysBaseMenus).Error
|
||||
return err
|
||||
}
|
||||
|
||||
// @title findChildrenAuthority
|
||||
// @description 查询子角色
|
||||
// @auth (2020/04/05 20:22 )
|
||||
// @param FileMd5 string
|
||||
// @param FileName string
|
||||
// @param FilePath string
|
||||
// @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
|
||||
|
||||
Reference in New Issue
Block a user