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.
192 lines
4.1 KiB
192 lines
4.1 KiB
/**
|
|
* @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
|
|
}
|