parent
f752eef08b
commit
bb74171a3b
@ -1,18 +0,0 @@
|
||||
package DataaccessController
|
||||
|
||||
import (
|
||||
"dsDataex/MyModel/DataAccess/DataaccessOpenAPI"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// Gin 路由配置
|
||||
func Routers(r *gin.RouterGroup) {
|
||||
rr := r.Group("/openapi")
|
||||
|
||||
rr.POST("/dataaccess/ReadDataaccess", DataaccessOpenAPI.ReadDataaccess)
|
||||
rr.POST("/dataaccess/CreateDataaccess", DataaccessOpenAPI.CreateDataaccess)
|
||||
rr.POST("/dataaccess/UpdateDataaccess/:id", DataaccessOpenAPI.UpdateDataaccess)
|
||||
rr.POST("/dataaccess/DeleteDataaccess/:id", DataaccessOpenAPI.DeleteDataaccess)
|
||||
|
||||
return
|
||||
}
|
@ -1,182 +0,0 @@
|
||||
package DataaccessOpenAPI
|
||||
|
||||
import (
|
||||
"dsDataex/GenXorm/models"
|
||||
"dsDataex/MyModel/DataAccess/DataaccessService"
|
||||
"dsDataex/MyModel/MySwagger"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// 获取数据订阅列表 godoc
|
||||
// @Summary 获取数据订阅列表
|
||||
// @Description 获取元数据列表
|
||||
// @Tags dataaccess
|
||||
// @ID readDataaccess
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param input body MySwagger.DataaccessSwag true "数据订阅"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/dataaccess/ReadDataaccess [post]
|
||||
func ReadDataaccess(c *gin.Context) {
|
||||
var raw MySwagger.DataaccessSwag
|
||||
|
||||
//input.AuthToken = c.Request.Header["Authorization"][0]
|
||||
//queryString := c.Request.URL.Query().Encode()
|
||||
|
||||
if err := c.ShouldBindJSON(&raw); err != nil {
|
||||
c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Message: "接入系统数据JSON格式错误"})
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
fmt.Println("json.page=", raw.Page)
|
||||
success, message, count, data, _ := DataaccessService.GetDataaccessResults(raw)
|
||||
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
Total: count,
|
||||
Data: data,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 创建数据订阅 godoc
|
||||
// @Summary 创建数据订阅
|
||||
// @Description 创建数据订阅
|
||||
// @Tags dataaccess
|
||||
// @ID createDataaccess
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param input body MySwagger.DataaccessSwag true "数据订阅"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/dataaccess/CreateDataaccess [post]
|
||||
func CreateDataaccess(c *gin.Context) {
|
||||
var raw models.TDataexDataaccess
|
||||
|
||||
if err := c.ShouldBindJSON(&raw); err != nil {
|
||||
c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Message: "接入系统数据JSON格式错误"})
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
success, message, _ := DataaccessService.CreateDataaccess(raw)
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 修改数据订阅 godoc
|
||||
// @Summary 修改数据订阅
|
||||
// @Description 修改数据订阅
|
||||
// @Tags dataaccess
|
||||
// @ID updateDataaccess
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "数据订阅ID"
|
||||
// @Param input body MySwagger.DataaccessSwag true "数据订阅"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/dataaccess/UpdateDataaccess/{id} [post]
|
||||
func UpdateDataaccess(c *gin.Context) {
|
||||
var raw models.TDataexDataaccess
|
||||
|
||||
ID := c.Param("id")
|
||||
|
||||
if err := c.ShouldBindJSON(&raw); err != nil {
|
||||
c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Fail: true, Message: "接入系统数据JSON格式错误"})
|
||||
return
|
||||
}
|
||||
|
||||
success, message, _ := DataaccessService.UpdateDataaccess(ID, raw)
|
||||
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 删除数据订阅 godoc
|
||||
// @Summary 删除数据订阅
|
||||
// @Description 删除数据订阅
|
||||
// @Tags dataaccess
|
||||
// @ID deleteDataaccess
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "数据订阅ID"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/dataaccess/DeleteDataaccess/{id} [post]
|
||||
func DeleteDataaccess(c *gin.Context) {
|
||||
ID := c.Param("id")
|
||||
|
||||
success, message, _ := DataaccessService.RemoveDataaccess(ID)
|
||||
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
@ -1,145 +0,0 @@
|
||||
package DataaccessService
|
||||
|
||||
import (
|
||||
"dsDataex/GenXorm/models"
|
||||
"dsDataex/MyModel/DataAccess/DataaccessDAO"
|
||||
"dsDataex/MyModel/DataSource/DatasourceService"
|
||||
"dsDataex/MyModel/LinkSystem/LinksystemService"
|
||||
"dsDataex/MyModel/MySwagger"
|
||||
"dsDataex/MyModel/OrgTree/OrgtreeService"
|
||||
"dsDataex/Utils/CacheUtil"
|
||||
"dsDataex/Utils/CommonUtil"
|
||||
"html"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func GetDataaccessResults(swag MySwagger.DataaccessSwag) (bool, string, int32, []map[string]interface{}, error) {
|
||||
var condition string
|
||||
var conditions []string
|
||||
var page int
|
||||
var query MySwagger.DataaccessQuery
|
||||
|
||||
if swag.DatasourceId != "" {
|
||||
conditions = append(conditions, "datasource_id="+"'"+html.EscapeString(swag.DatasourceId)+"'")
|
||||
}
|
||||
if swag.ConsumeSystemid != "" {
|
||||
conditions = append(conditions, "consume_systemid="+"'"+html.EscapeString(swag.ConsumeSystemid)+"'")
|
||||
}
|
||||
if swag.QueryFlag != 0 {
|
||||
conditions = append(conditions, "query_flag="+"'"+strconv.Itoa(swag.QueryFlag)+"'")
|
||||
}
|
||||
if swag.SetFlag != 0 {
|
||||
conditions = append(conditions, "set_flag="+"'"+strconv.Itoa(swag.SetFlag)+"'")
|
||||
}
|
||||
if swag.ConsumeType != 0 {
|
||||
conditions = append(conditions, "consume_type="+"'"+strconv.Itoa(swag.ConsumeType)+"'")
|
||||
}
|
||||
if swag.ConsumeOrgid != "" {
|
||||
conditions = append(conditions, "consume_orgid="+"'"+html.EscapeString(swag.ConsumeOrgid)+"'")
|
||||
}
|
||||
if swag.DeleteFlag != 0 {
|
||||
conditions = append(conditions, "delete_flag="+"'"+strconv.Itoa(swag.DeleteFlag)+"'")
|
||||
}
|
||||
if swag.EnableFlag != 0 {
|
||||
conditions = append(conditions, "enable_flag="+"'"+strconv.Itoa(swag.EnableFlag)+"'")
|
||||
}
|
||||
if swag.Page != 0 {
|
||||
page = swag.Page
|
||||
query.Page = (page - 1) * 100
|
||||
} else {
|
||||
query.Page = 0
|
||||
}
|
||||
|
||||
if len(conditions) > 0 {
|
||||
condition = " AND " + strings.Join(conditions, " AND ")
|
||||
} else {
|
||||
condition = ""
|
||||
}
|
||||
query.Conditions = condition
|
||||
|
||||
result, message, count, data, failResult := DataaccessDAO.GetDataaccessResults(query)
|
||||
|
||||
return result, message, count, data, failResult
|
||||
}
|
||||
|
||||
func CreateDataaccess(model models.TDataexDataaccess) (bool, string, error) {
|
||||
if !DatasourceService.IsDatasourceExistsById(model.DatasourceId) {
|
||||
return false, "DatasourceId不存在", nil
|
||||
}
|
||||
if !LinksystemService.IsLinksystemExistsById(model.ConsumeSystemid) {
|
||||
return false, "SystemId不存在", nil
|
||||
}
|
||||
if !OrgtreeService.IsOrgtreeExistsById(model.ConsumeOrgid) {
|
||||
return false, "OrgId不存在", nil
|
||||
}
|
||||
|
||||
business := new(models.TDataexDataaccess)
|
||||
business.Id = CommonUtil.GetUUID()
|
||||
business.DatasourceId = html.EscapeString(model.DatasourceId)
|
||||
business.ConsumeSystemid = html.EscapeString(model.ConsumeSystemid)
|
||||
business.QueryFlag = model.QueryFlag
|
||||
business.SetFlag = model.SetFlag
|
||||
business.ConsumeType = model.ConsumeType
|
||||
business.ConsumeOrgid = html.EscapeString(model.ConsumeOrgid)
|
||||
business.CreateTime = time.Now()
|
||||
business.DeleteFlag = -1
|
||||
business.EnableFlag = 1
|
||||
|
||||
result, message, error := DataaccessDAO.CreateDataaccess(business)
|
||||
|
||||
return result, message, error
|
||||
}
|
||||
|
||||
func UpdateDataaccess(id string, model models.TDataexDataaccess) (bool, string, error) {
|
||||
if !DatasourceService.IsDatasourceExistsById(model.DatasourceId) {
|
||||
return false, "DatasourceId不存在", nil
|
||||
}
|
||||
if !LinksystemService.IsLinksystemExistsById(model.ConsumeSystemid) {
|
||||
return false, "SystemId不存在", nil
|
||||
}
|
||||
if !OrgtreeService.IsOrgtreeExistsById(model.ConsumeOrgid) {
|
||||
return false, "OrgId不存在", nil
|
||||
}
|
||||
|
||||
business := new(models.TDataexDataaccess)
|
||||
|
||||
//清除Redis缓存
|
||||
var ids = []string{id}
|
||||
var selector = CacheUtil.GetBean("t_dataex_dataaccess")
|
||||
CacheUtil.DeleteCacheByIds(ids, selector)
|
||||
|
||||
business.ChangeTime = time.Now()
|
||||
business.DatasourceId = html.EscapeString(model.DatasourceId)
|
||||
business.ConsumeSystemid = html.EscapeString(model.ConsumeSystemid)
|
||||
business.QueryFlag = model.QueryFlag
|
||||
business.SetFlag = model.SetFlag
|
||||
business.ConsumeType = model.ConsumeType
|
||||
business.ConsumeOrgid = html.EscapeString(model.ConsumeOrgid)
|
||||
business.CreateTime = time.Now()
|
||||
business.DeleteFlag = -1
|
||||
business.EnableFlag = 1
|
||||
result, message, error := DataaccessDAO.UpdateDataaccess(id, business)
|
||||
|
||||
return result, message, error
|
||||
}
|
||||
|
||||
func RemoveDataaccess(id string) (bool, string, error) {
|
||||
business := new(models.TDataexDataaccess)
|
||||
|
||||
//清除Redis缓存
|
||||
var ids = []string{id}
|
||||
var selector = CacheUtil.GetBean("t_dataex_dataaccess")
|
||||
CacheUtil.DeleteCacheByIds(ids, selector)
|
||||
|
||||
business.Id = html.EscapeString(id)
|
||||
business.ChangeTime = time.Now()
|
||||
business.DeleteTime = time.Now()
|
||||
business.DeleteFlag = 1
|
||||
business.EnableFlag = -1
|
||||
|
||||
result, message, error := DataaccessDAO.RemoveDataaccess(id, business)
|
||||
|
||||
return result, message, error
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
/**
|
||||
* @Title:
|
||||
* @Description:
|
||||
* @Author: Yuki Wong(iyuki0430@msn.com)
|
||||
* @Update:
|
||||
* @Date: 2020/7/20 11:49
|
||||
* @File: DataerrorController.go
|
||||
* @Software: GoLand
|
||||
**/
|
||||
package DataerrorController
|
||||
|
||||
import (
|
||||
"dsDataex/MyModel/DataError/DataerrorOpenAPI"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Routers(r *gin.RouterGroup) {
|
||||
rr := r.Group("/openapi")
|
||||
|
||||
//rr.Use(middleware.Cors())
|
||||
|
||||
rr.POST("/dataerror/ReadDataerror", DataerrorOpenAPI.ReadDataerror)
|
||||
rr.POST("/dataerror//DeleteDataerror/:id", DataerrorOpenAPI.DeleteDataerror)
|
||||
|
||||
return
|
||||
}
|
@ -1,102 +0,0 @@
|
||||
/**
|
||||
* @Title:
|
||||
* @Description:
|
||||
* @Author: Yuki Wong(iyuki0430@msn.com)
|
||||
* @Update:
|
||||
* @Date: 2020/7/20 11:50
|
||||
* @File: DataerrorOpenAPI.go
|
||||
* @Software: GoLand
|
||||
**/
|
||||
package DataerrorOpenAPI
|
||||
|
||||
import (
|
||||
"dsDataex/MyModel/DataError/DataerrorService"
|
||||
"dsDataex/MyModel/MySwagger"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// 获取数据异常表 godoc
|
||||
// @Summary 获取数据异常列表
|
||||
// @Description 获取数据异常列表
|
||||
// @Tags dataerror
|
||||
// @ID readDataerror
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param input body MySwagger.DataerrorSwag true "数据异常"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/dataerror/ReadDataerror [post]
|
||||
func ReadDataerror(c *gin.Context) {
|
||||
var raw MySwagger.DataerrorSwag
|
||||
|
||||
//input.AuthToken = c.Request.Header["Authorization"][0]
|
||||
|
||||
if err := c.ShouldBindJSON(&raw); err != nil {
|
||||
c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Message: "接入系统数据JSON格式错误"})
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
success, message, count, data, _ := DataerrorService.GetDataerrorResults(raw)
|
||||
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
Total: count,
|
||||
Data: data,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 删除数据异常 godoc
|
||||
// @Summary 删除数据异常
|
||||
// @Description 删除数据异常
|
||||
// @Tags dataerror
|
||||
// @ID deleteDataerror
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "数据异常ID"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/dataerror/DeleteDataerror/{id} [post]
|
||||
func DeleteDataerror(c *gin.Context) {
|
||||
ID := c.Param("id")
|
||||
|
||||
success, message, _ := DataerrorService.RemoveDataerror(ID)
|
||||
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
/**
|
||||
* @Title:
|
||||
* @Description:
|
||||
* @Author: Yuki Wong(iyuki0430@msn.com)
|
||||
* @Update:
|
||||
* @Date: 2020/7/20 11:50
|
||||
* @File: DataerrorService.go
|
||||
* @Software: GoLand
|
||||
**/
|
||||
package DataerrorService
|
||||
|
||||
import (
|
||||
"dsDataex/GenXorm/models"
|
||||
"dsDataex/MyModel/DataError/DataerrorDAO"
|
||||
"dsDataex/MyModel/MySwagger"
|
||||
"dsDataex/Utils/CacheUtil"
|
||||
"html"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func GetDataerrorResults (swag MySwagger.DataerrorSwag) (bool, string, int32, []map[string]interface{}, error) {
|
||||
var condition string
|
||||
var conditions []string
|
||||
var page int
|
||||
var query MySwagger.DataerrorQuery
|
||||
|
||||
if swag.DeleteFlag != 0 {
|
||||
conditions = append(conditions, "delete_flag=" + "'" + strconv.Itoa(swag.DeleteFlag) + "'")
|
||||
}
|
||||
if swag.EnableFlag != 0 {
|
||||
conditions = append(conditions, "enable_flag=" + "'" + strconv.Itoa(swag.EnableFlag) + "'")
|
||||
}
|
||||
if swag.Page != 0 {
|
||||
page = swag.Page
|
||||
query.Page = (page -1) * 100
|
||||
}
|
||||
|
||||
if len(conditions) > 0 {
|
||||
condition = " AND " + strings.Join(conditions, " AND ")
|
||||
} else {
|
||||
condition = ""
|
||||
}
|
||||
query.Conditions = condition
|
||||
|
||||
result, message, count, data, failResult := DataerrorDAO.GetDataerrorResults(query)
|
||||
|
||||
return result, message, count, data, failResult
|
||||
}
|
||||
|
||||
func RemoveDataerror (id string) (bool, string, error) {
|
||||
business := new(models.TDataexError)
|
||||
|
||||
//清除Redis缓存
|
||||
var ids = []string{id}
|
||||
var selector = CacheUtil.GetBean("t_dataex_dataerror")
|
||||
CacheUtil.DeleteCacheByIds(ids, selector)
|
||||
|
||||
business.Id = html.EscapeString(id)
|
||||
business.ChangeTime = time.Now()
|
||||
business.DeleteTime = time.Now()
|
||||
business.DeleteFlag = 1
|
||||
business.EnableFlag = -1
|
||||
|
||||
result, message, error:= DataerrorDAO.RemoveDataerror(id, business)
|
||||
|
||||
return result, message, error
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package DatasourceController
|
||||
|
||||
import (
|
||||
"dsDataex/MyModel/Datasource/DatasourceOpenAPI"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Routers(r *gin.RouterGroup) {
|
||||
rr := r.Group("/openapi")
|
||||
|
||||
//rr.Use(middleware.Cors())
|
||||
|
||||
rr.POST("/datasource/ReadDatasource", DatasourceOpenAPI.ReadDatasource)
|
||||
rr.POST("/datasource/CreateDatasource", DatasourceOpenAPI.CreateDatasource)
|
||||
rr.POST("/datasource/UpdateDatasource/:id", DatasourceOpenAPI.UpdateDatasource)
|
||||
rr.POST("/datasource/DeleteDatasource/:id", DatasourceOpenAPI.DeleteDatasource)
|
||||
rr.POST("/datasource/ReadESDoc", DatasourceOpenAPI.ReadESDoc)
|
||||
|
||||
return
|
||||
}
|
@ -1,233 +0,0 @@
|
||||
package DatasourceOpenAPI
|
||||
|
||||
import (
|
||||
"dsDataex/GenXorm/models"
|
||||
"dsDataex/MyModel/DataSource/DatasourceService"
|
||||
"dsDataex/MyModel/MySwagger"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// 获取数据源列表 godoc
|
||||
// @Summary 获取数据源列表
|
||||
// @Description 获取数据源列表
|
||||
// @Tags datasource
|
||||
// @ID readDatasource
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param input body MySwagger.DatasourceSwag true "数据源"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/datasource/ReadDatasource [post]
|
||||
func ReadDatasource(c *gin.Context) {
|
||||
var raw MySwagger.DatasourceSwag
|
||||
|
||||
//input.AuthToken = c.Request.Header["Authorization"][0]
|
||||
|
||||
if err := c.ShouldBindJSON(&raw); err != nil {
|
||||
c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Message: "接入系统数据JSON格式错误"})
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
success, message, count, data, _ := DatasourceService.GetDatasourceResults(raw)
|
||||
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
Total: count,
|
||||
Data: data,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 创建数据源 godoc
|
||||
// @Summary 创建数据源
|
||||
// @Description 创建数据源
|
||||
// @Tags datasource
|
||||
// @ID createDatasource
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param input body MySwagger.DatasourceSwag true "数据源"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/datasource/CreateDatasource [post]
|
||||
func CreateDatasource(c *gin.Context) {
|
||||
var raw models.TDataexDatasource
|
||||
|
||||
if err := c.ShouldBindJSON(&raw); err != nil {
|
||||
c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Message: "接入系统数据JSON格式错误"})
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
success, message, _ := DatasourceService.CreateDatasource(raw)
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 修改数据源 godoc
|
||||
// @Summary 修改数据源
|
||||
// @Description 修改数据源
|
||||
// @Tags datasource
|
||||
// @ID updateDatasource
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "数据源ID"
|
||||
// @Param input body MySwagger.DatasourceSwag true "数据源"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/datasource/UpdateDatasource/{id} [post]
|
||||
func UpdateDatasource(c *gin.Context) {
|
||||
var raw models.TDataexDatasource
|
||||
|
||||
ID := c.Param("id")
|
||||
|
||||
if err := c.ShouldBindJSON(&raw); err != nil {
|
||||
fmt.Println("err=", err)
|
||||
c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Fail: true, Message: "接入系统数据JSON格式错误"})
|
||||
return
|
||||
}
|
||||
|
||||
success, message, _ := DatasourceService.UpdateDatasource(ID, raw)
|
||||
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 删除数据源 godoc
|
||||
// @Summary 删除数据源
|
||||
// @Description 删除数据源
|
||||
// @Tags datasource
|
||||
// @ID deleteDatasource
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "数据源ID"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/datasource/DeleteDatasource/{id} [post]
|
||||
func DeleteDatasource(c *gin.Context) {
|
||||
ID := c.Param("id")
|
||||
|
||||
success, message, _ := DatasourceService.RemoveDatasource(ID)
|
||||
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 获取es数据列表 godoc
|
||||
// @Summary 获取es数据列表
|
||||
// @Description 获取es数据列表
|
||||
// @Tags datasource
|
||||
// @ID readESDoc
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param input body MySwagger.DatasourceESSwag true "es数据"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/datasource/ReadESDoc [post]
|
||||
func ReadESDoc(c *gin.Context) {
|
||||
var raw MySwagger.DatasourceESSwag
|
||||
|
||||
if err := c.ShouldBindJSON(&raw); err != nil {
|
||||
c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Message: "接入系统数据JSON格式错误"})
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
datasourceCode := raw.DatasourceCode
|
||||
orgIDs := raw.OrgIDs
|
||||
page := raw.Page
|
||||
begin := raw.BeginTime
|
||||
conditions := raw.Conditions
|
||||
sort := raw.Sort
|
||||
|
||||
success, message, esdata := DatasourceService.ReadESDoc(datasourceCode, orgIDs, page, begin, conditions, sort)
|
||||
//fmt.Println("esdata=", esdata)
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
Data: esdata,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
@ -1,192 +0,0 @@
|
||||
package DatasourceService
|
||||
|
||||
import (
|
||||
"dsDataex/GenXorm/models"
|
||||
"dsDataex/MyModel/DataSource/DatasourceDAO"
|
||||
"dsDataex/MyModel/JYT2012/Jyt2012Service"
|
||||
"dsDataex/MyModel/LinkSystem/LinksystemService"
|
||||
"dsDataex/MyModel/MySwagger"
|
||||
"dsDataex/MyModel/OrgTree/OrgtreeService"
|
||||
"dsDataex/Utils/CacheUtil"
|
||||
"dsDataex/Utils/CommonUtil"
|
||||
"dsDataex/Utils/ES7Util"
|
||||
"encoding/json"
|
||||
"html"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ESDataContent struct {
|
||||
Address string `json:"address"`
|
||||
AreaCode string `json:"area_code"`
|
||||
OrgName string `json:"org_name"`
|
||||
}
|
||||
|
||||
func GetDatasourceResults (swag MySwagger.DatasourceSwag) (bool, string, int32, []map[string]interface{}, error) {
|
||||
var condition string
|
||||
var conditions []string
|
||||
var page int
|
||||
var query MySwagger.DatasourceQuery
|
||||
|
||||
if swag.SystemId != "" {
|
||||
conditions = append(conditions, "system_id=" + "'" + html.EscapeString(swag.SystemId) + "'")
|
||||
}
|
||||
if swag.DatasourceName != "" {
|
||||
conditions = append(conditions, "datasource_name=" + "'" + html.EscapeString(swag.DatasourceName) + "'")
|
||||
}
|
||||
if swag.DatasourceCode != "" {
|
||||
conditions = append(conditions, "datasource_code=" + "'" + html.EscapeString(swag.DatasourceCode) + "'")
|
||||
}
|
||||
if swag.DatasourceDetail != "" {
|
||||
conditions = append(conditions, "datasource_detail=" + "'" + html.EscapeString(swag.DatasourceDetail) + "'")
|
||||
}
|
||||
if swag.SetFlag != 0 {
|
||||
conditions = append(conditions, "set_flag=" + "'" + strconv.Itoa(swag.SetFlag) + "'")
|
||||
}
|
||||
if swag.CollectFlag != 0 {
|
||||
conditions = append(conditions, "collect_flag=" + "'" + strconv.Itoa(swag.CollectFlag) + "'")
|
||||
}
|
||||
if swag.ProvideType != 0 {
|
||||
conditions = append(conditions, "provider_type=" + "'" + strconv.Itoa(swag.ProvideType) + "'")
|
||||
}
|
||||
if swag.ProvideOrgid != "" {
|
||||
conditions = append(conditions, "provider_orgid=" + "'" + html.EscapeString(swag.ProvideOrgid) + "'")
|
||||
}
|
||||
if swag.DatastoreType != 0 {
|
||||
conditions = append(conditions, "datastore_type=" + "'" + strconv.Itoa(swag.DatastoreType) + "'")
|
||||
}
|
||||
if swag.DicId != "" {
|
||||
conditions = append(conditions, "dic_id=" + "'" + html.EscapeString(swag.DicId) + "'")
|
||||
}
|
||||
if swag.DeleteFlag != 0 {
|
||||
conditions = append(conditions, "delete_flag=" + "'" + strconv.Itoa(swag.DeleteFlag) + "'")
|
||||
}
|
||||
if swag.EnableFlag != 0 {
|
||||
conditions = append(conditions, "enable_flag=" + "'" + strconv.Itoa(swag.EnableFlag) + "'")
|
||||
}
|
||||
if swag.Page != 0 {
|
||||
page = swag.Page
|
||||
query.Page = (page -1) * 100
|
||||
}
|
||||
|
||||
if len(conditions) > 0 {
|
||||
condition = " AND " + strings.Join(conditions, " AND ")
|
||||
} else {
|
||||
condition = ""
|
||||
}
|
||||
query.Conditions = condition
|
||||
|
||||
result, message, count, data, failResult := DatasourceDAO.GetDatasourceResults(query)
|
||||
|
||||
return result, message, count, data, failResult
|
||||
}
|
||||
|
||||
|
||||
func CreateDatasource (model models.TDataexDatasource) (bool, string, error) {
|
||||
if ! LinksystemService.IsLinksystemExistsById(model.SystemId) {
|
||||
return false, "SystemId不存在", nil
|
||||
}
|
||||
if ! Jyt2012Service.IsJyt2012ExistsById(model.DicId) {
|
||||
return false, "DicId不存在", nil
|
||||
}
|
||||
if ! OrgtreeService.IsOrgtreeExistsById(model.ProvideOrgid) {
|
||||
return false, "OrgId不存在", nil
|
||||
}
|
||||
business := new(models.TDataexDatasource)
|
||||
business.Id = CommonUtil.GetUUID()
|
||||
business.SystemId = model.SystemId
|
||||
business.DatasourceName = html.EscapeString(model.DatasourceName)
|
||||
business.DatasourceCode = html.EscapeString(model.DatasourceCode)
|
||||
business.DatasourceDetail = html.EscapeString(model.DatasourceDetail)
|
||||
business.SetFlag = model.SetFlag
|
||||
business.CollectFlag = model.CollectFlag
|
||||
business.ProvideType = model.ProvideType
|
||||
business.ProvideOrgid = html.EscapeString(model.ProvideOrgid)
|
||||
business.DatastoreType = model.DatastoreType
|
||||
business.DicId = html.EscapeString(model.DicId)
|
||||
business.CreateTime = time.Now()
|
||||
business.DeleteFlag = -1
|
||||
business.EnableFlag = 1
|
||||
|
||||
result, message, error:= DatasourceDAO.CreateDatasource(business)
|
||||
|
||||
return result, message, error
|
||||
}
|
||||
|
||||
func UpdateDatasource (id string, model models.TDataexDatasource) (bool, string, error) {
|
||||
business := new(models.TDataexDatasource)
|
||||
|
||||
//清除Redis缓存
|
||||
var ids = []string{id}
|
||||
var selector = CacheUtil.GetBean("t_dataex_datasource")
|
||||
CacheUtil.DeleteCacheByIds(ids, selector)
|
||||
|
||||
business.Id = html.EscapeString(id)
|
||||
business.DatasourceName = html.EscapeString(model.DatasourceName)
|
||||
business.DatasourceCode = html.EscapeString(model.DatasourceCode)
|
||||
business.DatasourceDetail = html.EscapeString(model.DatasourceDetail)
|
||||
business.SetFlag = model.SetFlag
|
||||
business.CollectFlag = model.CollectFlag
|
||||
business.ProvideType = model.ProvideType
|
||||
business.ProvideOrgid = html.EscapeString(model.ProvideOrgid)
|
||||
business.DatastoreType = model.DatastoreType
|
||||
business.DicId = html.EscapeString(model.DicId)
|
||||
business.ChangeTime = time.Now()
|
||||
business.EnableFlag = model.EnableFlag
|
||||
|
||||
result, message, error:= DatasourceDAO.UpdateDatasource(id, business)
|
||||
|
||||
return result, message, error
|
||||
}
|
||||
|
||||
func RemoveDatasource (id string) (bool, string, error) {
|
||||
business := new(models.TDataexDatasource)
|
||||
|
||||
//清除Redis缓存
|
||||
var ids = []string{id}
|
||||
var selector = CacheUtil.GetBean("t_dataex_datasource")
|
||||
CacheUtil.DeleteCacheByIds(ids, selector)
|
||||
|
||||
business.Id = html.EscapeString(id)
|
||||
business.ChangeTime = time.Now()
|
||||
business.DeleteTime = time.Now()
|
||||
business.DeleteFlag = 1
|
||||
business.EnableFlag = -1
|
||||
|
||||
result, message, error:= DatasourceDAO.RemoveDatasource(id, business)
|
||||
|
||||
return result, message, error
|
||||
}
|
||||
|
||||
func ReadESDoc(datasourceCode string, orgIDs []string, page int, begin string, conditions map[string]interface{}, sort map[string]interface{}) (bool,string,[]map[string]interface{}) {
|
||||
result, message, esdata := ES7Util.SearchDocPage(datasourceCode, orgIDs, page, begin, conditions, sort)
|
||||
|
||||
var esDatas []map[string]interface{}
|
||||
var esData map[string]interface{}
|
||||
//esDatas := make(map[string]map[string]interface{})
|
||||
//esData := make(map[string]interface{})
|
||||
for _, value := range esdata {
|
||||
//esDatas = append(esDatas, value.DataContent)
|
||||
j, _ := json.Marshal(value)
|
||||
json.Unmarshal(j, &esData)
|
||||
//fmt.Println(esData)
|
||||
esData = make(map[string]interface{})
|
||||
esDatas = append(esDatas, esData)
|
||||
}
|
||||
|
||||
return result, message, esDatas
|
||||
}
|
||||
|
||||
func IsDatasourceExistsById(id string) bool {
|
||||
result :=DatasourceDAO.IsDatasourceExistsById(id)
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func GetDatasourceIdByCode(code string) (bool, string, interface{}, error) {
|
||||
result, message, data, err := DatasourceDAO.GetDatasourceIdByCode(code)
|
||||
|
||||
return result, message, data, err
|
||||
}
|
||||
|
@ -1,16 +0,0 @@
|
||||
package DatastatisticController
|
||||
|
||||
import (
|
||||
"dsDataex/MyModel/DataStatistic/DatastatisticOpenAPI"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Routers(r *gin.RouterGroup) {
|
||||
rr := r.Group("/openapi")
|
||||
|
||||
//rr.Use(middleware.Cors())
|
||||
|
||||
rr.POST("/datastatistic/ReadESDocAmount", DatastatisticOpenAPI.ReadESDocAmount)
|
||||
|
||||
return
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
package DatastatisticOpenAPI
|
||||
|
||||
import (
|
||||
"dsDataex/MyModel/DataStatistic/DatastatisticService"
|
||||
"dsDataex/MyModel/MySwagger"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// 获取数据源列表 godoc
|
||||
// @Summary 获取数据源列表
|
||||
// @Description 获取数据源列表
|
||||
// @Tags datasource
|
||||
// @ID readDatasource
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param input body MySwagger.DatasourceSwag true "数据源"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/datastatistic/ReadESDocAmount [post]
|
||||
func ReadESDocAmount(c *gin.Context) {
|
||||
success, data := DatastatisticService.GetESDocCount()
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: "",
|
||||
Data: data,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: "",
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package DatastatisticService
|
||||
|
||||
import (
|
||||
"dsDataex/MyModel/DataSource/DatasourceService"
|
||||
"dsDataex/MyModel/LinkSystem/LinksystemService"
|
||||
"dsDataex/MyModel/MySwagger"
|
||||
"dsDataex/Utils/ES7Util"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type ESDataContent struct {
|
||||
Address string `json:"address"`
|
||||
AreaCode string `json:"area_code"`
|
||||
OrgName string `json:"org_name"`
|
||||
}
|
||||
|
||||
func GetESDocCount() (bool,[]map[string]interface{}) {
|
||||
var datas []map[string]interface{}
|
||||
var data map[string]interface{}
|
||||
var swag MySwagger.LinksystemSwag
|
||||
|
||||
r, _, _, linksystems, _ := LinksystemService.GetLinksystemResults(swag)
|
||||
if r == true {
|
||||
for _, v := range linksystems {
|
||||
var num int64 = 0
|
||||
var sw MySwagger.DatasourceSwag
|
||||
sw.SystemId = v["id"].(string)
|
||||
rr, _, _, datasources, _ := DatasourceService.GetDatasourceResults(sw)
|
||||
if rr == true {
|
||||
for _, vv := range datasources {
|
||||
fmt.Println(vv["datasource_code"])
|
||||
result, _ := ES7Util.GetDocCount(vv["datasource_code"].(string))
|
||||
num += result
|
||||
}
|
||||
}
|
||||
|
||||
data = make(map[string]interface{})
|
||||
data["system_name"] = v["system_name"]
|
||||
data["system_id"] = v["id"]
|
||||
data["num"] = num
|
||||
datas = append(datas, data)
|
||||
}
|
||||
} else {
|
||||
return false, datas
|
||||
}
|
||||
|
||||
return true, datas
|
||||
}
|
||||
|
||||
|
@ -1,28 +0,0 @@
|
||||
/**
|
||||
* @Title:
|
||||
* @Description:
|
||||
* @Author: Yuki Wong(iyuki0430@msn.com)
|
||||
* @Update:
|
||||
* @Date: 2020/7/9 10:06
|
||||
* @File: JYT2012Controller.go
|
||||
* @Software: GoLand
|
||||
**/
|
||||
package Jyt2012Controller
|
||||
|
||||
import (
|
||||
"dsDataex/MyModel/JYT2012/Jyt2012OpenAPI"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Routers(r *gin.RouterGroup) {
|
||||
rr := r.Group("/openapi")
|
||||
|
||||
//rr.Use(middleware.Cors())
|
||||
|
||||
rr.POST("/jyt2012/ReadJyt2012", Jyt2012OpenAPI.ReadJyt2012)
|
||||
rr.POST("/jyt2012/CreateJyt2012", Jyt2012OpenAPI.CreateJyt2012)
|
||||
rr.POST("/jyt2012/UpdateJyt2012/:id", Jyt2012OpenAPI.UpdateJyt2012)
|
||||
rr.POST("/jyt2012/DeleteJyt2012/:id", Jyt2012OpenAPI.DeleteJyt2012)
|
||||
|
||||
return
|
||||
}
|
@ -1,191 +0,0 @@
|
||||
/**
|
||||
* @Title:
|
||||
* @Description:
|
||||
* @Author: Yuki Wong(iyuki0430@msn.com)
|
||||
* @Update:
|
||||
* @Date: 2020/7/9 10:39
|
||||
* @File: Jyt2012OpenAPI.go
|
||||
* @Software: GoLand
|
||||
**/
|
||||
package Jyt2012OpenAPI
|
||||
|
||||
import (
|
||||
"dsDataex/GenXorm/models"
|
||||
"dsDataex/MyModel/JYT2012/Jyt2012Service"
|
||||
"dsDataex/MyModel/MySwagger"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// 获取标准字典列表 godoc
|
||||
// @Summary 获取标准字典列表
|
||||
// @Description 获取标准字典列表
|
||||
// @Tags jyt2012
|
||||
// @ID readJyt2012
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param input body MySwagger.Jyt2012Swag true "标准字典"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/jyt2012/ReadJyt2012 [post]
|
||||
func ReadJyt2012(c *gin.Context) {
|
||||
var raw MySwagger.Jyt2012Swag
|
||||
|
||||
//input.AuthToken = c.Request.Header["Authorization"][0]
|
||||
//queryString := c.Request.URL.Query().Encode()
|
||||
|
||||
if err := c.ShouldBindJSON(&raw); err != nil {
|
||||
c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Message: "接入系统数据JSON格式错误"})
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
success, message, count, data, _ := Jyt2012Service.GetJyt2012Results(raw)
|
||||
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
Total: count,
|
||||
Data: data,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 创建标准字典 godoc
|
||||
// @Summary 创建标准字典
|
||||
// @Description 创建标准字典
|
||||
// @Tags jyt2012
|
||||
// @ID createJyt2012
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param input body MySwagger.Jyt2012Swag true "标准字典"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/jyt2012/CreateJyt2012 [post]
|
||||
func CreateJyt2012(c *gin.Context) {
|
||||
var raw models.TDataexJyt2012
|
||||
|
||||
if err := c.ShouldBindJSON(&raw); err != nil {
|
||||
c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Message: "接入系统数据JSON格式错误"})
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
success, message, _ := Jyt2012Service.CreateJyt2012(raw)
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 修改标准字典 godoc
|
||||
// @Summary 修改标准字典
|
||||
// @Description 修改标准字典
|
||||
// @Tags jyt2012
|
||||
// @ID updateJyt2012
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "标准字典ID"
|
||||
// @Param input body MySwagger.Jyt2012Swag true "标准字典"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/jyt2012/UpdateJyt2012/{id} [post]
|
||||
func UpdateJyt2012(c *gin.Context) {
|
||||
var raw models.TDataexJyt2012
|
||||
|
||||
ID := c.Param("id")
|
||||
|
||||
if err := c.ShouldBindJSON(&raw); err != nil {
|
||||
c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Fail: true, Message: "接入系统数据JSON格式错误"})
|
||||
return
|
||||
}
|
||||
|
||||
success, message, _ := Jyt2012Service.UpdateJyt2012(ID, raw)
|
||||
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 删除标准字典 godoc
|
||||
// @Summary 删除标准字典
|
||||
// @Description 删除标准字典
|
||||
// @Tags jyt2012
|
||||
// @ID deleteJyt2012
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "标准字典ID"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/jyt2012/DeleteJyt2012/{id} [post]
|
||||
func DeleteJyt2012(c *gin.Context) {
|
||||
ID := c.Param("id")
|
||||
|
||||
success, message, _ := Jyt2012Service.RemoveJyt2012(ID)
|
||||
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
@ -1,130 +0,0 @@
|
||||
package Jyt2012Service
|
||||
|
||||
import (
|
||||
"dsDataex/GenXorm/models"
|
||||
"dsDataex/MyModel/JYT2012/Jyt2012DAO"
|
||||
"dsDataex/MyModel/MySwagger"
|
||||
"dsDataex/Utils/CacheUtil"
|
||||
"dsDataex/Utils/CommonUtil"
|
||||
"html"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func GetJyt2012Results (swag MySwagger.Jyt2012Swag) (bool, string, int32, []map[string]interface{}, error) {
|
||||
var condition string
|
||||
var conditions []string
|
||||
var page int
|
||||
var query MySwagger.Jyt2012Query
|
||||
|
||||
if swag.DicName != "" {
|
||||
conditions = append(conditions, "dic_name=" + "'" + html.EscapeString(swag.DicName) + "'")
|
||||
}
|
||||
if swag.DicType != 0 {
|
||||
conditions = append(conditions, "dic_type=" + "'" + strconv.Itoa(swag.DicType) + "'")
|
||||
}
|
||||
if swag.DicInfo != "" {
|
||||
conditions = append(conditions, "dic_info=" + "'" + html.EscapeString(swag.DicInfo) + "'")
|
||||
}
|
||||
if swag.RootFlag != 0 {
|
||||
conditions = append(conditions, "root_flag=" + "'" + strconv.Itoa(swag.RootFlag) + "'")
|
||||
}
|
||||
if swag.JytFlag != 0 {
|
||||
conditions = append(conditions, "jyt_flag=" + "'" + strconv.Itoa(swag.JytFlag) + "'")
|
||||
}
|
||||
if swag.ParentId != "" {
|
||||
conditions = append(conditions, "parent_id=" + "'" + html.EscapeString(swag.ParentId) + "'")
|
||||
}
|
||||
if swag.DeleteFlag != 0 {
|
||||
conditions = append(conditions, "delete_flag=" + "'" + strconv.Itoa(swag.DeleteFlag) + "'")
|
||||
}
|
||||
if swag.EnableFlag != 0 {
|
||||
conditions = append(conditions, "enable_flag=" + "'" + strconv.Itoa(swag.EnableFlag) + "'")
|
||||
}
|
||||
if swag.Page != 0 {
|
||||
page = swag.Page
|
||||
query.Page = (page -1) * 100
|
||||
} else {
|
||||
query.Page = 0
|
||||
}
|
||||
|
||||
if len(conditions) > 0 {
|
||||
condition = " AND " + strings.Join(conditions, " AND ")
|
||||
} else {
|
||||
condition = ""
|
||||
}
|
||||
query.Conditions = condition
|
||||
|
||||
|
||||
result, message, count, data, failResult := Jyt2012DAO.GetJyt2012Results(query)
|
||||
|
||||
return result, message, count, data, failResult
|
||||
}
|
||||
|
||||
|
||||
func CreateJyt2012 (model models.TDataexJyt2012) (bool, string, error) {
|
||||
business := new(models.TDataexJyt2012)
|
||||
business.Id = CommonUtil.GetUUID()
|
||||
business.DicName = html.EscapeString(model.DicName)
|
||||
business.DicType = model.DicType
|
||||
business.DicInfo = html.EscapeString(model.DicInfo)
|
||||
business.RootFlag = model.RootFlag
|
||||
business.JytFlag = model.JytFlag
|
||||
business.ParentId = html.EscapeString(model.ParentId)
|
||||
business.CreateTime = time.Now()
|
||||
business.DeleteFlag = -1
|
||||
business.EnableFlag = 1
|
||||
|
||||
result, message, error:= Jyt2012DAO.CreateJyt2012(business)
|
||||
|
||||
return result, message, error
|
||||
}
|
||||
|
||||
func UpdateJyt2012 (id string, model models.TDataexJyt2012) (bool, string, error) {
|
||||
business := new(models.TDataexJyt2012)
|
||||
|
||||
//清除Redis缓存
|
||||
var ids = []string{id}
|
||||
var selector = CacheUtil.GetBean("t_dataex_jyt2012")
|
||||
CacheUtil.DeleteCacheByIds(ids, selector)
|
||||
|
||||
business.ChangeTime = time.Now()
|
||||
business.DicName = html.EscapeString(model.DicName)
|
||||
business.DicType = model.DicType
|
||||
business.DicInfo = html.EscapeString(model.DicInfo)
|
||||
business.RootFlag = model.RootFlag
|
||||
business.JytFlag = model.JytFlag
|
||||
business.ParentId = html.EscapeString(model.ParentId)
|
||||
business.EnableFlag = model.EnableFlag
|
||||
|
||||
result, message, error:= Jyt2012DAO.UpdateJyt2012(id, business)
|
||||
|
||||
return result, message, error
|
||||
}
|
||||
|
||||
func RemoveJyt2012 (id string) (bool, string, error) {
|
||||
business := new(models.TDataexJyt2012)
|
||||
|
||||
//清除Redis缓存
|
||||
var ids = []string{id}
|
||||
var selector = CacheUtil.GetBean("t_dataex_jyt2012")
|
||||
CacheUtil.DeleteCacheByIds(ids, selector)
|
||||
|
||||
business.Id = html.EscapeString(id)
|
||||
business.ChangeTime = time.Now()
|
||||
business.DeleteTime = time.Now()
|
||||
business.DeleteFlag = 1
|
||||
business.EnableFlag = -1
|
||||
|
||||
result, message, error:= Jyt2012DAO.RemoveJyt2012(id, business)
|
||||
|
||||
return result, message, error
|
||||
}
|
||||
|
||||
func IsJyt2012ExistsById(id string) bool {
|
||||
result := Jyt2012DAO.IsJyt2012ExistsById(id)
|
||||
|
||||
return result
|
||||
}
|
||||
|
@ -1,18 +0,0 @@
|
||||
package LinksystemController
|
||||
|
||||
import (
|
||||
"dsDataex/MyModel/LinkSystem/LinksystemOpenAPI"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
//Gin 路由配置
|
||||
func Routers(r *gin.RouterGroup) {
|
||||
rr := r.Group("/openapi")
|
||||
|
||||
rr.POST("/linksystem/ReadLinksystem", LinksystemOpenAPI.ReadLinksystem)
|
||||
rr.POST("/linksystem/CreateLinksystem", LinksystemOpenAPI.CreateLinksystem)
|
||||
rr.POST("/linksystem/UpdateLinksystem/:id", LinksystemOpenAPI.UpdateLinksystem)
|
||||
rr.POST("/linksystem/DeleteLinksystem/:id", LinksystemOpenAPI.DeleteLinksystem)
|
||||
|
||||
return
|
||||
}
|
@ -1,182 +0,0 @@
|
||||
package LinksystemOpenAPI
|
||||
|
||||
import (
|
||||
"dsDataex/GenXorm/models"
|
||||
"dsDataex/MyModel/LinkSystem/LinksystemService"
|
||||
"dsDataex/MyModel/MySwagger"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// 获取接入系统列表 godoc
|
||||
// @Summary 获取接入系统列表
|
||||
// @Description 获取接入系统列表
|
||||
// @Tags linksystem
|
||||
// @ID readLinksystem
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param input body MySwagger.LinksystemSwag true "系统"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/linksystem/ReadLinksystem [post]
|
||||
func ReadLinksystem(c *gin.Context) {
|
||||
var raw MySwagger.LinksystemSwag
|
||||
|
||||
//input.AuthToken = c.Request.Header["Authorization"][0]
|
||||
//queryString := c.Request.URL.Query().Encode()
|
||||
|
||||
if err := c.ShouldBindJSON(&raw); err != nil {
|
||||
c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Message: "接入系统数据JSON格式错误"})
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
success, message, count, data, _ := LinksystemService.GetLinksystemResults(raw)
|
||||
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
Total: count,
|
||||
Data: data,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 创建接入系统 godoc
|
||||
// @Summary 创建接入系统
|
||||
// @Description 创建接入系统
|
||||
// @Tags linksystem
|
||||
// @ID createLinksystem
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param input body MySwagger.LinksystemSwag true "系统"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/linksystem/CreateLinksystem [post]
|
||||
func CreateLinksystem(c *gin.Context) {
|
||||
var raw models.TDataexLinksystem
|
||||
|
||||
if err := c.ShouldBindJSON(&raw); err != nil {
|
||||
c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Message: "接入系统数据JSON格式错误"})
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
success, message, _ := LinksystemService.CreateLinksystem(raw)
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 修改接入系统 godoc
|
||||
// @Summary 修改接入系统
|
||||
// @Description 修改接入系统
|
||||
// @Tags linksystem
|
||||
// @ID updateLinksystem
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "系统ID"
|
||||
// @Param input body MySwagger.LinksystemSwag true "系统"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/linksystem/UpdateLinksystem/{id} [post]
|
||||
func UpdateLinksystem(c *gin.Context) {
|
||||
var raw models.TDataexLinksystem
|
||||
|
||||
ID := c.Param("id")
|
||||
|
||||
if err := c.ShouldBindJSON(&raw); err != nil {
|
||||
c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Fail: true, Message: "接入系统数据JSON格式错误"})
|
||||
return
|
||||
}
|
||||
|
||||
success, message, _ := LinksystemService.UpdateLinksystem(ID, raw)
|
||||
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 删除接入系统 godoc
|
||||
// @Summary 删除接入系统
|
||||
// @Description 删除接入系统
|
||||
// @Tags linksystem
|
||||
// @ID deleteLinksystem
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "系统ID"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/linksystem/DeleteLinksystem/{id} [post]
|
||||
func DeleteLinksystem(c *gin.Context) {
|
||||
ID := c.Param("id")
|
||||
|
||||
success, message, _ := LinksystemService.RemoveLinksystem(ID)
|
||||
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
@ -1,130 +0,0 @@
|
||||
package LinksystemService
|
||||
|
||||
import (
|
||||
"dsDataex/GenXorm/models"
|
||||
"dsDataex/MyModel/LinkSystem/LinksystemDAO"
|
||||
"dsDataex/MyModel/MySwagger"
|
||||
"dsDataex/Utils/CacheUtil"
|
||||
"dsDataex/Utils/CommonUtil"
|
||||
"html"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func GetLinksystemResults (swag MySwagger.LinksystemSwag) (bool, string, int32, []map[string]interface{}, error) {
|
||||
var condition string
|
||||
var conditions []string
|
||||
var page int
|
||||
var query MySwagger.LinksystemQuery
|
||||
|
||||
if swag.SystemName != "" {
|
||||
conditions = append(conditions, "system_name=" + "'" + html.EscapeString(swag.SystemName) + "'")
|
||||
}
|
||||
if swag.SystemCode != "" {
|
||||
conditions = append(conditions, "system_code=" + "'" + html.EscapeString(swag.SystemCode) + "'")
|
||||
}
|
||||
if swag.SystemType != 0 {
|
||||
conditions = append(conditions, "system_type=" + "'" + strconv.Itoa(swag.SystemType) + "'")
|
||||
}
|
||||
if swag.SystemKey != "" {
|
||||
conditions = append(conditions, "system_key=" + "'" + html.EscapeString(swag.SystemKey) + "'")
|
||||
}
|
||||
if swag.CollectFlag != 0 {
|
||||
conditions = append(conditions, "collect_flag=" + "'" + strconv.Itoa(swag.CollectFlag) + "'")
|
||||
}
|
||||
if swag.ProviderName != "" {
|
||||
conditions = append(conditions, "provider_name=" + "'" + html.EscapeString(swag.ProviderName) + "'")
|
||||
}
|
||||
if swag.DeleteFlag != 0 {
|
||||
conditions = append(conditions, "delete_flag=" + "'" + strconv.Itoa(swag.DeleteFlag) + "'")
|
||||
}
|
||||
if swag.EnableFlag != 0 {
|
||||
conditions = append(conditions, "enable_flag=" + "'" + strconv.Itoa(swag.EnableFlag) + "'")
|
||||
}
|
||||
if swag.Page != 0 {
|
||||
page = swag.Page
|
||||
query.Page = (page -1) * 100
|
||||
} else {
|
||||
query.Page = 0
|
||||
}
|
||||
|
||||
if len(conditions) > 0 {
|
||||
condition = " AND " + strings.Join(conditions, " AND ")
|
||||
} else {
|
||||
condition = ""
|
||||
}
|
||||
query.Conditions = condition
|
||||
|
||||
result, message, count, data, failResult := LinksystemDAO.GetLinksystemResults(query)
|
||||
|
||||
return result, message, count, data, failResult
|
||||
}
|
||||
|
||||
func CreateLinksystem (model models.TDataexLinksystem) (bool, string, error) {
|
||||
if ! LinksystemDAO.IsSystemCodeUnique(model.SystemCode) {
|
||||
return false, "SystemCode已存在", nil
|
||||
}
|
||||
business := new(models.TDataexLinksystem)
|
||||
business.Id = CommonUtil.GetUUID()
|
||||
business.SystemName = html.EscapeString(model.SystemName)
|
||||
business.SystemCode = html.EscapeString(model.SystemCode)
|
||||
business.SystemType = model.SystemType
|
||||
business.SystemKey = CommonUtil.GetUUID()
|
||||
business.CollectFlag = model.CollectFlag
|
||||
business.ProviderName = html.EscapeString(model.ProviderName)
|
||||
business.CreateTime = time.Now()
|
||||
business.DeleteFlag = -1
|
||||
business.EnableFlag = 1
|
||||
|
||||
result, message, error:= LinksystemDAO.CreateLinksystem(business)
|
||||
|
||||
return result, message, error
|
||||
}
|
||||
|
||||
func UpdateLinksystem (id string, model models.TDataexLinksystem) (bool, string, error) {
|
||||
business := new(models.TDataexLinksystem)
|
||||
|
||||
//清除Redis缓存
|
||||
var ids = []string{id}
|
||||
var selector = CacheUtil.GetBean("t_dataex_linksystem")
|
||||
CacheUtil.DeleteCacheByIds(ids, selector)
|
||||
|
||||
business.ChangeTime = time.Now()
|
||||
business.SystemName = html.EscapeString(model.SystemName)
|
||||
business.SystemCode = html.EscapeString(model.SystemCode)
|
||||
business.SystemType = model.SystemType
|
||||
business.CollectFlag = model.CollectFlag
|
||||
business.ProviderName = html.EscapeString(model.ProviderName)
|
||||
business.EnableFlag = model.EnableFlag
|
||||
|
||||
result, message, error:= LinksystemDAO.UpdateLinksystem(id, business)
|
||||
|
||||
return result, message, error
|
||||
}
|
||||
|
||||
func RemoveLinksystem (id string) (bool, string, error) {
|
||||
business := new(models.TDataexLinksystem)
|
||||
|
||||
//清除Redis缓存
|
||||
var ids = []string{id}
|
||||
var selector = CacheUtil.GetBean("t_dataex_linksystem")
|
||||
CacheUtil.DeleteCacheByIds(ids, selector)
|
||||
|
||||
business.Id = html.EscapeString(id)
|
||||
business.ChangeTime = time.Now()
|
||||
business.DeleteTime = time.Now()
|
||||
business.DeleteFlag = 1
|
||||
business.EnableFlag = -1
|
||||
|
||||
result, message, error:= LinksystemDAO.RemoveLinksystem(id, business)
|
||||
|
||||
return result, message, error
|
||||
}
|
||||
|
||||
func IsLinksystemExistsById(id string) bool {
|
||||
result := LinksystemDAO.IsLinksystemExistsById(id)
|
||||
|
||||
return result
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
package MetadataController
|
||||
|
||||
import (
|
||||
"dsDataex/MyModel/MetaData/MetadataOpenAPI"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
//Gin 路由配置
|
||||
func Routers(r *gin.RouterGroup) {
|
||||
rr := r.Group("/openapi")
|
||||
|
||||
rr.POST("/metadata/ReadMetadata", MetadataOpenAPI.ReadMetadata)
|
||||
rr.POST("/metadata/CreateMetadata", MetadataOpenAPI.CreateMetadata)
|
||||
rr.POST("/metadata/UpdateMetadata/:id", MetadataOpenAPI.UpdateMetadata)
|
||||
rr.POST("/metadata/DeleteMetadata/:id", MetadataOpenAPI.DeleteMetadata)
|
||||
rr.POST("/metadata/CreateMetadataES", MetadataOpenAPI.CreateMetadataES)
|
||||
|
||||
return
|
||||
}
|
@ -1,223 +0,0 @@
|
||||
package MetadataOpenAPI
|
||||
|
||||
import (
|
||||
"dsDataex/GenXorm/models"
|
||||
"dsDataex/MyModel/MetaData/MetadataService"
|
||||
"dsDataex/MyModel/MySwagger"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// 获取元数据列表 godoc
|
||||
// @Summary 获取元数据列表
|
||||
// @Description 获取元数据列表
|
||||
// @Tags metadata
|
||||
// @ID readMetadata
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param input body MySwagger.MetadataSwag true "元数据"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/metadata/ReadMetadata [post]
|
||||
func ReadMetadata(c *gin.Context) {
|
||||
var raw MySwagger.MetadataSwag
|
||||
|
||||
if err := c.ShouldBindJSON(&raw); err != nil {
|
||||
c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Message: "接入系统数据JSON格式错误"})
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
fmt.Println("json.page=", raw.Page)
|
||||
success, message, count, data, _ := MetadataService.GetMetadataResults(raw)
|
||||
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
Total: count,
|
||||
Data: data,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 创建元数据 godoc
|
||||
// @Summary 创建元数据
|
||||
// @Description 创建元数据
|
||||
// @Tags metadata
|
||||
// @ID createMetadata
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param input body MySwagger.MetadataSwag true "元数据"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/metadata/CreateMetadata [post]
|
||||
func CreateMetadata(c *gin.Context) {
|
||||
var raw models.TDataexMetadata
|
||||
|
||||
if err := c.ShouldBindJSON(&raw); err != nil {
|
||||
c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Message: "接入系统数据JSON格式错误"})
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
success, message, _ := MetadataService.CreateMetadata(raw)
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 修改元数据 godoc
|
||||
// @Summary 修改元数据
|
||||
// @Description 修改元数据
|
||||
// @Tags metadata
|
||||
// @ID updateMetadata
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "元数据ID"
|
||||
// @Param input body MySwagger.MetadataSwag true "元数据"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/metadata/UpdateMetadata/{id} [post]
|
||||
func UpdateMetadata(c *gin.Context) {
|
||||
var raw models.TDataexMetadata
|
||||
|
||||
ID := c.Param("id")
|
||||
|
||||
if err := c.ShouldBindJSON(&raw); err != nil {
|
||||
c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Fail: true, Message: "接入系统数据JSON格式错误"})
|
||||
return
|
||||
}
|
||||
|
||||
success, message, _ := MetadataService.UpdateMetadata(ID, raw)
|
||||
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 删除元数据 godoc
|
||||
// @Summary 删除元数据
|
||||
// @Description 删除元数据
|
||||
// @Tags metadata
|
||||
// @ID deleteMetadata
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "元数据ID"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/metadata/DeleteMetadata/{id} [post]
|
||||
func DeleteMetadata(c *gin.Context) {
|
||||
ID := c.Param("id")
|
||||
|
||||
success, message, _ := MetadataService.RemoveMetadata(ID)
|
||||
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 创建ES元数据 godoc
|
||||
// @Summary 创建ES元数据
|
||||
// @Description 创建ES元数据
|
||||
// @Tags metadata
|
||||
// @ID createMetadataES
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param input body MySwagger.MetadataESSwag true "ES元数据"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/metadata/CreateMetadataES [post]
|
||||
func CreateMetadataES(c *gin.Context) {
|
||||
var raw MySwagger.MetadataESSwag
|
||||
|
||||
if err := c.ShouldBindJSON(&raw); err != nil {
|
||||
c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Message: "接入系统数据JSON格式错误"})
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
indexName := raw.IndexName
|
||||
|
||||
success, message, _ := MetadataService.CreateMetadataES(indexName)
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
@ -1,222 +0,0 @@
|
||||
package MetadataService
|
||||
|
||||
import (
|
||||
"dsDataex/GenXorm/models"
|
||||
"dsDataex/MyModel/DataSource/DatasourceService"
|
||||
"dsDataex/MyModel/JYT2012/Jyt2012Service"
|
||||
"dsDataex/MyModel/MetaData/MetadataDAO"
|
||||
"dsDataex/MyModel/MySwagger"
|
||||
"dsDataex/Utils/CacheUtil"
|
||||
"dsDataex/Utils/CommonUtil"
|
||||
"dsDataex/Utils/ES7Util"
|
||||
"fmt"
|
||||
"html"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func GetMetadataResults (swag MySwagger.MetadataSwag) (bool, string, int32, []map[string]interface{}, error) {
|
||||
var condition string
|
||||
var conditions []string
|
||||
var page int
|
||||
var query MySwagger.MetadataQuery
|
||||
|
||||
if swag.DatasourceId != "" {
|
||||
conditions = append(conditions, "datasource_id=" + "'" + html.EscapeString(swag.DatasourceId) + "'")
|
||||
}
|
||||
if swag.ItemName != "" {
|
||||
conditions = append(conditions, "item_name=" + "'" + html.EscapeString(swag.ItemName) + "'")
|
||||
}
|
||||
if swag.DicId != "" {
|
||||
conditions = append(conditions, "dic_id=" + "'" + html.EscapeString(swag.DicId) + "'")
|
||||
}
|
||||
if swag.ItemLength != 0 {
|
||||
conditions = append(conditions, "item_length=" + "'" + strconv.Itoa(swag.ItemLength) + "'")
|
||||
}
|
||||
if swag.ItemPattern != "" {
|
||||
conditions = append(conditions, "item_pattern=" + "'" + html.EscapeString(swag.ItemPattern) + "'")
|
||||
}
|
||||
if swag.ItemInfo != "" {
|
||||
conditions = append(conditions, "item_info=" + "'" + html.EscapeString(swag.ItemInfo) + "'")
|
||||
}
|
||||
if swag.CheckName != 0 {
|
||||
conditions = append(conditions, "check_name=" + "'" + strconv.Itoa(swag.CheckName) + "'")
|
||||
}
|
||||
if swag.CheckDic != 0 {
|
||||
conditions = append(conditions, "check_dic=" + "'" + strconv.Itoa(swag.CheckDic) + "'")
|
||||
}
|
||||
if swag.CheckType != 0 {
|
||||
conditions = append(conditions, "check_type=" + "'" + strconv.Itoa(swag.CheckType) + "'")
|
||||
}
|
||||
if swag.CheckPattern != 0 {
|
||||
conditions = append(conditions, "check_pattern=" + "'" + strconv.Itoa(swag.CheckPattern) + "'")
|
||||
}
|
||||
if swag.CheckExist != 0 {
|
||||
conditions = append(conditions, "check_exist=" + "'" + strconv.Itoa(swag.CheckExist) + "'")
|
||||
}
|
||||
if swag.EnableFlag != 0 {
|
||||
conditions = append(conditions, "enable_flag=" + "'" + strconv.Itoa(swag.EnableFlag) + "'")
|
||||
}
|
||||
if swag.Page != 0 {
|
||||
page = swag.Page
|
||||
query.Page = (page -1) * 100
|
||||
} else {
|
||||
query.Page = 0
|
||||
}
|
||||
|
||||
if len(conditions) > 0 {
|
||||
condition = " AND " + strings.Join(conditions, " AND ")
|
||||
} else {
|
||||
condition = ""
|
||||
}
|
||||
query.Conditions = condition
|
||||
|
||||
|
||||
result, message, count, data, failResult := MetadataDAO.GetMetadataResults(query)
|
||||
|
||||
return result, message, count, data, failResult
|
||||
}
|
||||
|
||||
|
||||
func CreateMetadata (model models.TDataexMetadata) (bool, string, error) {
|
||||
if ! DatasourceService.IsDatasourceExistsById(model.DatasourceId) {
|
||||
return false, "DatasourceId不存在", nil
|
||||
}
|
||||
if ! Jyt2012Service.IsJyt2012ExistsById(model.DicId) {
|
||||
return false, "DicId不存在", nil
|
||||
}
|
||||
business := new(models.TDataexMetadata)
|
||||
business.Id = CommonUtil.GetUUID()
|
||||
business.DatasourceId = html.EscapeString(model.DatasourceId)
|
||||
business.ItemName = html.EscapeString(model.ItemName)
|
||||
business.DicId = html.EscapeString(model.DicId)
|
||||
business.ItemType = model.ItemType
|
||||
business.ItemLength = model.ItemLength
|
||||
business.ItemPattern = html.EscapeString(model.ItemPattern)
|
||||
business.ItemInfo = html.EscapeString(model.ItemInfo)
|
||||
business.CheckName = model.CheckName
|
||||
business.CheckDic = model.CheckDic
|
||||
business.CheckType = model.CheckType
|
||||
business.CheckPattern = model.CheckPattern
|
||||
business.CheckExist = model.CheckExist
|
||||
business.CreateTime = time.Now()
|
||||
business.DeleteFlag = -1
|
||||
business.EnableFlag = 1
|
||||
result, message, error:= MetadataDAO.CreateMetadata(business)
|
||||
|
||||
return result, message, error
|
||||
}
|
||||
|
||||
func UpdateMetadata (id string, model models.TDataexMetadata) (bool, string, error) {
|
||||
if ! DatasourceService.IsDatasourceExistsById(model.DatasourceId) {
|
||||
return false, "DatasourceId不存在", nil
|
||||
}
|
||||
if ! Jyt2012Service.IsJyt2012ExistsById(model.DicId) {
|
||||
return false, "DicId不存在", nil
|
||||
}
|
||||
business := new(models.TDataexMetadata)
|
||||
|
||||
//清除Redis缓存
|
||||
var ids = []string{id}
|
||||
var selector = CacheUtil.GetBean("t_dataex_metadata")
|
||||
CacheUtil.DeleteCacheByIds(ids, selector)
|
||||
|
||||
business.ChangeTime = time.Now()
|
||||
business.DatasourceId = html.EscapeString(model.DatasourceId)
|
||||
business.ItemName = html.EscapeString(model.ItemName)
|
||||
business.DicId = html.EscapeString(model.DicId)
|
||||
business.ItemType = model.ItemType
|
||||
business.ItemLength = model.ItemLength
|
||||
business.ItemPattern = html.EscapeString(model.ItemPattern)
|
||||
business.ItemInfo = html.EscapeString(model.ItemInfo)
|
||||
business.CheckName = model.CheckName
|
||||
business.CheckDic = model.CheckDic
|
||||
business.CheckType = model.CheckType
|
||||
business.CheckPattern = model.CheckPattern
|
||||
business.CheckExist = model.CheckExist
|
||||
|
||||
result, message, error:= MetadataDAO.UpdateMetadata(id, business)
|
||||
|
||||
return result, message, error
|
||||
}
|
||||
|
||||
func RemoveMetadata (id string) (bool, string, error) {
|
||||
business := new(models.TDataexMetadata)
|
||||
|
||||
//清除Redis缓存
|
||||
var ids = []string{id}
|
||||
var selector = CacheUtil.GetBean("t_dataex_metadata")
|
||||
CacheUtil.DeleteCacheByIds(ids, selector)
|
||||
|
||||
business.Id = html.EscapeString(id)
|
||||
business.ChangeTime = time.Now()
|
||||
business.DeleteTime = time.Now()
|
||||
business.DeleteFlag = 1
|
||||
business.EnableFlag = -1
|
||||
|
||||
result, message, error:= MetadataDAO.RemoveMetadata(id, business)
|
||||
|
||||
return result, message, error
|
||||
}
|
||||
|
||||
func CreateMetadataES (indexName string) (bool, string, error) {
|
||||
res, _, datasourceId, _ := DatasourceService.GetDatasourceIdByCode(indexName)
|
||||
if res == true {
|
||||
if MetadataDAO.IsMetadataExistsByDatasourceId(datasourceId.(string)) == true {
|
||||
MetadataDAO.DeleteMetadataByDatasourceId(datasourceId.(string))
|
||||
}
|
||||
fmt.Println("datasourceId: ", datasourceId)
|
||||
result := ES7Util.IndexDataContentMapping(indexName)
|
||||
var itemType string
|
||||
itemType = "string"
|
||||
business := []models.TDataexMetadata{}
|
||||
for k, v := range result{
|
||||
fmt.Println(k, v)
|
||||
fmt.Println("v: ", v.(map[string]interface{})["type"])
|
||||
if v.(map[string]interface{})["type"] == "float" {
|
||||
itemType = "float"
|
||||
} else if v.(map[string]interface{})["type"] == "keyword" {
|
||||
itemType = "string"
|
||||
} else if v.(map[string]interface{})["type"] == "date" {
|
||||
itemType = "datetime"
|
||||
} else if v.(map[string]interface{})["type"] == "integer" {
|
||||
itemType = "integer"
|
||||
} else if v.(map[string]interface{})["type"] == "long" {
|
||||
itemType = "text"
|
||||
} else if v.(map[string]interface{})["type"] == "text" {
|
||||
itemType = "text"
|
||||
} else if v.(map[string]interface{})["type"] == "boolean" {
|
||||
itemType = "boolean"
|
||||
} else {
|
||||
itemType = "string"
|
||||
}
|
||||
|
||||
b := models.TDataexMetadata{}
|
||||
b.Id = CommonUtil.GetUUID()
|
||||
b.DatasourceId = html.EscapeString(datasourceId.(string))
|
||||
b.ItemName = html.EscapeString(k)
|
||||
//b.DicId = html.EscapeString("BA710E2E-895B-4563-9377-0CA5B3DE1CFD")
|
||||
b.ItemType = itemType
|
||||
b.ItemLength = -1
|
||||
b.ItemPattern = html.EscapeString("")
|
||||
b.ItemInfo = html.EscapeString("")
|
||||
b.CheckName = -1
|
||||
b.CheckDic = -1
|
||||
b.CheckType = -1
|
||||
b.CheckPattern = -1
|
||||
b.CheckExist = -1
|
||||
b.CreateTime = time.Now()
|
||||
b.DeleteFlag = -1
|
||||
|
||||
business = append(business, b)
|
||||
}
|
||||
|
||||
fmt.Println(business)
|
||||
result1, message, error:= MetadataDAO.CreateMetadataBatch(business)
|
||||
return result1, message, error
|
||||
//return true, "ok", nil
|
||||
} else {
|
||||
return false, "", nil
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package MySwagger
|
||||
|
||||
type Data struct {
|
||||
OrgID string `json:"org_id" example:"200201"`
|
||||
DataID string `json:"data_id" example:"202008080008"`
|
||||
Data string `json:"data" example:"{id:12300,name:zhangj,org_id:123001}"`
|
||||
DelFlag int `json:"del_flag" example:"0"`
|
||||
}
|
||||
|
@ -1,6 +0,0 @@
|
||||
package MySwagger
|
||||
|
||||
type DataaccessQuery struct {
|
||||
Conditions string `json:"conditions"`
|
||||
Page int `json:"page" example:"1"`
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package MySwagger
|
||||
|
||||
type DataerrorQuery struct {
|
||||
Conditions string `json:"conditions"`
|
||||
Page int `json:"page" example:"1"`
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package MySwagger
|
||||
|
||||
type DatasourceQuery struct {
|
||||
Conditions string `json:"conditions"`
|
||||
Page int `json:"page" example:"1"`
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package MySwagger
|
||||
|
||||
type DatastatisticSwag struct {
|
||||
DatasourceCode string `json:"datasource_code" xorm:"not null comment('数据源编码') VARCHAR(8)"`
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package MySwagger
|
||||
|
||||
type Input struct {
|
||||
SystemID string `json:"id" example:"SYS-200201" `
|
||||
AuthToken string `json:"auth_token" example:"DATAEX-TOKEN-a6ce-11ea-b94df48e38f73cf7" `
|
||||
ID string `json:"id" example:"SYS-200201" `
|
||||
DataSource string `json:"data_source" example:"ORG" `
|
||||
Data Data `json:"data" `
|
||||
Datas []Data `json:"datas" `
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package MySwagger
|
||||
|
||||
type Jyt2012Query struct {
|
||||
Conditions string `json:"conditions"`
|
||||
Page int `json:"page" example:"1"`
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package MySwagger
|
||||
|
||||
type LinksystemQuery struct {
|
||||
Conditions string `json:"conditions"`
|
||||
Page int `json:"page" example:"1"`
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package MySwagger
|
||||
|
||||
type MetadataESSwag struct {
|
||||
IndexName string `json:"index_name" xorm:"not null comment('ES Index Name') VARCHAR(50)"`
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package MySwagger
|
||||
|
||||
type MetadataQuery struct {
|
||||
Conditions string `json:"conditions"`
|
||||
Page int `json:"page" example:"1"`
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package MySwagger
|
||||
|
||||
type OrgtreeQuery struct {
|
||||
Conditions string `json:"conditions"`
|
||||
Page int `json:"page" example:"1"`
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package MySwagger
|
||||
|
||||
type Query struct {
|
||||
ID string `json:"id" example:"SYS-200201"`
|
||||
SystemID string `json:"id" example:"SYS-200201" `
|
||||
AuthTime string `json:"auth_time" example:"2020-06-19 15:54:11"`
|
||||
AuthToken string `json:"auth_token" example:"DATAEX-TOKEN-a6ce-11ea-b94df48e38f73cf7"`
|
||||
DataSource string `json:"data_source" example:"ORG"`
|
||||
OrgID string `json:"org_id" example:"200201"`
|
||||
Conditions []string `json:"conditions" example:subject_code=22`
|
||||
Page int `json:"page" example:"1"`
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package MySwagger
|
||||
|
||||
type Result struct {
|
||||
Success bool `json:"success" example:"true"`
|
||||
Fail bool `json:"fail" example:"false"`
|
||||
Message string `json:"message" example:"操作成功"`
|
||||
Total int32 `json:"total" example:"120"`
|
||||
Data []map[string]interface{} `json:"data" `
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package OrgtreeController
|
||||
|
||||
import (
|
||||
"dsDataex/MyModel/OrgTree/OrgtreeOpenAPI"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Routers(r *gin.RouterGroup) {
|
||||
rr := r.Group("/openapi")
|
||||
|
||||
//rr.Use(middleware.Cors())
|
||||
|
||||
rr.POST("/orgtree/ReadOrgtree", OrgtreeOpenAPI.ReadOrgtree)
|
||||
rr.POST("/orgtree/CreateOrgtree", OrgtreeOpenAPI.CreateOrgtree)
|
||||
rr.POST("/orgtree/UpdateOrgtree/:id", OrgtreeOpenAPI.UpdateOrgtree)
|
||||
rr.POST("/orgtree/DeleteOrgtree/:id", OrgtreeOpenAPI.DeleteOrgtree)
|
||||
|
||||
return
|
||||
}
|
@ -1,176 +0,0 @@
|
||||
package OrgtreeOpenAPI
|
||||
|
||||
import (
|
||||
"dsDataex/GenXorm/models"
|
||||
"dsDataex/MyModel/MySwagger"
|
||||
"dsDataex/MyModel/OrgTree/OrgtreeService"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// 获取机构列表 godoc
|
||||
// @Summary 获取机构列表
|
||||
// @Description 获取机构列表
|
||||
// @Tags orgtree
|
||||
// @ID readOrgtree
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param input body MySwagger.OrgtreeSwag true "机构"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/orgtree/ReadOrgtree [post]
|
||||
func ReadOrgtree(c *gin.Context) {
|
||||
var raw MySwagger.OrgtreeSwag
|
||||
if err := c.ShouldBindJSON(&raw); err != nil {
|
||||
c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Message: "接入系统数据JSON格式错误"})
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
success, message, data, _ := OrgtreeService.GetOrgtreeResults(raw)
|
||||
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
Data: data,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 创建机构 godoc
|
||||
// @Summary 创建机构
|
||||
// @Description 创建机构
|
||||
// @Tags orgtree
|
||||
// @ID createOrgtree
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param input body MySwagger.OrgtreeSwag true "机构"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/orgtree/CreateOrgtree [post]
|
||||
func CreateOrgtree(c *gin.Context) {
|
||||
var raw models.TDataexOrgtree
|
||||
|
||||
if err := c.ShouldBindJSON(&raw); err != nil {
|
||||
c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Message: "接入系统数据JSON格式错误"})
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
success, message, _ := OrgtreeService.CreateOrgtree(raw)
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 修改机构 godoc
|
||||
// @Summary 修改机构
|
||||
// @Description 修改机构
|
||||
// @Tags orgtree
|
||||
// @ID updateOrgtree
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "机构ID"
|
||||
// @Param input body MySwagger.OrgtreeSwag true "机构"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/orgtree/UpdateOrgtree/{id} [post]
|
||||
func UpdateOrgtree(c *gin.Context) {
|
||||
var raw models.TDataexOrgtree
|
||||
|
||||
ID := c.Param("id")
|
||||
|
||||
if err := c.ShouldBindJSON(&raw); err != nil {
|
||||
c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Fail: true, Message: "接入系统数据JSON格式错误"})
|
||||
return
|
||||
}
|
||||
|
||||
success, message, _ := OrgtreeService.UpdateOrgtree(ID, raw)
|
||||
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 删除机构 godoc
|
||||
// @Summary 删除机构
|
||||
// @Description 删除机构
|
||||
// @Tags orgtree
|
||||
// @ID deleteOrgtree
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "机构ID"
|
||||
// @Success 200 {object} MySwagger.Result
|
||||
// @Failure 400 {object} MySwagger.Result
|
||||
// @Router /v1/openapi/orgtree/DeleteOrgtree/{id} [post]
|
||||
func DeleteOrgtree(c *gin.Context) {
|
||||
ID := c.Param("id")
|
||||
|
||||
success, message, _ := OrgtreeService.RemoveOrgtree(ID)
|
||||
|
||||
if success {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: true,
|
||||
Fail: false,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, MySwagger.Result{
|
||||
Success: false,
|
||||
Fail: true,
|
||||
Message: message,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
@ -1,146 +0,0 @@
|
||||
package OrgtreeService
|
||||
|
||||
import (
|
||||
"dsDataex/GenXorm/models"
|
||||
"dsDataex/MyModel/LinkSystem/LinksystemService"
|
||||
"dsDataex/MyModel/MySwagger"
|
||||
"dsDataex/MyModel/OrgTree/OrgtreeDAO"
|
||||
"dsDataex/Utils/CacheUtil"
|
||||
"dsDataex/Utils/CommonUtil"
|
||||
"html"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func GetOrgtreeResults (swag MySwagger.OrgtreeSwag) (bool,string, []map[string]interface{}, error) {
|
||||
var condition string
|
||||
var conditions []string
|
||||
var page int
|
||||
var query MySwagger.OrgtreeQuery
|
||||
|
||||
if swag.OrgName != "" {
|
||||
conditions = append(conditions, "org_name=" + "'" + html.EscapeString(swag.OrgName) + "'")
|
||||
}
|
||||
if swag.OrgType != 0 {
|
||||
conditions = append(conditions, "org_type=" + "'" + strconv.Itoa(swag.OrgType) + "'")
|
||||
}
|
||||
if swag.ParentId != "" {
|
||||
conditions = append(conditions, "parent_id=" + "'" + html.EscapeString(swag.ParentId) + "'")
|
||||
}
|
||||
if swag.CatId != "" {
|
||||
conditions = append(conditions, "cat_id=" + "'" + html.EscapeString(swag.CatId) + "'")
|
||||
}
|
||||
if swag.ProvinceId != "" {
|
||||
conditions = append(conditions, "province_id=" + "'" + html.EscapeString(swag.ProvinceId) + "'")
|
||||
}
|
||||
if swag.CityId != "" {
|
||||
conditions = append(conditions, "city_id=" + "'" + html.EscapeString(swag.CityId) + "'")
|
||||
}
|
||||
if swag.AreaId != "" {
|
||||
conditions = append(conditions, "area_id=" + "'" + html.EscapeString(swag.AreaId) + "'")
|
||||
}
|
||||
if swag.LinksystemId != "" {
|
||||
conditions = append(conditions, "linksystem_id=" + "'" + html.EscapeString(swag.LinksystemId) + "'")
|
||||
}
|
||||
if swag.LinkId != "" {
|
||||
conditions = append(conditions, "link_id=" + "'" + html.EscapeString(swag.LinkId) + "'")
|
||||
}
|
||||
if swag.DeleteFlag != 0 {
|
||||
conditions = append(conditions, "delete_flag=" + "'" + strconv.Itoa(swag.DeleteFlag) + "'")
|
||||
}
|
||||
if swag.EnableFlag != 0 {
|
||||
conditions = append(conditions, "enable_flag=" + "'" + strconv.Itoa(swag.EnableFlag) + "'")
|
||||
}
|
||||
if swag.Page != 0 {
|
||||
page = swag.Page
|
||||
query.Page = (page -1) * 100
|
||||
} else {
|
||||
query.Page = 0
|
||||
}
|
||||
|
||||
if len(conditions) > 0 {
|
||||
condition = " AND " + strings.Join(conditions, " AND ")
|
||||
} else {
|
||||
condition = ""
|
||||
}
|
||||
query.Conditions = condition
|
||||
|
||||
result,message,data,failResult:= OrgtreeDAO.GetOrgtreeResults(query)
|
||||
|
||||
return result,message,data,failResult
|
||||
}
|
||||
|
||||
|
||||
func CreateOrgtree (model models.TDataexOrgtree) (bool, string, error) {
|
||||
//if ! LinksystemService.IsLinksystemExistsById(model.LinksystemId) {
|
||||
// return false, "SystemId不存在", nil
|
||||
//}
|
||||
business := new(models.TDataexOrgtree)
|
||||
business.Id = CommonUtil.GetUUID()
|
||||
business.OrgName = html.EscapeString(model.OrgName)
|
||||
business.OrgType = model.OrgType
|
||||
business.ParentId = html.EscapeString(model.ParentId)
|
||||
business.CatId = html.EscapeString(model.CatId)
|
||||
business.ProvinceId = html.EscapeString(model.ProvinceId)
|
||||
business.CityId = html.EscapeString(model.CityId)
|
||||
business.AreaId = html.EscapeString(model.AreaId)
|
||||
business.LinksystemId = html.EscapeString(model.LinksystemId)
|
||||
business.LinkId = html.EscapeString(model.LinkId)
|
||||
business.CreateTime = time.Now()
|
||||
business.DeleteFlag = -1
|
||||
business.EnableFlag = 1
|
||||
|
||||
result, message, error:= OrgtreeDAO.CreateOrgtree(business)
|
||||
|
||||
return result, message, error
|
||||
}
|
||||
|
||||
func UpdateOrgtree (id string, model models.TDataexOrgtree) (bool, string, error) {
|
||||
if ! LinksystemService.IsLinksystemExistsById(model.LinksystemId) {
|
||||
return false, "SystemId不存在", nil
|
||||
}
|
||||
business := new(models.TDataexOrgtree)
|
||||
business.Id = html.EscapeString(id)
|
||||
business.OrgName = html.EscapeString(model.OrgName)
|
||||
business.OrgType = model.OrgType
|
||||
business.ParentId = html.EscapeString(model.ParentId)
|
||||
business.CatId = html.EscapeString(model.CatId)
|
||||
business.ProvinceId = html.EscapeString(model.ProvinceId)
|
||||
business.CityId = html.EscapeString(model.CityId)
|
||||
business.AreaId = html.EscapeString(model.AreaId)
|
||||
business.LinksystemId = html.EscapeString(model.LinksystemId)
|
||||
business.LinkId = html.EscapeString(model.LinkId)
|
||||
business.ChangeTime = time.Now()
|
||||
business.EnableFlag = model.EnableFlag
|
||||
|
||||
|
||||
result, message, error:= OrgtreeDAO.UpdateOrgtree(id, business)
|
||||
|
||||
return result, message, error
|
||||
}
|
||||
|
||||
func RemoveOrgtree (id string) (bool, string, error) {
|
||||
business := new(models.TDataexOrgtree)
|
||||
|
||||
//清除Redis缓存
|
||||
var ids = []string{id}
|
||||
var selector = CacheUtil.GetBean("t_dataex_orgtree")
|
||||
CacheUtil.DeleteCacheByIds(ids, selector)
|
||||
|
||||
business.Id = html.EscapeString(id)
|
||||
business.ChangeTime = time.Now()
|
||||
business.DeleteTime = time.Now()
|
||||
business.DeleteFlag = 1
|
||||
business.EnableFlag = -1
|
||||
|
||||
result, message, error:= OrgtreeDAO.RemoveOrgtree(id, business)
|
||||
|
||||
return result, message, error
|
||||
}
|
||||
|
||||
func IsOrgtreeExistsById(id string) bool {
|
||||
result := OrgtreeDAO.IsOrgtreeExistsById(id)
|
||||
|
||||
return result
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue