diff --git a/api/version1/customerApp/appControll.go b/api/version1/customerApp/appControll.go index bb7f5a1..b97fda2 100644 --- a/api/version1/customerApp/appControll.go +++ b/api/version1/customerApp/appControll.go @@ -292,6 +292,13 @@ func (a *ApiMethod) GainAppEditPsge(c *gin.Context) { json.Unmarshal([]byte(appCont.PowerStr), &appCont.PowerAry) // 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["appName"] = appCont.Name @@ -301,6 +308,8 @@ func (a *ApiMethod) GainAppEditPsge(c *gin.Context) { sendInfo["state"] = appCont.Status sendInfo["appSvg"] = appCont.Icon sendInfo["describe"] = appCont.Describe + sendInfo["MyContJwtPower"], sendInfo["MyContJwtPowerErr"] = c.Get(overall.MyContJwtPower) + sendInfo["myPower"] = myPower if appCont.ListJson != "" { var menuTerr []AppMenuTree json.Unmarshal([]byte(appCont.ListJson), &menuTerr) diff --git a/api/version1/dataCenter/hander.go b/api/version1/dataCenter/hander.go index 4b4284f..3516324 100644 --- a/api/version1/dataCenter/hander.go +++ b/api/version1/dataCenter/hander.go @@ -56,7 +56,7 @@ func (a *ApiMethod) GaindataCenter(c *gin.Context) { } // getUrl = url.QueryEscape(getUrl) - // fmt.Printf("%T--------->%v\n", getUrl, getUrl) + fmt.Printf("%T--------->%v\n", getUrl, getUrl) getData := publicmethod.CurlGet(getUrl) var sendMap map[string]interface{} json.Unmarshal(getData, &sendMap) diff --git a/api/version1/grantpowers/postpower.go b/api/version1/grantpowers/postpower.go index 6aba0ae..deec678 100644 --- a/api/version1/grantpowers/postpower.go +++ b/api/version1/grantpowers/postpower.go @@ -7,6 +7,7 @@ import ( "appPlatform/models/modelssystempermission" "appPlatform/overall" "appPlatform/overall/publicmethod" + "encoding/json" "fmt" "strconv" "strings" @@ -530,7 +531,7 @@ func (a *ApiMethod) GainAppTableListNew(c *gin.Context) { // var appInfo modelAppPlatform.CustomerForm // appInfo.GetCont(map[string]interface{}{"`signCode`":requestData.Id},"``") 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 for _, v := range custForm { 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, custForm, c) } diff --git a/api/version1/setupRoule/authorization.go b/api/version1/setupRoule/authorization.go index ebc5dd8..93fdf4d 100644 --- a/api/version1/setupRoule/authorization.go +++ b/api/version1/setupRoule/authorization.go @@ -62,6 +62,8 @@ func (a *ApiMethod) SystemAppAuthorization(c *gin.Context) { default: } jsonPowerInfo, _ := json.Marshal(powerInfo) + + appButPowerJson, _ := json.Marshal(requestData.AppFormButConfig) err := gormDb.First(&powerMastInfo).Error uuid := publicmethod.GetUUid(1) oukId, _ := strconv.ParseInt(requestData.RoleId, 10, 64) @@ -75,12 +77,14 @@ func (a *ApiMethod) SystemAppAuthorization(c *gin.Context) { powerMastInfo.Time = time.Now().Unix() //编辑时间 powerMastInfo.IsTrue = istrue //是否有权(1:有;非1:无) powerMastInfo.PowerInfo = string(jsonPowerInfo) //权限结构体" + powerMastInfo.AppButPower = string(appButPowerJson) err = overall.CONSTANT_DB_System_Permission.Create(&powerMastInfo).Error } else { uuid = powerMastInfo.Id saveData := publicmethod.MapOut[string]() saveData["`isTrue`"] = istrue saveData["`powerInfo`"] = string(jsonPowerInfo) + saveData["`appButPower`"] = string(appButPowerJson) saveData["`time`"] = time.Now().Unix() var saveInfo modelssystempermission.AuthPower 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, "授权失败!请重新提交授权数据!") return } - + switch requestData.AppSystem { + case "app": + requestData.EditAuthGroupPower(uuid) + default: + } //权限拆分 err = requestData.SplitPermissions(uuid) if err != nil { @@ -99,6 +107,39 @@ func (a *ApiMethod) SystemAppAuthorization(c *gin.Context) { 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) + } +} + /* * @ 作者: 秦东 @@ -130,7 +171,14 @@ func (a *AppSystemInfo) SplitPermissions(uuid int64) error { if lpAry == "null" { 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:所有) visibleOrgStr, _ := json.Marshal(v.DatePower.Attribute) saveInfo.VisibleOrg = string(visibleOrgStr) //可见范围辅助参数 diff --git a/api/version1/setupRoule/entry.go b/api/version1/setupRoule/entry.go index 8f55cd4..35bdc9f 100644 --- a/api/version1/setupRoule/entry.go +++ b/api/version1/setupRoule/entry.go @@ -106,25 +106,28 @@ type SendPowerPage struct { } type AppSystemInfo struct { - PowerType string `json:"powerType"` //权限分组 - RoleId string `json:"roleId"` //权限个体Id - AppSystem string `json:"appSystem"` //系统分类 - AppId string `json:"appId"` //子系统ID - IsPick bool `json:"isPick"` //当前自定义系统是否可见 - SystemPower []AppPowerTree `json:"sysstemPowerInfo"` //平台系统 - CustomizeApp []CusterAppTablePower `json:"CustomizeApp"` //自定义表单系统 + PowerType string `json:"powerType"` //权限分组 + RoleId string `json:"roleId"` //权限个体Id + AppSystem string `json:"appSystem"` //系统分类 + AppId string `json:"appId"` //子系统ID + IsPick bool `json:"isPick"` //当前自定义系统是否可见 + SystemPower []AppPowerTree `json:"sysstemPowerInfo"` //平台系统 + CustomizeApp []CusterAppTablePower `json:"CustomizeApp"` //自定义表单系统 + AppFormButConfig []string `json:"appFormButConfig"` //自定义app 应用按钮级权限 + AppSystemConfig []string `json:"appSystemConfig"` //自定义app分组级权限 } type CusterAppTablePower struct { - Id string `json:"id"` //表单ID - Name string `json:"name"` //表单名称 - SignCode string `json:"signCode"` //表单识别符 - IsTrue bool `json:"isTrue"` - TableIsAll bool `json:"tableIsAll"` - TablePower []string `json:"tablePower"` //表单权限 - ListIsAll bool `json:"listIsAll"` - ListPower []string `json:"listPower"` //列表权限 - DatePower DatePowerInfo `json:"datePower"` //数据权限 + Id string `json:"id"` //表单ID + Name string `json:"name"` //表单名称 + SignCode string `json:"signCode"` //表单识别符 + IsTrue bool `json:"isTrue"` + TableIsAll bool `json:"tableIsAll"` + TablePower []string `json:"tablePower"` //表单权限 + ListIsAll bool `json:"listIsAll"` + ListPower []string `json:"listPower"` //列表权限 + DatePower DatePowerInfo `json:"datePower"` //数据权限 + TablePagePower []string `json:"tablePagePower"` //页面授权 } type DatePowerInfo struct { diff --git a/api/version1/taskplatform/taskmanagement/runWorkFlow.go b/api/version1/taskplatform/taskmanagement/runWorkFlow.go index 7254692..8ac228f 100644 --- a/api/version1/taskplatform/taskmanagement/runWorkFlow.go +++ b/api/version1/taskplatform/taskmanagement/runWorkFlow.go @@ -704,6 +704,8 @@ func (a *ApiMethod) GainRunTaskWorkflow(c *gin.Context) { publicmethod.Result(200, err, c) 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) 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) var cureeNode RunFlow 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 { cureeNode = flowList[i] + switch flowList[i].ExamineMode { case 1: 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].Step <= endStep { @@ -917,10 +922,10 @@ func ApprovalInSequence(Operator []OperatorList, userCont modelshr.ManCont) bool 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 { 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 i == 0 { return true @@ -929,7 +934,7 @@ func ApprovalInSequence(Operator []OperatorList, userCont modelshr.ManCont) bool } return false } - + // fmt.Printf("依次审批--b-->%v---->%v---->%v\n", minVal, len(Operator), allAry) endTrue := true if allAry >= 2 { for i := 0; i < allAry-2; i++ { diff --git a/models/modelssystempermission/auth_group_power.go b/models/modelssystempermission/auth_group_power.go new file mode 100644 index 0000000..e1532cb --- /dev/null +++ b/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 +} diff --git a/models/modelssystempermission/auth_power.go b/models/modelssystempermission/auth_power.go index e4a0497..2500405 100644 --- a/models/modelssystempermission/auth_power.go +++ b/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"` 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"` + AppButPower string `gorm:"column:appButPower;type:text;comment:自定义应用按钮授权" json:"appButPower"` } func (cont *AuthPower) TableName() string { diff --git a/models/modelssystempermission/power_info.go b/models/modelssystempermission/power_info.go index df80cf4..ba16054 100644 --- a/models/modelssystempermission/power_info.go +++ b/models/modelssystempermission/power_info.go @@ -17,6 +17,7 @@ type PowerInfo struct { VisibleOrg string `gorm:"column:visibleOrg;type:text;comment:可见范围辅助参数" json:"visibleOrg"` 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"` + PageButPower string `gorm:"column:pageButPower;type:text;comment:页面表单权限" json:"pageButPower"` } func (cont *PowerInfo) TableName() string { diff --git a/overall/publicmethod/powerRedis.go b/overall/publicmethod/powerRedis.go index 0e56239..d2c3166 100644 --- a/overall/publicmethod/powerRedis.go +++ b/overall/publicmethod/powerRedis.go @@ -51,3 +51,20 @@ func GetMyMenuPower(userKey int64, menuId string) (menuPower SystemInfoPower) { } 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 +} diff --git a/overall/publicmethod/type.go b/overall/publicmethod/type.go index 55b1252..4d3d192 100644 --- a/overall/publicmethod/type.go +++ b/overall/publicmethod/type.go @@ -456,3 +456,9 @@ type OrgIdLevel struct { Id int64 Level int64 } + +// app相关输出 +type SendAppTabelPower struct { + FormTrue []string `json:"formTrue"` + FormPower []AppMyPowerTable `json:"formPower"` +}