应用集成平台服务端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
4.2 KiB

3 days ago
package humanResources
import (
"appPlatform/models/modelshr"
"appPlatform/overall"
"appPlatform/overall/publicmethod"
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
)
/**
@ 作者: 秦东
@ 时间: 2025-11-27 13:15:24
@ 功能: 行政组织事务处理模块
*/
/*
*
@ 作者: 秦东
@ 时间: 2025-11-27 13:19:44
@ 功能: 行政组织树
*/
func (a *ApiMethod) AuthorizeOrgTree(c *gin.Context) {
var requestData MenuIdCont
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
context, _ := c.Get(overall.MyContJwt)
var myContInfo modelshr.ManCont
jsonCont, _ := json.Marshal(context)
json.Unmarshal(jsonCont, &myContInfo)
var orgList []modelshr.OrgCont
gotmDb := overall.CONSTANT_DB_HR.Model(&modelshr.OrgCont{}).Where("state = ?", 1)
fmt.Printf("权限-----22222222222222222222222222222222222222222222222222222222222222222222222---->%v\n\n\n", gotmDb)
//获取权限
myPower := publicmethod.GetMyMenuPower(myContInfo.Key, requestData.MenuId)
fmt.Printf("权限--------->%v------>%v\n\n\n", myPower.Scope, myPower)
switch myPower.Scope { //可见范围(1:本人;2:本岗位;3:本部门;4:本分部;5:指定行政组织;6:所有)
case 2:
var sunGroupId publicmethod.GetOrgAllParent
sunGroupId.GetFormGroupSun(myContInfo.AdminOrg)
sunGroupId.Id = append(sunGroupId.Id, myContInfo.AdminOrg)
gotmDb = gotmDb.Where("`id` IN ?", sunGroupId.Id)
case 3:
var sunGroupId publicmethod.GetOrgAllParent
sunGroupId.GetFormGroupSun(myContInfo.MainDeparment)
sunGroupId.Id = append(sunGroupId.Id, myContInfo.MainDeparment)
gotmDb = gotmDb.Where("`id` IN ?", sunGroupId.Id)
case 4:
var sunGroupId publicmethod.GetOrgAllParent
sunGroupId.GetFormGroupSun(myContInfo.Company)
sunGroupId.Id = append(sunGroupId.Id, myContInfo.Company)
gotmDb = gotmDb.Where("`id` IN ?", sunGroupId.Id)
case 5:
gotmDb = gotmDb.Where("`id` IN ?", myPower.ScopeManAry)
case 6:
default:
var sunGroupId publicmethod.GetOrgAllParent
sunGroupId.GetFormGroupSun(myContInfo.AdminOrg)
sunGroupId.Id = append(sunGroupId.Id, myContInfo.AdminOrg)
gotmDb = gotmDb.Where("`id` IN ?", sunGroupId.Id)
}
err = gotmDb.Find(&orgList).Error
var sendTree []OrgTreePower
if err != nil {
publicmethod.Result(0, sendTree, c)
return
}
fmt.Printf("权限--------->%v------>%v\n\n\n", myPower.Scope, orgList)
sendTree = GovOrgTree(0, orgList)
publicmethod.Result(0, sendTree, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2025-11-27 16:34:15
@ 功能: 组装行政树
*/
func GovOrgTree(parentId int64, govList []modelshr.OrgCont) (govMap []OrgTreePower) {
for i := 0; i < len(govList); i++ {
if govList[i].Superior == parentId {
var govCont OrgTreePower
govCont.Id = govList[i].Id //
govCont.Number = govList[i].Number //行政编码"`
govCont.Name = govList[i].Name //组织名称"`
govCont.Superior = govList[i].Superior //上级ID"`
govCont.OrganizationType = govList[i].OrganizationType //行政组织类型"`
govCont.Abbreviation = govList[i].Abbreviation //行政组织简称"`
govCont.Time = govList[i].Time //创建时间"`
govCont.State = govList[i].State //状态(1:启用;2:禁用;3:删除)"`
govCont.WechatOrganizationId = govList[i].WechatOrganizationId //微信组织架构对照码"`
govCont.SuperiorSun = govList[i].SuperiorSun //级联ID"`
govCont.Schoole = govList[i].Schoole //原知行学院对照码"`
govCont.KingdeeId = govList[i].KingdeeId //金蝶对照ID"`
govCont.IsPower = govList[i].IsPower //是否为实权部门"`
govCont.Sort = govList[i].Sort //排序"`
govCont.TypeName = govList[i].TypeName //'类型名称"`
govCont.Level = govList[i].Level //级别"`
if govList[i].State == 1 {
govCont.Status = true
} else {
govCont.Status = false
}
govCont.Child = GovOrgTree(govList[i].Id, govList)
govMap = append(govMap, govCont)
}
}
return
}