Browse Source

权限处理

master
herenshan112 22 hours ago
parent
commit
64067d61bc
  1. 43
      api/version1/humanResources/enter.go
  2. 17
      api/version1/humanResources/org.go
  3. 284
      api/version1/humanResources/peopel.go
  4. 6
      api/version1/setupRoule/authorization.go
  5. 2
      api/version1/setupRoule/entry.go
  6. 8
      api/version1/setupRoule/power.go
  7. 24
      api/version1/user/setPower.go
  8. 7
      api/version1/user/type.go
  9. 1
      api/version1/user/userCont.go
  10. 8
      apirouter/hrRoute/hrrouter.go
  11. 2
      models/modelshr/man_cont.go
  12. 2
      models/modelshr/personarchives.go
  13. 21
      overall/publicmethod/getUserPower.go
  14. 26
      overall/publicmethod/technique.go
  15. 5
      overall/publicmethod/type.go

43
api/version1/humanResources/enter.go

@ -31,3 +31,46 @@ type OrgTreePower struct {
Status bool `json:"status"` Status bool `json:"status"`
Child []OrgTreePower `json:"child"` Child []OrgTreePower `json:"child"`
} }
// 根据权限及搜索条件获取人员列表
type SearchPowPople struct {
MenuIdCont
OrgId int `json:"orgId"`
Name string `json:"name"`
Employ []int `json:"employ"`
Team []int `json:"team"`
JoinTime string `json:"joinTime"`
Page int `json:"page"`
PageSize int `json:"pagesize"`
Total int `json:"total"`
OnJob int `json:"onJob"` //是否在职(1:不在职;非1:在职)
}
// 输出人员列表信息
type SendPowerPeople struct {
modelshr.ManCont
OrgAllName string `json:"orgAllName"`
WorkPostName string `json:"workpostname"` //工段名称
PositionName string `json:"positionname"` //职位
KeyStr string `json:"keystr"` //身份认证
TeamName string `json:"teamname"` //班组
PersonInCharge int `json:"personincharge"` //负责人
}
// 新增人员
type PeopleInfo struct {
publicmethod.PublicName //"name": "姓名",
Code string `json:"code"` //工号
Mobile string `json:"mobile"` //联系电话
Nation string `json:"nation"` //民族
Sex string `json:"sex"` //性别
Age string `json:"age"` //出生日期
OldName string `json:"oldName"` //曾用名,
Icon string `json:"icon"` //头像
OrgId int64 `json:"orgId"` //行政组织
Employment string `json:"employment"` // 用工关系
Address string `json:"address"` //联系地址
BodyStatus string `json:"bodyStatus"` //身体状况
MarriageStatus string `json:"marriageStatus"` //婚姻状况
}

17
api/version1/humanResources/org.go

