diff --git a/dsSupport/MyModel/DataAccess/DataaccessController/DataaccessController.go b/dsSupport/MyModel/DataAccess/DataaccessController/DataaccessController.go index 8ab7ec97..a3972092 100644 --- a/dsSupport/MyModel/DataAccess/DataaccessController/DataaccessController.go +++ b/dsSupport/MyModel/DataAccess/DataaccessController/DataaccessController.go @@ -10,6 +10,7 @@ func Routers(r *gin.RouterGroup) { rr := r.Group("/openapi") rr.POST("/dataaccess/ReadDataaccess", DataaccessOpenAPI.ReadDataaccess) + rr.POST("/dataaccess/GetDataaccess/:id", DataaccessOpenAPI.GetDataaccess) rr.POST("/dataaccess/CreateDataaccess", DataaccessOpenAPI.CreateDataaccess) rr.POST("/dataaccess/UpdateDataaccess/:id", DataaccessOpenAPI.UpdateDataaccess) rr.POST("/dataaccess/DeleteDataaccess/:id", DataaccessOpenAPI.DeleteDataaccess) diff --git a/dsSupport/MyModel/DataAccess/DataaccessDAO/DataaccessDAO.go b/dsSupport/MyModel/DataAccess/DataaccessDAO/DataaccessDAO.go index a41818c3..ae42b618 100644 --- a/dsSupport/MyModel/DataAccess/DataaccessDAO/DataaccessDAO.go +++ b/dsSupport/MyModel/DataAccess/DataaccessDAO/DataaccessDAO.go @@ -14,6 +14,22 @@ import ( // 数据库 var db = DbUtil.Engine +func GetDataaccessRow(id string) (bool, string, map[string]interface{}, error) { + sql := "SELECT * FROM t_dataex_dataaccess WHERE id = '" + id + "'" + + var dataaccess models.TDataexDataaccess + has, _ := DbUtil.Engine.SQL(sql).Get(&dataaccess) + if has == true { + m := make(map[string]interface{}) + j, _ := json.Marshal(dataaccess) + json.Unmarshal(j, &m) + + return true, "数据获取成功", m, nil + } else { + return false, "数据获取失败,数据源不存在", nil, nil + } +} + func GetDataaccessResults(query MySwagger.DataaccessQuery) (bool, string, int, []map[string]interface{}, error) { //sql := "SELECT ls.id source_systemid, ls.system_name source_systemname, ls1.system_name consume_systemname, da.* FROM t_dataex_dataaccess da LEFT JOIN t_dataex_datasource ds ON da.datasource_id = ds.id LEFT JOIN t_dataex_linksystem ls ON ls.id = ds.system_id LEFT JOIN t_dataex_linksystem ls1 ON ls1.id = da.consume_systemid" + query.Conditions diff --git a/dsSupport/MyModel/DataAccess/DataaccessOpenAPI/DataaccessOpenAPI.go b/dsSupport/MyModel/DataAccess/DataaccessOpenAPI/DataaccessOpenAPI.go index 265d3566..2f700e95 100644 --- a/dsSupport/MyModel/DataAccess/DataaccessOpenAPI/DataaccessOpenAPI.go +++ b/dsSupport/MyModel/DataAccess/DataaccessOpenAPI/DataaccessOpenAPI.go @@ -70,6 +70,52 @@ func ReadDataaccess(c *gin.Context) { return } +// 获取数据订阅详情 godoc +// @Summary 获取数据订阅详情 +// @Description `json:"id" xorm:"not null comment('ID') index VARCHAR(36)" example:"F38BD0DB-0142-4356-8F2B-623813FC2578"` +// @Tags dataaccess +// @ID readDataaccess +// @Accept json +// @Produce json +// @Param id path string true "数据订阅ID" +// @Success 200 {object} MySwagger.Result +// @Failure 400 {object} MySwagger.Result +// @Router /v1/openapi/dataaccess/GetDataaccess/{id} [post] +func GetDataaccess(c *gin.Context) { + + ID := c.Param("id") + //input.AuthToken = c.Request.Header["Authorization"][0] + //queryString := c.Request.URL.Query().Encode() + + if ID == "" { + c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Message: "ID必填"}) + return + } + + success, message, data, _ := DataaccessService.GetDataaccessRow(ID) + + if success { + c.JSON(http.StatusOK, MySwagger.ResultOne{ + 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 `*`json:"datasource_id" xorm:"not null comment('数据源ID') index VARCHAR(36)" example:"F38BD0DB-0142-4356-8F2B-623813FC2578" diff --git a/dsSupport/MyModel/DataAccess/DataaccessService/DataaccessService.go b/dsSupport/MyModel/DataAccess/DataaccessService/DataaccessService.go index 9b550050..8ef28bca 100644 --- a/dsSupport/MyModel/DataAccess/DataaccessService/DataaccessService.go +++ b/dsSupport/MyModel/DataAccess/DataaccessService/DataaccessService.go @@ -92,6 +92,24 @@ func GetDataaccessResults(swag MySwagger.DataaccessSwag) (bool, string, int, []m return result, message, count, data, failResult } +/** + * @title GetDataaccessRow + * @Description 获取订阅详情 + * @Author wangshuai + * @Date 2020-09-28 + * @Param swag MySwagger.DataaccessSwag 查询条件 + * @Return bool 执行结果 + * @Return string 提示信息 + * @Return map[string]interface{} 订阅详情 + * @Return error 错误信息 + */ +func GetDataaccessRow(id string) (bool, string, map[string]interface{}, error) { + + result, message, data, failResult := DataaccessDAO.GetDataaccessRow(id) + + return result, message, data, failResult +} + /** * @title CreateDataaccess * @Description 创建订阅 diff --git a/dsSupport/MyModel/MySwagger/DataaccessSwag.go b/dsSupport/MyModel/MySwagger/DataaccessSwag.go index 66cb6977..332c8f93 100644 --- a/dsSupport/MyModel/MySwagger/DataaccessSwag.go +++ b/dsSupport/MyModel/MySwagger/DataaccessSwag.go @@ -3,6 +3,7 @@ package MySwagger import "time" type DataaccessSwag struct { + Id string `json:"id" xorm:"not null comment('ID') index VARCHAR(36)" example:"F38BD0DB-0142-4356-8F2B-623813FC2578"` DatasourceId string `json:"datasource_id" xorm:"not null comment('数据源ID') index VARCHAR(36)" example:"F38BD0DB-0142-4356-8F2B-623813FC2578"` DatasourceCode string `json:"datasource_code" xorm:"comment('数据源编码') default 'NULL' VARCHAR(255)"` SourceSystemid string `json:"source_systemid" xorm:"not null comment('源系统ID') index VARCHAR(36)" example:"F38BD0DB-0142-4356-8F2B-623813FC2578"` diff --git a/dsSupport/docs/docs.go b/dsSupport/docs/docs.go index 8ac92b4c..fc201bcb 100644 --- a/dsSupport/docs/docs.go +++ b/dsSupport/docs/docs.go @@ -1377,6 +1377,45 @@ var doc = `{ } } }, + "/v1/openapi/dataaccess/GetDataaccess/{id}": { + "post": { + "description": "` + "`" + `json:\"id\" xorm:\"not null comment('ID') index VARCHAR(36)\" example:\"F38BD0DB-0142-4356-8F2B-623813FC2578\"` + "`" + `", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "dataaccess" + ], + "summary": "获取数据订阅详情", + "operationId": "readDataaccess", + "parameters": [ + { + "type": "string", + "description": "数据订阅ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/MySwagger.Result" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/MySwagger.Result" + } + } + } + } + }, "/v1/openapi/dataaccess/ReadDataaccess": { "post": { "description": "json:\"datasource_id\" xorm:\"not null comment('数据源ID') index VARCHAR(36)\" example:\"F38BD0DB-0142-4356-8F2B-623813FC2578\"\njson:\"datasource_code\" xorm:\"comment('数据源编码') default 'NULL' VARCHAR(255)\"\njson:\"` + "`" + `source_systemid` + "`" + `\" xorm:\"not null comment('源系统编码') index VARCHAR(36)\" example:\"F38BD0DB-0142-4356-8F2B-623813FC2578\"\njson:\"` + "`" + `consume_systemid` + "`" + `\" xorm:\"not null comment('数据使用系统编码') index VARCHAR(36)\" example:\"F38BD0DB-0142-4356-8F2B-623813FC2578\"\njson:\"query_flag\" xorm:\"not null default 1 comment('可查【1:是,-1:否】') INT(11)\" example:\"1\"\njson:\"set_flag\" xorm:\"not null default -1 comment('可修改【1:是,-1:否】') INT(11)\" example:\"1\"\n` + "`" + `*` + "`" + `json:\"consume_type\" xorm:\"not null comment('使用数据范围【1:本机构,2:本机构以及下属机构,-1:不限制】') INT(11)\" example:\"-1\"\n` + "`" + `*` + "`" + `json:\"consume_orgid\" xorm:\"not null comment('使用数据机构ID【-1:不限制】') index VARCHAR(36)\" example:\"-1\"\njson:\"create_time\" xorm:\"default 'NULL' created comment('建立时间') DATETIME\" example:\"2020-06-22 17:26:53\"\njson:\"change_time\" xorm:\"default 'NULL' updated comment('最近修改时间') DATETIME\" example:\"2020-06-22 17:26:53\"\njson:\"delete_time\" xorm:\"default 'NULL' deleted comment('删除时间') DATETIME\" example:\"2020-06-22 17:26:53\"\njson:\"delete_flag\" xorm:\"not null default -1 comment('删除标志【默认-1,1:删除,-1:正常】') INT(11)\" example:\"1\"\njson:\"enable_flag\" xorm:\"not null default 1 comment('启用标志【默认1,1:启用,-1:禁用】') INT(11)\" example:\"1\"\njson:\"page\" example:\"1\"` + "`" + `", @@ -2472,6 +2511,10 @@ var doc = `{ "type": "integer", "example": 1 }, + "id": { + "type": "string", + "example": "F38BD0DB-0142-4356-8F2B-623813FC2578" + }, "page": { "type": "integer", "example": 1 @@ -2848,28 +2891,13 @@ var doc = `{ "MySwagger.Result": { "type": "object", "properties": { - "data": { - "type": "array", - "items": { - "type": "object", - "additionalProperties": true - } - }, - "fail": { - "type": "boolean", - "example": false - }, "message": { "type": "string", - "example": "操作成功" + "example": "接入系统票据验证失败" }, "success": { "type": "boolean", - "example": true - }, - "total": { - "type": "integer", - "example": 120 + "example": false } } } diff --git a/dsSupport/docs/swagger.json b/dsSupport/docs/swagger.json index 3210a225..1cb98413 100644 --- a/dsSupport/docs/swagger.json +++ b/dsSupport/docs/swagger.json @@ -1361,6 +1361,45 @@ } } }, + "/v1/openapi/dataaccess/GetDataaccess/{id}": { + "post": { + "description": "`json:\"id\" xorm:\"not null comment('ID') index VARCHAR(36)\" example:\"F38BD0DB-0142-4356-8F2B-623813FC2578\"`", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "dataaccess" + ], + "summary": "获取数据订阅详情", + "operationId": "readDataaccess", + "parameters": [ + { + "type": "string", + "description": "数据订阅ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/MySwagger.Result" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/MySwagger.Result" + } + } + } + } + }, "/v1/openapi/dataaccess/ReadDataaccess": { "post": { "description": "json:\"datasource_id\" xorm:\"not null comment('数据源ID') index VARCHAR(36)\" example:\"F38BD0DB-0142-4356-8F2B-623813FC2578\"\njson:\"datasource_code\" xorm:\"comment('数据源编码') default 'NULL' VARCHAR(255)\"\njson:\"`source_systemid`\" xorm:\"not null comment('源系统编码') index VARCHAR(36)\" example:\"F38BD0DB-0142-4356-8F2B-623813FC2578\"\njson:\"`consume_systemid`\" xorm:\"not null comment('数据使用系统编码') index VARCHAR(36)\" example:\"F38BD0DB-0142-4356-8F2B-623813FC2578\"\njson:\"query_flag\" xorm:\"not null default 1 comment('可查【1:是,-1:否】') INT(11)\" example:\"1\"\njson:\"set_flag\" xorm:\"not null default -1 comment('可修改【1:是,-1:否】') INT(11)\" example:\"1\"\n`*`json:\"consume_type\" xorm:\"not null comment('使用数据范围【1:本机构,2:本机构以及下属机构,-1:不限制】') INT(11)\" example:\"-1\"\n`*`json:\"consume_orgid\" xorm:\"not null comment('使用数据机构ID【-1:不限制】') index VARCHAR(36)\" example:\"-1\"\njson:\"create_time\" xorm:\"default 'NULL' created comment('建立时间') DATETIME\" example:\"2020-06-22 17:26:53\"\njson:\"change_time\" xorm:\"default 'NULL' updated comment('最近修改时间') DATETIME\" example:\"2020-06-22 17:26:53\"\njson:\"delete_time\" xorm:\"default 'NULL' deleted comment('删除时间') DATETIME\" example:\"2020-06-22 17:26:53\"\njson:\"delete_flag\" xorm:\"not null default -1 comment('删除标志【默认-1,1:删除,-1:正常】') INT(11)\" example:\"1\"\njson:\"enable_flag\" xorm:\"not null default 1 comment('启用标志【默认1,1:启用,-1:禁用】') INT(11)\" example:\"1\"\njson:\"page\" example:\"1\"`", @@ -2456,6 +2495,10 @@ "type": "integer", "example": 1 }, + "id": { + "type": "string", + "example": "F38BD0DB-0142-4356-8F2B-623813FC2578" + }, "page": { "type": "integer", "example": 1 @@ -2832,28 +2875,13 @@ "MySwagger.Result": { "type": "object", "properties": { - "data": { - "type": "array", - "items": { - "type": "object", - "additionalProperties": true - } - }, - "fail": { - "type": "boolean", - "example": false - }, "message": { "type": "string", - "example": "操作成功" + "example": "接入系统票据验证失败" }, "success": { "type": "boolean", - "example": true - }, - "total": { - "type": "integer", - "example": 120 + "example": false } } } diff --git a/dsSupport/docs/swagger.yaml b/dsSupport/docs/swagger.yaml index 5d131e03..8ee4fdc7 100644 --- a/dsSupport/docs/swagger.yaml +++ b/dsSupport/docs/swagger.yaml @@ -68,6 +68,9 @@ definitions: enable_flag: example: 1 type: integer + id: + example: F38BD0DB-0142-4356-8F2B-623813FC2578 + type: string page: example: 1 type: integer @@ -343,23 +346,12 @@ definitions: type: object MySwagger.Result: properties: - data: - items: - additionalProperties: true - type: object - type: array - fail: - example: false - type: boolean message: - example: 操作成功 + example: 接入系统票据验证失败 type: string success: - example: true + example: false type: boolean - total: - example: 120 - type: integer type: object host: 127.0.0.1:8005 info: @@ -1250,6 +1242,32 @@ paths: summary: 删除数据订阅 tags: - dataaccess + /v1/openapi/dataaccess/GetDataaccess/{id}: + post: + consumes: + - application/json + description: '`json:"id" xorm:"not null comment(''ID'') index VARCHAR(36)" example:"F38BD0DB-0142-4356-8F2B-623813FC2578"`' + operationId: readDataaccess + parameters: + - description: 数据订阅ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/MySwagger.Result' + "400": + description: Bad Request + schema: + $ref: '#/definitions/MySwagger.Result' + summary: 获取数据订阅详情 + tags: + - dataaccess /v1/openapi/dataaccess/ReadDataaccess: post: consumes: