From 983a1a9dff2ddbd089a196fbd3afcc866f0a222b Mon Sep 17 00:00:00 2001 From: huanghai <10402852@qq.com> Date: Mon, 24 Aug 2020 10:48:53 +0800 Subject: [PATCH] 'commit' --- .../ControllerOauth2/ControllerOauth2.go | 2 +- .../Controller/ControllerSso/ControllerSso.go | 135 +----------- dsSso/Dao/DaoAppBase/DaoAppBase.go | 48 +++++ dsSso/Dao/DaoJoinApp/DaoJoinApp.go | 149 ------------- .../Service/ServiceJoinApp/ServiceJoinApp.go | 37 +--- dsSso/docs/docs.go | 200 +----------------- dsSso/docs/swagger.json | 200 +----------------- dsSso/docs/swagger.yaml | 126 +---------- dsSso/main.go | 18 +- dsSso/models/t_join_app.go | 9 - dsSso/models/t_join_app_access_log.go | 9 - dsSso/models/t_join_share_type.go | 9 - .../AccessSystemDao/AccessSystemDao.go | 2 +- 13 files changed, 71 insertions(+), 873 deletions(-) create mode 100644 dsSso/Dao/DaoAppBase/DaoAppBase.go delete mode 100644 dsSso/Dao/DaoJoinApp/DaoJoinApp.go delete mode 100644 dsSso/models/t_join_app.go delete mode 100644 dsSso/models/t_join_app_access_log.go delete mode 100644 dsSso/models/t_join_share_type.go diff --git a/dsSso/Controller/ControllerOauth2/ControllerOauth2.go b/dsSso/Controller/ControllerOauth2/ControllerOauth2.go index fe62fe88..c09c513b 100644 --- a/dsSso/Controller/ControllerOauth2/ControllerOauth2.go +++ b/dsSso/Controller/ControllerOauth2/ControllerOauth2.go @@ -489,7 +489,7 @@ func logout(context *gin.Context) { //取出现在的cookie中的accessToken accessToken := SsoUtil.ReadSsoCookie(context) //获取所有接入系统的 - list, _ := ServiceJoinApp.GetJoinAppList(1, Const.Int32Max, "") + list, _ := ServiceJoinApp.GetAppBaseList(1, Const.Int32Max, "") for i := range list { //每个系统的退出地址 logoutUri := list[i]["logout_uri"].(string) diff --git a/dsSso/Controller/ControllerSso/ControllerSso.go b/dsSso/Controller/ControllerSso/ControllerSso.go index a5fc5430..400d4e59 100644 --- a/dsSso/Controller/ControllerSso/ControllerSso.go +++ b/dsSso/Controller/ControllerSso/ControllerSso.go @@ -3,7 +3,6 @@ package ControllerSso import ( "dsSso/Model" "dsSso/Service/ServiceJoinApp" - "dsSso/Utils/ConvertUtil" "github.com/gin-gonic/gin" "net/http" ) @@ -13,16 +12,8 @@ func Routers(r *gin.RouterGroup) { rr := r.Group("") //用于统一认证管理员登录 rr.GET("/login", login) - //列表 - rr.GET("/getJoinAppList", GetJoinAppList) - //新增 - rr.POST("/addJoinApp", AddJoinApp) - //修改 - rr.POST("/updateJoinApp", UpdateJoinApp) - //删除 - rr.POST("/deleteJoinAppById", DeleteJoinAppById) //根据appId获取接入第三方统一认证系统的信息 - rr.GET("/getJoinAppInfoById", GetJoinAppInfoById) + rr.GET("/getAppInfoById", GetAppInfoById) return } @@ -39,124 +30,6 @@ func login(c *gin.Context) { c.Redirect(302, url) } -// @Summary 获取接入系统的列表 -// @Description 获取接入系统的列表 -// @Tags 接入系统维护类 -// @Accept application/x-www-form-urlencoded -// @Produce json -// @Param limit query int true "每页多少条数据" -// @Param page query int true "显示第几页" -// @Param keyword query string false "搜索的关键词" -// @Success 200 {object} Model.Res -// @Router /sso/getJoinAppList [get] -// @X-IntLimit ["limit","page"] -// @X-LengthLimit [{"keyword":"0,20"}] -func GetJoinAppList(c *gin.Context) { - page := ConvertUtil.StringToInt(c.Query("page")) - limit := ConvertUtil.StringToInt(c.Query("limit")) - keyword := c.Query("keyword") - //获取数据 - list, count := ServiceJoinApp.GetJoinAppList(page, limit, keyword) - c.JSON(http.StatusOK, Model.Res{ - Code: http.StatusOK, - Msg: "获取列表成功!", - Items: list, - TotalCount: count, - }) - return -} - -// @Summary 增加一条接入系统的记录 -// @Description 增加一条接入系统的记录 -// @Tags 接入系统维护类 -// @Accept application/x-www-form-urlencoded -// @Produce json -// @Param app_name formData string true "系统名称" -// @Param redirect_uri formData string true "回调的地址" -// @Success 200 {object} Model.Res -// @Router /sso/addJoinApp [post] -// @X-LengthLimit [{"app_name":"1,30"},{"redirect_uri_1":"8,100"},{"redirect_uri_2":"8,100"}] -func AddJoinApp(c *gin.Context) { - //接收参数 - appName := c.PostForm("app_name") - redirectUri := c.PostForm("redirect_uri") - //调用 Service进行插入 - success := ServiceJoinApp.AddJoinApp(appName, redirectUri) - if !success { - c.JSON(http.StatusOK, Model.Res{ - Code: http.StatusRequestedRangeNotSatisfiable, - Msg: "新增接入系统出错,请联系研发人员检查!", - }) - return - } - c.JSON(http.StatusOK, Model.Res{ - Code: http.StatusOK, - Msg: "操作成功!", - }) - return -} - -// @Summary 修改一条接入系统的记录 -// @Description 修改一条接入系统的记录 -// @Tags 接入系统维护类 -// @Accept application/x-www-form-urlencoded -// @Produce json -// @Param app_id formData string false "系统app_id" -// @Param app_name formData string true "系统名称" -// @Param redirect_uri formData string true "回调的地址" -// @Success 200 {object} Model.Res -// @Router /sso/updateJoinApp [post] -// @X-IntLimit ["app_id"] -// @X-LengthLimit [{"app_name":"1,30"},{"redirect_uri_1":"8,100"},{"redirect_uri_2":"8,100"}] -func UpdateJoinApp(c *gin.Context) { - //接收参数 - systemId := c.PostForm("app_id") - systemName := c.PostForm("app_name") - redirectUri := c.PostForm("redirect_uri") - //调用 Service进行插入 - success := ServiceJoinApp.UpdateJoinApp(systemId, systemName, redirectUri) - if !success { - c.JSON(http.StatusOK, Model.Res{ - Code: http.StatusNotImplemented, - Msg: "修改统一认证系统出错,请检查参数输入是否正确!", - }) - return - } - c.JSON(http.StatusOK, Model.Res{ - Code: http.StatusOK, - Msg: "操作成功!", - }) - return -} - -// @Summary 删除一条统一认证系统的记录 -// @Description 删除一条统一认证系统的记录 -// @Tags 接入系统维护类 -// @Accept application/x-www-form-urlencoded -// @Produce json -// @Param app_id formData string true "系统app_id" -// @Success 200 {object} Model.Res -// @Router /sso/deleteJoinAppById [post] -// @X-IntLimit ["app_id"] -func DeleteJoinAppById(c *gin.Context) { - //接收参数 - appId := c.PostForm("app_id") - //检查参数的合法性 - success := ServiceJoinApp.DeleteJoinAppById(appId) - if !success { - c.JSON(http.StatusOK, Model.Res{ - Code: http.StatusInternalServerError, - Msg: "删除统一认证系统出错,请检查参数是否正确!", - }) - return - } - c.JSON(http.StatusOK, Model.Res{ - Code: http.StatusOK, - Msg: "操作成功!", - }) - return -} - // @Summary 根据appId获取接入第三方统一认证系统的信息 // @Description 根据appId获取接入第三方统一认证系统的信息 // @Tags 接入系统维护类 @@ -164,13 +37,13 @@ func DeleteJoinAppById(c *gin.Context) { // @Produce json // @Param app_id query string true "系统app_id" // @Success 200 {object} Model.AppInfo -// @Router /sso/getJoinAppInfoById [get] +// @Router /sso/getAppInfoById [get] // @X-IntLimit ["app_id"] -func GetJoinAppInfoById(c *gin.Context) { +func GetAppInfoById(c *gin.Context) { //接收参数 appId := c.Query("app_id") //获取信息 - res := ServiceJoinApp.GetJoinAppInfoById(appId) + res := ServiceJoinApp.GetAppInfoById(appId) if res != nil { c.JSON(http.StatusOK, Model.AppInfo{ Code: http.StatusOK, diff --git a/dsSso/Dao/DaoAppBase/DaoAppBase.go b/dsSso/Dao/DaoAppBase/DaoAppBase.go new file mode 100644 index 00000000..80c7f058 --- /dev/null +++ b/dsSso/Dao/DaoAppBase/DaoAppBase.go @@ -0,0 +1,48 @@ +package DaoAppBase + +import ( + "dsSso/Dao/DaoCache" + "dsSso/Model" + "dsSso/Utils/DbUtil" +) + +var joinModel Model.Selector +var tableName = "t_app_base" + +var db = DbUtil.Engine + +func init() { + _, joinModel = joinModel.Get(tableName) +} + +/** +功能:获取统一认证的接入系统列表 +作者:黄海 +时间:2020-02-05 +*/ +func GetAppBaseList(page int, limit int, keyword string) ([]map[string]interface{}, int32) { + //基础查询语句 + baseSql := "select app_id from t_app_base where app_name like ? and b_use=1" + //使用通用方法,获取简单表的分页查询SQL语句和求总数SQL语句 + keyword = "%" + keyword + "%" + //偏移量 + var offset = (page - 1) * limit + //一键加载,最后两个参数:每页多少个+从哪个位置开始,中间的参数为sql语句中的查询参数 + list, count := DaoCache.PageData(baseSql, joinModel, keyword, limit, offset) + return list, count +} + +/** +功能:根据appId获取接入第三方统一认证系统的信息 +作者:吴缤 +日期:2020-03-26 +*/ +func GetAppInfoById(appId string) map[string]interface{} { + ids := []string{appId} + list := DaoCache.GetListByIds(ids, joinModel) + if len(list) > 0 { + return list[0] + } else { + return nil + } +} diff --git a/dsSso/Dao/DaoJoinApp/DaoJoinApp.go b/dsSso/Dao/DaoJoinApp/DaoJoinApp.go deleted file mode 100644 index 53bf61fb..00000000 --- a/dsSso/Dao/DaoJoinApp/DaoJoinApp.go +++ /dev/null @@ -1,149 +0,0 @@ -package DaoJoinApp - -import ( - "dsSso/Const/ErrorConst" - "dsSso/Dao/DaoCache" - "dsSso/Model" - "dsSso/Utils/DbUtil" - "dsSso/Utils/LogUtil" - "dsSso/Utils/RedisStorage" - "dsSso/Utils/RedisUtil" - "github.com/RangelReale/osin" - "github.com/oklog/ulid" - "github.com/rs/xid" - "math/rand" - "strings" - "time" -) - -var joinModel Model.Selector -var tableName = "t_join_app" - -var db = DbUtil.Engine - -func init() { - _, joinModel = joinModel.Get(tableName) -} - -/** -功能:获取统一认证的接入系统列表 -作者:黄海 -时间:2020-02-05 -*/ -func GetJoinAppList(page int, limit int, keyword string) ([]map[string]interface{}, int32) { - //基础查询语句 - baseSql := "select app_id from t_join_app where app_name like ?" - //使用通用方法,获取简单表的分页查询SQL语句和求总数SQL语句 - keyword = "%" + keyword + "%" - //偏移量 - var offset = (page - 1) * limit - //一键加载,最后两个参数:每页多少个+从哪个位置开始,中间的参数为sql语句中的查询参数 - list, count := DaoCache.PageData(baseSql, joinModel, keyword, limit, offset) - return list, count -} - -/** -功能:增加接入系统的记录 -作者:黄海 -时间:2020-02-21 -*/ -func AddJoinApp(appName string, redirectUri string) bool { - var appSecret string - //新增 - sql := "insert into t_join_app(app_key,app_secret,app_name,redirect_uri) values(?,?,?,?)" - //获取主键ID - ak := xid.New() - appKey := ak.String() //新增就生成一个secret - t := time.Now().UTC() - entropy := rand.New(rand.NewSource(t.UnixNano())) - appSecret = strings.ToLower(ulid.MustNew(ulid.Timestamp(t), entropy).String()) - _, err := db.Exec(sql, appKey, appSecret, appName, redirectUri) - if err != nil { - LogUtil.Error(ErrorConst.SqlUpdateError, "插入统一认证表信息出错:"+err.Error()) - return false - } else { - //删除redis查询缓存 - RedisUtil.DEL(joinModel.RedisPrefix + "_" + appKey) - //增加OAuth2 redis缓存 - client := &osin.DefaultClient{ - Id: appKey, - Secret: appSecret, - RedirectUri: redirectUri, - } - RedisStorage.OAuth2RedisStorage.CreateClient(client) - return true - } -} - -/** -功能:修改接入系统的记录 -作者:黄海 -时间:2020-02-21 -*/ -func UpdateJoinApp(appId string, appName string, redirectUri string) bool { - var secret string - //获取id对应的密码 - sql := "select app_secret from t_join_app where app_id=?" - _map, err :=db.QueryString(sql, appId) - if err != nil { - LogUtil.Error(ErrorConst.SqlQueryError, "查询统一认证表信息出错!") - return false - } - if len(_map) > 0 { - secret = _map[0]["app_secret"] - } else { - LogUtil.Error(ErrorConst.SqlQueryError, "查询统一认证表信息出错,没有找到此id!") - return false - } - //更新语句 - sql = "update t_join_app set app_name=?,redirect_uri=? where app_id=?" - _, err = db.Exec(sql, appName, redirectUri, appId) - if err != nil { - LogUtil.Error(ErrorConst.SqlUpdateError, "更新统一认证表信息出错!") - return false - } else { - //更新缓存 - client := &osin.DefaultClient{ - Id: appId, - Secret: secret, - RedirectUri: redirectUri, - } - RedisStorage.OAuth2RedisStorage.UpdateClient(client) - return true - } -} - -/** -功能:删除主键为ID的接入第三方统一认证系统 -作者:黄海 -时间:2020-02-21 -*/ -func DeleteJoinAppById(appId string) bool { - //更新语句 - sql := "delete from t_join_app where app_id=?" - db.Exec(sql, appId) - //删除缓存 - RedisUtil.DEL(joinModel.RedisPrefix + "_" + appId) - //删除OAuth2的redis缓存 - client, _ := RedisStorage.OAuth2RedisStorage.GetClient(appId) - if client != nil { - RedisStorage.OAuth2RedisStorage.DeleteClient(client) - return true - } - return false -} - -/** -功能:根据appId获取接入第三方统一认证系统的信息 -作者:吴缤 -日期:2020-03-26 -*/ -func GetJoinAppInfoById(appId string) map[string]interface{} { - ids := []string{appId} - list := DaoCache.GetListByIds(ids, joinModel) - if len(list) > 0 { - return list[0] - } else { - return nil - } -} diff --git a/dsSso/Service/ServiceJoinApp/ServiceJoinApp.go b/dsSso/Service/ServiceJoinApp/ServiceJoinApp.go index bd544497..07406a1e 100644 --- a/dsSso/Service/ServiceJoinApp/ServiceJoinApp.go +++ b/dsSso/Service/ServiceJoinApp/ServiceJoinApp.go @@ -1,41 +1,14 @@ package ServiceJoinApp -import "dsSso/Dao/DaoJoinApp" +import "dsSso/Dao/DaoAppBase" /** 功能:获取接入系统列表 作者:黄海 时间:2020-02-05 */ -func GetJoinAppList(pageInt int, limitInt int, keyword string) ([]map[string]interface{}, int32) { - return DaoJoinApp.GetJoinAppList(pageInt, limitInt, keyword) -} - -/** -功能:增加接入系统的记录 -作者:黄海 -时间:2020-02-21 -*/ -func AddJoinApp(systemName string, redirectUri string) bool { - return DaoJoinApp.AddJoinApp(systemName, redirectUri) -} - -/** -功能:修改接入系统的记录 -作者:黄海 -时间:2020-02-21 -*/ -func UpdateJoinApp(systemId string, systemName string, redirectUri string) bool { - return DaoJoinApp.UpdateJoinApp(systemId, systemName, redirectUri) -} - -/** -功能:删除主键为ID的接入系统 -作者:黄海 -时间:2020-02-21 -*/ -func DeleteJoinAppById(systemId string) bool { - return DaoJoinApp.DeleteJoinAppById(systemId) +func GetAppBaseList(pageInt int, limitInt int, keyword string) ([]map[string]interface{}, int32) { + return DaoAppBase.GetAppBaseList(pageInt, limitInt, keyword) } /** @@ -43,6 +16,6 @@ func DeleteJoinAppById(systemId string) bool { 作者:吴缤 日期:2020-03-26 */ -func GetJoinAppInfoById(appId string) map[string]interface{} { - return DaoJoinApp.GetJoinAppInfoById(appId) +func GetAppInfoById(appId string) map[string]interface{} { + return DaoAppBase.GetAppInfoById(appId) } diff --git a/dsSso/docs/docs.go b/dsSso/docs/docs.go index 7944aca5..7acc8d0f 100644 --- a/dsSso/docs/docs.go +++ b/dsSso/docs/docs.go @@ -463,92 +463,7 @@ var doc = `{ ] } }, - "/sso/addJoinApp": { - "post": { - "description": "增加一条接入系统的记录", - "consumes": [ - "application/x-www-form-urlencoded" - ], - "produces": [ - "application/json" - ], - "tags": [ - "接入系统维护类" - ], - "summary": "增加一条接入系统的记录", - "parameters": [ - { - "type": "string", - "description": "系统名称", - "name": "app_name", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "回调的地址", - "name": "redirect_uri", - "in": "formData", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/Model.Res" - } - } - }, - "x-lengthlimit": [ - { - "app_name": "1,30" - }, - { - "redirect_uri_1": "8,100" - }, - { - "redirect_uri_2": "8,100" - } - ] - } - }, - "/sso/deleteJoinAppById": { - "post": { - "description": "删除一条统一认证系统的记录", - "consumes": [ - "application/x-www-form-urlencoded" - ], - "produces": [ - "application/json" - ], - "tags": [ - "接入系统维护类" - ], - "summary": "删除一条统一认证系统的记录", - "parameters": [ - { - "type": "string", - "description": "系统app_id", - "name": "app_id", - "in": "formData", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/Model.Res" - } - } - }, - "x-intlimit": [ - "app_id" - ] - } - }, - "/sso/getJoinAppInfoById": { + "/sso/getAppInfoById": { "get": { "description": "根据appId获取接入第三方统一认证系统的信息", "consumes": [ @@ -583,60 +498,6 @@ var doc = `{ ] } }, - "/sso/getJoinAppList": { - "get": { - "description": "获取接入系统的列表", - "consumes": [ - "application/x-www-form-urlencoded" - ], - "produces": [ - "application/json" - ], - "tags": [ - "接入系统维护类" - ], - "summary": "获取接入系统的列表", - "parameters": [ - { - "type": "integer", - "description": "每页多少条数据", - "name": "limit", - "in": "query", - "required": true - }, - { - "type": "integer", - "description": "显示第几页", - "name": "page", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "搜索的关键词", - "name": "keyword", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/Model.Res" - } - } - }, - "x-intlimit": [ - "limit", - "page" - ], - "x-lengthlimit": [ - { - "keyword": "0,20" - } - ] - } - }, "/sso/login": { "get": { "description": "manager dsideal4r5t6y7u 为统一认证管理员默认帐号", @@ -659,65 +520,6 @@ var doc = `{ } } } - }, - "/sso/updateJoinApp": { - "post": { - "description": "修改一条接入系统的记录", - "consumes": [ - "application/x-www-form-urlencoded" - ], - "produces": [ - "application/json" - ], - "tags": [ - "接入系统维护类" - ], - "summary": "修改一条接入系统的记录", - "parameters": [ - { - "type": "string", - "description": "系统app_id", - "name": "app_id", - "in": "formData" - }, - { - "type": "string", - "description": "系统名称", - "name": "app_name", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "回调的地址", - "name": "redirect_uri", - "in": "formData", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/Model.Res" - } - } - }, - "x-intlimit": [ - "app_id" - ], - "x-lengthlimit": [ - { - "app_name": "1,30" - }, - { - "redirect_uri_1": "8,100" - }, - { - "redirect_uri_2": "8,100" - } - ] - } } }, "definitions": { diff --git a/dsSso/docs/swagger.json b/dsSso/docs/swagger.json index 0b21d67d..01646dde 100644 --- a/dsSso/docs/swagger.json +++ b/dsSso/docs/swagger.json @@ -447,92 +447,7 @@ ] } }, - "/sso/addJoinApp": { - "post": { - "description": "增加一条接入系统的记录", - "consumes": [ - "application/x-www-form-urlencoded" - ], - "produces": [ - "application/json" - ], - "tags": [ - "接入系统维护类" - ], - "summary": "增加一条接入系统的记录", - "parameters": [ - { - "type": "string", - "description": "系统名称", - "name": "app_name", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "回调的地址", - "name": "redirect_uri", - "in": "formData", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/Model.Res" - } - } - }, - "x-lengthlimit": [ - { - "app_name": "1,30" - }, - { - "redirect_uri_1": "8,100" - }, - { - "redirect_uri_2": "8,100" - } - ] - } - }, - "/sso/deleteJoinAppById": { - "post": { - "description": "删除一条统一认证系统的记录", - "consumes": [ - "application/x-www-form-urlencoded" - ], - "produces": [ - "application/json" - ], - "tags": [ - "接入系统维护类" - ], - "summary": "删除一条统一认证系统的记录", - "parameters": [ - { - "type": "string", - "description": "系统app_id", - "name": "app_id", - "in": "formData", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/Model.Res" - } - } - }, - "x-intlimit": [ - "app_id" - ] - } - }, - "/sso/getJoinAppInfoById": { + "/sso/getAppInfoById": { "get": { "description": "根据appId获取接入第三方统一认证系统的信息", "consumes": [ @@ -567,60 +482,6 @@ ] } }, - "/sso/getJoinAppList": { - "get": { - "description": "获取接入系统的列表", - "consumes": [ - "application/x-www-form-urlencoded" - ], - "produces": [ - "application/json" - ], - "tags": [ - "接入系统维护类" - ], - "summary": "获取接入系统的列表", - "parameters": [ - { - "type": "integer", - "description": "每页多少条数据", - "name": "limit", - "in": "query", - "required": true - }, - { - "type": "integer", - "description": "显示第几页", - "name": "page", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "搜索的关键词", - "name": "keyword", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/Model.Res" - } - } - }, - "x-intlimit": [ - "limit", - "page" - ], - "x-lengthlimit": [ - { - "keyword": "0,20" - } - ] - } - }, "/sso/login": { "get": { "description": "manager dsideal4r5t6y7u 为统一认证管理员默认帐号", @@ -643,65 +504,6 @@ } } } - }, - "/sso/updateJoinApp": { - "post": { - "description": "修改一条接入系统的记录", - "consumes": [ - "application/x-www-form-urlencoded" - ], - "produces": [ - "application/json" - ], - "tags": [ - "接入系统维护类" - ], - "summary": "修改一条接入系统的记录", - "parameters": [ - { - "type": "string", - "description": "系统app_id", - "name": "app_id", - "in": "formData" - }, - { - "type": "string", - "description": "系统名称", - "name": "app_name", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "回调的地址", - "name": "redirect_uri", - "in": "formData", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/Model.Res" - } - } - }, - "x-intlimit": [ - "app_id" - ], - "x-lengthlimit": [ - { - "app_name": "1,30" - }, - { - "redirect_uri_1": "8,100" - }, - { - "redirect_uri_2": "8,100" - } - ] - } } }, "definitions": { diff --git a/dsSso/docs/swagger.yaml b/dsSso/docs/swagger.yaml index 921b0227..81ce130c 100644 --- a/dsSso/docs/swagger.yaml +++ b/dsSso/docs/swagger.yaml @@ -332,60 +332,7 @@ paths: - 登录验证类 x-emptylimit: - code - /sso/addJoinApp: - post: - consumes: - - application/x-www-form-urlencoded - description: 增加一条接入系统的记录 - parameters: - - description: 系统名称 - in: formData - name: app_name - required: true - type: string - - description: 回调的地址 - in: formData - name: redirect_uri - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/Model.Res' - summary: 增加一条接入系统的记录 - tags: - - 接入系统维护类 - x-lengthlimit: - - app_name: 1,30 - - redirect_uri_1: 8,100 - - redirect_uri_2: 8,100 - /sso/deleteJoinAppById: - post: - consumes: - - application/x-www-form-urlencoded - description: 删除一条统一认证系统的记录 - parameters: - - description: 系统app_id - in: formData - name: app_id - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/Model.Res' - summary: 删除一条统一认证系统的记录 - tags: - - 接入系统维护类 - x-intlimit: - - app_id - /sso/getJoinAppInfoById: + /sso/getAppInfoById: get: consumes: - application/x-www-form-urlencoded @@ -408,41 +355,6 @@ paths: - 接入系统维护类 x-intlimit: - app_id - /sso/getJoinAppList: - get: - consumes: - - application/x-www-form-urlencoded - description: 获取接入系统的列表 - parameters: - - description: 每页多少条数据 - in: query - name: limit - required: true - type: integer - - description: 显示第几页 - in: query - name: page - required: true - type: integer - - description: 搜索的关键词 - in: query - name: keyword - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/Model.Res' - summary: 获取接入系统的列表 - tags: - - 接入系统维护类 - x-intlimit: - - limit - - page - x-lengthlimit: - - keyword: 0,20 /sso/login: get: consumes: @@ -458,40 +370,4 @@ paths: summary: 接入系统管理中心维护的路由跳转 tags: - 接入系统维护类 - /sso/updateJoinApp: - post: - consumes: - - application/x-www-form-urlencoded - description: 修改一条接入系统的记录 - parameters: - - description: 系统app_id - in: formData - name: app_id - type: string - - description: 系统名称 - in: formData - name: app_name - required: true - type: string - - description: 回调的地址 - in: formData - name: redirect_uri - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/Model.Res' - summary: 修改一条接入系统的记录 - tags: - - 接入系统维护类 - x-intlimit: - - app_id - x-lengthlimit: - - app_name: 1,30 - - redirect_uri_1: 8,100 - - redirect_uri_2: 8,100 swagger: "2.0" diff --git a/dsSso/main.go b/dsSso/main.go index 72b22ec9..f1a3dfcb 100644 --- a/dsSso/main.go +++ b/dsSso/main.go @@ -6,7 +6,6 @@ import ( "dsSso/Middleware" "dsSso/Service/ServiceJoinApp" "dsSso/Utils" - "dsSso/Utils/CommonUtil" "dsSso/Utils/ConfigUtil" "dsSso/Utils/DbUtil" "dsSso/Utils/FileUtil" @@ -40,20 +39,20 @@ func startOAuth2Server() { RedisStorage.OsinServer = osin.NewServer(cfg, RedisStorage.OAuth2RedisStorage) //清理redis中关于接入系统的缓存 - var db= DbUtil.Engine - sql:="select * from t_join_app" - list,_:=db.SQL(sql).Query().List() + var db = DbUtil.Engine + sql := "select * from t_app_base" + list, _ := db.SQL(sql).Query().List() for i := range list { - var appId=list[i]["app_id"].(int64) + var appId = list[i]["app_id"].(string) //删除redis查询缓存 - RedisUtil.DEL("TJoinApp:"+CommonUtil.ConvertInt64ToString(appId)) + RedisUtil.DEL("TAppBase:" + appId) } //这里需要循环从数据库中获取数据 - list, _ = ServiceJoinApp.GetJoinAppList(1, 1000, "") + list, _ = ServiceJoinApp.GetAppBaseList(1, 1000, "") for i := 0; i < len(list); i++ { - appKey := list[i]["app_key"].(string) - secret := list[i]["app_secret"].(string) + appKey := list[i]["access_key"].(string) + secret := list[i]["secret_key"].(string) redirectUri := list[i]["redirect_uri"].(string) RedisStorage.OAuth2RedisStorage.CreateClient( &osin.DefaultClient{ @@ -64,6 +63,7 @@ func startOAuth2Server() { ) } } + // @title 东师理想统一认证中心(OAuth2+Sso) // @version 2.0 // @description 参考自xxl-sso diff --git a/dsSso/models/t_join_app.go b/dsSso/models/t_join_app.go deleted file mode 100644 index 6dfa88b7..00000000 --- a/dsSso/models/t_join_app.go +++ /dev/null @@ -1,9 +0,0 @@ -package models - -type TJoinApp struct { - AppId int32 `xorm:"not null pk autoincr comment('Appid') INT(11)"` - AppKey string `xorm:"not null comment('AppKey') VARCHAR(24)"` - AppSecret string `xorm:"not null comment('AppSecret') VARCHAR(128)"` - AppName string `xorm:"not null comment('系统名称') VARCHAR(255)"` - RedirectUri string `xorm:"not null comment('回调地址') VARCHAR(1024)"` -} diff --git a/dsSso/models/t_join_app_access_log.go b/dsSso/models/t_join_app_access_log.go deleted file mode 100644 index 02b251ca..00000000 --- a/dsSso/models/t_join_app_access_log.go +++ /dev/null @@ -1,9 +0,0 @@ -package models - -type TJoinAppAccessLog struct { - Id int32 `xorm:"not null pk autoincr comment('主键') INT(11)"` - AppId int32 `xorm:"not null comment('第三方接入系统ID') index INT(11)"` - ActionCode string `xorm:"not null comment('行为代码') VARCHAR(255)"` - Parameter string `xorm:"not null comment('参数') VARCHAR(255)"` - Success int32 `xorm:"not null comment('是否执行成功') INT(255)"` -} diff --git a/dsSso/models/t_join_share_type.go b/dsSso/models/t_join_share_type.go deleted file mode 100644 index 77d52ad5..00000000 --- a/dsSso/models/t_join_share_type.go +++ /dev/null @@ -1,9 +0,0 @@ -package models - -type TJoinShareType struct { - Id int32 `xorm:"not null pk autoincr comment('主键ID') INT(11)"` - AppId string `xorm:"not null comment('接入系统的client_id') index VARCHAR(255)"` - DatatypeCode string `xorm:"not null comment('数据类型代码') unique VARCHAR(255)"` - DatatypeName string `xorm:"not null comment('数据类型名称') VARCHAR(255)"` - IndexName string `xorm:"not null comment('索引名称') VARCHAR(255)"` -} diff --git a/dsSupport/MyModel/AccessSystem/AccessSystemDao/AccessSystemDao.go b/dsSupport/MyModel/AccessSystem/AccessSystemDao/AccessSystemDao.go index 371fc606..837cff64 100644 --- a/dsSupport/MyModel/AccessSystem/AccessSystemDao/AccessSystemDao.go +++ b/dsSupport/MyModel/AccessSystem/AccessSystemDao/AccessSystemDao.go @@ -57,7 +57,7 @@ func DelApp(appId string) error { model := new(models.TAppBase) _, err := db.ID(appId).Delete(model) //删除REDIS缓存 - //TODO + //RedisUtil.DEL("TJoinApp:" + appId) return err }