@ -40,26 +40,39 @@ func (a *ApiMethod) AuthorizeOrgTree(c *gin.Context) {
//获取权限 //获取权限
myPower := publicmethod.GetMyMenuPower(myContInfo.Key, requestData.MenuId) myPower := publicmethod.GetMyMenuPower(myContInfo.Key, requestData.MenuId)
fmt.Printf("权限--------->%v------>%v\n\n\n", myPower.Scope, myPower) fmt.Printf("权限--------->%v------>%v\n\n\n", myPower.Scope, myPower)
var fisrtId int64
switch myPower.Scope { //可见范围(1:本人;2:本岗位;3:本部门;4:本分部;5:指定行政组织;6:所有) switch myPower.Scope { //可见范围(1:本人;2:本岗位;3:本部门;4:本分部;5:指定行政组织;6:所有)
case 2: case 2:
fisrtId = myContInfo.MainDeparment
var sunGroupId publicmethod.GetOrgAllParent var sunGroupId publicmethod.GetOrgAllParent
sunGroupId.GetFormGroupSun(myContInfo.AdminOrg) sunGroupId.GetFormGroupSun(myContInfo.AdminOrg)
sunGroupId.Id = append(sunGroupId.Id, myContInfo.AdminOrg) sunGroupId.Id = append(sunGroupId.Id, myContInfo.AdminOrg)
gotmDb = gotmDb.Where("`id` IN ?", sunGroupId.Id) gotmDb = gotmDb.Where("`id` IN ?", sunGroupId.Id)
case 3: case 3:
fisrtId = myContInfo.Company
var sunGroupId publicmethod.GetOrgAllParent var sunGroupId publicmethod.GetOrgAllParent
sunGroupId.GetFormGroupSun(myContInfo.MainDeparment) sunGroupId.GetFormGroupSun(myContInfo.MainDeparment)
sunGroupId.Id = append(sunGroupId.Id, myContInfo.MainDeparment) sunGroupId.Id = append(sunGroupId.Id, myContInfo.MainDeparment)
gotmDb = gotmDb.Where("`id` IN ?", sunGroupId.Id) gotmDb = gotmDb.Where("`id` IN ?", sunGroupId.Id)
case 4: case 4:
var prentInfo modelshr.AdministrativeOrganization
prentInfo.GetCont(map[string]interface{}{"`id`": myContInfo.Company}, "`superior`")
fisrtId = prentInfo.Superior
var sunGroupId publicmethod.GetOrgAllParent var sunGroupId publicmethod.GetOrgAllParent
sunGroupId.GetFormGroupSun(myContInfo.Company) sunGroupId.GetFormGroupSun(myContInfo.Company)
sunGroupId.Id = append(sunGroupId.Id, myContInfo.Company) sunGroupId.Id = append(sunGroupId.Id, myContInfo.Company)
gotmDb = gotmDb.Where("`id` IN ?", sunGroupId.Id) gotmDb = gotmDb.Where("`id` IN ?", sunGroupId.Id)
case 5: case 5:
var oid []int64
for _, v := range myPower.ScopeManAry {
oid = append(oid, int64(v))
}
fisrtId = publicmethod.GetFristOrgId(oid)
gotmDb = gotmDb.Where("`id` IN ?", myPower.ScopeManAry) gotmDb = gotmDb.Where("`id` IN ?", myPower.ScopeManAry)
case 6: case 6:
fisrtId = 313
default: default:
fisrtId = myContInfo.MainDeparment
var sunGroupId publicmethod.GetOrgAllParent var sunGroupId publicmethod.GetOrgAllParent
sunGroupId.GetFormGroupSun(myContInfo.AdminOrg) sunGroupId.GetFormGroupSun(myContInfo.AdminOrg)
sunGroupId.Id = append(sunGroupId.Id, myContInfo.AdminOrg) sunGroupId.Id = append(sunGroupId.Id, myContInfo.AdminOrg)
@ -71,8 +84,8 @@ func (a *ApiMethod) AuthorizeOrgTree(c *gin.Context) {
publicmethod.Result(0, sendTree, c) publicmethod.Result(0, sendTree, c)
return return
} }
fmt.Printf("权限--------->%v------>%v\n\n\n", myPower.Scope, orgList) fmt.Printf("权限--------->%v------>%v\n\n\n", myPower.Scope, fisrtId)
sendTree = GovOrgTree(0, orgList) sendTree = GovOrgTree(fisrtId, orgList)
publicmethod.Result(0, sendTree, c) publicmethod.Result(0, sendTree, c)
} }

284
api/version1/humanResources/peopel.go

