10 changed files with 942 additions and 1 deletions
@ -0,0 +1,246 @@ |
|||||
|
package customerform |
||||
|
|
||||
|
import ( |
||||
|
datacenter "appPlatform/api/version1/dataCenter" |
||||
|
"appPlatform/middleware/grocerystore" |
||||
|
"appPlatform/models/customerForm" |
||||
|
"appPlatform/models/modelAppPlatform" |
||||
|
"appPlatform/models/modelshr" |
||||
|
"appPlatform/overall" |
||||
|
"appPlatform/overall/publicmethod" |
||||
|
"encoding/json" |
||||
|
"fmt" |
||||
|
"strconv" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-05-22 10:44:33 |
||||
|
@ 功能: 获取App表单翻页列表数据 |
||||
|
@ 参数 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 返回值 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 方法原型 |
||||
|
|
||||
|
# |
||||
|
*/ |
||||
|
func (a *ApiMethod) GainFormPageListContNew(c *gin.Context) { |
||||
|
var requestData FormPageListAttr |
||||
|
err := c.ShouldBindJSON(&requestData) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(100, err, c) |
||||
|
return |
||||
|
} |
||||
|
if requestData.FormId == "" { |
||||
|
publicmethod.Result(1, err, c, "未知表单!无法获取字段!2") |
||||
|
return |
||||
|
} |
||||
|
if requestData.Page == 0 { |
||||
|
requestData.Page = 1 |
||||
|
} |
||||
|
if requestData.PageSize == 0 { |
||||
|
requestData.Page = 20 |
||||
|
} |
||||
|
context, _ := c.Get(overall.MyContJwt) |
||||
|
var userCont modelshr.ManCont |
||||
|
userCont.GetLoginCont(context) //当前操作人
|
||||
|
|
||||
|
//获取表单数据
|
||||
|
var formInfo modelAppPlatform.CustomerFormView |
||||
|
err = formInfo.GetCont(map[string]interface{}{"`cfid`": requestData.FormId, "`status`": 1}, "`tablekey`", "`table_structure`", "`mastesform`", "`mastesformjson`", "`listjson`", "`flowIsOpen`", "`flowkey`", "`groupid`", "`id`") |
||||
|
if err != nil { |
||||
|
publicmethod.Result(1, err, c, "未知表单!无法获取字段!") |
||||
|
return |
||||
|
} |
||||
|
//解析表单列表数据结构
|
||||
|
var formJsonCont CustomerFormMaster |
||||
|
json.Unmarshal([]byte(formInfo.MastesFormJson), &formJsonCont) |
||||
|
//解析表格组件数据
|
||||
|
var sunMap map[string]string |
||||
|
json.Unmarshal([]byte(formInfo.TableStructure), &sunMap) |
||||
|
|
||||
|
//判断当前数据源来源于什么地方
|
||||
|
if formJsonCont.Form.DataSource == "yes" { //采用外部数据源
|
||||
|
//Step 1 打开数据源
|
||||
|
var sqlDb datacenter.DataBastType |
||||
|
sqlDb.Type = formJsonCont.Form.DataSourceConfig.DSN.SqlType |
||||
|
sqlDb.Ip = formJsonCont.Form.DataSourceConfig.DSN.Ip |
||||
|
sqlDb.DataBaseName = formJsonCont.Form.DataSourceConfig.DSN.DataBaseName |
||||
|
sqlDb.Port = formJsonCont.Form.DataSourceConfig.DSN.Port |
||||
|
sqlDb.UserName = formJsonCont.Form.DataSourceConfig.DSN.UserName |
||||
|
sqlDb.Pwd = formJsonCont.Form.DataSourceConfig.DSN.Password |
||||
|
sqlDborm, err := sqlDb.StartDataBast() |
||||
|
if err != nil { |
||||
|
sqlDborm, err = datacenter.GainDataStorce(formJsonCont.Form.DataSourceConfig.Id) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(0, sqlDb, c) |
||||
|
return |
||||
|
} |
||||
|
} |
||||
|
//Step 2 使用数据源处理数据
|
||||
|
gormDb := sqlDborm.Table(formJsonCont.Form.DataSourceConfig.TableKey) //确定使用哪个库
|
||||
|
gormDb = gormDb.Where("`states` BETWEEN ? AND ?", 1, 2) //基础查询条件
|
||||
|
gormDb = AnalysisSerachTermSql(requestData.SearchData, gormDb) //处理查询条件
|
||||
|
//Step 3 权限处理
|
||||
|
var powerSearch publicmethod.GainUserPower |
||||
|
powerSearch.SystemName = "appsystem" //系统名称
|
||||
|
powerSearch.RoleId = userCont.Role //角色列表
|
||||
|
powerSearch.OrgId = userCont.AdminOrg //行政组织
|
||||
|
powerSearch.PostId = userCont.Position //岗位
|
||||
|
powerSearch.AppKey = formInfo.Groupid //归属哪个App
|
||||
|
powerSearch.TableId = formInfo.Id //归属哪个表格
|
||||
|
gormDb = powerSearch.MakeSearchSql(gormDb, userCont, formJsonCont.Form.DataSource) |
||||
|
//Step 4 获取一共有多少条数据
|
||||
|
var total int64 |
||||
|
totalErr := gormDb.Count(&total).Error |
||||
|
if totalErr != nil { |
||||
|
total = 0 |
||||
|
} |
||||
|
//Step 5 获取每页具体数据
|
||||
|
var formList []map[string]interface{} |
||||
|
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize) |
||||
|
err = gormDb.Order("`id` DESC").Find(&formList).Error |
||||
|
if err != nil && len(formList) < 1 { |
||||
|
publicmethod.Result(0, err, c) |
||||
|
return |
||||
|
} |
||||
|
//Setp 6 列表字段与数据绑定
|
||||
|
var listFieldsMap ListPageFields |
||||
|
if formInfo.ListJson != "" { |
||||
|
err = json.Unmarshal([]byte(formInfo.ListJson), &listFieldsMap) |
||||
|
if err == nil { |
||||
|
formList = listFieldsMap.DevelopSpecificationsSend(formList, formJsonCont) |
||||
|
} |
||||
|
} |
||||
|
//Setp 7 处理信息任务状态
|
||||
|
for i, v := range formList { |
||||
|
formList[i]["isRetract"] = false //是否可撤回
|
||||
|
var masterKey int64 |
||||
|
if mastrKeyVal, isOk := v["masters_key"]; isOk { |
||||
|
masterKeyVal := publicmethod.TypeToInterface(mastrKeyVal) |
||||
|
masterKey, _ = publicmethod.StringToInt64(mastrKeyVal) //表单数据唯一识别码
|
||||
|
formList[i]["masters_key"] = masterKeyVal |
||||
|
//获取Redsi
|
||||
|
redisKey := fmt.Sprintf("SendMsg:Work_WeChat_%v", masterKeyVal) |
||||
|
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS3) |
||||
|
formList[i]["retract_true"], _ = redisClient.Get(redisKey) |
||||
|
//获取任务详情
|
||||
|
var taskInfo customerForm.TaskRecord |
||||
|
overall.CONSTANT_DB_CustomerForm.Where("`masters_key` = ?", mastrKeyVal).First(&taskInfo) |
||||
|
formList[i]["runFlowId"] = strconv.FormatInt(taskInfo.RunFlowId, 10) |
||||
|
if mastrKey, ok := formList[i]["runFlowId"]; ok { //流程执行编号
|
||||
|
mastrKeyInt, _ := publicmethod.StringToInt64(mastrKey) |
||||
|
if mastrKeyInt != 0 { //存在流程
|
||||
|
//获取流程信息
|
||||
|
var runFlowInfo customerForm.RunWorkflow |
||||
|
runFlowInfo.GetCont(map[string]interface{}{"`id`": mastrKey}, "`id`", "`current_step`", "`next_step`") |
||||
|
formList[i]["runFlowInfo"] = strconv.FormatInt(runFlowInfo.Id, 10) |
||||
|
if taskInfo.Status == 3 && runFlowInfo.NextStep != 0 { //判断流程是否还在审批中
|
||||
|
if runFlowInfo.CurrentStep == 1 { |
||||
|
if createrName, ok := formList[i]["creater"].(string); ok { |
||||
|
if createrName == userCont.Name { |
||||
|
formList[i]["isRetract"] = true |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
for _, sv := range sunMap { |
||||
|
formList[i][sv] = gainMasterSunList(sv, masterKey, formJsonCont, sqlDborm) |
||||
|
} |
||||
|
} |
||||
|
//Setp 8 输出分页数据
|
||||
|
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(formList)), formList, c) |
||||
|
} else { //采用系统数据源
|
||||
|
//Step 1 使用数据源打开数据库表
|
||||
|
var formList []map[string]interface{} |
||||
|
tableName := fmt.Sprintf("`%v` as f", formInfo.TableKey) |
||||
|
gormDb := overall.CONSTANT_DB_CustomerForm.Table(tableName).Select("f.*,t.status as taskStatus,t.runFlowId") |
||||
|
gormDb = gormDb.Joins("LEFT JOIN `taskrecord` as t ON f.masters_key = t.masters_key") |
||||
|
gormDb = gormDb.Where("f.`states` BETWEEN ? AND ?", 1, 2) //基础查询条件
|
||||
|
gormDb = AnalysisSerachTermSql(requestData.SearchData, gormDb) //处理查询条件
|
||||
|
//Step 2 权限处理
|
||||
|
var powerSearch publicmethod.GainUserPower |
||||
|
powerSearch.SystemName = "appsystem" //系统名称
|
||||
|
powerSearch.RoleId = userCont.Role //角色列表
|
||||
|
powerSearch.OrgId = userCont.AdminOrg //行政组织
|
||||
|
powerSearch.PostId = userCont.Position //岗位
|
||||
|
powerSearch.AppKey = formInfo.Groupid //归属哪个App
|
||||
|
powerSearch.TableId = formInfo.Id //归属哪个表格
|
||||
|
gormDb = powerSearch.MakeSearchSql(gormDb, userCont, formJsonCont.Form.DataSource) |
||||
|
//Step 3 获取一共有多少条数据
|
||||
|
var total int64 |
||||
|
totalErr := gormDb.Count(&total).Error |
||||
|
if totalErr != nil { |
||||
|
total = 0 |
||||
|
} |
||||
|
//Step 4 翻页配置
|
||||
|
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize) |
||||
|
err = gormDb.Order("f.`id` DESC").Find(&formList).Error |
||||
|
if err != nil && len(formList) < 1 { |
||||
|
publicmethod.Result(0, err, c) |
||||
|
return |
||||
|
} |
||||
|
var listFieldsMap ListPageFields |
||||
|
if formInfo.ListJson != "" { |
||||
|
err = json.Unmarshal([]byte(formInfo.ListJson), &listFieldsMap) |
||||
|
if err == nil { |
||||
|
formList = listFieldsMap.DevelopSpecificationsSend(formList, formJsonCont) |
||||
|
} |
||||
|
} |
||||
|
//获取任务状态
|
||||
|
for i, v := range formList { |
||||
|
formList[i]["isRetract"] = false |
||||
|
if mastrKey, ok := v["runFlowId"]; ok { |
||||
|
mastrKeyInt, _ := publicmethod.StringToInt64(mastrKey) |
||||
|
if mastrKeyInt != 0 { |
||||
|
var runFlowInfo customerForm.RunWorkflow |
||||
|
runFlowInfo.GetCont(map[string]interface{}{"`id`": mastrKey}, "`id`", "`current_step`", "`next_step`") |
||||
|
formList[i]["runFlowInfo"] = runFlowInfo.Id |
||||
|
if stateVal, ok := v["taskStatus"]; ok { |
||||
|
if stauval, ok := stateVal.(string); ok { |
||||
|
if stauval == "3" && runFlowInfo.NextStep != 0 { |
||||
|
|
||||
|
if runFlowInfo.CurrentStep == 1 { |
||||
|
if createrName, ok := formList[i]["creater"].(string); ok { |
||||
|
if createrName == userCont.Name { |
||||
|
formList[i]["isRetract"] = true |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
var masterKey int64 |
||||
|
if mastrKeyVal, ok := v["masters_key"]; ok { |
||||
|
masterKey, _ = publicmethod.StringToInt64(mastrKeyVal) |
||||
|
masterKeyVal := publicmethod.TypeToInterface(mastrKeyVal) |
||||
|
if mastrKeyUint64, ok := mastrKeyVal.(uint64); ok { |
||||
|
formList[i]["masters_key"] = strconv.FormatUint(mastrKeyUint64, 10) |
||||
|
} |
||||
|
redisKey := fmt.Sprintf("SendMsg:Work_WeChat_%v", masterKeyVal) |
||||
|
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS3) |
||||
|
formList[i]["retract_true"], _ = redisClient.Get(redisKey) |
||||
|
} |
||||
|
for _, sv := range sunMap { |
||||
|
formList[i][sv] = gainMasterSunList(sv, masterKey, formJsonCont, overall.CONSTANT_DB_CustomerForm) |
||||
|
} |
||||
|
} |
||||
|
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(formList)), formList, c) |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,69 @@ |
|||||
|
package modelssystempermission |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/overall" |
||||
|
"strings" |
||||
|
) |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-05-19 14:01:12 |
||||
|
@ 功能: 自定义表单权限设置 |
||||
|
*/ |
||||
|
type CustomTableAuthorize struct { |
||||
|
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` // 编辑时间
|
||||
|
Roleid int64 `json:"role_id" gorm:"column:role_id;type:bigint(20) unsigned;default:0;not null;comment:角色ID"` // 角色ID
|
||||
|
TableSignCode int64 `json:"table_sign_code" gorm:"column:table_sign_code;type:bigint(20) unsigned;default:0;not null;comment:app表格唯一识别符"` // app表格唯一识别符
|
||||
|
AppCignCode int64 `json:"app_sign_code" gorm:"column:app_sign_code;type:bigint(20) unsigned;default:0;not null;comment:归谁哪个App"` // 归谁哪个App
|
||||
|
TablePower string `json:"table_power" gorm:column:table_power;type:varchar(255) ;comment:表格权限"` // 表格权限
|
||||
|
ListPower string `json:"list_power" gorm:"column:list_power;type:varchar(255) ;comment:列表权限"` // 列表权限
|
||||
|
PowerLerver int `json:"power_lerver" gorm:"column:power_lerver;type:tinyint(1) unsigned;default:1;not null;comment:授权范围等级(1:本岗位;2:本部门;3:本分部;4:指定行政组织;5:所有)"` // 授权范围等级(1:本岗位;2:本部门;3:本分部;4:指定行政组织;5:所有)
|
||||
|
Organization string `json:"organization" gorm:"column:organization;type:text;comment:授权范围属性"` // 授权范围属性
|
||||
|
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` // 编辑时间
|
||||
|
} |
||||
|
|
||||
|
func (CustomTableAuthorize *CustomTableAuthorize) TableName() string { |
||||
|
return "custom_table_authorize" |
||||
|
} |
||||
|
|
||||
|
// 编辑内容
|
||||
|
func (cont *CustomTableAuthorize) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
||||
|
err = overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Updates(saveData).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 获取内容
|
||||
|
func (cont *CustomTableAuthorize) 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 *CustomTableAuthorize) CountCont(whereMap interface{}) (countId int64) { |
||||
|
overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Count(&countId) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 读取全部信息
|
||||
|
func (cont *CustomTableAuthorize) ContMap(whereMap interface{}, field ...string) (countAry []CustomTableAuthorize, 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 *CustomTableAuthorize) DelCont(whereMap interface{}) (err error) { |
||||
|
err = overall.CONSTANT_DB_System_Permission.Where(whereMap).Delete(&cont).Error |
||||
|
return |
||||
|
} |
||||
@ -0,0 +1,251 @@ |
|||||
|
package publicmethod |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/models/modelshr" |
||||
|
"appPlatform/models/modelssystempermission" |
||||
|
"appPlatform/overall" |
||||
|
"fmt" |
||||
|
"strconv" |
||||
|
"strings" |
||||
|
|
||||
|
"gorm.io/gorm" |
||||
|
) |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-05-21 08:44:35 |
||||
|
@ 功能: 获取用户权限 |
||||
|
@ 参数 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 返回值 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 方法原型 |
||||
|
|
||||
|
# |
||||
|
*/ |
||||
|
func (g *GainUserPower) GetUserPower() (powerInfo SendUserPower) { |
||||
|
//正常系统权限配置
|
||||
|
orgLook := []int64{} |
||||
|
if g.RoleId != "" { |
||||
|
roleAry := strings.Split(g.RoleId, ",") |
||||
|
if len(roleAry) > 0 { |
||||
|
var rolePowerList []modelssystempermission.RoleEmpower |
||||
|
overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.RoleEmpower{}).Where("`state` = 1 AND `system` = ? AND `role_id` IN ?", g.SystemName, roleAry).Updates(&rolePowerList) |
||||
|
for _, v := range rolePowerList { |
||||
|
if v.Level >= powerInfo.System.Level { |
||||
|
powerInfo.System.Level = v.Level |
||||
|
} |
||||
|
if v.PointId != "" { |
||||
|
pointIdAry := strings.Split(v.PointId, ",") |
||||
|
for _, pv := range pointIdAry { |
||||
|
if !IsInTrue[string](pv, powerInfo.System.PointId) { |
||||
|
powerInfo.System.PointId = append(powerInfo.System.PointId, pv) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
if v.Operation != "" { |
||||
|
operationAry := strings.Split(v.Operation, ",") |
||||
|
for _, ov := range operationAry { |
||||
|
if !IsInTrue[string](ov, powerInfo.System.Operation) { |
||||
|
powerInfo.System.Operation = append(powerInfo.System.Operation, ov) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
if v.Organization != "" { |
||||
|
orgtionAry := strings.Split(v.Organization, ",") |
||||
|
for _, pv := range orgtionAry { |
||||
|
pvInt, _ := strconv.ParseInt(pv, 10, 64) |
||||
|
if !IsInTrue[int64](pvInt, orgLook) { |
||||
|
orgLook = append(orgLook, pvInt) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
if g.PostId != 0 && g.OrgId != 0 { |
||||
|
var postPower modelssystempermission.Empower |
||||
|
postPower.GetCont(map[string]interface{}{"`state`": 1, "`ordid`": g.OrgId, "`post_id`": g.PostId, "`system`": g.SystemName}) |
||||
|
if postPower.Level >= powerInfo.System.Level { |
||||
|
powerInfo.System.Level = postPower.Level |
||||
|
} |
||||
|
if postPower.PointId != "" { |
||||
|
pointIdAry := strings.Split(postPower.PointId, ",") |
||||
|
for _, pv := range pointIdAry { |
||||
|
if !IsInTrue[string](pv, powerInfo.System.PointId) { |
||||
|
powerInfo.System.PointId = append(powerInfo.System.PointId, pv) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
if postPower.Operation != "" { |
||||
|
operationAry := strings.Split(postPower.Operation, ",") |
||||
|
for _, ov := range operationAry { |
||||
|
if !IsInTrue[string](ov, powerInfo.System.Operation) { |
||||
|
powerInfo.System.Operation = append(powerInfo.System.Operation, ov) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
if postPower.Organization != "" { |
||||
|
orgtionAry := strings.Split(postPower.Organization, ",") |
||||
|
for _, pv := range orgtionAry { |
||||
|
pvInt, _ := strconv.ParseInt(pv, 10, 64) |
||||
|
if !IsInTrue[int64](pvInt, orgLook) { |
||||
|
orgLook = append(orgLook, pvInt) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
_, companyId, departmentId, _, workShopId := GetOrgStructure(g.OrgId) |
||||
|
switch powerInfo.System.Level { |
||||
|
case 1: |
||||
|
powerInfo.System.OrgList = []int64{} |
||||
|
var sunOrg GetOrgAllParent |
||||
|
sunOrg.GetOrgSun(workShopId) |
||||
|
sunOrg.Id = append(sunOrg.Id, workShopId) |
||||
|
powerInfo.System.OrgList = append(powerInfo.System.OrgList, sunOrg.Id...) |
||||
|
case 2: |
||||
|
powerInfo.System.OrgList = []int64{} |
||||
|
var sunOrgDepart GetOrgAllParent |
||||
|
sunOrgDepart.GetOrgSun(departmentId) |
||||
|
sunOrgDepart.Id = append(sunOrgDepart.Id, departmentId) |
||||
|
powerInfo.System.OrgList = append(powerInfo.System.OrgList, sunOrgDepart.Id...) |
||||
|
case 3: |
||||
|
powerInfo.System.OrgList = []int64{} |
||||
|
var sunOrgCompan GetOrgAllParent |
||||
|
sunOrgCompan.GetOrgSun(companyId) |
||||
|
sunOrgCompan.Id = append(sunOrgCompan.Id, companyId) |
||||
|
powerInfo.System.OrgList = append(powerInfo.System.OrgList, sunOrgCompan.Id...) |
||||
|
case 4: |
||||
|
powerInfo.System.OrgList = orgLook |
||||
|
case 5: |
||||
|
powerInfo.System.OrgList = []int64{} |
||||
|
default: |
||||
|
} |
||||
|
//低代码权限系统配置
|
||||
|
if g.RoleId != "" { |
||||
|
orgLookApp := []int64{} |
||||
|
roleAry := strings.Split(g.RoleId, ",") |
||||
|
if len(roleAry) > 0 { |
||||
|
|
||||
|
var tablePower []modelssystempermission.CustomTableAuthorize |
||||
|
|
||||
|
overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.CustomTableAuthorize{}).Where("`app_sign_code` = ? AND `table_sign_code` = ? AND `role_id` IN ?", g.AppKey, g.TableId, roleAry).Find(&tablePower) |
||||
|
|
||||
|
for _, v := range tablePower { |
||||
|
if v.PowerLerver >= powerInfo.System.Level { |
||||
|
powerInfo.AppSystem.Level = v.PowerLerver |
||||
|
} |
||||
|
|
||||
|
if v.TablePower != "" { |
||||
|
tableAry := strings.Split(v.TablePower, ",") |
||||
|
for _, tv := range tableAry { |
||||
|
if !IsInTrue[string](tv, powerInfo.AppSystem.PointId) { |
||||
|
powerInfo.AppSystem.PointId = append(powerInfo.AppSystem.PointId, tv) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
if v.ListPower != "" { |
||||
|
listAry := strings.Split(v.ListPower, ",") |
||||
|
for _, lv := range listAry { |
||||
|
if !IsInTrue[string](lv, powerInfo.AppSystem.Operation) { |
||||
|
powerInfo.AppSystem.Operation = append(powerInfo.AppSystem.Operation, lv) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
if v.Organization != "" { |
||||
|
orgtionAry := strings.Split(v.Organization, ",") |
||||
|
for _, pv := range orgtionAry { |
||||
|
pvInt, _ := strconv.ParseInt(pv, 10, 64) |
||||
|
if !IsInTrue[int64](pvInt, orgLookApp) { |
||||
|
orgLookApp = append(orgLookApp, pvInt) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
switch powerInfo.AppSystem.Level { |
||||
|
case 2: |
||||
|
powerInfo.AppSystem.OrgList = []int64{} |
||||
|
var sunOrg GetOrgAllParent |
||||
|
sunOrg.GetOrgSun(workShopId) |
||||
|
sunOrg.Id = append(sunOrg.Id, workShopId) |
||||
|
powerInfo.AppSystem.OrgList = append(powerInfo.AppSystem.OrgList, sunOrg.Id...) |
||||
|
case 3: |
||||
|
powerInfo.AppSystem.OrgList = []int64{} |
||||
|
var sunOrgDepart GetOrgAllParent |
||||
|
sunOrgDepart.GetOrgSun(departmentId) |
||||
|
sunOrgDepart.Id = append(sunOrgDepart.Id, departmentId) |
||||
|
powerInfo.AppSystem.OrgList = append(powerInfo.AppSystem.OrgList, sunOrgDepart.Id...) |
||||
|
case 4: |
||||
|
powerInfo.AppSystem.OrgList = []int64{} |
||||
|
var sunOrgCompan GetOrgAllParent |
||||
|
sunOrgCompan.GetOrgSun(companyId) |
||||
|
sunOrgCompan.Id = append(sunOrgCompan.Id, companyId) |
||||
|
powerInfo.AppSystem.OrgList = append(powerInfo.AppSystem.OrgList, sunOrgCompan.Id...) |
||||
|
case 5: |
||||
|
powerInfo.AppSystem.OrgList = orgLookApp |
||||
|
case 6: |
||||
|
powerInfo.AppSystem.OrgList = []int64{} |
||||
|
default: |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-05-22 13:53:17 |
||||
|
@ 功能: 权限结构查询语句 |
||||
|
@ 参数 |
||||
|
授权范围等级(1:本人;2:本岗位;3:本部门;4:本分部;5:指定行政组织;6:所有) |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 返回值 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 方法原型 |
||||
|
|
||||
|
# |
||||
|
*/ |
||||
|
func (g *GainUserPower) MakeSearchSql(gormDb *gorm.DB, userCont modelshr.ManCont, isOdeb string) *gorm.DB { |
||||
|
powerInfo := g.GetUserPower() |
||||
|
fmt.Printf("\n\n\n等级-----%v------->%v\n\n\n", powerInfo.AppSystem.Level, g) |
||||
|
if isOdeb == "yes" { |
||||
|
switch powerInfo.AppSystem.Level { |
||||
|
case 2, 3, 4: |
||||
|
if len(powerInfo.AppSystem.OrgList) > 0 { |
||||
|
gormDb = gormDb.Where("`createrOrg` IN ?", powerInfo.AppSystem.OrgList) |
||||
|
} else { |
||||
|
gormDb = gormDb.Where("`creater` = ?", userCont.Key) |
||||
|
} |
||||
|
case 6: |
||||
|
|
||||
|
default: |
||||
|
gormDb = gormDb.Where("`creater` = ?", userCont.Key) |
||||
|
} |
||||
|
} else { |
||||
|
switch powerInfo.AppSystem.Level { |
||||
|
case 2, 3, 4: |
||||
|
if len(powerInfo.AppSystem.OrgList) > 0 { |
||||
|
gormDb = gormDb.Where("f.`createrOrg` IN ?", powerInfo.AppSystem.OrgList) |
||||
|
} else { |
||||
|
gormDb = gormDb.Where("f.`creater` = ?", userCont.Key) |
||||
|
} |
||||
|
case 6: |
||||
|
|
||||
|
default: |
||||
|
gormDb = gormDb.Where("f.`creater` = ?", userCont.Key) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return gormDb |
||||
|
} |
||||
Loading…
Reference in new issue