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. 10
      api/version1/jurisdiction/jurisdictionpc/type.go
  4. 5
      initialization/initviper/init_viper.go
  5. 1
      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.State = 1
systemCont.Time = time.Now().Unix()
systemCont.ApiUrl = receivedValue.ApiUrl
err = overall.CONSTANT_DB_System_Permission.Create(&systemCont).Error
if err != nil {
publicmethod.Result(104, err, c)
@ -154,6 +155,9 @@ func (a *ApiMethod) EditSystem(c *gin.Context) {
saveData["`time`"] = time.Now().Unix()
err = oldSystemCont.EiteCont(where, saveData)
}
if receivedValue.ApiUrl != "" && receivedValue.ApiUrl != oldSystemCont.ApiUrl {
saveData["`api_url`"] = receivedValue.ApiUrl
}
if err != nil {
publicmethod.Result(106, err, c)
return

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

@ -1,6 +1,7 @@
package jurisdictionpc
import (
"key_performance_indicators/models/modelsschool"
"key_performance_indicators/models/modelssystempermission"
"key_performance_indicators/overall"
"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)
// 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
}

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

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

5
initialization/initviper/init_viper.go

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

1
models/modelssystempermission/appsystem.go

@ -13,6 +13,7 @@ type Appsystem struct {
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:创建时间"`
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 {

Loading…
Cancel
Save