diff --git a/api/base/loginVerify/login.go b/api/base/loginVerify/login.go index 329622f..0b83596 100644 --- a/api/base/loginVerify/login.go +++ b/api/base/loginVerify/login.go @@ -34,8 +34,9 @@ func (a *ApiMethod) ScanCodeLogin(c *gin.Context) { // return // } - userAgent := c.Request.Header.Get("User-Agent") // 获取用户代理 + // userAgent := c.Request.Header.Get("User-Agent") // 获取用户代理 // userAgent = "250" + userAgent := overall.CONSTANT_CONFIG.Appsetup.AppKey var md5JiaMiPwd publicmethod.Md5Encryption md5JiaMiPwd.Md5EncryptionInit(requestData.Password) @@ -68,17 +69,20 @@ func (a *ApiMethod) ScanCodeLogin(c *gin.Context) { uuIdVal := publicmethod.GetUUid(3) uuIdValStr := strconv.FormatInt(uuIdVal, 10) - + fmt.Printf("%v\n", uuIdValStr) var md5JiaMi publicmethod.Md5Encryption md5JiaMi.Md5EncryptionInit(userAgent) md5Token := md5JiaMi.Md5EncryptionAlgorithm() var md5JiaMiNumber publicmethod.Md5Encryption - md5JiaMiNumber.Md5EncryptionInit(userCont.Number + uuIdValStr) + // md5JiaMiNumber.Md5EncryptionInit(userCont.Number + uuIdValStr) + md5JiaMiNumber.Md5EncryptionInit(userCont.Number) userKeyCode := md5JiaMiNumber.Md5EncryptionAlgorithm() - sha1Str := userKeyCode + userCont.Number + userCont.Password + md5Token + uuIdValStr + // sha1Str := userKeyCode + userCont.Number + userCont.Password + md5Token + uuIdValStr + sha1Str := userKeyCode + userCont.Number + userCont.Password + md5Token sha1Token := publicmethod.Sha1Encryption(sha1Str) + fmt.Printf("token=========>\n%v\n---->%v\n---->%v\n---->%v\n---->%v\n---->%v\n", userKeyCode, userCont.Number, userCont.Password, md5Token, sha1Token, userAgent) //返回值 saveData := publicmethod.MapOut[string]() @@ -153,8 +157,19 @@ func (a *ApiMethod) ScanCodeLogin(c *gin.Context) { 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 // fmt.Printf("redisMyContKey------Login----->%v\n", redisMyContKey) publicmethod.Result(0, saveData, c) } @@ -217,8 +232,9 @@ func (a *ApiMethod) ScanCodeLoginNotVerify(c *gin.Context) { // return // } - userAgent := c.Request.Header.Get("User-Agent") // 获取用户代理 + // userAgent := c.Request.Header.Get("User-Agent") // 获取用户代理 // userAgent = "250" + userAgent := overall.CONSTANT_CONFIG.Appsetup.AppKey var md5JiaMiPwd publicmethod.Md5Encryption md5JiaMiPwd.Md5EncryptionInit(requestData.Password) diff --git a/api/base/loginVerify/type.go b/api/base/loginVerify/type.go index 531d3cd..7e82742 100644 --- a/api/base/loginVerify/type.go +++ b/api/base/loginVerify/type.go @@ -36,3 +36,8 @@ type OldSchollAdmin struct { modelsschool.SystemUser modelsschool.SystemUserAttribute } + +// 验证授权 +type VerifyEmpowerKey struct { + UserKey string `json:"userKey"` +} diff --git a/api/base/loginVerify/verifyCode.go b/api/base/loginVerify/verifyCode.go index d3778a5..bad7e26 100644 --- a/api/base/loginVerify/verifyCode.go +++ b/api/base/loginVerify/verifyCode.go @@ -44,3 +44,25 @@ func (a *ApiMethod) VerifyEmpower(c *gin.Context) { } publicmethod.Result(0, userRedisToken, c) } + +// 验证授权是否过期 +func (a *ApiMethod) VerifyEmpowerIsTrue(c *gin.Context) { + var requestData VerifyEmpowerKey + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.UserKey == "" { + publicmethod.Result(9001, requestData, c, "未获得授权信息!") + return + } + redisFileKey := fmt.Sprintf("ScanCode:Authentication:LoginApi_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, requestData.UserKey) + redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS5) + userRedisToken, isTrue := redisClient.HashGetAll(redisFileKey) + if isTrue == false { + publicmethod.Result(9002, requestData, c, "授权超时!") + return + } + publicmethod.Result(0, userRedisToken, c) +} diff --git a/api/version1/flowchart/flow.go b/api/version1/flowchart/flow.go index 3f497fb..fac89c5 100644 --- a/api/version1/flowchart/flow.go +++ b/api/version1/flowchart/flow.go @@ -166,10 +166,10 @@ func GetApproveUser(wechat, workWechat string) (userCont publicmethod.UserListFl var myCont modelshr.PersonArchives err := overall.CONSTANT_DB_HR.Where("`wechat` = ? OR `work_wechat` = ?", openId, openId).First(&myCont).Error if err == nil { - userCont.Id = strconv.FormatInt(myCont.Id, 10) //操作人ID - userCont.Name = myCont.Name //操作人姓名 - userCont.Icon = myCont.Icon //操作人头像 - userCont.Wechat = wechat //微信Openid + userCont.Id = strconv.FormatInt(myCont.Key, 10) //操作人ID + userCont.Name = myCont.Name //操作人姓名 + userCont.Icon = myCont.Icon //操作人头像 + userCont.Wechat = wechat //微信Openid if workWechat != "" { userCont.Wechat = workWechat } @@ -396,3 +396,34 @@ func SetUpWorkFlow(founderWechat string, founderDepartment int64, reviewFlowPara flowMap = append(flowMap, stepCopy) return } + +/* +* +@ 作者: 秦东 +@ 时间: 2022-10-15 08:46:33 +@ 功能: 获取节点操作人列表 +@ 参数 + + #flowMap 流程结构体 + #step 第几步 + +@ 返回值 + + #userKey 操作人key + #UserList 操作人列表 +*/ +func GetNodeOperator(flowMap []publicmethod.FlowChartList, step int) (userKey []string, UserList []publicmethod.UserListFlowAll) { + for _, v := range flowMap { + if v.Step == step { + UserList = v.UserList + if step > 0 { + for _, uv := range v.UserList { + if publicmethod.IsInTrue[string](uv.Id, userKey) == false { + userKey = append(userKey, uv.Id) + } + } + } + } + } + return +} diff --git a/api/version1/postseting/postweb/postration.go b/api/version1/postseting/postweb/postration.go index f75ff7b..e7c5f2b 100644 --- a/api/version1/postseting/postweb/postration.go +++ b/api/version1/postseting/postweb/postration.go @@ -224,8 +224,12 @@ func (a *ApiMethod) SubmitRationPostCont(c *gin.Context) { reviewFlowCont.PeopleList = append(reviewFlowCont.PeopleList, receivedValue.PersonLiable) flowMap, _ := flowchart.SetUpWorkFlow(wechatOpenId, context.MainDeparment, reviewFlowCont, 1) + var flowParticipants []string //流程参与人 + userKeyStr := strconv.FormatInt(context.Key, 10) + flowParticipants = append(flowParticipants, userKeyStr) var sendUserList []string var sendTitle string + var operatorKey []string //获取下一个节点审批人 for _, v := range flowMap { if v.Step == 2 { @@ -235,6 +239,12 @@ func (a *ApiMethod) SubmitRationPostCont(c *gin.Context) { if publicmethod.IsInTrue[string](vu.Wechat, sendUserList) == false { sendUserList = append(sendUserList, vu.Wechat) } + if publicmethod.IsInTrue[string](vu.Id, operatorKey) == false { + operatorKey = append(operatorKey, vu.Id) + } + if publicmethod.IsInTrue[string](vu.Id, flowParticipants) == false { + flowParticipants = append(flowParticipants, vu.Id) + } } } @@ -245,6 +255,7 @@ func (a *ApiMethod) SubmitRationPostCont(c *gin.Context) { flowCont.OrderId = uuId //审批单ID"` flowCont.Step = 1 //当前执行到第几步"` flowCont.NextStep = 2 //下一步执行哪个步骤"` + flowCont.NextExecutor = strings.Join(operatorKey, ",") sumStep := len(flowMap) if sumStep-1 > 0 { sumStep = sumStep - 1 @@ -268,6 +279,7 @@ func (a *ApiMethod) SubmitRationPostCont(c *gin.Context) { flowCont.State = 3 //流程状态 1:草稿;2:驳回;3:审批中;4:归档;5:废弃;6:删除"` flowCont.StartTime = addTime //流程开始时间"` flowCont.Time = addTime //时间"` + flowCont.Participants = strings.Join(flowParticipants, ",") if len(receivedValue.Enclosure) > 0 { jsonFileList, _ := json.Marshal(receivedValue.Enclosure) flowCont.EnclosureFormat = string(jsonFileList) //附件"` diff --git a/api/version1/postseting/postweb/posttarget.go b/api/version1/postseting/postweb/posttarget.go index e9bc607..aba02ec 100644 --- a/api/version1/postseting/postweb/posttarget.go +++ b/api/version1/postseting/postweb/posttarget.go @@ -598,8 +598,12 @@ func (a *ApiMethod) SendUsNatureEvaluation(c *gin.Context) { reviewFlowCont.PeopleList = append(reviewFlowCont.PeopleList, receivedValue.UserKey) flowMap, _ := flowchart.SetUpWorkFlow(wechatOpenId, context.MainDeparment, reviewFlowCont, 1) + var flowParticipants []string //流程参与人 + userKeyStr := strconv.FormatInt(context.Key, 10) + flowParticipants = append(flowParticipants, userKeyStr) var sendUserList []string //审批人列表 var sendTitle string //标题 + var operatorKey []string //下一步执行人 //获取下一个节点审批人 for _, v := range flowMap { if v.Step == 2 { @@ -609,6 +613,12 @@ func (a *ApiMethod) SendUsNatureEvaluation(c *gin.Context) { if publicmethod.IsInTrue[string](vu.Wechat, sendUserList) == false { sendUserList = append(sendUserList, vu.Wechat) } + if publicmethod.IsInTrue[string](vu.Id, operatorKey) == false { + operatorKey = append(operatorKey, vu.Id) + } + if publicmethod.IsInTrue[string](vu.Id, flowParticipants) == false { + flowParticipants = append(flowParticipants, vu.Id) + } } } @@ -618,6 +628,7 @@ func (a *ApiMethod) SendUsNatureEvaluation(c *gin.Context) { flowCont.OrderId = uuId //审批单ID"` flowCont.Step = 1 //当前执行到第几步"` flowCont.NextStep = 2 //下一步执行哪个步骤"` + flowCont.NextExecutor = strings.Join(operatorKey, ",") sumStep := len(flowMap) if sumStep-1 > 0 { sumStep = sumStep - 1 @@ -641,6 +652,7 @@ func (a *ApiMethod) SendUsNatureEvaluation(c *gin.Context) { flowCont.State = 3 //流程状态 1:草稿;2:驳回;3:审批中;4:归档;5:废弃;6:删除"` flowCont.StartTime = time.Now().Unix() //流程开始时间"` flowCont.Time = time.Now().Unix() //时间"` + flowCont.Participants = strings.Join(flowParticipants, ",") if len(receivedValue.Enclosure) > 0 { jsonFileList, _ := json.Marshal(receivedValue.Enclosure) flowCont.EnclosureFormat = string(jsonFileList) //附件"` @@ -1042,7 +1054,7 @@ func (a *ApiMethod) PostRectificationMeasures(c *gin.Context) { } //更新审批流状态 syncSeting.Add(1) - go UpdateStateFlow(pwoCont.Id, nextStep, flowState) + go UpdateStateFlow(pwoCont.Id, nextStep, flowState, flowMap) //更新审批工作流json内容 wechatName := context.Wechat if context.WorkWechat != "" { @@ -1143,8 +1155,11 @@ func ApproveFlow(systemApp string, flowMap []publicmethod.FlowChartList, flowOne nextStep = flowOneCont.Step + 1 } //更新审批流状态 - var pwoCont modelskpi.PostWorkflowOrders - pwoCont.EiteCont(map[string]interface{}{"`order_id`": pwoContOld.OrderId}, map[string]interface{}{"`next_step`": nextStep, "`state`": flowState, "`time`": time.Now().Unix()}) //改变审批流状态 + + // var pwoCont modelskpi.PostWorkflowOrders + // pwoCont.EiteCont(map[string]interface{}{"`order_id`": pwoContOld.OrderId}, map[string]interface{}{"`next_step`": nextStep, "`state`": flowState, "`time`": time.Now().Unix()}) //改变审批流状态 + syncSeting.Add(1) + go UpdateStateFlow(pwoContOld.Id, nextStep, flowState, flowMap) //获取下一部操作 for _, fv := range flowMap { @@ -1495,6 +1510,7 @@ func ApproveFlow(systemApp string, flowMap []publicmethod.FlowChartList, flowOne } } + syncSeting.Wait() } /* @@ -1567,13 +1583,38 @@ func EidtPostFlowLog(pwoId int64, flowMap []publicmethod.FlowChartList, oneFlowC #pwoId 审批流ID #nextStep 下一步 #flowState 流程状态 + #flowMap 流程结构体 @ 返回值 # */ -func UpdateStateFlow(pwoId int64, nextStep, flowState int) { +func UpdateStateFlow(pwoId int64, nextStep, flowState int, flowMap []publicmethod.FlowChartList) { defer syncSeting.Done() + var flowParticipants []string //流程参与人 + //获取参与者 + var pwoContInfo modelskpi.PostWorkflowOrders + errPwo := pwoContInfo.GetCont(map[string]interface{}{"`id`": pwoId}, "'participants'") + if errPwo == nil { + powPartAry := strings.Split(pwoContInfo.Participants, ",") + for _, vu := range powPartAry { + if publicmethod.IsInTrue[string](vu, flowParticipants) == false { + flowParticipants = append(flowParticipants, vu) + } + } + + } + nextUserKey, _ := flowchart.GetNodeOperator(flowMap, nextStep) + for _, vuk := range nextUserKey { + if publicmethod.IsInTrue[string](vuk, flowParticipants) == false { + flowParticipants = append(flowParticipants, vuk) + } + } + nextUserKeyStr := strings.Join(nextUserKey, ",") + if nextStep == 0 { + nextUserKeyStr = "" + } + flowUserKey := strings.Join(flowParticipants, ",") var pwoCont modelskpi.PostWorkflowOrders - pwoCont.EiteCont(map[string]interface{}{"`id`": pwoId}, map[string]interface{}{"`next_step`": nextStep, "`state`": flowState, "`time`": time.Now().Unix()}) //改变审批流状态 + pwoCont.EiteCont(map[string]interface{}{"`id`": pwoId}, map[string]interface{}{"`next_step`": nextStep, "`state`": flowState, "'next_executor'": nextUserKeyStr, "`participants`": flowUserKey, "`time`": time.Now().Unix()}) //改变审批流状态 } diff --git a/apirouter/verifyLogin/route.go b/apirouter/verifyLogin/route.go index 62d8418..88eba51 100644 --- a/apirouter/verifyLogin/route.go +++ b/apirouter/verifyLogin/route.go @@ -19,5 +19,7 @@ func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) { apiRouter.POST("signout", methodBinding.SignOut) //退出登录 apiRouter.POST("verify_empower", methodBinding.VerifyEmpower) //验证授权是否还有效 apiRouter.POST("login_not_verify", methodBinding.ScanCodeLoginNotVerify) //登录(无验证码) + + apiRouter.POST("verify_empower_istrue", methodBinding.VerifyEmpowerIsTrue) //验证授权是否过期 } } diff --git a/identification/interceptor/identity.go b/identification/interceptor/identity.go index 7ef0d2e..d443b06 100644 --- a/identification/interceptor/identity.go +++ b/identification/interceptor/identity.go @@ -16,6 +16,7 @@ func AuthenticateUser() gin.HandlerFunc { userKey := c.Request.Header.Get("user-key") userToken := c.Request.Header.Get("user-token") userAgent := c.Request.Header.Get("User-Agent") + userAgent = overall.CONSTANT_CONFIG.Appsetup.AppKey // fmt.Printf("userKey---------->%v----------userToken---------->%v--------userAgent---------->%v\n", userKey, userToken, userAgent) if userKey == "" || userToken == "" || userAgent == "" { response.FailWithDetailed(gin.H{"reload": false, "code": 300}, "未登录或非法访问", c) diff --git a/middleware/wechatapp/wechatcallback/event_processing.go b/middleware/wechatapp/wechatcallback/event_processing.go index a46f8e9..ba91136 100644 --- a/middleware/wechatapp/wechatcallback/event_processing.go +++ b/middleware/wechatapp/wechatcallback/event_processing.go @@ -4,6 +4,7 @@ import ( "encoding/json" "encoding/xml" "fmt" + "key_performance_indicators/api/version1/flowchart" "key_performance_indicators/middleware/wechatapp/wechatsendmsg" "key_performance_indicators/middleware/wechatapp/wechatstatice" "key_performance_indicators/models/modelshr" @@ -412,7 +413,23 @@ func (U *updateButtonSync) RejectFlow(systemApp string, flowMap []publicmethod.F nextStep := rejectNode.Step + 1 var pwoCont modelskpi.PostWorkflowOrders - pwoCont.EiteCont(map[string]interface{}{"`order_id`": pwoContOld.OrderId}, map[string]interface{}{"`next_step`": nextStep, "`state`": flowState, "`time`": time.Now().Unix()}) //改变审批流状态 + nextUserKey, _ := flowchart.GetNodeOperator(flowMap, nextStep) + nextUserKeyStr := strings.Join(nextUserKey, ",") + if nextStep == 0 { + nextUserKeyStr = "" + } + + // pwoCont.EiteCont(map[string]interface{}{"`order_id`": pwoContOld.OrderId}, map[string]interface{}{"`next_step`": nextStep, "`state`": flowState, "'next_executor'": nextUserKeyStr, "`time`": time.Now().Unix()}) //改变审批流状态 + + flowParticipants := strings.Split(pwoContOld.Participants, ",") + for _, vuk := range nextUserKey { + if publicmethod.IsInTrue[string](vuk, flowParticipants) == false { + flowParticipants = append(flowParticipants, vuk) + } + } + flowParticipantStr := strings.Join(flowParticipants, ",") + + pwoCont.EiteCont(map[string]interface{}{"`order_id`": pwoContOld.OrderId}, map[string]interface{}{"`next_step`": nextStep, "`state`": flowState, "'next_executor'": nextUserKeyStr, "`participants`": flowParticipantStr, "`time`": time.Now().Unix()}) //改变审批流状态 //发送同通信息 SendNoticeMsg(sendToUserList, markDowmStr, systemApp) } @@ -483,7 +500,21 @@ func (U *updateButtonSync) ApproveFlow(systemApp string, flowMap []publicmethod. } //更新审批流状态 var pwoCont modelskpi.PostWorkflowOrders - pwoCont.EiteCont(map[string]interface{}{"`order_id`": pwoContOld.OrderId}, map[string]interface{}{"`next_step`": nextStep, "`state`": flowState, "`time`": time.Now().Unix()}) //改变审批流状态 + nextUserKey, _ := flowchart.GetNodeOperator(flowMap, nextStep) + nextUserKeyStr := strings.Join(nextUserKey, ",") + if nextStep == 0 { + nextUserKeyStr = "" + } + + flowParticipants := strings.Split(pwoContOld.Participants, ",") + for _, vuk := range nextUserKey { + if publicmethod.IsInTrue[string](vuk, flowParticipants) == false { + flowParticipants = append(flowParticipants, vuk) + } + } + flowParticipantStr := strings.Join(flowParticipants, ",") + + pwoCont.EiteCont(map[string]interface{}{"`order_id`": pwoContOld.OrderId}, map[string]interface{}{"`next_step`": nextStep, "`state`": flowState, "'next_executor'": nextUserKeyStr, "`participants`": flowParticipantStr, "`time`": time.Now().Unix()}) //改变审批流状态 //获取下一部操作 for _, fv := range flowMap { diff --git a/models/modelskpi/post_workflow_orders.go b/models/modelskpi/post_workflow_orders.go index ea107d2..375d2b1 100644 --- a/models/modelskpi/post_workflow_orders.go +++ b/models/modelskpi/post_workflow_orders.go @@ -11,6 +11,7 @@ type PostWorkflowOrders struct { OrderId int64 `json:"orderid" gorm:"column:order_id;type:bigint(20) unsigned;default:0;not null;comment:审批单ID"` Step int `json:"step" gorm:"column:step;type:int(5) unsigned;default:0;not null;comment:当前执行到第几步"` NextStep int `json:"nextstep" gorm:"column:next_step;type:int(5) unsigned;default:0;not null;comment:下一步执行哪个步骤"` + NextExecutor string `json:"nextexecutor" gorm:"column:next_executor;type:longtext;comment:下一步执行人"` CountStep int `json:"countstep" gorm:"column:count_step;type:int(5) unsigned;default:0;not null;comment:总共几步"` WorkFlow string `json:"workflow" gorm:"column:work_flow;type:longtext;comment:工作流(审批json字符串)"` CompanyId int64 `json:"companyid" gorm:"column:company_id;type:bigint(20) unsigned;default:0;not null;comment:公司"` @@ -28,6 +29,7 @@ type PostWorkflowOrders struct { StartTime int64 `json:"starttime" gorm:"column:start_time;type:bigint(20) unsigned;default:0;not null;comment:流程开始时间"` Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:时间"` EnclosureFormat string `json:"enclosureformat" gorm:"column:enclosure_format;type:longtext;comment:附件"` + Participants string `json:"participants" gorm:"column:participants;type:longtext;comment:流程参与人"` } func (PostWorkflowOrders *PostWorkflowOrders) TableName() string {