diff --git a/api/version1/jurisdiction/jurisdictionpc/appsystem.go b/api/version1/jurisdiction/jurisdictionpc/appsystem.go index f79f4c6..cec7054 100644 --- a/api/version1/jurisdiction/jurisdictionpc/appsystem.go +++ b/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 diff --git a/api/version1/jurisdiction/jurisdictionpc/power.go b/api/version1/jurisdiction/jurisdictionpc/power.go index 1192774..a41d664 100644 --- a/api/version1/jurisdiction/jurisdictionpc/power.go +++ b/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 +} diff --git a/api/version1/jurisdiction/jurisdictionpc/type.go b/api/version1/jurisdiction/jurisdictionpc/type.go index f2a1bd6..e0883e2 100644 --- a/api/version1/jurisdiction/jurisdictionpc/type.go +++ b/api/version1/jurisdiction/jurisdictionpc/type.go @@ -26,16 +26,18 @@ type appPowerStruct struct { // 添加应用系统 type addsystemapp struct { publicmethod.PublicName - Coder string `json:"coder"` - Sort int `json:"sort"` + Coder string `json:"coder"` + Sort int `json:"sort"` + ApiUrl string `json:"apiurl"` } // 系统应用列表 type systemList struct { publicmethod.PagesTurn publicmethod.PublicName - Coder string `json:"coder"` - State int `json:"state"` + 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"` +} diff --git a/initialization/initviper/init_viper.go b/initialization/initviper/init_viper.go index 1f9ba0b..670203d 100644 --- a/initialization/initviper/init_viper.go +++ b/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 } diff --git a/models/modelssystempermission/appsystem.go b/models/modelssystempermission/appsystem.go index e1f8da4..06341a8 100644 --- a/models/modelssystempermission/appsystem.go +++ b/models/modelssystempermission/appsystem.go @@ -7,12 +7,13 @@ import ( // 应用系统 type Appsystem struct { - 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:系统名称"` - 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:删除)"` - 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:排序"` + 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:系统名称"` + 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:删除)"` + 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 {