83 changed files with 9089 additions and 336 deletions
@ -1,3 +1,14 @@ |
|||||
{ |
{ |
||||
"idf.pythonInstallPath": "f:\\esp32\\toolsides\\tools\\idf-python\\3.11.2\\python.exe" |
"idf.pythonInstallPath": "f:\\esp32\\toolsides\\tools\\idf-python\\3.11.2\\python.exe", |
||||
|
"editor.gotoLocation.alternativeDeclarationCommand": "editor.action.revealDefinition", |
||||
|
"editor.gotoLocation.alternativeDefinitionCommand": "editor.action.revealDefinition", |
||||
|
"editor.gotoLocation.alternativeTypeDefinitionCommand": "editor.action.revealDefinition", |
||||
|
"editor.selectionHighlight": false, |
||||
|
"files.autoSave": "onFocusChange", |
||||
|
"editor.suggest.snippetsPreventQuickSuggestions": false, |
||||
|
"editor.quickSuggestions": { |
||||
|
"other": "on", |
||||
|
"comments": "off", |
||||
|
"strings": "on" |
||||
|
} |
||||
} |
} |
||||
@ -0,0 +1,172 @@ |
|||||
|
package authentication |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/middleware/grocerystore" |
||||
|
"appPlatform/models/modelshr" |
||||
|
"appPlatform/models/modelsschool" |
||||
|
"appPlatform/overall" |
||||
|
"appPlatform/overall/publicmethod" |
||||
|
"fmt" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-08-13 15:30:06 |
||||
|
@ 功能: 获取身份 |
||||
|
*/ |
||||
|
func (a *ApiMethod) HaveMyCode(c *gin.Context) { |
||||
|
var requestData publicmethod.CommonId[string] |
||||
|
err := c.ShouldBindJSON(&requestData) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(200, err, c) |
||||
|
return |
||||
|
} |
||||
|
if requestData.Id == "" { |
||||
|
publicmethod.Result(200, err, c, "未知行政组织!") |
||||
|
return |
||||
|
} |
||||
|
var userCont modelshr.ManCont |
||||
|
err = overall.CONSTANT_DB_HR.Model(&modelshr.ManCont{}).Where("`state` = 1 AND `emp_type` BETWEEN ? AND ? AND `number` = ?", 1, 10, requestData.Id).First(&userCont).Error |
||||
|
if err != nil { |
||||
|
publicmethod.Result(200, err, c) |
||||
|
return |
||||
|
} |
||||
|
userAgent := overall.CONSTANT_CONFIG.Appsetup.AppKey |
||||
|
//加密固定参数
|
||||
|
var md5JiaMi publicmethod.Md5Encryption |
||||
|
md5JiaMi.Md5EncryptionInit(userAgent) |
||||
|
md5Token := md5JiaMi.Md5EncryptionAlgorithm() |
||||
|
//加密工号
|
||||
|
var md5JiaMiNumber publicmethod.Md5Encryption |
||||
|
md5JiaMiNumber.Md5EncryptionInit(userCont.Number) |
||||
|
userKeyCode := md5JiaMiNumber.Md5EncryptionAlgorithm() |
||||
|
|
||||
|
sha1Str := userKeyCode + userCont.Number + userCont.Password + md5Token |
||||
|
sha1Token := publicmethod.Sha1Encryption(sha1Str) |
||||
|
menuoper, jurisdiction := getRoleSeat(userCont.Role) |
||||
|
writeRedisData := map[string]interface{}{ |
||||
|
"userkey": userKeyCode, |
||||
|
"key": userCont.Key, |
||||
|
"usernumber": userCont.Number, |
||||
|
"userpwd": userCont.Password, |
||||
|
"usertoken": sha1Token, |
||||
|
"jurisdiction": jurisdiction, |
||||
|
"menuOper": menuoper, |
||||
|
"wand": 118, |
||||
|
} |
||||
|
//API Token数据
|
||||
|
redisFileKey := fmt.Sprintf("ScanCode:Authentication:LoginApi_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, userKeyCode) |
||||
|
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS5) |
||||
|
redisClient.SetRedisTime(10800) |
||||
|
redisClient.HashMsetAdd(redisFileKey, writeRedisData) |
||||
|
|
||||
|
saveData := publicmethod.MapOut[string]() |
||||
|
saveData["key"] = userKeyCode |
||||
|
saveData["token"] = sha1Token |
||||
|
|
||||
|
_, companyId, _, sunDepartId, _ := publicmethod.GetOrgStructurees(userCont.AdminOrg) |
||||
|
|
||||
|
var sunmaindeparment int64 |
||||
|
|
||||
|
if companyId != sunDepartId { |
||||
|
sunmaindeparment = sunDepartId |
||||
|
} |
||||
|
|
||||
|
//缓存写入个人信息
|
||||
|
redisMyContKey := fmt.Sprintf("ScanCode:Authentication:UserCont_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, userCont.Number) |
||||
|
myCont := publicmethod.MapOut[string]() |
||||
|
myCont["id"] = userCont.Id |
||||
|
myCont["number"] = userCont.Number //员工工号
|
||||
|
myCont["name"] = userCont.Name //姓名
|
||||
|
myCont["icon"] = userCont.Icon //头像
|
||||
|
myCont["hireclass"] = userCont.HireClass //雇佣类型(1:雇佣入职;2:再入职;)
|
||||
|
myCont["emptype"] = userCont.EmpType //用工关系(1:临时工 , 2:编外人员 ;3:实习&实习生;4:试用员工;5:待分配;6:待岗;7:临时调入;8:正式员工;9:长期病假;10:停薪留职;11:退休;12:辞职;13:辞退;14:离职)
|
||||
|
myCont["company"] = userCont.Company //入职公司
|
||||
|
// myCont["maindeparment"] = userCont.MainDeparment //主部门
|
||||
|
// myCont["sunmaindeparment"] = userCont.SunMainDeparment //二级主部门
|
||||
|
myCont["maindeparment"] = companyId //主部门
|
||||
|
myCont["sunmaindeparment"] = sunmaindeparment //二级主部门
|
||||
|
|
||||
|
myCont["deparment"] = userCont.Deparment //部门
|
||||
|
myCont["adminorg"] = userCont.AdminOrg //所属行政组织
|
||||
|
myCont["teamid"] = userCont.TeamId //班组
|
||||
|
myCont["position"] = userCont.Position //职位
|
||||
|
myCont["jobclass"] = userCont.JobClass //职务分类
|
||||
|
myCont["jobid"] = userCont.JobId //职务
|
||||
|
myCont["jobleve"] = userCont.JobLeve //职务等级
|
||||
|
myCont["wechat"] = userCont.Wechat //微信UserId
|
||||
|
myCont["workwechat"] = userCont.WorkWechat //企业微信UserId
|
||||
|
myCont["state"] = userCont.State //状态(1:启用;2:禁用;3:删除)
|
||||
|
myCont["key"] = userCont.Key //key
|
||||
|
myCont["isadmin"] = userCont.IsAdmin //是否为管理员(1:不是;2:分公司;3:集团管理员;4:超级管
|
||||
|
myCont["password"] = userCont.Password //密码
|
||||
|
myCont["role"] = userCont.Role //角色
|
||||
|
myCont["idcardno"] = userCont.Idcardno //身份证号
|
||||
|
myCont["passportno"] = userCont.Passportno //护照号码
|
||||
|
myCont["globalroaming"] = userCont.Globalroaming //国际区号
|
||||
|
myCont["mobilephone"] = userCont.Mobilephone //手机号码
|
||||
|
myCont["email"] = userCont.Email //电子邮件
|
||||
|
myCont["gender"] = userCont.Gender //性别(1:男性;2:女性;3:中性)
|
||||
|
myCont["birthday"] = userCont.Birthday //birthday
|
||||
|
myCont["myfolk"] = userCont.Myfolk //民族
|
||||
|
myCont["nativeplace"] = userCont.Nativeplace //籍贯
|
||||
|
myCont["idcardstartdate"] = userCont.Idcardstartdate //身份证有效期开始
|
||||
|
myCont["idcardenddate"] = userCont.Idcardenddate //身份证有效期结束
|
||||
|
myCont["idcardaddress"] = userCont.Idcardaddress //身份证地址
|
||||
|
myCont["idcardIssued"] = userCont.IdcardIssued //身份证签发机关
|
||||
|
myCont["health"] = userCont.Health //健康状况(1:良好;2:一般;3:较弱,4:有生理缺陷;5:残废)
|
||||
|
myCont["maritalstatus"] = userCont.Maritalstatus //婚姻状况(1:未婚;2:已婚;3:丧偶;4:离异)
|
||||
|
myCont["internaltelephone"] = userCont.Internaltelephone //内线电话
|
||||
|
myCont["currentresidence"] = userCont.Currentresidence //现居住地址
|
||||
|
myCont["constellationing"] = userCont.Constellation //星座(1:白羊座;2:金牛座;3:双子座;4:巨蟹座;5:狮子座;6:处女座;7:天枰座;8:天蝎座;9:射手座;10:摩羯座;11:水瓶座;12:双鱼座)
|
||||
|
myCont["isdoubleworker"] = userCont.Isdoubleworker //是否双职工(1:是;2:否)
|
||||
|
myCont["isveterans"] = userCont.Isveterans //是否为退役军人(1:是;2:否)
|
||||
|
myCont["veteransnumber"] = userCont.Veteransnumber //退役证编号
|
||||
|
myCont["jobstartdate"] = userCont.Jobstartdate //参加工作日期
|
||||
|
myCont["entrydate"] = userCont.Entrydate //入职日期
|
||||
|
myCont["probationperiod"] = userCont.Probationperiod //试用期
|
||||
|
myCont["planformaldate"] = userCont.Planformaldate //预计转正日期
|
||||
|
myCont["political_outlook"] = userCont.PoliticalOutlook //政治面貌(1:群众;2:无党派;3:台盟会员;4:九三社员;5:致公党员;6:农工党员;7:民进会员;8:民建会员;9:民盟盟员;10:民革会员,11:共青团员;12:预备党员;13:中共党员)
|
||||
|
|
||||
|
var companyCont modelshr.AdministrativeOrganization |
||||
|
companyCont.GetCont(map[string]interface{}{"`id`": userCont.Company}, "`name`") |
||||
|
myCont["companyname"] = companyCont.Name |
||||
|
var departmentCont modelshr.AdministrativeOrganization |
||||
|
departmentCont.GetCont(map[string]interface{}{"`id`": userCont.MainDeparment}, "`name`") |
||||
|
myCont["maindeparmentname"] = departmentCont.Name |
||||
|
var postInfo modelshr.Position |
||||
|
postInfo.GetCont(map[string]interface{}{"`id`": userCont.Position}, "`name`") |
||||
|
myCont["positionname"] = postInfo.Name |
||||
|
redisClient.HashMsetAdd(redisMyContKey, myCont) |
||||
|
|
||||
|
// saveData["usercont"] = myCont
|
||||
|
|
||||
|
// var sendKpiCont WriteIderCont
|
||||
|
// sendKpiCont.Openid = requestData.Id
|
||||
|
// sendKpiCont.Key = userKeyCode
|
||||
|
// sendKpiCont.Token = sha1Token
|
||||
|
// sendKpiCont.UserInfo.Key = strconv.FormatInt(userCont.Key, 10)
|
||||
|
// sendKpiCont.UserInfo.Number = userCont.Number
|
||||
|
// sendKpiCont.UserInfo.Password = userCont.Password
|
||||
|
// sendDate, _ := json.Marshal(sendKpiCont)
|
||||
|
// publicmethod.CurlPostJosn("http://120.224.6.6:39168/shiyan/write_token", sendDate)
|
||||
|
|
||||
|
publicmethod.Result(0, saveData, c) |
||||
|
} |
||||
|
|
||||
|
// 获取权限点位
|
||||
|
func getRoleSeat(roleId string) (menuStr, buttonStr string) { |
||||
|
var roleInfo modelsschool.SystemRole |
||||
|
err := roleInfo.GetCont(map[string]interface{}{"r_id": roleId}, "r_menu_oper", "r_jurisdiction") |
||||
|
if err != nil { |
||||
|
return |
||||
|
} |
||||
|
menuStr = roleInfo.MenuOper |
||||
|
buttonStr = roleInfo.Jurisdiction |
||||
|
// jsonStr, _ := json.Marshal(roleInfo)
|
||||
|
// fmt.Printf("roleInfo-->%v-menuStr->%v\n-buttonStr->%v----jsonStr--->%v\n", roleId, menuStr, buttonStr, string(jsonStr))
|
||||
|
return |
||||
|
} |
||||
@ -0,0 +1,313 @@ |
|||||
|
package authentication |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/models/modelshr" |
||||
|
"appPlatform/models/modelssystempermission" |
||||
|
"appPlatform/overall" |
||||
|
"appPlatform/overall/publicmethod" |
||||
|
"fmt" |
||||
|
"sort" |
||||
|
"strconv" |
||||
|
"time" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-10-23 09:07:27 |
||||
|
@ 功能: 获取角色树 |
||||
|
*/ |
||||
|
func (a *RoleApiMethod) GiveRoleTree(c *gin.Context) { |
||||
|
var roleList []modelssystempermission.SystemRole |
||||
|
err := overall.CONSTANT_DB_System_Permission.Where("`state` IN (1,2)").Find(&roleList).Error |
||||
|
var sendRoleList []RolePower |
||||
|
if err != nil || len(roleList) < 1 { |
||||
|
publicmethod.Result(0, sendRoleList, c) |
||||
|
return |
||||
|
} |
||||
|
sort.Slice(roleList, func(i, j int) bool { |
||||
|
return roleList[i].Sort < roleList[j].Sort |
||||
|
}) |
||||
|
sendRoleList = InfiniteRoleTree(0, roleList) |
||||
|
publicmethod.Result(0, sendRoleList, c) |
||||
|
} |
||||
|
|
||||
|
// 递归无线角色菜单
|
||||
|
func InfiniteRoleTree(parentId int64, threeData []modelssystempermission.SystemRole) []RolePower { |
||||
|
var roleTree []RolePower |
||||
|
for _, v := range threeData { |
||||
|
if v.Superior == parentId { |
||||
|
var roleInfo RolePower |
||||
|
roleInfo.Id = strconv.FormatInt(v.Id, 10) |
||||
|
roleInfo.Label = v.Name |
||||
|
roleInfo.Types = strconv.Itoa(v.Types) |
||||
|
if v.State == 1 { |
||||
|
roleInfo.Status = true |
||||
|
} else { |
||||
|
roleInfo.Status = false |
||||
|
} |
||||
|
roleInfo.Superior = strconv.FormatInt(v.Superior, 10) |
||||
|
roleInfo.Sort = v.Sort |
||||
|
roleInfo.Children = InfiniteRoleTree(v.Id, threeData) |
||||
|
roleTree = append(roleTree, roleInfo) |
||||
|
} |
||||
|
} |
||||
|
return roleTree |
||||
|
} |
||||
|
|
||||
|
// 获取角色分组树
|
||||
|
func (a *RoleApiMethod) GiveRoleGroupTree(c *gin.Context) { |
||||
|
var roleList []modelssystempermission.SystemRole |
||||
|
err := overall.CONSTANT_DB_System_Permission.Where("`state` IN (1,2) AND `types` = 2").Find(&roleList).Error |
||||
|
var sendRoleList []RolePower |
||||
|
if err != nil || len(roleList) < 1 { |
||||
|
publicmethod.Result(0, sendRoleList, c) |
||||
|
return |
||||
|
} |
||||
|
sort.Slice(roleList, func(i, j int) bool { |
||||
|
return roleList[i].Sort < roleList[j].Sort |
||||
|
}) |
||||
|
sendRoleList = InfiniteRoleTree(0, roleList) |
||||
|
publicmethod.Result(0, sendRoleList, c) |
||||
|
} |
||||
|
|
||||
|
// 编辑角色组
|
||||
|
func (a *RoleApiMethod) EditRoleCont(c *gin.Context) { |
||||
|
var request EditInfoRole |
||||
|
err := c.ShouldBindJSON(&request) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(1, err, c) |
||||
|
return |
||||
|
} |
||||
|
roleType := 2 |
||||
|
if request.Types == "" { |
||||
|
roleType = 2 |
||||
|
} else { |
||||
|
roleType, _ = strconv.Atoi(request.Types) |
||||
|
} |
||||
|
if request.Id == "" || request.Id == "0" { |
||||
|
err = AddRoleCont(request) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(1, err, c) |
||||
|
return |
||||
|
} |
||||
|
publicmethod.Result(0, err, c) |
||||
|
} else { |
||||
|
var roleInfo modelssystempermission.SystemRole |
||||
|
err = roleInfo.GetCont(map[string]interface{}{"`id`": request.Id}) |
||||
|
if err != nil || roleInfo.Id == 0 { |
||||
|
err = AddRoleCont(request) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(1, err, c) |
||||
|
return |
||||
|
} |
||||
|
publicmethod.Result(0, err, c) |
||||
|
} else { |
||||
|
saveData := publicmethod.MapOut[string]() |
||||
|
if request.Name != "" && request.Name != roleInfo.Name { |
||||
|
saveData["name"] = request.Name |
||||
|
} |
||||
|
if request.Sort != 0 && request.Sort != roleInfo.Sort { |
||||
|
saveData["sort"] = request.Sort |
||||
|
} |
||||
|
var roleSuper int64 |
||||
|
if request.Superior != "" { |
||||
|
roleSuper, _ = strconv.ParseInt(request.Superior, 10, 64) |
||||
|
} |
||||
|
if roleSuper != roleInfo.Superior { |
||||
|
saveData["superior"] = roleSuper |
||||
|
} |
||||
|
if roleType != roleInfo.Types { |
||||
|
saveData["types"] = roleType |
||||
|
} |
||||
|
if len(saveData) > 0 { |
||||
|
saveData["`time`"] = time.Now().Unix() |
||||
|
var saveRoleInfo modelssystempermission.SystemRole |
||||
|
err = saveRoleInfo.EiteCont(map[string]interface{}{"`id`": roleInfo.Id}, saveData) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(1, err, c) |
||||
|
return |
||||
|
} |
||||
|
} |
||||
|
publicmethod.Result(0, err, c) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-10-23 15:06:53 |
||||
|
@ 功能: 新增角色 |
||||
|
*/ |
||||
|
func AddRoleCont(saveData EditInfoRole) (err error) { |
||||
|
roleType := 2 |
||||
|
if saveData.Types == "" { |
||||
|
roleType = 2 |
||||
|
} else { |
||||
|
roleType, _ = strconv.Atoi(saveData.Types) |
||||
|
} |
||||
|
var saveRoleInfo modelssystempermission.SystemRole |
||||
|
saveRoleInfo.Name = saveData.Name //系统名称"`
|
||||
|
saveRoleInfo.State = 1 //状态(1:启用;2:禁用;3:删除)"`
|
||||
|
saveRoleInfo.Time = time.Now().Unix() //创建时间"`
|
||||
|
saveRoleInfo.Sort = saveData.Sort //排序"`
|
||||
|
saveRoleInfo.Types = roleType //类型"`
|
||||
|
saveRoleInfo.Superior, _ = strconv.ParseInt(saveData.Superior, 10, 64) //上级"`
|
||||
|
err = overall.CONSTANT_DB_System_Permission.Create(&saveRoleInfo).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-10-23 16:52:54 |
||||
|
@ 功能: 修改角色状态 |
||||
|
*/ |
||||
|
func (a *RoleApiMethod) EditRoleStatus(c *gin.Context) { |
||||
|
var request EditRoleState |
||||
|
err := c.ShouldBindJSON(&request) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(1, err, c) |
||||
|
return |
||||
|
} |
||||
|
if request.Id == "" { |
||||
|
publicmethod.Result(1, err, c, "未知角色!") |
||||
|
return |
||||
|
} |
||||
|
var roleInfo modelssystempermission.SystemRole |
||||
|
err = roleInfo.GetCont(map[string]interface{}{"`id`": request.Id}) |
||||
|
if err != nil || roleInfo.Id == 0 { |
||||
|
publicmethod.Result(1, err, c) |
||||
|
return |
||||
|
} |
||||
|
var allSunId GetAllSunId |
||||
|
allSunId.GaveMySunAll(roleInfo.Id) |
||||
|
allSunId.Id = append(allSunId.Id, roleInfo.Id) |
||||
|
if request.Status == 0 { |
||||
|
request.Status = 1 |
||||
|
} |
||||
|
|
||||
|
saveData := publicmethod.MapOut[string]() |
||||
|
saveData["`state`"] = request.Status |
||||
|
saveData["`time`"] = time.Now().Unix() |
||||
|
var saveRoleInfo modelssystempermission.SystemRole |
||||
|
// err = saveRoleInfo.EiteCont(map[string]interface{}{"`id`": request.Id}, saveData)
|
||||
|
err = overall.CONSTANT_DB_System_Permission.Model(&saveRoleInfo).Where("`id` IN ?", allSunId.Id).Updates(saveData).Error |
||||
|
if err != nil { |
||||
|
publicmethod.Result(1, err, c) |
||||
|
return |
||||
|
} |
||||
|
publicmethod.Result(0, err, c) |
||||
|
} |
||||
|
|
||||
|
// 获取所有子集
|
||||
|
func (g *GetAllSunId) GaveMySunAll(parentId int64) { |
||||
|
var id []int64 |
||||
|
overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.SystemRole{}).Select("`id`").Where("`superior` = ?", parentId).Find(&id) |
||||
|
if len(id) > 0 { |
||||
|
for _, v := range id { |
||||
|
if v != 0 { |
||||
|
if !publicmethod.IsInTrue[int64](v, g.Id) { |
||||
|
g.Id = append(g.Id, v) |
||||
|
} |
||||
|
g.GaveMySunAll(v) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 获取行政组织加岗位树
|
||||
|
func (a *RoleApiMethod) GetOrgPostTree(c *gin.Context) { |
||||
|
var request publicmethod.PublicId |
||||
|
c.ShouldBindJSON(&request) |
||||
|
var orgId int64 |
||||
|
var sunOrgList publicmethod.GetOrgAllParent |
||||
|
if request.Id != "" { |
||||
|
orgId, _ = strconv.ParseInt(request.Id, 10, 64) |
||||
|
if orgId != 0 { |
||||
|
sunOrgList.GetOrgSun(orgId) |
||||
|
} |
||||
|
if len(sunOrgList.Id) > 0 { |
||||
|
sunOrgList.Id = append(sunOrgList.Id, orgId) |
||||
|
} |
||||
|
} else { |
||||
|
orgId = 0 |
||||
|
} |
||||
|
var list []modelshr.OrgCont |
||||
|
var postList []modelshr.Position |
||||
|
if len(sunOrgList.Id) > 0 { |
||||
|
overall.CONSTANT_DB_HR.Model(&modelshr.OrgCont{}).Where("`state` = 1 AND `id` IN ?", sunOrgList.Id).Find(&list) |
||||
|
overall.CONSTANT_DB_HR.Model(&modelshr.Position{}).Where("`state` = 1 AND `administrative_organization` IN ?", sunOrgList.Id).Find(&postList) |
||||
|
} else { |
||||
|
if orgId > 0 { |
||||
|
overall.CONSTANT_DB_HR.Model(&modelshr.OrgCont{}).Where("`state` = 1 AND `id` = ?", orgId).Find(&list) |
||||
|
overall.CONSTANT_DB_HR.Model(&modelshr.Position{}).Where("`state` = 1 and `administrative_organization` = ?", orgId).Find(&postList) |
||||
|
} else { |
||||
|
overall.CONSTANT_DB_HR.Model(&modelshr.OrgCont{}).Where("`state` = 1").Find(&list) |
||||
|
overall.CONSTANT_DB_HR.Model(&modelshr.Position{}).Where("`state` = 1").Find(&postList) |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
var allList []OrgPostPower |
||||
|
for _, v := range list { |
||||
|
var orgInfo OrgPostPower |
||||
|
orgInfo.Id = strconv.FormatInt(v.Id, 10) //string `json:"id"`
|
||||
|
orgInfo.Label = v.Name //string `json:"label"`
|
||||
|
orgInfo.Types = strconv.FormatInt(v.Level, 10) // string `json:"types"`
|
||||
|
orgInfo.TypeName = v.TypeName |
||||
|
orgInfo.Status = false //bool `json:"status"`
|
||||
|
orgInfo.Superior = strconv.FormatInt(v.Superior, 10) //string `json:"superior"`
|
||||
|
orgInfo.Key = fmt.Sprintf("o_%v", v.Id) |
||||
|
orgInfo.Sort = v.Sort //int `json:"sort"`
|
||||
|
allList = append(allList, orgInfo) |
||||
|
} |
||||
|
|
||||
|
for i, v := range postList { |
||||
|
var positInfo OrgPostPower |
||||
|
positInfo.Id = strconv.FormatInt(v.Id, 10) //string `json:"id"`
|
||||
|
positInfo.Label = v.Name //string `json:"label"`
|
||||
|
positInfo.Types = "9" |
||||
|
positInfo.TypeName = "岗位" // string `json:"types"`
|
||||
|
positInfo.Status = true //bool `json:"status"`
|
||||
|
positInfo.Superior = strconv.FormatInt(v.AdministrativeOrganization, 10) //string `json:"superior"`
|
||||
|
positInfo.Key = fmt.Sprintf("p_%v", v.Id) |
||||
|
positInfo.Sort = i //int `json:"sort"`
|
||||
|
allList = append(allList, positInfo) |
||||
|
} |
||||
|
|
||||
|
sort.Slice(allList, func(i, j int) bool { |
||||
|
return allList[i].Types < allList[j].Types |
||||
|
}) |
||||
|
// publicmethod.Result(0, allList, c)
|
||||
|
orgIdStr := strconv.FormatInt(orgId, 10) |
||||
|
var orgPostTree []OrgPostisTree |
||||
|
orgPostTree = InfiniteOrgPostTree(orgIdStr, allList) |
||||
|
publicmethod.Result(0, orgPostTree, c) |
||||
|
} |
||||
|
|
||||
|
// 递归无线行政组织与岗位菜单
|
||||
|
func InfiniteOrgPostTree(parentId string, threeData []OrgPostPower) []OrgPostisTree { |
||||
|
var roleTree []OrgPostisTree |
||||
|
for _, v := range threeData { |
||||
|
if v.Superior == parentId { |
||||
|
var roleInfo OrgPostisTree |
||||
|
roleInfo.Id = v.Id //string `json:"id"`
|
||||
|
roleInfo.Label = v.Label //string `json:"label"`
|
||||
|
roleInfo.Types = v.Types // string `json:"types"`
|
||||
|
roleInfo.TypeName = v.TypeName |
||||
|
roleInfo.Status = v.Status //bool `json:"status"`
|
||||
|
roleInfo.Superior = v.Superior //string `json:"superior"`
|
||||
|
roleInfo.Key = v.Key |
||||
|
roleInfo.Sort = v.Sort //int `json:"sort"`
|
||||
|
if v.Types != "9" { |
||||
|
roleInfo.Children = InfiniteOrgPostTree(v.Id, threeData) |
||||
|
} |
||||
|
roleTree = append(roleTree, roleInfo) |
||||
|
} |
||||
|
} |
||||
|
return roleTree |
||||
|
} |
||||
@ -0,0 +1,579 @@ |
|||||
|
package customChartesing |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/overall/publicmethod" |
||||
|
"fmt" |
||||
|
"strconv" |
||||
|
) |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-09-22 15:56:52 |
||||
|
@ 功能: 以时间线为主的子表数据处理 |
||||
|
1:求和;2:平均值;3:计数;4:去重计数;5:最大值;6:最小值 |
||||
|
当字段为时间类型时. 1:自动(原始值);2:整数;3:保留1位小数;4:保留2位小数;5:百分比;6:百分比1位小数;7:百分比2位小数; |
||||
|
# masterFiled 主表维度字段 |
||||
|
# masterVal 主表相关数据 |
||||
|
# val 子表所有数据 |
||||
|
# x ,y 子表维度于度量 |
||||
|
# chartType 图表类型 |
||||
|
# types 时间类型 |
||||
|
*/ |
||||
|
func (b *BarDataInfo) SunDayVal(masterFiled string, masterVal interface{}, x, y []SunTableSetup, chartType, types string, timeAry []string) { |
||||
|
var dataMastKey []string |
||||
|
if valMapAry, isOk := masterVal.([]map[string]interface{}); isOk { |
||||
|
for _, v := range valMapAry { |
||||
|
if mastKey, isok := v["masters_key"]; isok { |
||||
|
|
||||
|
key := publicmethod.TypeToInterface(mastKey) |
||||
|
if !publicmethod.IsInTrue[string](key, dataMastKey) { |
||||
|
dataMastKey = append(dataMastKey, key) |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
if len(dataMastKey) > 0 { |
||||
|
var SunTabelName []string //子表名称
|
||||
|
var weiduDataMap []EveryOneSunTableData //子表数据
|
||||
|
for _, v := range x { |
||||
|
if !publicmethod.IsInTrue[string](v.TableKey, SunTabelName) { |
||||
|
SunTabelName = append(SunTabelName, v.TableKey) |
||||
|
weiduDataMap = append(weiduDataMap, SunTableDataList(v, dataMastKey)) |
||||
|
} |
||||
|
} |
||||
|
if len(weiduDataMap) > 0 { //存在子表数据
|
||||
|
for _, v := range weiduDataMap { |
||||
|
for _, lv := range v.List { //每个子表数据
|
||||
|
for _, yv := range y { //子表度量字段
|
||||
|
var seriesInfo SeriesList //输出单元
|
||||
|
titleStr := fmt.Sprintf("%v:%v-%v", lv.Title, lv.Label, yv.Title) |
||||
|
seriesInfo.Name = titleStr |
||||
|
seriesInfo.Types = chartType |
||||
|
if !publicmethod.IsInTrue[string](titleStr, b.Legend.Data) { |
||||
|
b.Legend.Data = append(b.Legend.Data, titleStr) |
||||
|
} |
||||
|
switch yv.Method { //结算类型
|
||||
|
case 2: |
||||
|
seriesInfo.SunSumDataNewAverage(masterFiled, masterVal, lv.List, lv.Field, yv.Field, types, yv.Format, timeAry) |
||||
|
case 3: |
||||
|
seriesInfo.SunSumDataNewjs(masterFiled, masterVal, lv.List, lv.Field, yv.Field, types, yv.Format, timeAry) |
||||
|
case 4: |
||||
|
seriesInfo.SunSumDataNewQcjs(masterFiled, masterVal, lv.List, lv.Field, yv.Field, types, yv.Format, timeAry) |
||||
|
case 5: |
||||
|
seriesInfo.SunSumDataNewMax(masterFiled, masterVal, lv.List, lv.Field, yv.Field, types, yv.Format, timeAry) |
||||
|
case 6: |
||||
|
seriesInfo.SunSumDataNewMin(masterFiled, masterVal, lv.List, lv.Field, yv.Field, types, yv.Format, timeAry) |
||||
|
default: |
||||
|
// seriesInfo.SunSumData(masterFiled, masterVal, lv.List, lv.Field, yv.Field, types, yv.Format, timeAry)
|
||||
|
seriesInfo.SunSumDataNew(masterFiled, masterVal, lv.List, lv.Field, yv.Field, types, yv.Format, timeAry) |
||||
|
|
||||
|
} |
||||
|
b.Series = append(b.Series, seriesInfo) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-09-23 09:13:23 |
||||
|
@ 功能: 求最小值 |
||||
|
*/ |
||||
|
func (s *SeriesList) SunSumDataNewMin(masterFiled string, masterVal, sunVal interface{}, xField, yField, types string, format int, timeAry []string) { |
||||
|
var monthAry []interface{} |
||||
|
for _, v := range timeAry { |
||||
|
switch types { |
||||
|
case "year": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v)) |
||||
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v)) |
||||
|
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNewMin(startTime, endTime, sunListDate, xField, yField, format)) |
||||
|
case "month": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v)) |
||||
|
yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16)) |
||||
|
monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17)) |
||||
|
endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) |
||||
|
sunListDate := MasterToSunData(startTime, endTime.AllTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNewMin(startTime, endTime.AllTime, sunListDate, xField, yField, format)) |
||||
|
case "day": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v)) |
||||
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v)) |
||||
|
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNewMin(startTime, endTime, sunListDate, xField, yField, format)) |
||||
|
case "hour": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) |
||||
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) |
||||
|
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNewMin(startTime, endTime, sunListDate, xField, yField, format)) |
||||
|
case "minute": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v)) |
||||
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v)) |
||||
|
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNewMin(startTime, endTime, sunListDate, xField, yField, format)) |
||||
|
default: |
||||
|
} |
||||
|
} |
||||
|
s.Data = monthAry |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
*AA |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-09-23 09:14:05 |
||||
|
@ 功能: 计算最大着 |
||||
|
*/ |
||||
|
func (s *SeriesList) QuSumDataNewMin(startTime, endTime int64, val interface{}, xField, yField string, format int) (jieguo interface{}) { |
||||
|
|
||||
|
if yVal, isOk := val.([]interface{}); isOk { |
||||
|
var sumVal float64 |
||||
|
for i, mv := range yVal { |
||||
|
if mapVal, isOk := mv.(map[string]interface{}); isOk { |
||||
|
if yzVal, isOk := mapVal[yField]; isOk { |
||||
|
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) |
||||
|
if err == nil { |
||||
|
if i == 0 { |
||||
|
sumVal = minVal |
||||
|
} else { |
||||
|
if sumVal >= minVal { |
||||
|
sumVal = minVal |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
jieguo = publicmethod.DataChuli(sumVal, format) |
||||
|
} else { |
||||
|
jieguo = 0 |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-09-23 08:57:58 |
||||
|
@ 功能: 求最大值 |
||||
|
*/ |
||||
|
func (s *SeriesList) SunSumDataNewMax(masterFiled string, masterVal, sunVal interface{}, xField, yField, types string, format int, timeAry []string) { |
||||
|
var monthAry []interface{} |
||||
|
for _, v := range timeAry { |
||||
|
switch types { |
||||
|
case "year": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v)) |
||||
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v)) |
||||
|
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNewMax(startTime, endTime, sunListDate, xField, yField, format)) |
||||
|
case "month": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v)) |
||||
|
yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16)) |
||||
|
monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17)) |
||||
|
endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) |
||||
|
sunListDate := MasterToSunData(startTime, endTime.AllTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNewMax(startTime, endTime.AllTime, sunListDate, xField, yField, format)) |
||||
|
case "day": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v)) |
||||
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v)) |
||||
|
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNewMax(startTime, endTime, sunListDate, xField, yField, format)) |
||||
|
case "hour": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) |
||||
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) |
||||
|
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNewMax(startTime, endTime, sunListDate, xField, yField, format)) |
||||
|
case "minute": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v)) |
||||
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v)) |
||||
|
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNewMax(startTime, endTime, sunListDate, xField, yField, format)) |
||||
|
default: |
||||
|
} |
||||
|
} |
||||
|
s.Data = monthAry |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-09-23 09:14:05 |
||||
|
@ 功能: 计算最大着 |
||||
|
*/ |
||||
|
func (s *SeriesList) QuSumDataNewMax(startTime, endTime int64, val interface{}, xField, yField string, format int) (jieguo interface{}) { |
||||
|
|
||||
|
if yVal, isOk := val.([]interface{}); isOk { |
||||
|
var sumVal float64 |
||||
|
for i, mv := range yVal { |
||||
|
if mapVal, isOk := mv.(map[string]interface{}); isOk { |
||||
|
if yzVal, isOk := mapVal[yField]; isOk { |
||||
|
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) |
||||
|
if err == nil { |
||||
|
if i == 0 { |
||||
|
sumVal = minVal |
||||
|
} else { |
||||
|
if sumVal <= minVal { |
||||
|
sumVal = minVal |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
jieguo = publicmethod.DataChuli(sumVal, format) |
||||
|
} else { |
||||
|
jieguo = 0 |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-09-23 09:03:55 |
||||
|
@ 功能: 去重计数 |
||||
|
*/ |
||||
|
func (s *SeriesList) SunSumDataNewQcjs(masterFiled string, masterVal, sunVal interface{}, xField, yField, types string, format int, timeAry []string) { |
||||
|
var monthAry []interface{} |
||||
|
for _, v := range timeAry { |
||||
|
switch types { |
||||
|
case "year": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v)) |
||||
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v)) |
||||
|
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNewQcjs(startTime, endTime, sunListDate, xField, yField, format)) |
||||
|
case "month": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v)) |
||||
|
yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16)) |
||||
|
monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17)) |
||||
|
endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) |
||||
|
sunListDate := MasterToSunData(startTime, endTime.AllTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNewQcjs(startTime, endTime.AllTime, sunListDate, xField, yField, format)) |
||||
|
case "day": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v)) |
||||
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v)) |
||||
|
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNewQcjs(startTime, endTime, sunListDate, xField, yField, format)) |
||||
|
case "hour": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) |
||||
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) |
||||
|
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNewQcjs(startTime, endTime, sunListDate, xField, yField, format)) |
||||
|
case "minute": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v)) |
||||
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v)) |
||||
|
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNewQcjs(startTime, endTime, sunListDate, xField, yField, format)) |
||||
|
default: |
||||
|
} |
||||
|
} |
||||
|
s.Data = monthAry |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-09-23 08:04:59 |
||||
|
@ 功能:计数 |
||||
|
*/ |
||||
|
func (s *SeriesList) QuSumDataNewQcjs(startTime, endTime int64, val interface{}, xField, yField string, format int) (jieguo interface{}) { |
||||
|
|
||||
|
if yVal, isOk := val.([]interface{}); isOk { |
||||
|
var valAry []float64 |
||||
|
for _, mv := range yVal { |
||||
|
if mapVal, isOk := mv.(map[string]interface{}); isOk { |
||||
|
if yzVal, isOk := mapVal[yField]; isOk { |
||||
|
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) |
||||
|
if err == nil { |
||||
|
if !publicmethod.IsInTrue[float64](minVal, valAry) { |
||||
|
valAry = append(valAry, minVal) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
jieguo = len(valAry) |
||||
|
// jieguo = publicmethod.DataChuli(sumVal, format)
|
||||
|
} else { |
||||
|
jieguo = 0 |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-09-23 09:03:55 |
||||
|
@ 功能: 计数 |
||||
|
*/ |
||||
|
func (s *SeriesList) SunSumDataNewjs(masterFiled string, masterVal, sunVal interface{}, xField, yField, types string, format int, timeAry []string) { |
||||
|
var monthAry []interface{} |
||||
|
for _, v := range timeAry { |
||||
|
switch types { |
||||
|
case "year": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v)) |
||||
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v)) |
||||
|
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNewjs(startTime, endTime, sunListDate, xField, yField, format)) |
||||
|
case "month": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v)) |
||||
|
yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16)) |
||||
|
monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17)) |
||||
|
endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) |
||||
|
sunListDate := MasterToSunData(startTime, endTime.AllTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNewjs(startTime, endTime.AllTime, sunListDate, xField, yField, format)) |
||||
|
case "day": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v)) |
||||
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v)) |
||||
|
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNewjs(startTime, endTime, sunListDate, xField, yField, format)) |
||||
|
case "hour": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) |
||||
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) |
||||
|
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNewjs(startTime, endTime, sunListDate, xField, yField, format)) |
||||
|
case "minute": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v)) |
||||
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v)) |
||||
|
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNewjs(startTime, endTime, sunListDate, xField, yField, format)) |
||||
|
default: |
||||
|
} |
||||
|
} |
||||
|
s.Data = monthAry |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-09-23 08:04:59 |
||||
|
@ 功能:计数 |
||||
|
*/ |
||||
|
func (s *SeriesList) QuSumDataNewjs(startTime, endTime int64, val interface{}, xField, yField string, format int) (jieguo interface{}) { |
||||
|
|
||||
|
if yVal, isOk := val.([]interface{}); isOk { |
||||
|
var valAry []float64 |
||||
|
for _, mv := range yVal { |
||||
|
if mapVal, isOk := mv.(map[string]interface{}); isOk { |
||||
|
if yzVal, isOk := mapVal[yField]; isOk { |
||||
|
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) |
||||
|
if err == nil { |
||||
|
valAry = append(valAry, minVal) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
jieguo = len(valAry) |
||||
|
// jieguo = publicmethod.DataChuli(sumVal, format)
|
||||
|
} else { |
||||
|
jieguo = 0 |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-09-23 08:58:06 |
||||
|
@ 功能: 求平均值 |
||||
|
*/ |
||||
|
func (s *SeriesList) SunSumDataNewAverage(masterFiled string, masterVal, sunVal interface{}, xField, yField, types string, format int, timeAry []string) { |
||||
|
var monthAry []interface{} |
||||
|
for _, v := range timeAry { |
||||
|
switch types { |
||||
|
case "year": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v)) |
||||
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v)) |
||||
|
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNewpj(startTime, endTime, sunListDate, xField, yField, format)) |
||||
|
case "month": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v)) |
||||
|
yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16)) |
||||
|
monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17)) |
||||
|
endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) |
||||
|
sunListDate := MasterToSunData(startTime, endTime.AllTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNewpj(startTime, endTime.AllTime, sunListDate, xField, yField, format)) |
||||
|
case "day": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v)) |
||||
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v)) |
||||
|
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNewpj(startTime, endTime, sunListDate, xField, yField, format)) |
||||
|
case "hour": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) |
||||
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) |
||||
|
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNewpj(startTime, endTime, sunListDate, xField, yField, format)) |
||||
|
case "minute": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v)) |
||||
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v)) |
||||
|
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNewpj(startTime, endTime, sunListDate, xField, yField, format)) |
||||
|
default: |
||||
|
} |
||||
|
} |
||||
|
s.Data = monthAry |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-09-23 08:04:59 |
||||
|
@ 功能:平均值 |
||||
|
*/ |
||||
|
func (s *SeriesList) QuSumDataNewpj(startTime, endTime int64, val interface{}, xField, yField string, format int) (jieguo interface{}) { |
||||
|
|
||||
|
if yVal, isOk := val.([]interface{}); isOk { |
||||
|
var sumVal float64 |
||||
|
jibuqi := len(yVal) |
||||
|
for _, mv := range yVal { |
||||
|
if mapVal, isOk := mv.(map[string]interface{}); isOk { |
||||
|
if yzVal, isOk := mapVal[yField]; isOk { |
||||
|
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) |
||||
|
if err == nil { |
||||
|
sumVal = sumVal + minVal |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
if jibuqi > 0 { |
||||
|
avgVal := sumVal / float64(jibuqi) |
||||
|
jieguo = publicmethod.DataChuli(avgVal, format) |
||||
|
} else { |
||||
|
jieguo = 0 |
||||
|
} |
||||
|
// jieguo = publicmethod.DataChuli(sumVal, format)
|
||||
|
} else { |
||||
|
jieguo = 0 |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-09-23 08:57:58 |
||||
|
@ 功能: 求和 |
||||
|
*/ |
||||
|
func (s *SeriesList) SunSumDataNew(masterFiled string, masterVal, sunVal interface{}, xField, yField, types string, format int, timeAry []string) { |
||||
|
var monthAry []interface{} |
||||
|
for _, v := range timeAry { |
||||
|
switch types { |
||||
|
case "year": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v)) |
||||
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v)) |
||||
|
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNew(startTime, endTime, sunListDate, xField, yField, format)) |
||||
|
case "month": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v)) |
||||
|
yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16)) |
||||
|
monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17)) |
||||
|
endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) |
||||
|
sunListDate := MasterToSunData(startTime, endTime.AllTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNew(startTime, endTime.AllTime, sunListDate, xField, yField, format)) |
||||
|
case "day": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v)) |
||||
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v)) |
||||
|
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNew(startTime, endTime, sunListDate, xField, yField, format)) |
||||
|
case "hour": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) |
||||
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) |
||||
|
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNew(startTime, endTime, sunListDate, xField, yField, format)) |
||||
|
case "minute": |
||||
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v)) |
||||
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v)) |
||||
|
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) |
||||
|
monthAry = append(monthAry, s.QuSumDataNew(startTime, endTime, sunListDate, xField, yField, format)) |
||||
|
default: |
||||
|
} |
||||
|
} |
||||
|
s.Data = monthAry |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-09-23 08:04:59 |
||||
|
@ 功能: |
||||
|
*/ |
||||
|
func (s *SeriesList) QuSumDataNew(startTime, endTime int64, val interface{}, xField, yField string, format int) (jieguo interface{}) { |
||||
|
|
||||
|
if yVal, isOk := val.([]interface{}); isOk { |
||||
|
var sumVal float64 |
||||
|
for _, mv := range yVal { |
||||
|
if mapVal, isOk := mv.(map[string]interface{}); isOk { |
||||
|
if yzVal, isOk := mapVal[yField]; isOk { |
||||
|
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) |
||||
|
if err == nil { |
||||
|
sumVal = sumVal + minVal |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
jieguo = publicmethod.DataChuli(sumVal, format) |
||||
|
} else { |
||||
|
jieguo = 0 |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-09-22 16:55:06 |
||||
|
@ 功能: 获取当前时间段内的主数据,然后推导出当此时间段中的子数据 |
||||
|
*/ |
||||
|
func MasterToSunData(startTime, endTime int64, masterFiled string, masterVal, sunVal interface{}) interface{} { |
||||
|
var dataMastKey []string |
||||
|
if mVal, isOk := masterVal.([]map[string]interface{}); isOk { |
||||
|
for _, mv := range mVal { |
||||
|
if xVal, isOk := mv[masterFiled]; isOk { |
||||
|
pageTime, _ := publicmethod.StringToInt64(xVal) |
||||
|
var begTime int64 |
||||
|
var eldTime int64 |
||||
|
if publicmethod.GetIntLength(pageTime) >= 13 { |
||||
|
if publicmethod.GetIntLength(startTime) < 13 { |
||||
|
begTime = startTime * 1000 |
||||
|
} |
||||
|
if publicmethod.GetIntLength(endTime) < 13 { |
||||
|
eldTime = endTime * 1000 |
||||
|
} |
||||
|
} else { |
||||
|
begTime = startTime |
||||
|
eldTime = endTime |
||||
|
} |
||||
|
if begTime <= pageTime && pageTime <= eldTime { |
||||
|
if mastKey, isok := mv["masters_key"]; isok { |
||||
|
key := publicmethod.TypeToInterface(mastKey) |
||||
|
if !publicmethod.IsInTrue[string](key, dataMastKey) { |
||||
|
dataMastKey = append(dataMastKey, key) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
var sunListData []interface{} |
||||
|
if sVal, isOk := sunVal.([]map[string]interface{}); isOk { |
||||
|
for _, mv := range sVal { |
||||
|
if mastKey, isok := mv["masters_key"]; isok { |
||||
|
key := publicmethod.TypeToInterface(mastKey) |
||||
|
if publicmethod.IsInTrue[string](key, dataMastKey) { |
||||
|
sunListData = append(sunListData, mv) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return sunListData |
||||
|
} |
||||
@ -0,0 +1,607 @@ |
|||||
|
package customerApp |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/middleware/grocerystore" |
||||
|
"appPlatform/models/customerForm" |
||||
|
"appPlatform/models/modelshr" |
||||
|
"appPlatform/models/teamlog" |
||||
|
"appPlatform/overall" |
||||
|
"appPlatform/overall/publicmethod" |
||||
|
"encoding/csv" |
||||
|
"encoding/json" |
||||
|
"fmt" |
||||
|
"mime/multipart" |
||||
|
"path" |
||||
|
"strconv" |
||||
|
"strings" |
||||
|
"time" |
||||
|
|
||||
|
"github.com/360EntSecGroup-Skylar/excelize" |
||||
|
"github.com/gin-gonic/gin" |
||||
|
"golang.org/x/text/encoding/simplifiedchinese" |
||||
|
"golang.org/x/text/transform" |
||||
|
) |
||||
|
|
||||
|
var RongXinArrOrg []modelshr.AdministrativeOrganization |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-08-18 14:16:25 |
||||
|
@ 功能: 下载排班模板 |
||||
|
*/ |
||||
|
func (a *ApiMethod) DownLoadDutyPage(c *gin.Context) { |
||||
|
orgId := c.Query("orgid") //哪个行政组织
|
||||
|
types := c.Query("types") //什么类型
|
||||
|
timeVal := c.Query("timeval") //时间
|
||||
|
if orgId == "undefined" || orgId == "" || orgId == "" { |
||||
|
fmt.Printf("%v--%v--%v", orgId, types, timeVal) |
||||
|
return |
||||
|
} |
||||
|
// var orgInfo modelshr.AdministrativeOrganization
|
||||
|
// err := orgInfo.GetCont(map[string]interface{}{"`id`": orgId})
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-08-19 08:09:34 |
||||
|
@ 功能: 上传文档并解析(Redis) |
||||
|
*/ |
||||
|
func (a *ApiMethod) UploadFilesRedis(c *gin.Context) { |
||||
|
orgId := c.Request.FormValue("orgId") |
||||
|
types := c.Request.FormValue("types") |
||||
|
dateTime := c.Request.FormValue("dateTime") //附加参数
|
||||
|
fileInfo, fileHeader, fileErr := c.Request.FormFile("file") //上传的文件
|
||||
|
if fileErr != nil { |
||||
|
publicmethod.Result(200, fileErr, c) |
||||
|
return |
||||
|
} |
||||
|
defer fileInfo.Close() |
||||
|
// fmt.Printf("argVal-dateTime-->%T--->%v\n\n\n", orgId, orgId)
|
||||
|
// fmt.Printf("argVal-types-->%T--->%v\n\n\n", types, types)
|
||||
|
// fmt.Printf("argVal-dateTime-->%T--->%v\n\n\n", dateTime, dateTime)
|
||||
|
|
||||
|
if orgId == "" { |
||||
|
publicmethod.Result(200, fileErr, c, "未知行政组织!数据不可导入!") |
||||
|
return |
||||
|
} |
||||
|
typesInt := 1 |
||||
|
if types != "" { |
||||
|
typesVal, _ := strconv.Atoi(types) |
||||
|
if typesVal > 0 { |
||||
|
typesInt = typesVal |
||||
|
} |
||||
|
} |
||||
|
currTime := time.Now().Unix() |
||||
|
if dateTime != "" { |
||||
|
currTimes, _ := strconv.ParseInt(dateTime, 10, 64) |
||||
|
if currTimes > 0 { |
||||
|
if publicmethod.GetIntLength(currTimes) >= 13 { |
||||
|
currTime = currTimes / 1000 |
||||
|
} else { |
||||
|
currTime = currTimes |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
encoding := c.Request.FormValue("encoding") |
||||
|
if encoding == "" { |
||||
|
encoding = "utf-8" // 默认使用UTF-8
|
||||
|
} |
||||
|
// fmt.Printf("argVal-currTime-->%T--->%v\n\n\n", currTime, currTime)
|
||||
|
// fmt.Printf("argVal-encoding-->%T--->%v\n\n\n", encoding, encoding)
|
||||
|
tageExt := path.Ext(fileHeader.Filename) //获取文件后缀
|
||||
|
fileType := publicmethod.JudgeUpFileType(tageExt) |
||||
|
if fileType != 5 && fileType != 6 { |
||||
|
publicmethod.Result(200, fileType, c, "您上传的不是电子表格!请上传正确的文件!") |
||||
|
return |
||||
|
} |
||||
|
orgIdInt, _ := strconv.ParseInt(orgId, 10, 64) |
||||
|
var orgCont []string |
||||
|
overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`name`").Where("`superior` = ?", orgId).Find(&orgCont) |
||||
|
if len(orgCont) < 1 { |
||||
|
publicmethod.Result(200, orgCont, c, "未知行政组织!数据不可导入") |
||||
|
return |
||||
|
} |
||||
|
redisListKey := fmt.Sprintf("ExcelCsvImport:List:u_%v_%v", orgId, publicmethod.GetUUid(1)) //获取当前列表的Key
|
||||
|
sendData := publicmethod.MapOut[string]() |
||||
|
sendData["redisKey"] = redisListKey |
||||
|
isTrue := true |
||||
|
callBackMsg := "" |
||||
|
switch fileType { |
||||
|
case 5: |
||||
|
xlsx, err := excelize.OpenReader(fileInfo) //读取文件内容
|
||||
|
if err != nil { |
||||
|
publicmethod.Result(2, xlsx, c, tageExt) |
||||
|
return |
||||
|
} |
||||
|
rows := xlsx.GetRows(xlsx.GetSheetName(xlsx.GetActiveSheetIndex())) |
||||
|
fmt.Printf("row--->%T\n\n\n", rows) |
||||
|
if len(rows) < 1 { |
||||
|
publicmethod.Result(200, err, c, "你没有写入数据!") |
||||
|
return |
||||
|
} |
||||
|
sendData["total"], callBackMsg, isTrue = ParseExcelCsvData(rows, orgCont, typesInt, orgIdInt, currTime, redisListKey) |
||||
|
case 6: |
||||
|
// xlsx := csv.NewReader()
|
||||
|
records, err := ReadCSVFromMultipartFileWithEncoding(fileInfo, "gbk") |
||||
|
if err != nil || len(records) < 1 { |
||||
|
publicmethod.Result(200, err, c, "你没有写入数据!") |
||||
|
return |
||||
|
} |
||||
|
sendData["total"], callBackMsg, isTrue = ParseExcelCsvData(records, orgCont, typesInt, orgIdInt, currTime, redisListKey) |
||||
|
default: |
||||
|
|
||||
|
} |
||||
|
if !isTrue { |
||||
|
publicmethod.Result(200, sendData, c, callBackMsg) |
||||
|
return |
||||
|
} |
||||
|
publicmethod.Result(0, sendData, c) |
||||
|
} |
||||
|
|
||||
|
// File读取CSV数据
|
||||
|
func ReadCSVFromMultipartFileWithEncoding(file multipart.File, encoding string) ([][]string, error) { |
||||
|
var reader *csv.Reader |
||||
|
|
||||
|
// 根据指定的编码创建相应的reader
|
||||
|
switch encoding { |
||||
|
case "gbk", "gb2312": |
||||
|
// 创建GBK解码器
|
||||
|
gbkReader := transform.NewReader(file, simplifiedchinese.GBK.NewDecoder()) |
||||
|
reader = csv.NewReader(gbkReader) |
||||
|
case "utf-8", "utf8": |
||||
|
fallthrough |
||||
|
default: |
||||
|
// 默认使用UTF-8
|
||||
|
reader = csv.NewReader(file) |
||||
|
} |
||||
|
|
||||
|
// 设置CSV选项
|
||||
|
reader.Comma = ',' // 设置分隔符
|
||||
|
reader.LazyQuotes = true // 允许非标准的引号
|
||||
|
|
||||
|
// 读取所有记录
|
||||
|
records, err := reader.ReadAll() |
||||
|
if err != nil { |
||||
|
return nil, fmt.Errorf("读取CSV失败: %w", err) |
||||
|
} |
||||
|
|
||||
|
return records, nil |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-08-19 11:44:51 |
||||
|
@ 功能: 解析数据 |
||||
|
|
||||
|
#row 多数的表格数据 |
||||
|
#orgList 行政组织列表 |
||||
|
#types 1:按月;非1:按天 |
||||
|
#orgIdInt 公司 |
||||
|
#redisKey redis唯一识别符 |
||||
|
*/ |
||||
|
func ParseExcelCsvData(row [][]string, orgList []string, types int, orgIdInt, currTime int64, redisKey string) (totalNum int, msg string, isOk bool) { |
||||
|
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS4) |
||||
|
redisClient.SetRedisTime(86400) |
||||
|
year, _ := strconv.Atoi(publicmethod.UnixTimeToDay(currTime, 16)) |
||||
|
month, _ := strconv.Atoi(publicmethod.UnixTimeToDay(currTime, 17)) |
||||
|
day, _ := strconv.Atoi(publicmethod.UnixTimeToDay(currTime, 18)) |
||||
|
for i, v := range row { |
||||
|
// for vi, vv := range v {
|
||||
|
// fmt.Printf("%v-%v:%v\n\n", i, vi, vv)
|
||||
|
// if i == 1 && vi == 0 {
|
||||
|
// if types == 1 {
|
||||
|
// var timeVal publicmethod.DateTimeTotimes
|
||||
|
// timeVal.BaisStrToTime(vv)
|
||||
|
// if timeVal.AllTime <= 0 {
|
||||
|
// msg = "书写的导入日期不正确;请按照规定书写日期。"
|
||||
|
// return
|
||||
|
// }
|
||||
|
// } else {
|
||||
|
// var timeVal publicmethod.DateTimeTotimes
|
||||
|
// timeVal.BaisStrToTime(vv)
|
||||
|
// if timeVal.AllTime <= 0 {
|
||||
|
// msg = "书写的导入日期不正确;请按照规定书写日期。"
|
||||
|
// return
|
||||
|
// }
|
||||
|
// }
|
||||
|
// }
|
||||
|
// if orgIdInt == 309 {
|
||||
|
// if i == 2 && vi == 0 {
|
||||
|
// if vv != "公司带班" {
|
||||
|
// msg = "您的导入的数据所使用得模版不符合当前公司导入模版格式。请先下载相应的模版后,重新编辑数据,再上传!"
|
||||
|
// return
|
||||
|
// }
|
||||
|
// }
|
||||
|
// if i == 3 && vi == 0 {
|
||||
|
// if vv != "公司值班" {
|
||||
|
// msg = "您的导入的数据所使用得模版不符合当前公司导入模版格式。请先下载相应的模版后,重新编辑数据,再上传!"
|
||||
|
// return
|
||||
|
// }
|
||||
|
// }
|
||||
|
// } else {
|
||||
|
// if i == 2 && vi == 0 {
|
||||
|
// if vv != "公司带班" {
|
||||
|
// msg = "您的导入的数据所使用得模版不符合当前公司导入模版格式。请先下载相应的模版后,重新编辑数据,再上传!"
|
||||
|
// return
|
||||
|
// }
|
||||
|
// }
|
||||
|
// }
|
||||
|
|
||||
|
// }
|
||||
|
if i == 1 { |
||||
|
if v[0] == "" { |
||||
|
msg = "书写的导入日期不正确;请按照规定书写日期。" |
||||
|
return |
||||
|
} else { |
||||
|
if types == 1 { |
||||
|
var timeVal publicmethod.DateTimeTotimes |
||||
|
timeVal.BaisStrToTimeExcel(v[0]) |
||||
|
if timeVal.AllTime <= 0 { |
||||
|
msg = "书写的导入日期不正确;请按照规定书写日期。" |
||||
|
return |
||||
|
} |
||||
|
timeYear, _ := strconv.Atoi(timeVal.Years) |
||||
|
timeMonth, _ := strconv.Atoi(timeVal.Months) |
||||
|
if year != timeYear || month != timeMonth { |
||||
|
// msg = "导入日期,与模版设定日期不符!请检查!。"
|
||||
|
msg = fmt.Sprintf("%v-%v-%v导入日期,与模版设定日期不符!请检查!%v-%v", year, month, day, timeYear, timeMonth) |
||||
|
return |
||||
|
} |
||||
|
} else { |
||||
|
var timeVal publicmethod.DateTimeTotimes |
||||
|
timeVal.BaisStrToTimeExcel(v[0]) |
||||
|
if timeVal.AllTime <= 0 { |
||||
|
msg = "书写的导入日期不正确;请按照规定书写日期。" |
||||
|
return |
||||
|
} |
||||
|
timeYear, _ := strconv.Atoi(timeVal.Years) |
||||
|
timeMonth, _ := strconv.Atoi(timeVal.Months) |
||||
|
timeDay, _ := strconv.Atoi(timeVal.Days) |
||||
|
if year != timeYear || month != timeMonth || day != timeDay { |
||||
|
msg = fmt.Sprintf("%v-%v-%v导入日期,与模版设定日期不符!请检查!%v-%v-%v", year, month, day, timeYear, timeMonth, timeDay) |
||||
|
return |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
// fmt.Printf("v---0---->%v\n\n", v[0])
|
||||
|
} |
||||
|
if orgIdInt == 309 { |
||||
|
if i == 2 { |
||||
|
if v[0] == "" { |
||||
|
msg = "您的导入的数据所使用得模版不符合当前公司导入模版格式。请先下载相应的模版后,重新编辑数据,再上传!" |
||||
|
return |
||||
|
} else { |
||||
|
if v[0] != "公司带班" { |
||||
|
msg = "您的导入的数据所使用得模版不符合当前公司导入模版格式。请先下载相应的模版后,重新编辑数据,再上传!" |
||||
|
return |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
if i == 3 { |
||||
|
if v[0] == "" { |
||||
|
msg = "您的导入的数据所使用得模版不符合当前公司导入模版格式。请先下载相应的模版后,重新编辑数据,再上传!" |
||||
|
return |
||||
|
} else { |
||||
|
if v[0] != "公司值班" { |
||||
|
msg = "您的导入的数据所使用得模版不符合当前公司导入模版格式。请先下载相应的模版后,重新编辑数据,再上传!" |
||||
|
return |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} else { |
||||
|
if i == 2 { |
||||
|
if v[0] == "" { |
||||
|
msg = "您的导入的数据所使用得模版不符合当前公司导入模版格式。请先下载相应的模版后,重新编辑数据,再上传!" |
||||
|
return |
||||
|
} else { |
||||
|
if v[0] != "公司带班" { |
||||
|
msg = "您的导入的数据所使用得模版不符合当前公司导入模版格式。请先下载相应的模版后,重新编辑数据,再上传!" |
||||
|
return |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
if i > 1 { |
||||
|
jsonStr, _ := json.Marshal(v) |
||||
|
redisClient.Lpush(redisKey, jsonStr) |
||||
|
totalNum++ |
||||
|
} |
||||
|
} |
||||
|
if totalNum > 0 { |
||||
|
isOk = true |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-08-19 15:34:42 |
||||
|
@ 功能: 将排班信息解写入数据库 |
||||
|
*/ |
||||
|
func (a *ApiMethod) AnalysisDutyData(c *gin.Context) { |
||||
|
var requestData AlaDutyInfo |
||||
|
err := c.ShouldBindJSON(&requestData) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(100, err, c) |
||||
|
return |
||||
|
} |
||||
|
if requestData.OrgId == 0 { |
||||
|
publicmethod.Result(200, err, c, "未知行政组织!非法数据据") |
||||
|
return |
||||
|
} |
||||
|
if requestData.Types == 0 { |
||||
|
requestData.Types = 1 |
||||
|
} |
||||
|
currTime := time.Now().Unix() |
||||
|
if requestData.DateTime != 0 { |
||||
|
if publicmethod.GetIntLength(requestData.DateTime) >= 13 { |
||||
|
currTime = requestData.DateTime / 1000 |
||||
|
} else { |
||||
|
currTime = requestData.DateTime |
||||
|
} |
||||
|
} |
||||
|
if requestData.RedisKey == "" { |
||||
|
publicmethod.Result(200, err, c, "数据获取识别!没有找到数据! ") |
||||
|
return |
||||
|
} |
||||
|
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS4) |
||||
|
orgDutyList, err := redisClient.Llen(requestData.RedisKey) //获取列表总长度
|
||||
|
if err != nil { |
||||
|
publicmethod.Result(200, err, c, "数据获取识别!没有找到数据! ") |
||||
|
return |
||||
|
} |
||||
|
redisVal, err := redisClient.Lindex(requestData.RedisKey, requestData.Number) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(200, err, c, "数据获取识别!没有找到数据! ") |
||||
|
return |
||||
|
} |
||||
|
var redisDataMap []string |
||||
|
err = json.Unmarshal([]byte(redisVal), &redisDataMap) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(200, err, c, "数据格式不正取!") |
||||
|
return |
||||
|
} |
||||
|
var msgStr string |
||||
|
var orgCompunt modelshr.AdministrativeOrganization |
||||
|
orgCompunt.GetCont(map[string]interface{}{"`id`": requestData.OrgId}, "`name`") |
||||
|
year, _ := strconv.Atoi(publicmethod.UnixTimeToDay(currTime, 16)) |
||||
|
month, _ := strconv.Atoi(publicmethod.UnixTimeToDay(currTime, 17)) |
||||
|
day, _ := strconv.Atoi(publicmethod.UnixTimeToDay(currTime, 18)) |
||||
|
if requestData.Types == 1 { |
||||
|
if len(redisDataMap) >= 1 { |
||||
|
if redisDataMap[0] != "" { |
||||
|
orgKey, orgTitle, orgErr := CallBackOrgIdName(requestData.OrgId, redisDataMap[0]) |
||||
|
if orgErr != nil { |
||||
|
msgStr = fmt.Sprintf("%v[%v]数据处理失败!--->%v", orgCompunt.Name, "未知行政组织", time.Now().Unix()) |
||||
|
} else { |
||||
|
for i, v := range redisDataMap { |
||||
|
fmt.Printf("读取的回写数据:\ni:%v------------------>%v\n", i, v) |
||||
|
if i > 0 { |
||||
|
if v != "" { |
||||
|
msgStr = SaveDutyData(orgCompunt.Name, orgTitle, orgKey, year, month, i, v) |
||||
|
} else { |
||||
|
msgStr = fmt.Sprintf("%v[%v]数据处理完成!--->%v", orgCompunt.Name, orgTitle, time.Now().Unix()) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} else { |
||||
|
msgStr = fmt.Sprintf("%v[%v]数据处理失败!--->%v", orgCompunt.Name, "未知行政组织", time.Now().Unix()) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} else { |
||||
|
if len(redisDataMap) >= 2 { |
||||
|
if redisDataMap[0] != "" { |
||||
|
orgKey, orgTitle, orgErr := CallBackOrgIdName(requestData.OrgId, redisDataMap[0]) |
||||
|
if orgErr != nil { |
||||
|
msgStr = fmt.Sprintf("%v[%v]数据处理失败!--->%v", orgCompunt.Name, "未知行政组织", time.Now().Unix()) |
||||
|
} else { |
||||
|
if redisDataMap[1] != "" { |
||||
|
msgStr = SaveDutyData(orgCompunt.Name, orgTitle, orgKey, year, month, day, redisDataMap[1]) |
||||
|
} else { |
||||
|
msgStr = fmt.Sprintf("%v[%v]数据处理完成!--->%v", orgCompunt.Name, orgTitle, time.Now().Unix()) |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} else { |
||||
|
msgStr = fmt.Sprintf("%v[%v]数据处理失败!--->%v", orgCompunt.Name, "未知行政组织", time.Now().Unix()) |
||||
|
} |
||||
|
|
||||
|
} else { |
||||
|
msgStr = fmt.Sprintf("%v[%v]数据处理失败!--->%v", orgCompunt.Name, redisDataMap[0], time.Now().Unix()) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
sendData := publicmethod.MapOut[string]() |
||||
|
sendData["currTime"] = currTime |
||||
|
sendData["orgDutyList"] = orgDutyList |
||||
|
sendData["msg"] = msgStr |
||||
|
publicmethod.Result(0, sendData, c) |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-08-19 16:28:20 |
||||
|
@ 功能: 编辑排班数据 |
||||
|
*/ |
||||
|
func SaveDutyData(compurtNam, orgNam string, orgid int64, year, month, day int, userStr string) (msgStr string) { |
||||
|
var comDutyLog teamlog.Companylog |
||||
|
err := comDutyLog.GetCont(map[string]interface{}{"`orgid`": orgid, "`years`": year, "`months`": month, "`days`": day}) |
||||
|
fmt.Printf("编辑排班数据:\n%v---->%v---->%v---->%v---->%v\n\n\n", orgid, year, month, day, userStr) |
||||
|
var userKeyAllDayAry []string |
||||
|
var userKeyBaiTianAry []string |
||||
|
var userKeyNightAry []string |
||||
|
var userKeyMorningAry []string |
||||
|
var userKeyAfternoonAry []string |
||||
|
holiday := 2 |
||||
|
userAry := strings.Split(userStr, ",") |
||||
|
if len(userStr) > 0 { //获取排班人员
|
||||
|
// fmt.Printf("编辑排班数据:\n%v---->%v---->%v---->%v---->%v\n\n\n", orgid, year, month, day, userAry)
|
||||
|
for _, v := range userAry { |
||||
|
userInfoStr := publicmethod.MatchBracket(v, "(", ")") |
||||
|
fmt.Printf("编辑排班数据110:\n%v\n\n\n", userInfoStr) |
||||
|
if userInfoStr != "" { |
||||
|
userAttr := strings.Split(userInfoStr, "*") |
||||
|
if len(userAttr) > 0 { |
||||
|
var usInfo modelshr.PersonArchives |
||||
|
usInfo.GetCont(map[string]interface{}{"`number`": userAttr[0]}) |
||||
|
if len(userAttr) >= 2 { |
||||
|
//(B:白天;Y:夜间;S:上午;X:下午;Z:值班)不填默认为值班(Z)
|
||||
|
if usInfo.Key != 0 { |
||||
|
switch userAttr[1] { |
||||
|
case "B": |
||||
|
holiday = 1 |
||||
|
userKeyBaiTianAry = append(userKeyBaiTianAry, strconv.FormatInt(usInfo.Key, 10)) |
||||
|
case "Y": |
||||
|
holiday = 1 |
||||
|
userKeyNightAry = append(userKeyNightAry, strconv.FormatInt(usInfo.Key, 10)) |
||||
|
case "S": |
||||
|
userKeyMorningAry = append(userKeyMorningAry, strconv.FormatInt(usInfo.Key, 10)) |
||||
|
case "X": |
||||
|
userKeyAfternoonAry = append(userKeyAfternoonAry, strconv.FormatInt(usInfo.Key, 10)) |
||||
|
default: |
||||
|
userKeyAllDayAry = append(userKeyAllDayAry, strconv.FormatInt(usInfo.Key, 10)) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} else { |
||||
|
if usInfo.Key != 0 { |
||||
|
userKeyAllDayAry = append(userKeyAllDayAry, strconv.FormatInt(usInfo.Key, 10)) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
// fmt.Printf("编辑排班数据val:\n%v---->%v---->%v---->%v---->%v\n\n\n", orgid, year, month, day, v)
|
||||
|
} |
||||
|
|
||||
|
} |
||||
|
if err == nil && comDutyLog.ID != 0 { //存在,进行修改
|
||||
|
saveEitd := publicmethod.MapOut[string]() |
||||
|
saveEitd["`holiday`"] = holiday |
||||
|
saveEitd["allDay"] = strings.Join(userKeyAllDayAry, ",") |
||||
|
saveEitd["baiTian"] = strings.Join(userKeyBaiTianAry, ",") |
||||
|
saveEitd["night"] = strings.Join(userKeyNightAry, ",") |
||||
|
saveEitd["morning"] = strings.Join(userKeyMorningAry, ",") |
||||
|
saveEitd["afternoon"] = strings.Join(userKeyAfternoonAry, ",") |
||||
|
saveEitd["saveTime"] = time.Now().Unix() |
||||
|
var newDutyCont teamlog.Companylog |
||||
|
err = newDutyCont.EiteCont(map[string]interface{}{"`id`": comDutyLog.ID}, saveEitd) |
||||
|
if err == nil { |
||||
|
msgStr = fmt.Sprintf("%v[%v]数据处理完成!--->%v", compurtNam, orgNam, time.Now().Unix()) |
||||
|
} else { |
||||
|
msgStr = fmt.Sprintf("%v[%v]数据处理失败!--->%v", compurtNam, orgNam, time.Now().Unix()) |
||||
|
} |
||||
|
} else { //不存在!进行新增
|
||||
|
var saveConter teamlog.Companylog |
||||
|
saveConter.Orgid = orgid // 行政组织ID
|
||||
|
saveConter.RunTime = time.Now().Unix() // 执行时间
|
||||
|
saveConter.Years = year // 年
|
||||
|
saveConter.Months = month // 月
|
||||
|
saveConter.Days = day // 日
|
||||
|
saveConter.Holiday = holiday // 假日(1:是;2:否)
|
||||
|
saveConter.AllDay = strings.Join(userKeyAllDayAry, ",") // 全天值班人员
|
||||
|
saveConter.BaiTian = strings.Join(userKeyBaiTianAry, ",") // 白天值班人员
|
||||
|
saveConter.Night = strings.Join(userKeyNightAry, ",") // 夜晚值班人员
|
||||
|
saveConter.Morning = strings.Join(userKeyMorningAry, ",") // 夜晚值班人员
|
||||
|
saveConter.Afternoon = strings.Join(userKeyAfternoonAry, ",") // 夜晚值班人员
|
||||
|
saveConter.SaveTime = time.Now().Unix() // 编辑时间
|
||||
|
err = overall.CONSTANT_DB_TeamsLog.Create(&saveConter).Error |
||||
|
if err == nil { |
||||
|
msgStr = fmt.Sprintf("%v[%v]数据处理完成!--->%v", compurtNam, orgNam, time.Now().Unix()) |
||||
|
} else { |
||||
|
msgStr = fmt.Sprintf("%v[%v]数据处理失败!--->%v", compurtNam, orgNam, time.Now().Unix()) |
||||
|
} |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-08-19 16:17:31 |
||||
|
@ 功能: 返回当前行政组织的id与名称 |
||||
|
*/ |
||||
|
func CallBackOrgIdName(superiorId int64, orgName string) (orgId int64, orgTitle string, err error) { |
||||
|
|
||||
|
switch orgName { |
||||
|
case "公司带班": |
||||
|
orgId = superiorId * 10000 |
||||
|
orgTitle = orgName |
||||
|
case "公司值班": |
||||
|
orgId = superiorId*10000 + 1 |
||||
|
orgTitle = orgName |
||||
|
default: |
||||
|
var orgBan modelshr.AdministrativeOrganization |
||||
|
err = orgBan.GetCont(map[string]interface{}{"`superior`": superiorId, "`name`": orgName}, "`id`") |
||||
|
if err != nil { |
||||
|
return |
||||
|
} |
||||
|
orgId = orgBan.Id |
||||
|
orgTitle = orgName |
||||
|
} |
||||
|
|
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 判断有无换班申请
|
||||
|
func ShiftChange(userCode string, userKey int64, year, month, day int) (userInfo modelshr.ManCont, isTrue bool) { |
||||
|
monthStr := "01" |
||||
|
if month > 0 && month <= 12 { |
||||
|
if month < 10 { |
||||
|
monthStr = fmt.Sprintf("0%v", month) |
||||
|
} else { |
||||
|
monthStr = strconv.Itoa(month) |
||||
|
} |
||||
|
} |
||||
|
dayStr := "01" |
||||
|
if day > 0 && day <= 12 { |
||||
|
if day < 10 { |
||||
|
dayStr = fmt.Sprintf("0%v", day) |
||||
|
} else { |
||||
|
dayStr = strconv.Itoa(day) |
||||
|
} |
||||
|
} |
||||
|
fullDayStr := fmt.Sprintf("%v-%v-%v", year, monthStr, dayStr) |
||||
|
startTime, endTime := publicmethod.OenDayStartOrEndTime(fullDayStr, 1) |
||||
|
kaishi, _ := publicmethod.StringToInt64(startTime) |
||||
|
beginTime := kaishi * 1000 |
||||
|
jieshu, _ := publicmethod.StringToInt64(endTime) |
||||
|
lastTime := jieshu * 1000 |
||||
|
//被调换人到当前日期
|
||||
|
var diaoban []customerForm.SCApplication |
||||
|
overall.CONSTANT_DB_CustomerForm.Model(&customerForm.SCApplication{}).Where("FIND_IN_SET(?,`diao4huan4ren2`) AND `dang1zhi2ri4qi141995810` BETWEEN ? AND ?", userCode, beginTime, lastTime).Find(&diaoban) |
||||
|
if len(diaoban) > 0 { |
||||
|
for _, v := range diaoban { |
||||
|
var taskInfo customerForm.RunFlowTask |
||||
|
taskInfo.GetCont(map[string]interface{}{"`masters_key`": v.MastersKey}, "status") |
||||
|
if taskInfo.Status == 4 { |
||||
|
isTrue = true |
||||
|
userInfo.GetCont(map[string]interface{}{"`number`": userCode}) |
||||
|
break |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
//申请人到调换日期
|
||||
|
var shenQing []customerForm.SCApplication |
||||
|
overall.CONSTANT_DB_CustomerForm.Model(&customerForm.SCApplication{}).Where("`creater` = ? AND `diao4huan4ri4qi1` BETWEEN ? AND ?", userKey, beginTime, lastTime).Find(&shenQing) |
||||
|
if len(shenQing) > 0 { |
||||
|
for _, v := range shenQing { |
||||
|
var taskInfo customerForm.RunFlowTask |
||||
|
taskInfo.GetCont(map[string]interface{}{"`masters_key`": v.MastersKey}, "status") |
||||
|
if taskInfo.Status == 4 { |
||||
|
isTrue = true |
||||
|
userInfo.GetCont(map[string]interface{}{"`key`": userKey}) |
||||
|
break |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return |
||||
|
} |
||||
File diff suppressed because it is too large
@ -0,0 +1,529 @@ |
|||||
|
package customerApp |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/models/modelshr" |
||||
|
"appPlatform/models/modelssystempermission" |
||||
|
"appPlatform/models/teamlog" |
||||
|
"appPlatform/overall" |
||||
|
"appPlatform/overall/publicmethod" |
||||
|
"fmt" |
||||
|
"sort" |
||||
|
"strconv" |
||||
|
"strings" |
||||
|
"time" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
// var paichu = []int64{163, 281, 319}
|
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-08-11 15:33:40 |
||||
|
@ 功能: 初始化排版页面 |
||||
|
*/ |
||||
|
func (a *ApiMethod) TestCompanyDutyInit(c *gin.Context) { |
||||
|
context, _ := c.Get(overall.MyContJwt) |
||||
|
var userCont modelshr.ManCont |
||||
|
userCont.GetLoginCont(context) //当前操作人
|
||||
|
sendData := publicmethod.MapOut[string]() |
||||
|
|
||||
|
sendData["currentOrg"] = userCont.Company |
||||
|
var orgCurre modelshr.AdministrativeOrganization |
||||
|
// orgCurre.GetCont(map[string]interface{}{"`id`": userCont.Company}, "`name`")
|
||||
|
overall.CONSTANT_DB_HrInside.Model(&orgCurre).Select("`name`").Where("`id` = ?", userCont.Company).First(&orgCurre) |
||||
|
|
||||
|
currentTime := time.Now().Unix() |
||||
|
yearVal := publicmethod.UnixTimeToDay(currentTime, 16) |
||||
|
yearValInt, _ := strconv.Atoi(yearVal) |
||||
|
monthVal := publicmethod.UnixTimeToDay(currentTime, 17) |
||||
|
monthValInt, _ := strconv.Atoi(monthVal) |
||||
|
currentDay := int(time.Now().Day()) |
||||
|
sendData["title"] = fmt.Sprintf("%v.%v.%v%v值班表", yearVal, monthVal, currentDay, orgCurre.Name) |
||||
|
sendData["titlePc"] = fmt.Sprintf("%v年%v月%v值班表", yearVal, monthVal, orgCurre.Name) |
||||
|
sendData["year"] = yearValInt |
||||
|
sendData["month"] = monthValInt |
||||
|
|
||||
|
endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) |
||||
|
monthEndDay, _ := strconv.Atoi(endTime.Days) |
||||
|
var monthAllDay []string |
||||
|
for i := 1; i <= monthEndDay; i++ { |
||||
|
monthAllDay = append(monthAllDay, fmt.Sprintf("%v日", i)) |
||||
|
} |
||||
|
|
||||
|
//角色权限范围判定
|
||||
|
//1:本岗位;2:本部门;3:本分部;4:指定行政组织;5:所有
|
||||
|
switch SearchRoleLevev(userCont.Role) { |
||||
|
case 5: |
||||
|
sendData["orgLevel"] = 5 |
||||
|
sendData["orgList"] = GetOrgLevel(313, 1) |
||||
|
case 4: |
||||
|
sendData["orgLevel"] = 4 |
||||
|
sendData["orgList"] = GetOrgLevel(userCont.Company, 1) |
||||
|
case 3: |
||||
|
sendData["orgLevel"] = 3 |
||||
|
sendData["orgList"] = GetOrgLevel(userCont.MainDeparment, 2) |
||||
|
case 2: |
||||
|
sendData["orgLevel"] = 2 |
||||
|
sendData["orgList"] = GetOrgLevel(userCont.MainDeparment, 2) |
||||
|
case 1: |
||||
|
sendData["orgLevel"] = 1 |
||||
|
sendData["orgList"] = GetOrgLevel(userCont.MainDeparment, 2) |
||||
|
default: |
||||
|
} |
||||
|
|
||||
|
sendData["currentDay"] = currentDay |
||||
|
// sendData["endTime"] = endTime
|
||||
|
sendData["monthAllDay"] = monthAllDay |
||||
|
publicmethod.Result(0, sendData, c) |
||||
|
} |
||||
|
|
||||
|
// 获取行政组织层级
|
||||
|
func TestGetOrgLevel(partenId int64, types int) (orgList []GaveOrgAry) { |
||||
|
|
||||
|
gormDb := overall.CONSTANT_DB_HrInside.Model(&GaveOrgAry{}).Where("`state` = 1") |
||||
|
if types == 1 { |
||||
|
gormDb = gormDb.Where("`superior` = ?", partenId) |
||||
|
} else { |
||||
|
gormDb = gormDb.Where("`id` = ?", partenId) |
||||
|
} |
||||
|
gormDb.Order("`sort` ASC").Find(&orgList) |
||||
|
sort.Slice(orgList, func(i, j int) bool { |
||||
|
return orgList[i].Sort < orgList[j].Sort |
||||
|
}) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 获取最大查询范围
|
||||
|
func TestSearchRoleLevev(roles string) (level int) { |
||||
|
roleList := strings.Split(roles, ",") |
||||
|
var roleVerify []modelssystempermission.RoleEmpower |
||||
|
overall.CONSTANT_DB_System_Permission.Where("`state` = 1 AND `system` = ? AND `id` IN ? ", "appsystem", roleList).Find(&roleVerify) |
||||
|
for _, v := range roleVerify { |
||||
|
if v.Level >= level { |
||||
|
level = v.Level |
||||
|
} |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-08-12 08:36:19 |
||||
|
@ 功能: 获取根据年月获取排班目录表 |
||||
|
*/ |
||||
|
func (a *ApiMethod) TestGetYearMonthWorkMan(c *gin.Context) { |
||||
|
var requestData PaiBanInfo |
||||
|
err := c.ShouldBindJSON(&requestData) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(100, err, c) |
||||
|
return |
||||
|
} |
||||
|
if requestData.OrgId == 0 { |
||||
|
publicmethod.Result(1, err, c, "未知行政组织!") |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
currentTime := time.Now().Unix() |
||||
|
yearVal := publicmethod.UnixTimeToDay(currentTime, 16) |
||||
|
yearValInt, _ := strconv.Atoi(yearVal) |
||||
|
monthVal := publicmethod.UnixTimeToDay(currentTime, 17) |
||||
|
monthValInt, _ := strconv.Atoi(monthVal) |
||||
|
if requestData.Years != 0 { |
||||
|
yearValInt = requestData.Years |
||||
|
} |
||||
|
if requestData.Months != 0 { |
||||
|
monthValInt = requestData.Months |
||||
|
} |
||||
|
endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) |
||||
|
monthEndDay, _ := strconv.Atoi(endTime.Days) |
||||
|
|
||||
|
sendCenter := publicmethod.MapOut[string]() |
||||
|
var currOrgInfo GaveOrgAry |
||||
|
currOrgInfo.GetCont(map[string]interface{}{"`id`": requestData.OrgId}, "`name`") |
||||
|
sendCenter["title"] = fmt.Sprintf("%v年%v月%v", yearVal, monthValInt, currOrgInfo.Name) |
||||
|
sendCenter["orgId"] = requestData.OrgId |
||||
|
|
||||
|
var sendData []SendCompanyWork |
||||
|
var orgList []GaveOrgAry |
||||
|
|
||||
|
if requestData.OrgId == 309 { |
||||
|
var gsdaban GaveOrgAry |
||||
|
gsdaban.Id = requestData.OrgId * 10000 |
||||
|
gsdaban.Name = "公司带班" |
||||
|
gsdaban.IsCompany = 1 |
||||
|
orgList = append(orgList, gsdaban) |
||||
|
var gszhiban GaveOrgAry |
||||
|
gszhiban.Id = requestData.OrgId*10000 + 1 |
||||
|
gszhiban.Name = "公司值班" |
||||
|
gszhiban.IsCompany = 1 |
||||
|
orgList = append(orgList, gszhiban) |
||||
|
} else { |
||||
|
var gsld GaveOrgAry |
||||
|
gsld.Id = requestData.OrgId * 10000 |
||||
|
gsld.Name = "公司值班" |
||||
|
gsld.IsCompany = 1 |
||||
|
orgList = append(orgList, gsld) |
||||
|
} |
||||
|
orgListAry := GetOrgLevel(requestData.OrgId, 1) |
||||
|
orgList = append(orgList, orgListAry...) |
||||
|
for _, v := range orgList { |
||||
|
if !publicmethod.IsInTrue[int64](v.Id, paichu) { |
||||
|
var sendInfo SendCompanyWork |
||||
|
sendInfo.OrgInfo.Id = v.Id |
||||
|
sendInfo.OrgInfo.Name = v.Name |
||||
|
sendInfo.OrgInfo.IsCompany = v.IsCompany |
||||
|
var comLog []teamlog.Companylog |
||||
|
overall.CONSTANT_DB_TeamsLog.Where("`orgid` = ? AND `years` = ? AND `months` = ?", v.Id, yearValInt, monthValInt).Find(&comLog) |
||||
|
sendInfo.DutyList = GetOrgParWork(comLog, yearValInt, monthValInt, monthEndDay) |
||||
|
sendData = append(sendData, sendInfo) |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
sendCenter["list"] = sendData |
||||
|
publicmethod.Result(0, sendCenter, c) |
||||
|
} |
||||
|
|
||||
|
func TestGetOrgParWork(comLog []teamlog.Companylog, yearValInt, monthValInt, monthEndDay int) (DutyList []DutyListStruct) { |
||||
|
for i := 1; i <= monthEndDay; i++ { |
||||
|
var dayWorkMan DutyListStruct |
||||
|
|
||||
|
dayWorkMan.Years = yearValInt |
||||
|
dayWorkMan.Months = monthValInt |
||||
|
dayWorkMan.Days = i |
||||
|
for _, v := range comLog { |
||||
|
if i == v.Days { |
||||
|
dayWorkMan.Id = v.ID |
||||
|
dayWorkMan.Holiday = v.Holiday |
||||
|
dayWorkMan.AllDay = GetMAnInfo(v.AllDay, yearValInt, monthValInt, i) |
||||
|
dayWorkMan.BaiTian = GetMAnInfo(v.BaiTian, yearValInt, monthValInt, i) |
||||
|
dayWorkMan.Night = GetMAnInfo(v.Night, yearValInt, monthValInt, i) |
||||
|
dayWorkMan.Morning = GetMAnInfo(v.Morning, yearValInt, monthValInt, i) |
||||
|
dayWorkMan.Afternoon = GetMAnInfo(v.Afternoon, yearValInt, monthValInt, i) |
||||
|
} |
||||
|
} |
||||
|
DutyList = append(DutyList, dayWorkMan) |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-08-12 10:11:10 |
||||
|
@ 功能: 值班人员信息 |
||||
|
*/ |
||||
|
func TestGetMAnInfo(userKey string) (userList []UserCentor) { |
||||
|
if userKey != "" { |
||||
|
userAry := strings.Split(userKey, ",") |
||||
|
if len(userAry) > 0 { |
||||
|
var man []modelshr.ManCont |
||||
|
|
||||
|
overall.CONSTANT_DB_HrInside.Model(&modelshr.ManCont{}).Select("`id`,`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`,`mobilephone`,`company`").Where("`state` = 1 AND `emp_type` BETWEEN ? AND ? AND `key` IN ?", 1, 10, userAry).Find(&man) |
||||
|
for _, v := range man { |
||||
|
var userInfo UserCentor |
||||
|
userInfo.Id = strconv.FormatInt(v.Id, 10) |
||||
|
userInfo.UserKey = strconv.FormatInt(v.Key, 10) |
||||
|
userInfo.Coder = v.Number |
||||
|
userInfo.Name = v.Name |
||||
|
userInfo.Icon = v.Icon |
||||
|
if v.IconPhpto != "" { |
||||
|
userInfo.Icon = v.IconPhpto |
||||
|
} |
||||
|
userInfo.Wechat = v.Wechat |
||||
|
userInfo.WorkWechat = v.WorkWechat |
||||
|
userInfo.Tel = v.Mobilephone |
||||
|
userInfo.Gender = v.Gender |
||||
|
userList = append(userList, userInfo) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 根据行政组织获取人员信息
|
||||
|
func (a *ApiMethod) TestGeiOrgAllPeople(c *gin.Context) { |
||||
|
var requestData GetOrgPeopel |
||||
|
err := c.ShouldBindJSON(&requestData) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(100, err, c) |
||||
|
return |
||||
|
} |
||||
|
if requestData.OrgId == 0 { |
||||
|
publicmethod.Result(1, err, c, "未知行政组织!") |
||||
|
return |
||||
|
} |
||||
|
if requestData.IsAll == 0 { |
||||
|
requestData.IsAll = 1 |
||||
|
} |
||||
|
if requestData.IsAll == 1 { |
||||
|
var sunOrg publicmethod.GetOrgAllParent |
||||
|
sunOrg.GetOrgSunNei(requestData.OrgId) |
||||
|
sunOrg.Id = append(sunOrg.Id, requestData.OrgId) |
||||
|
var userList []UserCentor |
||||
|
if len(sunOrg.Id) > 0 { |
||||
|
var man []modelshr.ManCont |
||||
|
overall.CONSTANT_DB_HrInside.Model(&modelshr.ManCont{}).Select("`id`,`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`,`mobilephone`,`company`").Where("`state` = 1 AND `emp_type` BETWEEN ? AND ? AND `admin_org` IN ?", 1, 10, sunOrg.Id).Find(&man) |
||||
|
for _, v := range man { |
||||
|
var userInfo UserCentor |
||||
|
userInfo.Id = strconv.FormatInt(v.Id, 10) |
||||
|
userInfo.UserKey = strconv.FormatInt(v.Key, 10) |
||||
|
userInfo.Coder = v.Number |
||||
|
userInfo.Name = fmt.Sprintf("%v(%v)", v.Name, v.Number) |
||||
|
userInfo.Icon = v.Icon |
||||
|
if v.IconPhpto != "" { |
||||
|
userInfo.Icon = v.IconPhpto |
||||
|
} |
||||
|
userInfo.Wechat = v.Wechat |
||||
|
userInfo.WorkWechat = v.WorkWechat |
||||
|
userInfo.Tel = v.Mobilephone |
||||
|
userInfo.Gender = v.Gender |
||||
|
userList = append(userList, userInfo) |
||||
|
} |
||||
|
} |
||||
|
publicmethod.Result(0, userList, c) |
||||
|
} else { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-08-13 08:42:32 |
||||
|
@ 功能: 编辑值班信息 |
||||
|
*/ |
||||
|
func (a *ApiMethod) TestSaveEditDutyInfo(c *gin.Context) { |
||||
|
var requestData DutyOrgInfo |
||||
|
err := c.ShouldBindJSON(&requestData) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(100, err, c) |
||||
|
return |
||||
|
} |
||||
|
if requestData.Orgid == 0 { |
||||
|
publicmethod.Result(1, err, c, "未知行政组织!") |
||||
|
return |
||||
|
} |
||||
|
if requestData.Years == 0 || requestData.Months == 0 || requestData.Days == 0 { |
||||
|
publicmethod.Result(1, err, c, "未知时间安排!") |
||||
|
return |
||||
|
} |
||||
|
holiday := 2 |
||||
|
if requestData.Holiday != "" { |
||||
|
holiday, _ = strconv.Atoi(requestData.Holiday) |
||||
|
if holiday == 0 { |
||||
|
holiday = 2 |
||||
|
} |
||||
|
} |
||||
|
isAdd := true |
||||
|
monthval := fmt.Sprintf("%v", requestData.Months) |
||||
|
if requestData.Months < 10 { |
||||
|
monthval = fmt.Sprintf("0%v", requestData.Months) |
||||
|
} |
||||
|
daysval := fmt.Sprintf("%v", requestData.Days) |
||||
|
if requestData.Days < 10 { |
||||
|
daysval = fmt.Sprintf("0%v", requestData.Days) |
||||
|
} |
||||
|
timeStr := fmt.Sprintf("%v-%v-%v 12:00:00", requestData.Years, monthval, daysval) |
||||
|
var timeVal publicmethod.DateTimeTotimes |
||||
|
timeVal.BaisStrToTime(timeStr) |
||||
|
if requestData.Id != 0 { |
||||
|
var oldDutyCont teamlog.Companylog |
||||
|
err = oldDutyCont.GetCont(map[string]interface{}{"`id`": requestData.Id}) |
||||
|
if err == nil { |
||||
|
isAdd = false |
||||
|
saveEitd := publicmethod.MapOut[string]() |
||||
|
saveEitd["`holiday`"] = holiday |
||||
|
saveEitd["allDay"] = strings.Join(requestData.AllDay, ",") |
||||
|
saveEitd["baiTian"] = strings.Join(requestData.BaiTian, ",") |
||||
|
saveEitd["night"] = strings.Join(requestData.Night, ",") |
||||
|
saveEitd["morning"] = strings.Join(requestData.Morning, ",") |
||||
|
saveEitd["afternoon"] = strings.Join(requestData.Afternoon, ",") |
||||
|
saveEitd["saveTime"] = time.Now().Unix() |
||||
|
var newDutyCont teamlog.Companylog |
||||
|
err = newDutyCont.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveEitd) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(106, err, c) |
||||
|
return |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if isAdd { |
||||
|
var saveConter teamlog.Companylog |
||||
|
saveConter.Orgid = requestData.Orgid // 行政组织ID
|
||||
|
saveConter.RunTime = timeVal.AllTime // 执行时间
|
||||
|
saveConter.Years = requestData.Years // 年
|
||||
|
saveConter.Months = requestData.Months // 月
|
||||
|
saveConter.Days = requestData.Days // 日
|
||||
|
saveConter.Holiday = holiday // 假日(1:是;2:否)
|
||||
|
saveConter.AllDay = strings.Join(requestData.AllDay, ",") // 全天值班人员
|
||||
|
saveConter.BaiTian = strings.Join(requestData.BaiTian, ",") // 白天值班人员
|
||||
|
saveConter.Night = strings.Join(requestData.Night, ",") // 夜晚值班人员
|
||||
|
saveConter.Morning = strings.Join(requestData.Morning, ",") // 夜晚值班人员
|
||||
|
saveConter.Afternoon = strings.Join(requestData.Afternoon, ",") // 夜晚值班人员
|
||||
|
saveConter.SaveTime = time.Now().Unix() // 编辑时间
|
||||
|
err = overall.CONSTANT_DB_TeamsLog.Create(&saveConter).Error |
||||
|
if err != nil { |
||||
|
publicmethod.Result(106, err, c) |
||||
|
return |
||||
|
} |
||||
|
} |
||||
|
publicmethod.Result(0, err, c) |
||||
|
} |
||||
|
|
||||
|
// 根据日期获取行政组织排班列表
|
||||
|
func (a *ApiMethod) TestGeyOneDayDuty(c *gin.Context) { |
||||
|
var requestData OenDayDuty |
||||
|
err := c.ShouldBindJSON(&requestData) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(100, err, c) |
||||
|
return |
||||
|
} |
||||
|
if requestData.OrgId == 0 { |
||||
|
publicmethod.Result(1, err, c, "未知行政组织!") |
||||
|
return |
||||
|
} |
||||
|
currentTime := time.Now().Unix() |
||||
|
yearVal := publicmethod.UnixTimeToDay(currentTime, 16) |
||||
|
yearValInt, _ := strconv.Atoi(yearVal) |
||||
|
monthVal := publicmethod.UnixTimeToDay(currentTime, 17) |
||||
|
monthValInt, _ := strconv.Atoi(monthVal) |
||||
|
dayhVal := publicmethod.UnixTimeToDay(currentTime, 18) |
||||
|
dayhValInt, _ := strconv.Atoi(dayhVal) |
||||
|
if requestData.Years != 0 { |
||||
|
yearValInt = requestData.Years |
||||
|
} |
||||
|
if requestData.Months != 0 { |
||||
|
monthValInt = requestData.Months |
||||
|
} |
||||
|
if requestData.Days != 0 { |
||||
|
dayhValInt = requestData.Days |
||||
|
} |
||||
|
sendCenter := publicmethod.MapOut[string]() |
||||
|
var currOrgInfo GaveOrgAry |
||||
|
// currOrgInfo.GetCont(map[string]interface{}{"`id`": requestData.OrgId}, "`name`")
|
||||
|
overall.CONSTANT_DB_HrInside.Model(&currOrgInfo).Select("`name`").Where("`id` = ?", requestData.OrgId).First(&currOrgInfo) |
||||
|
sendCenter["title"] = fmt.Sprintf("%v.%v.%v%v", yearVal, monthValInt, dayhValInt, currOrgInfo.Name) |
||||
|
sendCenter["orgId"] = requestData.OrgId |
||||
|
var orgList []GaveOrgAry |
||||
|
|
||||
|
if requestData.OrgId == 309 { |
||||
|
var gsdaban GaveOrgAry |
||||
|
gsdaban.Id = requestData.OrgId * 10000 |
||||
|
gsdaban.Name = "公司带班" |
||||
|
gsdaban.IsCompany = 1 |
||||
|
orgList = append(orgList, gsdaban) |
||||
|
var gszhiban GaveOrgAry |
||||
|
gszhiban.Id = requestData.OrgId*10000 + 1 |
||||
|
gszhiban.Name = "公司值班" |
||||
|
gsdaban.IsCompany = 1 |
||||
|
orgList = append(orgList, gszhiban) |
||||
|
} else { |
||||
|
var gsld GaveOrgAry |
||||
|
gsld.Id = requestData.OrgId * 10000 |
||||
|
gsld.Name = "公司值班" |
||||
|
gsld.IsCompany = 1 |
||||
|
orgList = append(orgList, gsld) |
||||
|
} |
||||
|
orgListAry := GetOrgLevel(requestData.OrgId, 1) |
||||
|
orgList = append(orgList, orgListAry...) |
||||
|
|
||||
|
var sendData []WebSendTo |
||||
|
for _, v := range orgList { |
||||
|
if !publicmethod.IsInTrue[int64](v.Id, paichu) { |
||||
|
var sendInfo WebSendTo |
||||
|
sendInfo.OrgId = v.Id |
||||
|
sendInfo.OrgName = v.Name |
||||
|
sendInfo.IsCompany = v.IsCompany |
||||
|
var comLog teamlog.Companylog |
||||
|
err = overall.CONSTANT_DB_TeamsLog.Where("`orgid` = ? AND `years` = ? AND `months` = ? AND `days` = ?", v.Id, yearValInt, monthValInt, dayhValInt).First(&comLog).Error |
||||
|
if err == nil { |
||||
|
sendInfo.Id = strconv.FormatInt(comLog.ID, 10) |
||||
|
sendInfo.Holiday = comLog.Holiday |
||||
|
sendInfo.AllDay = GetMAnInfo(comLog.AllDay, yearValInt, monthValInt, dayhValInt) |
||||
|
sendInfo.BaiTian = GetMAnInfo(comLog.BaiTian, yearValInt, monthValInt, dayhValInt) |
||||
|
sendInfo.Night = GetMAnInfo(comLog.Night, yearValInt, monthValInt, dayhValInt) |
||||
|
sendInfo.Morning = GetMAnInfo(comLog.Morning, yearValInt, monthValInt, dayhValInt) |
||||
|
sendInfo.Afternoon = GetMAnInfo(comLog.Afternoon, yearValInt, monthValInt, dayhValInt) |
||||
|
sendData = append(sendData, sendInfo) |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
||||
|
sendCenter["list"] = sendData |
||||
|
publicmethod.Result(0, sendCenter, c) |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-08-13 21:24:02 |
||||
|
@ 功能: 清空日期值班 |
||||
|
*/ |
||||
|
func (a *ApiMethod) TestDelOneDayDuty(c *gin.Context) { |
||||
|
var requestData publicmethod.CommonId[int64] |
||||
|
err := c.ShouldBindJSON(&requestData) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(100, err, c) |
||||
|
return |
||||
|
} |
||||
|
if requestData.Id == 0 { |
||||
|
publicmethod.Result(1, err, c, "未知删除项目!") |
||||
|
return |
||||
|
} |
||||
|
var comLog teamlog.Companylog |
||||
|
err = comLog.DelCont(map[string]interface{}{"`id`": requestData.Id}) |
||||
|
publicmethod.Result(0, err, c) |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-08-14 11:20:51 |
||||
|
@ 功能: 获取排版信息 |
||||
|
*/ |
||||
|
func (a *ApiMethod) TestGetDutyCont(c *gin.Context) { |
||||
|
var requestData publicmethod.PublicId |
||||
|
err := c.ShouldBindJSON(&requestData) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(100, err, c) |
||||
|
return |
||||
|
} |
||||
|
if requestData.Id == "" { |
||||
|
publicmethod.Result(1, err, c, "未知项目!") |
||||
|
return |
||||
|
} |
||||
|
var comLog CompanyDutyCont |
||||
|
comLog.GetCont(map[string]interface{}{"`id`": requestData.Id}) |
||||
|
if comLog.AllDay != "" { |
||||
|
comLog.AllDayAry = strings.Split(comLog.AllDay, ",") |
||||
|
} else { |
||||
|
comLog.AllDayAry = []string{} |
||||
|
} |
||||
|
if comLog.BaiTian != "" { |
||||
|
comLog.BaiTianAry = strings.Split(comLog.BaiTian, ",") |
||||
|
} else { |
||||
|
comLog.BaiTianAry = []string{} |
||||
|
} |
||||
|
if comLog.Night != "" { |
||||
|
comLog.NightAry = strings.Split(comLog.Night, ",") |
||||
|
} else { |
||||
|
comLog.NightAry = []string{} |
||||
|
} |
||||
|
if comLog.Morning != "" { |
||||
|
comLog.MorningAry = strings.Split(comLog.Morning, ",") |
||||
|
} else { |
||||
|
comLog.MorningAry = []string{} |
||||
|
} |
||||
|
if comLog.Afternoon != "" { |
||||
|
comLog.AfternoonAry = strings.Split(comLog.Afternoon, ",") |
||||
|
} else { |
||||
|
comLog.AfternoonAry = []string{} |
||||
|
} |
||||
|
publicmethod.Result(0, comLog, c) |
||||
|
} |
||||
@ -0,0 +1,33 @@ |
|||||
|
package humanResources |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/models/modelshr" |
||||
|
"appPlatform/overall/publicmethod" |
||||
|
"sync" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
// 协程设置
|
||||
|
var syncSeting = sync.WaitGroup{} |
||||
|
|
||||
|
type ApiMethod struct{} |
||||
|
|
||||
|
// 人力资源
|
||||
|
func (a *ApiMethod) Index(c *gin.Context) { |
||||
|
outputCont := publicmethod.MapOut[string]() |
||||
|
outputCont["index"] = "人力资源入口" |
||||
|
publicmethod.Result(0, outputCont, c) |
||||
|
} |
||||
|
|
||||
|
// 菜单ID
|
||||
|
type MenuIdCont struct { |
||||
|
MenuId string `json:"menuId"` |
||||
|
} |
||||
|
|
||||
|
// 赋权菜单树
|
||||
|
type OrgTreePower struct { |
||||
|
modelshr.OrgCont |
||||
|
Status bool `json:"status"` |
||||
|
Child []OrgTreePower `json:"child"` |
||||
|
} |
||||
@ -0,0 +1,116 @@ |
|||||
|
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 |
||||
|
} |
||||
@ -0,0 +1,133 @@ |
|||||
|
package publicapi |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/models/modelshr" |
||||
|
"appPlatform/overall" |
||||
|
"appPlatform/overall/publicmethod" |
||||
|
"encoding/csv" |
||||
|
"fmt" |
||||
|
"net/url" |
||||
|
"sort" |
||||
|
"strconv" |
||||
|
"strings" |
||||
|
"time" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-08-18 14:16:25 |
||||
|
@ 功能: 下载排班模板 |
||||
|
*/ |
||||
|
func (a *ApiMethod) DownLoadDutyPage(c *gin.Context) { |
||||
|
orgId := c.Query("orgid") //哪个行政组织
|
||||
|
types := c.Query("types") //什么类型
|
||||
|
timeVal := c.Query("timeval") //时间
|
||||
|
if orgId == "undefined" || orgId == "" || orgId == "" { |
||||
|
c.Writer.Write([]byte("未知行政组织")) |
||||
|
return |
||||
|
} |
||||
|
fmt.Printf("types:%T----->%v\n\n", types, types) |
||||
|
fmt.Printf("timeVal:%T----->%v\n\n", timeVal, timeVal) |
||||
|
var orgInfo modelshr.AdministrativeOrganization |
||||
|
err := orgInfo.GetCont(map[string]interface{}{"`id`": orgId}) |
||||
|
if err != nil { |
||||
|
c.Writer.Write([]byte("未知行政组织")) |
||||
|
return |
||||
|
} |
||||
|
orgIdInt, _ := strconv.ParseInt(orgId, 10, 64) |
||||
|
var orgList []modelshr.AdministrativeOrganization |
||||
|
gormDb := overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Where("`state` = 1") |
||||
|
gormDb = gormDb.Where("`superior` = ?", orgIdInt) |
||||
|
gormDb.Order("`sort` ASC").Find(&orgList) |
||||
|
sort.Slice(orgList, func(i, j int) bool { |
||||
|
return orgList[i].Sort < orgList[j].Sort |
||||
|
}) |
||||
|
dayAll := time.Now().Unix() |
||||
|
if timeVal != "" { |
||||
|
dayAll, _ = strconv.ParseInt(timeVal, 10, 64) |
||||
|
if publicmethod.GetIntLength(dayAll) >= 13 { |
||||
|
dayAll = dayAll / 1000 |
||||
|
} |
||||
|
} |
||||
|
fmt.Printf("首行--timeVal----------->%v------------->%v\n\n\n", timeVal, dayAll) |
||||
|
|
||||
|
dutyTitle := fmt.Sprintf("%v周末(节假日)在岗人员", orgInfo.Name) |
||||
|
fileName := fmt.Sprintf("%v_%v.csv", dutyTitle, publicmethod.GetUUid(1)) |
||||
|
shuoMing := "人员录入格式为姓名(工号);括号为英文模式下括号;在岗时间代替方式为(B:白天;Y:夜间;S:上午;X:下午;Z:值班)不填默认为值班(Z),填写格式为:秦东(300450*Z)。代表姓名:秦东;工号:300450;今天值班。多个人员用英文','分开。如:杜婷婷(206527*B),秦东(300450*Z)。不要随意更改格式,也不要更改固定好的行政组织位置及其他模版中自带的信息。否则信息会录入失败!!!" |
||||
|
if types == "1" { |
||||
|
|
||||
|
yearVal := publicmethod.UnixTimeToDay(dayAll, 16) |
||||
|
yearValInt, _ := strconv.Atoi(yearVal) |
||||
|
monthVal := publicmethod.UnixTimeToDay(dayAll, 17) |
||||
|
monthValInt, _ := strconv.Atoi(monthVal) |
||||
|
|
||||
|
endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) |
||||
|
monthEndDay, _ := strconv.Atoi(endTime.Days) |
||||
|
|
||||
|
fmt.Printf("首行--timeVal-----monthValInt------>%v------------->%v------------->%v\n\n\n", yearValInt, monthValInt, endTime) |
||||
|
|
||||
|
var builder strings.Builder |
||||
|
builder.WriteString("\xEF\xBB\xBF") //写入UTF-8 BOM 防止乱码
|
||||
|
writer := csv.NewWriter(&builder) |
||||
|
writer.Write([]string{dutyTitle, shuoMing}) //标题
|
||||
|
// dayAllStr := publicmethod.UnixTimeToDay(dayAll, 15)
|
||||
|
var fristHane []string |
||||
|
dayAllStr := fmt.Sprintf("\t%v", publicmethod.UnixTimeToDay(dayAll, 15)) |
||||
|
// fristHane = append(fristHane, fmt.Sprintf("%v年%v月", yearVal, monthVal))
|
||||
|
fristHane = append(fristHane, dayAllStr) |
||||
|
|
||||
|
for i := 1; i <= monthEndDay; i++ { |
||||
|
fristHane = append(fristHane, strconv.Itoa(i)) |
||||
|
} |
||||
|
fmt.Printf("首行------------->%v------------->%v\n\n\n", monthEndDay, fristHane) |
||||
|
writer.Write(fristHane) //首行
|
||||
|
if orgIdInt == 309 { |
||||
|
writer.Write([]string{"公司带班"}) |
||||
|
} |
||||
|
writer.Write([]string{"公司值班"}) |
||||
|
//循环输出体
|
||||
|
for _, v := range orgList { |
||||
|
writer.Write([]string{v.Name}) //
|
||||
|
} |
||||
|
writer.Flush() |
||||
|
|
||||
|
c.Writer.Header().Add("Content-type", "application/octet-stream") |
||||
|
c.Header("Content-Type", "application/vnd.ms-excel;charset=utf8") |
||||
|
c.Header("Content-Disposition", "attachment; filename="+url.PathEscape(fileName)) |
||||
|
// c.Header("Content-Disposition", "attachment; filename=团队角色盘点.csv")
|
||||
|
c.Header("Content-Transfer-Encoding", "binary") |
||||
|
c.Writer.Write([]byte(builder.String())) |
||||
|
} else { |
||||
|
|
||||
|
dayAllStr := fmt.Sprintf("\t%v", publicmethod.UnixTimeToDay(dayAll, 14)) |
||||
|
dayHao := publicmethod.UnixTimeToDay(dayAll, 18) |
||||
|
|
||||
|
// dayInt, _ := strconv.ParseInt(dayHao, 10, 64)
|
||||
|
var builder strings.Builder |
||||
|
builder.WriteString("\xEF\xBB\xBF") //写入UTF-8 BOM 防止乱码
|
||||
|
writer := csv.NewWriter(&builder) |
||||
|
writer.Write([]string{dutyTitle, shuoMing}) //标题
|
||||
|
writer.Write([]string{dayAllStr, dayHao}) //首行
|
||||
|
if orgIdInt == 309 { |
||||
|
writer.Write([]string{"公司带班"}) |
||||
|
} |
||||
|
writer.Write([]string{"公司值班"}) |
||||
|
//循环输出体
|
||||
|
for _, v := range orgList { |
||||
|
writer.Write([]string{v.Name, ""}) //
|
||||
|
} |
||||
|
writer.Flush() |
||||
|
|
||||
|
c.Writer.Header().Add("Content-type", "application/octet-stream") |
||||
|
c.Header("Content-Type", "application/vnd.ms-excel;charset=utf8") |
||||
|
c.Header("Content-Disposition", "attachment; filename="+url.PathEscape(fileName)) |
||||
|
// c.Header("Content-Disposition", "attachment; filename=团队角色盘点.csv")
|
||||
|
c.Header("Content-Transfer-Encoding", "binary") |
||||
|
c.Writer.Write([]byte(builder.String())) |
||||
|
} |
||||
|
|
||||
|
// c.Writer.Write([]byte("未知行政组织"))
|
||||
|
} |
||||
@ -0,0 +1,267 @@ |
|||||
|
package setupRoule |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/models/modelssystempermission" |
||||
|
"appPlatform/overall" |
||||
|
"appPlatform/overall/publicmethod" |
||||
|
"encoding/json" |
||||
|
"strconv" |
||||
|
"time" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-11-19 09:05:13 |
||||
|
@ 功能: 授权 |
||||
|
*/ |
||||
|
func (a *ApiMethod) SystemAppAuthorization(c *gin.Context) { |
||||
|
var requestData AppSystemInfo |
||||
|
c.ShouldBindJSON(&requestData) |
||||
|
if requestData.PowerType == "" { |
||||
|
publicmethod.Result(1, requestData, c, "未知赋权分类!请明确!") |
||||
|
return |
||||
|
} |
||||
|
if requestData.AppSystem == "" { |
||||
|
publicmethod.Result(2, requestData, c, "未知系统分类!请明确!") |
||||
|
return |
||||
|
} |
||||
|
if requestData.RoleId == "" { |
||||
|
publicmethod.Result(3, requestData, c, "未知赋权项目!请明确!") |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
var powerMastInfo modelssystempermission.AuthPower |
||||
|
gormDb := overall.CONSTANT_DB_System_Permission.Model(&powerMastInfo).Where("`orgPowerType` = ? AND `orgOrUserKey` = ? AND `appType` = ?", requestData.PowerType, requestData.RoleId, requestData.AppSystem) |
||||
|
var powerInfo interface{} |
||||
|
istrue := 0 |
||||
|
if requestData.IsPick { |
||||
|
istrue = 1 |
||||
|
} |
||||
|
switch requestData.AppSystem { |
||||
|
case "app": |
||||
|
if requestData.AppId == "" { |
||||
|
publicmethod.Result(4, requestData, c, "未知赋权系统!请明确!") |
||||
|
return |
||||
|
} |
||||
|
if len(requestData.CustomizeApp) < 1 { |
||||
|
publicmethod.Result(5, requestData, c, "为对任何项目赋权!请明确!") |
||||
|
return |
||||
|
} |
||||
|
powerInfo = requestData.CustomizeApp |
||||
|
gormDb = gormDb.Where("`appKey` = ?", requestData.AppId) |
||||
|
case "system": |
||||
|
if len(requestData.SystemPower) < 1 { |
||||
|
publicmethod.Result(6, requestData, c, "为对任何项目赋权!请明确!") |
||||
|
return |
||||
|
} |
||||
|
powerInfo = requestData.SystemPower |
||||
|
gormDb = gormDb.Where("`appKey` = 0") |
||||
|
default: |
||||
|
} |
||||
|
jsonPowerInfo, _ := json.Marshal(powerInfo) |
||||
|
err := gormDb.First(&powerMastInfo).Error |
||||
|
uuid := publicmethod.GetUUid(1) |
||||
|
oukId, _ := strconv.ParseInt(requestData.RoleId, 10, 64) |
||||
|
appId, _ := strconv.ParseInt(requestData.AppId, 10, 64) |
||||
|
if err != nil { |
||||
|
powerMastInfo.Id = uuid //
|
||||
|
powerMastInfo.OrgPowerType = requestData.PowerType //赋权类型(org:组织;job:岗位;role:角色;person:个人)"
|
||||
|
powerMastInfo.OrgOrUserKey = oukId // unsigned;default:0;comment:行政组织或角色、人员识别符
|
||||
|
powerMastInfo.AppType = requestData.AppSystem //ment:系统类型(system:系统平台;app:自定义表单与应用)"
|
||||
|
powerMastInfo.AppKey = appId //ned;default:0;comment:自定义应用App"
|
||||
|
powerMastInfo.Time = time.Now().Unix() //编辑时间
|
||||
|
powerMastInfo.IsTrue = istrue //是否有权(1:有;非1:无)
|
||||
|
powerMastInfo.PowerInfo = string(jsonPowerInfo) //权限结构体"
|
||||
|
err = overall.CONSTANT_DB_System_Permission.Create(&powerMastInfo).Error |
||||
|
} else { |
||||
|
uuid = powerMastInfo.Id |
||||
|
saveData := publicmethod.MapOut[string]() |
||||
|
saveData["`isTrue`"] = istrue |
||||
|
saveData["`powerInfo`"] = string(jsonPowerInfo) |
||||
|
saveData["`time`"] = time.Now().Unix() |
||||
|
var saveInfo modelssystempermission.AuthPower |
||||
|
err = saveInfo.EiteCont(map[string]interface{}{"`id`": uuid}, saveData) |
||||
|
} |
||||
|
if err != nil { |
||||
|
publicmethod.Result(7, requestData, c, "授权失败!请重新提交授权数据!") |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
//权限拆分
|
||||
|
err = requestData.SplitPermissions(uuid) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(8, err, c, "授权失败!请重新提交授权数据!") |
||||
|
return |
||||
|
} |
||||
|
publicmethod.Result(0, err, c) |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-11-20 10:08:09 |
||||
|
@ 功能: 拆分权限 |
||||
|
*/ |
||||
|
func (a *AppSystemInfo) SplitPermissions(uuid int64) error { |
||||
|
var oldPower modelssystempermission.PowerInfo |
||||
|
err := oldPower.DelCont(map[string]interface{}{"`authId`": uuid}) |
||||
|
var insterAry []modelssystempermission.PowerInfo |
||||
|
switch a.AppSystem { |
||||
|
case "app": |
||||
|
|
||||
|
for _, v := range a.CustomizeApp { |
||||
|
isPick := 0 |
||||
|
if v.ListIsAll { |
||||
|
isPick = 1 |
||||
|
} |
||||
|
var saveInfo modelssystempermission.PowerInfo |
||||
|
saveInfo.AuthId = uuid //归属权限
|
||||
|
saveInfo.ItemId, _ = strconv.ParseInt(v.Id, 10, 64) //项目ID
|
||||
|
saveInfo.IsPick = isPick //是否有权(1:有;非1:无)
|
||||
|
tpAry := MyCreateTablePower(v.TablePower) |
||||
|
if tpAry == "null" { |
||||
|
tpAry = "[]" |
||||
|
} |
||||
|
saveInfo.TablePower = tpAry //表单权限
|
||||
|
lpAry := MyCreateTablePower(v.ListPower) |
||||
|
if lpAry == "null" { |
||||
|
lpAry = "[]" |
||||
|
} |
||||
|
saveInfo.ListPower = lpAry //列表权限
|
||||
|
saveInfo.VisibleRange = v.DatePower.Types //可见范围(1:本人;2:本岗位;3:本部门;4:本分部;5:指定行政组织;6:所有)
|
||||
|
visibleOrgStr, _ := json.Marshal(v.DatePower.Attribute) |
||||
|
saveInfo.VisibleOrg = string(visibleOrgStr) //可见范围辅助参数
|
||||
|
saveInfo.ButPower = "[]" //按钮权限
|
||||
|
saveInfo.Time = time.Now().Unix() //编辑时间
|
||||
|
insterAry = append(insterAry, saveInfo) |
||||
|
} |
||||
|
case "system": |
||||
|
for _, v := range a.SystemPower { |
||||
|
isPick := 0 |
||||
|
if v.IsTrue { |
||||
|
isPick = 1 |
||||
|
} |
||||
|
var saveInfo modelssystempermission.PowerInfo |
||||
|
saveInfo.AuthId = uuid //归属权限
|
||||
|
saveInfo.ItemId = int64(v.Id) //项目ID
|
||||
|
saveInfo.IsPick = isPick //是否有权(1:有;非1:无)
|
||||
|
saveInfo.TablePower = "[]" //表单权限
|
||||
|
saveInfo.ListPower = "[]" //列表权限
|
||||
|
saveInfo.VisibleRange = v.VisibleRange.Types //可见范围(1:本人;2:本岗位;3:本部门;4:本分部;5:指定行政组织;6:所有)
|
||||
|
visibleOrgStr, _ := json.Marshal(v.VisibleRange.Val) |
||||
|
// fmt.Printf("\n\n转换福泉击缶提---------------->%v\n\n", fsdfsd)
|
||||
|
saveInfo.VisibleOrg = string(visibleOrgStr) //可见范围辅助参数
|
||||
|
jieguo := ButPower(v.ButtenPower) |
||||
|
if jieguo == "null" { |
||||
|
jieguo = "[]" |
||||
|
} |
||||
|
saveInfo.ButPower = jieguo //按钮权限
|
||||
|
saveInfo.Time = time.Now().Unix() //编辑时间
|
||||
|
insterAry = append(insterAry, saveInfo) |
||||
|
if len(v.Children) > 0 { |
||||
|
var childAry SystemTreePower |
||||
|
childAry.WriteSystemInfo(uuid, v.Children) |
||||
|
if len(childAry.WriteInfo) > 0 { |
||||
|
insterAry = append(insterAry, childAry.WriteInfo...) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
default: |
||||
|
} |
||||
|
if len(insterAry) > 0 { |
||||
|
err = overall.CONSTANT_DB_System_Permission.Create(&insterAry).Error |
||||
|
} |
||||
|
return err |
||||
|
} |
||||
|
|
||||
|
func (s *SystemTreePower) WriteSystemInfo(uuid int64, list []AppPowerTree) { |
||||
|
if len(list) > 0 { |
||||
|
for _, v := range list { |
||||
|
isPick := 0 |
||||
|
if v.IsTrue { |
||||
|
isPick = 1 |
||||
|
} |
||||
|
var saveInfo modelssystempermission.PowerInfo |
||||
|
saveInfo.AuthId = uuid //归属权限
|
||||
|
saveInfo.ItemId = int64(v.Id) //项目ID
|
||||
|
saveInfo.IsPick = isPick //是否有权(1:有;非1:无)
|
||||
|
saveInfo.TablePower = "[]" //表单权限
|
||||
|
saveInfo.ListPower = "[]" //列表权限
|
||||
|
saveInfo.VisibleRange = v.VisibleRange.Types //可见范围(1:本人;2:本岗位;3:本部门;4:本分部;5:指定行政组织;6:所有)
|
||||
|
visibleOrgStr, _ := json.Marshal(v.VisibleRange.Val) |
||||
|
saveInfo.VisibleOrg = string(visibleOrgStr) //可见范围辅助参数
|
||||
|
jieguo := ButPower(v.ButtenPower) |
||||
|
if jieguo == "null" { |
||||
|
jieguo = "[]" |
||||
|
} |
||||
|
saveInfo.ButPower = jieguo //按钮权限
|
||||
|
saveInfo.Time = time.Now().Unix() //编辑时间
|
||||
|
s.WriteInfo = append(s.WriteInfo, saveInfo) |
||||
|
if len(v.Children) > 0 { |
||||
|
s.WriteSystemInfo(uuid, v.Children) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-11-20 11:39:52 |
||||
|
@ 功能: 解释自定义表单权限 |
||||
|
*/ |
||||
|
func MyCreateTablePower(powerList []string) string { |
||||
|
if len(powerList) <= 0 { |
||||
|
return "[]" |
||||
|
} |
||||
|
var powerAry []string |
||||
|
for _, v := range powerList { |
||||
|
if !publicmethod.IsInTrue[string](v, powerAry) { |
||||
|
powerAry = append(powerAry, v) |
||||
|
} |
||||
|
} |
||||
|
jsonStr, _ := json.Marshal(powerAry) |
||||
|
return string(jsonStr) |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-11-20 11:28:56 |
||||
|
@ 功能: 按钮列表处理 |
||||
|
*/ |
||||
|
func ButPower(butList []AppPowerInfo) string { |
||||
|
if len(butList) <= 0 { |
||||
|
return "[]" |
||||
|
} |
||||
|
var powerAry []int |
||||
|
for _, v := range butList { |
||||
|
if v.IsTrue { |
||||
|
if !publicmethod.IsInTrue[int](v.Id, powerAry) { |
||||
|
powerAry = append(powerAry, v.Id) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
jsonStr, _ := json.Marshal(powerAry) |
||||
|
return string(jsonStr) |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-11-20 14:31:23 |
||||
|
@ 功能: 数据范围转换格式 |
||||
|
*/ |
||||
|
func PowerOrg(orgAry []int) string { |
||||
|
// if len(orgAry) <= 0{
|
||||
|
return "[]" |
||||
|
// }
|
||||
|
// var orgStr []string
|
||||
|
// for _,v := range orgAry{
|
||||
|
// vStr := strconv.Itoa(v)
|
||||
|
// // if
|
||||
|
// }
|
||||
|
} |
||||
@ -0,0 +1,150 @@ |
|||||
|
package setupRoule |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/models/modelssystempermission" |
||||
|
"appPlatform/overall/publicmethod" |
||||
|
"sync" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
// 处理角色问题
|
||||
|
type ApiMethod struct{} |
||||
|
|
||||
|
// 协程设置
|
||||
|
var syncSeting = sync.WaitGroup{} |
||||
|
|
||||
|
// 处理角色入口
|
||||
|
func (a *ApiMethod) Index(c *gin.Context) { |
||||
|
outputCont := publicmethod.MapOut[string]() |
||||
|
outputCont["index"] = "处理角色入口" |
||||
|
publicmethod.Result(0, outputCont, c) |
||||
|
} |
||||
|
|
||||
|
// 角色赋权输出结构体
|
||||
|
type RolePower struct { |
||||
|
Id string `json:"id"` |
||||
|
Label string `json:"label"` |
||||
|
Types string `json:"types"` |
||||
|
Children []RolePower `json:"children"` |
||||
|
} |
||||
|
|
||||
|
// 获取参数
|
||||
|
type GetPowerUnitParameter struct { |
||||
|
PowerType string `json:"powerType"` //行政组织、岗位、角色(org、position、role)
|
||||
|
AppSystem string `json:"appSystem"` //系统类型
|
||||
|
RoleId string `json:"roleId"` //角色
|
||||
|
AppId string `json:"appId"` //角色
|
||||
|
} |
||||
|
|
||||
|
// 平台授权结构体
|
||||
|
type AppPowerInfo struct { |
||||
|
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"` //菜单名称
|
||||
|
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"` //权限标识
|
||||
|
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
|
||||
|
IsTrue bool `gorm:"-" json:"isTrue"` |
||||
|
} |
||||
|
|
||||
|
// 分流
|
||||
|
type AppMenuBut struct { |
||||
|
AppPowerInfo |
||||
|
AppPowerList []int64 `json:"appPowerList"` |
||||
|
ButtenPower []AppPowerInfo `json:"buttenPower"` |
||||
|
Visible int `json:"visible"` //1、自己;2、本岗位、3、本部门;4、本公司;5:自定义范围;6、所有
|
||||
|
VisibleRange VisibleRangeInfo `json:"visibleRange"` //当可见范围为自定义范围时。此辅助选项生效
|
||||
|
} |
||||
|
|
||||
|
// 平台授权结构树
|
||||
|
type AppPowerTree struct { |
||||
|
AppMenuBut |
||||
|
Children []AppPowerTree `json:"children"` |
||||
|
Visible int `json:"visible"` //1、自己;2、本岗位、3、本部门;4、本公司;5:自定义范围;6、所有
|
||||
|
VisibleRange VisibleRangeInfo `json:"visibleRange"` //当可见范围为自定义范围时。此辅助选项生效
|
||||
|
} |
||||
|
|
||||
|
type VisibleRangeInfo struct { |
||||
|
Types int `json:"typrs"` //1、行政组织;2、岗位;3:人员
|
||||
|
Val []int `json:"val"` |
||||
|
} |
||||
|
|
||||
|
// 输出获取首层子行政组织和本组织下的人员
|
||||
|
type HaveOrgLeveID struct { |
||||
|
publicmethod.PublicId |
||||
|
Level int `json:"level"` |
||||
|
} |
||||
|
type TopSunOrgAndPeople struct { |
||||
|
publicmethod.PublicId |
||||
|
publicmethod.PublicName |
||||
|
Types int `json:"types"` |
||||
|
IsLeaf bool `json:"isLeaf"` //指定节点是否为叶子节点,仅在指定了 lazy 属性的情况下生效
|
||||
|
} |
||||
|
|
||||
|
// 输出获取首层子行政组织和本组织岗位下的人员
|
||||
|
type HaveOrgPostLeveID struct { |
||||
|
publicmethod.PublicId |
||||
|
Types int `json:"types"` |
||||
|
Level int `json:"level"` |
||||
|
} |
||||
|
|
||||
|
// 授权页面获取人员
|
||||
|
type PowerPageUser struct { |
||||
|
publicmethod.PagesTurn |
||||
|
publicmethod.PublicName |
||||
|
OrgId int64 `json:"orgId"` |
||||
|
} |
||||
|
|
||||
|
// 输出授权页人员
|
||||
|
type SendPowerPage struct { |
||||
|
publicmethod.PublicId |
||||
|
publicmethod.PublicName |
||||
|
Code string `json:"code"` |
||||
|
Icon string `json:"icon"` |
||||
|
Org string `json:"org"` |
||||
|
} |
||||
|
|
||||
|
type AppSystemInfo struct { |
||||
|
PowerType string `json:"powerType"` //权限分组
|
||||
|
RoleId string `json:"roleId"` //权限个体Id
|
||||
|
AppSystem string `json:"appSystem"` //系统分类
|
||||
|
AppId string `json:"appId"` //子系统ID
|
||||
|
IsPick bool `json:"isPick"` //当前自定义系统是否可见
|
||||
|
SystemPower []AppPowerTree `json:"sysstemPowerInfo"` //平台系统
|
||||
|
CustomizeApp []CusterAppTablePower `json:"CustomizeApp"` //自定义表单系统
|
||||
|
} |
||||
|
|
||||
|
type CusterAppTablePower struct { |
||||
|
Id string `json:"id"` //表单ID
|
||||
|
Name string `json:"name"` //表单名称
|
||||
|
SignCode string `json:"signCode"` //表单识别符
|
||||
|
IsTrue bool `json:"isTrue"` |
||||
|
TableIsAll bool `json:"tableIsAll"` |
||||
|
TablePower []string `json:"tablePower"` //表单权限
|
||||
|
ListIsAll bool `json:"listIsAll"` |
||||
|
ListPower []string `json:"listPower"` //列表权限
|
||||
|
DatePower DatePowerInfo `json:"datePower"` //数据权限
|
||||
|
} |
||||
|
|
||||
|
type DatePowerInfo struct { |
||||
|
Types int `json:"types"` //权限类型
|
||||
|
Attribute []int64 `json:"attribute"` //全选属性
|
||||
|
} |
||||
|
|
||||
|
// 权限树写入
|
||||
|
type SystemTreePower struct { |
||||
|
WriteInfo []modelssystempermission.PowerInfo |
||||
|
} |
||||
|
|
||||
|
// 获取角色所有人
|
||||
|
type GetRolePople struct { |
||||
|
RoleId int64 `json:"roleId"` |
||||
|
publicmethod.PublicName |
||||
|
} |
||||
|
|
||||
|
// 设置角色使用人
|
||||
|
type SetupRoleMan struct { |
||||
|
RoleId int64 `json:"roleId"` |
||||
|
UserKey []string `json:"userKey"` |
||||
|
} |
||||
@ -0,0 +1,459 @@ |
|||||
|
package setupRoule |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/models/modelshr" |
||||
|
"appPlatform/models/modelssystempermission" |
||||
|
"appPlatform/overall" |
||||
|
"appPlatform/overall/publicmethod" |
||||
|
"encoding/json" |
||||
|
"fmt" |
||||
|
"strconv" |
||||
|
"time" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-11-13 09:25:55 |
||||
|
@ 功能: 获取首层子行政组织和本组织下的人员 |
||||
|
*/ |
||||
|
func (a *ApiMethod) GetMyPeopleAndSunOrg(c *gin.Context) { |
||||
|
var requestData HaveOrgLeveID |
||||
|
err := c.ShouldBindJSON(&requestData) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(100, err, c) |
||||
|
return |
||||
|
} |
||||
|
if requestData.Id == "" { |
||||
|
requestData.Id = "0" |
||||
|
} |
||||
|
orgId, _ := strconv.ParseInt(requestData.Id, 10, 64) |
||||
|
var snedList []TopSunOrgAndPeople |
||||
|
if requestData.Level == 0 { |
||||
|
if requestData.Id == "0" { |
||||
|
|
||||
|
orgList := GetOrgList(orgId) |
||||
|
snedList = append(snedList, orgList...) |
||||
|
// orgManList := GetOrgPeopleList(orgId)
|
||||
|
// snedList = append(snedList, orgManList...)
|
||||
|
} else { |
||||
|
var myOrgMyInfo modelshr.AdministrativeOrganization |
||||
|
err = myOrgMyInfo.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`id`,`name`") |
||||
|
if err != nil { |
||||
|
publicmethod.Result(0, err, c, "没有此行政组织") |
||||
|
return |
||||
|
} |
||||
|
var sendMyInfo TopSunOrgAndPeople |
||||
|
sendMyInfo.Id = strconv.FormatInt(myOrgMyInfo.Id, 10) |
||||
|
sendMyInfo.Name = myOrgMyInfo.Name |
||||
|
sendMyInfo.Types = 1 |
||||
|
sendMyInfo.IsLeaf = false |
||||
|
snedList = append(snedList, sendMyInfo) |
||||
|
// orgManList := GetOrgPeopleList(orgId)
|
||||
|
// snedList = append(snedList, orgManList...)
|
||||
|
} |
||||
|
|
||||
|
} else { |
||||
|
orgList := GetOrgList(orgId) |
||||
|
snedList = append(snedList, orgList...) |
||||
|
} |
||||
|
|
||||
|
publicmethod.Result(0, snedList, c) |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-11-13 11:03:47 |
||||
|
@ 功能: 获取行政组织列表 |
||||
|
*/ |
||||
|
func GetOrgList(orgId int64) (snedList []TopSunOrgAndPeople) { |
||||
|
var orgList []modelshr.AdministrativeOrganization |
||||
|
overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`id`,`name`").Where("`state` = 1 AND `superior` = ?", orgId).Find(&orgList) |
||||
|
if len(orgList) > 0 { |
||||
|
for _, v := range orgList { |
||||
|
var sendInfo TopSunOrgAndPeople |
||||
|
sendInfo.Id = strconv.FormatInt(v.Id, 10) |
||||
|
sendInfo.Name = v.Name |
||||
|
sendInfo.Types = 1 |
||||
|
sendInfo.IsLeaf = false |
||||
|
snedList = append(snedList, sendInfo) |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
orgManList := GetOrgPeopleList(orgId) |
||||
|
snedList = append(snedList, orgManList...) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-11-13 11:03:47 |
||||
|
@ 功能: 获取行政组织岗位 |
||||
|
*/ |
||||
|
func GetOrgPostPeopleList(postId int64) (snedList []TopSunOrgAndPeople) { |
||||
|
var orgList []modelshr.Position |
||||
|
overall.CONSTANT_DB_HR.Model(&modelshr.Position{}).Select("`id`,`name`,`number`").Where("`state` = 1 AND `administrative_organization` = ?", postId).Find(&orgList) |
||||
|
if len(orgList) > 0 { |
||||
|
for _, v := range orgList { |
||||
|
var sendInfo TopSunOrgAndPeople |
||||
|
sendInfo.Id = strconv.FormatInt(v.Id, 10) |
||||
|
sendInfo.Name = v.Name |
||||
|
sendInfo.Types = 2 |
||||
|
sendInfo.IsLeaf = false |
||||
|
snedList = append(snedList, sendInfo) |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
// orgManList := GetPostPeopleList(postId)
|
||||
|
// snedList = append(snedList, orgManList...)
|
||||
|
return |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-11-13 11:03:47 |
||||
|
@ 功能: 获取行政组织人员 |
||||
|
*/ |
||||
|
func GetOrgPeopleList(orgId int64) (snedList []TopSunOrgAndPeople) { |
||||
|
var peopleList []modelshr.PersonArchives |
||||
|
overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`id`,`key`,`name`,`number`").Where("`state` = 1 AND `emp_type` BETWEEN 1 AND 10 AND `admin_org` = ?", orgId).Find(&peopleList) |
||||
|
if len(peopleList) > 0 { |
||||
|
for _, v := range peopleList { |
||||
|
var sendInfo TopSunOrgAndPeople |
||||
|
sendInfo.Id = strconv.FormatInt(v.Key, 10) |
||||
|
sendInfo.Name = fmt.Sprintf("%v(%v)", v.Name, v.Number) |
||||
|
sendInfo.Types = 3 |
||||
|
sendInfo.IsLeaf = true |
||||
|
snedList = append(snedList, sendInfo) |
||||
|
} |
||||
|
} |
||||
|
orgManList := GetOrgPostPeopleList(orgId) |
||||
|
snedList = append(snedList, orgManList...) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-11-13 11:03:47 |
||||
|
@ 功能: 获取岗位人员 |
||||
|
*/ |
||||
|
func GetPostPeopleList(orgId int64) (snedList []TopSunOrgAndPeople) { |
||||
|
var peopleList []modelshr.PersonArchives |
||||
|
overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`id`,`key`,`name`,`number`").Where("`state` = 1 AND `emp_type` BETWEEN 1 AND 10 AND `position` = ?", orgId).Find(&peopleList) |
||||
|
if len(peopleList) > 0 { |
||||
|
for _, v := range peopleList { |
||||
|
var sendInfo TopSunOrgAndPeople |
||||
|
sendInfo.Id = strconv.FormatInt(v.Key, 10) |
||||
|
sendInfo.Name = fmt.Sprintf("%v(%v)", v.Name, v.Number) |
||||
|
sendInfo.Types = 3 |
||||
|
sendInfo.IsLeaf = true |
||||
|
snedList = append(snedList, sendInfo) |
||||
|
} |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-11-13 09:25:55 |
||||
|
@ 功能: 获取首层子行政组织和本组织下的岗位及人员 |
||||
|
*/ |
||||
|
func (a *ApiMethod) GetMyPeopleAndSunOrgPost(c *gin.Context) { |
||||
|
var requestData HaveOrgPostLeveID |
||||
|
err := c.ShouldBindJSON(&requestData) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(100, err, c) |
||||
|
return |
||||
|
} |
||||
|
if requestData.Id == "" { |
||||
|
requestData.Id = "0" |
||||
|
} |
||||
|
if requestData.Types == 0 { |
||||
|
requestData.Types = 1 |
||||
|
} |
||||
|
orgId, _ := strconv.ParseInt(requestData.Id, 10, 64) |
||||
|
var snedList []TopSunOrgAndPeople |
||||
|
if requestData.Level == 0 { |
||||
|
if requestData.Id == "0" { |
||||
|
orgList := GetOrgPostList(orgId) |
||||
|
snedList = append(snedList, orgList...) |
||||
|
} else { |
||||
|
if requestData.Types == 1 { |
||||
|
orgList := GetOrgPostList(orgId) |
||||
|
snedList = append(snedList, orgList...) |
||||
|
} else { |
||||
|
orgManList := GetPostPeopleList(orgId) |
||||
|
snedList = append(snedList, orgManList...) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} else { |
||||
|
|
||||
|
if requestData.Types == 1 { |
||||
|
orgList := GetOrgPostList(orgId) |
||||
|
snedList = append(snedList, orgList...) |
||||
|
} else { |
||||
|
orgManList := GetPostPeopleList(orgId) |
||||
|
snedList = append(snedList, orgManList...) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
publicmethod.Result(0, snedList, c) |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-11-13 11:03:47 |
||||
|
@ 功能: 获取行政组织列表 |
||||
|
*/ |
||||
|
func GetOrgPostList(orgId int64) (snedList []TopSunOrgAndPeople) { |
||||
|
var orgList []modelshr.AdministrativeOrganization |
||||
|
overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`id`,`name`").Where("`state` = 1 AND `superior` = ?", orgId).Find(&orgList) |
||||
|
if len(orgList) > 0 { |
||||
|
for _, v := range orgList { |
||||
|
var sendInfo TopSunOrgAndPeople |
||||
|
sendInfo.Id = strconv.FormatInt(v.Id, 10) |
||||
|
sendInfo.Name = v.Name |
||||
|
sendInfo.Types = 1 |
||||
|
sendInfo.IsLeaf = false |
||||
|
snedList = append(snedList, sendInfo) |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
if orgId != 0 { |
||||
|
orgManList := GetOrgPostPeopleList(orgId) |
||||
|
snedList = append(snedList, orgManList...) |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-11-13 11:03:47 |
||||
|
@ 功能: 获取行政组织岗位 |
||||
|
*/ |
||||
|
func GetPostPeopleListAry(postId int64) (snedList []TopSunOrgAndPeople) { |
||||
|
var orgList []modelshr.Position |
||||
|
overall.CONSTANT_DB_HR.Model(&modelshr.Position{}).Select("`id`,`name`,`number`").Where("`state` = 1 AND `superior` = ?", postId).Find(&orgList) |
||||
|
if len(orgList) > 0 { |
||||
|
for _, v := range orgList { |
||||
|
var sendInfo TopSunOrgAndPeople |
||||
|
sendInfo.Id = strconv.FormatInt(v.Id, 10) |
||||
|
sendInfo.Name = v.Name |
||||
|
sendInfo.Types = 2 |
||||
|
sendInfo.IsLeaf = false |
||||
|
snedList = append(snedList, sendInfo) |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
orgManList := GetPostPeopleList(postId) |
||||
|
snedList = append(snedList, orgManList...) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 获取人员
|
||||
|
func (a *ApiMethod) GetPowerPageUser(c *gin.Context) { |
||||
|
var requestData PowerPageUser |
||||
|
c.ShouldBindJSON(&requestData) |
||||
|
if requestData.Page == 0 { |
||||
|
requestData.Page = 1 |
||||
|
} |
||||
|
if requestData.PageSize == 0 { |
||||
|
requestData.PageSize = 20 |
||||
|
} |
||||
|
var peopleList []modelshr.PersonArchives |
||||
|
gormDb := overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`id`,`key`,`name`,`number`,`icon`,`company`,`maindeparment`,`admin_org`,`icon_photo`").Where("`state` = 1 AND `emp_type` BETWEEN 1 AND 10 ") |
||||
|
if requestData.Name != "" { |
||||
|
gormDb = gormDb.Where("`name` LIKE ? OR `number` LIKE ?", "%"+requestData.Name+"%", "%"+requestData.Name+"%") |
||||
|
} |
||||
|
if requestData.OrgId != 0 { |
||||
|
var sunOrg publicmethod.GetOrgAllParent |
||||
|
sunOrg.GetOrgSun(requestData.OrgId) |
||||
|
sunOrg.Id = append(sunOrg.Id, requestData.OrgId) |
||||
|
gormDb = gormDb.Where("`admin_org` IN ?", sunOrg.Id) |
||||
|
} |
||||
|
var total int64 |
||||
|
totalErr := gormDb.Count(&total).Error |
||||
|
if totalErr != nil { |
||||
|
total = 0 |
||||
|
} |
||||
|
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize) |
||||
|
err := gormDb.Order("`id` DESC").Find(&peopleList).Error |
||||
|
if err != nil { |
||||
|
publicmethod.Result(105, err, c) |
||||
|
return |
||||
|
} |
||||
|
var sendList []SendPowerPage |
||||
|
for _, v := range peopleList { |
||||
|
var sendCont SendPowerPage |
||||
|
sendCont.Id = strconv.FormatInt(v.Key, 10) |
||||
|
sendCont.Name = v.Name |
||||
|
sendCont.Code = v.Number |
||||
|
sendCont.Icon = v.IconPhoto |
||||
|
if v.Icon != "" { |
||||
|
sendCont.Icon = v.Icon |
||||
|
} |
||||
|
orgName := "" |
||||
|
if v.Company != 0 { |
||||
|
var orgCont modelshr.AdministrativeOrganization |
||||
|
orgCont.GetCont(map[string]interface{}{"`id`": v.Company}, "`name`") |
||||
|
if orgCont.Name != "" { |
||||
|
orgName = orgCont.Name |
||||
|
} |
||||
|
} |
||||
|
if v.MainDeparment != 0 && v.MainDeparment != v.Company { |
||||
|
var orgCont modelshr.AdministrativeOrganization |
||||
|
orgCont.GetCont(map[string]interface{}{"`id`": v.MainDeparment}, "`name`") |
||||
|
if orgCont.Name != "" { |
||||
|
orgName = fmt.Sprintf("%v-%v", orgName, orgCont.Name) |
||||
|
} else { |
||||
|
orgName = orgCont.Name |
||||
|
} |
||||
|
} |
||||
|
if v.AdminOrg != 0 && v.AdminOrg != v.MainDeparment && v.AdminOrg != 0 { |
||||
|
var orgCont modelshr.AdministrativeOrganization |
||||
|
orgCont.GetCont(map[string]interface{}{"`id`": v.AdminOrg}, "`name`") |
||||
|
if orgCont.Name != "" { |
||||
|
orgName = fmt.Sprintf("%v-%v", orgName, orgCont.Name) |
||||
|
} else { |
||||
|
orgName = orgCont.Name |
||||
|
} |
||||
|
} |
||||
|
sendCont.Org = orgName |
||||
|
sendList = append(sendList, sendCont) |
||||
|
} |
||||
|
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(sendList)), sendList, c) |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-11-27 08:42:43 |
||||
|
@ 功能: 获取角色使用人 |
||||
|
*/ |
||||
|
func (a *ApiMethod) GetRolePeople(c *gin.Context) { |
||||
|
var requestData GetRolePople |
||||
|
c.ShouldBindJSON(&requestData) |
||||
|
if requestData.RoleId == 0 { |
||||
|
publicmethod.Result(3, requestData, c, "未知赋权项目!请明确!") |
||||
|
return |
||||
|
} |
||||
|
var roleInfo modelssystempermission.SystemRole |
||||
|
err := overall.CONSTANT_DB_System_Permission.Model(&roleInfo).Where("`id` = ?", requestData.RoleId).First(&roleInfo).Error |
||||
|
if err != nil { |
||||
|
publicmethod.Result(1, requestData, c, "未知赋权项目!请明确!") |
||||
|
return |
||||
|
} |
||||
|
outPut := publicmethod.MapOut[string]() |
||||
|
var sendList []SendPowerPage |
||||
|
if roleInfo.Roleuser == "" { |
||||
|
outPut["userKey"] = []string{} |
||||
|
outPut["list"] = sendList |
||||
|
publicmethod.Result(0, outPut, c) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
var userKey []string |
||||
|
json.Unmarshal([]byte(roleInfo.Roleuser), &userKey) |
||||
|
var userList []modelshr.PersonArchives |
||||
|
gormDb := overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`id`,`key`,`name`,`number`,`icon`,`company`,`maindeparment`,`admin_org`,`icon_photo`").Where("`key` IN ?", userKey).Find(&userList) |
||||
|
if requestData.Name != "" { |
||||
|
gormDb = gormDb.Where("`name` LIKE ? OR `number` LIKE ?", "%"+requestData.Name+"%", "%"+requestData.Name+"%") |
||||
|
} |
||||
|
err = gormDb.Find(&userList).Error |
||||
|
|
||||
|
if err != nil { |
||||
|
outPut["userKey"] = userKey |
||||
|
outPut["list"] = sendList |
||||
|
publicmethod.Result(0, outPut, c) |
||||
|
return |
||||
|
} |
||||
|
for _, v := range userList { |
||||
|
var sendCont SendPowerPage |
||||
|
sendCont.Id = strconv.FormatInt(v.Key, 10) |
||||
|
sendCont.Name = v.Name |
||||
|
sendCont.Code = v.Number |
||||
|
sendCont.Icon = v.IconPhoto |
||||
|
if v.Icon != "" { |
||||
|
sendCont.Icon = v.Icon |
||||
|
} |
||||
|
orgName := "" |
||||
|
if v.Company != 0 { |
||||
|
var orgCont modelshr.AdministrativeOrganization |
||||
|
orgCont.GetCont(map[string]interface{}{"`id`": v.Company}, "`name`") |
||||
|
if orgCont.Name != "" { |
||||
|
orgName = orgCont.Name |
||||
|
} |
||||
|
} |
||||
|
if v.MainDeparment != 0 && v.MainDeparment != v.Company { |
||||
|
var orgCont modelshr.AdministrativeOrganization |
||||
|
orgCont.GetCont(map[string]interface{}{"`id`": v.MainDeparment}, "`name`") |
||||
|
if orgCont.Name != "" { |
||||
|
orgName = fmt.Sprintf("%v-%v", orgName, orgCont.Name) |
||||
|
} else { |
||||
|
orgName = orgCont.Name |
||||
|
} |
||||
|
} |
||||
|
if v.AdminOrg != 0 && v.AdminOrg != v.MainDeparment && v.AdminOrg != 0 { |
||||
|
var orgCont modelshr.AdministrativeOrganization |
||||
|
orgCont.GetCont(map[string]interface{}{"`id`": v.AdminOrg}, "`name`") |
||||
|
if orgCont.Name != "" { |
||||
|
orgName = fmt.Sprintf("%v-%v", orgName, orgCont.Name) |
||||
|
} else { |
||||
|
orgName = orgCont.Name |
||||
|
} |
||||
|
} |
||||
|
sendCont.Org = orgName |
||||
|
sendList = append(sendList, sendCont) |
||||
|
} |
||||
|
outPut["userKey"] = userKey |
||||
|
outPut["list"] = sendList |
||||
|
publicmethod.Result(0, outPut, c) |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-11-27 10:21:20 |
||||
|
@ 功能: 保存角色使用人 |
||||
|
*/ |
||||
|
func (a *ApiMethod) SavePickRoleMan(c *gin.Context) { |
||||
|
var requestData SetupRoleMan |
||||
|
err := c.ShouldBindJSON(&requestData) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(100, err, c) |
||||
|
return |
||||
|
} |
||||
|
if requestData.RoleId == 0 { |
||||
|
publicmethod.Result(3, requestData, c, "未知赋权项目!请明确!") |
||||
|
return |
||||
|
} |
||||
|
var roleInfo modelssystempermission.SystemRole |
||||
|
err = overall.CONSTANT_DB_System_Permission.Model(&roleInfo).Where("`id` = ?", requestData.RoleId).First(&roleInfo).Error |
||||
|
if err != nil { |
||||
|
publicmethod.Result(1, requestData, c, "未知赋权项目!请明确!") |
||||
|
return |
||||
|
} |
||||
|
saveData := publicmethod.MapOut[string]() |
||||
|
if len(requestData.UserKey) > 0 { |
||||
|
peopleJson, _ := json.Marshal(requestData.UserKey) |
||||
|
saveData["roleuser"] = string(peopleJson) |
||||
|
} else { |
||||
|
saveData["roleuser"] = "" |
||||
|
} |
||||
|
saveData["`time`"] = time.Now().Unix() |
||||
|
err = roleInfo.EiteCont(map[string]interface{}{"`id`": requestData.RoleId}, saveData) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(106, err, c) |
||||
|
return |
||||
|
} |
||||
|
publicmethod.Result(0, err, c) |
||||
|
} |
||||
@ -0,0 +1,149 @@ |
|||||
|
package setupRoule |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/models/modelAppPlatform" |
||||
|
"appPlatform/overall" |
||||
|
"appPlatform/overall/publicmethod" |
||||
|
"sort" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
// 获取平台授权项目
|
||||
|
func (a *ApiMethod) AppPowerUnit(c *gin.Context) { |
||||
|
var requestData GetPowerUnitParameter |
||||
|
err := c.ShouldBindJSON(&requestData) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(100, err, c) |
||||
|
return |
||||
|
} |
||||
|
if requestData.PowerType == "" { |
||||
|
requestData.PowerType = "org" |
||||
|
} |
||||
|
if requestData.AppSystem == "" { |
||||
|
requestData.AppSystem = "appsystem" |
||||
|
} |
||||
|
if requestData.RoleId == "" { |
||||
|
requestData.RoleId = "0" |
||||
|
} |
||||
|
powerInfo := publicmethod.GetSystemPower(requestData.PowerType, requestData.AppSystem, requestData.RoleId, requestData.PowerType) |
||||
|
var appPowerTrue []AppPowerTree |
||||
|
switch requestData.AppSystem { |
||||
|
default: |
||||
|
appPowerTrue = AppMenuPower(requestData.PowerType, requestData.RoleId, powerInfo) |
||||
|
} |
||||
|
publicmethod.Result(0, appPowerTrue, c) |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-11-10 10:02:54 |
||||
|
@ 功能: 数通智联平台菜单 |
||||
|
*/ |
||||
|
func AppMenuPower(powerType, unitId string, powerInfo publicmethod.SendSystemPower) []AppPowerTree { |
||||
|
var menuList []AppPowerInfo |
||||
|
overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.Menus{}).Where("`visible` = 1").Find(&menuList) |
||||
|
sort.Slice(menuList, func(i, j int) bool { |
||||
|
return menuList[i].Sort < menuList[j].Sort |
||||
|
}) |
||||
|
var noButMenu []AppPowerInfo |
||||
|
var ButMenu []AppPowerInfo |
||||
|
for _, v := range menuList { |
||||
|
if v.Types != 4 { |
||||
|
noButMenu = append(noButMenu, v) |
||||
|
} else { |
||||
|
ButMenu = append(ButMenu, v) |
||||
|
} |
||||
|
} |
||||
|
butList := MenuPower(MenuButList(noButMenu, ButMenu), powerInfo) |
||||
|
return AppMenuTrue(0, butList) |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-11-21 14:20:46 |
||||
|
@ 功能: 判断按钮 |
||||
|
*/ |
||||
|
func JuadgeBut(menuInfo []AppPowerInfo, powerInfo publicmethod.ItemInfo) (butPower []AppPowerInfo) { |
||||
|
for _, v := range menuInfo { |
||||
|
if publicmethod.IsInTrue[int](v.Id, powerInfo.ButPower) { |
||||
|
v.IsTrue = true |
||||
|
} else { |
||||
|
v.IsTrue = false |
||||
|
} |
||||
|
butPower = append(butPower, v) |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 组合菜单按钮
|
||||
|
func MenuButList(noButMenu, ButMenu []AppPowerInfo) (menuButList []AppMenuBut) { |
||||
|
// var but []int64
|
||||
|
for _, v := range noButMenu { |
||||
|
var menuButInfo AppMenuBut |
||||
|
menuButInfo.Id = v.Id |
||||
|
menuButInfo.Name = v.Name //菜单名称
|
||||
|
menuButInfo.Types = v.Types //菜单类型(1-菜单;2-目录;3-外链;4-按钮权限)
|
||||
|
menuButInfo.Perm = v.Perm //权限标识
|
||||
|
menuButInfo.Sort = v.Sort //排序(数字越小排名越靠前)
|
||||
|
menuButInfo.ParentId = v.ParentId //父菜单ID
|
||||
|
menuButInfo.IsTrue = v.IsTrue |
||||
|
menuButInfo.AppPowerList = []int64{1} |
||||
|
for _, bv := range ButMenu { |
||||
|
if bv.ParentId == v.Id { |
||||
|
menuButInfo.ButtenPower = append(menuButInfo.ButtenPower, bv) |
||||
|
} |
||||
|
} |
||||
|
menuButList = append(menuButList, menuButInfo) |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
func AppMenuTrue(parentId int, list []AppMenuBut) []AppPowerTree { |
||||
|
treeList := []AppPowerTree{} |
||||
|
for _, v := range list { |
||||
|
if v.ParentId == parentId { |
||||
|
var treeInfo AppPowerTree |
||||
|
treeInfo.Id = v.Id //
|
||||
|
treeInfo.Name = v.Name //菜单名称
|
||||
|
treeInfo.Types = v.Types //菜单类型(1-菜单;2-目录;3-外链;4-按钮权限)
|
||||
|
treeInfo.Perm = v.Perm //权限标识
|
||||
|
treeInfo.Sort = v.Sort //排序(数字越小排名越靠前)
|
||||
|
treeInfo.ParentId = v.ParentId //父菜单ID
|
||||
|
treeInfo.IsTrue = v.IsTrue //
|
||||
|
treeInfo.Visible = v.Visible |
||||
|
treeInfo.ButtenPower = v.ButtenPower |
||||
|
treeInfo.VisibleRange.Types = v.VisibleRange.Types |
||||
|
treeInfo.VisibleRange.Val = v.VisibleRange.Val |
||||
|
if v.Types != 4 { |
||||
|
treeInfo.Children = AppMenuTrue(v.Id, list) |
||||
|
} |
||||
|
treeList = append(treeList, treeInfo) |
||||
|
} |
||||
|
} |
||||
|
return treeList |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-11-21 14:12:32 |
||||
|
@ 功能: 菜单判断是否选中 |
||||
|
*/ |
||||
|
func MenuPower(menuInfo []AppMenuBut, powerInfo publicmethod.SendSystemPower) (menuPower []AppMenuBut) { |
||||
|
for _, v := range menuInfo { |
||||
|
for _, pv := range powerInfo.PowerList { |
||||
|
if pv.ItemId == int64(v.Id) { |
||||
|
v.IsTrue = pv.IsPick |
||||
|
v.Visible = pv.VisibleRange |
||||
|
v.VisibleRange.Types = pv.VisibleRange |
||||
|
v.VisibleRange.Val = pv.VisibleOrg |
||||
|
v.ButtenPower = JuadgeBut(v.ButtenPower, pv) |
||||
|
} |
||||
|
} |
||||
|
menuPower = append(menuPower, v) |
||||
|
} |
||||
|
return |
||||
|
} |
||||
@ -0,0 +1,302 @@ |
|||||
|
package taskflowing |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/overall/publicmethod" |
||||
|
"encoding/json" |
||||
|
"fmt" |
||||
|
"sort" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
// 解析表单格式
|
||||
|
func (a *ApiMethod) AnalyFormJsonMap(c *gin.Context) { |
||||
|
var requestData AnalysisNodesUnitPower |
||||
|
err := c.ShouldBindJSON(&requestData) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(100, err, c) |
||||
|
return |
||||
|
} |
||||
|
if requestData.NodeKey == "" { |
||||
|
requestData.NodeKey = "begin" |
||||
|
} |
||||
|
|
||||
|
var unitCont TypesAnalysisNodesUnit |
||||
|
json.Unmarshal([]byte(requestData.NodeJson), &unitCont.UnitList) //获取当前表单Json配置数据
|
||||
|
var flowUnit FlowTypeKeyWordAry |
||||
|
|
||||
|
if purviewList, ok := unitCont.UnitList["purview"]; ok { |
||||
|
|
||||
|
if purviewAry, ok := purviewList.([]interface{}); ok { |
||||
|
for _, v := range purviewAry { |
||||
|
if vMap, ok := v.(map[string]interface{}); ok { |
||||
|
if nodeKey, ok := vMap["nodeKey"]; ok { |
||||
|
if publicmethod.TypeToInterface(nodeKey) == requestData.NodeKey { |
||||
|
if powerList, ok := vMap["powerAry"]; ok { |
||||
|
if powerListAry, ok := powerList.([]interface{}); ok { |
||||
|
flowUnit.NodePower = SplitNodeUnitPurviewNew(powerListAry) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
// recUnitAry = SplitNodeUnitPurviewNew(purviewAry)
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// fmt.Printf("授权清空\n%T----------------%v\n\n", flowUnit, flowUnit)
|
||||
|
|
||||
|
//获取组件
|
||||
|
if list, ok := unitCont.UnitList["list"]; ok { |
||||
|
if listAry, ok := list.([]interface{}); ok { |
||||
|
var mainTable FlowTypeKeyWord |
||||
|
mainTable.Id = "masterid" |
||||
|
mainTable.Name = "主表" |
||||
|
mainTable.IsEdit = true |
||||
|
mainTable.IsLook = true |
||||
|
mainTable.Status = 4 |
||||
|
mainTable.Sort = 0 |
||||
|
flowUnit.SplitComponents(mainTable, listAry) |
||||
|
} |
||||
|
} |
||||
|
sort.Slice(flowUnit.ListAry, func(i, j int) bool { |
||||
|
return flowUnit.ListAry[i].Sort < flowUnit.ListAry[j].Sort |
||||
|
}) |
||||
|
sendData := publicmethod.MapOut[string]() |
||||
|
sendData["nodeKey"] = requestData.NodeKey |
||||
|
sendData["recUnitAry"] = flowUnit.ListAry |
||||
|
publicmethod.Result(0, sendData, c) |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2024-03-14 08:38:32 |
||||
|
@ 功能: 拆分节点已有得权限 |
||||
|
@ 参数 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 返回值 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 方法原型 |
||||
|
|
||||
|
# |
||||
|
*/ |
||||
|
func SplitNodeUnitPurviewNew(purviewAry []interface{}) (nodeUnitPowerAry []NodesUnitNameStatue) { |
||||
|
jsonCont, jsonErr := json.Marshal(purviewAry) |
||||
|
// fmt.Printf("purviewList:%T--->%v--->%v\n", jsonCont, jsonErr, string(jsonCont))
|
||||
|
if jsonErr == nil { |
||||
|
json.Unmarshal(jsonCont, &nodeUnitPowerAry) |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 拆分组件
|
||||
|
func (f *FlowTypeKeyWordAry) SplitComponents(tableInfo FlowTypeKeyWord, unitList []interface{}) { |
||||
|
var masterUnit []NodesUnitNameStatue |
||||
|
for i, v := range unitList { |
||||
|
if mapVal, ok := v.(map[string]interface{}); ok { |
||||
|
if mapType, ok := mapVal["type"]; ok { //获取组件类型
|
||||
|
// fmt.Printf("\n====1======\n%v:\n%v\n======1====\n", i, mapType)
|
||||
|
unitName := "" |
||||
|
unitLabelName := "" |
||||
|
if mapName, ok := mapVal["name"]; ok { |
||||
|
unitName = publicmethod.TypeToInterface(mapName) |
||||
|
} |
||||
|
if item, ok := mapVal["item"]; ok { |
||||
|
if itemMap, ok := item.(map[string]interface{}); ok { |
||||
|
if itemName, ok := itemMap["label"]; ok { |
||||
|
unitLabelName = publicmethod.TypeToInterface(itemName) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
switch mapType { |
||||
|
case "flex": |
||||
|
|
||||
|
var mainTable FlowTypeKeyWord |
||||
|
mainTable.Id = unitName |
||||
|
if unitLabelName == "" { |
||||
|
if mapName, ok := mapVal["unitName"]; ok { |
||||
|
mainTable.Name = publicmethod.TypeToInterface(mapName) |
||||
|
} |
||||
|
} else { |
||||
|
mainTable.Name = unitLabelName |
||||
|
} |
||||
|
// mainTable.IsEdit = true
|
||||
|
// mainTable.IsLook = true
|
||||
|
mainTable.IsLook, mainTable.IsEdit, mainTable.Status = f.JuadgeUnitStatus(unitName) |
||||
|
// mainTable.Status = 4
|
||||
|
mainTable.Sort = i + 1 |
||||
|
if list, ok := mapVal["list"]; ok { |
||||
|
if listAry, ok := list.([]interface{}); ok { |
||||
|
|
||||
|
f.SplitComponents(mainTable, listAry) |
||||
|
} |
||||
|
} |
||||
|
case "table": |
||||
|
var mainTable FlowTypeKeyWord |
||||
|
mainTable.Id = unitName |
||||
|
if unitLabelName == "" { |
||||
|
if mapName, ok := mapVal["unitName"]; ok { |
||||
|
mainTable.Name = publicmethod.TypeToInterface(mapName) |
||||
|
} |
||||
|
} else { |
||||
|
mainTable.Name = unitLabelName |
||||
|
} |
||||
|
// mainTable.IsEdit = true
|
||||
|
// mainTable.IsLook = true
|
||||
|
mainTable.IsLook, mainTable.IsEdit, mainTable.Status = f.JuadgeUnitStatus(unitName) |
||||
|
// mainTable.Status = 4
|
||||
|
mainTable.Sort = i + 1 |
||||
|
if list, ok := mapVal["list"]; ok { |
||||
|
if listAry, ok := list.([]interface{}); ok { |
||||
|
|
||||
|
f.SplitComponents(mainTable, listAry) |
||||
|
} |
||||
|
} |
||||
|
case "grid": |
||||
|
var mainTable FlowTypeKeyWord |
||||
|
|
||||
|
if unitName == "" { |
||||
|
mainTable.Id = fmt.Sprintf("%v_%v", mapType, i) |
||||
|
} else { |
||||
|
mainTable.Id = unitName |
||||
|
} |
||||
|
if unitLabelName == "" { |
||||
|
if mapName, ok := mapVal["unitName"]; ok { |
||||
|
mainTable.Name = publicmethod.TypeToInterface(mapName) |
||||
|
} |
||||
|
} else { |
||||
|
mainTable.Name = unitLabelName |
||||
|
} |
||||
|
// mainTable.IsEdit = true
|
||||
|
// mainTable.IsLook = true
|
||||
|
mainTable.IsLook, mainTable.IsEdit, mainTable.Status = f.JuadgeUnitStatus(unitName) |
||||
|
mainTable.Sort = i + 1 |
||||
|
// mainTable.Status = 4
|
||||
|
if columnsList, ok := mapVal["columns"]; ok { |
||||
|
if listAry, ok := columnsList.([]interface{}); ok { |
||||
|
for _, colVal := range listAry { |
||||
|
if colList, ok := colVal.(map[string]interface{}); ok { |
||||
|
|
||||
|
if listMap, ok := colList["list"]; ok { |
||||
|
if colListAry, ok := listMap.([]interface{}); ok { |
||||
|
f.SplitComponents(mainTable, colListAry) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
case "tabs": |
||||
|
var mainTable FlowTypeKeyWord |
||||
|
|
||||
|
if unitName == "" { |
||||
|
mainTable.Id = fmt.Sprintf("%v_%v", mapType, i) |
||||
|
} else { |
||||
|
mainTable.Id = unitName |
||||
|
} |
||||
|
if unitLabelName == "" { |
||||
|
if mapName, ok := mapVal["unitName"]; ok { |
||||
|
mainTable.Name = publicmethod.TypeToInterface(mapName) |
||||
|
} |
||||
|
} else { |
||||
|
mainTable.Name = unitLabelName |
||||
|
} |
||||
|
// mainTable.IsEdit = true
|
||||
|
// mainTable.IsLook = true
|
||||
|
mainTable.IsLook, mainTable.IsEdit, mainTable.Status = f.JuadgeUnitStatus(unitName) |
||||
|
// mainTable.Status = 4
|
||||
|
mainTable.Sort = i + 1 |
||||
|
if columnsList, ok := mapVal["columns"]; ok { |
||||
|
if listAry, ok := columnsList.([]interface{}); ok { |
||||
|
for ci, colVal := range listAry { |
||||
|
if colList, ok := colVal.(map[string]interface{}); ok { |
||||
|
if mapName, ok := colList["label"]; ok { |
||||
|
mainTable.Name = publicmethod.TypeToInterface(mapName) |
||||
|
} |
||||
|
mainTable.Id = fmt.Sprintf("%v_%v", mainTable.Id, ci) |
||||
|
if listMap, ok := colList["list"]; ok { |
||||
|
if colListAry, ok := listMap.([]interface{}); ok { |
||||
|
f.SplitComponents(mainTable, colListAry) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
case "card", "div": |
||||
|
// fmt.Printf("\n===普通容器,无需授权组装=======\n%v:\n%v\n==========\n", i, mapType)
|
||||
|
if list, ok := mapVal["list"]; ok { |
||||
|
if listAry, ok := list.([]interface{}); ok { |
||||
|
|
||||
|
f.SplitComponents(tableInfo, listAry) |
||||
|
} |
||||
|
} |
||||
|
case "title", "txt", "button": |
||||
|
// fmt.Printf("\n===无需授权组装=======\n%v:\n%v\n==========\n", i, mapType)
|
||||
|
default: |
||||
|
var masterMainUnit NodesUnitNameStatue |
||||
|
masterMainUnit.Id = unitName |
||||
|
masterMainUnit.Name = unitLabelName |
||||
|
// masterMainUnit.IsEdit = true
|
||||
|
// masterMainUnit.IsLook = true
|
||||
|
masterMainUnit.IsLook, masterMainUnit.IsEdit, masterMainUnit.Status = f.JuadgeUnitStatus(unitName) |
||||
|
// masterMainUnit.Status = 4
|
||||
|
masterUnit = append(masterUnit, masterMainUnit) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
// jsonByte, err := json.Marshal(masterUnit)
|
||||
|
// fmt.Printf("\n====2======\n%v:\n%v\n\n%v\n=====2=====\n", err, string(jsonByte), tableInfo)
|
||||
|
if len(masterUnit) > 0 { |
||||
|
isNew := true |
||||
|
// fmt.Printf("\n=---------%v--------->\n=", len(f.ListAry))
|
||||
|
if len(f.ListAry) > 0 { |
||||
|
for i, v := range f.ListAry { |
||||
|
// fmt.Printf("\n=---------%v-----%v-----%v--------->\n=", v.Id, tableInfo.Id, v.Id == tableInfo.Id)
|
||||
|
if v.Id == tableInfo.Id { |
||||
|
isNew = false |
||||
|
f.ListAry[i].List = append(f.ListAry[i].List, masterUnit...) |
||||
|
} |
||||
|
} |
||||
|
if isNew { |
||||
|
tableInfo.List = append(tableInfo.List, masterUnit...) |
||||
|
f.ListAry = append(f.ListAry, tableInfo) |
||||
|
} |
||||
|
} else { |
||||
|
tableInfo.List = append(tableInfo.List, masterUnit...) |
||||
|
f.ListAry = append(f.ListAry, tableInfo) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 判断组件授权状态
|
||||
|
func (f *FlowTypeKeyWordAry) JuadgeUnitStatus(key string) (isLook, isErit bool, states int) { |
||||
|
isLook = true |
||||
|
isErit = true |
||||
|
for _, v := range f.NodePower { |
||||
|
if v.Id == key { |
||||
|
isLook = v.IsLook |
||||
|
isErit = v.IsEdit |
||||
|
} |
||||
|
} |
||||
|
if isLook && isErit { |
||||
|
states = 4 |
||||
|
} else if isLook && !isErit { |
||||
|
states = 3 |
||||
|
} else if !isLook && isErit { |
||||
|
states = 2 |
||||
|
} else { |
||||
|
states = 1 |
||||
|
} |
||||
|
return |
||||
|
} |
||||
@ -0,0 +1,483 @@ |
|||||
|
package user |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/models/modelAppPlatform" |
||||
|
"appPlatform/models/modelssystempermission" |
||||
|
"appPlatform/overall" |
||||
|
"appPlatform/overall/publicmethod" |
||||
|
"encoding/json" |
||||
|
"fmt" |
||||
|
"strconv" |
||||
|
) |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-11-24 08:30:44 |
||||
|
@ 功能: 获取个人系统权限 |
||||
|
*/ |
||||
|
func GetMyPower(powerType string, oupk, org, poetId int64) (allPower SendAllPower, err error) { |
||||
|
|
||||
|
//获取系统权限
|
||||
|
var systemPower []modelssystempermission.AuthPowerList |
||||
|
err = overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.AuthPowerList{}).Where("`appType` = 'system' AND `orgPowerType` = 'person' AND `orgOrUserKey` = ? AND `appKey` = 0", oupk).Find(&systemPower).Error |
||||
|
if len(systemPower) > 0 { //首先判断个人是否已经赋权
|
||||
|
for _, v := range systemPower { |
||||
|
var sysPower SystemInfoPower |
||||
|
sysPower.AppId = strconv.FormatInt(v.ItemId, 10) |
||||
|
if v.IsPick == 1 { |
||||
|
sysPower.IsPick = true |
||||
|
if !publicmethod.IsInTrue[int64](v.ItemId, allPower.MenuIdAry) { |
||||
|
allPower.MenuIdAry = append(allPower.MenuIdAry, v.ItemId) |
||||
|
} |
||||
|
} else { |
||||
|
sysPower.IsPick = false |
||||
|
} |
||||
|
if v.ButPower != "" && v.ButPower != "null" { |
||||
|
json.Unmarshal([]byte(v.ButPower), &sysPower.ButIdAry) |
||||
|
} |
||||
|
sysPower.Scope = v.VisibleRange |
||||
|
if v.VisibleRange == 5 && v.ButPower != "" && v.ButPower != "null" { |
||||
|
json.Unmarshal([]byte(v.VisibleOrg), &sysPower.ScopeManAry) |
||||
|
} |
||||
|
allPower.SystemPower = append(allPower.SystemPower, sysPower) |
||||
|
} |
||||
|
} else { |
||||
|
// var systemPower []modelssystempermission.AuthPowerList
|
||||
|
// err = overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.AuthPowerList{}).Where("`appType` = 'system' AND `orgPowerType` IN ('org','job','role') AND `orgOrUserKey` = ? AND `appKey` = 0", oupk).Find(&systemPower).Error
|
||||
|
var mySysMenuPower XieChengPowerSys |
||||
|
mySysMenuPower.GetPowerSystem(systemPower) |
||||
|
allPower.MenuIdAry = mySysMenuPower.MenuId |
||||
|
allPower.SystemPower = mySysMenuPower.SystemPower |
||||
|
syncSeting.Add(1) |
||||
|
go mySysMenuPower.GetOrgSysPower("system", "org", org) |
||||
|
syncSeting.Add(1) |
||||
|
go mySysMenuPower.GetOrgSysPower("system", "job", poetId) |
||||
|
syncSeting.Add(1) |
||||
|
go mySysMenuPower.GetOrgSysPower("system", "role", oupk) |
||||
|
syncSeting.Wait() |
||||
|
mySysMenuPower.GetPowerSystem(mySysMenuPower.SysTemList) |
||||
|
allPower.MenuIdAry = mySysMenuPower.MenuId |
||||
|
var menuList []modelAppPlatform.Menus |
||||
|
overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.Menus{}).Select("`id`,`name`").Where("`id` IN ?", mySysMenuPower.MenuId).Find(&menuList) |
||||
|
for _, v := range menuList { |
||||
|
for si, sv := range mySysMenuPower.SystemPower { |
||||
|
if strconv.Itoa(v.Id) == sv.AppId { |
||||
|
mySysMenuPower.SystemPower[si].Name = v.Name |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
allPower.SystemPower = mySysMenuPower.SystemPower |
||||
|
} |
||||
|
|
||||
|
//获取自定义表单权限
|
||||
|
var appPower []modelssystempermission.AuthPower |
||||
|
overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.AuthPower{}).Where("`appType` = 'app' AND `orgPowerType` = 'person' AND `orgOrUserKey` = ?", oupk).Find(&appPower) |
||||
|
if len(appPower) > 0 { //首先判断个人是否已经赋权
|
||||
|
for _, v := range appPower { |
||||
|
var myAppInfo AppMyPower |
||||
|
myAppInfo.AppId = strconv.FormatInt(v.AppKey, 10) |
||||
|
if v.IsTrue == 1 { |
||||
|
allPower.AppKeyAry = append(allPower.AppKeyAry, strconv.FormatInt(v.AppKey, 10)) |
||||
|
myAppInfo.IsPick = true |
||||
|
} else { |
||||
|
myAppInfo.IsPick = false |
||||
|
} |
||||
|
myAppInfo.FormTrue, myAppInfo.FormPower = GetTablePower(v.Id) |
||||
|
allPower.AppSystemPower = append(allPower.AppSystemPower, myAppInfo) |
||||
|
} |
||||
|
} else { |
||||
|
var myAppPower XieChengPowerSys |
||||
|
syncSeting.Add(1) |
||||
|
go myAppPower.GetAppFormPower("app", "org", org) |
||||
|
syncSeting.Add(1) |
||||
|
go myAppPower.GetAppFormPower("app", "job", poetId) |
||||
|
syncSeting.Add(1) |
||||
|
go myAppPower.GetAppFormPower("app", "role", oupk) |
||||
|
syncSeting.Wait() |
||||
|
var tableId []string |
||||
|
for _, v := range myAppPower.AppUUID { |
||||
|
if !publicmethod.IsInTrue[string](v, tableId) { |
||||
|
tableId = append(tableId, v) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
allPower.AppKeyAry = tableId |
||||
|
allPower.AppSystemPower = MergePower(myAppPower.FormTable) |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 合并组织、角色、岗位权限
|
||||
|
func MergePower(FormTable []AppMyPower) (list []AppMyPower) { |
||||
|
for _, v := range FormTable { //循环所有授权
|
||||
|
isNewApp := true |
||||
|
for li, lv := range list { //循环已合并过的授权
|
||||
|
if v.AppId == lv.AppId { //判断在已合并中是否已经存在
|
||||
|
isNewApp = false |
||||
|
for _, fv := range v.FormTrue { //合并App中已经授权的表单
|
||||
|
if !publicmethod.IsInTrue[string](fv, lv.FormTrue) { |
||||
|
list[li].FormTrue = append(list[li].FormTrue, fv) |
||||
|
} |
||||
|
} |
||||
|
for _, pv := range v.FormPower { //相应表单权限细节整合
|
||||
|
if pv.IsPick { |
||||
|
if !publicmethod.IsInTrue[string](pv.AppId, list[li].FormTrue) { |
||||
|
list[li].FormTrue = append(list[li].FormTrue, pv.AppId) |
||||
|
} |
||||
|
} |
||||
|
isNewTable := true |
||||
|
for fpi, fpv := range lv.FormPower { |
||||
|
if pv.AppId == fpv.AppId { |
||||
|
isNewTable = false |
||||
|
list[li].FormPower[fpi].ListPower = publicmethod.MergeStruct[string](pv.ListPower, fpv.ListPower) |
||||
|
list[li].FormPower[fpi].TablePower = publicmethod.MergeStruct[string](pv.TablePower, fpv.TablePower) |
||||
|
if pv.Scope < 1 { |
||||
|
pv.Scope = 1 |
||||
|
} |
||||
|
if pv.Scope >= fpv.Scope { |
||||
|
list[li].FormPower[fpi].Scope = pv.Scope |
||||
|
list[li].FormPower[fpi].ScopeManAry = publicmethod.MergeStruct[int](pv.ScopeManAry, fpv.ScopeManAry) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
if isNewTable { |
||||
|
list[li].FormPower = append(list[li].FormPower, pv) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
if isNewApp { |
||||
|
list = append(list, v) |
||||
|
} |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 自定义App
|
||||
|
func (x *XieChengPowerSys) GetAppFormPower(sysType, powerType string, key int64) { |
||||
|
defer syncSeting.Done() |
||||
|
switch powerType { |
||||
|
case "org": |
||||
|
//Step 1:获取可见App
|
||||
|
var appAuthPower []modelssystempermission.AuthPower |
||||
|
overall.CONSTANT_DB_System_Permission.Where("`appType` = ? AND `orgPowerType` = ? AND `orgOrUserKey` = ? AND `appKey` <> 0", sysType, powerType, key).Find(&appAuthPower) |
||||
|
if len(appAuthPower) > 0 { |
||||
|
for _, v := range appAuthPower { |
||||
|
appKeyStr := strconv.FormatInt(v.AppKey, 10) |
||||
|
var appSetUpPower AppMyPower |
||||
|
appSetUpPower.AppId = appKeyStr |
||||
|
if v.IsTrue == 1 { |
||||
|
appSetUpPower.IsPick = true |
||||
|
|
||||
|
if !publicmethod.IsInTrue[string](appKeyStr, x.AppUUID) { |
||||
|
x.AppUUID = append(x.AppUUID, appKeyStr) |
||||
|
} |
||||
|
} else { |
||||
|
appSetUpPower.IsPick = false |
||||
|
} |
||||
|
appSetUpPower.FormTrue, appSetUpPower.FormPower = GetMyAppTableForm(v.Id) |
||||
|
x.FormTable = append(x.FormTable, appSetUpPower) |
||||
|
} |
||||
|
} else { |
||||
|
var allFirstOrgId publicmethod.GetOrgAllParent |
||||
|
allFirstOrgId.GetOrgFirst(key) |
||||
|
if len(allFirstOrgId.Id) > 0 { //继承最近父级授权
|
||||
|
for _, v := range allFirstOrgId.Id { |
||||
|
var appAuthFirstPower []modelssystempermission.AuthPower |
||||
|
overall.CONSTANT_DB_System_Permission.Where("`appType` = ? AND `orgPowerType` = ? AND `orgOrUserKey` = ? AND `appKey` <> 0", sysType, powerType, v).Find(&appAuthFirstPower) |
||||
|
if len(appAuthFirstPower) > 0 { |
||||
|
for _, v := range appAuthFirstPower { |
||||
|
appKeyStr := strconv.FormatInt(v.AppKey, 10) |
||||
|
var appSetUpPower AppMyPower |
||||
|
appSetUpPower.AppId = appKeyStr |
||||
|
if v.IsTrue == 1 { |
||||
|
appSetUpPower.IsPick = true |
||||
|
|
||||
|
if !publicmethod.IsInTrue[string](appKeyStr, x.AppUUID) { |
||||
|
x.AppUUID = append(x.AppUUID, appKeyStr) |
||||
|
} |
||||
|
} else { |
||||
|
appSetUpPower.IsPick = false |
||||
|
} |
||||
|
appSetUpPower.FormTrue, appSetUpPower.FormPower = GetMyAppTableForm(v.Id) |
||||
|
x.FormTable = append(x.FormTable, appSetUpPower) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
case "role": |
||||
|
var roleId []int64 |
||||
|
overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.SystemRole{}).Select("`id`").Where("FIND_IN_SET(?, `superior`)", key).Find(&roleId) |
||||
|
if len(roleId) > 0 { |
||||
|
var appAuthPower []modelssystempermission.AuthPower |
||||
|
overall.CONSTANT_DB_System_Permission.Where("`appType` = ? AND `orgPowerType` = ? AND `orgOrUserKey` IN ? AND `appKey` <> 0", sysType, powerType, roleId).Find(&appAuthPower) |
||||
|
if len(appAuthPower) > 0 { |
||||
|
for _, v := range appAuthPower { |
||||
|
appKeyStr := strconv.FormatInt(v.AppKey, 10) |
||||
|
var appSetUpPower AppMyPower |
||||
|
appSetUpPower.AppId = appKeyStr |
||||
|
if v.IsTrue == 1 { |
||||
|
appSetUpPower.IsPick = true |
||||
|
|
||||
|
if !publicmethod.IsInTrue[string](appKeyStr, x.AppUUID) { |
||||
|
x.AppUUID = append(x.AppUUID, appKeyStr) |
||||
|
} |
||||
|
} else { |
||||
|
appSetUpPower.IsPick = false |
||||
|
} |
||||
|
appSetUpPower.FormTrue, appSetUpPower.FormPower = GetMyAppTableForm(v.Id) |
||||
|
x.FormTable = append(x.FormTable, appSetUpPower) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
default: |
||||
|
var appAuthPower []modelssystempermission.AuthPower |
||||
|
overall.CONSTANT_DB_System_Permission.Where("`appType` = ? AND `orgPowerType` = ? AND `orgOrUserKey` = ? AND `appKey` <> 0", sysType, powerType, key).Find(&appAuthPower) |
||||
|
if len(appAuthPower) > 0 { |
||||
|
for _, v := range appAuthPower { |
||||
|
appKeyStr := strconv.FormatInt(v.AppKey, 10) |
||||
|
var appSetUpPower AppMyPower |
||||
|
appSetUpPower.AppId = appKeyStr |
||||
|
if v.IsTrue == 1 { |
||||
|
appSetUpPower.IsPick = true |
||||
|
if !publicmethod.IsInTrue[string](appKeyStr, x.AppUUID) { |
||||
|
x.AppUUID = append(x.AppUUID, appKeyStr) |
||||
|
} |
||||
|
} else { |
||||
|
appSetUpPower.IsPick = false |
||||
|
} |
||||
|
appSetUpPower.FormTrue, appSetUpPower.FormPower = GetMyAppTableForm(v.Id) |
||||
|
x.FormTable = append(x.FormTable, appSetUpPower) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 获取自定义App表单
|
||||
|
func GetMyAppTableForm(authid int64) (formId []string, list []AppMyPowerTable) { |
||||
|
var formListPow []modelssystempermission.PowerInfo |
||||
|
overall.CONSTANT_DB_System_Permission.Where("`authId` = ? ", authid).Find(&formListPow) |
||||
|
for _, v := range formListPow { |
||||
|
idStr := strconv.FormatInt(v.ItemId, 10) |
||||
|
var formInfo AppMyPowerTable |
||||
|
formInfo.AppId = idStr |
||||
|
if v.IsPick == 1 { |
||||
|
formInfo.IsPick = true |
||||
|
if !publicmethod.IsInTrue[string](idStr, formId) { |
||||
|
formId = append(formId, idStr) |
||||
|
} |
||||
|
} else { |
||||
|
formInfo.IsPick = false |
||||
|
} |
||||
|
if v.ListPower != "" && v.ListPower != "null" { |
||||
|
json.Unmarshal([]byte(v.ListPower), &formInfo.ListPower) |
||||
|
} |
||||
|
if v.TablePower != "" && v.TablePower != "null" { |
||||
|
json.Unmarshal([]byte(v.TablePower), &formInfo.TablePower) |
||||
|
} |
||||
|
if v.VisibleRange == 0 { |
||||
|
v.VisibleRange = 1 |
||||
|
} |
||||
|
formInfo.Scope = v.VisibleRange |
||||
|
if v.VisibleOrg != "" && v.VisibleOrg != "null" { |
||||
|
json.Unmarshal([]byte(v.VisibleOrg), &formInfo.ScopeManAry) |
||||
|
} |
||||
|
list = append(list, formInfo) |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 系统菜单
|
||||
|
func (x *XieChengPowerSys) GetOrgSysPower(sysType, powerType string, key int64) { |
||||
|
defer syncSeting.Done() |
||||
|
// var systemPower []modelssystempermission.AuthPowerList
|
||||
|
goromDb := overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.AuthPowerList{}).Where("`appType` = ? AND `orgPowerType` = ? AND `appKey` = 0", sysType, powerType) |
||||
|
switch powerType { |
||||
|
case "org": |
||||
|
|
||||
|
var orgPowList []modelssystempermission.AuthPowerList |
||||
|
overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.AuthPowerList{}).Where("`appType` = ? AND `orgPowerType` = ? AND `appKey` = 0 AND `orgOrUserKey` = ? ", sysType, powerType, key).Find(&orgPowList) |
||||
|
if len(orgPowList) > 0 { |
||||
|
x.SysTemList = append(x.SysTemList, orgPowList...) |
||||
|
} else { |
||||
|
var allFirstOrgId publicmethod.GetOrgAllParent |
||||
|
allFirstOrgId.GetOrgFirst(key) |
||||
|
if len(allFirstOrgId.Id) > 0 { |
||||
|
for _, v := range allFirstOrgId.Id { |
||||
|
var fatherOrgPower []modelssystempermission.AuthPowerList |
||||
|
overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.AuthPowerList{}).Where("`appType` = ? AND `orgPowerType` = ? AND `appKey` = 0 AND `orgOrUserKey` = ?", sysType, powerType, v).Find(&fatherOrgPower) |
||||
|
if len(fatherOrgPower) > 0 { |
||||
|
fmt.Printf("Org--%v--->%v\n\n", v, len(fatherOrgPower)) |
||||
|
x.SysTemList = append(x.SysTemList, fatherOrgPower...) |
||||
|
break |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// var allFirstOrgId publicmethod.GetOrgAllParent
|
||||
|
// allFirstOrgId.GetOrgFirst(key)
|
||||
|
// allFirstOrgId.Id = append(allFirstOrgId.Id, key)
|
||||
|
|
||||
|
// goromDb = goromDb.Where("`orgOrUserKey` IN ?", allFirstOrgId.Id)
|
||||
|
// goromDb.Find(&x.SysTemList)
|
||||
|
case "role": |
||||
|
var roleId []int64 |
||||
|
overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.SystemRole{}).Select("`id`").Where("FIND_IN_SET(?, `superior`)", key).Find(&roleId) |
||||
|
// fmt.Printf("role----->%v\n\n", roleId)
|
||||
|
if len(roleId) > 0 { |
||||
|
goromDb = goromDb.Where("`orgOrUserKey` IN ?", roleId) |
||||
|
goromDb.Find(&x.SysTemList) |
||||
|
} |
||||
|
|
||||
|
default: |
||||
|
// fmt.Printf("post----->%v\n\n", key)
|
||||
|
goromDb = goromDb.Where("`orgOrUserKey` = ?", key) |
||||
|
goromDb.Find(&x.SysTemList) |
||||
|
|
||||
|
} |
||||
|
|
||||
|
// if len(systemPower) > 0 {
|
||||
|
// x.GetPowerSystem(systemPower)
|
||||
|
// }
|
||||
|
} |
||||
|
|
||||
|
func (x *XieChengPowerSys) GetPowerSystem(list []modelssystempermission.AuthPowerList) { |
||||
|
// fmt.Printf("管理范围----list--->%v--->%v\n\n\n", len(list), len(x.SystemPower))
|
||||
|
for _, v := range list { |
||||
|
// fmt.Printf("管理范围----list--->%v--->%v--->%v\n\n\n", len(list), v.VisibleRange, len(v.VisibleOrg))
|
||||
|
appId := strconv.FormatInt(v.ItemId, 10) |
||||
|
if len(x.SystemPower) > 0 { //判断是否已经存在该项赋值
|
||||
|
isWrite := true |
||||
|
for xi, xv := range x.SystemPower { |
||||
|
if appId == xv.AppId { //存在赋值,修改
|
||||
|
// fmt.Printf("管理范围-----%v----->%v----->%v\n\n\n", appId, v.VisibleRange, xv.Scope)
|
||||
|
|
||||
|
isWrite = false |
||||
|
if v.IsPick == 1 { |
||||
|
x.SystemPower[xi].IsPick = true |
||||
|
} |
||||
|
if v.ButPower != "" && v.ButPower != "null" { |
||||
|
var butPow []int64 |
||||
|
json.Unmarshal([]byte(v.ButPower), &butPow) |
||||
|
for _, bv := range butPow { |
||||
|
if !publicmethod.IsInTrue[int64](bv, x.SystemPower[xi].ButIdAry) { |
||||
|
x.SystemPower[xi].ButIdAry = append(x.SystemPower[xi].ButIdAry, bv) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
if v.VisibleRange == 0 { |
||||
|
v.VisibleRange = 1 |
||||
|
} |
||||
|
if v.VisibleRange > xv.Scope { |
||||
|
x.SystemPower[xi].Scope = v.VisibleRange |
||||
|
if v.VisibleOrg != "" && v.VisibleOrg != "null" { |
||||
|
var visAry []int |
||||
|
json.Unmarshal([]byte(v.VisibleOrg), &visAry) |
||||
|
for _, vv := range visAry { |
||||
|
if !publicmethod.IsInTrue[int](vv, x.SystemPower[xi].ScopeManAry) { |
||||
|
x.SystemPower[xi].ScopeManAry = append(x.SystemPower[xi].ScopeManAry, vv) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
if isWrite { //没有赋值新增
|
||||
|
var menuPower SystemInfoPower |
||||
|
menuPower.AppId = appId |
||||
|
if v.IsPick == 1 { |
||||
|
menuPower.IsPick = true |
||||
|
} else { |
||||
|
menuPower.IsPick = false |
||||
|
} |
||||
|
if v.ButPower != "" && v.ButPower != "null" { |
||||
|
json.Unmarshal([]byte(v.ButPower), &menuPower.ButIdAry) |
||||
|
} else { |
||||
|
menuPower.ButIdAry = []int64{} |
||||
|
} |
||||
|
if v.VisibleRange == 0 { |
||||
|
v.VisibleRange = 1 |
||||
|
} |
||||
|
menuPower.Scope = v.VisibleRange |
||||
|
if v.VisibleOrg != "" && v.VisibleOrg != "null" { |
||||
|
json.Unmarshal([]byte(v.VisibleOrg), &menuPower.ScopeManAry) |
||||
|
} else { |
||||
|
menuPower.ScopeManAry = []int{} |
||||
|
} |
||||
|
x.SystemPower = append(x.SystemPower, menuPower) |
||||
|
} |
||||
|
} else { //没有赋值新增
|
||||
|
var menuPower SystemInfoPower |
||||
|
menuPower.AppId = appId |
||||
|
if v.IsPick == 1 { |
||||
|
menuPower.IsPick = true |
||||
|
} else { |
||||
|
menuPower.IsPick = false |
||||
|
} |
||||
|
if v.ButPower != "" && v.ButPower != "null" { |
||||
|
json.Unmarshal([]byte(v.ButPower), &menuPower.ButIdAry) |
||||
|
} else { |
||||
|
menuPower.ButIdAry = []int64{} |
||||
|
} |
||||
|
menuPower.Scope = 1 |
||||
|
if v.VisibleRange > menuPower.Scope { |
||||
|
menuPower.Scope = v.VisibleRange |
||||
|
} |
||||
|
|
||||
|
if v.VisibleOrg != "" && v.VisibleOrg != "null" { |
||||
|
json.Unmarshal([]byte(v.VisibleOrg), &menuPower.ScopeManAry) |
||||
|
} else { |
||||
|
menuPower.ScopeManAry = []int{} |
||||
|
} |
||||
|
x.SystemPower = append(x.SystemPower, menuPower) |
||||
|
} |
||||
|
if v.IsPick == 1 { |
||||
|
// idStr := strconv.FormatInt(v.ItemId, 10)
|
||||
|
if !publicmethod.IsInTrue[int64](v.ItemId, x.MenuId) { |
||||
|
x.MenuId = append(x.MenuId, v.ItemId) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-11-24 14:55:49 |
||||
|
@ 功能: 获取自定义表单权限解析 |
||||
|
*/ |
||||
|
func GetTablePower(authId int64) (itenIdAry []string, TableList []AppMyPowerTable) { |
||||
|
var tableInfo []modelssystempermission.PowerInfo |
||||
|
overall.CONSTANT_DB_System_Permission.Where("`authId` = ?", authId).Find(&tableInfo) |
||||
|
for _, v := range tableInfo { |
||||
|
var formPwInfo AppMyPowerTable |
||||
|
itemIdSte := strconv.FormatInt(v.ItemId, 10) |
||||
|
formPwInfo.AppId = itemIdSte |
||||
|
if v.IsPick == 1 { |
||||
|
if !publicmethod.IsInTrue[string](itemIdSte, itenIdAry) { |
||||
|
itenIdAry = append(itenIdAry, itemIdSte) |
||||
|
} |
||||
|
formPwInfo.IsPick = true |
||||
|
} else { |
||||
|
formPwInfo.IsPick = false |
||||
|
} |
||||
|
formPwInfo.Scope = v.VisibleRange |
||||
|
if v.VisibleRange == 5 && v.ButPower != "" && v.ButPower != "null" { |
||||
|
json.Unmarshal([]byte(v.VisibleOrg), &formPwInfo.ScopeManAry) |
||||
|
} |
||||
|
if v.TablePower != "" && v.TablePower != "null" { |
||||
|
json.Unmarshal([]byte(v.TablePower), &formPwInfo.TablePower) |
||||
|
} |
||||
|
if v.ListPower != "" && v.ListPower != "null" { |
||||
|
json.Unmarshal([]byte(v.ListPower), &formPwInfo.ListPower) |
||||
|
} |
||||
|
TableList = append(TableList, formPwInfo) |
||||
|
} |
||||
|
return |
||||
|
} |
||||
@ -0,0 +1,3 @@ |
|||||
|
package appPower |
||||
|
|
||||
|
type ApiRouter struct{} |
||||
@ -0,0 +1,32 @@ |
|||||
|
package appPower |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/api/version1" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
/** |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-11-10 10:50:19 |
||||
|
@ 功能: 权限处理 |
||||
|
*/ |
||||
|
|
||||
|
func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) { |
||||
|
apiRouter := router.Group("authorize") |
||||
|
|
||||
|
var methodBinding = version1.AppApiEntry.AuthorizeApi |
||||
|
{ |
||||
|
apiRouter.GET("", methodBinding.Index) //入口
|
||||
|
apiRouter.POST("", methodBinding.Index) //入口
|
||||
|
|
||||
|
apiRouter.POST("appPowerUnit", methodBinding.AppPowerUnit) //获取平台授权项目
|
||||
|
apiRouter.POST("getMyPeoplceAndSunOrg", methodBinding.GetMyPeopleAndSunOrg) //获取首层子行政组织和本组织下的人员
|
||||
|
apiRouter.POST("getMyPeopleAndSunOrgPost", methodBinding.GetMyPeopleAndSunOrgPost) //获取首层子行政组织和本组织下的岗位及人员
|
||||
|
apiRouter.POST("getPowerPageUser", methodBinding.GetPowerPageUser) //获取人员
|
||||
|
apiRouter.POST("systemAppAuthorization", methodBinding.SystemAppAuthorization) //授权
|
||||
|
apiRouter.POST("getRolePeople", methodBinding.GetRolePeople) //获取角色使用人
|
||||
|
apiRouter.POST("savePickRoleMan", methodBinding.SavePickRoleMan) //保存角色使用人
|
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,3 @@ |
|||||
|
package hrRoute |
||||
|
|
||||
|
type ApiRouter struct{} |
||||
@ -0,0 +1,18 @@ |
|||||
|
package hrRoute |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/api/version1" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
// 授权
|
||||
|
func (p *ApiRouter) InitRouterGroup(route *gin.RouterGroup) { |
||||
|
apiRouter := route.Group("hr") |
||||
|
var apiHandle = version1.AppApiEntry.HrApi |
||||
|
{ |
||||
|
apiRouter.GET("", apiHandle.Index) //入口
|
||||
|
apiRouter.POST("", apiHandle.Index) //入口
|
||||
|
apiRouter.POST("authorizeOrgTree", apiHandle.AuthorizeOrgTree) //行政组织树
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,78 @@ |
|||||
|
package customerForm |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/overall" |
||||
|
"strings" |
||||
|
) |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2024-03-06 13:23:03 |
||||
|
@ 功能: 公司值班设定表 |
||||
|
*/ |
||||
|
type SCApplication struct { |
||||
|
Id int64 `gorm:"column:id;type:bigint(20) unsigned;primary_key;AUTO_INCREMENT" json:"id"` |
||||
|
MastersKey int64 `gorm:"column:masters_key;type:bigint(20) unsigned;default:0;comment:主表标识;NOT NULL" json:"masters_key"` |
||||
|
Creater int64 `gorm:"column:creater;type:bigint(20);comment:申请人" json:"creater"` |
||||
|
CreaterTime int64 `gorm:"column:creater_time;type:bigint(20) unsigned;default:0;comment:创建时间;NOT NULL" json:"creater_time"` |
||||
|
EditTime int64 `gorm:"column:edit_time;type:bigint(20) unsigned;default:0;comment:编辑时间;NOT NULL" json:"edit_time"` |
||||
|
FlowId int64 `gorm:"column:flow_id;type:bigint(20) unsigned;default:0;comment:流程识别标识;NOT NULL" json:"flow_id"` |
||||
|
States int `gorm:"column:states;type:int(11) unsigned;default:1;comment:状态(1:启用,2:禁用;3:删除);NOT NULL" json:"states"` |
||||
|
FlowIsOpen int `gorm:"column:flowIsOpen;type:int(1) unsigned;default:2;comment:是否开启工作流;NOT NULL" json:"flowIsOpen"` |
||||
|
Diao4Huan4Ren2 string `gorm:"column:diao4huan4ren2;type:mediumtext;comment:调换人" json:"diao4huan4ren2"` |
||||
|
Shen1Qing3Yuan2Yin1 string `gorm:"column:shen1qing3yuan2yin1;type:mediumtext;comment:申请原因" json:"shen1qing3yuan2yin1"` |
||||
|
Diao4Huan4Fang1Shi4 string `gorm:"column:diao4huan4fang1shi4;type:varchar(50);comment:调换方式" json:"diao4huan4fang1shi4"` |
||||
|
Shou3Ji1Hao4 string `gorm:"column:shou3ji1hao4;type:varchar(255);comment:手机号" json:"shou3ji1hao4"` |
||||
|
CreaterOrg int `gorm:"column:createrOrg;type:int(1) unsigned;default:2;comment:创建人行政组织;NOT NULL" json:"createrOrg"` |
||||
|
Dang1Zhi2Ri4Qi141995810 int64 `gorm:"column:dang1zhi2ri4qi141995810;type:bigint(20) unsigned;default:0;comment:当值日期;NOT NULL" json:"dang1zhi2ri4qi141995810"` |
||||
|
Zhi2Ban1Lei4Xing2 string `gorm:"column:zhi2ban1lei4xing2;type:varchar(50);comment:值班类型" json:"zhi2ban1lei4xing2"` |
||||
|
Diao4Huan4Ri4Qi1 int64 `gorm:"column:diao4huan4ri4qi1;type:bigint(20) unsigned;default:0;comment:调换日期;NOT NULL" json:"diao4huan4ri4qi1"` |
||||
|
Fu4Jian4 string `gorm:"column:fu4jian4;type:mediumtext;comment:附件" json:"fu4jian4"` |
||||
|
Shou3Ji1Hao453554781 string `gorm:"column:shou3ji1hao453554781;type:varchar(255);comment:手机号" json:"shou3ji1hao453554781"` |
||||
|
} |
||||
|
|
||||
|
func (cont *SCApplication) TableName() string { |
||||
|
return "shiftChangeApplication" |
||||
|
} |
||||
|
|
||||
|
// 编辑内容
|
||||
|
func (cont *SCApplication) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
||||
|
err = overall.CONSTANT_DB_CustomerForm.Model(&cont).Where(whereMap).Updates(saveData).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 获取内容
|
||||
|
func (cont *SCApplication) GetCont(whereMap interface{}, field ...string) (err error) { |
||||
|
gormDb := overall.CONSTANT_DB_CustomerForm.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 *SCApplication) CountCont(whereMap interface{}) (countId int64) { |
||||
|
overall.CONSTANT_DB_CustomerForm.Model(&cont).Where(whereMap).Count(&countId) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 读取全部信息
|
||||
|
func (cont *SCApplication) ContMap(whereMap interface{}, field ...string) (countAry []SCApplication, err error) { |
||||
|
gormDb := overall.CONSTANT_DB_CustomerForm.Model(&cont) |
||||
|
if len(field) > 0 { |
||||
|
fieldStr := strings.Join(field, ",") |
||||
|
gormDb = gormDb.Select(fieldStr) |
||||
|
} |
||||
|
err = gormDb.Where(whereMap).Find(&countAry).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 删除内容
|
||||
|
func (cont *SCApplication) DelCont(whereMap interface{}) (err error) { |
||||
|
err = overall.CONSTANT_DB_CustomerForm.Where(whereMap).Delete(&cont).Error |
||||
|
return |
||||
|
} |
||||
@ -0,0 +1,70 @@ |
|||||
|
package modelAppPlatform |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/overall" |
||||
|
"strings" |
||||
|
) |
||||
|
|
||||
|
// 个人图表设置
|
||||
|
type Mychart struct { |
||||
|
Uuid int64 `gorm:"column:uuid;type:bigint(20) unsigned;primary_key" json:"uuid"` |
||||
|
TableKey string `gorm:"column:tableKey;type:varchar(200);comment:关联得表单key" json:"tableKey"` |
||||
|
UserKey int64 `gorm:"column:userKey;type:bigint(20) unsigned;comment:使用人的KEY;NOT NULL" json:"userKey"` |
||||
|
ChartView string `gorm:"column:chartView;type:longtext;comment:图标设定值" json:"chartView"` |
||||
|
EditTime int64 `gorm:"column:editTime;type:bigint(20) unsigned;comment:编辑时间" json:"editTime"` |
||||
|
} |
||||
|
|
||||
|
func (m Mychart) Create(mychart *Mychart) { |
||||
|
panic("unimplemented") |
||||
|
} |
||||
|
|
||||
|
func (m *Mychart) TableName() string { |
||||
|
return "mychart" |
||||
|
} |
||||
|
|
||||
|
// 写入内容
|
||||
|
func (cont *Mychart) WriteCont() (err error) { |
||||
|
err = overall.CONSTANT_DB_AppPlatform.Create(&cont).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 编辑内容
|
||||
|
func (cont *Mychart) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
||||
|
err = overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Updates(saveData).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 获取内容
|
||||
|
func (cont *Mychart) GetCont(whereMap interface{}, field ...string) (err error) { |
||||
|
gormDb := overall.CONSTANT_DB_AppPlatform.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 *Mychart) CountCont(whereMap interface{}) (countId int64) { |
||||
|
overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Count(&countId) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 读取全部信息
|
||||
|
func (cont *Mychart) ContMap(whereMap interface{}, field ...string) (countAry []Mychart, err error) { |
||||
|
gormDb := overall.CONSTANT_DB_AppPlatform.Model(&cont) |
||||
|
if len(field) > 0 { |
||||
|
fieldStr := strings.Join(field, ",") |
||||
|
gormDb = gormDb.Select(fieldStr) |
||||
|
} |
||||
|
err = gormDb.Where(whereMap).Find(&countAry).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 删除内容
|
||||
|
func (cont *Mychart) DelCont(whereMap interface{}) (err error) { |
||||
|
err = overall.CONSTANT_DB_AppPlatform.Where(whereMap).Delete(&cont).Error |
||||
|
return |
||||
|
} |
||||
@ -0,0 +1,82 @@ |
|||||
|
package modelshr |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/middleware/grocerystore" |
||||
|
"appPlatform/overall" |
||||
|
"encoding/json" |
||||
|
"fmt" |
||||
|
"strings" |
||||
|
) |
||||
|
|
||||
|
// 行政组织内哦他那个
|
||||
|
type OrgCont struct { |
||||
|
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` |
||||
|
Number string `json:"number" gorm:"column:number;type:varchar(50) unsigned;default:'';not null;comment:行政编码"` |
||||
|
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:组织名称"` |
||||
|
Superior int64 `json:"superior" gorm:"column:superior;type:bigint(20) unsigned;default:0;not null;comment:上级ID"` |
||||
|
OrganizationType int64 `json:"organizationtype" gorm:"column:organization_type;type:bigint(20) unsigned;default:0;not null;comment:行政组织类型"` |
||||
|
Abbreviation string `json:"abbreviation" gorm:"column:abbreviation;type:varchar(255) unsigned;default:'';not null;comment:行政组织简称"` |
||||
|
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
||||
|
State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
||||
|
WechatOrganizationId int64 `json:"wechatorganizationid" gorm:"column:wechat_organization_id;type:bigint(20) unsigned;default:0;not null;comment:微信组织架构对照码"` |
||||
|
SuperiorSun string `json:"superiorsun" gorm:"column:superior_sun;type:mediumtext;comment:级联ID"` |
||||
|
Schoole int64 `json:"schoole" gorm:"column:schoole;type:bigint(20) unsigned;default:0;not null;comment:原知行学院对照码"` |
||||
|
KingdeeId string `json:"kingdeeid" gorm:"column:kingdeeid;type:varchar(255) unsigned;default:'';comment:金蝶对照ID"` |
||||
|
IsPower int `json:"ispower" gorm:"column:ispower;type:int(1) unsigned;default:2;not null;comment:是否为实权部门"` |
||||
|
Sort int `json:"sort" gorm:"column:sort;type:int(6) unsigned;default:100;not null;comment:排序"` |
||||
|
TypeName string `json:"typeName" gorm:"column:type_name;type:varchar(255) unsigned;default:'';not null;comment:类型名称"` |
||||
|
Level int64 `json:"level" gorm:"column:level;type:int(5) unsigned;default:1;not null;comment:级别"` |
||||
|
} |
||||
|
|
||||
|
func (OrgCont *OrgCont) TableName() string { |
||||
|
return "org_cont" |
||||
|
} |
||||
|
|
||||
|
// 获取行政组织内容
|
||||
|
func (cont *OrgCont) GetCont(whereMap interface{}, field ...string) (err error) { |
||||
|
gormDb := overall.CONSTANT_DB_HR.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 *OrgCont) CountCont(whereMap interface{}) (countId int64) { |
||||
|
overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 读取全部信息
|
||||
|
func (cont *OrgCont) ContMap(whereMap interface{}, field ...string) (countAry []OrgCont) { |
||||
|
gormDb := overall.CONSTANT_DB_HR.Model(&cont) |
||||
|
if len(field) > 0 { |
||||
|
fieldStr := strings.Join(field, ",") |
||||
|
gormDb = gormDb.Select(fieldStr) |
||||
|
} |
||||
|
gormDb.Where(whereMap).Find(&countAry) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 根据ID获取行政组织内容
|
||||
|
func (cont *OrgCont) RedisCont(orgId int64) (err error) { |
||||
|
redisFileKey := fmt.Sprintf("org:Info:%v_%v", orgId, overall.CONSTANT_CONFIG.RedisPrefixStr.Alias) |
||||
|
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS4) //设定redis库
|
||||
|
isTrue, tokens := redisClient.Get(redisFileKey) |
||||
|
if isTrue && tokens != "" { |
||||
|
err = json.Unmarshal([]byte(tokens), &cont) |
||||
|
return |
||||
|
} else { |
||||
|
var jsonStr []byte |
||||
|
err = overall.CONSTANT_DB_HR.Model(&cont).Where("`id` = ?", orgId).First(&cont).Error |
||||
|
if err == nil { |
||||
|
redisClient.SetRedisTime(0) |
||||
|
jsonStr, err = json.Marshal(cont) |
||||
|
redisClient.Set(redisFileKey, string(jsonStr)) |
||||
|
} |
||||
|
} |
||||
|
return |
||||
|
} |
||||
@ -0,0 +1,63 @@ |
|||||
|
package modelssystempermission |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/overall" |
||||
|
"strings" |
||||
|
) |
||||
|
|
||||
|
// 新版赋权表单
|
||||
|
type AuthPower struct { |
||||
|
Id int64 `gorm:"column:id;type:bigint(20) unsigned;primary_key" json:"id"` |
||||
|
OrgPowerType string `gorm:"column:orgPowerType;type:varchar(20);comment:赋权类型(org:组织;job:岗位;role:角色;person:个人)" json:"orgPowerType"` |
||||
|
OrgOrUserKey int64 `gorm:"column:orgOrUserKey;type:bigint(20) unsigned;default:0;comment:行政组织或角色、人员识别符;NOT NULL" json:"orgOrUserKey"` |
||||
|
AppType string `gorm:"column:appType;type:varchar(30);comment:系统类型(system:系统平台;app:自定义表单与应用)" json:"appType"` |
||||
|
AppKey int64 `gorm:"column:appKey;type:bigint(20) unsigned;default:0;comment:自定义应用App" json:"appKey"` |
||||
|
Time int64 `gorm:"column:time;type:bigint(20) unsigned;default:0;comment:编辑时间;NOT NULL" json:"time"` |
||||
|
IsTrue int `gorm:"column:isTrue;type:int(1) unsigned;default:0;comment:是否有权(1:有;非1:无);NOT NULL" json:"isTrue"` |
||||
|
PowerInfo string `gorm:"column:powerInfo;type:text;comment:权限结构体" json:"powerInfo"` |
||||
|
} |
||||
|
|
||||
|
func (cont *AuthPower) TableName() string { |
||||
|
return "auth_power" |
||||
|
} |
||||
|
|
||||
|
// 编辑内容
|
||||
|
func (cont *AuthPower) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
||||
|
err = overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Updates(saveData).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 获取内容
|
||||
|
func (cont *AuthPower) 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 *AuthPower) CountCont(whereMap interface{}) (countId int64) { |
||||
|
overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Count(&countId) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 读取全部信息
|
||||
|
func (cont *AuthPower) ContMap(whereMap interface{}, field ...string) (countAry []AuthPower, 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 *AuthPower) DelCont(whereMap interface{}) (err error) { |
||||
|
err = overall.CONSTANT_DB_System_Permission.Where(whereMap).Delete(&cont).Error |
||||
|
return |
||||
|
} |
||||
@ -0,0 +1,72 @@ |
|||||
|
package modelssystempermission |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/overall" |
||||
|
"strings" |
||||
|
) |
||||
|
|
||||
|
// 新版赋权表单
|
||||
|
type AuthPowerList struct { |
||||
|
Id int64 `gorm:"column:id;type:bigint(20) unsigned;primary_key;AUTO_INCREMENT" json:"id"` |
||||
|
AuthId int64 `gorm:"column:authId;type:bigint(20) unsigned;default:0;comment:归属权限;NOT NULL" json:"authId"` |
||||
|
ItemId int64 `gorm:"column:itemId;type:bigint(20) unsigned;default:0;comment:项目ID;NOT NULL" json:"itemId"` |
||||
|
IsPick int `gorm:"column:isPick;type:int(1) unsigned;default:0;comment:是否有权(1:有;非1:无);NOT NULL" json:"isPick"` |
||||
|
TablePower string `gorm:"column:tablePower;type:text;comment:表单权限" json:"tablePower"` |
||||
|
ListPower string `gorm:"column:listPower;type:text;comment:列表权限" json:"listPower"` |
||||
|
VisibleRange int `gorm:"column:visibleRange;type:int(1);comment:可见范围(1:本人;2:本岗位;3:本部门;4:本分部;5:指定行政组织;6:所有);NOT NULL" json:"visibleRange"` |
||||
|
VisibleOrg string `gorm:"column:visibleOrg;type:text;comment:可见范围辅助参数" json:"visibleOrg"` |
||||
|
ButPower string `gorm:"column:butPower;type:text;comment:按钮权限" json:"butPower"` |
||||
|
Time int64 `gorm:"column:time;type:bigint(20) unsigned;default:0;comment:编辑时间;NOT NULL" json:"time"` |
||||
|
|
||||
|
OrgPowerType string `gorm:"column:orgPowerType;type:varchar(20);comment:赋权类型(org:组织;job:岗位;role:角色;person:个人)" json:"orgPowerType"` |
||||
|
OrgOrUserKey int64 `gorm:"column:orgOrUserKey;type:bigint(20) unsigned;default:0;comment:行政组织或角色、人员识别符;NOT NULL" json:"orgOrUserKey"` |
||||
|
AppType string `gorm:"column:appType;type:varchar(30);comment:系统类型(system:系统平台;app:自定义表单与应用)" json:"appType"` |
||||
|
AppKey int64 `gorm:"column:appKey;type:bigint(20) unsigned;default:0;comment:自定义应用App" json:"appKey"` |
||||
|
IsTrue int `gorm:"column:isTrue;type:int(1) unsigned;default:0;comment:是否有权(1:有;非1:无);NOT NULL" json:"isTrue"` |
||||
|
PowerInfo string `json:"powerInfo" gorm:"column:powerInfo;type:text;comment:权限结构体"` |
||||
|
} |
||||
|
|
||||
|
func (cont *AuthPowerList) TableName() string { |
||||
|
return "authpowerlist" |
||||
|
} |
||||
|
|
||||
|
// 编辑内容
|
||||
|
func (cont *AuthPowerList) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
||||
|
err = overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Updates(saveData).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 获取内容
|
||||
|
func (cont *AuthPowerList) 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 *AuthPowerList) CountCont(whereMap interface{}) (countId int64) { |
||||
|
overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Count(&countId) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 读取全部信息
|
||||
|
func (cont *AuthPowerList) ContMap(whereMap interface{}, field ...string) (countAry []AuthPowerList, 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 *AuthPowerList) DelCont(whereMap interface{}) (err error) { |
||||
|
err = overall.CONSTANT_DB_System_Permission.Where(whereMap).Delete(&cont).Error |
||||
|
return |
||||
|
} |
||||
@ -0,0 +1,65 @@ |
|||||
|
package modelssystempermission |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/overall" |
||||
|
"strings" |
||||
|
) |
||||
|
|
||||
|
// 权限配置详情
|
||||
|
type PowerInfo struct { |
||||
|
Id int64 `gorm:"column:id;type:bigint(20) unsigned;primary_key;AUTO_INCREMENT" json:"id"` |
||||
|
AuthId int64 `gorm:"column:authId;type:bigint(20) unsigned;default:0;comment:归属权限;NOT NULL" json:"authId"` |
||||
|
ItemId int64 `gorm:"column:itemId;type:bigint(20) unsigned;default:0;comment:项目ID;NOT NULL" json:"itemId"` |
||||
|
IsPick int `gorm:"column:isPick;type:int(1) unsigned;default:0;comment:是否有权(1:有;非1:无);NOT NULL" json:"isPick"` |
||||
|
TablePower string `gorm:"column:tablePower;type:text;comment:表单权限" json:"tablePower"` |
||||
|
ListPower string `gorm:"column:listPower;type:text;comment:列表权限" json:"listPower"` |
||||
|
VisibleRange int `gorm:"column:visibleRange;type:int(1);comment:可见范围(1:本人;2:本岗位;3:本部门;4:本分部;5:指定行政组织;6:所有);NOT NULL" json:"visibleRange"` |
||||
|
VisibleOrg string `gorm:"column:visibleOrg;type:text;comment:可见范围辅助参数" json:"visibleOrg"` |
||||
|
ButPower string `gorm:"column:butPower;type:text;comment:按钮权限" json:"butPower"` |
||||
|
Time int64 `gorm:"column:time;type:bigint(20) unsigned;default:0;comment:编辑时间;NOT NULL" json:"time"` |
||||
|
} |
||||
|
|
||||
|
func (cont *PowerInfo) TableName() string { |
||||
|
return "power_info" |
||||
|
} |
||||
|
|
||||
|
// 编辑内容
|
||||
|
func (cont *PowerInfo) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
||||
|
err = overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Updates(saveData).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 获取内容
|
||||
|
func (cont *PowerInfo) 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 *PowerInfo) CountCont(whereMap interface{}) (countId int64) { |
||||
|
overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Count(&countId) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 读取全部信息
|
||||
|
func (cont *PowerInfo) ContMap(whereMap interface{}, field ...string) (countAry []PowerInfo, 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 *PowerInfo) DelCont(whereMap interface{}) (err error) { |
||||
|
err = overall.CONSTANT_DB_System_Permission.Where(whereMap).Delete(&cont).Error |
||||
|
return |
||||
|
} |
||||
@ -0,0 +1,69 @@ |
|||||
|
// Code generated by sql2gorm. DO NOT EDIT.
|
||||
|
package teamlog |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/overall" |
||||
|
"strings" |
||||
|
) |
||||
|
|
||||
|
// 公司值班表记录
|
||||
|
type Companylog struct { |
||||
|
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primary_key;AUTO_INCREMENT" json:"id"` |
||||
|
Orgid int64 `gorm:"column:orgid;type:bigint(20) unsigned;default:0;NOT NULL" json:"orgid"` // 行政组织ID
|
||||
|
RunTime int64 `gorm:"column:runTime;type:bigint(20) unsigned;default:0;NOT NULL" json:"runTime"` // 执行时间
|
||||
|
Years int `gorm:"column:years;type:int(5) unsigned;default:0;NOT NULL" json:"years"` // 年
|
||||
|
Months int `gorm:"column:months;type:int(3) unsigned;default:0;NOT NULL" json:"months"` // 月
|
||||
|
Days int `gorm:"column:days;type:int(3) unsigned;default:0;NOT NULL" json:"days"` // 日
|
||||
|
Holiday int `gorm:"column:holiday;type:int(1) unsigned;default:2;NOT NULL" json:"holiday"` // 假日(1:是;2:否)
|
||||
|
AllDay string `gorm:"column:allDay;type:mediumtext" json:"allDay"` // 全天值班人员
|
||||
|
BaiTian string `gorm:"column:baiTian;type:mediumtext" json:"baiTian"` // 白天值班人员
|
||||
|
Night string `gorm:"column:night;type:mediumtext" json:"night"` // 夜晚值班人员
|
||||
|
SaveTime int64 `gorm:"column:saveTime;type:bigint(20);NOT NULL" json:"saveTime"` // 编辑时间
|
||||
|
Morning string `gorm:"column:morning;type:mediumtext" json:"morning"` // 上午值班人员
|
||||
|
Afternoon string `gorm:"column:afternoon;type:mediumtext" json:"afternoon"` // 下午值班人员
|
||||
|
} |
||||
|
|
||||
|
func (m *Companylog) TableName() string { |
||||
|
return "companylog" |
||||
|
} |
||||
|
|
||||
|
// 编辑内容
|
||||
|
func (cont *Companylog) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
||||
|
err = overall.CONSTANT_DB_TeamsLog.Model(&cont).Where(whereMap).Updates(saveData).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 获取内容
|
||||
|
func (cont *Companylog) GetCont(whereMap interface{}, field ...string) (err error) { |
||||
|
gormDb := overall.CONSTANT_DB_TeamsLog.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 *Companylog) CountCont(whereMap interface{}) (countId int64) { |
||||
|
overall.CONSTANT_DB_TeamsLog.Model(&cont).Where(whereMap).Count(&countId) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 读取全部信息
|
||||
|
func (cont *Companylog) ContMap(whereMap interface{}, field ...string) (countAry []TeamsLog, err error) { |
||||
|
gormDb := overall.CONSTANT_DB_TeamsLog.Model(&cont) |
||||
|
if len(field) > 0 { |
||||
|
fieldStr := strings.Join(field, ",") |
||||
|
gormDb = gormDb.Select(fieldStr) |
||||
|
} |
||||
|
err = gormDb.Where(whereMap).Find(&countAry).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 删除内容
|
||||
|
func (cont *Companylog) DelCont(whereMap interface{}) (err error) { |
||||
|
err = overall.CONSTANT_DB_TeamsLog.Where(whereMap).Delete(&cont).Error |
||||
|
return |
||||
|
} |
||||
@ -0,0 +1,53 @@ |
|||||
|
package publicmethod |
||||
|
|
||||
|
import ( |
||||
|
"appPlatform/middleware/grocerystore" |
||||
|
"appPlatform/overall" |
||||
|
"encoding/json" |
||||
|
"fmt" |
||||
|
) |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-11-26 14:04:11 |
||||
|
@ 功能: 设置权限Redis |
||||
|
*/ |
||||
|
func SetupPowerInfo(userKey int64, powerInfo string) { |
||||
|
redisFileKey := fmt.Sprintf("SystemPower:AllPower_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, userKey) |
||||
|
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS4) |
||||
|
redisClient.SetRedisTime(86400) |
||||
|
redisClient.Set(redisFileKey, powerInfo) |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-11-26 14:08:15 |
||||
|
@ 功能: 获取权限 |
||||
|
*/ |
||||
|
func GetSystemPowerInfo(userKey int64) (powerInfo SendAllPower) { |
||||
|
redisFileKey := fmt.Sprintf("SystemPower:AllPower_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, userKey) |
||||
|
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS4) |
||||
|
isTrue, powerStr := redisClient.Get(redisFileKey) |
||||
|
if isTrue { |
||||
|
json.Unmarshal([]byte(powerStr), &powerInfo) |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-11-27 15:21:00 |
||||
|
@ 功能: 获取我的菜单权限 |
||||
|
*/ |
||||
|
func GetMyMenuPower(userKey int64, menuId string) (menuPower SystemInfoPower) { |
||||
|
myPower := GetSystemPowerInfo(userKey) |
||||
|
for _, v := range myPower.SystemPower { |
||||
|
if v.AppId == menuId { |
||||
|
menuPower = v |
||||
|
} |
||||
|
} |
||||
|
return |
||||
|
} |
||||
@ -1,6 +1,7 @@ |
|||||
package publicmethod |
package publicmethod |
||||
|
|
||||
//自定义表单量化类型
|
//自定义表单量化类型
|
||||
var Dimension = []string{"input", "textarea", "datePicker", "timePicker", "organization", "tinymce", "colorPicker", "treeSelect", "serialNumber", "expand-user", "orgCentent", "founder", "founderTime", "editTime", "owner", "deptOrg", "pickpost", "pickrole", "radio", "checkbox"} //维度字段
|
var Dimension = []string{"input", "textarea", "select", "datePicker", "timePicker", "organization", "tinymce", "colorPicker", "treeSelect", "serialNumber", "expand-user", "orgCentent", "founder", "founderTime", "editTime", "owner", "deptOrg", "pickpost", "pickrole", "radio", "checkbox"} //维度字段
|
||||
var Quantization = []string{"digitpage", "select", "cascader", "switch", "inputNumber", "slider", "rate"} //可量化字段
|
var Quantization = []string{"digitpage", "select", "cascader", "switch", "inputNumber", "slider", "rate"} //可量化字段
|
||||
var TimeUint = []string{"founderTime", "editTime", "timePicker", "datePicker"} //时间
|
var TimeUint = []string{"founderTime", "editTime", "timePicker", "datePicker"} //时间
|
||||
|
var SunXuColor = []string{"#FF0000", "#00FF00", "#0000FF", "#FFFF00", "#00FFFF", "#FF00FF", "#808080", "#A52A2A", "#FFD700", "#FFA500", "#800080", "#FFC0CB", "#00008B", "#006400", "#8B0000", "#ADD8E6", "#90EE90", "#FFA07A", "#808000", "#4B0082", "#C0C0C0", "#008B8B", "#B22222", "#FF7F50", "#9370DB", "#E6E6FA", "#20B2AA", "#DAA520", "#0000CD", "#c289f8ff", "#2E8B57", "#4682B4", "#FF1493", "#FAF0E6", "#B8860B", "#FF6347", "#8A2BE2", "#A9A9A9", "#000000"} |
||||
|
|||||
@ -0,0 +1,6 @@ |
|||||
|
{ |
||||
|
"devDependencies": { |
||||
|
"unplugin-vue-components": "^29.1.0", |
||||
|
"unplugin-auto-import": "^20.2.0" |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue