用户关联查询 jwt鉴权调整 api删除调整 authorityId默认类型调整

This commit is contained in:
pixel
2019-10-09 17:32:14 +08:00
parent 756353bd68
commit ddf879793a
9 changed files with 51 additions and 50 deletions

View File

@@ -26,7 +26,8 @@ func (a *Api) CreateApi() (err error) {
}
func (a *Api) DeleteApi() (err error) {
err = qmsql.DEFAULTDB.Where("path = ?", a.Path).Delete(a).Delete(&ApiAuthority{}).Error
err = qmsql.DEFAULTDB.Delete(a).Error
err = qmsql.DEFAULTDB.Where("api_id = ?", a.ID).Unscoped().Delete(&ApiAuthority{}).Error
return err
}
@@ -35,16 +36,16 @@ func (a *Api) UpdataApi() (err error) {
return err
}
func (a *Api) GetApiById(id float64)(err error,api Api){
err = qmsql.DEFAULTDB.Where("id = ?",id).First(&api).Error
return
}
// 获取所有api信息
func (a *Api)GetAllApis()(err error,apis []Api){
err = qmsql.DEFAULTDB.Find(&apis).Error
func (a *Api) GetApiById(id float64) (err error, api Api) {
err = qmsql.DEFAULTDB.Where("id = ?", id).First(&api).Error
return
}
// 获取所有api信息
func (a *Api) GetAllApis() (err error, apis []Api) {
err = qmsql.DEFAULTDB.Find(&apis).Error
return
}
// 分页获取数据 需要分页实现这个接口即可
func (a *Api) GetInfoList(info modelInterface.PageInfo) (err error, list interface{}, total int) {
@@ -54,7 +55,7 @@ func (a *Api) GetInfoList(info modelInterface.PageInfo) (err error, list interfa
return
} else {
var apiList []Api
err = db.Order("group",true).Find(&apiList).Error
err = db.Order("group", true).Find(&apiList).Error
return err, apiList, total
}
}

View File

@@ -42,7 +42,7 @@ func (m *Menu) GetMenuAuthority(authorityId string) (err error, menus []Menu) {
}
//获取动态路由树
func (m *Menu) GetMenuTree(authorityId float64) (err error, menus []Menu) {
func (m *Menu) GetMenuTree(authorityId string) (err error, menus []Menu) {
err = qmsql.DEFAULTDB.Where("authority_id = ? AND parent_id = ?", authorityId, 0).Find(&menus).Error
for i := 0; i < len(menus); i++ {
err = getChildrenList(&menus[i])

View File

@@ -13,12 +13,12 @@ import (
type User struct {
gorm.Model `json:"-"`
UUID uuid.UUID `json:"uuid"`
Username string `json:"-"`
Username string `json:"userName"`
Password string `json:"-"`
NickName string `json:"nickName" gorm:"default:'QMPlusUser'"`
HeaderImg string `json:"headerImg" gorm:"default:'http://www.henrongyi.top/avatar/lufu.jpg'"`
Authority Authority `json:"authority" form:"ForeignKey:authority_id;AssociationForeignKey:authority_id"`
AuthorityId float64 `json:"-" gorm:"default:888"`
Authority Authority `json:"authority" gorm:"ForeignKey:AuthorityId;AssociationForeignKey:AuthorityId"`
AuthorityId string `json:"-" gorm:"default:888"`
//Propertie // 多余属性自行添加
//PropertieId uint // 自动关联 Propertie 的Id 附加属性过多 建议创建一对一关系
}
@@ -83,7 +83,7 @@ func (u *User) GetInfoList(info modelInterface.PageInfo) (err error, list interf
return
} else {
var userList []User
err = db.Find(&userList).Error
err = db.Preload("Authority").Find(&userList).Error
return err, userList, total
}
}