diff --git a/api/base/loginVerify/login.go b/api/base/loginVerify/login.go index 2003f36..f859c4a 100644 --- a/api/base/loginVerify/login.go +++ b/api/base/loginVerify/login.go @@ -150,6 +150,8 @@ func (a *ApiMethod) ScanCodeLogin(c *gin.Context) { myCont["planformaldate"] = userCont.Planformaldate //预计转正日期 myCont["political_outlook"] = userCont.PoliticalOutlook //政治面貌(1:群众;2:无党派;3:台盟会员;4:九三社员;5:致公党员;6:农工党员;7:民进会员;8:民建会员;9:民盟盟员;10:民革会员,11:共青团员;12:预备党员;13:中共党员) redisClient.HashMsetAdd(redisMyContKey, myCont) + + fmt.Printf("redisMyContKey------Login----->%v\n", redisMyContKey) publicmethod.Result(0, saveData, c) } diff --git a/api/version1/empower/system_license.go b/api/version1/empower/system_license.go new file mode 100644 index 0000000..dce91cd --- /dev/null +++ b/api/version1/empower/system_license.go @@ -0,0 +1,42 @@ +package empower + +import ( + "key_performance_indicators/models/modelssystempermission" + "key_performance_indicators/overall/publicmethod" + "strings" + + "github.com/gin-gonic/gin" +) + +// 系统授权 +func (a *ApiMethod) ObtainAuthorization(c *gin.Context) { + var receivedValue getSystemEmpower + err := c.ShouldBindJSON(&receivedValue) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if receivedValue.System == "" { + publicmethod.Result(1, err, c, "未知系统!不可授权!") + return + } + //获取登录人信息 + context, err := publicmethod.LoginMyCont(c) + if err != nil { + publicmethod.Result(1, err, c, "未知身份!不可授权!") + return + } + var systemPermission modelssystempermission.Empower + err = systemPermission.GetCont(map[string]interface{}{"`state`": 1, "`ordid`": context.AdminOrg, "`post_id`": context.Position, "`system`": receivedValue.System}, "`point_id`") + if err != nil { + publicmethod.Result(1, err, c, "没有可使用的授权信息!") + return + } + // var pointId []string + pointId := strings.Split(systemPermission.PointId, ",") + if len(pointId) < 1 { + publicmethod.Result(1, err, c, "没有可使用的授23权信息!") + return + } + publicmethod.Result(0, pointId, c) +} diff --git a/api/version1/empower/type.go b/api/version1/empower/type.go new file mode 100644 index 0000000..1554d98 --- /dev/null +++ b/api/version1/empower/type.go @@ -0,0 +1,21 @@ +package empower + +import ( + "key_performance_indicators/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 getSystemEmpower struct { + System string `json:"system"` +} diff --git a/api/version1/entry.go b/api/version1/entry.go index 82dfd02..ca9b083 100644 --- a/api/version1/entry.go +++ b/api/version1/entry.go @@ -4,6 +4,7 @@ import ( "key_performance_indicators/api/version1/bookimg" "key_performance_indicators/api/version1/departmentseting/departmentpc" "key_performance_indicators/api/version1/departmentseting/departmentweb" + "key_performance_indicators/api/version1/empower" "key_performance_indicators/api/version1/honoraryArchives" "key_performance_indicators/api/version1/jurisdiction/jurisdictionpc" "key_performance_indicators/api/version1/postseting/postpc" @@ -18,6 +19,7 @@ type ApiEntry struct { DeparmentWebApi departmentweb.ApiMethod //部门web端 BookImg bookimg.ApiMethod //图文信息管理 JurisdictionpcApi jurisdictionpc.ApiMethod //权限模块PC端 + EmpowerApi empower.ApiMethod //系统授权 } var AppApiEntry = new(ApiEntry) diff --git a/apirouter/entry.go b/apirouter/entry.go index b92e577..7a4a6d0 100644 --- a/apirouter/entry.go +++ b/apirouter/entry.go @@ -5,6 +5,7 @@ import ( "key_performance_indicators/apirouter/empower" "key_performance_indicators/apirouter/v1/bookimg" "key_performance_indicators/apirouter/v1/departmentseting" + "key_performance_indicators/apirouter/v1/empowerrouter" honorsRoute "key_performance_indicators/apirouter/v1/honorsRoute" "key_performance_indicators/apirouter/v1/postseting" "key_performance_indicators/apirouter/v1/systempower" @@ -22,6 +23,7 @@ type RouterGroup struct { DepartmentRouter departmentseting.ApiRouter BookImg bookimg.ApiRouter SystemPowerRouter systempower.ApiRouter + Empowerouter empowerrouter.ApiRouter } var RouterGroupEntry = new(RouterGroup) diff --git a/apirouter/v1/empowerrouter/authorize.go b/apirouter/v1/empowerrouter/authorize.go new file mode 100644 index 0000000..a1be300 --- /dev/null +++ b/apirouter/v1/empowerrouter/authorize.go @@ -0,0 +1,20 @@ +package empowerrouter + +import ( + "key_performance_indicators/api/version1" + + "github.com/gin-gonic/gin" +) + +// 系统授权 +func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) { + apiRouter := router.Group("system_authorizing") + + var methodBinding = version1.AppApiEntry.EmpowerApi + { + apiRouter.GET("", methodBinding.Index) //入口 + apiRouter.POST("", methodBinding.Index) //入口 + apiRouter.POST("obtain_authorization", methodBinding.ObtainAuthorization) //系统授权 + } + +} diff --git a/apirouter/v1/empowerrouter/type.go b/apirouter/v1/empowerrouter/type.go new file mode 100644 index 0000000..039b36b --- /dev/null +++ b/apirouter/v1/empowerrouter/type.go @@ -0,0 +1,4 @@ +package empowerrouter + +//系统授权 +type ApiRouter struct{} diff --git a/identification/interceptor/identity.go b/identification/interceptor/identity.go index 505aea8..b335fbe 100644 --- a/identification/interceptor/identity.go +++ b/identification/interceptor/identity.go @@ -3,6 +3,7 @@ package interceptor import ( "fmt" "key_performance_indicators/middleware/grocerystore" + "key_performance_indicators/models/modelshr" "key_performance_indicators/models/modelssystempermission" "key_performance_indicators/overall" "key_performance_indicators/overall/publicmethod" @@ -37,13 +38,17 @@ func AuthenticateUser() gin.HandlerFunc { c.Abort() return } - myCont, myErr := publicmethod.GetUserRedisCont(userRedisToken["usernumber"]) + // myCont, myErr := publicmethod.GetUserRedisCont(userRedisToken["usernumber"]) + var myCont modelshr.ManCont + myErr := myCont.GetCont(map[string]interface{}{"`number`": userRedisToken["usernumber"]}) if myErr != nil { response.FailWithDetailed(gin.H{"reload": false, "code": 303, "data": myErr}, "登录超时!请重新登录", c) c.Abort() return } - // fmt.Printf("myCont---------------->%v\n", myCont) + + // myContJson, _ := json.Marshal(myCont) + // fmt.Printf("myCont---------------->%v\n", string(myContJson)) c.Set(overall.MyContJwt, myCont) writeRedisData := publicmethod.MapOut[string]() for i, v := range userRedisToken { @@ -102,6 +107,11 @@ func AuthenticateUser() gin.HandlerFunc { myContRedis["planformaldate"] = myCont.Planformaldate //预计转正日期 myContRedis["political_outlook"] = myCont.PoliticalOutlook //政治面貌(1:群众;2:无党派;3:台盟会员;4:九三社员;5:致公党员;6:农工党员;7:民进会员;8:民建会员;9:民盟盟员;10:民革会员,11:共青团员;12:预备党员;13:中共党员) redisMyContKey := fmt.Sprintf("ScanCode:Authentication:UserCont_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, myCont.Number) + + // fmt.Printf("redisMyContKey------------>%v\n", redisMyContKey) + // myContRedisJson, _ := json.Marshal(myContRedis) + // fmt.Printf("myContRedisJson------------>%v\n", string(myContRedisJson)) + redisClient.HashMsetAdd(redisMyContKey, myContRedis) c.Next() } diff --git a/initialization/route/initRoute.go b/initialization/route/initRoute.go index 2a281fb..601f096 100644 --- a/initialization/route/initRoute.go +++ b/initialization/route/initRoute.go @@ -68,6 +68,10 @@ func InitialRouter() *gin.Engine { // 图文信息 bookimgRouterApi := apirouter.RouterGroupEntry.BookImg bookimgRouterApi.RouterGroup(VerifyIdentity) + + //系统授权 + systemAuthorizingApi := apirouter.RouterGroupEntry.Empowerouter + systemAuthorizingApi.RouterGroup(VerifyIdentity) //系统授权 } //验证身份接口 无需鉴权Url(主要web端使用) VerifyIdentityWeb := router.Group("") diff --git a/models/modelssystempermission/empower.go b/models/modelssystempermission/empower.go index 309dfc5..26c9018 100644 --- a/models/modelssystempermission/empower.go +++ b/models/modelssystempermission/empower.go @@ -16,7 +16,7 @@ type Empower struct { } func (Empower *Empower) TableName() string { - return "Empower" + return "empower" } // 编辑内容 diff --git a/overall/publicmethod/formatOutput.go b/overall/publicmethod/formatOutput.go index d37ef88..b1662b1 100644 --- a/overall/publicmethod/formatOutput.go +++ b/overall/publicmethod/formatOutput.go @@ -53,11 +53,13 @@ func ResultList(code, page, pageSize int, total, count int64, data interface{}, // 登录信息转换 func LoginMyCont(c *gin.Context) (myCont modelshr.ManCont, err error) { context, exi := c.Get(overall.MyContJwt) + if exi != true { err = errors.New("对不起!你没有该功能的操作权限!1") return } jsonCont, jsonErr := json.Marshal(context) + // fmt.Printf("LoginMyCont--------->%v\n", string(jsonCont)) if jsonErr != nil { err = jsonErr return diff --git a/overall/publicmethod/technique.go b/overall/publicmethod/technique.go index 4059c36..5420928 100644 --- a/overall/publicmethod/technique.go +++ b/overall/publicmethod/technique.go @@ -403,6 +403,7 @@ func GetUserRedisCont(number string) (manCont modelshr.ManCont, err error) { redisMyContKey := fmt.Sprintf("ScanCode:Authentication:UserCont_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, number) redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS5) useMap, isTrue := redisClient.HashGetAll(redisMyContKey) + // fmt.Printf("redisMyContKey------pubils------>%v\n", redisMyContKey) if isTrue == false { err.Error() return @@ -417,6 +418,7 @@ func GetUserRedisCont(number string) (manCont modelshr.ManCont, err error) { // 获取人员Redis信息返回指针 func GetUserRedisContPointer(number string) (manCont modelshr.ManCont, err error) { redisMyContKey := fmt.Sprintf("ScanCode:Authentication:UserCont_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, number) + fmt.Printf("redisMyContKey------pubils------>%v\n", redisMyContKey) redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS5) useMap, isTrue := redisClient.HashGetAll(redisMyContKey) if isTrue == false {