diff --git a/api/version1/personnelapi/staffarchives.go b/api/version1/personnelapi/staffarchives.go index c459372..4308a34 100644 --- a/api/version1/personnelapi/staffarchives.go +++ b/api/version1/personnelapi/staffarchives.go @@ -3318,6 +3318,11 @@ func (s *StaffApi) ArchivesListCont(c *gin.Context) { if requestData.Right == 0 { requestData.Right = 1 } + context, _ := c.Get(overall.MyContJwt) + var userCont models.ManCont + userCont.GetLoginCont(context) //当前操作人 + + fmt.Printf("当前登陆人----------->%v\n\n\n", userCont) gormDb := overall.CONSTANT_DB_HR.Model(&models.PersonArchives{}).Select("`id`").Where("`number` NOT LIKE ?", "%W%") if requestData.KeyWords != "" { @@ -3385,6 +3390,16 @@ func (s *StaffApi) ArchivesListCont(c *gin.Context) { } } + //Step 3 权限处理 + var powerSearch overallhandle.GainUserPower + powerSearch.SystemName = "appsystem" //系统名称 + powerSearch.RoleId = userCont.Role //角色列表 + powerSearch.OrgId = userCont.AdminOrg //行政组织 + powerSearch.PostId = userCont.Position //岗位 + powerSearch.AppKey = 0 //归属哪个App + powerSearch.TableId = 0 //归属哪个表格 + gormDb = powerSearch.MakeSearchSql(gormDb, userCont, "no") + var total int64 totalErr := gormDb.Count(&total).Error if totalErr != nil { @@ -3392,6 +3407,7 @@ func (s *StaffApi) ArchivesListCont(c *gin.Context) { } var idAry []int64 err := gormDb.Order("company ASC,maindeparment ASC,admin_org ASC,position ASC").Limit(requestData.PageSize).Offset(overallhandle.LimitPage(requestData.Page, requestData.PageSize)).Find(&idAry).Error + return var positionAry []peopleManOutList if err != nil { overallhandle.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(positionAry)), positionAry, c) diff --git a/api/version1/personnelapi/userarchives.go b/api/version1/personnelapi/userarchives.go index 7b88916..03fcbf8 100644 --- a/api/version1/personnelapi/userarchives.go +++ b/api/version1/personnelapi/userarchives.go @@ -247,6 +247,8 @@ func (s *StaffApi) PersonnelFiles(c *gin.Context) { saveInfo["PolitOutlook"] = overallhandle.PoliticalIdentity(int64(myInfo.PoliticalOutlook)) saveInfo["Maristatus"] = overallhandle.MaritalStatus(int64(myInfo.Maritalstatus)) saveInfo["KeyStr"] = strconv.FormatInt(myInfo.Key, 10) + // saveInfo["NumberChildren"] = + //教育经历 synPro.Add(1) go func() { @@ -295,7 +297,7 @@ func (s *StaffApi) PersonnelFiles(c *gin.Context) { //家庭成员 synPro.Add(1) go func() { - saveInfo["familyMembers"] = FamilyMembers(myInfo.Key) //工作履历 + saveInfo["familyMembers"], saveInfo["numberChildren"] = FamilyMembers(myInfo.Key) //工作履历 }() //性格社彩 // var myColor personalitycolor.Charcolortest @@ -380,9 +382,20 @@ func (s *StaffApi) PersonnelFiles(c *gin.Context) { # */ -func FamilyMembers(userKey int64) (list []models.FamilyMembers) { +func FamilyMembers(userKey int64) (list []models.FamilyMembers, num string) { defer synPro.Done() overall.CONSTANT_DB_HR.Model(&models.FamilyMembers{}).Where("`state` = 1 AND `key` = ?", userKey).Find(&list) + sunNum := 0 + for _, v := range list { + if overallhandle.IsInTrue[string](v.Relationship, []string{"父子", "父女", "母子", "母女", "子女", "儿子", "女儿", "祖孙", "监护人", "儿媳"}) { + sunNum++ + } + } + if sunNum == 0 { + num = "无" + } else { + num = strconv.Itoa(sunNum) + } return } diff --git a/apirouter/inlet.go b/apirouter/inlet.go index bd545b2..f1d788d 100644 --- a/apirouter/inlet.go +++ b/apirouter/inlet.go @@ -19,6 +19,7 @@ type RouterGroup struct { OrganizationApiOpen organization.OrganizationRouteOpen //组织架构 PermitPowerApi permit.PermitPower //权限相关操作 PersonnelRoute personnel.PersonnelRoute //人员管理 + PersonnelRoutePower personnel.PersonnelRoutePower //人员管理(带权限) PersonnelRouteKingdee personnel.PersonnelRouteKingdee //人员管理Kingdee ShiyanApiRRouter shiyanrouter.ShiyanApiRouter EmpowerApiRouter empowerrote.EmpowerApiRouter diff --git a/apirouter/personnel/people.go b/apirouter/personnel/people.go index a55dc48..f42948c 100644 --- a/apirouter/personnel/people.go +++ b/apirouter/personnel/people.go @@ -168,3 +168,114 @@ func (p *PersonnelRouteKingdee) InitRouterGroup(route *gin.RouterGroup) { apiRouterOut.POST("personnelPositioning", apiHandleOut.PersonnelPositioning) //人员定位信息(简略) } } + +// 员工档案 +func (p *PersonnelRoutePower) InitRouterGroup(route *gin.RouterGroup) { + apiRouter := route.Group("staffp") + var apiHandle = version1.AppApiInlet.StaffApi + { + apiRouter.GET("", apiHandle.Index) //入口 + apiRouter.POST("", apiHandle.Index) //入口 + apiRouter.POST("stafflist", apiHandle.StaffList) //人员列表 + apiRouter.POST("addstaff", apiHandle.AddStaff) //添加人员档案 + apiRouter.POST("allocationofrights", apiHandle.AllocationOfRights) //分配权限 + // apiRouter.POST("archiveslist", apiHandle.ArchivesList) //人员列表(新) + // apiRouter.POST("archiveslist", apiHandle.ArchivesListWai) //人员列表(新)PeopleList + apiRouter.POST("archiveslist", apiHandle.PeopleList) //人员列表(新增加班组修订) + + apiRouter.POST("archiveslistcont", apiHandle.ArchivesListCont) //人员档案列表(平台用) + apiRouter.POST("archivescont", apiHandle.ArchivesCon) //个人档案 + apiRouter.POST("personnelFiles", apiHandle.PersonnelFiles) //根据工号获取个人档案 + apiRouter.POST("getPeopleColor", apiHandle.GetPeopleColor) //根据工号获取个人档案性格色彩 + apiRouter.POST("getPeopleKey", apiHandle.GetPeopleKey) //根据Key获取个人档案 + + apiRouter.POST("kingdeehr", apiHandle.NewKingdee) //对接金蝶HR系统 + apiRouter.POST("editpassword", apiHandle.EditPassWord) //修改密码 + apiRouter.POST("wechat_give_uscont", apiHandle.WeChatGiveUsCont) //根据微信OpenId获取个人档案 + apiRouter.POST("edit_us_wechat_openid", apiHandle.EditUsWechatOpenId) //修改员工微信或企业微信UserId + apiRouter.POST("edit_people_icon", apiHandle.EditPeopleIcon) //修改员工微信或企业微信UserId + + // apiRouter.POST("useraboutorglist", apiHandle.UserAboutOrgList) //行政组织关系 UserAboutOrgListNew + apiRouter.POST("useraboutorglist", apiHandle.UserAboutOrgListNew) //行政组织关系 + //双职工 + apiRouter.POST("doubleworkerlist", apiHandle.DoubleWorkerList) //双职工列表 + apiRouter.POST("adddoubleworker", apiHandle.AddDoubleWorkerApi) //添加双职工 + apiRouter.POST("eidtdoubleworker", apiHandle.EidtDoubleWorkerApi) //编辑双职工 + apiRouter.POST("eidtdoubleworkerstate", apiHandle.EidtDoubleWorkerState) //编辑双职工状态 + //员工资料 + apiRouter.POST("eidtstaffcont", apiHandle.EidtStaffCont) //编辑员工资料 + //紧急联系人 + apiRouter.POST("emergencycontactlist", apiHandle.EmergencyContactList) //紧急联系人列表 + apiRouter.POST("addemercycall", apiHandle.AddEmercyCall) //添加紧急联系人 + apiRouter.POST("editemercycall", apiHandle.EditEmercyCall) //编辑紧急联系人 + apiRouter.POST("editemercycallstate", apiHandle.EditEmercyCallState) //编辑紧急联系人状态 + //家庭成员 + apiRouter.POST("familymemberslist", apiHandle.FamilyMemBersList) //家庭成员列表 + apiRouter.POST("addfamilymembers", apiHandle.AddFamilyMembers) //添加家庭成员 + apiRouter.POST("editfamilymembers", apiHandle.EditFamilyMembers) //编辑家庭成员 + apiRouter.POST("editfamilymemberssatte", apiHandle.EditFamilyMembersSatte) //编辑家庭成员状态 + //教育经历 + apiRouter.POST("personneleducationlist", apiHandle.PersonnelEducationList) //教育经历列表 + apiRouter.POST("addeducationalexperience", apiHandle.AddEducationalExperience) //添加教育经历 + apiRouter.POST("editeducationalexperience", apiHandle.EditEducationalExperience) //编辑教育经历 + apiRouter.POST("editeduexpstate", apiHandle.EditEduExpState) //编辑教育经历状态 + //工作履历 + apiRouter.POST("workhistorylist", apiHandle.WorkHistoryList) //工作履历列表 + apiRouter.POST("addworkhistorycont", apiHandle.AddWorkHistoryCont) //添加工作履历 + apiRouter.POST("editworkhistorycont", apiHandle.EditWorkHistoryCont) //编辑工作履历 + apiRouter.POST("editworkhistorystate", apiHandle.EditWorkHistoryState) //编辑工作履历状态 + //集团工作履历 + apiRouter.POST("insideworkhistorylist", apiHandle.InsideWorkHistoryList) //集团工作履历列表 + apiRouter.POST("getinsideworkhistorylist", apiHandle.GetInsideWorkHistoryList) //集团工作履历列表(新版) + apiRouter.POST("addinsidehistory", apiHandle.AddInsideHistory) //添加集团工作履历 + apiRouter.POST("eidtinsidehistoryworkcont", apiHandle.EidtInsideHistoryWorkCont) //编辑集团工作履历 + apiRouter.POST("editordelinsideworkhistorystate", apiHandle.EditOrDelInsideWorkHistoryState) //编辑集团工作履历状态 + + apiRouter.POST("archives_list_exporcsv", apiHandle.ArchivesListExporCsv) //导出人员信息 + + apiRouter.POST("add_people_cont", apiHandle.AddPeopleCont) //写入人员信息(新版) + apiRouter.POST("get_archives_cont", apiHandle.GetArchivesCon) //获取人员基础信息(新版) + apiRouter.POST("get_people_main_cont", apiHandle.GetPeopleMainCont) //获取员工主信息 + apiRouter.POST("get_peo_data_integrity", apiHandle.GetPeopleDataIntegrity) //获取资料完整度 + apiRouter.POST("edit_man_org_cont", apiHandle.EditManOrgCont) //编辑人员行政组织 EditManMainCont + apiRouter.POST("edit_manmain_cont", apiHandle.EditManMainCont) //编辑人员主题信息 + + apiRouter.POST("judge_prin_position", apiHandle.JudgePrincipalPosition) //判断是否已经存在主职 + + apiRouter.POST("addinsidehistorynew", apiHandle.AddInsideHistoryNew) //添加集团工作履历(新版) + + apiRouter.POST("dimission_rate", apiHandle.DimissionRate) //离职率 + + apiRouter.POST("oneorg_dimission_rate", apiHandle.GetOenOrgDimRate) //获取单一行政组织离职率 + apiRouter.POST("getorgtimerate", apiHandle.GetOrgTimeRate) //获取公司指定年月的离职率 + apiRouter.POST("get_edu_stru", apiHandle.GetEducationalStructure) //获取学历结构 + + apiRouter.POST("uploadUserFiles", apiHandle.UploadUserFiles) //解析上传的人员信息表格 + apiRouter.POST("uploadUserFilesRedis", apiHandle.UploadUserFilesRedis) //解析上传的人员信息表格 + + apiRouter.POST("upLoadPeopelMerits", apiHandle.UpLoadPeopelMerits) //解析考评人员成绩统计表 + + apiRouter.POST("analysisRedisExelect", apiHandle.AnalysisRedisExelect) //解析Redis列表中的数据 + apiRouter.POST("analysisRedisOrgExelect", apiHandle.AnalysisRedisOrgExelect) //解析Redis列表中的数据 + + apiRouter.POST("anaRedisOrgStaffExc", apiHandle.AnalysisRedisOrgStaffExelect) //解析人员绩效成绩 + + apiRouter.POST("personnelPositioning", apiHandle.PersonnelPositioning) //人员定位信息(简略) + apiRouter.POST("gainSunOrgAndUser", apiHandle.GainSunOrgAndUser) //根据行政组织ID获取当前行政组织人员及子行政组织 + apiRouter.POST("searchOrgUser", apiHandle.SearchOrgUser) //搜索行政组织及人员 + + apiRouter.POST("rewPunList", apiHandle.RewPunList) //奖惩记录 + apiRouter.POST("assessmentRecords", apiHandle.AssessmentRecords) //绩效考核成绩 + apiRouter.POST("peopleEmploymentRelationship", apiHandle.PeopleEmploymentRelationship) //员工关系 + apiRouter.POST("peopleTitle", apiHandle.PeopleTitle) //职称列表 + apiRouter.POST("peopleHonor", apiHandle.PeopleHonor) //荣誉 + + apiRouter.POST("gainMyChengjiYears", apiHandle.GainMyChengjiYears) //获取个人年份评估成绩详情 + + apiRouter.POST("uploadTiemsManFiles", apiHandle.UploadTiemsManFiles) //上传班组设定人员 + apiRouter.POST("analysisRedisTimesExelect", apiHandle.AnalysisRedisTimesExelect) //解析人员信息!并写入数据库 + + apiRouter.POST("myTraining", apiHandle.MyTraining) //培训内容 + + } +} diff --git a/apirouter/personnel/type.go b/apirouter/personnel/type.go index 1d4affd..21ddc61 100644 --- a/apirouter/personnel/type.go +++ b/apirouter/personnel/type.go @@ -3,3 +3,5 @@ package personnel //人员管理方面 type PersonnelRoute struct{} type PersonnelRouteKingdee struct{} + +type PersonnelRoutePower struct{} diff --git a/config/configDatabase/database.go b/config/configDatabase/database.go index 074649f..0c3d4f5 100644 --- a/config/configDatabase/database.go +++ b/config/configDatabase/database.go @@ -20,6 +20,7 @@ type MysqlSetUp struct { HrNeiSever MasterMysqlSetUp `mapstructure:"hrNeiSever" json:"hrNeiSever" yaml:"hrNeiSever"` //HR数据库 HrDatabaseServer MasterMysqlSetUp `mapstructure:"hrdatabaseserver" json:"hrdatabaseserver" yaml:"hrdatabaseserver"` //外网HR数据库 CustomerForm MasterMysqlSetUp `mapstructure:"customerFormDatabase" json:"customerFormDatabase" yaml:"customerFormDatabase"` //自定义表单数据库 + SystemPermission MasterMysqlSetUp `mapstructure:"systempermission" json:"systempermission" yaml:"systempermission"` //系统权限配置数据库 } type MasterMysqlSetUp struct { diff --git a/config/configDatabase/database.yaml b/config/configDatabase/database.yaml index 012e071..aea4027 100644 --- a/config/configDatabase/database.yaml +++ b/config/configDatabase/database.yaml @@ -158,4 +158,18 @@ appPlatformDatabase: loc: 'Local' #时区 max_idle_conns: 100 #最大空闲数量 max_open_conns: 1500 #最大打开数量 + gorm_log: true #是否开启gorm日志 + +#系统权限配置数据库 +systemPermission: + url_path: '172.20.5.34' #数据库地址 + port: 4000 #数据库端口 + charset: 'utf8mb4' #数据库编码方式 + parseTime: 'True' #是否自动转换时间 + loc: 'Local' #时区 + name: 'system_empower' #数据库名称 + username: 'root' #数据库用户民 + password: '9z_Bu28r1*DZ3K6@+a' #数据库密码 + max_idle_conns: 100 #最大空闲数量 + max_open_conns: 1500 #最大打开数量 gorm_log: true #是否开启gorm日志 \ No newline at end of file diff --git a/identification/authentication.go b/identification/authentication.go index 74fcbd2..86a00ec 100644 --- a/identification/authentication.go +++ b/identification/authentication.go @@ -172,3 +172,101 @@ func Interceptor() gin.HandlerFunc { } } + +// 内部人员身份认证 +func Internaluthentication() gin.HandlerFunc { + return func(c *gin.Context) { + userKey := c.Request.Header.Get("user-key") + userToken := c.Request.Header.Get("user-token") + userAgent := c.Request.Header.Get("User-Agent") + userAgent = overall.CONSTANT_CONFIG.Appsetup.AppKey + if userKey == "" || userToken == "" || userAgent == "" { + overallhandle.Result(2001, "未登录或非法访问", c) + c.Abort() + return + } + redisFileKey := fmt.Sprintf("ScanCode:Authentication:LoginApi_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, userKey) + redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS5) + userRedisToken, isTrue := redisClient.HashGetAll(redisFileKey) + if isTrue == false { + overallhandle.Result(2001, "未登录或非法访问", c) + c.Abort() + return + } + if userToken != userRedisToken["usertoken"] { + overallhandle.Result(2001, "令牌不正确!非法访问!", c) + c.Abort() + return + } + myCont, myErr := overallhandle.GetUserRedisCont(userRedisToken["usernumber"]) + if myErr != nil { + overallhandle.Result(2001, "登录超时!请重新登录", c) + c.Abort() + return + } + fmt.Printf("\n\n\n获取登录信息------>%v------>%v\n\n\n", overall.MyContJwt, myCont) + c.Set(overall.MyContJwt, myCont) + writeRedisData := overallhandle.MapOut() + for i, v := range userRedisToken { + writeRedisData[i] = v + } + redisClient.SetRedisTime(10800) + redisClient.HashMsetAdd(redisFileKey, writeRedisData) + myContRedis := overallhandle.MapOut() + myContRedis["id"] = myCont.Id + myContRedis["number"] = myCont.Number //员工工号 + myContRedis["name"] = myCont.Name //姓名 + myContRedis["icon"] = myCont.Icon //头像 + myContRedis["hireclass"] = myCont.HireClass //雇佣类型(1:雇佣入职;2:再入职;) + myContRedis["emptype"] = myCont.EmpType //用工关系(1:临时工 , 2:编外人员 ;3:实习&实习生;4:试用员工;5:待分配;6:待岗;7:临时调入;8:正式员工;9:长期病假;10:停薪留职;11:退休;12:辞职;13:辞退;14:离职) + myContRedis["company"] = myCont.Company //入职公司 + myContRedis["maindeparment"] = myCont.MainDeparment //主部门 + myContRedis["sunmaindeparment"] = myCont.SunMainDeparment //二级主部门 + myContRedis["deparment"] = myCont.Deparment //部门 + myContRedis["adminorg"] = myCont.AdminOrg //所属行政组织 + myContRedis["teamid"] = myCont.TeamId //班组 + myContRedis["position"] = myCont.Position //职位 + myContRedis["jobclass"] = myCont.JobClass //职务分类 + myContRedis["jobid"] = myCont.JobId //职务 + myContRedis["jobleve"] = myCont.JobLeve //职务等级 + myContRedis["wechat"] = myCont.Wechat //微信UserId + myContRedis["workwechat"] = myCont.WorkWechat //企业微信UserId + myContRedis["state"] = myCont.State //状态(1:启用;2:禁用;3:删除) + myContRedis["key"] = myCont.Key //key + myContRedis["isadmin"] = myCont.IsAdmin //是否为管理员(1:不是;2:分公司;3:集团管理员;4:超级管 + myContRedis["password"] = myCont.Password //密码 + myContRedis["role"] = myCont.Role //角色 + myContRedis["idcardno"] = myCont.Idcardno //身份证号 + myContRedis["passportno"] = myCont.Passportno //护照号码 + myContRedis["globalroaming"] = myCont.Globalroaming //国际区号 + myContRedis["mobilephone"] = myCont.Mobilephone //手机号码 + myContRedis["email"] = myCont.Email //电子邮件 + myContRedis["gender"] = myCont.Gender //性别(1:男性;2:女性;3:中性) + myContRedis["birthday"] = myCont.Birthday //birthday + myContRedis["myfolk"] = myCont.Myfolk //民族 + myContRedis["nativeplace"] = myCont.Nativeplace //籍贯 + myContRedis["idcardstartdate"] = myCont.Idcardstartdate //身份证有效期开始 + myContRedis["idcardenddate"] = myCont.Idcardenddate //身份证有效期结束 + myContRedis["idcardaddress"] = myCont.Idcardaddress //身份证地址 + myContRedis["idcardIssued"] = myCont.IdcardIssued //身份证签发机关 + myContRedis["health"] = myCont.Health //健康状况(1:良好;2:一般;3:较弱,4:有生理缺陷;5:残废) + myContRedis["maritalstatus"] = myCont.Maritalstatus //婚姻状况(1:未婚;2:已婚;3:丧偶;4:离异) + myContRedis["internaltelephone"] = myCont.Internaltelephone //内线电话 + myContRedis["currentresidence"] = myCont.Currentresidence //现居住地址 + myContRedis["constellationing"] = myCont.Constellation //星座(1:白羊座;2:金牛座;3:双子座;4:巨蟹座;5:狮子座;6:处女座;7:天枰座;8:天蝎座;9:射手座;10:摩羯座;11:水瓶座;12:双鱼座) + myContRedis["isdoubleworker"] = myCont.Isdoubleworker //是否双职工(1:是;2:否) + myContRedis["isveterans"] = myCont.Isveterans //是否为退役军人(1:是;2:否) + myContRedis["veteransnumber"] = myCont.Veteransnumber //退役证编号 + myContRedis["jobstartdate"] = myCont.Jobstartdate //参加工作日期 + myContRedis["entrydate"] = myCont.Entrydate //入职日期 + myContRedis["probationperiod"] = myCont.Probationperiod //试用期 + myContRedis["planformaldate"] = myCont.Planformaldate //预计转正日期 + myContRedis["political_outlook"] = myCont.PoliticalOutlook //政治面貌(1:群众;2:无党派;3:台盟会员;4:九三社员;5:致公党员;6:农工党员;7:民进会员;8:民建会员;9:民盟盟员;10:民革会员,11:共青团员;12:预备党员;13:中共党员) + redisMyContKey := fmt.Sprintf("ScanCode:Authentication:UserCont_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, myCont.Number) + redisClient.HashMsetAdd(redisMyContKey, myContRedis) + var powerCont EmpowerCont + powerCont.RoleName, powerCont.PointId, powerCont.Operation, powerCont.Level = overallhandle.GetNewAccredit("kpi", myCont.Role, myCont.Key, myCont.AdminOrg, myCont.Position) + c.Set(overall.MyContJwtPower, powerCont) + c.Next() + } +} diff --git a/identification/type.go b/identification/type.go index 77f4c73..27ba31c 100644 --- a/identification/type.go +++ b/identification/type.go @@ -6,3 +6,11 @@ type ValidatorType struct { UserKey string `json:"userkey"` //用户名 PassWord string `json:"password"` //密码 } + +//权限相关 +type EmpowerCont struct { + RoleName string `json:"roleName"` + PointId string `json:"pointid"` + Operation string `json:"operation"` + Level int `json:"level"` +} diff --git a/initialization/databaseinit/mysql.go b/initialization/databaseinit/mysql.go index 4914d86..427c4f7 100644 --- a/initialization/databaseinit/mysql.go +++ b/initialization/databaseinit/mysql.go @@ -72,4 +72,11 @@ func LoadDatabase() { } else { fmt.Printf("%v:数据库开启成功!\n", sqlConfig.AppPlatformDatabase.Name) } + //系统权限配置数据库 + overall.CONSTANT_DB_System_Permission = sqlConfig.SystemPermission.OpenSql() + if overall.CONSTANT_DB_System_Permission == nil { + fmt.Printf("%v:数据库开启失败!\n", sqlConfig.SystemPermission.Name) + } else { + fmt.Printf("%v:数据库开启成功!\n", sqlConfig.SystemPermission.Name) + } } diff --git a/initialization/route/route_entry.go b/initialization/route/route_entry.go index c9e00a0..6b7e194 100644 --- a/initialization/route/route_entry.go +++ b/initialization/route/route_entry.go @@ -40,6 +40,8 @@ func InitialRouter() *gin.Engine { staffApi := apirouter.RouterGroupInlet.PersonnelRoute staffApiFuben := apirouter.RouterGroupInlet.PersonnelRouteKingdee + staffApiPower := apirouter.RouterGroupInlet.PersonnelRoutePower + //排班相关操作 rosteringApi := apirouter.RouterGroupInlet.RosteringApiRouter @@ -58,15 +60,20 @@ func InitialRouter() *gin.Engine { organizationApi.InitRouterGroup(appLoadRouterGroup) //组织架构 jinDieDockingApi.InitRouterGroup(appLoadRouterGroup) //金蝶对接接口 - staffApi.InitRouterGroup(appLoadRouterGroup) //人员档案 - rosteringApi.InitRouterGroup(appLoadRouterGroup) //排班相关操作 roleApi.InitRouterGroup(appLoadRouterGroup) //角色相关 wechatApiRouter.RouterGroupPc(appLoadRouterGroup) + staffApi.InitRouterGroup(appLoadRouterGroup) //人员档案 } + //内部身份认证 + IIAuton := router.Group("") + IIAuton.Use(identification.Internaluthentication()) + { + staffApiPower.InitRouterGroup(IIAuton) //人员档案 + } //身份验证 Authentication := router.Group("") diff --git a/models/man_cont.go b/models/man_cont.go index 374b8dc..339121d 100644 --- a/models/man_cont.go +++ b/models/man_cont.go @@ -1,6 +1,7 @@ package models import ( + "encoding/json" "hr_server/overall" "strings" ) @@ -84,3 +85,13 @@ func (cont *ManCont) GetCont(whereMap interface{}, field ...string) (err error) err = gormDb.First(&cont).Error return } + +// 获取当前登录信息 +func (c *ManCont) GetLoginCont(context any) (err error) { + jsonCont, err := json.Marshal(context) + if err != nil { + return + } + err = json.Unmarshal(jsonCont, c) + return +} diff --git a/models/modelssystempermission/appsystem.go b/models/modelssystempermission/appsystem.go new file mode 100644 index 0000000..2f76c6b --- /dev/null +++ b/models/modelssystempermission/appsystem.go @@ -0,0 +1,62 @@ +package modelssystempermission + +import ( + "hr_server/overall" + "strings" +) + +// 应用系统 +type Appsystem struct { + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` + Title string `json:"title" gorm:"column:title;type:varchar(255) ;comment:系统名称"` + Coder string `json:"coder" gorm:"column:coder;type:varchar(255) ;comment:识别符"` + State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` + Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` + Sort int `json:"sort" gorm:"column:sort;type:int(5) unsigned;default:50;not null;comment:排序"` + ApiUrl string `json:"apiurl" gorm:"column:api_url;type:varchar(255) ;comment:菜单访问权限列表"` +} + +func (Appsystem *Appsystem) TableName() string { + return "appsystem" +} + +// 编辑内容 +func (cont *Appsystem) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *Appsystem) 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 *Appsystem) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *Appsystem) ContMap(whereMap interface{}, field ...string) (countAry []Appsystem, 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 *Appsystem) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_System_Permission.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/modelssystempermission/custom_table_authorize.go b/models/modelssystempermission/custom_table_authorize.go new file mode 100644 index 0000000..ec55d7c --- /dev/null +++ b/models/modelssystempermission/custom_table_authorize.go @@ -0,0 +1,69 @@ +package modelssystempermission + +import ( + "hr_server/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 +} diff --git a/models/modelssystempermission/empower.go b/models/modelssystempermission/empower.go new file mode 100644 index 0000000..a8fd40e --- /dev/null +++ b/models/modelssystempermission/empower.go @@ -0,0 +1,65 @@ +package modelssystempermission + +import ( + "hr_server/overall" + "strings" +) + +// 权限配置 +type Empower struct { + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` + OrdId int64 `json:"ordid" gorm:"column:ordid;type:bigint(20) unsigned;default:0;not null;comment:行政组织"` + PostId int64 `json:"postid" gorm:"column:post_id;type:bigint(20) unsigned;default:0;not null;comment:岗位ID"` + System string `json:"system" gorm:"column:system;type:varchar(255) ;comment:系统"` + PointId string `json:"pointid" gorm:"column:point_id;type:longtext;comment:权限点位"` + State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` + Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` + Level int `json:"level" gorm:"column:level;type:int(1) unsigned;default:1;not null;comment:授权范围等级(1:本部门;2:本分部;3:所有)"` + Organization string `json:"organization" gorm:"column:organization;type:longtext;comment:行政组织"` + Operation string `json:"operation" gorm:"column:operation;type:longtext;comment:操作点位"` +} + +func (Empower *Empower) TableName() string { + return "empower" +} + +// 编辑内容 +func (cont *Empower) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *Empower) 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 *Empower) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *Empower) ContMap(whereMap interface{}, field ...string) (countAry []Empower, 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 *Empower) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_System_Permission.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/modelssystempermission/role_empower.go b/models/modelssystempermission/role_empower.go new file mode 100644 index 0000000..a0416d9 --- /dev/null +++ b/models/modelssystempermission/role_empower.go @@ -0,0 +1,64 @@ +package modelssystempermission + +import ( + "hr_server/overall" + "strings" +) + +// 权限配置 +type RoleEmpower struct { + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` + RoleId int64 `json:"roleid" gorm:"column:role_id;type:bigint(20) unsigned;default:0;not null;comment:行政组织"` + System string `json:"system" gorm:"column:system;type:varchar(255) ;comment:系统"` + PointId string `json:"pointid" gorm:"column:point_id;type:longtext;comment:权限点位"` + Operation string `json:"operation" gorm:"column:operation;type:longtext;comment:操作点位"` + State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` + Level int `json:"level" gorm:"column:level;type:int(1) unsigned;default:1;not null;comment:授权范围等级(1:本部门;2:本分部;3:所有)"` + Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` + Organization string `json:"organization" gorm:"column:organization;type:longtext;comment:行政组织列表"` +} + +func (RoleEmpower *RoleEmpower) TableName() string { + return "role_empower" +} + +// 编辑内容 +func (cont *RoleEmpower) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *RoleEmpower) 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 *RoleEmpower) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *RoleEmpower) ContMap(whereMap interface{}, field ...string) (countAry []RoleEmpower, 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 *RoleEmpower) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_System_Permission.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/modelssystempermission/system_role.go b/models/modelssystempermission/system_role.go new file mode 100644 index 0000000..cfeeb6b --- /dev/null +++ b/models/modelssystempermission/system_role.go @@ -0,0 +1,60 @@ +package modelssystempermission + +import ( + "hr_server/overall" + "strings" +) + +// 系统角色表 +type SystemRole struct { + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` + Name string `json:"name" gorm:"column:name;type:varchar(255) ;comment:系统名称"` + State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` + Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` + Sort int `json:"sort" gorm:"column:sort;type:int(5) unsigned;default:50;not null;comment:排序"` +} + +func (SystemRole *SystemRole) TableName() string { + return "system_role" +} + +// 编辑内容 +func (cont *SystemRole) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *SystemRole) 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 *SystemRole) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *SystemRole) ContMap(whereMap interface{}, field ...string) (countAry []SystemRole, 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 *SystemRole) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_System_Permission.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/personarchives.go b/models/personarchives.go index 42feee4..45b9db8 100644 --- a/models/personarchives.go +++ b/models/personarchives.go @@ -55,6 +55,7 @@ func (PersonArchives *PersonArchives) TableName() string { // 编辑员工档案 func (PersonArchives *PersonArchives) EiteCont(whereMap interface{}, saveData interface{}) (err error) { err = overall.CONSTANT_DB_HR.Model(&PersonArchives).Where(whereMap).Updates(saveData).Error + overall.CONSTANT_HRSERVER_DATABASE.Model(&PersonArchives).Where(whereMap).Updates(saveData) return } diff --git a/overall/app_config_const.go b/overall/app_config_const.go index 941519b..7f1c2d5 100644 --- a/overall/app_config_const.go +++ b/overall/app_config_const.go @@ -12,15 +12,16 @@ var ( //服务常量 CONSTANT_CONFIG configApp.Server // - CONSTANT_DB_Master *gorm.DB //主数据库 - CONSTANT_DB_Wechat *gorm.DB //微信数据库 - CONSTANT_DB_HR *gorm.DB //微信数据库 - CONSTANT_DB_HR_Jin *gorm.DB //微信数据库 - CONSTANT_Personality_Color *gorm.DB //性格色彩 - CONSTANT_Hr_Server *gorm.DB //性格色彩 - CONSTANT_HRSERVER_DATABASE *gorm.DB //性格色彩 - CONSTANT_DB_CustomerForm *gorm.DB //自定义表单数据库 - CONSTANT_DB_AppPlatform *gorm.DB //应用平台据库 + CONSTANT_DB_Master *gorm.DB //主数据库 + CONSTANT_DB_Wechat *gorm.DB //微信数据库 + CONSTANT_DB_HR *gorm.DB //微信数据库 + CONSTANT_DB_HR_Jin *gorm.DB //微信数据库 + CONSTANT_Personality_Color *gorm.DB //性格色彩 + CONSTANT_Hr_Server *gorm.DB //性格色彩 + CONSTANT_HRSERVER_DATABASE *gorm.DB //性格色彩 + CONSTANT_DB_CustomerForm *gorm.DB //自定义表单数据库 + CONSTANT_DB_AppPlatform *gorm.DB //应用平台据库 + CONSTANT_DB_System_Permission *gorm.DB //系统权限配置数据库 //Redis CONSTANT_REDIS0 *redis.Client CONSTANT_REDIS1 *redis.Client diff --git a/overall/app_constant.go b/overall/app_constant.go index 5a0e60a..eb51a0b 100644 --- a/overall/app_constant.go +++ b/overall/app_constant.go @@ -10,4 +10,6 @@ var ( // DockingKingdeeUrl = "http://36.134.44.40:18888" // DockingKingdeeUrl = "http://36.133.124.113:18888" //测试地址 DockingKingdeeUrl = "http://36.133.124.113:18888" //正式地址 + MyContJwt = "mycontjwt" + MyContJwtPower = "mycontjwtpower" ) diff --git a/overall/overallhandle/peopleLog.go b/overall/overallhandle/peopleLog.go index 26b7df1..b3d2262 100644 --- a/overall/overallhandle/peopleLog.go +++ b/overall/overallhandle/peopleLog.go @@ -1,18 +1,421 @@ package overallhandle -import "github.com/gin-gonic/gin" +import ( + "fmt" + "hr_server/grocerystore" + "hr_server/models" + "hr_server/models/modelssystempermission" + "hr_server/overall" + "strconv" + "strings" -/** + "github.com/gin-gonic/gin" + "gorm.io/gorm" +) + +/* +* @ 作者: 秦东 @ 时间: 2024-03-08 13:38:51 @ 功能: 人员操作记录 @ 参数 - # + + # + @ 返回值 - # + + # + @ 方法原型 - # + + # */ func WritePeopleLog(c *gin.Context, class string, errmsg ...any) { } + +/* +* +@ 作者: 秦东 +@ 时间: 2022-11-19 15:03:42 +@ 功能: 获取系统授权 +@ 参数 + + #roleId 角色ID + #systemName 系统名称 + #userKey 人员识别码 + #orgId 行政组织 + #postId 岗位 + +@ 返回值 + + #roleName 角色名称 + #pointId 菜单权限 + #operation 操作权限 + #level 操作等级 + +@ 方法原型 + + #func GetNewAccredit(systemName, roleId string, userKey, orgId, postId int64) (roleName, pointId, operation string, level int) +*/ +func GetNewAccredit(systemName, roleId string, userKey, orgId, postId int64) (roleName, pointId, operation string, level int) { + redisFileKey := fmt.Sprintf("Licence:PowerLoginApi_%v_%v_%v_%v", systemName, userKey, orgId, postId) + redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS3) + userRedisToken, isTrue := redisClient.HashGetAll(redisFileKey) + if isTrue == false { + var pointIdAry []string + var operationAry []string + if roleId != "" { + roleIdAry := strings.Split(roleId, ",") + var roleCont []modelssystempermission.SystemRole + if len(roleIdAry) > 0 { + err := overall.CONSTANT_DB_Master.Model(&modelssystempermission.SystemRole{}).Select("`name`").Where("`id` IN ?", roleIdAry).Find(&roleCont).Error + if err == nil && len(roleCont) > 0 { + var roleNameAry []string + for _, rnv := range roleCont { + if IsInTrue[string](rnv.Name, roleNameAry) == false { + roleNameAry = append(roleNameAry, rnv.Name) + } + } + roleName = strings.Join(roleNameAry, "|") + } + //获取配置的所有角色权限 + var roleEmpowerCont []modelssystempermission.RoleEmpower + err = overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.RoleEmpower{}).Select("`point_id`,`operation`,`level`").Where("`system` = ? AND `role_id` IN ?", systemName, roleIdAry).Find(&roleEmpowerCont).Error + if err == nil && len(roleEmpowerCont) > 0 { + for _, rev := range roleEmpowerCont { + menuList := strings.Split(rev.PointId, ",") + for _, mv := range menuList { //菜单权限 + if mv != "" && IsInTrue[string](mv, pointIdAry) == false { + pointIdAry = append(pointIdAry, mv) + } + } + operList := strings.Split(rev.Operation, ",") + for _, ov := range operList { //操作权限 + if ov != "" && IsInTrue[string](ov, operationAry) == false { + operationAry = append(operationAry, ov) + } + } + if level < rev.Level { + level = rev.Level //等级 + } + } + } + } + } + //获取行政组织授权 + if orgId > 0 && postId > 0 { + var orgEmpowerCont modelssystempermission.Empower + orgEmpowerCont.GetCont(map[string]interface{}{"`ordid`": orgId, "`post_id`": postId, "`system`": systemName}, "`point_id`", "`operation`", "`level`") + if len(pointIdAry) < 1 { //判断是否已经配过权限 + pointIdAry = strings.Split(orgEmpowerCont.PointId, ",") + } else { + guoduPoin := strings.Split(orgEmpowerCont.PointId, ",") + for _, pv := range guoduPoin { //合并权限 + if pv != "" && IsInTrue[string](pv, pointIdAry) == false { + pointIdAry = append(pointIdAry, pv) + } + } + + } + if len(operationAry) < 1 { //判断是否已经配过权限 + operationAry = strings.Split(orgEmpowerCont.Operation, ",") + } else { + guoduOper := strings.Split(orgEmpowerCont.Operation, ",") + for _, gpv := range guoduOper { //合并权限 + if gpv != "" && IsInTrue[string](gpv, operationAry) == false { + operationAry = append(operationAry, gpv) + } + } + + } + if level < orgEmpowerCont.Level { + level = orgEmpowerCont.Level + } + } + pointId = strings.Join(pointIdAry, ",") + operation = strings.Join(operationAry, ",") + + var powerCont EmpowerCont + powerCont.RoleName = roleName + powerCont.PointId = pointId + powerCont.Operation = operation + powerCont.Level = level + //组转写入redis + myContRedis := MapOut() + myContRedis["roleName"] = roleName + myContRedis["pointid"] = pointId + myContRedis["operation"] = operation + myContRedis["level"] = level + redisClient.SetRedisTime(10800) + redisClient.HashMsetAdd(redisFileKey, myContRedis) + } else { + roleName = userRedisToken["roleName"] + pointId = userRedisToken["pointid"] + operation = userRedisToken["operation"] + level, _ = strconv.Atoi(userRedisToken["level"]) + //组转写入redis + writeRedisData := MapOut() + for i, v := range userRedisToken { + writeRedisData[i] = v + } + redisClient.SetRedisTime(10800) + redisClient.HashMsetAdd(redisFileKey, writeRedisData) + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-05-21 08:44:35 +@ 功能: 获取用户权限 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (g *GainUserPower) GetUserPower() (powerInfo SendUserPower) { + //正常系统权限配置 + orgLook := []int64{} + if g.RoleId != "" { + roleAry := strings.Split(g.RoleId, ",") + fmt.Printf("\n\n\n角色----------->%v----------->%v\n\n\n", roleAry, len(roleAry) > 0) + 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).Find(&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) + } + } + } + } + } + } + + fmt.Printf("\n\n\n角色权限----------->%v\n\n\n", powerInfo.System.Level) + + 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) + } + } + } + } + + fmt.Printf("\n\n\n职务权限----------->%v\n\n\n", powerInfo.System.Level) + + _, companyId, departmentId, _, workShopId := GetOrgStructure(g.OrgId) + switch powerInfo.System.Level { + case 1: + powerInfo.System.OrgList = []int64{} + var sunOrg GetOrgAllParent + sunOrg.GetGCSOrgSonAllId(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.GetGCSOrgSonAllId(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.GetGCSOrgSonAllId(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.GetGCSOrgSonAllId(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.GetGCSOrgSonAllId(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.GetGCSOrgSonAllId(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 models.ManCont, isOdeb string) *gorm.DB { + powerInfo := g.GetUserPower() + fmt.Printf("\n\n\n等级-----%v------->%v\n\n\n", powerInfo.System.Level, g) + if isOdeb == "yes" { + switch powerInfo.AppSystem.Level { + case 2, 3, 4: + if len(powerInfo.AppSystem.OrgList) > 0 { + gormDb = gormDb.Where("`admin_org` IN ?", powerInfo.AppSystem.OrgList) + } else { + if userCont.Key != 0 { + gormDb = gormDb.Where("`key` = ?", userCont.Key) + } + } + case 6: + + default: + if userCont.Key != 0 { + gormDb = gormDb.Where("`key` = ?", userCont.Key) + } + } + } else { + switch powerInfo.System.Level { + case 1, 2, 3, 4: + if len(powerInfo.AppSystem.OrgList) > 0 { + gormDb = gormDb.Where("`admin_org` IN ?", powerInfo.AppSystem.OrgList) + } else { + if userCont.Key != 0 { + gormDb = gormDb.Where("`key` = ?", userCont.Key) + } + + } + case 5: + + default: + if userCont.Key != 0 { + gormDb = gormDb.Where("`key` = ?", userCont.Key) + } + } + } + + return gormDb +} diff --git a/overall/overallhandle/type.go b/overall/overallhandle/type.go index 01451ce..a21cf0a 100644 --- a/overall/overallhandle/type.go +++ b/overall/overallhandle/type.go @@ -151,3 +151,34 @@ type NodePowerInfo struct { NodeKey string `json:"nodeKey"` PowerAry []NodesUnitNameStatue `json:"powerAry"` } + +// 权限相关 +type EmpowerCont struct { + RoleName string `json:"roleName"` + PointId string `json:"pointid"` + Operation string `json:"operation"` + Level int `json:"level"` +} + +// 获取权限参数 +type GainUserPower struct { + SystemName string //系统名称 + RoleId string //角色列表 + OrgId int64 //行政组织 + PostId int64 //岗位 + AppKey int64 //归属哪个App + TableId int64 //归属哪个表格 +} + +// 输出用户的权限 +type SendUserPower struct { + System SystemPower + AppSystem SystemPower +} + +type SystemPower struct { + Level int //级别 + PointId []string //菜单级&表格 + Operation []string //按钮级&列表 + OrgList []int64 //可见行政组织&数据可见行政组织 +} diff --git a/scheduledtask/time_task.go b/scheduledtask/time_task.go index 9bb529d..c57826a 100644 --- a/scheduledtask/time_task.go +++ b/scheduledtask/time_task.go @@ -349,6 +349,11 @@ func TimeTask() { workWechat.NewTimedTasksForOrgWechat(330) overallhandle.WriteLog("t", "结束执行企业微信信息对照(恒信新能源)") }) //每天3时40分执行 + c.AddFunc("0 15 5 * * *", func() { + overallhandle.WriteLog("t", "开始执行荣信集团企业微信信息对照(设备动力部)") + workWechat.NewTimedTasksForOrgWechat(361) + overallhandle.WriteLog("t", "结束执行企业微信信息对照(设备动力部)") + }) //每天5时15分执行 //新材料