|
|
package OrgtreeOpenAPI
|
|
|
|
|
|
import (
|
|
|
"dsSupport/MyModel/MySwagger"
|
|
|
"dsSupport/MyModel/OrgTree/OrgtreeService"
|
|
|
"dsSupport/models"
|
|
|
"fmt"
|
|
|
"github.com/gin-gonic/gin"
|
|
|
"net/http"
|
|
|
)
|
|
|
|
|
|
// 获取机构列表 godoc
|
|
|
// @Summary 获取机构列表
|
|
|
// @Description 获取机构列表
|
|
|
// @Description `json:"id" xorm:"not null pk comment('ID【根节点默认为-1】') VARCHAR(36)" example:"0383FF67-CCBA-4256-891E-BAFD487547FA"`
|
|
|
// @Description `json:"org_name" xorm:"not null comment('机构名称') VARCHAR(100)" example:"开平区教育局"`
|
|
|
// @Description `json:"org_type" xorm:"not null comment('机构类型【1:教育局、2:学校、3:教辅单位、4:大学区、5:部门、6、主校,7、学段、8:年级、9:班级】') INT(11)" example:"1"`
|
|
|
// @Description `json:"parent_id" xorm:"default ''NULL'' comment('父节点ID') VARCHAR(36)" example:"0383FF67-CCBA-4256-891E-BAFD487547FA"`
|
|
|
// @Description `json:"cat_id" xorm:"not null comment('层级ID【4位数字一组、右侧多级累加】') VARCHAR(100)" example:"0383FF67-CCBA-4256-891E-BAFD487547FA"`
|
|
|
// @Description `json:"province_id" xorm:"default 'NULL' comment('省编码') VARCHAR(6)" example:"0383FF67-CCBA-4256-891E-BAFD487547FA"`
|
|
|
// @Description `json:"city_id" xorm:"default 'NULL' comment('地市编码') VARCHAR(6)" example:"0383FF67-CCBA-4256-891E-BAFD487547FA"`
|
|
|
// @Description `json:"area_id" xorm:"default 'NULL' comment('县区编码') VARCHAR(6)" example:"0383FF67-CCBA-4256-891E-BAFD487547FA"`
|
|
|
// @Description `json:"`linksystem_id`" xorm:"default 'NULL' comment('源业务系统编码') VARCHAR(36)" example:"0383FF67-CCBA-4256-891E-BAFD487547FA"`
|
|
|
// @Description `json:"link_id" xorm:"default 'NULL' comment('业务系统机构原ID') VARCHAR(36)" example:"0383FF67-CCBA-4256-891E-BAFD487547FA"`
|
|
|
// @Description `json:"create_time" xorm:"default 'NULL' created comment('建立时间') DATETIME" example:"2020-06-11 09:19:26"`
|
|
|
// @Description `json:"change_time" xorm:"default 'NULL' updated comment('最近修改时间') DATETIME" example:"2020-06-11 09:19:26"`
|
|
|
// @Description `json:"delete_time" xorm:"default 'NULL' deleted comment('删除时间') DATETIME" example:"2020-06-11 09:19:26"`
|
|
|
// @Description `json:"delete_flag" xorm:"not null default -1 comment('删除标志【默认-1,1:删除,-1:正常】') INT(11)" example:"1"`
|
|
|
// @Description `json:"enable_flag" xorm:"not null default 1 comment('启用标志【默认1,1:启用,-1:禁用】') INT(11)" example:"1"`
|
|
|
// @Description `json:"page" example:"1"`
|
|
|
// @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, count, data, _ := OrgtreeService.GetOrgtreeResults(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 创建机构
|
|
|
// @Description `json:"id" xorm:"not null pk comment('ID【根节点默认为-1】') VARCHAR(36)" example:"0383FF67-CCBA-4256-891E-BAFD487547FA"`
|
|
|
// @Description `*`json:"org_name" xorm:"not null comment('机构名称') VARCHAR(100)" example:"开平区教育局"`
|
|
|
// @Description `*`json:"org_type" xorm:"not null comment('机构类型【1:教育局、2:学校、3:教辅单位、4:大学区、5:部门、6、主校,7、学段、8:年级、9:班级】') INT(11)" example:"1"`
|
|
|
// @Description `*`json:"parent_id" xorm:"default ''NULL'' comment('父节点ID') VARCHAR(36)" example:"0383FF67-CCBA-4256-891E-BAFD487547FA"`
|
|
|
// @Description `json:"cat_id" xorm:"not null comment('层级ID【4位数字一组、右侧多级累加】') VARCHAR(100)" example:"0383FF67-CCBA-4256-891E-BAFD487547FA"`
|
|
|
// @Description `*`json:"province_id" xorm:"default 'NULL' comment('省编码') VARCHAR(6)" example:"0383FF67-CCBA-4256-891E-BAFD487547FA"`
|
|
|
// @Description `*`json:"city_id" xorm:"default 'NULL' comment('地市编码') VARCHAR(6)" example:"0383FF67-CCBA-4256-891E-BAFD487547FA"`
|
|
|
// @Description `*`json:"area_id" xorm:"default 'NULL' comment('县区编码') VARCHAR(6)" example:"0383FF67-CCBA-4256-891E-BAFD487547FA"`
|
|
|
// @Description `*`json:"`linksystem_id`" xorm:"default 'NULL' comment('源业务系统编码') VARCHAR(36)" example:"0383FF67-CCBA-4256-891E-BAFD487547FA"`
|
|
|
// @Description `json:"link_id" xorm:"default 'NULL' comment('业务系统机构原ID') VARCHAR(36)" example:"0383FF67-CCBA-4256-891E-BAFD487547FA"`
|
|
|
// @Description `json:"create_time" xorm:"default 'NULL' created comment('建立时间') DATETIME" example:"2020-06-11 09:19:26"`
|
|
|
// @Description `json:"change_time" xorm:"default 'NULL' updated comment('最近修改时间') DATETIME" example:"2020-06-11 09:19:26"`
|
|
|
// @Description `json:"delete_time" xorm:"default 'NULL' deleted comment('删除时间') DATETIME" example:"2020-06-11 09:19:26"`
|
|
|
// @Description `json:"delete_flag" xorm:"not null default -1 comment('删除标志【默认-1,1:删除,-1:正常】') INT(11)" example:"1"`
|
|
|
// @Description `json:"enable_flag" xorm:"not null default 1 comment('启用标志【默认1,1:启用,-1:禁用】') INT(11)" example:"1"`
|
|
|
// @Description `json:"page" example:"1"`
|
|
|
// @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.ResultOne{
|
|
|
Success: true,
|
|
|
Fail: false,
|
|
|
Message: message,
|
|
|
})
|
|
|
|
|
|
return
|
|
|
} else {
|
|
|
c.JSON(http.StatusOK, MySwagger.ResultOne{
|
|
|
Success: false,
|
|
|
Fail: true,
|
|
|
Message: message,
|
|
|
})
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 修改机构 godoc
|
|
|
// @Summary 修改机构
|
|
|
// @Description 修改机构
|
|
|
// @Description `json:"id" xorm:"not null pk comment('ID【根节点默认为-1】') VARCHAR(36)" example:"0383FF67-CCBA-4256-891E-BAFD487547FA"`
|
|
|
// @Description `json:"org_name" xorm:"not null comment('机构名称') VARCHAR(100)" example:"开平区教育局"`
|
|
|
// @Description `json:"org_type" xorm:"not null comment('机构类型【1:教育局、2:学校、3:教辅单位、4:大学区、5:部门、6、主校,7、学段、8:年级、9:班级】') INT(11)" example:"1"`
|
|
|
// @Description `json:"parent_id" xorm:"default ''NULL'' comment('父节点ID') VARCHAR(36)" example:"0383FF67-CCBA-4256-891E-BAFD487547FA"`
|
|
|
// @Description `json:"cat_id" xorm:"not null comment('层级ID【4位数字一组、右侧多级累加】') VARCHAR(100)" example:"0383FF67-CCBA-4256-891E-BAFD487547FA"`
|
|
|
// @Description `json:"province_id" xorm:"default 'NULL' comment('省编码') VARCHAR(6)" example:"0383FF67-CCBA-4256-891E-BAFD487547FA"`
|
|
|
// @Description `json:"city_id" xorm:"default 'NULL' comment('地市编码') VARCHAR(6)" example:"0383FF67-CCBA-4256-891E-BAFD487547FA"`
|
|
|
// @Description `json:"area_id" xorm:"default 'NULL' comment('县区编码') VARCHAR(6)" example:"0383FF67-CCBA-4256-891E-BAFD487547FA"`
|
|
|
// @Description `json:"`linksystem_id`" xorm:"default 'NULL' comment('源业务系统编码') VARCHAR(36)" example:"0383FF67-CCBA-4256-891E-BAFD487547FA"`
|
|
|
// @Description `json:"link_id" xorm:"default 'NULL' comment('业务系统机构原ID') VARCHAR(36)" example:"0383FF67-CCBA-4256-891E-BAFD487547FA"`
|
|
|
// @Description `json:"create_time" xorm:"default 'NULL' created comment('建立时间') DATETIME" example:"2020-06-11 09:19:26"`
|
|
|
// @Description `json:"change_time" xorm:"default 'NULL' updated comment('最近修改时间') DATETIME" example:"2020-06-11 09:19:26"`
|
|
|
// @Description `json:"delete_time" xorm:"default 'NULL' deleted comment('删除时间') DATETIME" example:"2020-06-11 09:19:26"`
|
|
|
// @Description `json:"delete_flag" xorm:"not null default -1 comment('删除标志【默认-1,1:删除,-1:正常】') INT(11)" example:"1"`
|
|
|
// @Description `json:"enable_flag" xorm:"not null default 1 comment('启用标志【默认1,1:启用,-1:禁用】') INT(11)" example:"1"`
|
|
|
// @Description `json:"page" example:"1"`
|
|
|
// @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.ResultOne{
|
|
|
Success: true,
|
|
|
Fail: false,
|
|
|
Message: message,
|
|
|
})
|
|
|
|
|
|
return
|
|
|
} else {
|
|
|
c.JSON(http.StatusOK, MySwagger.ResultOne{
|
|
|
Success: false,
|
|
|
Fail: true,
|
|
|
Message: message,
|
|
|
})
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 删除机构 godoc
|
|
|
// @Summary 删除机构
|
|
|
// @Description 删除机构
|
|
|
// @Description `*`json:"id" xorm:"not null pk comment('ID') VARCHAR(36)"
|
|
|
// @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.ResultOne{
|
|
|
Success: true,
|
|
|
Fail: false,
|
|
|
Message: message,
|
|
|
})
|
|
|
|
|
|
return
|
|
|
} else {
|
|
|
c.JSON(http.StatusOK, MySwagger.ResultOne{
|
|
|
Success: false,
|
|
|
Fail: true,
|
|
|
Message: message,
|
|
|
})
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
return
|
|
|
}
|