@ -0,0 +1,284 @@
package humanResources
import (
"appPlatform/models/modelshr"
"appPlatform/overall"
"appPlatform/overall/publicmethod"
"encoding/json"
"strconv"
"strings"
"github.com/gin-gonic/gin"
)
/*
*
@ 作者: 秦东
@ 时间: 2025-12-02 11:31:56
@ 功能: 根据权限获取数据
*/
func (a *ApiMethod) AuthorizePeopleList(c *gin.Context) {
var requestData SearchPowPople
c.ShouldBindJSON(&requestData)
if requestData.Page < 0 {
requestData.Page = 1
}
if requestData.PageSize < 0 {
requestData.PageSize = 10
}
//获取当前操作人
context, _ := c.Get(overall.MyContJwt)
var myContInfo modelshr.ManCont
jsonCont, _ := json.Marshal(context)
json.Unmarshal(jsonCont, &myContInfo)
//获取权限
myPower := publicmethod.GetMyMenuPower(myContInfo.Key, requestData.MenuId)
//获取人员列表
// var peopelList []modelshr.PersonArchives
gormDb := overall.CONSTANT_DB_HR.Model(&modelshr.ManCont{}).Select("`id`").Where("`number` NOT LIKE ?", "%W%")
if requestData.Name != "" {
gormDb = gormDb.Where("`number` LIKE ? OR `name` LIKE ? OR `mobilephone` LIKE ?", "%"+requestData.Name+"%", "%"+requestData.Name+"%", "%"+requestData.Name+"%")
}
if len(requestData.Employ) > 0 {
gormDb = gormDb.Where("`emp_type` IN ?", requestData.Employ)
} else {
if requestData.OnJob != 0 {
gormDb = gormDb.Where("`emp_type` BETWEEN ? AND ?", 11, 14)
} else {
gormDb = gormDb.Where("`emp_type` BETWEEN ? AND ?", 1, 10)
}
}
if len(requestData.Team) > 0 {
gormDb = gormDb.Where("`teamid` IN ?", requestData.Team)
}
if requestData.JoinTime != "" {
startTime, endTime := publicmethod.OenDayStartOrEndTime(requestData.JoinTime, 1)
gormDb = gormDb.Where("`entrydate` BETWEEN ? AND ?", startTime, endTime)
}
switch myPower.Scope { //可见范围(1:本人;2:本岗位;3:本部门;4:本分部;5:指定行政组织;6:所有)
case 2:
gormDb = gormDb.Where("`position` = ?", myContInfo.Position)
case 3:
if requestData.OrgId != 0 {
var sunOrg publicmethod.GetOrgAllParent
sunOrg.GetOrgSun(int64(myContInfo.MainDeparment))
sunOrg.Id = append(sunOrg.Id, int64(myContInfo.MainDeparment))
if publicmethod.IsInTrue[int64](int64(requestData.OrgId), sunOrg.Id) {
var pickSunOrg publicmethod.GetOrgAllParent
pickSunOrg.GetOrgSun(int64(requestData.OrgId))
pickSunOrg.Id = append(pickSunOrg.Id, int64(requestData.OrgId))
gormDb = gormDb.Where("`admin_org` = ?", pickSunOrg.Id)
} else {
gormDb = gormDb.Where("`maindeparment` = ?", myContInfo.MainDeparment)
}
} else {
gormDb = gormDb.Where("`maindeparment` = ?", myContInfo.MainDeparment)
}
case 4:
if requestData.OrgId != 0 {
if int64(requestData.OrgId) == myContInfo.Company {
gormDb = gormDb.Where("`company` = ?", myContInfo.Company)
} else {
var sunOrg publicmethod.GetOrgAllParent
sunOrg.GetOrgSun(myContInfo.Company)
if publicmethod.IsInTrue[int64](int64(requestData.OrgId), sunOrg.Id) {
var pickSunOrg publicmethod.GetOrgAllParent
pickSunOrg.GetOrgSun(int64(requestData.OrgId))
pickSunOrg.Id = append(pickSunOrg.Id, int64(requestData.OrgId))
gormDb = gormDb.Where("`admin_org` = ?", pickSunOrg.Id)
} else {
gormDb = gormDb.Where("`company` = ?", myContInfo.Company)
}
}
} else {
}
case 5:
if requestData.OrgId != 0 {
//目标行政组织
var sunOrg publicmethod.GetOrgAllParent
sunOrg.GetOrgSun(int64(requestData.OrgId))
sunOrg.Id = append(sunOrg.Id, int64(requestData.OrgId))
//可观测的行政组织
var oid []int64
for _, v := range myPower.ScopeManAry {
oid = append(oid, int64(v))
}
lookOrg := publicmethod.Intersect[int64](sunOrg.Id, oid)
if len(lookOrg) > 0 {
gormDb = gormDb.Where("`admin_org` IN ?", lookOrg)
} else {
gormDb = gormDb.Where("`admin_org` = ?", myContInfo.AdminOrg)
}
}
case 6:
if requestData.OrgId != 0 {
var sunOrg publicmethod.GetOrgAllParent
sunOrg.GetOrgSun(int64(requestData.OrgId))
sunOrg.Id = append(sunOrg.Id, int64(requestData.OrgId))
if len(sunOrg.Id) > 0 {
gormDb = gormDb.Where("`admin_org` IN ?", sunOrg.Id)
} else {
gormDb = gormDb.Where("`admin_org` = ?", requestData.OrgId)
}
}
default:
gormDb = gormDb.Where("`key` = ?", myContInfo.Key)
}
//获取人员总数
var total int64
totalErr := gormDb.Count(&total).Error
if totalErr != nil {
total = 0
}
var idAry []int64
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize)
err := gormDb.Order("`time` DESC").Find(&idAry).Error
if err != nil && len(idAry) < 1 {
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(idAry)), idAry, c)
return
}
var manContList []modelshr.ManCont
err = overall.CONSTANT_DB_HR.Where("`id` IN ?", idAry).Order("`time` DESC").Find(&manContList).Error
if err != nil {
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(idAry)), idAry, c)
return
}
var sendList []SendPowerPeople
for _, v := range manContList {
var sendCont SendPowerPeople
sendCont.ManCont = v
if v.Position != 0 {
var postCont modelshr.Position
postCont.GetCont(map[string]interface{}{"`id`": v.Position}, "`name`")
sendCont.PositionName = postCont.Name
}
sendCont.KeyStr = strconv.FormatInt(v.Key, 10)
var orgAllName []string
if v.Company != 0 {
var orgCont modelshr.AdministrativeOrganization
orgCont.GetCont(map[string]interface{}{"`id`": v.Company}, "`name`")
if orgCont.Name != "" {
if !publicmethod.IsInTrue[string](orgCont.Name, orgAllName) {
orgAllName = append(orgAllName, orgCont.Name)
}
}
}
if v.MainDeparment != 0 {
var orgCont modelshr.AdministrativeOrganization
orgCont.GetCont(map[string]interface{}{"`id`": v.MainDeparment}, "`name`")
if orgCont.Name != "" {
if !publicmethod.IsInTrue[string](orgCont.Name, orgAllName) {
orgAllName = append(orgAllName, orgCont.Name)
}
}
}
if v.SunMainDeparment != 0 {
var orgCont modelshr.AdministrativeOrganization
orgCont.GetCont(map[string]interface{}{"`id`": v.SunMainDeparment}, "`name`")
if orgCont.Name != "" {
if !publicmethod.IsInTrue[string](orgCont.Name, orgAllName) {
orgAllName = append(orgAllName, orgCont.Name)
}
}
}
if v.AdminOrg != 0 {
var orgCont modelshr.AdministrativeOrganization
orgCont.GetCont(map[string]interface{}{"`id`": v.AdminOrg}, "`name`")
if orgCont.Name != "" {
if !publicmethod.IsInTrue[string](orgCont.Name, orgAllName) {
orgAllName = append(orgAllName, orgCont.Name)
}
}
}
sendCont.OrgAllName = strings.Join(orgAllName, " / ")
sendCont.PersonInCharge = 2
if v.PersonInCharge == 1 {
orgResList := strings.Split(v.ResponsibleDepartment, ",")
if len(orgResList) > 0 {
orgIdStr := strconv.FormatInt(int64(requestData.OrgId), 10)
if publicmethod.IsInTrue[string](orgIdStr, orgResList) == true {
sendCont.PersonInCharge = 1
}
}
}
sendList = append(sendList, sendCont)
}
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(sendList)), sendList, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2025-12-03 15:48:03
@ 功能: 新增人员
*/
func (a *ApiMethod) AddNewPeople(c *gin.Context) {
var requestData PeopleInfo
err := c.ShouldBindJSON(&requestData)
if requestData.OrgId == 0 {
publicmethod.Result(100, err, c, "请选择归属部门")
return
}
if requestData.Name == "" {
publicmethod.Result(100, err, c, "请输入姓名")
return
}
if requestData.Code == "" {
publicmethod.Result(100, err, c, "请输入工号")
return
}
if requestData.Mobile == "" {
publicmethod.Result(100, err, c, "请输入联系电话")
return
}
if requestData.Employment == "" {
publicmethod.Result(100, err, c, "请选择用工关系")
return
}
sexVal := 1
sexVal, swxErr := strconv.Atoi(requestData.Sex)
if swxErr != nil {
sexVal = 1
}
var myInfoOld modelshr.PersonArchives
myInfoOld.GetCont(map[string]interface{}{"`number`": requestData.Code}, "`id`")
if myInfoOld.Id != 0 {
publicmethod.Result(100, err, c, "该工号已被使用请不要重复使用!")
return
}
uuid := publicmethod.GetUUid(1)
var myInfo modelshr.PersonArchives
myInfo.Key = uuid
myInfo.Name = requestData.Name
myInfo.Number = requestData.Code
myInfo.Icon = requestData.Icon
_, myInfo.Company, myInfo.MainDeparment, myInfo.SunMainDeparment, myInfo.AdminOrg = publicmethod.GetOrgStructurees(requestData.OrgId)
myInfo.EmpType, _ = strconv.Atoi(requestData.Employment)
var myAboutInfo modelshr.PersonnelContent
myAboutInfo.Number = requestData.Code
myAboutInfo.NameUsedBefore = requestData.OldName
myAboutInfo.Mobilephone = requestData.Mobile
myAboutInfo.Myfolk = requestData.Nation
myAboutInfo.Gender = sexVal
var creTimeAll publicmethod.DateTimeTotimes
creTimeAll.BaisStrToTime(requestData.Age)
myAboutInfo.Birthday = creTimeAll.AllTime
myAboutInfo.Currentresidence = requestData.Address
myAboutInfo.Health, _ = strconv.Atoi(requestData.BodyStatus)
myAboutInfo.Maritalstatus, _ = strconv.Atoi(requestData.MarriageStatus)
myAboutInfo.Key = uuid
err = overall.CONSTANT_DB_HR.Create(&myInfo).Error
if err == nil {
overall.CONSTANT_DB_HR.Create(&myAboutInfo)
publicmethod.Result(0, err, c)
} else {
publicmethod.Result(104, err, c)
}
}

