|
|
package AccessSystemController
|
|
|
|
|
|
import (
|
|
|
"dsSupport/Model"
|
|
|
"dsSupport/MyModel/AccessSystem/AccessSystemDao"
|
|
|
"dsSupport/Utils/CommonUtil"
|
|
|
"fmt"
|
|
|
"github.com/gin-gonic/gin"
|
|
|
"net/http"
|
|
|
"os"
|
|
|
"strings"
|
|
|
)
|
|
|
|
|
|
//模块的路由配置
|
|
|
func Routers(r *gin.RouterGroup) {
|
|
|
rr := r.Group("/accessSystem")
|
|
|
//配置接口
|
|
|
rr.GET("/PageAccessSystemInfo", PageAccessSystemInfo)
|
|
|
rr.POST("/AddAccessSystemInfo", AddAccessSystemInfo)
|
|
|
rr.POST("/UpdateAccessSystemInfo", UpdateAccessSystemInfo)
|
|
|
rr.POST("/DeleteAccessSystemInfo", DeleteAccessSystemInfo)
|
|
|
rr.GET("/GetAccessSystemRangeInfo", GetAccessSystemRangeInfo)
|
|
|
rr.POST("/SettingAccessSystemRangeInfo", SettingAccessSystemRangeInfo)
|
|
|
rr.GET("/GetAccessSystemSsoInfo", GetAccessSystemSsoInfo)
|
|
|
rr.POST("/SettingAccessSystemSsoInfo", SettingAccessSystemSsoInfo)
|
|
|
rr.POST("/EmptyAccessSystemSsoInfo", EmptyAccessSystemSsoInfo)
|
|
|
rr.GET("/GetAccessSystemIntegratedInfo", GetAccessSystemIntegratedInfo)
|
|
|
rr.POST("/SettingAccessSystemIntegratedInfo", SettingAccessSystemIntegratedInfo)
|
|
|
rr.POST("/EmptyAccessSystemIntegratedInfo", EmptyAccessSystemIntegratedInfo)
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// @Summary 获取接入系统列表
|
|
|
// @Description 获取接入系统列表
|
|
|
// @Tags 接入系统
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param page query int true "第几页"
|
|
|
// @Param limit query int true "一页显示多少条"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /support/accessSystem/PageAccessSystemInfo [get]
|
|
|
// @X-EmptyLimit ["page","limit"]
|
|
|
// @X-IntRangeLimit [{"page":"1,1000"},{"limit":"1,1000"}]
|
|
|
// @X-TableName ["t_app_base"]
|
|
|
// @X-Sort [0]
|
|
|
func PageAccessSystemInfo(c *gin.Context) {
|
|
|
//第几页
|
|
|
page := CommonUtil.ConvertStringToInt(c.Query("page"))
|
|
|
//一页显示多少条
|
|
|
limit := CommonUtil.ConvertStringToInt(c.Query("limit"))
|
|
|
|
|
|
res, count, err := AccessSystemDao.ListApp("", page, limit)
|
|
|
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: res,
|
|
|
Count: count,
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
// @Summary 增加接入系统
|
|
|
// @Description 增加接入系统
|
|
|
// @Tags 接入系统
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param appName formData string true "系统名称"
|
|
|
// @Param appCode formData string true "系统编码"
|
|
|
// @Param sortId formData int false "排序号"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /support/accessSystem/AddAccessSystemInfo [post]
|
|
|
// @X-EmptyLimit ["appName","appCode"]
|
|
|
// @X-LengthLimit [{"appName":"2,30"},{"appCode":"2,20"}]
|
|
|
// @X-TableName ["t_app_base"]
|
|
|
// @X-Sort [1]
|
|
|
func AddAccessSystemInfo(c *gin.Context) {
|
|
|
//系统名称
|
|
|
appName := c.PostForm("appName")
|
|
|
//系统编码
|
|
|
appCode := c.PostForm("appCode")
|
|
|
//排序号
|
|
|
sortId := CommonUtil.ConvertStringToInt32(c.PostForm("sortId"))
|
|
|
err := AccessSystemDao.AddApp(appCode, appName, sortId)
|
|
|
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 修改接入系统
|
|
|
// @Description 修改接入系统
|
|
|
// @Tags 接入系统
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param appId formData string true "系统ID"
|
|
|
// @Param appName formData string true "系统名称"
|
|
|
// @Param appCode formData string true "系统编码"
|
|
|
// @Param sortId formData int false "排序号"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /support/accessSystem/UpdateAccessSystemInfo [post]
|
|
|
// @X-EmptyLimit ["appId","appName","appCode"]
|
|
|
// @X-LengthLimit [{"appId":"36,36"},{"appName":"2,30"},{"appCode":"2,20"}]
|
|
|
// @X-TableName ["t_app_base"]
|
|
|
// @X-Sort [2]
|
|
|
func UpdateAccessSystemInfo(c *gin.Context) {
|
|
|
//系统ID
|
|
|
appId := c.PostForm("appId")
|
|
|
//系统名称
|
|
|
appName := c.PostForm("appName")
|
|
|
//系统编码
|
|
|
appCode := c.PostForm("appCode")
|
|
|
//排序号
|
|
|
sortId := CommonUtil.ConvertStringToInt32(c.PostForm("sortId"))
|
|
|
err := AccessSystemDao.UpdateApp(appId, appCode, appName, sortId)
|
|
|
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 删除接入系统
|
|
|
// @Description 删除接入系统
|
|
|
// @Tags 接入系统
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param appId formData string true "系统ID"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /support/accessSystem/DeleteAccessSystemInfo [post]
|
|
|
// @X-EmptyLimit ["appId"]
|
|
|
// @X-LengthLimit [{"appId":"36,36"}]
|
|
|
// @X-TableName ["t_app_base"]
|
|
|
// @X-Sort [3]
|
|
|
func DeleteAccessSystemInfo(c *gin.Context) {
|
|
|
//系统ID
|
|
|
appId := c.PostForm("appId")
|
|
|
err := AccessSystemDao.DelApp(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 获取接入系统的使用范围
|
|
|
// @Description 获取接入系统的使用范围
|
|
|
// @Tags 接入系统
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param appId query string true "系统ID"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /support/accessSystem/GetAccessSystemRangeInfo [get]
|
|
|
// @X-EmptyLimit ["appId"]
|
|
|
// @X-LengthLimit [{"appId":"36,36"}]
|
|
|
// @X-TableName ["t_app_base"]
|
|
|
// @X-Sort [5]
|
|
|
func GetAccessSystemRangeInfo(c *gin.Context) {
|
|
|
//系统ID
|
|
|
appId := c.Query("appId")
|
|
|
fmt.Println(appId)
|
|
|
}
|
|
|
|
|
|
// @Summary 设置接入系统的使用范围
|
|
|
// @Description 设置接入系统的使用范围
|
|
|
// @Tags 接入系统
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param appId formData string true "系统ID"
|
|
|
// @Param rangeCode formData string true "使用范围的行政区划码、单位ID,多个用逗号分隔"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /support/accessSystem/SettingAccessSystemRange [post]
|
|
|
// @X-EmptyLimit ["orgId","rangeCode"]
|
|
|
// @X-LengthLimit [{"orgId":"36,36"},{"rangeCode":"1,3700"}]
|
|
|
// @X-TableName ["t_app_base"]
|
|
|
// @X-Sort [4]
|
|
|
func SettingAccessSystemRangeInfo(c *gin.Context) {
|
|
|
//系统ID
|
|
|
appId := c.PostForm("appId")
|
|
|
//使用范围的行政区划码、单位ID,多个用逗号分隔
|
|
|
rangeCode := c.PostForm("rangeCode")
|
|
|
arr := make([]string, 0)
|
|
|
if len(rangeCode) > 0 {
|
|
|
arr = strings.Split(rangeCode, ",")
|
|
|
}
|
|
|
|
|
|
err := AccessSystemDao.SaveAppRange(appId, arr)
|
|
|
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 获取接入系统的统一认证信息
|
|
|
// @Description 获取接入系统的统一认证信息
|
|
|
// @Tags 接入系统
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param appId query string true "系统ID"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /support/accessSystem/GetAccessSystemSsoInfo [get]
|
|
|
// @X-EmptyLimit ["appId"]
|
|
|
// @X-LengthLimit [{"appId":"36,36"}]
|
|
|
// @X-TableName ["t_app_base"]
|
|
|
// @X-Sort [6]
|
|
|
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 设置接入系统的统一认证信息
|
|
|
// @Description 设置接入系统的统一认证信息
|
|
|
// @Tags 接入系统
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param appId formData string true "系统ID"
|
|
|
// @Param redirectUri formData string true "统一认证回调地址"
|
|
|
// @Param logoutUri formData string false "统一认证登出地址"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /support/accessSystem/SettingAccessSystemSsoInfo [post]
|
|
|
// @X-EmptyLimit ["appId","redirectUri"]
|
|
|
// @X-LengthLimit [{"appId":"36,36"},{"redirectUri":"2,300"},{"logoutUri":"2,300"}]
|
|
|
// @X-TableName ["t_app_base"]
|
|
|
// @X-Sort [7]
|
|
|
func SettingAccessSystemSsoInfo(c *gin.Context) {
|
|
|
//系统ID
|
|
|
appId := c.PostForm("appId")
|
|
|
//统一认证回调地址
|
|
|
redirectUri := c.PostForm("redirectUri")
|
|
|
//统一认证登出地址
|
|
|
logoutUri := c.PostForm("logoutUri")
|
|
|
|
|
|
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: "操作成功!",
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
// @Summary 清空接入系统的统一认证信息
|
|
|
// @Description 清空接入系统的统一认证信息
|
|
|
// @Tags 接入系统
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param appId formData string true "系统ID"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /support/accessSystem/EmptyAccessSystemSsoInfo [post]
|
|
|
// @X-EmptyLimit ["orgId"]
|
|
|
// @X-LengthLimit [{"orgId":"36,36"}]
|
|
|
// @X-TableName ["t_app_base"]
|
|
|
// @X-Sort [8]
|
|
|
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 获取接入系统的集成信息
|
|
|
// @Description 获取接入系统的集成信息
|
|
|
// @Tags 接入系统
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param appId query string true "系统ID"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /support/accessSystem/GetAccessSystemIntegratedInfo [get]
|
|
|
// @X-EmptyLimit ["appId"]
|
|
|
// @X-LengthLimit [{"appId":"36,36"}]
|
|
|
// @X-TableName ["t_app_base"]
|
|
|
// @X-Sort [6]
|
|
|
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 设置接入系统的集成信息
|
|
|
// @Description 设置接入系统的集成信息
|
|
|
// @Tags 接入系统
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param appId formData string true "系统ID"
|
|
|
// @Param appUrl formData string true "接入系统在集成页面的调用地址"
|
|
|
// @Param appIcon formData file true "接入系统在集成页面的图标"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /support/accessSystem/SettingAccessSystemIntegratedInfo [post]
|
|
|
// @X-EmptyLimit ["appId","redirectUri"]
|
|
|
// @X-LengthLimit [{"appId":"36,36"},{"redirectUri":"2,300"},{"logoutUri":"2,300"}]
|
|
|
// @X-TableName ["t_app_base"]
|
|
|
// @X-Sort [7]
|
|
|
func SettingAccessSystemIntegratedInfo(c *gin.Context) {
|
|
|
//系统ID
|
|
|
appId := c.PostForm("appId")
|
|
|
//接入系统在集成页面的调用地址
|
|
|
redirectUri := c.PostForm("redirectUri")
|
|
|
//接入系统在集成页面的图标
|
|
|
header, _ := c.FormFile("icon")
|
|
|
rootPath, _ := os.Getwd()
|
|
|
iconDir := rootPath + "/Html/Icon/"
|
|
|
//生成图标的ID
|
|
|
iconFileId := CommonUtil.GetUUID()
|
|
|
iconFileName := strings.Split(header.Filename, ".")[1]
|
|
|
iconPath := iconDir + iconFileId + "." + iconFileName
|
|
|
//保存图标
|
|
|
c.SaveUploadedFile(header, iconPath)
|
|
|
|
|
|
err := AccessSystemDao.UpdateIntegration(appId, redirectUri, "/dsSupport/Icon/"+iconFileName)
|
|
|
|
|
|
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 清空接入系统的集成信息
|
|
|
// @Description 清空接入系统的集成信息
|
|
|
// @Tags 接入系统
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param appId formData string true "系统ID"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /support/accessSystem/EmptyAccessSystemIntegratedInfo [post]
|
|
|
// @X-EmptyLimit ["orgId"]
|
|
|
// @X-LengthLimit [{"orgId":"36,36"}]
|
|
|
// @X-TableName ["t_app_base"]
|
|
|
// @X-Sort [8]
|
|
|
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: "操作成功!",
|
|
|
})
|
|
|
}
|