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.
608 lines
23 KiB
608 lines
23 KiB
package custom
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"strconv"
|
|
|
|
"gin_server_admin/api/admin/systemuser"
|
|
"gin_server_admin/api/v1/staff"
|
|
"gin_server_admin/commonus"
|
|
"gin_server_admin/global"
|
|
"gin_server_admin/model/common/response"
|
|
"gin_server_admin/model/hrsystem"
|
|
systemReq "gin_server_admin/model/system/request"
|
|
roleModel "gin_server_admin/model/systemuser"
|
|
"gin_server_admin/utils"
|
|
"gin_server_admin/utils/redishandel"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// 自定义登录
|
|
func (cu *CustomHandle) CustomLogin(c *gin.Context) {
|
|
var l systemReq.Login
|
|
_ = c.ShouldBindJSON(&l)
|
|
// if err := utils.Verify(l, utils.LoginVerify); err != nil {
|
|
// response.FailWithMessage(err.Error(), c)
|
|
// return
|
|
// }
|
|
userAgent := c.Request.Header.Get("User-Agent")
|
|
// userAgent = "250"
|
|
userAgent = global.GVA_CONFIG.MyConfig.AppKey
|
|
// store
|
|
// if store.Verify(l.CaptchaId, l.Captcha, true) {
|
|
userErr, user := staff.GetUserWork(l.Username, l.Password)
|
|
if userErr != true {
|
|
// // global.GVA_LOG.Error("登陆失败! 用户名不存在或者密码错误!", zap.Any("err", err))
|
|
response.Result(101, userErr, "登陆失败! 用户名不存在或者密码错误!!", c)
|
|
return
|
|
} else {
|
|
if user.State == 2 {
|
|
response.Result(102, userErr, "登陆失败! 该账号已经被禁用!", c)
|
|
return
|
|
}
|
|
if user.State == 3 {
|
|
response.Result(102, userErr, "登陆失败! 该账号不存在!", c)
|
|
return
|
|
}
|
|
if user.HireSet != 1 {
|
|
response.Result(102, userErr, "登陆失败! 该员工已经离职!", c)
|
|
return
|
|
}
|
|
var md5JiaMi commonus.Md5Encryption
|
|
md5JiaMi.Md5EncryptionInit(userAgent)
|
|
md5Token := md5JiaMi.Md5EncryptionAlgorithm()
|
|
|
|
sha1Str := user.KeyStr + user.Number + user.Password + md5Token
|
|
sha1Token := commonus.Sha1Encryption(sha1Str)
|
|
|
|
saveData := commonus.MapOut()
|
|
saveData["key"] = user.KeyStr
|
|
saveData["token"] = sha1Token
|
|
saveData["userinfo"] = user
|
|
|
|
redisClient := redishandel.RunRedis()
|
|
redisClient.SetRedisTime(86400)
|
|
// redisClient.SetRedisTime(60)
|
|
writeRedisData := map[string]interface{}{
|
|
"userkey": user.KeyStr,
|
|
"usernumber": user.Number,
|
|
"userpwd": user.Password,
|
|
"usertoken": sha1Token,
|
|
}
|
|
|
|
// global.GVA_INDEX_USERKEY = user.Key
|
|
|
|
redisClient.HashMsetAdd("system:Identification_"+global.GVA_CONFIG.RedisPrefix.Alias+"_"+user.KeyStr, writeRedisData)
|
|
|
|
userInfo := commonus.MapOut()
|
|
userInfo["id"] = user.Id
|
|
userInfo["number"] = user.Number
|
|
userInfo["departmentid"] = user.DepartmentId
|
|
userInfo["workshopid"] = user.WorkshopId
|
|
userInfo["postid"] = user.PostId
|
|
userInfo["key"] = user.Key
|
|
userInfo["group"] = user.Group
|
|
userInfo["tema"] = user.Tema
|
|
userInfo["workwechatid"] = user.WorkWechatId
|
|
userInfo["wechatid"] = user.WechatId
|
|
userInfo["name"] = user.Name
|
|
userInfo["nickname"] = user.NickName
|
|
|
|
redisUserClient := redishandel.RunRedis()
|
|
redisUserClient.SetRedisTime(0)
|
|
redisUserClient.HashMsetAdd("system:userContent_"+global.GVA_CONFIG.RedisPrefix.Alias+"_"+user.KeyStr, userInfo)
|
|
// // b.tokenNext(c, *user)
|
|
response.Result(0, saveData, "登录成功!", c)
|
|
}
|
|
// } else {
|
|
// response.FailWithMessage("验证码错误", c)
|
|
// }
|
|
}
|
|
|
|
// 自定义登录
|
|
func (cu *CustomHandle) SystemLogin(c *gin.Context) {
|
|
var l systemReq.Login
|
|
_ = c.ShouldBindJSON(&l)
|
|
if err := utils.Verify(l, utils.LoginVerify); err != nil {
|
|
response.FailWithMessage(err.Error(), c)
|
|
return
|
|
}
|
|
userAgent := c.Request.Header.Get("User-Agent")
|
|
// store
|
|
// if store.Verify(l.CaptchaId, l.Captcha, true) {
|
|
userErr, user := systemuser.GetSysAdminLoginInfo(l.Username, l.Password)
|
|
if userErr != true {
|
|
// // global.GVA_LOG.Error("登陆失败! 用户名不存在或者密码错误!", zap.Any("err", err))
|
|
response.Result(101, userErr, "登陆失败! 用户名不存在或者密码错误!!", c)
|
|
return
|
|
} else {
|
|
if user.State == 2 {
|
|
response.Result(102, userErr, "登陆失败! 该账号已经被禁用!", c)
|
|
return
|
|
}
|
|
if user.State == 3 {
|
|
response.Result(102, userErr, "登陆失败! 该账号不存在!", c)
|
|
return
|
|
}
|
|
var md5JiaMi commonus.Md5Encryption
|
|
md5JiaMi.Md5EncryptionInit(userAgent)
|
|
md5Token := md5JiaMi.Md5EncryptionAlgorithm()
|
|
|
|
sha1Str := user.KeyStr + user.Name + user.PassWord + md5Token
|
|
sha1Token := commonus.Sha1Encryption(sha1Str)
|
|
|
|
saveData := commonus.MapOut()
|
|
saveData["key"] = user.KeyStr
|
|
saveData["token"] = sha1Token
|
|
saveData["userinfo"] = user
|
|
|
|
redisClient := redishandel.RunRedis()
|
|
redisClient.SetRedisTime(86400)
|
|
writeRedisData := map[string]interface{}{
|
|
"userkey": user.KeyStr,
|
|
"usernumber": user.Name,
|
|
"userpwd": user.PassWord,
|
|
"usertoken": sha1Token,
|
|
"jurisdiction": user.Jurisdiction,
|
|
"menuOper": user.MenuOper,
|
|
"wand": user.Wand,
|
|
}
|
|
redisClient.HashMsetAdd("system:SystemIdentification_"+global.GVA_CONFIG.RedisPrefix.Alias+"_"+user.KeyStr, writeRedisData)
|
|
|
|
adminRedisData := map[string]interface{}{
|
|
"userkey": user.KeyStr,
|
|
"usernumber": user.Name,
|
|
"userpwd": user.PassWord,
|
|
"usertoken": sha1Token,
|
|
"jurisdiction": user.Jurisdiction,
|
|
"menuOper": user.MenuOper,
|
|
"wand": user.Wand,
|
|
"name": user.NameAttr,
|
|
"groupname": user.GroupName,
|
|
"group": user.Group,
|
|
"attribute": user.Attribute,
|
|
"branchfactoryname": user.BranchFactoryName,
|
|
"role": user.Role,
|
|
"roleName": user.RoleName,
|
|
}
|
|
redisAdminClient := redishandel.RunRedis()
|
|
redisAdminClient.SetRedisTime(0)
|
|
redisAdminClient.HashMsetAdd("system:SystemAdminInfo_"+global.GVA_CONFIG.RedisPrefix.Alias+"_"+user.KeyStr, adminRedisData)
|
|
|
|
global.GVA_ADMIN_USERKEY = strconv.FormatInt(user.Key, 10)
|
|
// // b.tokenNext(c, *user)
|
|
var surisdictionStr []string
|
|
var surisdictionInt []int64
|
|
jsonErr := json.Unmarshal([]byte(user.Jurisdiction), &surisdictionStr)
|
|
if jsonErr == nil {
|
|
for _, jurVal := range surisdictionStr {
|
|
jurValInt, jurValErr := strconv.ParseInt(jurVal, 10, 64)
|
|
if jurValErr == nil {
|
|
surisdictionInt = append(surisdictionInt, jurValInt)
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
global.Gva_Authority_Authentication = surisdictionInt
|
|
var menuOperStr []string
|
|
var menuOperInts []int64
|
|
jsonErrSun := json.Unmarshal([]byte(user.MenuOper), &menuOperStr)
|
|
if jsonErrSun == nil {
|
|
for _, menuOperVal := range menuOperStr {
|
|
menuOperInt, menuOperErr := strconv.ParseInt(menuOperVal, 10, 64)
|
|
if menuOperErr == nil {
|
|
menuOperInts = append(menuOperInts, menuOperInt)
|
|
}
|
|
|
|
}
|
|
}
|
|
global.Gva_Authority_Authentication_Subsidiary = menuOperInts
|
|
saveData["Jurisdiction"] = global.Gva_Authority_Authentication
|
|
saveData["MenuOper"] = global.Gva_Authority_Authentication_Subsidiary
|
|
|
|
// saveData["jsonErr"] = jsonErr
|
|
// saveData["jsonErrSun"] = jsonErrSun
|
|
|
|
response.Result(0, saveData, "登录成功!", c)
|
|
}
|
|
// } else {
|
|
// response.FailWithMessage("验证码错误", c)
|
|
// }
|
|
}
|
|
|
|
// oauth2.0
|
|
func (cu *CustomHandle) OauthTwo(c *gin.Context) {
|
|
var requestData getData
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
response.Result(101, err, "单点登录登录失败!", c)
|
|
return
|
|
}
|
|
if requestData.Number == "" {
|
|
response.Result(102, err, "单点登录登录失败!", c)
|
|
return
|
|
}
|
|
redisClient := redishandel.RunRedis()
|
|
tokenErr, token := redisClient.Get("system:Oauth2_" + global.GVA_CONFIG.RedisPrefix.Alias + "_" + requestData.Number)
|
|
if tokenErr == true {
|
|
saveData := commonus.MapOut()
|
|
saveData["token"] = token
|
|
response.Result(0, saveData, "登录成功!", c)
|
|
} else {
|
|
userAgent := c.Request.Header.Get("User-Agent")
|
|
var md5JiaMi commonus.Md5Encryption
|
|
md5JiaMi.Md5EncryptionInit(userAgent)
|
|
md5Token := md5JiaMi.Md5EncryptionAlgorithm()
|
|
|
|
var md5Number commonus.Md5Encryption
|
|
md5Number.Md5EncryptionInit(requestData.Number)
|
|
md5NumberToken := md5Number.Md5EncryptionAlgorithm()
|
|
|
|
sha1Str := fmt.Sprintf("%v-%v-%v", md5Token, requestData.Number, md5NumberToken)
|
|
sha1Token := commonus.Sha1Encryption(sha1Str)
|
|
|
|
saveData := commonus.MapOut()
|
|
saveData["token"] = sha1Token
|
|
redisClient.SetRedisTime(10800)
|
|
redisClient.Set("system:Oauth2_"+global.GVA_CONFIG.RedisPrefix.Alias+"_"+requestData.Number, sha1Token)
|
|
response.Result(0, saveData, "Token获取成功!", c)
|
|
}
|
|
}
|
|
|
|
// 企业微信单点登录
|
|
func (cu *CustomHandle) SingleSignOn(c *gin.Context) {
|
|
var requestData oneLogin
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
response.Result(101, err, "单点登录登录失败!", c)
|
|
return
|
|
}
|
|
if requestData.Number == "" {
|
|
response.Result(102, err, "单点登录登录失败!", c)
|
|
return
|
|
}
|
|
if requestData.Token == "" {
|
|
response.Result(102, err, "单点登录登录失败!", c)
|
|
return
|
|
}
|
|
if requestData.OpenId == "" {
|
|
response.Result(102, err, "单点登录登录失败!", c)
|
|
return
|
|
}
|
|
redisClient := redishandel.RunRedis()
|
|
tokenErr, token := redisClient.Get("system:Oauth2_" + global.GVA_CONFIG.RedisPrefix.Alias + "_" + requestData.Number)
|
|
if tokenErr != true {
|
|
response.Result(103, err, "单点登录登录失败!", c)
|
|
return
|
|
}
|
|
if token != requestData.Token {
|
|
response.Result(103, err, "单点登录登录失败!", c)
|
|
return
|
|
}
|
|
isTrue, userInfo := commonus.GetUesrContForWechatID(requestData.OpenId)
|
|
if isTrue != true {
|
|
response.Result(103, err, "单点登录登录失败!", c)
|
|
return
|
|
}
|
|
|
|
//获取操作人
|
|
userFileStr := "worker_man.*,worker_man_data.*"
|
|
//操作人条件
|
|
userWherAry := commonus.MapOut()
|
|
// userWherAry["wm_key"] = "WoBenShanLiang_3" //"WoBenShanLiang_3"
|
|
userWherAry["wm_key"] = userInfo.Key
|
|
userConting, userIsTrue := commonus.GetUserInfoPublic(userFileStr, userWherAry)
|
|
if userIsTrue != true {
|
|
response.Result(103, err, "单点登录登录失败!", c)
|
|
return
|
|
}
|
|
userAgent := c.Request.Header.Get("User-Agent")
|
|
|
|
var md5JiaMi commonus.Md5Encryption
|
|
md5JiaMi.Md5EncryptionInit(userAgent)
|
|
md5Token := md5JiaMi.Md5EncryptionAlgorithm()
|
|
|
|
sha1Str := fmt.Sprintf("%v%v%v%v", userConting.Key, userConting.Number, userConting.Password, md5Token)
|
|
sha1Token := commonus.Sha1Encryption(sha1Str)
|
|
|
|
saveData := commonus.MapOut()
|
|
saveData["key"] = userConting.Key
|
|
saveData["token"] = sha1Token
|
|
saveData["userinfo"] = userConting
|
|
|
|
writeRedisData := map[string]interface{}{
|
|
"userkey": userInfo.Key,
|
|
"usernumber": userInfo.Number,
|
|
"userpwd": userConting.Password,
|
|
"usertoken": sha1Token,
|
|
}
|
|
redisClient.SetRedisTime(86400)
|
|
redisKey := fmt.Sprintf("system:Identification_%v_%v", global.GVA_CONFIG.RedisPrefix.Alias, userInfo.Key)
|
|
redisClient.HashMsetAdd(redisKey, writeRedisData)
|
|
|
|
userInfoMap := commonus.MapOut()
|
|
userInfoMap["id"] = userConting.Id
|
|
userInfoMap["number"] = userConting.Number
|
|
userInfoMap["departmentid"] = userConting.MainDeparment
|
|
userInfoMap["workshopid"] = userConting.AdminOrg
|
|
userInfoMap["postid"] = userConting.Position
|
|
userInfoMap["key"] = userConting.Key
|
|
userInfoMap["group"] = userConting.Company
|
|
userInfoMap["tema"] = userConting.TeamId
|
|
userInfoMap["workwechatid"] = userConting.WorkWechat
|
|
userInfoMap["wechatid"] = userConting.Wechat
|
|
userInfoMap["name"] = userConting.Name
|
|
userInfoMap["nickname"] = userConting.Name
|
|
|
|
redisUserClient := redishandel.RunRedis()
|
|
redisUserClient.SetRedisTime(0)
|
|
redisKeyMap := fmt.Sprintf("system:userContent_%v_%v", global.GVA_CONFIG.RedisPrefix.Alias, userInfo.Key)
|
|
redisUserClient.HashMsetAdd(redisKeyMap, userInfoMap)
|
|
response.Result(0, saveData, "登录成功!", c)
|
|
}
|
|
|
|
// 一端登录
|
|
func (cu *CustomHandle) ScanCodeLogin(c *gin.Context) {
|
|
var l systemReq.Login
|
|
_ = c.ShouldBindJSON(&l)
|
|
// if err := utils.Verify(l, utils.LoginVerify); err != nil {
|
|
// response.FailWithMessage(err.Error(), c)
|
|
// return
|
|
// }
|
|
userAgent := c.Request.Header.Get("User-Agent")
|
|
// userAgent = "250"
|
|
userAgent = global.GVA_CONFIG.MyConfig.AppKey
|
|
|
|
userAdminErr, userAdmin := systemuser.GetSysAdminLoginInfo(l.Username, l.Password)
|
|
// fmt.Printf("jieguo----------------->%v\n", userAdminErr)
|
|
// userAdminErr, _ := systemuser.HrUserInfor(l.Username, l.Password)
|
|
if userAdminErr == true {
|
|
if userAdmin.State == 2 {
|
|
response.Result(102, userAdminErr, "登陆失败! 该账号已经被禁用!", c)
|
|
return
|
|
}
|
|
if userAdmin.State == 3 {
|
|
response.Result(102, userAdminErr, "登陆失败! 该账号不存在!", c)
|
|
return
|
|
}
|
|
var md5JiaMi commonus.Md5Encryption
|
|
md5JiaMi.Md5EncryptionInit(userAgent)
|
|
md5Token := md5JiaMi.Md5EncryptionAlgorithm()
|
|
|
|
var md5JiaMiNumber commonus.Md5Encryption
|
|
md5JiaMiNumber.Md5EncryptionInit(userAdmin.Name)
|
|
userKeyCode := md5JiaMiNumber.Md5EncryptionAlgorithm()
|
|
|
|
sha1Str := userKeyCode + userAdmin.Name + userAdmin.PassWord + md5Token
|
|
sha1Token := commonus.Sha1Encryption(sha1Str)
|
|
|
|
saveData := commonus.MapOut()
|
|
saveData["key"] = userKeyCode
|
|
saveData["token"] = sha1Token
|
|
saveData["userinfo"] = userAdmin
|
|
|
|
// userKeyInt, _ := strconv.ParseInt(userKeyCode, 10, 64)
|
|
global.GVA_ADMIN_USERKEY = userKeyCode
|
|
global.GVA_SCANCODE_USERNUMBER = userAdmin.KeyStr
|
|
|
|
roleCont := getRole(userAdmin.Role)
|
|
|
|
writeRedisData := map[string]interface{}{
|
|
"userkey": userKeyCode,
|
|
"key": userAdmin.KeyStr,
|
|
"usernumber": userAdmin.Name,
|
|
"userpwd": userAdmin.PassWord,
|
|
"usertoken": sha1Token,
|
|
"jurisdiction": roleCont.Jurisdiction,
|
|
"menuOper": roleCont.MenuOper,
|
|
"wand": 118,
|
|
}
|
|
|
|
var surisdictionStr []string
|
|
var surisdictionInt []int64
|
|
jsonErr := json.Unmarshal([]byte(roleCont.Jurisdiction), &surisdictionStr)
|
|
if jsonErr == nil {
|
|
for _, jurVal := range surisdictionStr {
|
|
jurValInt, jurValErr := strconv.ParseInt(jurVal, 10, 64)
|
|
if jurValErr == nil {
|
|
surisdictionInt = append(surisdictionInt, jurValInt)
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
global.Gva_Authority_Authentication = surisdictionInt
|
|
var menuOperStr []string
|
|
var menuOperInts []int64
|
|
jsonErrSun := json.Unmarshal([]byte(roleCont.MenuOper), &menuOperStr)
|
|
if jsonErrSun == nil {
|
|
for _, menuOperVal := range menuOperStr {
|
|
menuOperInt, menuOperErr := strconv.ParseInt(menuOperVal, 10, 64)
|
|
if menuOperErr == nil {
|
|
menuOperInts = append(menuOperInts, menuOperInt)
|
|
}
|
|
|
|
}
|
|
}
|
|
global.Gva_Authority_Authentication_Subsidiary = menuOperInts
|
|
|
|
redisFileKey := "ScanCode:Authentication:LoginApi_" + global.GVA_CONFIG.RedisPrefix.Alias + "_" + userKeyCode
|
|
redisClient := redishandel.RunRedis()
|
|
redisClient.SetRedisDb(5)
|
|
redisClient.SetRedisTime(10800)
|
|
redisClient.HashMsetAdd(redisFileKey, writeRedisData)
|
|
response.Result(0, saveData, "登录成功!", c)
|
|
} else {
|
|
// userErr, user := staff.GetUserWork(l.Username, l.Password)
|
|
userErr, user := staff.HrUserInfor(l.Username, l.Password)
|
|
if userErr != true {
|
|
response.Result(109, userErr, "登录失败!", c)
|
|
return
|
|
}
|
|
if l.OpenId != "" {
|
|
var sysUserCont hrsystem.PersonArchives
|
|
sysUserCont.EiteCont(map[string]interface{}{"id": user.Id}, map[string]interface{}{"work_wechat": l.OpenId})
|
|
}
|
|
if user.State == 2 {
|
|
response.Result(102, userErr, "登陆失败! 该账号已经被禁用!", c)
|
|
return
|
|
}
|
|
if user.State == 3 {
|
|
response.Result(102, userErr, "登陆失败! 该账号不存在!", c)
|
|
return
|
|
}
|
|
|
|
var md5JiaMi commonus.Md5Encryption
|
|
md5JiaMi.Md5EncryptionInit(userAgent)
|
|
md5Token := md5JiaMi.Md5EncryptionAlgorithm()
|
|
|
|
var md5JiaMiNumber commonus.Md5Encryption
|
|
md5JiaMiNumber.Md5EncryptionInit(user.Number)
|
|
userKeyCode := md5JiaMiNumber.Md5EncryptionAlgorithm()
|
|
|
|
sha1Str := userKeyCode + user.Number + user.Password + md5Token
|
|
sha1Token := commonus.Sha1Encryption(sha1Str)
|
|
|
|
saveData := commonus.MapOut()
|
|
saveData["key"] = userKeyCode
|
|
saveData["token"] = sha1Token
|
|
saveData["userinfo"] = user
|
|
|
|
// userKeyInt, _ := strconv.ParseInt(userKeyCode, 10, 64)
|
|
global.GVA_ADMIN_USERKEY = userKeyCode
|
|
global.GVA_SCANCODE_USERNUMBER = user.Number
|
|
writeRedisData := map[string]interface{}{
|
|
"userkey": userKeyCode,
|
|
"key": user.Key,
|
|
"usernumber": user.Number,
|
|
"userpwd": user.Password,
|
|
"usertoken": sha1Token,
|
|
"jurisdiction": user.Jurisdiction,
|
|
"menuOper": user.Menuoper,
|
|
"wand": 118,
|
|
}
|
|
var surisdictionStr []string
|
|
var surisdictionInt []int64
|
|
jsonErr := json.Unmarshal([]byte(user.Jurisdiction), &surisdictionStr)
|
|
if jsonErr == nil {
|
|
for _, jurVal := range surisdictionStr {
|
|
jurValInt, jurValErr := strconv.ParseInt(jurVal, 10, 64)
|
|
if jurValErr == nil {
|
|
surisdictionInt = append(surisdictionInt, jurValInt)
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
global.Gva_Authority_Authentication = surisdictionInt
|
|
var menuOperStr []string
|
|
var menuOperInts []int64
|
|
jsonErrSun := json.Unmarshal([]byte(user.Menuoper), &menuOperStr)
|
|
if jsonErrSun == nil {
|
|
for _, menuOperVal := range menuOperStr {
|
|
menuOperInt, menuOperErr := strconv.ParseInt(menuOperVal, 10, 64)
|
|
if menuOperErr == nil {
|
|
menuOperInts = append(menuOperInts, menuOperInt)
|
|
}
|
|
|
|
}
|
|
}
|
|
global.Gva_Authority_Authentication_Subsidiary = menuOperInts
|
|
redisFileKey := "ScanCode:Authentication:LoginApi_" + global.GVA_CONFIG.RedisPrefix.Alias + "_" + userKeyCode
|
|
redisClient := redishandel.RunRedis()
|
|
redisClient.SetRedisDb(5)
|
|
redisClient.SetRedisTime(10800)
|
|
redisClient.HashMsetAdd(redisFileKey, writeRedisData)
|
|
// fmt.Printf("Login------->%v---------->%v\n", userKeyCode, md5Token)
|
|
var userCont hrsystem.ManCont
|
|
userErrd := userCont.GetCont(map[string]interface{}{"`id`": user.Id})
|
|
if userErrd != nil {
|
|
response.Result(102, userErr, "登陆失败! 该账号不存在!", c)
|
|
return
|
|
}
|
|
//缓存写入个人信息
|
|
redisMyContKey := fmt.Sprintf("ScanCode:Authentication:UserCont_%v_%v", global.GVA_CONFIG.RedisPrefix.Alias, userCont.Number)
|
|
myCont := commonus.MapOut()
|
|
myCont["id"] = userCont.Id
|
|
myCont["number"] = userCont.Number //员工工号
|
|
myCont["name"] = userCont.Name //姓名
|
|
myCont["icon"] = userCont.Icon //头像
|
|
myCont["hire_class"] = userCont.HireClass //雇佣类型(1:雇佣入职;2:再入职;)
|
|
myCont["emp_type"] = 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["sun_main_department"] = userCont.SunMainDeparment //二级主部门
|
|
myCont["deparment"] = userCont.Deparment //部门
|
|
myCont["admin_org"] = userCont.AdminOrg //所属行政组织
|
|
myCont["teamid"] = userCont.TeamId //班组
|
|
myCont["position"] = userCont.Position //职位
|
|
myCont["job_class"] = userCont.JobClass //职务分类
|
|
myCont["job_id"] = userCont.JobId //职务
|
|
myCont["job_leve"] = userCont.JobLeve //职务等级
|
|
myCont["wechat"] = userCont.Wechat //微信UserId
|
|
myCont["work_wechat"] = userCont.WorkWechat //企业微信UserId
|
|
myCont["state"] = userCont.State //状态(1:启用;2:禁用;3:删除)
|
|
myCont["key"] = userCont.Key //key
|
|
myCont["is_admin"] = 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:中共党员)
|
|
redisClient.HashMsetAdd(redisMyContKey, myCont)
|
|
|
|
response.Result(0, saveData, "登录成功!", c)
|
|
}
|
|
|
|
}
|
|
|
|
// 获取角色信息
|
|
func getRole(roleId int64) (roleCont roleModel.SystemRole) {
|
|
global.GVA_DB_HrDataBase.Where("`id` = ?", roleId).Find(&roleCont)
|
|
return
|
|
}
|
|
|
|
func (cu *CustomHandle) SignOut(c *gin.Context) {
|
|
_, userCont := commonus.ClientIdentity()
|
|
var md5JiaMiNumber commonus.Md5Encryption
|
|
md5JiaMiNumber.Md5EncryptionInit(userCont.Number)
|
|
userKeyCode := md5JiaMiNumber.Md5EncryptionAlgorithm()
|
|
redisFileKey := "ScanCode:Authentication:LoginApi_" + global.GVA_CONFIG.RedisPrefix.Alias + "_" + userKeyCode
|
|
redisClient := redishandel.RunRedis()
|
|
redisClient.SetRedisDb(5)
|
|
one := redisClient.DelKey(redisFileKey)
|
|
redisFileKeyInfo := fmt.Sprintf("ScanCode:UserInfo:LoginUser_%v_%v", global.GVA_CONFIG.RedisPrefix.Alias, userCont.Number)
|
|
two := redisClient.DelKey(redisFileKeyInfo)
|
|
saveData := commonus.MapOut()
|
|
saveData["one"] = one
|
|
saveData["two"] = two
|
|
response.Result(0, saveData, "退出成功!", c)
|
|
}
|
|
|