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

172 lines
8.5 KiB

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
}