6
api/version1/setupRoule/authorization.go

@ -237,11 +237,11 @@ func ButPower(butList []AppPowerInfo) string {
if len(butList) <= 0 { if len(butList) <= 0 {
return "[]" return "[]"
} }
var powerAry []int var powerAry []string
for _, v := range butList { for _, v := range butList {
if v.IsTrue { if v.IsTrue {
if !publicmethod.IsInTrue[int](v.Id, powerAry) { if !publicmethod.IsInTrue[string](v.Perm, powerAry) {
powerAry = append(powerAry, v.Id) powerAry = append(powerAry, v.Perm)
} }
} }
} }

2
api/version1/setupRoule/entry.go

@ -42,7 +42,7 @@ type AppPowerInfo struct {
Id int `gorm:"column:id;type:int(10) unsigned;primary_key;AUTO_INCREMENT" json:"id"` Id int `gorm:"column:id;type:int(10) unsigned;primary_key;AUTO_INCREMENT" json:"id"`
Name string `gorm:"column:name;type:varchar(255);comment:菜单名称" json:"name"` //菜单名称 Name string `gorm:"column:name;type:varchar(255);comment:菜单名称" json:"name"` //菜单名称
Types int `gorm:"column:type;type:int(10) unsigned;default:1;comment:菜单类型(1-菜单;2-目录;3-外链;4-按钮权限);NOT NULL" json:"types"` //菜单类型(1-菜单;2-目录;3-外链;4-按钮权限) Types int `gorm:"column:type;type:int(10) unsigned;default:1;comment:菜单类型(1-菜单;2-目录;3-外链;4-按钮权限);NOT NULL" json:"types"` //菜单类型(1-菜单;2-目录;3-外链;4-按钮权限)
Perm int64 `gorm:"column:perm;type:bigint(20) unsigned;default:0;comment:权限标识;NOT NULL" json:"perm"` //权限标识 Perm string `gorm:"column:perm;type:bigint(20) unsigned;default:0;comment:权限标识;NOT NULL" json:"perm"` //权限标识
Sort int `gorm:"column:sort;type:int(10) unsigned;default:50;comment:排序(数字越小排名越靠前);NOT NULL" json:"sort"` //排序(数字越小排名越靠前) Sort int `gorm:"column:sort;type:int(10) unsigned;default:50;comment:排序(数字越小排名越靠前);NOT NULL" json:"sort"` //排序(数字越小排名越靠前)
ParentId int `gorm:"column:parentId;type:int(10) unsigned;default:0;comment:父菜单ID;NOT NULL" json:"parentId"` //父菜单ID ParentId int `gorm:"column:parentId;type:int(10) unsigned;default:0;comment:父菜单ID;NOT NULL" json:"parentId"` //父菜单ID
IsTrue bool `gorm:"-" json:"isTrue"` IsTrue bool `gorm:"-" json:"isTrue"`

8
api/version1/setupRoule/power.go

@ -93,6 +93,14 @@ func MenuButList(noButMenu, ButMenu []AppPowerInfo) (menuButList []AppMenuBut) {
menuButInfo.AppPowerList = []int64{1} menuButInfo.AppPowerList = []int64{1}
for _, bv := range ButMenu { for _, bv := range ButMenu {
if bv.ParentId == v.Id { if bv.ParentId == v.Id {
// var butInfo AppPowerInfo
// butInfo.Id = v.Id //int
// butInfo.Name = v.Name //string
// butInfo.Types = v.Types //int
// butInfo.Perm = v.Perm //string
// butInfo.Sort = v.Sort //int
// butInfo.ParentId = v.ParentId //int
// butInfo.IsTrue = v.IsTrue //bool
menuButInfo.ButtenPower = append(menuButInfo.ButtenPower, bv) menuButInfo.ButtenPower = append(menuButInfo.ButtenPower, bv)
} }
} }

24
api/version1/user/setPower.go

@ -41,6 +41,7 @@ func GetMyPower(powerType string, oupk, org, poetId int64) (allPower SendAllPowe
if v.VisibleRange == 5 && v.ButPower != "" && v.ButPower != "null" { if v.VisibleRange == 5 && v.ButPower != "" && v.ButPower != "null" {
json.Unmarshal([]byte(v.VisibleOrg), &sysPower.ScopeManAry) json.Unmarshal([]byte(v.VisibleOrg), &sysPower.ScopeManAry)
} }
allPower.MenuButIdAry = append(allPower.MenuButIdAry, v.ButPower)
allPower.SystemPower = append(allPower.SystemPower, sysPower) allPower.SystemPower = append(allPower.SystemPower, sysPower)
} }
} else { } else {
@ -59,6 +60,14 @@ func GetMyPower(powerType string, oupk, org, poetId int64) (allPower SendAllPowe
syncSeting.Wait() syncSeting.Wait()
mySysMenuPower.GetPowerSystem(mySysMenuPower.SysTemList) mySysMenuPower.GetPowerSystem(mySysMenuPower.SysTemList)
allPower.MenuIdAry = mySysMenuPower.MenuId allPower.MenuIdAry = mySysMenuPower.MenuId
var butAryStr []string
for _, v := range allPower.SystemPower {
for _, bv := range v.ButIdAry {
butAryStr = append(butAryStr, bv)
}
}
allPower.MenuButIdAry = append(allPower.MenuButIdAry, butAryStr...)
var menuList []modelAppPlatform.Menus var menuList []modelAppPlatform.Menus
if len(mySysMenuPower.MenuId) > 0 { if len(mySysMenuPower.MenuId) > 0 {
overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.Menus{}).Select("`id`,`name`").Where("`id` IN ?", mySysMenuPower.MenuId).Find(&menuList) overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.Menus{}).Select("`id`,`name`").Where("`id` IN ?", mySysMenuPower.MenuId).Find(&menuList)
@ -109,6 +118,13 @@ func GetMyPower(powerType string, oupk, org, poetId int64) (allPower SendAllPowe
allPower.AppKeyAry = tableId allPower.AppKeyAry = tableId
allPower.AppSystemPower = MergePower(myAppPower.FormTable) allPower.AppSystemPower = MergePower(myAppPower.FormTable)
} }
for _, v := range allPower.SystemPower {
if len(v.ButIdAry) > 0 {
for _, bv := range v.ButIdAry {
allPower.MenuButIdAry = append(allPower.MenuButIdAry, bv)
}
}
}
return return
} }
@ -365,10 +381,10 @@ func (x *XieChengPowerSys) GetPowerSystem(list []modelssystempermission.AuthPowe
x.SystemPower[xi].IsPick = true x.SystemPower[xi].IsPick = true
} }
if v.ButPower != "" && v.ButPower != "null" { if v.ButPower != "" && v.ButPower != "null" {
var butPow []int64 var butPow []string
json.Unmarshal([]byte(v.ButPower), &butPow) json.Unmarshal([]byte(v.ButPower), &butPow)
for _, bv := range butPow { for _, bv := range butPow {
if !publicmethod.IsInTrue[int64](bv, x.SystemPower[xi].ButIdAry) { if !publicmethod.IsInTrue[string](bv, x.SystemPower[xi].ButIdAry) {
x.SystemPower[xi].ButIdAry = append(x.SystemPower[xi].ButIdAry, bv) x.SystemPower[xi].ButIdAry = append(x.SystemPower[xi].ButIdAry, bv)
} }
} }
@ -402,7 +418,7 @@ func (x *XieChengPowerSys) GetPowerSystem(list []modelssystempermission.AuthPowe
if v.ButPower != "" && v.ButPower != "null" { if v.ButPower != "" && v.ButPower != "null" {
json.Unmarshal([]byte(v.ButPower), &menuPower.ButIdAry) json.Unmarshal([]byte(v.ButPower), &menuPower.ButIdAry)
} else { } else {
menuPower.ButIdAry = []int64{} menuPower.ButIdAry = []string{}
} }
if v.VisibleRange == 0 { if v.VisibleRange == 0 {
v.VisibleRange = 1 v.VisibleRange = 1
@ -426,7 +442,7 @@ func (x *XieChengPowerSys) GetPowerSystem(list []modelssystempermission.AuthPowe
if v.ButPower != "" && v.ButPower != "null" { if v.ButPower != "" && v.ButPower != "null" {
json.Unmarshal([]byte(v.ButPower), &menuPower.ButIdAry) json.Unmarshal([]byte(v.ButPower), &menuPower.ButIdAry)
} else { } else {
menuPower.ButIdAry = []int64{} menuPower.ButIdAry = []string{}
} }
menuPower.Scope = 1 menuPower.Scope = 1
if v.VisibleRange > menuPower.Scope { if v.VisibleRange > menuPower.Scope {

7
api/version1/user/type.go

@ -129,6 +129,7 @@ type SendOrgAndManInfo struct {
type SendAllPower struct { type SendAllPower struct {
SystemPower []SystemInfoPower `json:"systemPower"` SystemPower []SystemInfoPower `json:"systemPower"`
MenuIdAry []int64 `json:"menuIdAry"` MenuIdAry []int64 `json:"menuIdAry"`
MenuButIdAry []string `json:"menuButIdAry"`
AppSystemPower []AppMyPower `json:"AppSystemPower"` AppSystemPower []AppMyPower `json:"AppSystemPower"`
AppKeyAry []string `json:"appKeyAry"` AppKeyAry []string `json:"appKeyAry"`
} }
@ -141,9 +142,9 @@ type SystemInfoPower struct {
} }
type OutPowerInfo struct { type OutPowerInfo struct {
ButIdAry []int64 `json:"butIdAry"` ButIdAry []string `json:"butIdAry"`
Scope int `json:"scope"` Scope int `json:"scope"`
ScopeManAry []int `json:"scopeManAry"` ScopeManAry []int `json:"scopeManAry"`
} }
// 自定义应用授权 // 自定义应用授权

1
api/version1/user/userCont.go

@ -84,6 +84,7 @@ func (a *ApiMethod) GetUserCont(c *gin.Context) {
sendData.Currentresidence = myContInfo.Currentresidence sendData.Currentresidence = myContInfo.Currentresidence
sendData.AllPowerConfig, _ = GetMyPower("person", myContInfo.Key, myContInfo.AdminOrg, myContInfo.Position) sendData.AllPowerConfig, _ = GetMyPower("person", myContInfo.Key, myContInfo.AdminOrg, myContInfo.Position)
writeRedisData, _ := json.Marshal(sendData.AllPowerConfig) writeRedisData, _ := json.Marshal(sendData.AllPowerConfig)
publicmethod.SetupPowerInfo(myContInfo.Key, string(writeRedisData)) publicmethod.SetupPowerInfo(myContInfo.Key, string(writeRedisData))
publicmethod.Result(0, sendData, c) publicmethod.Result(0, sendData, c)

8
apirouter/hrRoute/hrrouter.go

@ -11,8 +11,10 @@ func (p *ApiRouter) InitRouterGroup(route *gin.RouterGroup) {
apiRouter := route.Group("hr") apiRouter := route.Group("hr")
var apiHandle = version1.AppApiEntry.HrApi var apiHandle = version1.AppApiEntry.HrApi
{ {
apiRouter.GET("", apiHandle.Index) //入口 apiRouter.GET("", apiHandle.Index) //入口
apiRouter.POST("", apiHandle.Index) //入口 apiRouter.POST("", apiHandle.Index) //入口
apiRouter.POST("authorizeOrgTree", apiHandle.AuthorizeOrgTree) //行政组织树 apiRouter.POST("authorizeOrgTree", apiHandle.AuthorizeOrgTree) //行政组织树
apiRouter.POST("authorizePeopleList", apiHandle.AuthorizePeopleList) //根据权限获取数据
apiRouter.POST("addNewPeople", apiHandle.AddNewPeople) //新增人员
} }
} }

2
models/modelshr/man_cont.go

@ -65,6 +65,8 @@ type ManCont struct {
PersonInCharge int `json:"personInCharge" gorm:"column:person_in_charge;type:int(10) unsigned;default:1;comment:负责人(1:是;2:否)"` PersonInCharge int `json:"personInCharge" gorm:"column:person_in_charge;type:int(10) unsigned;default:1;comment:负责人(1:是;2:否)"`
ResponsibleDepartment string `json:"responsibledepartment" gorm:"column:responsible_department;type:longtext;default:'';not null;comment:负责的行政组织"` ResponsibleDepartment string `json:"responsibledepartment" gorm:"column:responsible_department;type:longtext;default:'';not null;comment:负责的行政组织"`
ResponsibleDepartmentJson string `json:"responsibledepartmentjson" gorm:"column:responsible_department_json;type:longtext;default:'';not null;comment:负责的行政组织json"` ResponsibleDepartmentJson string `json:"responsibledepartmentjson" gorm:"column:responsible_department_json;type:longtext;default:'';not null;comment:负责的行政组织json"`
ExcelTemplate int64 `json:"excelTemplate" gorm:"column:excel_template;type:bigint(20) unsigned;default:0;not null;comment:信息来源于哪个模板`
IsShowTrue int64 `json:"isShowTrue" gorm:"column:is_show_true;type:int(5) unsigned;default:2;not null;comment:信息是否锁定`
} }
func (ManCont *ManCont) TableName() string { func (ManCont *ManCont) TableName() string {

2
models/modelshr/personarchives.go

@ -7,7 +7,7 @@ import (
// 员工档案(主) // 员工档案(主)
type PersonArchives struct { type PersonArchives struct {
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:ID"` Id int64 `json:"id" gorm:"column:id;type:bigint(20) unsigned;primary_key;AUTO_INCREMENT" `
Number string `json:"number" gorm:"column:number;type:varchar(30) unsigned;not null;comment:员工工号"` Number string `json:"number" gorm:"column:number;type:varchar(30) unsigned;not null;comment:员工工号"`
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:姓名"` Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:姓名"`
Icon string `json:"icon" gorm:"column:icon;type:varchar(255) unsigned;default:'';not null;comment:头像"` Icon string `json:"icon" gorm:"column:icon;type:varchar(255) unsigned;default:'';not null;comment:头像"`

21
overall/publicmethod/getUserPower.go

@ -355,3 +355,24 @@ func GetSystemAppPower(powerType, systemTyep, powerId string) (powerAry []SendSy
} }
return return
} }
// 获取综合行政组织上级
func GetFristOrgId(orgAry []int64) (orgId int64) {
var orgLevel []modelshr.OrgContType
overall.CONSTANT_DB_HR.Model(&modelshr.OrgContType{}).Where("`state` = 1 AND `id` IN ?", orgAry).Find(&orgLevel)
if len(orgLevel) > 0 {
var OrgIdLevelInfo OrgIdLevel
OrgIdLevelInfo.Level = 6
OrgIdLevelInfo.Id = 0
for _, v := range orgLevel {
if v.Level <= OrgIdLevelInfo.Level {
OrgIdLevelInfo.Id = v.Superior
}
}
orgId = OrgIdLevelInfo.Id
} else {
orgId = 0
}
return
}

26
overall/publicmethod/technique.go

@ -492,10 +492,28 @@ func Intersect[T GenericityVariable](a, b []T) []T {
inter = append(inter, s) inter = append(inter, s)
} }
} }
return inter return inter
} }
func Intersection[T GenericityVariable](a, b []T) []T {
var result []T
i, j := 0, 0
for i < len(a) && j < len(b) {
if a[i] < b[j] {
i++
} else if a[i] > b[j] {
j++
} else { // a[i] == b[j]
if len(result) == 0 || a[i] != result[len(result)-1] { // 避免重复元素
result = append(result, a[i])
}
i++
j++
}
}
return result
}
//判断类型转换成 //判断类型转换成
/* /*
字符转int 字符转int
@ -1863,6 +1881,12 @@ func MergeStruct[T GenericityVariable](aryOen, aryTwo []T) (structAry []T) {
return return
} }
/**
@ 作者: 秦东
@ 时间: 2025-12-02 13:45:47
@ 功能: 求两个数组交集
*/
/* /*
* *
@ 作者: 秦东 @ 作者: 秦东

5
overall/publicmethod/type.go

@ -433,3 +433,8 @@ type AppMyPowerTable struct {
Scope int `json:"scope"` Scope int `json:"scope"`
ScopeManAry []int `json:"scopeManAry"` ScopeManAry []int `json:"scopeManAry"`
} }
type OrgIdLevel struct {
Id int64
Level int64
}

Loading…
Cancel
Save