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.
177 lines
3.7 KiB
177 lines
3.7 KiB
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
|
|
}
|