package DataaccessOpenAPI import ( "dsSupport/MyModel/DataAccess/DataaccessService" "dsSupport/MyModel/MySwagger" "dsSupport/models" "fmt" "github.com/gin-gonic/gin" "net/http" ) // 获取数据订阅列表 godoc // @Summary 获取数据订阅列表 // @Description json:"datasource_id" xorm:"not null comment('数据源ID') index VARCHAR(36)" example:"F38BD0DB-0142-4356-8F2B-623813FC2578" // @Description json:"datasource_code" xorm:"comment('数据源编码') default 'NULL' VARCHAR(255)" // @Description json:"`source_systemid`" xorm:"not null comment('源系统编码') index VARCHAR(36)" example:"F38BD0DB-0142-4356-8F2B-623813FC2578" // @Description json:"`consume_systemid`" xorm:"not null comment('数据使用系统编码') index VARCHAR(36)" example:"F38BD0DB-0142-4356-8F2B-623813FC2578" // @Description json:"query_flag" xorm:"not null default 1 comment('可查【1:是,-1:否】') INT(11)" example:"1" // @Description json:"set_flag" xorm:"not null default -1 comment('可修改【1:是,-1:否】') INT(11)" example:"1" // @Description `*`json:"consume_type" xorm:"not null comment('使用数据范围【1:本机构,2:本机构以及下属机构,-1:不限制】') INT(11)" example:"-1" // @Description `*`json:"consume_orgid" xorm:"not null comment('使用数据机构ID【-1:不限制】') index VARCHAR(36)" example:"-1" // @Description json:"create_time" xorm:"default 'NULL' created comment('建立时间') DATETIME" example:"2020-06-22 17:26:53" // @Description json:"change_time" xorm:"default 'NULL' updated comment('最近修改时间') DATETIME" example:"2020-06-22 17:26:53" // @Description json:"delete_time" xorm:"default 'NULL' deleted comment('删除时间') DATETIME" example:"2020-06-22 17:26:53" // @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 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 } 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 `*`json:"datasource_id" xorm:"not null comment('数据源ID') index VARCHAR(36)" example:"F38BD0DB-0142-4356-8F2B-623813FC2578" // @Description `*`json:"datasource_code" xorm:"comment('数据源编码') default 'NULL' VARCHAR(255)" // @Description `*`json:"`source_systemid`" xorm:"not null comment('源系统编码') index VARCHAR(36)" example:"F38BD0DB-0142-4356-8F2B-623813FC2578" // @Description `*`json:"`consume_systemid`" xorm:"not null comment('数据使用系统编码') index VARCHAR(36)" example:"F38BD0DB-0142-4356-8F2B-623813FC2578" // @Description json:"query_flag" xorm:"not null default 1 comment('可查【1:是,-1:否】') INT(11)" example:"1" // @Description json:"set_flag" xorm:"not null default -1 comment('可修改【1:是,-1:否】') INT(11)" example:"1" // @Description `*`json:"consume_type" xorm:"not null comment('使用数据范围【1:本机构,2:本机构以及下属机构,-1:不限制】') INT(11)" example:"-1" // @Description `*`json:"consume_orgid" xorm:"not null comment('使用数据机构ID【-1:不限制】') index VARCHAR(36)" example:"-1" // @Description json:"create_time" xorm:"default 'NULL' created comment('建立时间') DATETIME" example:"2020-06-22 17:26:53" // @Description json:"change_time" xorm:"default 'NULL' updated comment('最近修改时间') DATETIME" example:"2020-06-22 17:26:53" // @Description json:"delete_time" xorm:"default 'NULL' deleted comment('删除时间') DATETIME" example:"2020-06-22 17:26:53" // @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" // @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 json:"datasource_id" xorm:"not null comment('数据源ID') index VARCHAR(36)" example:"F38BD0DB-0142-4356-8F2B-623813FC2578" // @Description json:"datasource_code" xorm:"comment('数据源编码') default 'NULL' VARCHAR(255)" // @Description json:"`source_systemid`" xorm:"not null comment('源系统编码') index VARCHAR(36)" example:"F38BD0DB-0142-4356-8F2B-623813FC2578" // @Description json:"`consume_systemid`" xorm:"not null comment('数据使用系统编码') index VARCHAR(36)" example:"F38BD0DB-0142-4356-8F2B-623813FC2578" // @Description json:"query_flag" xorm:"not null default 1 comment('可查【1:是,-1:否】') INT(11)" example:"1" // @Description json:"set_flag" xorm:"not null default -1 comment('可修改【1:是,-1:否】') INT(11)" example:"1" // @Description json:"consume_type" xorm:"not null comment('使用数据范围【1:本机构,2:本机构以及下属机构,-1:不限制】') INT(11)" example:"-1" // @Description json:"consume_orgid" xorm:"not null comment('使用数据机构ID【-1:不限制】') index VARCHAR(36)" example:"-1" // @Description json:"create_time" xorm:"default 'NULL' created comment('建立时间') DATETIME" example:"2020-06-22 17:26:53" // @Description json:"change_time" xorm:"default 'NULL' updated comment('最近修改时间') DATETIME" example:"2020-06-22 17:26:53" // @Description json:"delete_time" xorm:"default 'NULL' deleted comment('删除时间') DATETIME" example:"2020-06-22 17:26:53" // @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" // @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 `*`json:"id" xorm:"not null pk comment('ID') VARCHAR(36)" // @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 }