diff --git a/README.md b/README.md
index 4571083..00017e4 100644
--- a/README.md
+++ b/README.md
@@ -420,4 +420,40 @@ Time:2022-10-24
```
select `pf`.`id` AS `id`,`pf`.`order_id` AS `order_id`,`pf`.`add_or_decrease` AS `add_or_decrease`,`pf`.`score` AS `score`,`pf`.`money` AS `money`,`pf`.`reason` AS `reason`,`pf`.`sheme_id` AS `sheme_id`,`pf`.`sheme_version` AS `sheme_version`,`pf`.`dimension` AS `dimension`,`pf`.`target` AS `target`,`pf`.`son_target` AS `son_target`,`pf`.`detailed` AS `detailed`,`pf`.`year` AS `year`,`pf`.`quarter` AS `quarter`,`pf`.`month` AS `month`,`pf`.`week` AS `week`,`pf`.`person_liable` AS `person_liable`,`pf`.`company_id` AS `company_id`,`pf`.`department_id` AS `department_id`,`pf`.`org_id` AS `org_id`,`pf`.`post_id` AS `post_id`,`pf`.`executor` AS `executor`,`pf`.`executor_department` AS `executor_department`,`pf`.`rectification` AS `rectification`,`pf`.`correction_time` AS `correction_time`,`pf`.`happen_time` AS `happen_time`,`pf`.`happen_count` AS `happen_count`,`pf`.`time` AS `time`,`po`.`class` AS `class`,`po`.`state` AS `state`,`po`.`participants` AS `participants` from (`post_nature_flow` `pf` left join `post_workflow_orders` `po` on((`pf`.`order_id` = `po`.`order_id`)))
+```
+
+
+Time:2022-11-08
+数据库增加 角色权限分配 role_empower
+
+
+```
+CREATE TABLE `role_empower` (
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ `role_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '角色',
+ `system` varchar(255) NOT NULL DEFAULT '' COMMENT '系统',
+ `point_id` longtext NOT NULL COMMENT '权限点位',
+ `operation` longtext COMMENT '操作点位',
+ `state` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:启用;2:禁用;3:删除)',
+ `level` int(1) unsigned NOT NULL DEFAULT '1' COMMENT '授权范围等级(1:本岗位;2:本部门;3:本分部;4:指定行政组织;5:所有)',
+ `time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '时间',
+ PRIMARY KEY (`id`) USING BTREE
+) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COMMENT='角色权限分配';
+
+```
+
+
+Time:2022-11-08
+数据库增加 系统角色表 system_role
+
+
+```
+CREATE TABLE `system_role` (
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ `name` varchar(255) NOT NULL DEFAULT '' COMMENT '角色名称',
+ `state` int(1) unsigned NOT NULL DEFAULT '1' COMMENT '1:启用;2:禁用;3:删除',
+ `time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '写入时间',
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COMMENT='系统角色表';
+
```
\ No newline at end of file
diff --git a/api/base/loginVerify/login.go b/api/base/loginVerify/login.go
index 0b83596..c375a62 100644
--- a/api/base/loginVerify/login.go
+++ b/api/base/loginVerify/login.go
@@ -183,6 +183,8 @@ func getRoleSeat(roleId string) (menuStr, buttonStr string) {
}
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
}
diff --git a/api/base/loginVerify/type.go b/api/base/loginVerify/type.go
index 7e82742..2621851 100644
--- a/api/base/loginVerify/type.go
+++ b/api/base/loginVerify/type.go
@@ -41,3 +41,9 @@ type OldSchollAdmin struct {
type VerifyEmpowerKey struct {
UserKey string `json:"userKey"`
}
+
+// 配置参数
+type ExamConfig struct {
+ Url string `json:"url"`
+ State int `json:"state"`
+}
diff --git a/api/base/loginVerify/work_js_sdk.go b/api/base/loginVerify/work_js_sdk.go
new file mode 100644
index 0000000..bba138c
--- /dev/null
+++ b/api/base/loginVerify/work_js_sdk.go
@@ -0,0 +1,571 @@
+package loginVerify
+
+import (
+ "encoding/json"
+ "fmt"
+ "key_performance_indicators/middleware/grocerystore"
+ "key_performance_indicators/middleware/wechatapp/wechatstatice"
+ "key_performance_indicators/models/modelshr"
+ "key_performance_indicators/overall"
+ "key_performance_indicators/overall/publicmethod"
+ "net/http"
+ "net/url"
+ "strconv"
+ "time"
+
+ "github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
+ "github.com/gin-gonic/gin"
+)
+
+/*
+*
+@ 作者: 秦东
+@ 时间: 2022-10-31 13:31:05
+@ 功能: 获取企业微信基础配置
+@ 参数
+
+ #
+
+@ 返回值
+
+ #
+*/
+func (a *ApiMethod) GetWorkWechatJsApiConfig(c *gin.Context) {
+ host := c.Request.Header.Get("Host")
+ userAgent := c.Request.Header.Get("User-Agent")
+ wechatTokenStr := fmt.Sprintf("%v_%v", host, userAgent)
+ var md5JiaMi publicmethod.Md5Encryption
+ md5JiaMi.Md5EncryptionInit(wechatTokenStr)
+ md5Token := md5JiaMi.Md5EncryptionAlgorithm()
+
+ var receivedValue ExamConfig
+ err := c.ShouldBindJSON(&receivedValue)
+ if err != nil {
+ publicmethod.Result(100, receivedValue, c)
+ return
+ }
+ if receivedValue.Url == "" {
+ publicmethod.Result(1, receivedValue, c, "参数错误!请重新提交!")
+ return
+ }
+ if receivedValue.State == 0 {
+ receivedValue.State = 1
+ }
+ //获取JsApi_ticket
+ _, jsapiTicker, err := GetJsapiTicket("kpi", md5Token, receivedValue.State)
+ if err != nil {
+ publicmethod.Result(1, err, c, "获取jsapi_ticket数据失败!")
+ return
+ }
+ noncestr := publicmethod.GetUUid(3)
+ timestamp := time.Now().Unix()
+ url := receivedValue.Url
+ jiamistr := fmt.Sprintf("jsapi_ticket=%v&noncestr=%v×tamp=%v&url=%v", jsapiTicker, noncestr, timestamp, url)
+ jiamistrHa1 := publicmethod.Sha1Encryption(jiamistr)
+ outData := publicmethod.MapOut[string]()
+ outData["corpid"] = overall.CONSTANT_CONFIG.WechatCompany.CompanyId
+ outData["agentid"] = overall.CONSTANT_CONFIG.WechatKpi.Agentid
+ outData["timestamp"] = strconv.FormatInt(timestamp, 10)
+ outData["nonceStr"] = strconv.FormatInt(noncestr, 10)
+ outData["signature"] = jiamistrHa1
+ outData["orderid"] = strconv.FormatInt(publicmethod.GetUUid(2), 10)
+
+ outData["jsapi_ticket"] = jsapiTicker
+
+ outData["state"] = receivedValue.State
+
+ response.Result(0, outData, "查询成功", c)
+}
+
+/*
+*
+@ 作者: 秦东
+@ 时间: 2022-10-31 13:07:35
+@ 功能: 获取企业的jsapi_ticket 或 获取应用的jsapi_ticket
+@ 参数
+
+ #systemApp 系统
+ #key 身份识别
+ #calss 1:应用,2:企业
+
+@ 返回值
+
+ #sendUrlstr jsapiTicket访问URL
+*/
+func GetJsapiTicket(systemApp, key string, class int) (sendUrlstr, jsApiTickerStr string, err error) {
+
+ //获取token
+ tokenStr, err := wechatstatice.GetWechatTokenEs(systemApp, key, 1)
+ if class != 1 {
+ sendUrlstr = "https://qyapi.weixin.qq.com/cgi-bin/get_jsapi_ticket?access_token=" + tokenStr //获取企业级
+ } else {
+ sendUrlstr = "https://qyapi.weixin.qq.com/cgi-bin/ticket/get?access_token=" + tokenStr + "&type=agent_config" //获取应用级
+ }
+ jsApiTicketRedis := fmt.Sprintf("WorkWechat:JsapiTicket:%v_%v_%v", systemApp, overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, class)
+ redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS3)
+ isTrue, jsApiTickerStr := redisClient.Get(jsApiTicketRedis) //读取redis数据
+ if isTrue != true {
+ //获取企业微信jsapi_ticket
+ jsapiTickerMsg := publicmethod.CurlGet(sendUrlstr)
+ var callBackCont wechatstatice.WeChatCallBack
+ err = json.Unmarshal(jsapiTickerMsg, &callBackCont)
+ if err != nil {
+ return
+ }
+ if callBackCont.Errcode != 0 {
+ return
+ }
+ jsApiTickerStr = callBackCont.Ticket
+ redisClient.SetRedisTime(7200)
+ redisClient.Set(jsApiTicketRedis, jsApiTickerStr)
+ } else {
+ return
+ }
+ return
+}
+
+// 获取身份认证
+func (a *ApiMethod) AuthenticationUser(c *gin.Context) {
+
+ host := c.Request.Header.Get("Host")
+ userAgent := c.Request.Header.Get("User-Agent")
+ wechatTokenStr := fmt.Sprintf("%v_%v", host, userAgent)
+ var md5JiaMi publicmethod.Md5Encryption
+ md5JiaMi.Md5EncryptionInit(wechatTokenStr)
+ md5Token := md5JiaMi.Md5EncryptionAlgorithm()
+ //获取token
+ tokenStr, err := wechatstatice.GetWechatTokenEs("kpi", md5Token, 1)
+ if err != nil {
+ publicmethod.Result(100, err, c, "身份认证失败!----------------->")
+ // user_code_url := fmt.Sprintf("%v", overall.CONSTANT_CONFIG.Appsetup.WebUrl)
+ // c.Redirect(http.StatusMovedPermanently, user_code_url)
+ return
+ }
+ //重定向身份认证
+ callBackUrl := url.QueryEscape(fmt.Sprintf("%v/kpiapi/base/callbackauthuser", overall.CONSTANT_CONFIG.Appsetup.WebUrl))
+ redirectUrl := fmt.Sprintf("https://open.weixin.qq.com/connect/oauth2/authorize?appid=%v&redirect_uri=%v&response_type=code&scope=snsapi_base&state=%v#wechat_redirect", overall.CONSTANT_CONFIG.WechatCompany.CompanyId, callBackUrl, tokenStr)
+ c.Redirect(http.StatusMovedPermanently, redirectUrl)
+ // publicmethod.Result(1, tokenStr, c, "身份认证失败!!")
+}
+
+/*
+*
+@ 作者: 秦东
+@ 时间: 2022-11-01 10:02:09
+@ 功能: 企业微信身份回调认证
+@ 参数
+
+ #
+
+@ 返回值
+
+ #
+*/
+func (a *ApiMethod) CallBackAuthUser(c *gin.Context) {
+ code := c.Query("code")
+ state := c.Query("state")
+ if code == "" || state == "" {
+ publicmethod.Result(1, code, c, "未能查询到您的信息!企业微信授权失败!1")
+ return
+ }
+
+ sendUser := fmt.Sprintf("https://qyapi.weixin.qq.com/cgi-bin/auth/getuserinfo?access_token=%v&code=%v", state, code)
+ tokenByte := publicmethod.CurlGet(sendUser)
+ var callBackData wechatstatice.WorkWechatUserAuter
+ err := json.Unmarshal(tokenByte, &callBackData)
+ if err != nil {
+ publicmethod.Result(1, err, c, "未能查询到您的信息!企业微信授权失败!2")
+ return
+ }
+ if callBackData.Errcode != 0 {
+
+ if callBackData.Errcode == 42001 {
+ AgainEmpower(c)
+ return
+ }
+ publicmethod.Result(1, callBackData, c, "未能查询到您的信息!企业微信授权失败!3")
+ return
+ }
+ var userWechatId string
+ if callBackData.OpenId != "" {
+ userWechatId = callBackData.OpenId
+ }
+ if callBackData.Userid != "" {
+ userWechatId = callBackData.Userid
+ }
+ if userWechatId == "" {
+ publicmethod.Result(1, err, c, "未能查询到您的信息!企业微信授权失败!4")
+ return
+ }
+ _, sendMap, msg, isTrue := SetUpUserLogin(userWechatId)
+ callBackLoginUrl := fmt.Sprintf("%v/#/pages/login/login", overall.CONSTANT_CONFIG.Appsetup.WebUrl)
+ switch isTrue {
+ case 2:
+ publicmethod.Result(1, err, c, msg)
+ return
+ case 3:
+ publicmethod.Result(1, err, c, msg)
+ return
+ case 4:
+ callBackLoginUrl = fmt.Sprintf("%v?exitstr=0&openid=%v&userkey=%v&token=%v", callBackLoginUrl, userWechatId, sendMap["key"], sendMap["token"])
+ default:
+ callBackLoginUrl = fmt.Sprintf("%v?exitstr=1&openid=%v", callBackLoginUrl, userWechatId)
+ }
+ c.Redirect(http.StatusMovedPermanently, callBackLoginUrl)
+}
+
+/*
+*
+@ 作者: 秦东
+@ 时间: 2022-11-02 13:22:08
+@ 功能: 重新等下授权
+@ 参数
+
+ #
+
+@ 返回值
+
+ #
+*/
+func AgainEmpower(c *gin.Context) {
+ host := c.Request.Header.Get("Host")
+ userAgent := c.Request.Header.Get("User-Agent")
+ wechatTokenStr := fmt.Sprintf("%v_%v", host, userAgent)
+ var md5JiaMi publicmethod.Md5Encryption
+ md5JiaMi.Md5EncryptionInit(wechatTokenStr)
+ md5Token := md5JiaMi.Md5EncryptionAlgorithm()
+ //获取token
+ tokenStr, err := wechatstatice.GetWechatTokenEs("kpi", md5Token, 2)
+ if err != nil {
+ // publicmethod.Result(1, err, c, "身份认证失败!")
+ user_code_url := fmt.Sprintf("%v", overall.CONSTANT_CONFIG.Appsetup.WebUrl)
+ c.Redirect(http.StatusMovedPermanently, user_code_url)
+ return
+ }
+ //重定向身份认证
+ callBackUrl := url.QueryEscape(fmt.Sprintf("%v/kpiapi/base/callbackauthuser", overall.CONSTANT_CONFIG.Appsetup.WebUrl))
+ redirectUrl := fmt.Sprintf("https://open.weixin.qq.com/connect/oauth2/authorize?appid=%v&redirect_uri=%v&response_type=code&scope=snsapi_base&state=%v#wechat_redirect", overall.CONSTANT_CONFIG.WechatCompany.CompanyId, callBackUrl, tokenStr)
+ c.Redirect(http.StatusMovedPermanently, redirectUrl)
+}
+
+/*
+*
+@ 作者: 秦东
+@ 时间: 2022-11-01 11:24:40
+@ 功能: 设定登录信息
+@ 参数
+
+ #
+
+@ 返回值
+
+ #
+*/
+func SetUpUserLogin(openId string) (userCont modelshr.ManCont, sendMap map[string]interface{}, msg string, isTrue int) {
+ isTrue = 1
+
+ // var userCont modelshr.ManCont
+ err := overall.CONSTANT_DB_HR.Where("`wechat` = ? OR `work_wechat` = ?", openId, openId).First(&userCont).Error //获取人员信息
+ if err != nil {
+ return
+ }
+
+ if userCont.State == 2 {
+ msg = "登陆失败! 该账号已经被禁用!"
+ isTrue = 2
+ return
+ }
+ if userCont.State == 3 {
+ msg = "登陆失败! 该账号不存在!"
+ isTrue = 3
+ return
+ }
+
+ uuIdVal := publicmethod.GetUUid(3) //获取随机数
+ uuIdValStr := strconv.FormatInt(uuIdVal, 10)
+ fmt.Printf("%v\n", uuIdValStr)
+ //Token定参
+ userAgent := overall.CONSTANT_CONFIG.Appsetup.AppKey
+ var md5JiaMi publicmethod.Md5Encryption
+ md5JiaMi.Md5EncryptionInit(userAgent)
+ md5Token := md5JiaMi.Md5EncryptionAlgorithm()
+ //工号MD5加密
+ var md5JiaMiNumber publicmethod.Md5Encryption
+ // md5JiaMiNumber.Md5EncryptionInit(userCont.Number + uuIdValStr)
+ md5JiaMiNumber.Md5EncryptionInit(userCont.Number)
+ userKeyCode := md5JiaMiNumber.Md5EncryptionAlgorithm()
+ //组成Token字符串进行
+ // sha1Str := userKeyCode + userCont.Number + userCont.Password + md5Token + uuIdValStr
+ 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,
+ }
+
+ // fmt.Printf("writeRedisData--------->%v\n", writeRedisData)
+
+ //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)
+
+ //缓存写入个人信息
+ 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["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 := publicmethod.MapOut[string]()
+ saveData["key"] = userKeyCode
+ saveData["token"] = sha1Token
+ saveData["userinfo"] = userCont
+ saveData["usercont"] = myCont
+
+ sendMap = saveData
+ isTrue = 4
+ return
+}
+
+// 手机端免登录验证
+func (a *ApiMethod) LaissezPasser(c *gin.Context) {
+ userKey := c.Request.Header.Get("user-key")
+ userToken := c.Request.Header.Get("user-token")
+
+ //API Token数据
+ redisFileKey := fmt.Sprintf("ScanCode:Authentication:LoginApi_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, userKey)
+ redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS5)
+ userRedisToken, isTrue := redisClient.HashGetAll(redisFileKey)
+ if !isTrue {
+ publicmethod.Result(1, isTrue, c, "未登录或非法访问!")
+ return
+ }
+ if userToken != userRedisToken["usertoken"] {
+ publicmethod.Result(1, isTrue, c, "令牌不正确!非法访问!")
+ return
+ }
+ userCont, myErr := publicmethod.GetUserRedisCont(userRedisToken["usernumber"])
+ if myErr != nil {
+ publicmethod.Result(1, isTrue, c, "登录超时!请重新登录!")
+ return
+ }
+ 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["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
+
+ //返回值
+ saveData := publicmethod.MapOut[string]()
+ saveData["key"] = userKey
+ saveData["token"] = userToken
+ saveData["userinfo"] = userCont
+ saveData["usercont"] = myCont
+
+ publicmethod.Result(0, saveData, c)
+}
+
+/*
+*
+@ 作者: 秦东
+@ 时间: 2022-11-08 13:10:54
+@ 功能: 扫码登录
+@ 参数
+
+ #
+
+@ 返回值
+
+ #
+*/
+func (a *ApiMethod) ScanQrCodeCallBackAuthUser(c *gin.Context) {
+ code := c.Query("code")
+ state := c.Query("state")
+ if code == "" || state == "" {
+ publicmethod.Result(1, code, c, "未能查询到您的信息!企业微信授权失败!1")
+ return
+ }
+
+ host := c.Request.Header.Get("Host")
+ userAgent := c.Request.Header.Get("User-Agent")
+ wechatTokenStr := fmt.Sprintf("%v_%v", host, userAgent)
+ var md5JiaMi publicmethod.Md5Encryption
+ md5JiaMi.Md5EncryptionInit(wechatTokenStr)
+ md5Token := md5JiaMi.Md5EncryptionAlgorithm()
+
+ //获取token
+ tokenStr, err := wechatstatice.GetWechatTokenEs("kpi", md5Token, 1)
+
+ if err != nil {
+ publicmethod.Result(1, err, c, "未能查询到您的信息!企业微信授权失败!4")
+ return
+ }
+
+ sendUser := fmt.Sprintf("https://qyapi.weixin.qq.com/cgi-bin/auth/getuserinfo?access_token=%v&code=%v", tokenStr, code)
+ tokenByte := publicmethod.CurlGet(sendUser)
+ var callBackData wechatstatice.WorkWechatUserAuter
+ err = json.Unmarshal(tokenByte, &callBackData)
+ if err != nil {
+ publicmethod.Result(1, err, c, "未能查询到您的信息!企业微信授权失败!2")
+ return
+ }
+ if callBackData.Errcode != 0 {
+
+ if callBackData.Errcode == 42001 {
+ AgainEmpower(c)
+ return
+ }
+ publicmethod.Result(1, callBackData, c, "未能查询到您的信息!企业微信授权失败!3")
+ return
+ }
+ var userWechatId string
+ if callBackData.OpenId != "" {
+ userWechatId = callBackData.OpenId
+ }
+ if callBackData.Userid != "" {
+ userWechatId = callBackData.Userid
+ }
+ if userWechatId == "" {
+ publicmethod.Result(1, err, c, "未能查询到您的信息!企业微信授权失败!4")
+ return
+ }
+ // userWechatId := "KaiXinGuo"
+ _, sendMap, msg, isTrue := SetUpUserLogin(userWechatId)
+ callBackLoginUrl := fmt.Sprintf("%v/#/ceshi", overall.CONSTANT_CONFIG.Appsetup.PcbUrl)
+ switch isTrue {
+ case 2:
+ publicmethod.Result(1, err, c, msg)
+ return
+ case 3:
+ publicmethod.Result(1, err, c, msg)
+ return
+ case 4:
+ callBackLoginUrl = fmt.Sprintf("%v?token=%v&key=%v", callBackLoginUrl, sendMap["token"], sendMap["key"])
+ default:
+ callBackLoginUrl = fmt.Sprintf("%v?token=%v&key=%v", callBackLoginUrl, sendMap["token"], sendMap["key"])
+ }
+ // publicmethod.Result(1, callBackLoginUrl, c, "未能查询到您的信息!企业微信授权失败!5")
+ c.Redirect(http.StatusMovedPermanently, callBackLoginUrl)
+}
diff --git a/api/version1/departmentseting/departmentpc/qualitativekpi.go b/api/version1/departmentseting/departmentpc/qualitativekpi.go
index 042aa5c..a056cb9 100644
--- a/api/version1/departmentseting/departmentpc/qualitativekpi.go
+++ b/api/version1/departmentseting/departmentpc/qualitativekpi.go
@@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"key_performance_indicators/middleware/snowflake"
- "key_performance_indicators/middleware/wechatapp/wechatsendmsg"
"key_performance_indicators/models/modelshr"
"key_performance_indicators/models/modelskpi"
"key_performance_indicators/overall"
@@ -113,14 +112,14 @@ func (a *ApiMethod) Shiyan(c *gin.Context) {
// fmt.Printf("gormDb----->%v----->%v\n", err, evalCont)
// //校正部门级考核
- // var dimeTargetList []modelskpi.DetailedTarget
- // err := overall.CONSTANT_DB_KPI.Where("dt_state = 1").Find(&dimeTargetList).Error
- // if err != nil || len(dimeTargetList) < 1 {
- // publicmethod.Result(107, err, c)
- // return
- // }
+ var dimeTargetList []modelskpi.DetailedTarget
+ err := overall.CONSTANT_DB_KPI.Where("dt_state = 1").Find(&dimeTargetList).Error
+ if err != nil || len(dimeTargetList) < 1 {
+ publicmethod.Result(107, err, c)
+ return
+ }
- // fmt.Printf("总数---->%v\n", len(dimeTargetList))
+ fmt.Printf("总数---->%v\n", len(dimeTargetList))
// var xieChengChuli []modelskpi.DetailedTarget
// for i, v := range dimeTargetList {
// if (i+1)%100 == 0 {
@@ -132,14 +131,14 @@ func (a *ApiMethod) Shiyan(c *gin.Context) {
// }
// }
- // for _, v := range dimeTargetList {
- // xiaoZhengBuMen(v)
- // }
+ for _, v := range dimeTargetList {
+ xiaoZhengBuMen(v)
+ }
// fmt.Printf("jieshu---->%v\n", len(dimeTargetList))
//校正维度
- // xiaoZehgnWeiDu()
+ xiaoZehgnWeiDu()
// var receivedValue publicmethod.PublicId
// c.ShouldBindJSON(&receivedValue)
// //获取被考核人基本信息
@@ -220,40 +219,40 @@ func (a *ApiMethod) Shiyan(c *gin.Context) {
//发送模板卡片
//文本通知
- var sourceText wechatsendmsg.SourceText
- sourceText.IconUrl = "https://docu.hxgk.group/images/2022_01/3f7a1120a559e9bee3991b85eb34d103.png"
- sourceText.Desc = "恒信高科"
- sourceText.DescColor = 1
-
- var actionListCont []wechatsendmsg.ActionListCont
-
- var actionListContOne wechatsendmsg.ActionListCont
- actionListContOne.Key = "A"
- actionListContOne.Text = "接受推送"
- actionListCont = append(actionListCont, actionListContOne)
- var actionListContTwo wechatsendmsg.ActionListCont
- actionListContTwo.Key = "B"
- actionListContTwo.Text = "不再推送"
- actionListCont = append(actionListCont, actionListContTwo)
- var ActionMenuCont wechatsendmsg.ActionMenuCont
- ActionMenuCont.Desc = "卡片副交互辅助文本说明"
- ActionMenuCont.ActionList = actionListCont
+ // var sourceText wechatsendmsg.SourceText
+ // sourceText.IconUrl = "https://docu.hxgk.group/images/2022_01/3f7a1120a559e9bee3991b85eb34d103.png"
+ // sourceText.Desc = "恒信高科"
+ // sourceText.DescColor = 1
+
+ // var actionListCont []wechatsendmsg.ActionListCont
+
+ // var actionListContOne wechatsendmsg.ActionListCont
+ // actionListContOne.Key = "A"
+ // actionListContOne.Text = "接受推送"
+ // actionListCont = append(actionListCont, actionListContOne)
+ // var actionListContTwo wechatsendmsg.ActionListCont
+ // actionListContTwo.Key = "B"
+ // actionListContTwo.Text = "不再推送"
+ // actionListCont = append(actionListCont, actionListContTwo)
+ // var ActionMenuCont wechatsendmsg.ActionMenuCont
+ // ActionMenuCont.Desc = "卡片副交互辅助文本说明"
+ // ActionMenuCont.ActionList = actionListCont
// var mainTitleCont wechatsendmsg.MainTitleCont
// mainTitleCont.Title = "一级标题一级标题一级标题\n一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题"
// mainTitleCont.Desc = "一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明"
- var quoteAreaCont wechatsendmsg.QuoteAreaCont
- quoteAreaCont.Type = 1
- quoteAreaCont.Url = "http://admin.hxgk.group"
+ // var quoteAreaCont wechatsendmsg.QuoteAreaCont
+ // quoteAreaCont.Type = 1
+ // quoteAreaCont.Url = "http://admin.hxgk.group"
// quoteAreaCont.Title = "引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题"
- quoteAreaCont.QuoteText = "引用文献描述引用文献描述\n引用文献描\n述引用文献描述引用文献描述\n引用文献描述引用\n文献描述引用文献描\n述引用文献描述\n引用文献描述引用文献描述引用文献描述引用文献描\n述引用文献描述引用文献描\n述引用文献描述引用文\n献描述引用文献描述引\n用文献描述引用文献描述引用\n文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述\n引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引\n用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述"
+ // quoteAreaCont.QuoteText = "引用文献描述引用文献描述\n引用文献描\n述引用文献描述引用文献描述\n引用文献描述引用\n文献描述引用文献描\n述引用文献描述\n引用文献描述引用文献描述引用文献描述引用文献描\n述引用文献描述引用文献描\n述引用文献描述引用文\n献描述引用文献描述引\n用文献描述引用文献描述引用\n文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述\n引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引\n用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述"
// var emphasisContentInfo wechatsendmsg.EmphasisContentInfo
// emphasisContentInfo.Title = "关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题"
// emphasisContentInfo.Desc = "关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述"
- var horizontalContentListInfoAry []wechatsendmsg.HorizontalContentListInfo
+ // var horizontalContentListInfoAry []wechatsendmsg.HorizontalContentListInfo
// var horizontalContentListInfo wechatsendmsg.HorizontalContentListInfo
// horizontalContentListInfo.KeyName = "邀请人"
@@ -273,20 +272,20 @@ func (a *ApiMethod) Shiyan(c *gin.Context) {
// // horizontalContentLis2.MediaId = "https://work.weixin.qq.com"
// // horizontalContentListInfoAry = append(horizontalContentListInfoAry, horizontalContentLis2)
- var horizontalContentLis3 wechatsendmsg.HorizontalContentListInfo
- horizontalContentLis3.KeyName = "员工信息"
- horizontalContentLis3.Value = "点击查看"
- horizontalContentLis3.Type = 3
- horizontalContentLis3.Userid = "KaiXinGuo"
- horizontalContentListInfoAry = append(horizontalContentListInfoAry, horizontalContentLis3)
+ // var horizontalContentLis3 wechatsendmsg.HorizontalContentListInfo
+ // horizontalContentLis3.KeyName = "员工信息"
+ // horizontalContentLis3.Value = "点击查看"
+ // horizontalContentLis3.Type = 3
+ // horizontalContentLis3.Userid = "KaiXinGuo"
+ // horizontalContentListInfoAry = append(horizontalContentListInfoAry, horizontalContentLis3)
- var jumpListContList []wechatsendmsg.JumpListCont
+ // var jumpListContList []wechatsendmsg.JumpListCont
- var jumpList1 wechatsendmsg.JumpListCont
- jumpList1.Type = 1
- jumpList1.Title = "企业微信官网===>"
- jumpList1.Url = "https://work.weixin.qq.com"
- jumpListContList = append(jumpListContList, jumpList1)
+ // var jumpList1 wechatsendmsg.JumpListCont
+ // jumpList1.Type = 1
+ // jumpList1.Title = "企业微信官网===>"
+ // jumpList1.Url = "https://work.weixin.qq.com"
+ // jumpListContList = append(jumpListContList, jumpList1)
// // var jumpList2 wechatsendmsg.JumpListCont
// // jumpList2.Type = 2
@@ -295,9 +294,9 @@ func (a *ApiMethod) Shiyan(c *gin.Context) {
// // jumpList2.PagePath = "/index.html"
// // jumpListContList = append(jumpListContList, jumpList2)
- var cardActionContStr wechatsendmsg.CardActionCont
- cardActionContStr.Type = 1
- cardActionContStr.Url = "http://www.baidu.com"
+ // var cardActionContStr wechatsendmsg.CardActionCont
+ // cardActionContStr.Type = 1
+ // cardActionContStr.Url = "http://www.baidu.com"
// uuId := publicmethod.GetUUid(5)
// var tempCardContText wechatsendmsg.TemplateCardContText
@@ -331,104 +330,104 @@ func (a *ApiMethod) Shiyan(c *gin.Context) {
// fmt.Printf("callData------>%v--------err--------->%v--------->%v\n", callData, err, string(jsonstr))
// publicmethod.Result(0, callData, c)
- var mainTitleCont wechatsendmsg.MainTitleCont
- mainTitleCont.Title = "关键数据标\n题关键数据标题关键数据\n标题关键数据标题关\n键数据标题关键数据标题关\n键数据标题\n关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据\n标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题"
-
- var imageTextAreaCont wechatsendmsg.ImageTextAreaCont
- imageTextAreaCont.Type = 1
- imageTextAreaCont.Url = "https://work.weixin.qq.com"
- imageTextAreaCont.Title = "企业微信的左图右文样式"
- imageTextAreaCont.Desc = "企业微信真好用呀真好用"
- imageTextAreaCont.ImageUrl = "https://img.iplaysoft.com/wp-content/uploads/2019/free-images/free_stock_photo_2x.jpg"
-
- var cardImageCont wechatsendmsg.CardImageCont
- cardImageCont.Url = "https://docu.hxgk.group/images/2022_01/3f7a1120a559e9bee3991b85eb34d103.png"
- cardImageCont.AspectRatio = 2.2
-
- var verticalContentListCont wechatsendmsg.VerticalContentListCont
- verticalContentListCont.Title = "惊喜红包等你来拿"
- verticalContentListCont.Desc = "下载企业微信还能抢红包!"
-
- var optionListContList []wechatsendmsg.OptionListCont
- var optionListCont1 wechatsendmsg.OptionListCont
- optionListCont1.Id = "btn_selection_id1"
- optionListCont1.Text = "100分"
- optionListContList = append(optionListContList, optionListCont1)
- var optionListCont2 wechatsendmsg.OptionListCont
- optionListCont2.Id = "btn_selection_id2"
- optionListCont2.Text = "101分"
- optionListContList = append(optionListContList, optionListCont2)
-
- var buttonSelectionCont wechatsendmsg.ButtonSelectionCont
- buttonSelectionCont.QuestionKey = "btn_question_key1"
- buttonSelectionCont.Title = "企业微信评分"
- buttonSelectionCont.SelectedId = "btn_selection_id1"
- buttonSelectionCont.OptionList = optionListContList
-
- var optionListContList1 []wechatsendmsg.OptionListCont
- var optionListCont11 wechatsendmsg.OptionListCont
- optionListCont11.Id = "btn_selection_id12"
- optionListCont11.Text = "100"
- optionListContList1 = append(optionListContList1, optionListCont11)
- var optionListCont12 wechatsendmsg.OptionListCont
- optionListCont12.Id = "btn_selection_id22"
- optionListCont12.Text = "101"
- optionListContList1 = append(optionListContList1, optionListCont12)
-
- var buttonSelectionCont1 wechatsendmsg.ButtonSelectionCont
- buttonSelectionCont1.QuestionKey = "btn_question_key12"
- buttonSelectionCont1.Title = "评分"
- buttonSelectionCont1.SelectedId = "btn_selection_id12"
- buttonSelectionCont1.OptionList = optionListContList1
-
- var buttonSelectionContList []wechatsendmsg.ButtonSelectionCont
-
- buttonSelectionContList = append(buttonSelectionContList, buttonSelectionCont)
- buttonSelectionContList = append(buttonSelectionContList, buttonSelectionCont1)
- var buttonList []wechatsendmsg.ButtonListCont
-
- var buttonList1 wechatsendmsg.ButtonListCont
- buttonList1.Text = "按钮1"
- buttonList1.Style = 1
- buttonList1.Key = "button_key_1"
- buttonList = append(buttonList, buttonList1)
-
- var buttonList2 wechatsendmsg.ButtonListCont
- buttonList2.Text = "按钮2"
- buttonList2.Style = 2
- buttonList2.Key = "button_key_2"
- buttonList = append(buttonList, buttonList2)
-
- var OptionListContCheckBoxList []wechatsendmsg.OptionListContCheckBox
-
- var OptionListContCheckBox1 wechatsendmsg.OptionListContCheckBox
- OptionListContCheckBox1.Id = "option_id1"
- OptionListContCheckBox1.Text = "选择题选项1"
- OptionListContCheckBox1.IsChecked = true
- OptionListContCheckBoxList = append(OptionListContCheckBoxList, OptionListContCheckBox1)
- var OptionListContCheckBox2 wechatsendmsg.OptionListContCheckBox
- OptionListContCheckBox2.Id = "option_id2"
- OptionListContCheckBox2.Text = "选择题选项2"
- OptionListContCheckBox2.IsChecked = false
- OptionListContCheckBoxList = append(OptionListContCheckBoxList, OptionListContCheckBox2)
-
- var checkBoxCont wechatsendmsg.CheckBoxCont
- checkBoxCont.QuestionKey = "question_key1"
- checkBoxCont.Mode = 1
- checkBoxCont.OptionList = OptionListContCheckBoxList
-
- var submitButton wechatsendmsg.ActionListCont
- submitButton.Text = "提交"
- submitButton.Key = "key"
-
- uuId := publicmethod.GetUUid(5)
-
- var sendCont wechatsendmsg.TemMultipleInteraction
- sendCont.CardType = "multiple_interaction"
- sendCont.Source = sourceText
- // sendCont.ActionMenu = ActionMenuCont
- sendCont.TaskId = fmt.Sprintf("KPI_%v", uuId)
- sendCont.MainTitle = mainTitleCont
+ // var mainTitleCont wechatsendmsg.MainTitleCont
+ // mainTitleCont.Title = "关键数据标\n题关键数据标题关键数据\n标题关键数据标题关\n键数据标题关键数据标题关\n键数据标题\n关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据\n标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题"
+
+ // var imageTextAreaCont wechatsendmsg.ImageTextAreaCont
+ // imageTextAreaCont.Type = 1
+ // imageTextAreaCont.Url = "https://work.weixin.qq.com"
+ // imageTextAreaCont.Title = "企业微信的左图右文样式"
+ // imageTextAreaCont.Desc = "企业微信真好用呀真好用"
+ // imageTextAreaCont.ImageUrl = "https://img.iplaysoft.com/wp-content/uploads/2019/free-images/free_stock_photo_2x.jpg"
+
+ // var cardImageCont wechatsendmsg.CardImageCont
+ // cardImageCont.Url = "https://docu.hxgk.group/images/2022_01/3f7a1120a559e9bee3991b85eb34d103.png"
+ // cardImageCont.AspectRatio = 2.2
+
+ // var verticalContentListCont wechatsendmsg.VerticalContentListCont
+ // verticalContentListCont.Title = "惊喜红包等你来拿"
+ // verticalContentListCont.Desc = "下载企业微信还能抢红包!"
+
+ // var optionListContList []wechatsendmsg.OptionListCont
+ // var optionListCont1 wechatsendmsg.OptionListCont
+ // optionListCont1.Id = "btn_selection_id1"
+ // optionListCont1.Text = "100分"
+ // optionListContList = append(optionListContList, optionListCont1)
+ // var optionListCont2 wechatsendmsg.OptionListCont
+ // optionListCont2.Id = "btn_selection_id2"
+ // optionListCont2.Text = "101分"
+ // optionListContList = append(optionListContList, optionListCont2)
+
+ // var buttonSelectionCont wechatsendmsg.ButtonSelectionCont
+ // buttonSelectionCont.QuestionKey = "btn_question_key1"
+ // buttonSelectionCont.Title = "企业微信评分"
+ // buttonSelectionCont.SelectedId = "btn_selection_id1"
+ // buttonSelectionCont.OptionList = optionListContList
+
+ // var optionListContList1 []wechatsendmsg.OptionListCont
+ // var optionListCont11 wechatsendmsg.OptionListCont
+ // optionListCont11.Id = "btn_selection_id12"
+ // optionListCont11.Text = "100"
+ // optionListContList1 = append(optionListContList1, optionListCont11)
+ // var optionListCont12 wechatsendmsg.OptionListCont
+ // optionListCont12.Id = "btn_selection_id22"
+ // optionListCont12.Text = "101"
+ // optionListContList1 = append(optionListContList1, optionListCont12)
+
+ // var buttonSelectionCont1 wechatsendmsg.ButtonSelectionCont
+ // buttonSelectionCont1.QuestionKey = "btn_question_key12"
+ // buttonSelectionCont1.Title = "评分"
+ // buttonSelectionCont1.SelectedId = "btn_selection_id12"
+ // buttonSelectionCont1.OptionList = optionListContList1
+
+ // var buttonSelectionContList []wechatsendmsg.ButtonSelectionCont
+
+ // buttonSelectionContList = append(buttonSelectionContList, buttonSelectionCont)
+ // buttonSelectionContList = append(buttonSelectionContList, buttonSelectionCont1)
+ // var buttonList []wechatsendmsg.ButtonListCont
+
+ // var buttonList1 wechatsendmsg.ButtonListCont
+ // buttonList1.Text = "按钮1"
+ // buttonList1.Style = 1
+ // buttonList1.Key = "button_key_1"
+ // buttonList = append(buttonList, buttonList1)
+
+ // var buttonList2 wechatsendmsg.ButtonListCont
+ // buttonList2.Text = "按钮2"
+ // buttonList2.Style = 2
+ // buttonList2.Key = "button_key_2"
+ // buttonList = append(buttonList, buttonList2)
+
+ // var OptionListContCheckBoxList []wechatsendmsg.OptionListContCheckBox
+
+ // var OptionListContCheckBox1 wechatsendmsg.OptionListContCheckBox
+ // OptionListContCheckBox1.Id = "option_id1"
+ // OptionListContCheckBox1.Text = "选择题选项1"
+ // OptionListContCheckBox1.IsChecked = true
+ // OptionListContCheckBoxList = append(OptionListContCheckBoxList, OptionListContCheckBox1)
+ // var OptionListContCheckBox2 wechatsendmsg.OptionListContCheckBox
+ // OptionListContCheckBox2.Id = "option_id2"
+ // OptionListContCheckBox2.Text = "选择题选项2"
+ // OptionListContCheckBox2.IsChecked = false
+ // OptionListContCheckBoxList = append(OptionListContCheckBoxList, OptionListContCheckBox2)
+
+ // var checkBoxCont wechatsendmsg.CheckBoxCont
+ // checkBoxCont.QuestionKey = "question_key1"
+ // checkBoxCont.Mode = 1
+ // checkBoxCont.OptionList = OptionListContCheckBoxList
+
+ // var submitButton wechatsendmsg.ActionListCont
+ // submitButton.Text = "提交"
+ // submitButton.Key = "key"
+
+ // uuId := publicmethod.GetUUid(5)
+
+ // var sendCont wechatsendmsg.TemMultipleInteraction
+ // sendCont.CardType = "multiple_interaction"
+ // sendCont.Source = sourceText
+ // // sendCont.ActionMenu = ActionMenuCont
+ // sendCont.TaskId = fmt.Sprintf("KPI_%v", uuId)
+ // sendCont.MainTitle = mainTitleCont
// sendCont.QuoteArea = quoteAreaCont
// sendCont.SubTitleText = quoteAreaCont.QuoteText
@@ -442,25 +441,25 @@ func (a *ApiMethod) Shiyan(c *gin.Context) {
// sendCont.HorizontalContentList = horizontalContentListInfoAry
// sendCont.JumpList = jumpListContList
- sendCont.SelectList = buttonSelectionContList
- sendCont.SubmitButton = submitButton
-
- var sendTextTempl wechatsendmsg.SendMultipleInteraction
- sendTextTempl.Touser = "KaiXinGuo" //指定接收消息的成员,成员ID列表;特殊情况:指定为"@all",则向该企业应用的全部成员发送;最多支持1000个
- sendTextTempl.Toparty = "" //指定接收消息的部门,部门ID列表,多个接收者用‘|’分隔,最多支持100个。当touser为"@all"时忽略本参数
- sendTextTempl.Totag = "" //指定接收消息的标签,标签ID列表,多个接收者用‘|’分隔,最多支持100个。当touser为"@all"时忽略本参数
- sendTextTempl.Msgtype = "template_card" //消息类型
- agentIdInt, _ := strconv.ParseInt(overall.CONSTANT_CONFIG.WechatKpi.Agentid, 10, 64)
- sendTextTempl.Agentid = agentIdInt
- sendTextTempl.EnableDuplicateCheck = 0
- sendTextTempl.DuplicateCheckInterval = 1800
- sendTextTempl.TemplateCard = sendCont
- sendTextTempl.EnableIdTrans = 0
-
- callData, err := sendTextTempl.SendMsg("kpi")
- jsonstr, _ := json.Marshal(sendTextTempl)
- fmt.Printf("callData------>%v--------err--------->%v--------->%v\n", callData, err, string(jsonstr))
- publicmethod.Result(0, callData, c)
+ // sendCont.SelectList = buttonSelectionContList
+ // sendCont.SubmitButton = submitButton
+
+ // var sendTextTempl wechatsendmsg.SendMultipleInteraction
+ // sendTextTempl.Touser = "KaiXinGuo" //指定接收消息的成员,成员ID列表;特殊情况:指定为"@all",则向该企业应用的全部成员发送;最多支持1000个
+ // sendTextTempl.Toparty = "" //指定接收消息的部门,部门ID列表,多个接收者用‘|’分隔,最多支持100个。当touser为"@all"时忽略本参数
+ // sendTextTempl.Totag = "" //指定接收消息的标签,标签ID列表,多个接收者用‘|’分隔,最多支持100个。当touser为"@all"时忽略本参数
+ // sendTextTempl.Msgtype = "template_card" //消息类型
+ // agentIdInt, _ := strconv.ParseInt(overall.CONSTANT_CONFIG.WechatKpi.Agentid, 10, 64)
+ // sendTextTempl.Agentid = agentIdInt
+ // sendTextTempl.EnableDuplicateCheck = 0
+ // sendTextTempl.DuplicateCheckInterval = 1800
+ // sendTextTempl.TemplateCard = sendCont
+ // sendTextTempl.EnableIdTrans = 0
+
+ // callData, err := sendTextTempl.SendMsg("kpi")
+ // jsonstr, _ := json.Marshal(sendTextTempl)
+ // fmt.Printf("callData------>%v--------err--------->%v--------->%v\n", callData, err, string(jsonstr))
+ // publicmethod.Result(0, callData, c)
}
// 校正关联维度
diff --git a/api/version1/jurisdiction/jurisdictionpc/power.go b/api/version1/jurisdiction/jurisdictionpc/power.go
index 200c384..1fdabff 100644
--- a/api/version1/jurisdiction/jurisdictionpc/power.go
+++ b/api/version1/jurisdiction/jurisdictionpc/power.go
@@ -3,6 +3,7 @@ package jurisdictionpc
import (
"encoding/json"
"fmt"
+ "key_performance_indicators/models/modelshr"
"key_performance_indicators/models/modelsschool"
"key_performance_indicators/models/modelsstorage"
"key_performance_indicators/models/modelssystempermission"
@@ -126,7 +127,7 @@ func (a *ApiMethod) EditPower(c *gin.Context) {
// 相关系统菜单
func (a *ApiMethod) SystemAboutMenu(c *gin.Context) {
- var receivedValue publicmethod.PublicName
+ var receivedValue GetSystemMenuPower
err := c.ShouldBindJSON(&receivedValue)
if err != nil {
publicmethod.Result(100, err, c)
@@ -151,7 +152,7 @@ func (a *ApiMethod) SystemAboutMenu(c *gin.Context) {
return
}
var menuThree []publicmethod.PowerThree
- // fmt.Printf("ApiUrl------>%v\n", systemPower)
+ // fmt.Printf("ApiUrl------>%v\n", receivedValue)
if systemPower.ApiUrl != "" {
//api入口不为空的情况下采用get访问方式接收数据
htmlByte := publicmethod.CurlGet(systemPower.ApiUrl)
@@ -168,22 +169,43 @@ func (a *ApiMethod) SystemAboutMenu(c *gin.Context) {
}
menuThree = jsonAry.Data
} else {
+ var pointInt []string
+ var operatIon []string
+ var systemEmpowerCont modelssystempermission.Empower
+ err = systemEmpowerCont.GetCont(map[string]interface{}{"`ordid`": receivedValue.OrdId, "`post_id`": receivedValue.PostId, "`system`": systemPower.Coder}, "`point_id`", `operation`)
+ if err == nil {
+ pointInt = strings.Split(systemEmpowerCont.PointId, ",")
+ operatIon = strings.Split(systemEmpowerCont.Operation, ",")
+ }
//api入口为空,采用系统内置获取授权菜单
switch systemPower.Coder {
case "cangchu":
- menuThree = wmsMenuThree()
+ menuThree = wmsMenuThree(pointInt, operatIon)
// fmt.Printf("ApiUrl----2-->%v\n", systemPower.ApiUrl)
default:
//获取绩效考核菜单树
- menuThree = kpiMenuThree()
+ menuThree = kpiMenuThree(pointInt, operatIon)
// fmt.Printf("ApiUrl---1--->%v\n", systemPower.ApiUrl)
}
}
publicmethod.Result(0, menuThree, c)
}
-// kpi菜单树
-func kpiMenuThree() (menuThree []publicmethod.PowerThree) {
+/*
+*
+@ 作者: 秦东
+@ 时间: 2022-11-06 16:02:56
+@ 功能: kpi菜单树
+@ 参数
+
+ #purview 以获得的权限
+ #operatIon 操作点位
+
+@ 返回值
+
+ #
+*/
+func kpiMenuThree(purview, operatIon []string) (menuThree []publicmethod.PowerThree) {
var menuList []modelsschool.SystemMenuSchool
err := overall.CONSTANT_DB_Master.Where("`m_steat` = 1").Order("`m_sort` ASC").Order("`m_id` DESC").Find(&menuList).Error
@@ -195,18 +217,39 @@ func kpiMenuThree() (menuThree []publicmethod.PowerThree) {
var menuSmaillList []publicmethod.MenuContList
for i := 0; i < lenSum; i++ {
var menSmaiCont publicmethod.MenuContList
- menSmaiCont.Id = strconv.FormatInt(menuList[i].Id, 10)
+ idStr := strconv.FormatInt(menuList[i].Id, 10)
+ menSmaiCont.Id = idStr
menSmaiCont.Name = menuList[i].Title
menSmaiCont.ParentId = strconv.FormatInt(menuList[i].ParentId, 10)
menSmaiCont.PathUrl = menuList[i].ApiUrl
+
+ if len(purview) > 0 {
+ if publicmethod.IsInTrue[string](idStr, purview) == true {
+ menSmaiCont.IsTrue = true
+ // fmt.Printf("\n\npurview------>%v------>%v------>%v\n\n", idStr, purview, publicmethod.IsInTrue[string](idStr, purview))
+ }
+ }
menuSmaillList = append(menuSmaillList, menSmaiCont)
}
- menuThree = publicmethod.GetMenuThree(1, "0", menuSmaillList)
+ menuThree = publicmethod.GetMenuThreePeiQuan(1, "0", menuSmaillList, operatIon)
return
}
-// 仓储菜单树
-func wmsMenuThree() (menuThree []publicmethod.PowerThree) {
+/*
+*
+@ 作者: 秦东
+@ 时间: 2022-11-06 16:02:56
+@ 功能: 仓储菜单树
+@ 参数
+
+ #purview 以获得的权限
+ #operatIon 操作点位
+
+@ 返回值
+
+ #
+*/
+func wmsMenuThree(purview, operatIon []string) (menuThree []publicmethod.PowerThree) {
var menuList []modelsstorage.AccesstoAddress
err := overall.CONSTANT_DB_Storage.Where("`state` = 1").Find(&menuList).Error
lenSum := len(menuList)
@@ -216,12 +259,273 @@ func wmsMenuThree() (menuThree []publicmethod.PowerThree) {
var menuSmaillList []publicmethod.MenuContList
for i := 0; i < lenSum; i++ {
var menSmaiCont publicmethod.MenuContList
- menSmaiCont.Id = strconv.FormatInt(menuList[i].Id, 10)
+ idStr := strconv.FormatInt(menuList[i].Id, 10)
+ menSmaiCont.Id = idStr
menSmaiCont.Name = menuList[i].Name
menSmaiCont.ParentId = strconv.FormatInt(int64(menuList[i].Menuparent), 10)
menSmaiCont.PathUrl = menuList[i].Url
+
+ // fmt.Printf("ApiUrl---1--->%v--->%v--->%v\n", idStr, purview, publicmethod.IsInTrue[string](idStr, purview))
+
+ if len(purview) > 0 {
+ if publicmethod.IsInTrue[string](idStr, purview) == true {
+ menSmaiCont.IsTrue = true
+ }
+ }
+
menuSmaillList = append(menuSmaillList, menSmaiCont)
}
menuThree = publicmethod.GetMenuThrees(1, "0", menuSmaillList)
return
}
+
+/*
+*
+@ 作者: 秦东
+@ 时间: 2022-11-07 13:46:06
+@ 功能: 编辑权限新版
+@ 参数
+
+ #
+
+@ 返回值
+
+ #
+*/
+func (a *ApiMethod) EditPowerNew(c *gin.Context) {
+ var receivedValue editPowerStructNew
+ err := c.ShouldBindJSON(&receivedValue)
+ if err != nil {
+ publicmethod.Result(100, err, c)
+ return
+ }
+ if receivedValue.OrdId == "" || receivedValue.OrdId == "0" {
+ publicmethod.Result(1, receivedValue, c, "未知行政组织!不可进行配权")
+ return
+ }
+ if receivedValue.PostId == "" || receivedValue.PostId == "0" {
+ publicmethod.Result(1, receivedValue, c, "未知岗位!不可进行配权")
+ return
+ }
+ if receivedValue.SystemName == "" {
+ publicmethod.Result(1, receivedValue, c, "未知配权系统!不可进行配权")
+ return
+ }
+ if receivedValue.Level == 0 {
+ receivedValue.Level = 2
+ }
+ var orgIdList []int64
+ switch receivedValue.Level {
+ case 2: //本部门
+ orgIdInt, _ := strconv.ParseInt(receivedValue.OrdId, 10, 64)
+ _, _, departmentId, _, _ := publicmethod.GetOrgStructure(orgIdInt)
+ orgIdList = publicmethod.GetDepartmentSun(departmentId, orgIdList)
+ case 3: //本分部
+ orgIdInt, _ := strconv.ParseInt(receivedValue.OrdId, 10, 64)
+ _, companyId, _, _, _ := publicmethod.GetOrgStructure(orgIdInt)
+ orgIdList = publicmethod.GetDepartmentSun(companyId, orgIdList)
+ case 4: //指定行政组织
+ case 5: //所有
+ overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`id`").Where("`state` = 1").Find(&orgIdList)
+ default: //本岗位
+ orgIdInt, _ := strconv.ParseInt(receivedValue.OrdId, 10, 64)
+ orgIdList = append(orgIdList, orgIdInt)
+ }
+ var orgIdListStr string //行政组织
+ if len(orgIdList) > 0 {
+ var orgIdListStrAry []string //
+ for _, ovl := range orgIdList {
+ idStr := strconv.FormatInt(ovl, 10)
+ if publicmethod.IsInTrue[string](idStr, orgIdListStrAry) == false {
+ orgIdListStrAry = append(orgIdListStrAry, idStr)
+ }
+ }
+ orgIdListStr = strings.Join(orgIdListStrAry, ",")
+ }
+
+ var menuList []string //权限点位
+ var menuOperationList []string //操作点位
+ addTime := time.Now().Unix()
+ var empowerCont modelssystempermission.Empower
+ err = empowerCont.GetCont(map[string]interface{}{"`ordid`": receivedValue.OrdId, "`post_id`": receivedValue.PostId, "`system`": receivedValue.SystemName}, "`id`")
+ if len(receivedValue.PowerList) < 1 {
+ if err == nil {
+ err = empowerCont.EiteCont(map[string]interface{}{"`id`": empowerCont.Id}, map[string]interface{}{"`point_id`": "", "`operation`": "", "`level`": receivedValue.Level, "`time`": addTime, "`state`": 1, "`organization`": orgIdListStr})
+ if err != nil {
+ publicmethod.Result(1, err, c, "权限配置失败")
+ return
+ }
+ } else {
+ orgIdInt, _ := strconv.ParseInt(receivedValue.OrdId, 10, 64)
+ empowerCont.OrdId = orgIdInt //行政组织"`
+ postIdInt, _ := strconv.ParseInt(receivedValue.PostId, 10, 64)
+ empowerCont.PostId = postIdInt //岗位ID"`
+ empowerCont.System = receivedValue.SystemName //系统"`
+ empowerCont.PointId = strings.Join(menuList, ",") //权限点位"`
+ empowerCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
+ empowerCont.Time = addTime //创建时间"`
+ empowerCont.Level = receivedValue.Level //授权范围等级(1:本部门;2:本分部;3:所有)"`
+ empowerCont.Organization = orgIdListStr //行政组织"`
+ empowerCont.Operation = strings.Join(menuOperationList, ",") //操作点位
+ err = overall.CONSTANT_DB_System_Permission.Create(&empowerCont).Error
+ if err != nil {
+ publicmethod.Result(1, err, c, "权限配置失败")
+ return
+ }
+ }
+ } else {
+ var munePowerList empowerSync
+ for _, v := range receivedValue.PowerList {
+ // if v.Id == "1" {
+ syncSeting.Add(1)
+ go munePowerList.GetAllSunCont(v)
+ // }
+
+ }
+ syncSeting.Wait()
+ menuIdList, menuOperIdList := munePowerList.readDataLock()
+ // fmt.Printf("\n\n%v-------结果-------->%v\n", menuIdList, menuOperIdList)
+ // publicmethod.Result(0, receivedValue.PowerList, c)
+ // return
+ // outData := publicmethod.MapOut[string]()
+ // outData["menuIdList"] = menuIdList
+ // outData["menuOperIdList"] = menuOperIdList
+ // publicmethod.Result(0, outData, c)
+ menuIdListStr := strings.Join(menuIdList, ",")
+ menuOperIdListStr := strings.Join(menuOperIdList, ",")
+ if err == nil {
+ err = empowerCont.EiteCont(map[string]interface{}{"`id`": empowerCont.Id}, map[string]interface{}{"`point_id`": menuIdListStr, "`operation`": menuOperIdListStr, "`level`": receivedValue.Level, "`time`": addTime, "`state`": 1, "`organization`": orgIdListStr})
+ if err != nil {
+ publicmethod.Result(1, err, c, "权限配置失败")
+ return
+ }
+ } else {
+ orgIdInt, _ := strconv.ParseInt(receivedValue.OrdId, 10, 64)
+ empowerCont.OrdId = orgIdInt //行政组织"`
+ postIdInt, _ := strconv.ParseInt(receivedValue.PostId, 10, 64)
+ empowerCont.PostId = postIdInt //岗位ID"`
+ empowerCont.System = receivedValue.SystemName //系统"`
+ empowerCont.PointId = menuIdListStr //权限点位"`
+ empowerCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
+ empowerCont.Time = addTime //创建时间"`
+ empowerCont.Level = receivedValue.Level //授权范围等级(1:本部门;2:本分部;3:所有)"`
+ empowerCont.Organization = orgIdListStr //行政组织"`
+ empowerCont.Operation = menuOperIdListStr //操作点位
+ err = overall.CONSTANT_DB_System_Permission.Create(&empowerCont).Error
+ if err != nil {
+ publicmethod.Result(1, err, c, "权限配置失败")
+ return
+ }
+ }
+ }
+
+ publicmethod.Result(0, receivedValue, c)
+}
+
+/*
+*
+@ 作者: 秦东
+@ 时间: 2022-11-07 15:34:48
+@ 功能: 获取菜单所有操作
+@ 参数
+
+ #
+
+@ 返回值
+
+ #
+*/
+func (e *empowerSync) GetAllSunCont(menuList publicmethod.PowerThree) {
+ e.mutext.Lock()
+ defer e.mutext.Unlock()
+ if menuList.IsTrue == true {
+ if publicmethod.IsInTrue[string](menuList.Id, e.menuList) == false {
+ e.menuList = append(e.menuList, menuList.Id)
+ }
+ }
+ if len(menuList.MenuOperation) > 0 {
+ for _, v := range menuList.MenuOperation {
+ if v.IsTrue == true {
+ if publicmethod.IsInTrue[string](v.Id, e.menuOperationList) == false {
+ e.menuOperationList = append(e.menuOperationList, v.Id)
+ }
+
+ }
+ }
+ }
+ if len(menuList.Child) > 0 {
+ var menuId []string
+ var menuOperId []string
+ menuIdList, menuOperIdList := DiGuiMenuList(menuList.Child, menuId, menuOperId)
+ // // fmt.Printf("\n\nmenuIdList------%v----->%v\n\n", menuList.Id, menuList.Child)
+ // fmt.Printf("\n\nmenuOperIdList----%v------->%v------->%v\n\n", menuList.Id, menuIdList, menuOperIdList)
+ if len(menuIdList) > 0 {
+ for _, mv := range menuIdList {
+ if publicmethod.IsInTrue[string](mv, e.menuList) == false {
+ e.menuList = append(e.menuList, mv)
+ }
+ }
+ }
+ if len(menuOperIdList) > 0 {
+ for _, mvo := range menuOperIdList {
+ // fmt.Printf("menuOper--Fuji->%v---->%v\n", menuList.Id, mvo)
+ // e.menuOperationList = append(e.menuOperationList, mvo)
+ if publicmethod.IsInTrue[string](mvo, e.menuOperationList) == false {
+ e.menuOperationList = append(e.menuOperationList, mvo)
+ }
+ }
+ }
+ }
+ syncSeting.Done()
+}
+
+/*
+*
+@ 作者: 秦东
+@ 时间: 2022-11-07 16:15:58
+@ 功能: 递归菜单选择操作
+@ 参数
+
+ #
+
+@ 返回值
+
+ #
+*/
+func DiGuiMenuList(menuList []publicmethod.PowerThree, menuId, menuOperId []string) (menuIdList, menuOperIdList []string) {
+
+ // fmt.Printf("\n\nmenuIdList----222222--%v----->%v----->%v\n\n", menuId, menuOperId, menuList)
+
+ for _, v := range menuList {
+ // fmt.Printf("\n\nmenuIdList----33333--%v----->%v----->%v\n\n", menuId, menuOperId, v.IsTrue)
+ if v.IsTrue == true {
+ fmt.Printf("\n\nmenuIdList----444--%v----->%v----->%v\n\n", menuId, menuOperId, v.Id)
+ menuIdList = append(menuIdList, v.Id)
+ for _, menuCont := range menuId {
+ if publicmethod.IsInTrue[string](menuCont, menuIdList) == false {
+ menuIdList = append(menuIdList, menuCont)
+ }
+ }
+ }
+ if len(v.MenuOperation) > 0 {
+ for _, vm := range v.MenuOperation {
+ if vm.IsTrue == true {
+
+ menuOperIdList = append(menuOperIdList, vm.Id)
+ for _, menuContOper := range menuOperId {
+ if publicmethod.IsInTrue[string](menuContOper, menuOperIdList) == false {
+ menuOperIdList = append(menuOperIdList, menuContOper)
+ }
+ }
+
+ }
+ }
+ }
+ if len(v.Child) > 0 {
+ // fmt.Printf("menuOper--zijian->%v---->%v\n", v.Id, v.Id)
+ menuIdList, menuOperIdList = DiGuiMenuList(v.Child, menuIdList, menuOperIdList)
+ }
+ }
+ // fmt.Printf("menuOper--jieshuzhi->%v---->%v\n", menuIdList, menuOperIdList)
+ return
+}
diff --git a/api/version1/jurisdiction/jurisdictionpc/systemrole.go b/api/version1/jurisdiction/jurisdictionpc/systemrole.go
new file mode 100644
index 0000000..40121e3
--- /dev/null
+++ b/api/version1/jurisdiction/jurisdictionpc/systemrole.go
@@ -0,0 +1,204 @@
+package jurisdictionpc
+
+import (
+ "key_performance_indicators/models/modelssystempermission"
+ "key_performance_indicators/overall"
+ "key_performance_indicators/overall/publicmethod"
+ "time"
+
+ "github.com/gin-gonic/gin"
+)
+
+//系统角色处理
+
+func (a *ApiMethod) AddSystemRole(c *gin.Context) {
+ var receivedValue systemRole
+ err := c.ShouldBindJSON(&receivedValue)
+ if err != nil {
+ publicmethod.Result(100, err, c)
+ return
+ }
+ if receivedValue.Name == "" {
+ publicmethod.Result(101, receivedValue, c)
+ return
+ }
+ if receivedValue.Sort == 0 {
+ receivedValue.Sort = 50
+ }
+ var systemRoleCont modelssystempermission.SystemRole
+ err = systemRoleCont.GetCont(map[string]interface{}{"`name`": receivedValue.Name}, "`id`")
+ if err == nil {
+ publicmethod.Result(103, systemRoleCont, c)
+ return
+ }
+ systemRoleCont.Name = receivedValue.Name
+ systemRoleCont.Sort = receivedValue.Sort
+ systemRoleCont.State = 1
+ systemRoleCont.Time = time.Now().Unix()
+ err = overall.CONSTANT_DB_System_Permission.Create(&systemRoleCont).Error
+ if err != nil {
+ publicmethod.Result(104, err, c)
+ return
+ }
+ publicmethod.Result(0, err, c)
+}
+
+/*
+*
+@ 作者: 秦东
+@ 时间: 2022-11-09 08:30:04
+@ 功能: 系统角色编辑
+@ 参数
+
+ #Id 项目ID
+ #Name 角色名称
+ #Sort 角色排序
+
+@ 返回值
+
+ #
+*/
+func (a *ApiMethod) EditSystemRole(c *gin.Context) {
+ var receivedValue editSystemRoleCont
+ err := c.ShouldBindJSON(&receivedValue)
+ if err != nil {
+ publicmethod.Result(100, err, c)
+ return
+ }
+ if receivedValue.Id == "" {
+ publicmethod.Result(101, receivedValue, c)
+ return
+ }
+ if receivedValue.Name == "" {
+ publicmethod.Result(101, receivedValue, c)
+ return
+ }
+ if receivedValue.Sort == 0 {
+ receivedValue.Sort = 50
+ }
+ var systemRoleCont modelssystempermission.SystemRole
+ err = systemRoleCont.GetCont(map[string]interface{}{"`id`": receivedValue.Id}, "`name`")
+ if err != nil {
+ publicmethod.Result(107, err, c)
+ return
+ }
+
+ editCont := publicmethod.MapOut[string]()
+ if receivedValue.Sort != systemRoleCont.Sort {
+ editCont["`sort`"] = receivedValue.Sort
+
+ }
+ if systemRoleCont.Name != receivedValue.Name {
+ err = systemRoleCont.GetCont(map[string]interface{}{"`name`": receivedValue.Name}, "`id`")
+ if err == nil {
+ publicmethod.Result(103, systemRoleCont, c)
+ return
+ }
+ editCont["`name`"] = receivedValue.Name
+ }
+ if len(editCont) > 0 {
+ editCont["`time`"] = time.Now().Unix()
+ editCont["`state`"] = 1
+ err = systemRoleCont.EiteCont(map[string]interface{}{"`id`": receivedValue.Id}, editCont)
+ if err != nil {
+ publicmethod.Result(106, err, c)
+ return
+ }
+ }
+ publicmethod.Result(0, systemRoleCont, c)
+}
+
+/*
+*
+@ 作者: 秦东
+@ 时间: 2022-11-09 08:41:20
+@ 功能: 角色列表
+@ 参数
+
+ #
+
+@ 返回值
+
+ #
+*/
+func (a *ApiMethod) SystemRoleList(c *gin.Context) {
+ var receivedValue systemRoleContList
+ c.ShouldBindJSON(&receivedValue)
+ var systemRoleInfoList []modelssystempermission.SystemRole
+ gormDb := overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.SystemRole{}).Where("`state` BETWEEN ? AND ?", 1, 2)
+ if receivedValue.Name != "" {
+ gormDb = gormDb.Where("`name` LIKE ?", "%"+receivedValue.Name+"%")
+ }
+ err := gormDb.Order("`sort` ASC").Order("`id` DESC").Find(&systemRoleInfoList)
+ if err != nil {
+ publicmethod.Result(107, err, c)
+ return
+ }
+ publicmethod.Result(0, systemRoleInfoList, c)
+}
+
+/*
+*
+@ 作者: 秦东
+@ 时间: 2022-11-09 08:52:56
+@ 功能: 编辑角色状态
+@ 参数
+
+ #
+
+@ 返回值
+
+ #
+*/
+func (a *ApiMethod) EditSystemRoleState(c *gin.Context) {
+ var receivedValue publicmethod.PublicState
+ err := c.ShouldBindJSON(&receivedValue)
+ if err != nil {
+ publicmethod.Result(100, err, c)
+ return
+ }
+ if receivedValue.Id == "" {
+ publicmethod.Result(101, receivedValue, c)
+ return
+ }
+ if receivedValue.State == 0 {
+ receivedValue.State = 2
+ }
+ wheAry := publicmethod.MapOut[string]()
+ wheAry["`id`"] = receivedValue.Id
+ var systemRoleCont modelssystempermission.SystemRole
+ err = systemRoleCont.GetCont(wheAry, "`state`")
+ if err != nil {
+ publicmethod.Result(107, err, c)
+ return
+ }
+
+ if receivedValue.State != 3 {
+ editCont := publicmethod.MapOut[string]()
+ if receivedValue.State != systemRoleCont.State {
+ editCont["`state`"] = receivedValue.State
+ }
+ if len(editCont) > 0 {
+ editCont["`time`"] = time.Now().Unix()
+ err = systemRoleCont.EiteCont(wheAry, editCont)
+ }
+ } else {
+ if receivedValue.IsTrue != 1 {
+ editCont := publicmethod.MapOut[string]()
+ if receivedValue.State != systemRoleCont.State {
+ editCont["`state`"] = receivedValue.State
+ }
+ if len(editCont) > 0 {
+ editCont["`time`"] = time.Now().Unix()
+ err = systemRoleCont.EiteCont(wheAry, editCont)
+ }
+ } else {
+ err = systemRoleCont.DelCont(wheAry)
+ }
+ }
+ if err != nil {
+ publicmethod.Result(106, err, c)
+ return
+ }
+ publicmethod.Result(0, err, c)
+}
diff --git a/api/version1/jurisdiction/jurisdictionpc/type.go b/api/version1/jurisdiction/jurisdictionpc/type.go
index 11b5329..c6edbcc 100644
--- a/api/version1/jurisdiction/jurisdictionpc/type.go
+++ b/api/version1/jurisdiction/jurisdictionpc/type.go
@@ -2,12 +2,30 @@ package jurisdictionpc
import (
"key_performance_indicators/overall/publicmethod"
+ "sync"
"github.com/gin-gonic/gin"
)
type ApiMethod struct{}
+// 协程设置
+var syncSeting = sync.WaitGroup{}
+
+// 授权协程操作
+type empowerSync struct {
+ menuList []string
+ menuOperationList []string
+ mutext sync.RWMutex
+}
+
+// 读取岗位指标协程数据
+func (d *empowerSync) readDataLock() ([]string, []string) {
+ d.mutext.RLock()
+ defer d.mutext.RUnlock()
+ return d.menuList, d.menuOperationList
+}
+
// 权限配置
func (a *ApiMethod) Index(c *gin.Context) {
outputCont := publicmethod.MapOut[string]()
@@ -67,3 +85,36 @@ type callBackUrlMenu struct {
Msg string `json:"msg"`
Data []publicmethod.PowerThree `json:"data"`
}
+
+// 获取系统菜单权限
+type GetSystemMenuPower struct {
+ publicmethod.PublicName //系统标识符
+ OrdId string `json:"ordid"` //行政组织
+ PostId string `json:"postid"` //岗位
+}
+
+// 添加权限参数
+type editPowerStructNew struct {
+ OrdId string `json:"ordid"` //行政组织
+ PostId string `json:"postid"` //岗位
+ SystemName string `json:"systemname"` //系统识别符
+ Level int `json:"level"` //授权范围等级(1:本岗位;2:本部门;3:本分部;4:指定行政组织;5:所有)
+ PowerList []publicmethod.PowerThree `json:"power"` //权限列表
+}
+
+// 系统角色通用
+type systemRole struct {
+ publicmethod.PublicName
+ publicmethod.PublicSort
+}
+
+// 编辑系统角色
+type editSystemRoleCont struct {
+ publicmethod.PublicId
+ systemRole
+}
+
+// 系统角色列表
+type systemRoleContList struct {
+ publicmethod.PublicName
+}
diff --git a/apirouter/v1/systempower/pc.go b/apirouter/v1/systempower/pc.go
index 7fdd3aa..a517f25 100644
--- a/apirouter/v1/systempower/pc.go
+++ b/apirouter/v1/systempower/pc.go
@@ -12,16 +12,19 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) {
var methodBinding = version1.AppApiEntry.JurisdictionpcApi
{
- apiRouter.GET("", methodBinding.Index) //入口
- apiRouter.POST("", methodBinding.Index) //入口
- apiRouter.POST("edit_power", methodBinding.EditPower) //编辑权限
-
+ apiRouter.GET("", methodBinding.Index) //入口
+ apiRouter.POST("", methodBinding.Index) //入口
+ apiRouter.POST("edit_power", methodBinding.EditPower) //编辑权限
+ apiRouter.POST("edit_power_new", methodBinding.EditPowerNew) //编辑权限
+ //系统
apiRouter.POST("add_system", methodBinding.AddSystem) //添加应用系统
apiRouter.POST("system_list", methodBinding.SystemList) //系统列表
apiRouter.POST("edit_system", methodBinding.EditSystem) //编辑应用系统信息
apiRouter.POST("edit_state_of_del", methodBinding.EditStateOfDel) //更改状态或删除
-
//相关系统菜单
apiRouter.POST("system_about_menu", methodBinding.SystemAboutMenu) //系统菜单
+
+ //角色
+
}
}
diff --git a/apirouter/verifyLogin/route.go b/apirouter/verifyLogin/route.go
index 88eba51..1b88bf7 100644
--- a/apirouter/verifyLogin/route.go
+++ b/apirouter/verifyLogin/route.go
@@ -21,5 +21,14 @@ func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) {
apiRouter.POST("login_not_verify", methodBinding.ScanCodeLoginNotVerify) //登录(无验证码)
apiRouter.POST("verify_empower_istrue", methodBinding.VerifyEmpowerIsTrue) //验证授权是否过期
+
+ apiRouter.POST("get_work_wechat_jsapi_config", methodBinding.GetWorkWechatJsApiConfig) //获取企业微信jsapi_ticket
+ apiRouter.GET("authuser", methodBinding.AuthenticationUser) //获取身份认证
+ apiRouter.GET("callbackauthuser", methodBinding.CallBackAuthUser) //企业微信身份回调认证
+
+ apiRouter.POST("laissezpasser", methodBinding.LaissezPasser) //免登录
+
+ apiRouter.GET("scan_qrcode_callback", methodBinding.ScanQrCodeCallBackAuthUser) //扫码登录
+
}
}
diff --git a/config/configApp/server.go b/config/configApp/server.go
index d3881f3..60d50e8 100644
--- a/config/configApp/server.go
+++ b/config/configApp/server.go
@@ -20,6 +20,7 @@ type appsetup struct {
DefaultPassword string `mapstructure:"password" json:"password" yaml:"password"`
PreFix string `mapstructure:"prefix" json:"prefix" yaml:"prefix"`
WebUrl string `mapstructure:"weburl" json:"weburl" yaml:"weburl"`
+ PcbUrl string `mapstructure:"pcurl" json:"pcurl" yaml:"pcurl"`
}
//日志配置
diff --git a/middleware/wechatapp/wechatstatice/method.go b/middleware/wechatapp/wechatstatice/method.go
index ef1471f..ba1063b 100644
--- a/middleware/wechatapp/wechatstatice/method.go
+++ b/middleware/wechatapp/wechatstatice/method.go
@@ -13,13 +13,65 @@ import (
/*
获取企业微信token
@systemApp 系统
+@key 身份KEy
+@isAgain 重新授权 1:否,2:是
*/
-func GetWechatToken(systemApp string) (token string, err error) {
+func GetWechatToken(systemApp string, isAgain int) (token string, err error) {
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS3)
companyId := overall.CONSTANT_CONFIG.WechatCompany.CompanyId
redisFileKey := fmt.Sprintf("Wechat:GainToken:%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, companyId)
var secretStr string
switch systemApp {
+ case "kpi":
+ redisFileKey = fmt.Sprintf("%v_%v_%v_%v", redisFileKey, systemApp, overall.CONSTANT_CONFIG.WechatKpi.Agentid)
+ secretStr = overall.CONSTANT_CONFIG.WechatKpi.Secret
+ case "school":
+ redisFileKey = fmt.Sprintf("%v_%v_%v_%v", redisFileKey, systemApp, overall.CONSTANT_CONFIG.WechatSchool.Agentid)
+ secretStr = overall.CONSTANT_CONFIG.WechatSchool.Secret
+ default:
+ redisFileKey = fmt.Sprintf("%v_%v_%v", redisFileKey, systemApp)
+ }
+ isTrue, token := redisClient.Get(redisFileKey)
+ // fmt.Printf("\n\n isTrue:%v \n\n token:%v \n\n", isTrue, token)
+ if isAgain != 2 {
+ if isTrue == true {
+ err = nil
+ return
+ }
+ }
+
+ //重新获取token
+ getTokenUrl := "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=" + companyId + "&corpsecret=" + secretStr
+ tokenByte := publicmethod.CurlGet(getTokenUrl)
+ var callBackCont WeChatCallBack
+ err = json.Unmarshal(tokenByte, &callBackCont)
+
+ // fmt.Printf("\n\n callBackCont:%v \n\n", callBackCont)
+
+ if err != nil {
+ return
+ }
+ if callBackCont.Errcode != 0 {
+ return
+ }
+ token = callBackCont.Accesstoken
+ redisClient.SetRedisTime(7200)
+ redisClient.Set(redisFileKey, token)
+ return
+}
+
+/*
+获取企业微信token
+@systemApp 系统
+@key 身份KEy
+@isAgain 重新授权 1:否,2:是
+*/
+func GetWechatTokenEs(systemApp, key string, isAgain int) (token string, err error) {
+ redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS3)
+ companyId := overall.CONSTANT_CONFIG.WechatCompany.CompanyId
+ redisFileKey := fmt.Sprintf("Wechat:GainToken:%v_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, companyId, key)
+ var secretStr string
+ switch systemApp {
case "kpi":
redisFileKey = fmt.Sprintf("%v_%v_%v", redisFileKey, systemApp, overall.CONSTANT_CONFIG.WechatKpi.Agentid)
secretStr = overall.CONSTANT_CONFIG.WechatKpi.Secret
@@ -30,15 +82,22 @@ func GetWechatToken(systemApp string) (token string, err error) {
redisFileKey = fmt.Sprintf("%v_%v", redisFileKey, systemApp)
}
isTrue, token := redisClient.Get(redisFileKey)
- if isTrue == true {
- err = nil
- return
+ // fmt.Printf("\n\n isTrue:%v \n\n token:%v \n\n", isTrue, token)
+ if isAgain != 2 {
+ if isTrue == true {
+ err = nil
+ return
+ }
}
+
//重新获取token
getTokenUrl := "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=" + companyId + "&corpsecret=" + secretStr
tokenByte := publicmethod.CurlGet(getTokenUrl)
- var callBackCont weChatCallBack
+ var callBackCont WeChatCallBack
err = json.Unmarshal(tokenByte, &callBackCont)
+
+ // fmt.Printf("\n\n callBackCont:%v \n\n", callBackCont)
+
if err != nil {
return
}
@@ -68,7 +127,7 @@ func GetWechatToken(systemApp string) (token string, err error) {
#err 系统信息
*/
func GetSendMsgTokenUrl(systemApp, class string) (sendUrl string, token string, err error) {
- token, err = GetWechatToken(systemApp)
+ token, err = GetWechatToken(systemApp, 1)
if err != nil {
return
}
diff --git a/middleware/wechatapp/wechatstatice/type.go b/middleware/wechatapp/wechatstatice/type.go
index b14913d..63a47bd 100644
--- a/middleware/wechatapp/wechatstatice/type.go
+++ b/middleware/wechatapp/wechatstatice/type.go
@@ -1,7 +1,7 @@
package wechatstatice
//组织架构返回统类
-type weChatCallBack struct {
+type WeChatCallBack struct {
RevokeMsgSendCallBack
Accesstoken string `json:"access_token"`
Expiresin int64 `json:"expires_in"`
@@ -55,3 +55,12 @@ type UpdateButtonCallBackMsg struct {
RevokeMsgSendCallBack
Invaliduser []string `json:"invaliduser"` //不合法的userid,不区分大小写,统一转为小写
}
+
+//企业微信身份认证
+type WorkWechatUserAuter struct {
+ RevokeMsgSendCallBack
+ Userid string `json:"userid"` // 成员UserID。若需要获得用户详情信息,可调用通讯录接口:读取成员。如果是互联企业/企业互联/上下游,则返回的UserId格式如:CorpId/userid
+ UserTicket string `json:"user_ticket"` //成员票据,最大为512字节,有效期为1800s。scope为snsapi_privateinfo,且用户在应用可见范围之内时返回此参数。后续利用该参数可以获取用户信息或敏感信息,参见"获取访问用户敏感信息"。暂时不支持上下游或/企业互联场景
+ OpenId string `json:"openid"` //非企业成员的标识,对当前企业唯一。不超过64字节
+ ExternalUserid string `json:"external_userid"` //外部联系人id,当且仅当用户是企业的客户,且跟进人在应用的可见范围内时返回。如果是第三方应用调用,针对同一个客户,同一个服务商不同应用获取到的id相同
+}
diff --git a/models/modelsschool/system_role.go b/models/modelsschool/system_role.go
index 7db4331..ee91f0c 100644
--- a/models/modelsschool/system_role.go
+++ b/models/modelsschool/system_role.go
@@ -1,6 +1,9 @@
package modelsschool
-import "key_performance_indicators/overall"
+import (
+ "key_performance_indicators/overall"
+ "strings"
+)
type SystemRole struct {
Id int64 `json:"id" gorm:"column:r_id;type:bigint(20) unsigned;not null;comment:Id"`
@@ -20,19 +23,21 @@ func (SystemRole *SystemRole) TableName() string {
return "system_role"
}
-//获取详情
+// 获取详情
func (cont *SystemRole) GetCont(where interface{}, filed ...string) error {
gormDb := overall.CONSTANT_DB_Master.Where(where)
if len(filed) > 0 {
- for _, v := range filed {
- gormDb = gormDb.Select(v)
- }
+ // for _, v := range filed {
+ // gormDb = gormDb.Select(v)
+ // }
+ filedStr := strings.Join(filed, ",")
+ gormDb = gormDb.Select(filedStr)
}
err := gormDb.First(&cont).Error
return err
}
-//编辑内容
+// 编辑内容
func (cont *SystemRole) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_Master.Model(&cont).Where(whereMap).Updates(saveData).Error
return
diff --git a/models/modelssystempermission/empower.go b/models/modelssystempermission/empower.go
index f6d5735..0768b07 100644
--- a/models/modelssystempermission/empower.go
+++ b/models/modelssystempermission/empower.go
@@ -16,6 +16,7 @@ type Empower struct {
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"`
Level int `json:"level" gorm:"column:level;type:int(1) unsigned;default:1;not null;comment:授权范围等级(1:本部门;2:本分部;3:所有)"`
Organization string `json:"organization" gorm:"column:organization;type:longtext;comment:行政组织"`
+ Operation string `json:"operation" gorm:"column:operation;type:longtext;comment:操作点位"`
}
func (Empower *Empower) TableName() string {
diff --git a/models/modelssystempermission/role_empower.go b/models/modelssystempermission/role_empower.go
new file mode 100644
index 0000000..0b011d9
--- /dev/null
+++ b/models/modelssystempermission/role_empower.go
@@ -0,0 +1,63 @@
+package modelssystempermission
+
+import (
+ "key_performance_indicators/overall"
+ "strings"
+)
+
+// 权限配置
+type RoleEmpower struct {
+ Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"`
+ RoleId int64 `json:"roleid" gorm:"column:role_id;type:bigint(20) unsigned;default:0;not null;comment:行政组织"`
+ System string `json:"system" gorm:"column:system;type:varchar(255) ;comment:系统"`
+ PointId string `json:"pointid" gorm:"column:point_id;type:longtext;comment:权限点位"`
+ Operation string `json:"operation" gorm:"column:operation;type:longtext;comment:操作点位"`
+ State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"`
+ Level int `json:"level" gorm:"column:level;type:int(1) unsigned;default:1;not null;comment:授权范围等级(1:本部门;2:本分部;3:所有)"`
+ Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"`
+}
+
+func (RoleEmpower *RoleEmpower) TableName() string {
+ return "role_RoleEmpower"
+}
+
+// 编辑内容
+func (cont *RoleEmpower) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
+ err = overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Updates(saveData).Error
+ return
+}
+
+// 获取内容
+func (cont *RoleEmpower) GetCont(whereMap interface{}, field ...string) (err error) {
+ gormDb := overall.CONSTANT_DB_System_Permission.Model(&cont)
+ if len(field) > 0 {
+ fieldStr := strings.Join(field, ",")
+ gormDb = gormDb.Select(fieldStr)
+ }
+ gormDb = gormDb.Where(whereMap)
+ err = gormDb.First(&cont).Error
+ return
+}
+
+// 根据条件获取总数
+func (cont *RoleEmpower) CountCont(whereMap interface{}) (countId int64) {
+ overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Count(&countId)
+ return
+}
+
+// 读取全部信息
+func (cont *RoleEmpower) ContMap(whereMap interface{}, field ...string) (countAry []RoleEmpower, err error) {
+ gormDb := overall.CONSTANT_DB_System_Permission.Model(&cont)
+ if len(field) > 0 {
+ fieldStr := strings.Join(field, ",")
+ gormDb = gormDb.Select(fieldStr)
+ }
+ err = gormDb.Where(whereMap).Find(&countAry).Error
+ return
+}
+
+// 删除内容
+func (cont *RoleEmpower) DelCont(whereMap interface{}) (err error) {
+ err = overall.CONSTANT_DB_System_Permission.Where(whereMap).Delete(&cont).Error
+ return
+}
diff --git a/models/modelssystempermission/system_role.go b/models/modelssystempermission/system_role.go
new file mode 100644
index 0000000..e0ca03d
--- /dev/null
+++ b/models/modelssystempermission/system_role.go
@@ -0,0 +1,60 @@
+package modelssystempermission
+
+import (
+ "key_performance_indicators/overall"
+ "strings"
+)
+
+// 系统角色表
+type SystemRole struct {
+ Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"`
+ Name string `json:"name" gorm:"column:name;type:varchar(255) ;comment:系统名称"`
+ State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"`
+ Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"`
+ Sort int `json:"sort" gorm:"column:sort;type:int(5) unsigned;default:50;not null;comment:排序"`
+}
+
+func (SystemRole *SystemRole) TableName() string {
+ return "system_role"
+}
+
+// 编辑内容
+func (cont *SystemRole) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
+ err = overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Updates(saveData).Error
+ return
+}
+
+// 获取内容
+func (cont *SystemRole) GetCont(whereMap interface{}, field ...string) (err error) {
+ gormDb := overall.CONSTANT_DB_System_Permission.Model(&cont)
+ if len(field) > 0 {
+ fieldStr := strings.Join(field, ",")
+ gormDb = gormDb.Select(fieldStr)
+ }
+ gormDb = gormDb.Where(whereMap)
+ err = gormDb.First(&cont).Error
+ return
+}
+
+// 根据条件获取总数
+func (cont *SystemRole) CountCont(whereMap interface{}) (countId int64) {
+ overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Count(&countId)
+ return
+}
+
+// 读取全部信息
+func (cont *SystemRole) ContMap(whereMap interface{}, field ...string) (countAry []SystemRole, err error) {
+ gormDb := overall.CONSTANT_DB_System_Permission.Model(&cont)
+ if len(field) > 0 {
+ fieldStr := strings.Join(field, ",")
+ gormDb = gormDb.Select(fieldStr)
+ }
+ err = gormDb.Where(whereMap).Find(&countAry).Error
+ return
+}
+
+// 删除内容
+func (cont *SystemRole) DelCont(whereMap interface{}) (err error) {
+ err = overall.CONSTANT_DB_System_Permission.Where(whereMap).Delete(&cont).Error
+ return
+}
diff --git a/overall/publicmethod/technique.go b/overall/publicmethod/technique.go
index 672db31..99466ba 100644
--- a/overall/publicmethod/technique.go
+++ b/overall/publicmethod/technique.go
@@ -852,6 +852,7 @@ func GetMenuThree(jurisd int, parentId string, threeData []MenuContList) []Power
node.Id = v.Id
node.Name = v.Name
node.ParentId = v.ParentId
+ node.IsTrue = v.IsTrue
isTrue, menuOper := MenuOperation(jurisd, v.Id)
if isTrue == true {
node.MenuOperation = menuOper
@@ -898,6 +899,7 @@ func GetMenuThrees(jurisd int, parentId string, threeData []MenuContList) []Powe
node.Name = v.Name
node.ParentId = v.ParentId
node.Child = child
+ node.IsTrue = v.IsTrue
// fmt.Printf("GetMenuThree-22222--%v--->%v\n", v.Id, node)
treeList = append(treeList, node)
}
@@ -1289,3 +1291,63 @@ func StringToTimeIng(unit, str string) (res time.Time) {
res, _ = time.ParseInLocation(layout, str, loc)
return
}
+
+// 递归无限极菜单树
+/*
+@jurisd 起始位置
+@parentId 上级ID
+@threeData 结果值
+@oper 已付权限
+*/
+func GetMenuThreePeiQuan(jurisd int, parentId string, threeData []MenuContList, oper []string) []PowerThree {
+ treeList := []PowerThree{}
+ for _, v := range threeData {
+ if v.ParentId == parentId {
+ child := GetMenuThreePeiQuan(jurisd, v.Id, threeData, oper)
+ var node PowerThree
+ node.Id = v.Id
+ node.Name = v.Name
+ node.ParentId = v.ParentId
+ node.IsTrue = v.IsTrue
+ isTrue, menuOper := MenuOperationPeiQuan(jurisd, v.Id, oper)
+ if isTrue == true {
+ node.MenuOperation = menuOper
+ // fmt.Printf("GetMenuThree-1111--%v--->%v\n", v.Id, menuOper)
+ }
+ node.Child = child
+ treeList = append(treeList, node)
+ }
+ }
+ return treeList
+}
+
+// 配权
+// 获取菜单操作项目
+/*
+@jurisd 起始位置
+@menuId 菜单ID
+@oper 已付权限
+*/
+func MenuOperationPeiQuan(jurisd int, menuId string, oper []string) (isTrue bool, operation []MenuContList) {
+ var operList []modelsschool.MenuOperation
+ isTrue = false
+ operErr := overall.CONSTANT_DB_Master.Where("`menu_id` = ?", menuId).Order("oper_id desc").Find(&operList).Error
+ if operErr != nil || len(operList) < 1 {
+ return
+ }
+
+ isTrue = true
+ for i := 0; i < len(operList); i++ {
+ var menSmaiCont MenuContList
+ idStr := strconv.FormatInt(operList[i].OperId, 10)
+ menSmaiCont.Id = idStr
+ menSmaiCont.Name = operList[i].OperTitle
+ menSmaiCont.ParentId = strconv.FormatInt(operList[i].MenuId, 10)
+ if IsInTrue[string](idStr, oper) == true {
+ menSmaiCont.IsTrue = true
+ }
+ operation = append(operation, menSmaiCont)
+ }
+ // fmt.Printf("ApiUrl---%v--->%v--->%v--->%v\n", menuId, isTrue, operErr, operList)
+ return
+}
diff --git a/overall/publicmethod/type.go b/overall/publicmethod/type.go
index 3076357..ebb9e02 100644
--- a/overall/publicmethod/type.go
+++ b/overall/publicmethod/type.go
@@ -33,6 +33,11 @@ type PublicName struct {
Name string `json:"name"`
}
+// 通用排序结构体
+type PublicSort struct {
+ Sort int `json:"sort"`
+}
+
// 通用编辑状态结构体
type PublicState struct {
PublicId
@@ -70,17 +75,18 @@ type empowerOut struct {
// 菜单列表
type MenuContList struct {
- PublicId
- PublicName
- ParentId string `json:"parentid"`
- PathUrl string `json:"pathurl"`
+ PublicId //菜单ID
+ PublicName //菜单名称
+ ParentId string `json:"parentid"` //上级
+ PathUrl string `json:"pathurl"` //访问路径
+ IsTrue bool `json:"istrue"` //是否已授权 true:授权,false:未授权
}
// 权限菜单树
type PowerThree struct {
MenuContList
- Child []PowerThree `json:"child"`
- MenuOperation []MenuContList `json:"menuOperation"`
+ Child []PowerThree `json:"child"` //下级菜单
+ MenuOperation []MenuContList `json:"menuOperation"` //本级菜单操作
}
// 部门判断列表