diff --git a/dsSupport/MyModel/AccessSystem/AccessSystemController/AccessSystemController.go b/dsSupport/MyModel/AccessSystem/AccessSystemController/AccessSystemController.go index f3142793..a60df640 100644 --- a/dsSupport/MyModel/AccessSystem/AccessSystemController/AccessSystemController.go +++ b/dsSupport/MyModel/AccessSystem/AccessSystemController/AccessSystemController.go @@ -4,6 +4,7 @@ import ( "dsSupport/Model" "dsSupport/MyModel/AccessSystem/AccessSystemDao" "dsSupport/Utils/CommonUtil" + "fmt" "github.com/gin-gonic/gin" "net/http" "strings" @@ -19,7 +20,6 @@ func Routers(r *gin.RouterGroup) { rr.POST("/DeleteAccessSystemInfo", DeleteAccessSystemInfo) rr.GET("/GetAccessSystemRangeInfo", GetAccessSystemRangeInfo) rr.POST("/SettingAccessSystemRangeInfo", SettingAccessSystemRangeInfo) - rr.POST("/EmptyAccessSystemRangeInfo", EmptyAccessSystemRangeInfo) rr.GET("/GetAccessSystemSsoInfo", GetAccessSystemSsoInfo) rr.POST("/SettingAccessSystemSsoInfo", SettingAccessSystemSsoInfo) rr.POST("/EmptyAccessSystemSsoInfo", EmptyAccessSystemSsoInfo) @@ -45,9 +45,9 @@ func Routers(r *gin.RouterGroup) { // @X-Sort [0] func PageAccessSystemInfo(c *gin.Context) { //第几页 - page := CommonUtil.ConvertStringToInt32(c.Query("page")) + page := CommonUtil.ConvertStringToInt(c.Query("page")) //一页显示多少条 - limit := CommonUtil.ConvertStringToInt32(c.Query("limit")) + limit := CommonUtil.ConvertStringToInt(c.Query("limit")) res, count, err := AccessSystemDao.ListApp("", page, limit) if err != nil { @@ -237,6 +237,19 @@ func SettingAccessSystemRangeInfo(c *gin.Context) { func GetAccessSystemSsoInfo(c *gin.Context) { //系统ID appId := c.Query("appId") + res, err := AccessSystemDao.GetApp(appId) + if err != nil { + c.JSON(http.StatusOK, Model.Res{ + Success: false, + Message: err.Error(), + }) + return + } + c.JSON(http.StatusOK, Model.Res{ + Success: true, + Message: "操作成功!", + List: CommonUtil.MapKeepFields(res, "redirect_uri", "logout_uri"), + }) } // @Summary 设置接入系统的统一认证信息 @@ -261,7 +274,19 @@ func SettingAccessSystemSsoInfo(c *gin.Context) { //统一认证登出地址 logoutUri := c.PostForm("logoutUri") - AccessSystemDao.UpdateSso() + err := AccessSystemDao.UpdateSso(appId, redirectUri, logoutUri) + + if err != nil { + c.JSON(http.StatusOK, Model.Res{ + Success: false, + Message: err.Error(), + }) + return + } + c.JSON(http.StatusOK, Model.Res{ + Success: true, + Message: "操作成功!", + }) } @@ -280,6 +305,19 @@ func SettingAccessSystemSsoInfo(c *gin.Context) { func EmptyAccessSystemSsoInfo(c *gin.Context) { //系统ID appId := c.PostForm("appId") + err := AccessSystemDao.ClearSso(appId) + + if err != nil { + c.JSON(http.StatusOK, Model.Res{ + Success: false, + Message: err.Error(), + }) + return + } + c.JSON(http.StatusOK, Model.Res{ + Success: true, + Message: "操作成功!", + }) } // @Summary 获取接入系统的集成信息 @@ -297,6 +335,20 @@ func EmptyAccessSystemSsoInfo(c *gin.Context) { func GetAccessSystemIntegratedInfo(c *gin.Context) { //系统ID appId := c.Query("appId") + + res, err := AccessSystemDao.GetApp(appId) + if err != nil { + c.JSON(http.StatusOK, Model.Res{ + Success: false, + Message: err.Error(), + }) + return + } + c.JSON(http.StatusOK, Model.Res{ + Success: true, + Message: "操作成功!", + List: CommonUtil.MapKeepFields(res, "app_url", "app_icon"), + }) } // @Summary 设置接入系统的集成信息 @@ -321,7 +373,22 @@ func SettingAccessSystemIntegratedInfo(c *gin.Context) { //接入系统在集成页面的图标 header, _ := c.FormFile("excelFile") //生成图标的ID - iconFileId := CommonUtil.GetUUID() + //iconFileId := CommonUtil.GetUUID() + fmt.Println(header) + + err := AccessSystemDao.UpdateIntegration(appId, redirectUri, "") + + if err != nil { + c.JSON(http.StatusOK, Model.Res{ + Success: false, + Message: err.Error(), + }) + return + } + c.JSON(http.StatusOK, Model.Res{ + Success: true, + Message: "操作成功!", + }) } @@ -340,4 +407,17 @@ func SettingAccessSystemIntegratedInfo(c *gin.Context) { func EmptyAccessSystemIntegratedInfo(c *gin.Context) { //系统ID appId := c.PostForm("appId") + err := AccessSystemDao.ClearIntegration(appId) + + if err != nil { + c.JSON(http.StatusOK, Model.Res{ + Success: false, + Message: err.Error(), + }) + return + } + c.JSON(http.StatusOK, Model.Res{ + Success: true, + Message: "操作成功!", + }) } diff --git a/dsSupport/Utils/CommonUtil/CommonUtil.go b/dsSupport/Utils/CommonUtil/CommonUtil.go index 5ab0bd9a..473f5949 100644 --- a/dsSupport/Utils/CommonUtil/CommonUtil.go +++ b/dsSupport/Utils/CommonUtil/CommonUtil.go @@ -631,6 +631,7 @@ func CopyFields(sourceStruct interface{}, targetStruct interface{}, fields ...st } return } + // Convert json string to map func JsonToMap(jsonStr string) (map[string]string, error) { m := make(map[string]string) @@ -673,4 +674,27 @@ func CompressStr(str string) string { func ConvertStringToInt32(s string) int32 { i, _ := strconv.Atoi(s) return int32(i) -} \ No newline at end of file +} + +/** +功能:将一个MAP保留fields中的无素 +作者:吴缤 +日期:2020-08-24 +*/ +func MapKeepFields(m map[string]interface{}, fields ...string) map[string]interface{} { + for s := range m { + if !IsContain(fields, s) { + delete(m, s) + } + } + return m +} + +func IsContain(items []string, item string) bool { + for _, eachItem := range items { + if eachItem == item { + return true + } + } + return false +} diff --git a/dsSupport/go.mod b/dsSupport/go.mod index 23f36b58..d063da4b 100644 --- a/dsSupport/go.mod +++ b/dsSupport/go.mod @@ -8,23 +8,23 @@ require ( github.com/CloudyKit/jet v2.1.2+incompatible // indirect github.com/agrison/go-tablib v0.0.0-20160310143025-4930582c22ee // indirect github.com/agrison/mxj v0.0.0-20160310142625-1269f8afb3b4 // indirect - github.com/bluesky335/IDCheck v0.0.0-20200319021444-08ee85bfcb7b // indirect + github.com/bluesky335/IDCheck v0.0.0-20200319021444-08ee85bfcb7b github.com/bndr/gotabulate v1.1.2 // indirect github.com/fatih/structs v1.1.0 // indirect github.com/fsnotify/fsnotify v1.4.9 // indirect github.com/gin-gonic/gin v1.6.3 - github.com/go-redis/redis/v7 v7.4.0 // indirect - github.com/go-sql-driver/mysql v1.5.0 // indirect + github.com/go-redis/redis/v7 v7.4.0 + github.com/go-sql-driver/mysql v1.5.0 github.com/golang/snappy v0.0.1 // indirect - github.com/oklog/ulid v1.3.1 // indirect - github.com/rs/xid v1.2.1 // indirect + github.com/oklog/ulid v1.3.1 + github.com/rs/xid v1.2.1 github.com/satori/go.uuid v1.2.0 github.com/swaggo/gin-swagger v1.2.0 github.com/syndtr/goleveldb v1.0.0 // indirect github.com/tealeg/xlsx v1.0.5 // indirect - github.com/xormplus/builder v0.0.0-20200331055651-240ff40009be // indirect - github.com/xormplus/core v0.0.0-20200308074340-f3bce19d5f31 // indirect - github.com/xormplus/xorm v0.0.0-20200731130200-6811f3bde592 // indirect + github.com/xormplus/builder v0.0.0-20200331055651-240ff40009be + github.com/xormplus/core v0.0.0-20200308074340-f3bce19d5f31 + github.com/xormplus/xorm v0.0.0-20200731130200-6811f3bde592 golang.org/x/sys v0.0.0-20200821140526-fda516888d29 // indirect gopkg.in/flosch/pongo2.v3 v3.0.0-20141028000813-5e81b817a0c4 // indirect gopkg.in/ini.v1 v1.60.1 diff --git a/dsSupport/go.sum b/dsSupport/go.sum index e03112f2..3b132eda 100644 --- a/dsSupport/go.sum +++ b/dsSupport/go.sum @@ -139,6 +139,7 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190611141213-3f473d35a33a h1:+KkCgOMgnKSgenxTBoiwkMqTiouMIy/3o8RLdmSbGoY= golang.org/x/net v0.0.0-20190611141213-3f473d35a33a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190923162816-aa69164e4478 h1:l5EDrHhldLYb3ZRHDUhXF7Om7MvYXnkV9/iQNo1lX6g= golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=