You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

183 lines
4.0 KiB

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
}