Browse Source

主表计算引擎

li_v1
超级管理员 2 years ago
parent
commit
f0ab2b6973
  1. 2
      api/version1/entry.go
  2. 26
      api/version1/publicapi/api.go
  3. 262
      api/version1/taskplatform/matsFormula/formula.go
  4. 43
      api/version1/taskplatform/matsFormula/type.go
  5. 3
      api/version1/user/userCont.go
  6. 2
      apirouter/entry.go
  7. 19
      apirouter/v1/mathsrouter/mathsrouterapi.go
  8. 4
      apirouter/v1/mathsrouter/type.go
  9. 25
      config/configNosql/redisv9.go
  10. 2
      go.mod
  11. 9
      go.sum
  12. 2
      initialization/nosql/redis.go
  13. 9
      initialization/route/initRoute.go
  14. 6
      middleware/grocerystore/redis.go
  15. 6
      middleware/grocerystore/redisclan.go
  16. 1
      overall/publicmethod/formatOutput.go

2
api/version1/entry.go

@ -9,6 +9,7 @@ import (
"appPlatform/api/version1/menus" "appPlatform/api/version1/menus"
"appPlatform/api/version1/newsclass" "appPlatform/api/version1/newsclass"
"appPlatform/api/version1/publicapi" "appPlatform/api/version1/publicapi"
matsformula "appPlatform/api/version1/taskplatform/matsFormula"
"appPlatform/api/version1/taskplatform/taskflow" "appPlatform/api/version1/taskplatform/taskflow"
"appPlatform/api/version1/taskplatform/taskmanagement" "appPlatform/api/version1/taskplatform/taskmanagement"
"appPlatform/api/version1/user" "appPlatform/api/version1/user"
@ -26,6 +27,7 @@ type ApiEntry struct {
TaskFlowApi taskflow.ApiMethod TaskFlowApi taskflow.ApiMethod
NewsClassApi newsclass.ApiMethod //新闻类 NewsClassApi newsclass.ApiMethod //新闻类
RedisManagApi redisController.ApiMethod RedisManagApi redisController.ApiMethod
MathsApi matsformula.ApiMethod
} }
var AppApiEntry = new(ApiEntry) var AppApiEntry = new(ApiEntry)

26
api/version1/publicapi/api.go

@ -585,13 +585,18 @@ func (a *ApiMethod) ObtainToken(c *gin.Context) {
redisCont["userkey"] = requestData.UserNumber redisCont["userkey"] = requestData.UserNumber
redisCont["password"] = pwdStr redisCont["password"] = pwdStr
//将信息写入哈希 //将信息写入哈希
redisClient := grocerystore.RunRedisClan(overall.CONSTANT_ClusterClient) // redisClient := grocerystore.RunRedisClan(overall.CONSTANT_ClusterClient)
// redisClient.SetRedisTime(10800)
// isTrue := redisClient.HashMsetAddClan(redisKey, redisCont)
// grocerystore.RunRedis(overall.CONSTANT_Cluster)
redisClient := grocerystore.RunRedis(overall.CONSTANT_Cluster)
redisClient.SetRedisTime(10800) redisClient.SetRedisTime(10800)
isTrue := redisClient.HashMsetAddClan(redisKey, redisCont) isTrue := redisClient.HashMsetAdd(redisKey, redisCont)
if !isTrue { if !isTrue {
publicmethod.Result(1, overall.CONSTANT_Cluster, c, "授权失败!") publicmethod.Result(1, overall.CONSTANT_Cluster, c, "授权失败!")
return return
} }
//输出内容 //输出内容
sendCont := publicmethod.MapOut[string]() sendCont := publicmethod.MapOut[string]()
sendCont["number"] = uuidStr sendCont["number"] = uuidStr
@ -640,8 +645,11 @@ func (a *ApiMethod) VerifyIdentity(c *gin.Context) {
// } // }
//redis键 //redis键
redisKey := fmt.Sprintf("Authentication:PasswordFreeLogin:key_%v", token) redisKey := fmt.Sprintf("Authentication:PasswordFreeLogin:key_%v", token)
redisClient := grocerystore.RunRedisClan(overall.CONSTANT_ClusterClient) // redisClient := grocerystore.RunRedisClan(overall.CONSTANT_ClusterClient)
tokenInfo, isTrue := redisClient.HashGetAllClan(redisKey) // tokenInfo, isTrue := redisClient.HashGetAllClan(redisKey)
redisClient := grocerystore.RunRedis(overall.CONSTANT_Cluster)
tokenInfo, isTrue := redisClient.HashGetAll(redisKey)
if isTrue != true { if isTrue != true {
publicmethod.Result(1, redisKey, c, "token错误") publicmethod.Result(1, redisKey, c, "token错误")
return return
@ -841,7 +849,7 @@ func (a *ApiMethod) VerifyIdentity(c *gin.Context) {
postInfo.GetCont(map[string]interface{}{"`id`": userCont.Position}, "`name`") postInfo.GetCont(map[string]interface{}{"`id`": userCont.Position}, "`name`")
myCont["positionname"] = postInfo.Name myCont["positionname"] = postInfo.Name
redisClients.HashMsetAdd(redisMyContKey, myCont) redisClients.HashMsetAdd(redisMyContKey, myCont)
redisClient.HashMsetAddClan(redisMyContKey, myCont) redisClient.HashMsetAdd(redisMyContKey, myCont)
saveData["usercont"] = myCont saveData["usercont"] = myCont
if openId != "" { if openId != "" {
@ -913,8 +921,10 @@ func (a *ApiMethod) SilentLogin(c *gin.Context) {
// } // }
//redis键 //redis键
redisKey := fmt.Sprintf("Authentication:PasswordFreeLogin:key_%v", requestData.Token) redisKey := fmt.Sprintf("Authentication:PasswordFreeLogin:key_%v", requestData.Token)
redisClient := grocerystore.RunRedisClan(overall.CONSTANT_ClusterClient) // redisClient := grocerystore.RunRedisClan(overall.CONSTANT_ClusterClient)
tokenInfo, isTrue := redisClient.HashGetAllClan(redisKey) // tokenInfo, isTrue := redisClient.HashGetAllClan(redisKey)
redisClient := grocerystore.RunRedis(overall.CONSTANT_Cluster)
tokenInfo, isTrue := redisClient.HashGetAll(redisKey)
if isTrue != true { if isTrue != true {
publicmethod.Result(10001, redisKey, c, "token错误") publicmethod.Result(10001, redisKey, c, "token错误")
return return
@ -1114,7 +1124,7 @@ func (a *ApiMethod) SilentLogin(c *gin.Context) {
postInfo.GetCont(map[string]interface{}{"`id`": userCont.Position}, "`name`") postInfo.GetCont(map[string]interface{}{"`id`": userCont.Position}, "`name`")
myCont["positionname"] = postInfo.Name myCont["positionname"] = postInfo.Name
redisClients.HashMsetAdd(redisMyContKey, myCont) redisClients.HashMsetAdd(redisMyContKey, myCont)
redisClient.HashMsetAddClan(redisMyContKey, myCont) redisClient.HashMsetAdd(redisMyContKey, myCont)
saveData["usercont"] = myCont saveData["usercont"] = myCont
if requestData.Openid != "" { if requestData.Openid != "" {

262
api/version1/taskplatform/matsFormula/formula.go

@ -0,0 +1,262 @@
package matsformula
import (
"appPlatform/overall/publicmethod"
"fmt"
"math"
"strconv"
"strings"
"github.com/dengsgo/math-engine/engine"
"github.com/gin-gonic/gin"
)
/*
*
@ 作者: 秦东
@ 时间: 2024-01-02 08:53:21
@ 功能: 解析数学公式
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) AnalyticalMathematicalFormulas(c *gin.Context) {
var requestsData Formula
err := c.ShouldBindJSON(&requestsData)
if err != nil {
publicmethod.Result(1, err, c)
return
}
mathsStr := requestsData.Val
for _, v := range requestsData.FormJson {
zhi := strconv.FormatFloat(v.Val, 'f', -1, 64)
mathsStr = strings.Replace(mathsStr, v.Keys, zhi, 1)
}
sendData := publicmethod.MapOut[string]()
sendData["mathsStr"] = mathsStr
runMaths, err := AnalyticCalculation(mathsStr, 0, 2)
sendData["runMaths"] = runMaths
sendData["err"] = err
publicmethod.Result(0, sendData, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-01-08 10:46:15
@ 功能: 解析数学公式
@ 参数
#mathsFormula 组合后的公式
#takingMethod 结果保留形式 0:原始数据 1四舍五入2向上取整3向下取整4舍去
#digit 保留位数
@ 返回值
#
@ 方法原型
#
*/
func AnalyticCalculation(mathsFormula string, takingMethod, digit int) (runMaths float64, err error) {
//自定义一个Sum计算
engine.RegFunction("sum", -1, func(expr ...engine.ExprAST) float64 {
var sum float64
for _, v := range expr {
sum = sum + engine.ExprASTResult(v)
}
return sum
})
engine.RegFunction("average", -1, func(expr ...engine.ExprAST) float64 {
var sum float64
num := 0
for _, v := range expr {
sum = sum + engine.ExprASTResult(v)
num++
}
if num > 0 {
sum = sum / float64(num)
}
return sum
})
//解析、执行数学公式字符串
runMaths, err = engine.ParseAndExec(mathsFormula)
switch takingMethod {
case 1:
// fmt.Printf("1:%v--1-->%v---->%v\n", takingMethod, digit, runMaths)
runMaths = publicmethod.DecimalEs(runMaths, digit)
// fmt.Printf("1:%v---->%v---->%v\n", takingMethod, digit, runMaths)
case 2:
runMaths = math.Ceil(runMaths)
// fmt.Printf("2:%v---->%v---->%v\n", takingMethod, digit, runMaths)
case 3:
runMaths = math.Floor(runMaths)
// fmt.Printf("3:%v---->%v---->%v\n", takingMethod, digit, runMaths)
case 4:
runMaths = float64(int64(runMaths))
// fmt.Printf("4:%v---->%v---->%v\n", takingMethod, digit, runMaths)
default:
// fmt.Printf("5:%v---->%v---->%v\n", takingMethod, digit, runMaths)
return
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2024-01-09 14:48:06
@ 功能: 数学计算
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) MathematicalCalculations(c *gin.Context) {
var requestsData ReceiveMathsFornula
err := c.ShouldBindJSON(&requestsData)
if err != nil {
publicmethod.Result(1, err, c)
return
}
zhi := make(map[string]float64)
var formulaList []FormJsonInfor
for i, v := range requestsData.MathsFornula {
var formulaCont FormJsonInfor
formulaCont.Keys = i
formulaCont.Val = v.MathsFormula
formulaList = append(formulaList, formulaCont)
if i != requestsData.FieldKey {
zhiVal := FieldToValue(v.MathsFormula, requestsData.KeyVal, v.TakingMethod, v.Digit)
zhi[i] = zhiVal
}
}
// publicmethod.Result(10000, zhi, c)
sendData := publicmethod.MapOut[string]()
sendData["formulaList"] = formulaList
sendData["zhi"] = zhi
sendData["requestsData"] = requestsData
publicmethod.Result(0, zhi, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-01-09 15:52:41
@ 功能: 解析计算数值
@ 参数
#formula 计算公式
#formKeyVal 表单字段
#takingMethod 结果保留形式 1四舍五入2向上取整3向下取整4舍去
#digit 保留位数
@ 返回值
#
@ 方法原型
#
*/
func FieldToValue(formula string, formKeyVal map[string]interface{}, takingMethod, digit int) (runMaths float64) {
for i, v := range formKeyVal {
if val, isOk := v.(string); isOk {
if val == "" {
val = "0"
}
formula = strings.Replace(formula, i, val, -1)
}
if val, isOk := v.(int); isOk {
valStr := strconv.Itoa(val)
formula = strings.Replace(formula, i, valStr, -1)
}
if val, isOk := v.(int64); isOk {
valStr := strconv.FormatInt(val, 10)
formula = strings.Replace(formula, i, valStr, -1)
}
if val, isOk := v.(float32); isOk {
valStr := strconv.FormatFloat(float64(val), 'f', -1, 64)
formula = strings.Replace(formula, i, valStr, -1)
}
if val, isOk := v.(float64); isOk {
valStr := strconv.FormatFloat(val, 'f', -1, 64)
formula = strings.Replace(formula, i, valStr, -1)
}
}
formula = strings.Replace(formula, ",", ",", -1)
smaillMathsStr := strings.ToLower(formula)
fmt.Printf("smaillMathsStr===>%v\n", smaillMathsStr)
runMaths, err := AnalyticCalculation(smaillMathsStr, takingMethod, digit)
if err != nil {
runMaths = 0
return
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2024-01-09 15:00:33
@ 功能: 数学公式字段转化数值
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func FieldToValues(formulaList []FormJsonInfor, key string, val string, takingMethod, digit int) map[string]float64 {
var fieldVal map[string]float64
for _, v := range formulaList {
mathsStr := strings.Replace(v.Val, key, val, -1)
mathsStr = strings.Replace(mathsStr, ",", ",", -1)
smaillMathsStr := strings.ToLower(mathsStr)
fmt.Printf("smaillMathsStr===>%v\n", smaillMathsStr)
runMaths, err := AnalyticCalculation(smaillMathsStr, takingMethod, digit)
fmt.Printf("runMaths===>%v\n err===>%v\n", runMaths, err)
// if err == nil {
// switch takingMethod {
// case 2:
// fieldVal[v.Keys] = math.Ceil(runMaths)
// case 3:
// fieldVal[v.Keys] = math.Floor(runMaths)
// case 4:
// fieldVal[v.Keys] = math.Floor(runMaths)
// default:
// fieldVal[v.Keys] = math.Round(publicmethod.DecimalEs(runMaths, digit))
// }
// } else {
// fieldVal[v.Keys] = 0
// }
}
return fieldVal
}

43
api/version1/taskplatform/matsFormula/type.go

@ -0,0 +1,43 @@
package matsformula
import (
"appPlatform/overall/publicmethod"
"github.com/gin-gonic/gin"
)
type ApiMethod struct{}
func (a *ApiMethod) Index(c *gin.Context) {
outputCont := publicmethod.MapOut[string]()
outputCont["index"] = "数学函数处理内容列表入口"
publicmethod.Result(0, outputCont, c)
}
// 接收公式
type Formula struct {
Val string `json:"val"`
FormJson []FormJsonCont `json:"formJson"`
}
type FormJsonCont struct {
Keys string `json:"key"`
Val float64 `json:"val"`
}
type FormJsonInfor struct {
Keys string `json:"key"`
Val string `json:"val"`
}
// 接收数学公式及字段表单
type ReceiveMathsFornula struct {
FieldKey string `json:"fieldKey"`
MathsFornula map[string]MathsValCont `json:"mathsFornula"`
KeyVal map[string]interface{} `json:"keyVal"`
}
// 数值配置参数
type MathsValCont struct {
MathsFormula string `json:"mathsFormula"`
TakingMethod int `json:"takingMethod"`
Digit int `json:"digit"`
}

3
api/version1/user/userCont.go

@ -182,6 +182,9 @@ func GainOrgPostLog(uid int64) (postLog []string) {
#func GetUserPower(appType string, postId int64, roleList []string) (menuPoint []string, opeart []string, orgList []string) #func GetUserPower(appType string, postId int64, roleList []string) (menuPoint []string, opeart []string, orgList []string)
*/ */
func GetUserPower(appType string, postId int64, roleList []string) (menuPoint, opeart, orgList []string) { func GetUserPower(appType string, postId int64, roleList []string) (menuPoint, opeart, orgList []string) {
if postId == 0 {
return
}
//获取职务权限 //获取职务权限
var emPower modelssystempermission.Empower var emPower modelssystempermission.Empower
err := emPower.GetCont(map[string]interface{}{"`post_id`": postId, "`system`": appType}) err := emPower.GetCont(map[string]interface{}{"`post_id`": postId, "`system`": appType})

2
apirouter/entry.go

@ -6,6 +6,7 @@ import (
"appPlatform/apirouter/v1/customerformrouter" "appPlatform/apirouter/v1/customerformrouter"
dictrouters "appPlatform/apirouter/v1/dict_routers" dictrouters "appPlatform/apirouter/v1/dict_routers"
"appPlatform/apirouter/v1/grantsystempower" "appPlatform/apirouter/v1/grantsystempower"
"appPlatform/apirouter/v1/mathsrouter"
matrixrouters "appPlatform/apirouter/v1/matrixRouters" matrixrouters "appPlatform/apirouter/v1/matrixRouters"
menusrouters "appPlatform/apirouter/v1/menusRouters" menusrouters "appPlatform/apirouter/v1/menusRouters"
"appPlatform/apirouter/v1/newsclassrouter" "appPlatform/apirouter/v1/newsclassrouter"
@ -29,6 +30,7 @@ type RouterGroup struct {
TaskRouter taskrouter.ApiRouter TaskRouter taskrouter.ApiRouter
NewsClassApiRouter newsclassrouter.ApiRouter NewsClassApiRouter newsclassrouter.ApiRouter
RedisClassApiRouter redisRouter.ApiRouter RedisClassApiRouter redisRouter.ApiRouter
MathsRouter mathsrouter.ApiRouter
} }
var RouterGroupEntry = new(RouterGroup) var RouterGroupEntry = new(RouterGroup)

19
apirouter/v1/mathsrouter/mathsrouterapi.go

@ -0,0 +1,19 @@
package mathsrouter
import (
"appPlatform/api/version1"
"github.com/gin-gonic/gin"
)
// 数学公式接口路由
func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) {
apiRouter := router.Group("maths")
var mathsClassRouter = version1.AppApiEntry.MathsApi
{
apiRouter.GET("", mathsClassRouter.Index) //入口
apiRouter.POST("", mathsClassRouter.Index) //入口
apiRouter.POST("am_formulas", mathsClassRouter.AnalyticalMathematicalFormulas) //解析数学公式
apiRouter.POST("mathematicalCalculations", mathsClassRouter.MathematicalCalculations) //数学计算
}
}

4
apirouter/v1/mathsrouter/type.go

@ -0,0 +1,4 @@
package mathsrouter
//数学公式路由设定
type ApiRouter struct{}

25
config/configNosql/redisv9.go

@ -1,6 +1,11 @@
package confignosql package confignosql
import "fmt" import (
"context"
"fmt"
"github.com/redis/go-redis/v9"
)
type RedisSetUpV9 struct { type RedisSetUpV9 struct {
RedisClusterV9 RedisConfitSetUp `mapstructure:"redisCluster" json:"redisCluster" yaml:"redisCluster"` //内网集群 RedisClusterV9 RedisConfitSetUp `mapstructure:"redisCluster" json:"redisCluster" yaml:"redisCluster"` //内网集群
@ -23,6 +28,20 @@ type RedisSetUpV9 struct {
# #
*/ */
func (r *RedisConfitSetUp) OpenRedisClan() { func (r *RedisConfitSetUp) OpenRedisClan() (redisClient *redis.Client) {
fmt.Printf("开启%v Redis库 %v\n", r.UrlPathList, r.Name) fmt.Printf("开1启%v Redis库 %v\n", r.UrlPathList, r.Name)
for _, v := range r.UrlPathList {
redisClient = redis.NewClient(&redis.Options{
Addr: v,
Password: r.PassWord,
DB: 0,
})
pingLink, err := redisClient.Ping(context.Background()).Result()
if err == nil {
fmt.Printf("%v Redis集群链接成功!==%v===>%v\n", v, r.Name, pingLink)
return
}
}
fmt.Printf("%v Redis集群链接失败!==%v\n", r.UrlPathList, r.Name)
return
} }

2
go.mod

@ -3,9 +3,11 @@ module appPlatform
go 1.19 go 1.19
require ( require (
github.com/dengsgo/math-engine v0.0.0-20230823154425-78f211b48149
github.com/flipped-aurora/gin-vue-admin/server v0.0.0-20231212025023-e0a8e9370425 github.com/flipped-aurora/gin-vue-admin/server v0.0.0-20231212025023-e0a8e9370425
github.com/fsnotify/fsnotify v1.7.0 github.com/fsnotify/fsnotify v1.7.0
github.com/gin-gonic/gin v1.9.1 github.com/gin-gonic/gin v1.9.1
github.com/go-redis/redis/v8 v8.11.5
github.com/mitchellh/mapstructure v1.5.0 github.com/mitchellh/mapstructure v1.5.0
github.com/mozillazg/go-pinyin v0.20.0 github.com/mozillazg/go-pinyin v0.20.0
github.com/redis/go-redis/v9 v9.3.0 github.com/redis/go-redis/v9 v9.3.0

9
go.sum

@ -11,6 +11,8 @@ github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583j
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dengsgo/math-engine v0.0.0-20230823154425-78f211b48149 h1:TkVfb0s14IUHDGvjQfq3f0PZnV1zh609did4DrnD4q4=
github.com/dengsgo/math-engine v0.0.0-20230823154425-78f211b48149/go.mod h1:zkR27k4K0I8FS6rkEd8qBhPeS8i3X2FKfvSPdF64OpQ=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/flipped-aurora/gin-vue-admin/server v0.0.0-20231212025023-e0a8e9370425 h1:XTvBOk+EFcon1fL8gzFRN2N7jGvc2QGZMqWF+evZT10= github.com/flipped-aurora/gin-vue-admin/server v0.0.0-20231212025023-e0a8e9370425 h1:XTvBOk+EFcon1fL8gzFRN2N7jGvc2QGZMqWF+evZT10=
@ -31,6 +33,8 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js= github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js=
github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI= github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
@ -68,6 +72,9 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/mozillazg/go-pinyin v0.20.0 h1:BtR3DsxpApHfKReaPO1fCqF4pThRwH9uwvXzm+GnMFQ= github.com/mozillazg/go-pinyin v0.20.0 h1:BtR3DsxpApHfKReaPO1fCqF4pThRwH9uwvXzm+GnMFQ=
github.com/mozillazg/go-pinyin v0.20.0/go.mod h1:iR4EnMMRXkfpFVV5FMi4FNB6wGq9NV6uDWbUuPhP4Yc= github.com/mozillazg/go-pinyin v0.20.0/go.mod h1:iR4EnMMRXkfpFVV5FMi4FNB6wGq9NV6uDWbUuPhP4Yc=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@ -127,6 +134,8 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogR
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

2
initialization/nosql/redis.go

@ -16,6 +16,6 @@ func LoadRedis() {
overall.CONSTANT_REDIS3 = redisConfig.MasterRedis3.OpenRedis() overall.CONSTANT_REDIS3 = redisConfig.MasterRedis3.OpenRedis()
overall.CONSTANT_REDIS4 = redisConfig.MasterRedis4.OpenRedis() overall.CONSTANT_REDIS4 = redisConfig.MasterRedis4.OpenRedis()
overall.CONSTANT_REDIS5 = redisConfig.MasterRedis5.OpenRedis() overall.CONSTANT_REDIS5 = redisConfig.MasterRedis5.OpenRedis()
overall.CONSTANT_Cluster = redisConfig.RedisCluster.OpenRedis() overall.CONSTANT_Cluster = redisConfig.RedisCluster.OpenRedisClan()
overall.CONSTANT_ClusterClient = redisConfig.RedisCluster.OpenRedisColony() overall.CONSTANT_ClusterClient = redisConfig.RedisCluster.OpenRedisColony()
} }

9
initialization/route/initRoute.go

@ -3,14 +3,15 @@ package route
import ( import (
"appPlatform/apirouter" "appPlatform/apirouter"
"appPlatform/identification/interceptor" "appPlatform/identification/interceptor"
"io/ioutil"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
// 初始化主路由 // 初始化主路由
func InitialRouter() *gin.Engine { func InitialRouter() *gin.Engine {
// gin.SetMode(gin.ReleaseMode) gin.SetMode(gin.ReleaseMode)
// gin.DefaultWriter = ioutil.Discard gin.DefaultWriter = ioutil.Discard
var router = gin.Default() var router = gin.Default()
//app默认相应 //app默认相应
@ -79,7 +80,9 @@ func InitialRouter() *gin.Engine {
//带身份实验 //带身份实验
shiyanApiVerify := apirouter.RouterGroupEntry.ShiyanApi shiyanApiVerify := apirouter.RouterGroupEntry.ShiyanApi
shiyanApiVerify.RouterGroupVerify(VerifyIdentity) shiyanApiVerify.RouterGroupVerify(VerifyIdentity)
//注册数学函数处理
mathsApiVerify := apirouter.RouterGroupEntry.MathsRouter
mathsApiVerify.RouterGroup(VerifyIdentity)
} }
//验证身份接口 无需鉴权Url(主要web端使用) //验证身份接口 无需鉴权Url(主要web端使用)
VerifyIdentityWeb := router.Group("") VerifyIdentityWeb := router.Group("")

6
middleware/grocerystore/redis.go

@ -110,7 +110,7 @@ func (r *RedisStoreType) HashSet(hashName, hashKey, hashVal string) bool {
func (r *RedisStoreType) HashMsetAdd(hashName string, hashVal map[string]interface{}) bool { func (r *RedisStoreType) HashMsetAdd(hashName string, hashVal map[string]interface{}) bool {
// rdb := RedisInit() // rdb := RedisInit()
err := r.RedisDb.HMSet(r.Context, r.PreKey+hashName, hashVal).Err() err := r.RedisDb.HMSet(r.Context, r.PreKey+hashName, hashVal).Err()
fmt.Printf("错误sss=========》%v=====2====》%v\n", err, hashVal) // fmt.Printf("错误sss=========》%v=====2====》%v\n", err, hashVal)
// err := rdb.HMSet(ctx, "userfg", hashVal).Err() // err := rdb.HMSet(ctx, "userfg", hashVal).Err()
if err != nil { if err != nil {
return false return false
@ -163,9 +163,9 @@ func (r *RedisStoreType) HashMsetAddAry(hashName string, hashVal []map[string]in
*/ */
func (r *RedisStoreType) HashGetAll(hashName string) (map[string]string, bool) { func (r *RedisStoreType) HashGetAll(hashName string) (map[string]string, bool) {
// rdb := RedisInit() // rdb := RedisInit()
fmt.Printf("strKEy:===>%v\n", r.PreKey+hashName) // fmt.Printf("strKEy:===>%v\n", r.PreKey+hashName)
val, err := r.RedisDb.HGetAll(r.Context, r.PreKey+hashName).Result() val, err := r.RedisDb.HGetAll(r.Context, r.PreKey+hashName).Result()
fmt.Printf("strKEy:==1=>%v==1=>%v\n", val, err) // fmt.Printf("strKEy:==1=>%v==1=>%v\n", val, err)
if err != nil { if err != nil {
return val, false return val, false
} }

6
middleware/grocerystore/redisclan.go

@ -107,7 +107,7 @@ func (r *RedisStoreType) HashSetClan(hashName, hashKey, hashVal string) bool {
func (r *RedisStoreType) HashMsetAddClan(hashName string, hashVal map[string]interface{}) bool { func (r *RedisStoreType) HashMsetAddClan(hashName string, hashVal map[string]interface{}) bool {
// rdb := RedisInit() // rdb := RedisInit()
err := r.RedisDbClan.HMSet(r.Context, r.PreKey+hashName, hashVal).Err() err := r.RedisDbClan.HMSet(r.Context, r.PreKey+hashName, hashVal).Err()
fmt.Printf("错误sss=========》%v=====2====》%v\n", err, hashVal) // fmt.Printf("错误sss=========》%v=====2====》%v\n", err, hashVal)
// err := rdb.HMSet(ctx, "userfg", hashVal).Err() // err := rdb.HMSet(ctx, "userfg", hashVal).Err()
if err != nil { if err != nil {
return false return false
@ -160,9 +160,9 @@ func (r *RedisStoreType) HashMsetAddAryClan(hashName string, hashVal []map[strin
*/ */
func (r *RedisStoreType) HashGetAllClan(hashName string) (map[string]string, bool) { func (r *RedisStoreType) HashGetAllClan(hashName string) (map[string]string, bool) {
// rdb := RedisInit() // rdb := RedisInit()
fmt.Printf("strKEy:===>%v\n", r.PreKey+hashName) // fmt.Printf("strKEy:===>%v\n", r.PreKey+hashName)
val, err := r.RedisDbClan.HGetAll(r.Context, r.PreKey+hashName).Result() val, err := r.RedisDbClan.HGetAll(r.Context, r.PreKey+hashName).Result()
fmt.Printf("strKEy:==1=>%v==1=>%v\n", val, err) // fmt.Printf("strKEy:==1=>%v==1=>%v\n", val, err)
if err != nil { if err != nil {
return val, false return val, false
} }

1
overall/publicmethod/formatOutput.go

@ -180,6 +180,7 @@ func DetermineUserIdentity(userKey int64) (identity outShenFen) {
roleList := strings.Split(userCont.Role, ",") roleList := strings.Split(userCont.Role, ",")
var roleVerify modelssystempermission.RoleEmpower var roleVerify modelssystempermission.RoleEmpower
overall.CONSTANT_DB_System_Permission.Where("`state` = 1 AND `system` = ? AND `id` IN ? ", "kpi", roleList).Find(&roleVerify) overall.CONSTANT_DB_System_Permission.Where("`state` = 1 AND `system` = ? AND `id` IN ? ", "kpi", roleList).Find(&roleVerify)
//岗位权限范围判定 //岗位权限范围判定
var postVerify modelssystempermission.Empower var postVerify modelssystempermission.Empower
postVerify.GetCont(map[string]interface{}{"`post_id`": userCont.Position, "`state`": 1, "`system`": "kpi"}) postVerify.GetCont(map[string]interface{}{"`post_id`": userCont.Position, "`state`": 1, "`system`": "kpi"})

Loading…
Cancel
Save