Browse Source

授权

master
herenshan112 7 days ago
parent
commit
4cd9210ffd
  1. 9
      api/version1/customerApp/appControll.go
  2. 2
      api/version1/dataCenter/hander.go
  3. 14
      api/version1/grantpowers/postpower.go
  4. 50
      api/version1/setupRoule/authorization.go
  5. 3
      api/version1/setupRoule/entry.go
  6. 13
      api/version1/taskplatform/taskmanagement/runWorkFlow.go
  7. 61
      models/modelssystempermission/auth_group_power.go
  8. 1
      models/modelssystempermission/auth_power.go
  9. 1
      models/modelssystempermission/power_info.go
  10. 17
      overall/publicmethod/powerRedis.go
  11. 6
      overall/publicmethod/type.go

9
api/version1/customerApp/appControll.go

@ -292,6 +292,13 @@ func (a *ApiMethod) GainAppEditPsge(c *gin.Context) {
json.Unmarshal([]byte(appCont.PowerStr), &appCont.PowerAry) json.Unmarshal([]byte(appCont.PowerStr), &appCont.PowerAry)
// tableFormPage.PowerAry = powAry // tableFormPage.PowerAry = powAry
} }
//获取当前操作人
context, _ := c.Get(overall.MyContJwt)
var myContInfo modelshr.ManCont
jsonCont, _ := json.Marshal(context)
json.Unmarshal(jsonCont, &myContInfo)
//获取权限
myPower := publicmethod.GetMyTableMenuPower(myContInfo.Key, requestData.Id)
sendInfo := publicmethod.MapOut[string]() sendInfo := publicmethod.MapOut[string]()
sendInfo["appName"] = appCont.Name sendInfo["appName"] = appCont.Name
@ -301,6 +308,8 @@ func (a *ApiMethod) GainAppEditPsge(c *gin.Context) {
sendInfo["state"] = appCont.Status sendInfo["state"] = appCont.Status
sendInfo["appSvg"] = appCont.Icon sendInfo["appSvg"] = appCont.Icon
sendInfo["describe"] = appCont.Describe sendInfo["describe"] = appCont.Describe
sendInfo["MyContJwtPower"], sendInfo["MyContJwtPowerErr"] = c.Get(overall.MyContJwtPower)
sendInfo["myPower"] = myPower
if appCont.ListJson != "" { if appCont.ListJson != "" {
var menuTerr []AppMenuTree var menuTerr []AppMenuTree
json.Unmarshal([]byte(appCont.ListJson), &menuTerr) json.Unmarshal([]byte(appCont.ListJson), &menuTerr)

2
api/version1/dataCenter/hander.go

@ -56,7 +56,7 @@ func (a *ApiMethod) GaindataCenter(c *gin.Context) {
} }
// getUrl = url.QueryEscape(getUrl) // getUrl = url.QueryEscape(getUrl)
// fmt.Printf("%T--------->%v\n", getUrl, getUrl) fmt.Printf("%T--------->%v\n", getUrl, getUrl)
getData := publicmethod.CurlGet(getUrl) getData := publicmethod.CurlGet(getUrl)
var sendMap map[string]interface{} var sendMap map[string]interface{}
json.Unmarshal(getData, &sendMap) json.Unmarshal(getData, &sendMap)

14
api/version1/grantpowers/postpower.go

@ -7,6 +7,7 @@ import (
"appPlatform/models/modelssystempermission" "appPlatform/models/modelssystempermission"
"appPlatform/overall" "appPlatform/overall"
"appPlatform/overall/publicmethod" "appPlatform/overall/publicmethod"
"encoding/json"
"fmt" "fmt"
"strconv" "strconv"
"strings" "strings"
@ -530,7 +531,7 @@ func (a *ApiMethod) GainAppTableListNew(c *gin.Context) {
// var appInfo modelAppPlatform.CustomerForm // var appInfo modelAppPlatform.CustomerForm
// appInfo.GetCont(map[string]interface{}{"`signCode`":requestData.Id},"``") // appInfo.GetCont(map[string]interface{}{"`signCode`":requestData.Id},"``")
var custForm []modelAppPlatform.CustomerForm var custForm []modelAppPlatform.CustomerForm
overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.CustomerForm{}).Where("`states` = 1 AND `groupid` = ? AND `classify` IN (2,4)", requestData.Id).Find(&custForm) overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.CustomerForm{}).Where("`states` = 1 AND `groupid` = ? AND `classify` IN (1,2,4)", requestData.Id).Find(&custForm)
var sendList []CusterAppTablePower var sendList []CusterAppTablePower
for _, v := range custForm { for _, v := range custForm {
powerInfo, isOk := CallBackTablePower(v, powerInfo.PowerList) powerInfo, isOk := CallBackTablePower(v, powerInfo.PowerList)
@ -555,6 +556,17 @@ func (a *ApiMethod) GainAppTableListNew(c *gin.Context) {
} }
} }
outData := publicmethod.MapOut[string]()
outData["list"] = sendList
outData["butPower"] = []string{}
//获取app按钮控制
var groupPower modelssystempermission.AuthGroupPower
groupPower.GetCont(map[string]interface{}{"`appType`": requestData.AppType, "`orgPowerType`": requestData.PowerType, "`orgOrUserKey`": roleIdInt})
if groupPower.PowerInfo != "" {
var butPower []string
json.Unmarshal([]byte(groupPower.PowerInfo), &butPower)
outData["butPower"] = butPower
}
publicmethod.Result(0, sendList, c) publicmethod.Result(0, sendList, c)
// publicmethod.Result(0, custForm, c) // publicmethod.Result(0, custForm, c)
} }

