Browse Source

授权

master
超级管理员 3 years ago
parent
commit
0c9647bc52
  1. 4
      api/version1/jurisdiction/jurisdictionpc/appsystem.go
  2. 51
      api/version1/jurisdiction/jurisdictionpc/power.go
  3. 18
      api/version1/jurisdiction/jurisdictionpc/type.go
  4. 5
      initialization/initviper/init_viper.go
  5. 13
      models/modelssystempermission/appsystem.go

4
api/version1/jurisdiction/jurisdictionpc/appsystem.go

@ -42,6 +42,7 @@ func (a *ApiMethod) AddSystem(c *gin.Context) {
systemCont.Sort = receivedValue.Sort systemCont.Sort = receivedValue.Sort
systemCont.State = 1 systemCont.State = 1
systemCont.Time = time.Now().Unix() systemCont.Time = time.Now().Unix()
systemCont.ApiUrl = receivedValue.ApiUrl
err = overall.CONSTANT_DB_System_Permission.Create(&systemCont).Error err = overall.CONSTANT_DB_System_Permission.Create(&systemCont).Error
if err != nil { if err != nil {
publicmethod.Result(104, err, c) publicmethod.Result(104, err, c)
@ -154,6 +155,9 @@ func (a *ApiMethod) EditSystem(c *gin.Context) {
saveData["`time`"] = time.Now().Unix() saveData["`time`"] = time.Now().Unix()
err = oldSystemCont.EiteCont(where, saveData) err = oldSystemCont.EiteCont(where, saveData)
} }
if receivedValue.ApiUrl != "" && receivedValue.ApiUrl != oldSystemCont.ApiUrl {
saveData["`api_url`"] = receivedValue.ApiUrl
}
if err != nil { if err != nil {
publicmethod.Result(106, err, c) publicmethod.Result(106, err, c)
return return

51
api/version1/jurisdiction/jurisdictionpc/power.go

@ -1,6 +1,7 @@
package jurisdictionpc package jurisdictionpc
import ( import (
"key_performance_indicators/models/modelsschool"
"key_performance_indicators/models/modelssystempermission" "key_performance_indicators/models/modelssystempermission"
"key_performance_indicators/overall" "key_performance_indicators/overall"
"key_performance_indicators/overall/publicmethod" "key_performance_indicators/overall/publicmethod"
@ -89,3 +90,53 @@ func (a *ApiMethod) EditPower(c *gin.Context) {
// overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.Empower{}).Where("`state` = 1 AND `post_id` = ? AND `system` = ?", receivedValue.PostId, receivedValue.SystemName).Not(map[string]interface{}{"point_id": receivedValue.PointId}).Updates(&otherSaveData) // overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.Empower{}).Where("`state` = 1 AND `post_id` = ? AND `system` = ?", receivedValue.PostId, receivedValue.SystemName).Not(map[string]interface{}{"point_id": receivedValue.PointId}).Updates(&otherSaveData)
// publicmethod.Result(0, saveData, c) // publicmethod.Result(0, saveData, c)
} }
// 相关系统菜单
func (a *ApiMethod) SystemAboutMenu(c *gin.Context) {
var receivedValue publicmethod.PublicName
err := c.ShouldBindJSON(&receivedValue)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if receivedValue.Name == "" {
publicmethod.Result(101, err, c)
return
}
var systemPower modelssystempermission.Appsystem
err = systemPower.GetCont(map[string]interface{}{"`system`": receivedValue.Name})
if err != nil {
publicmethod.Result(105, err, c)
return
}
if systemPower.State == 2 {
publicmethod.Result(1, err, c, "该系统授权已经禁用!")
return
}
if systemPower.State == 3 {
publicmethod.Result(1, err, c, "该系统授权已经取消合作!")
return
}
var menuThree []powerThree
if systemPower.ApiUrl != "" {
//api入口不为空的情况下采用get访问方式接收数据
} else {
//api入口为空,采用系统内置获取授权菜单
switch systemPower.Coder {
default:
//获取绩效考核菜单树
menuThree = kpiMenuThree()
}
}
publicmethod.Result(0, menuThree, c)
}
// kpi菜单树
func kpiMenuThree() (menuThree []powerThree) {
var menuList []modelsschool.SystemMenu
err := overall.CONSTANT_DB_Master.Where("`m_steat` = 1").Find(&menuList).Error
if err != nil {
return
}
return
}

18
api/version1/jurisdiction/jurisdictionpc/type.go

@ -26,16 +26,18 @@ type appPowerStruct struct {
// 添加应用系统 // 添加应用系统
type addsystemapp struct { type addsystemapp struct {
publicmethod.PublicName publicmethod.PublicName
Coder string `json:"coder"` Coder string `json:"coder"`
Sort int `json:"sort"` Sort int `json:"sort"`
ApiUrl string `json:"apiurl"`
} }
// 系统应用列表 // 系统应用列表
type systemList struct { type systemList struct {
publicmethod.PagesTurn publicmethod.PagesTurn
publicmethod.PublicName publicmethod.PublicName
Coder string `json:"coder"` Coder string `json:"coder"`
State int `json:"state"` State int `json:"state"`
ApiUrl string `json:"apiurl"`
} }
// 修改应用信息 // 修改应用信息
@ -43,3 +45,11 @@ type editSystemCont struct {
publicmethod.PublicId publicmethod.PublicId
addsystemapp addsystemapp
} }
// 权限菜单树
type powerThree struct {
publicmethod.PublicId
publicmethod.PublicName
Child []powerThree `json:"child"`
}

5
initialization/initviper/init_viper.go

@ -1,6 +1,7 @@
package initviper package initviper
import ( import (
"encoding/json"
"fmt" "fmt"
"key_performance_indicators/overall" "key_performance_indicators/overall"
@ -49,7 +50,7 @@ func RunViper(configInfo interface{}, path ...string) *viper.Viper {
fmt.Printf("配置解析失败!原因:%s\n", errStruct) fmt.Printf("配置解析失败!原因:%s\n", errStruct)
} }
// json.Marshal(configInfo) // json.Marshal(configInfo)
// cfi, _ := json.Marshal(configInfo) cfi, _ := json.Marshal(configInfo)
// fmt.Printf("============>%v\n", string(cfi)) fmt.Printf("============>%v\n", string(cfi))
return v return v
} }

13
models/modelssystempermission/appsystem.go

@ -7,12 +7,13 @@ import (
// 应用系统 // 应用系统
type Appsystem struct { type Appsystem struct {
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"`
Title string `json:"title" gorm:"column:title;type:varchar(255) ;comment:系统名称"` Title string `json:"title" gorm:"column:title;type:varchar(255) ;comment:系统名称"`
Coder string `json:"coder" gorm:"column:coder;type:varchar(255) ;comment:识别符"` Coder string `json:"coder" gorm:"column:coder;type:varchar(255) ;comment:识别符"`
State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"`
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"`
Sort int `json:"sort" gorm:"column:sort;type:int(5) unsigned;default:50;not null;comment:排序"` Sort int `json:"sort" gorm:"column:sort;type:int(5) unsigned;default:50;not null;comment:排序"`
ApiUrl string `json:"apiurl" gorm:"column:api_url;type:varchar(255) ;comment:菜单访问权限列表"`
} }
func (Appsystem *Appsystem) TableName() string { func (Appsystem *Appsystem) TableName() string {

Loading…
Cancel
Save