|
|
package DatahyperOpenapi
|
|
|
|
|
|
import (
|
|
|
"dsDataex/MyHyper/DataHyper/DatahyperService"
|
|
|
"dsDataex/MyHyper/MySwagger"
|
|
|
"dsDataex/MyService/Auth/AuthService"
|
|
|
"dsDataex/MyService/DataEX/DataexService"
|
|
|
"dsDataex/Utils/CommonUtil"
|
|
|
"dsDataex/Utils/ValidationUtil"
|
|
|
"github.com/gin-gonic/gin"
|
|
|
"net/http"
|
|
|
"strings"
|
|
|
)
|
|
|
|
|
|
// 接入系统
|
|
|
var platforms = []string{"xpt", "ypt"}
|
|
|
|
|
|
// @Summary 超融合数据查询(后台)
|
|
|
// @Description 【超融合服务】超融合数据查询接口,使用自定义的查询,返回查询结果数据。
|
|
|
// @Tags hyper
|
|
|
// @Accept json
|
|
|
// @Produce json
|
|
|
// @Param input body MySwagger.DatahyperQuery true "查询参数"
|
|
|
// @Success 200 {object} MySwagger.DatahyperGetResult
|
|
|
// @Failure 400 {object} MySwagger.DatahyperGetResult
|
|
|
// @Router /dataex/hyper_ypt/Query [post]
|
|
|
func Query(c *gin.Context) {
|
|
|
var input MySwagger.DatahyperQuery
|
|
|
platform := c.Param("platform")
|
|
|
|
|
|
if err := c.ShouldBindJSON(&input); err != nil {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{Success: false, Message: "查询数据JSON格式错误"})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if input.QueryID == "" {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{Success: false, Message: "查询数据QueryID不能为空"})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//TODO:数据查询权限验证 !!!
|
|
|
var temp = strings.Split(input.AccessToken, "##")
|
|
|
|
|
|
if len(temp) != 3 {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{Success: false, Message: "接入系统票据格式不正确"})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
flag, _, systemID := AuthService.CheckAccessToken(temp[0], temp[1], temp[2])
|
|
|
|
|
|
if flag == false {
|
|
|
//c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{Success: false,Message: "接入系统票据不正确"})
|
|
|
//return
|
|
|
}
|
|
|
|
|
|
flag2, _ := DataexService.CheckDatasourceSql(systemID, input.QueryID)
|
|
|
|
|
|
if flag2 == false {
|
|
|
//c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{Success: false,Message: "接入系统GP-SQL查询权限验证失败"})
|
|
|
//return
|
|
|
}
|
|
|
|
|
|
// 接入系统URL后缀校验
|
|
|
if ! CommonUtil.StringArrayContain(platforms, platform) {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{Success: false, Message: "接入系统请求URL后缀错误"})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
res, msg, count, data, _ := DatahyperService.GetResults(platform, input)
|
|
|
if res {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{
|
|
|
Success: true,
|
|
|
Message: msg,
|
|
|
Total: count,
|
|
|
Result: data,
|
|
|
})
|
|
|
} else {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{
|
|
|
Success: false,
|
|
|
Message: msg,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// @Summary 超融合数据详情查询(后台)
|
|
|
// @Description 【超融合服务】超融合数据详情查询接口,使用自定义的查询,返回查询详情数据。
|
|
|
// @Tags hyper
|
|
|
// @Accept json
|
|
|
// @Produce json
|
|
|
// @Param input body MySwagger.DatahyperQueryByID true "查询参数"
|
|
|
// @Success 200 {object} MySwagger.DatahyperGet
|
|
|
// @Failure 400 {object} MySwagger.DatahyperGet
|
|
|
// @Router /dataex/hyper_ypt/QueryByID [post]
|
|
|
func QueryByID(c *gin.Context) {
|
|
|
var input MySwagger.DatahyperQueryByID
|
|
|
platform := c.Param("platform")
|
|
|
|
|
|
if err := c.ShouldBindJSON(&input); err != nil {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{Success: false, Message: "查询数据JSON格式错误"})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if input.QueryID == "" {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{Success: false, Message: "查询数据QueryID不能为空"})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//TODO:数据查询权限验证 !!!
|
|
|
var temp = strings.Split(input.AccessToken, "##")
|
|
|
|
|
|
if len(temp) != 3 {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{Success: false, Message: "接入系统票据格式不正确"})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
flag, _, systemID := AuthService.CheckAccessToken(temp[0], temp[1], temp[2])
|
|
|
|
|
|
if flag == false {
|
|
|
//c.JSON(http.StatusOK, MySwagger.DatahyperGet{Success: false,Message: "接入系统票据不正确"})
|
|
|
//return
|
|
|
}
|
|
|
|
|
|
flag2, _ := DataexService.CheckDatasourceSql(systemID, input.QueryID)
|
|
|
|
|
|
if flag2 == false {
|
|
|
//c.JSON(http.StatusOK, MySwagger.DatahyperGet{Success: false,Message: "接入系统GP-SQL查询权限验证失败"})
|
|
|
//return
|
|
|
}
|
|
|
|
|
|
// 接入系统URL后缀校验
|
|
|
if ! CommonUtil.StringArrayContain(platforms, platform) {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{Success: false, Message: "接入系统请求URL后缀错误"})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
res, msg, data, _ := DatahyperService.GetRow(platform, input)
|
|
|
if res {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGet{
|
|
|
Success: true,
|
|
|
Message: msg,
|
|
|
Result: data,
|
|
|
})
|
|
|
} else {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGet{
|
|
|
Success: false,
|
|
|
Message: msg,
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// @Summary 超融合数据查询(前端)
|
|
|
// @Description 【超融合服务】超融合数据查询接口,使用自定义的查询,返回查询结果数据。
|
|
|
// @Tags hyper
|
|
|
// @Accept json
|
|
|
// @Produce json
|
|
|
// @Param input body MySwagger.DatahyperQueryFE true "查询参数"
|
|
|
// @Success 200 {object} MySwagger.DatahyperGetResult
|
|
|
// @Failure 400 {object} MySwagger.DatahyperGetResult
|
|
|
// @Router /dataex/hyper_ypt/QueryFE [post]
|
|
|
func QueryFE(c *gin.Context) {
|
|
|
var input MySwagger.DatahyperQueryFE
|
|
|
platform := c.Param("platform")
|
|
|
|
|
|
if err := c.ShouldBindJSON(&input); err != nil {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{Success: false, Message: "查询数据JSON格式错误"})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if input.QueryID == "" {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{Success: false, Message: "查询数据QueryID不能为空"})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//TODO:数据查询权限验证 !!!
|
|
|
var temp = strings.Split(input.AccessToken, "##")
|
|
|
|
|
|
if len(temp) != 3 {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{Success: false, Message: "接入系统票据格式不正确"})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
flag, _, systemID := AuthService.CheckAccessToken(temp[0], temp[1], temp[2])
|
|
|
|
|
|
if flag == false {
|
|
|
//c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{Success: false,Message: "接入系统票据不正确"})
|
|
|
//return
|
|
|
}
|
|
|
|
|
|
flag2, _ := DataexService.CheckDatasourceSql(systemID, input.QueryID)
|
|
|
|
|
|
if flag2 == false {
|
|
|
//c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{Success: false,Message: "接入系统GP-SQL查询权限验证失败"})
|
|
|
//return
|
|
|
}
|
|
|
|
|
|
// 接入系统URL后缀校验
|
|
|
if ! CommonUtil.StringArrayContain(platforms, platform) {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{Success: false, Message: "接入系统请求URL后缀错误"})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 输入参数 SQL注入检测
|
|
|
if len(input.QueryCondition) > 0 {
|
|
|
result, msg, _ := ValidationUtil.ValidHyperSql(CommonUtil.ConvertInterfaceArrayToStringArray(input.QueryCondition))
|
|
|
if result == false {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{Success: false, Message: msg})
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 输入参数 SQL注入检测
|
|
|
if input.QueryCombination != "" {
|
|
|
var queryCombination []string
|
|
|
queryCombination = append(queryCombination, input.QueryCombination)
|
|
|
|
|
|
result, msg, _ := ValidationUtil.ValidHyperSql(queryCombination)
|
|
|
if result == false {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{Success: false, Message: msg})
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
|
|
|
res, msg, count, data, _ := DatahyperService.GetResultsFE(platform, input)
|
|
|
if res {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{
|
|
|
Success: true,
|
|
|
Message: msg,
|
|
|
Total: count,
|
|
|
Result: data,
|
|
|
})
|
|
|
} else {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{
|
|
|
Success: false,
|
|
|
Message: msg,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// @Summary 超融合数据详情查询(前端)
|
|
|
// @Description 【超融合服务】超融合数据详情查询接口,使用自定义的查询,返回查询详情数据。
|
|
|
// @Tags hyper
|
|
|
// @Accept json
|
|
|
// @Produce json
|
|
|
// @Param input body MySwagger.DatahyperQueryFEByID true "查询参数"
|
|
|
// @Success 200 {object} MySwagger.DatahyperGet
|
|
|
// @Failure 400 {object} MySwagger.DatahyperGet
|
|
|
// @Router /dataex/hyper_ypt/QueryFEByID [post]
|
|
|
func QueryFEByID(c *gin.Context) {
|
|
|
var input MySwagger.DatahyperQueryFEByID
|
|
|
platform := c.Param("platform")
|
|
|
|
|
|
if err := c.ShouldBindJSON(&input); err != nil {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{Success: false, Message: "查询数据JSON格式错误"})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if input.QueryID == "" {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{Success: false, Message: "查询数据QueryID不能为空"})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//TODO:数据查询权限验证 !!!
|
|
|
var temp = strings.Split(input.AccessToken, "##")
|
|
|
|
|
|
if len(temp) != 3 {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{Success: false, Message: "接入系统票据格式不正确"})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
flag, _, systemID := AuthService.CheckAccessToken(temp[0], temp[1], temp[2])
|
|
|
|
|
|
if flag == false {
|
|
|
//c.JSON(http.StatusOK, MySwagger.DatahyperGet{Success: false,Message: "接入系统票据不正确"})
|
|
|
//return
|
|
|
}
|
|
|
|
|
|
flag2, _ := DataexService.CheckDatasourceSql(systemID, input.QueryID)
|
|
|
|
|
|
if flag2 == false {
|
|
|
//c.JSON(http.StatusOK, MySwagger.DatahyperGet{Success: false,Message: "接入系统GP-SQL查询权限验证失败"})
|
|
|
//return
|
|
|
}
|
|
|
|
|
|
// 接入系统URL后缀校验
|
|
|
if ! CommonUtil.StringArrayContain(platforms, platform) {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGetResult{Success: false, Message: "接入系统请求URL后缀错误"})
|
|
|
return
|
|
|
}
|
|
|
res, msg, data, _ := DatahyperService.GetRowFE(platform, input)
|
|
|
if res {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGet{
|
|
|
Success: true,
|
|
|
Message: msg,
|
|
|
Result: data,
|
|
|
})
|
|
|
} else {
|
|
|
c.JSON(http.StatusOK, MySwagger.DatahyperGet{
|
|
|
Success: false,
|
|
|
Message: msg,
|
|
|
})
|
|
|
}
|
|
|
} |