50
api/version1/setupRoule/authorization.go

@ -62,6 +62,8 @@ func (a *ApiMethod) SystemAppAuthorization(c *gin.Context) {
default: default:
} }
jsonPowerInfo, _ := json.Marshal(powerInfo) jsonPowerInfo, _ := json.Marshal(powerInfo)
appButPowerJson, _ := json.Marshal(requestData.AppFormButConfig)
err := gormDb.First(&powerMastInfo).Error err := gormDb.First(&powerMastInfo).Error
uuid := publicmethod.GetUUid(1) uuid := publicmethod.GetUUid(1)
oukId, _ := strconv.ParseInt(requestData.RoleId, 10, 64) oukId, _ := strconv.ParseInt(requestData.RoleId, 10, 64)
@ -75,12 +77,14 @@ func (a *ApiMethod) SystemAppAuthorization(c *gin.Context) {
powerMastInfo.Time = time.Now().Unix() //编辑时间 powerMastInfo.Time = time.Now().Unix() //编辑时间
powerMastInfo.IsTrue = istrue //是否有权(1:有;非1:无) powerMastInfo.IsTrue = istrue //是否有权(1:有;非1:无)
powerMastInfo.PowerInfo = string(jsonPowerInfo) //权限结构体" powerMastInfo.PowerInfo = string(jsonPowerInfo) //权限结构体"
powerMastInfo.AppButPower = string(appButPowerJson)
err = overall.CONSTANT_DB_System_Permission.Create(&powerMastInfo).Error err = overall.CONSTANT_DB_System_Permission.Create(&powerMastInfo).Error
} else { } else {
uuid = powerMastInfo.Id uuid = powerMastInfo.Id
saveData := publicmethod.MapOut[string]() saveData := publicmethod.MapOut[string]()
saveData["`isTrue`"] = istrue saveData["`isTrue`"] = istrue
saveData["`powerInfo`"] = string(jsonPowerInfo) saveData["`powerInfo`"] = string(jsonPowerInfo)
saveData["`appButPower`"] = string(appButPowerJson)
saveData["`time`"] = time.Now().Unix() saveData["`time`"] = time.Now().Unix()
var saveInfo modelssystempermission.AuthPower var saveInfo modelssystempermission.AuthPower
err = saveInfo.EiteCont(map[string]interface{}{"`id`": uuid}, saveData) err = saveInfo.EiteCont(map[string]interface{}{"`id`": uuid}, saveData)
@ -89,7 +93,11 @@ func (a *ApiMethod) SystemAppAuthorization(c *gin.Context) {
publicmethod.Result(7, requestData, c, "授权失败!请重新提交授权数据!") publicmethod.Result(7, requestData, c, "授权失败!请重新提交授权数据!")
return return
} }
switch requestData.AppSystem {
case "app":
requestData.EditAuthGroupPower(uuid)
default:
}
//权限拆分 //权限拆分
err = requestData.SplitPermissions(uuid) err = requestData.SplitPermissions(uuid)
if err != nil { if err != nil {
@ -99,6 +107,39 @@ func (a *ApiMethod) SystemAppAuthorization(c *gin.Context) {
publicmethod.Result(0, err, c) publicmethod.Result(0, err, c)
} }
/*
*
@ 作者: 秦东
@ 时间: 2025-12-10 16:44:40
@ 功能: 编辑自定义应用分组授权
*/
func (a *AppSystemInfo) EditAuthGroupPower(uuid int64) {
powerSte, _ := json.Marshal(a.AppSystemConfig)
var groupPower modelssystempermission.AuthGroupPower
err := groupPower.GetCont(map[string]interface{}{"`id`": uuid})
// fmt.Printf("编辑自定义应用分组授权--->%v--->%v\n\n", err, groupPower.Time)
if err != nil || groupPower.Time == 0 {
oukId, _ := strconv.ParseInt(a.RoleId, 10, 64)
var saveGroupPower modelssystempermission.AuthGroupPower
saveGroupPower.Id = uuid
saveGroupPower.AppType = a.AppSystem
saveGroupPower.OrgPowerType = a.PowerType
saveGroupPower.OrgOrUserKey = oukId
saveGroupPower.Time = time.Now().Unix()
saveGroupPower.PowerInfo = string(powerSte)
overall.CONSTANT_DB_System_Permission.Create(&saveGroupPower)
} else {
saveData := publicmethod.MapOut[string]()
saveData["`appType`"] = a.AppSystem
saveData["`orgPowerType`"] = a.PowerType
saveData["`orgOrUserKey`"] = a.RoleId
saveData["`time`"] = time.Now().Unix()
saveData["`powerInfo`"] = string(powerSte)
var saveGroupPower modelssystempermission.AuthGroupPower
saveGroupPower.EiteCont(map[string]interface{}{"`id`": uuid}, saveData)
}
}
/* /*
* *
@ 作者: 秦东 @ 作者: 秦东
@ -131,6 +172,13 @@ func (a *AppSystemInfo) SplitPermissions(uuid int64) error {
lpAry = "[]" lpAry = "[]"
} }
saveInfo.ListPower = lpAry //列表权限 saveInfo.ListPower = lpAry //列表权限
pgButAry := MyCreateTablePower(v.TablePagePower)
if pgButAry == "null" {
pgButAry = "[]"
}
saveInfo.PageButPower = pgButAry //列表权限
saveInfo.VisibleRange = v.DatePower.Types //可见范围(1:本人;2:本岗位;3:本部门;4:本分部;5:指定行政组织;6:所有) saveInfo.VisibleRange = v.DatePower.Types //可见范围(1:本人;2:本岗位;3:本部门;4:本分部;5:指定行政组织;6:所有)
visibleOrgStr, _ := json.Marshal(v.DatePower.Attribute) visibleOrgStr, _ := json.Marshal(v.DatePower.Attribute)
saveInfo.VisibleOrg = string(visibleOrgStr) //可见范围辅助参数 saveInfo.VisibleOrg = string(visibleOrgStr) //可见范围辅助参数

3
api/version1/setupRoule/entry.go

@ -113,6 +113,8 @@ type AppSystemInfo struct {
IsPick bool `json:"isPick"` //当前自定义系统是否可见 IsPick bool `json:"isPick"` //当前自定义系统是否可见
SystemPower []AppPowerTree `json:"sysstemPowerInfo"` //平台系统 SystemPower []AppPowerTree `json:"sysstemPowerInfo"` //平台系统
CustomizeApp []CusterAppTablePower `json:"CustomizeApp"` //自定义表单系统 CustomizeApp []CusterAppTablePower `json:"CustomizeApp"` //自定义表单系统
AppFormButConfig []string `json:"appFormButConfig"` //自定义app 应用按钮级权限
AppSystemConfig []string `json:"appSystemConfig"` //自定义app分组级权限
} }
type CusterAppTablePower struct { type CusterAppTablePower struct {
@ -125,6 +127,7 @@ type CusterAppTablePower struct {
ListIsAll bool `json:"listIsAll"` ListIsAll bool `json:"listIsAll"`
ListPower []string `json:"listPower"` //列表权限 ListPower []string `json:"listPower"` //列表权限
DatePower DatePowerInfo `json:"datePower"` //数据权限 DatePower DatePowerInfo `json:"datePower"` //数据权限
TablePagePower []string `json:"tablePagePower"` //页面授权
} }
type DatePowerInfo struct { type DatePowerInfo struct {

13
api/version1/taskplatform/taskmanagement/runWorkFlow.go

@ -704,6 +704,8 @@ func (a *ApiMethod) GainRunTaskWorkflow(c *gin.Context) {
publicmethod.Result(200, err, c) publicmethod.Result(200, err, c)
return return
} }
fmt.Printf("当前操作人--->%v----->%v\n\n", userCont.Name, userCont.Number)
fmt.Printf("当前操作人--->%v----->%v----->%v\n\n", runFlowInfo.FlowKey, runFlowInfo.RunKey, runFlowInfo.Status)
//判断是否需要回写流程记录 //判断是否需要回写流程记录
flowAry, operational := CheckMakeCopy(runFlowInfo.FlowKey, runFlowInfo.RunKey, runFlowInfo.Status, runFlowInfo.CurrentStep, flowList, userCont) flowAry, operational := CheckMakeCopy(runFlowInfo.FlowKey, runFlowInfo.RunKey, runFlowInfo.Status, runFlowInfo.CurrentStep, flowList, userCont)
if runFlowInfo.Status != 3 { if runFlowInfo.Status != 3 {
@ -750,9 +752,11 @@ func CheckMakeCopy(uuid, runKey int64, state int, currepStep int, flowList []Run
userKey := strconv.FormatInt(userCont.Key, 10) userKey := strconv.FormatInt(userCont.Key, 10)
var cureeNode RunFlow var cureeNode RunFlow
for i := 0; i < len(flowList); i++ { //梳理抄送节点 for i := 0; i < len(flowList); i++ { //梳理抄送节点
fmt.Printf("解析步骤--->%v--->%v--->%v--->%v\n\n", i, flowList[i].Step, endStep, flowList[i].Step == endStep)
if flowList[i].Step == endStep { if flowList[i].Step == endStep {
cureeNode = flowList[i] cureeNode = flowList[i]
switch flowList[i].ExamineMode { switch flowList[i].ExamineMode {
case 1: case 1:
operational = ApprovalInSequence(flowList[i].Operator, userCont) operational = ApprovalInSequence(flowList[i].Operator, userCont)
@ -767,7 +771,8 @@ func CheckMakeCopy(uuid, runKey int64, state int, currepStep int, flowList []Run
} }
} }
} }
// fmt.Printf("currepStep:%v---->endStep:%v\n", flowList[i].ExamineMode, operational) // fmt.Printf("解析步骤--->%v--->%v--->%v\n\n", i, cureeNode, flowList[i].Operator)
fmt.Printf("currepStep:%v---->endStep:%v\n", flowList[i].ExamineMode, operational)
} }
if flowList[i].Types != 0 { if flowList[i].Types != 0 {
if flowList[i].Step <= endStep { if flowList[i].Step <= endStep {
@ -917,10 +922,10 @@ func ApprovalInSequence(Operator []OperatorList, userCont modelshr.ManCont) bool
minVal = len(v.LogList) minVal = len(v.LogList)
} }
} }
// fmt.Printf("依次审批--a-->%v---->%v---->%v\n", minVal, len(Operator), allAry) fmt.Printf("依次审批--a-->%v---->%v---->%v\n", minVal, len(Operator), allAry)
if minVal == 0 { if minVal == 0 {
for i, v := range Operator { for i, v := range Operator {
// fmt.Printf("依次审批---->%v---->%v\n", i, v.Name) fmt.Printf("依次审批---->%v---->%v\n", i, v.Name, v.Id, userKey)
if v.Id == userKey { if v.Id == userKey {
if i == 0 { if i == 0 {
return true return true
@ -929,7 +934,7 @@ func ApprovalInSequence(Operator []OperatorList, userCont modelshr.ManCont) bool
} }
return false return false
} }
// fmt.Printf("依次审批--b-->%v---->%v---->%v\n", minVal, len(Operator), allAry)
endTrue := true endTrue := true
if allAry >= 2 { if allAry >= 2 {
for i := 0; i < allAry-2; i++ { for i := 0; i < allAry-2; i++ {

61
models/modelssystempermission/auth_group_power.go

@ -0,0 +1,61 @@
package modelssystempermission
import (
"appPlatform/overall"
"strings"
)
// 自定义应用分组授权
type AuthGroupPower struct {
Id int64 `gorm:"column:id;type:bigint(20) unsigned;primary_key" json:"id"`
AppType string `gorm:"column:appType;type:varchar(30);comment:系统类型(system:系统平台;app:自定义表单与应用)" json:"appType"`
OrgPowerType string `gorm:"column:orgPowerType;type:varchar(20);comment:赋权类型(org:组织;job:岗位;role:角色;person:个人)" json:"orgPowerType"`
OrgOrUserKey int64 `gorm:"column:orgOrUserKey;type:bigint(20) unsigned;default:0;comment:行政组织或角色、人员识别符;NOT NULL" json:"orgOrUserKey"`
Time int64 `gorm:"column:time;type:bigint(20) unsigned;default:0;comment:编辑时间;NOT NULL" json:"time"`
PowerInfo string `gorm:"column:powerInfo;type:text;comment:权限结构体" json:"powerInfo"`
}
func (cont *AuthGroupPower) TableName() string {
return "auth_group_power"
}
// 编辑内容
func (cont *AuthGroupPower) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Updates(saveData).Error
return
}
// 获取内容
func (cont *AuthGroupPower) GetCont(whereMap interface{}, field ...string) (err error) {
gormDb := overall.CONSTANT_DB_System_Permission.Model(&cont)
if len(field) > 0 {
fieldStr := strings.Join(field, ",")
gormDb = gormDb.Select(fieldStr)
}
gormDb = gormDb.Where(whereMap)
err = gormDb.First(&cont).Error
return
}
// 根据条件获取总数
func (cont *AuthGroupPower) CountCont(whereMap interface{}) (countId int64) {
overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Count(&countId)
return
}
// 读取全部信息
func (cont *AuthGroupPower) ContMap(whereMap interface{}, field ...string) (countAry []AuthGroupPower, err error) {
gormDb := overall.CONSTANT_DB_System_Permission.Model(&cont)
if len(field) > 0 {
fieldStr := strings.Join(field, ",")
gormDb = gormDb.Select(fieldStr)
}
err = gormDb.Where(whereMap).Find(&countAry).Error
return
}
// 删除内容
func (cont *AuthGroupPower) DelCont(whereMap interface{}) (err error) {
err = overall.CONSTANT_DB_System_Permission.Where(whereMap).Delete(&cont).Error
return
}

1
models/modelssystempermission/auth_power.go

@ -15,6 +15,7 @@ type AuthPower struct {
Time int64 `gorm:"column:time;type:bigint(20) unsigned;default:0;comment:编辑时间;NOT NULL" json:"time"` Time int64 `gorm:"column:time;type:bigint(20) unsigned;default:0;comment:编辑时间;NOT NULL" json:"time"`
IsTrue int `gorm:"column:isTrue;type:int(1) unsigned;default:0;comment:是否有权(1:有;非1:无);NOT NULL" json:"isTrue"` IsTrue int `gorm:"column:isTrue;type:int(1) unsigned;default:0;comment:是否有权(1:有;非1:无);NOT NULL" json:"isTrue"`
PowerInfo string `gorm:"column:powerInfo;type:text;comment:权限结构体" json:"powerInfo"` PowerInfo string `gorm:"column:powerInfo;type:text;comment:权限结构体" json:"powerInfo"`
AppButPower string `gorm:"column:appButPower;type:text;comment:自定义应用按钮授权" json:"appButPower"`
} }
func (cont *AuthPower) TableName() string { func (cont *AuthPower) TableName() string {

1
models/modelssystempermission/power_info.go

@ -17,6 +17,7 @@ type PowerInfo struct {
VisibleOrg string `gorm:"column:visibleOrg;type:text;comment:可见范围辅助参数" json:"visibleOrg"` VisibleOrg string `gorm:"column:visibleOrg;type:text;comment:可见范围辅助参数" json:"visibleOrg"`
ButPower string `gorm:"column:butPower;type:text;comment:按钮权限" json:"butPower"` ButPower string `gorm:"column:butPower;type:text;comment:按钮权限" json:"butPower"`
Time int64 `gorm:"column:time;type:bigint(20) unsigned;default:0;comment:编辑时间;NOT NULL" json:"time"` Time int64 `gorm:"column:time;type:bigint(20) unsigned;default:0;comment:编辑时间;NOT NULL" json:"time"`
PageButPower string `gorm:"column:pageButPower;type:text;comment:页面表单权限" json:"pageButPower"`
} }
func (cont *PowerInfo) TableName() string { func (cont *PowerInfo) TableName() string {

17
overall/publicmethod/powerRedis.go

@ -51,3 +51,20 @@ func GetMyMenuPower(userKey int64, menuId string) (menuPower SystemInfoPower) {
} }
return return
} }
/*
*
@ 作者: 秦东
@ 时间: 2025-12-10 13:31:59
@ 功能: 获取自定义应用表单权限
*/
func GetMyTableMenuPower(userKey int64, menuId string) (menuPower SendAppTabelPower) {
myPower := GetSystemPowerInfo(userKey)
for _, v := range myPower.AppSystemPower {
if v.AppId == menuId {
menuPower.FormPower = v.FormPower
menuPower.FormTrue = v.FormTrue
}
}
return
}

6
overall/publicmethod/type.go

@ -456,3 +456,9 @@ type OrgIdLevel struct {
Id int64 Id int64
Level int64 Level int64
} }
// app相关输出
type SendAppTabelPower struct {
FormTrue []string `json:"formTrue"`
FormPower []AppMyPowerTable `json:"formPower"`
}

Loading…
Cancel
Save