master
wangshuai 5 years ago
parent 9f140864e3
commit ca4596c852

@ -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)

@ -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

@ -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"

@ -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

@ -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"`

@ -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('删除标志【默认-11删除-1正常】') INT(11)\" example:\"1\"\njson:\"enable_flag\" xorm:\"not null default 1 comment('启用标志【默认11启用-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
}
}
}

@ -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('删除标志【默认-11删除-1正常】') INT(11)\" example:\"1\"\njson:\"enable_flag\" xorm:\"not null default 1 comment('启用标志【默认11启用-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
}
}
}

@ -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:

Loading…
Cancel
Save