master
wangshuai 5 years ago
parent 5dce50653a
commit 35224df1db

@ -40,7 +40,7 @@ func ReadDataaccess(c *gin.Context) {
Fail: false,
Message: message,
Total: count,
Data: data,
Datas: data,
})
return

@ -47,7 +47,7 @@ func ReadDataerror(c *gin.Context) {
Fail: false,
Message: message,
Total: count,
Data: data,
Datas: data,
})
return

@ -15,6 +15,7 @@ func Routers(r *gin.RouterGroup) {
rr.POST("/datasource/UpdateDatasource/:id", DatasourceOpenAPI.UpdateDatasource)
rr.POST("/datasource/DeleteDatasource/:id", DatasourceOpenAPI.DeleteDatasource)
rr.POST("/datasource/ReadESDoc", DatasourceOpenAPI.ReadESDoc)
rr.POST("/datasource/GetESDoc", DatasourceOpenAPI.GetESDoc)
return
}

@ -40,7 +40,7 @@ func ReadDatasource(c *gin.Context) {
Fail: false,
Message: message,
Total: count,
Data: data,
Datas: data,
})
return
@ -211,6 +211,52 @@ func ReadESDoc(c *gin.Context) {
success, message, esdata := DatasourceService.ReadESDoc(datasourceCode, orgIDs, page, begin, conditions, sort)
//fmt.Println("esdata=", esdata)
if success {
c.JSON(http.StatusOK, MySwagger.Result{
Success: true,
Fail: false,
Message: message,
Datas: esdata,
})
return
} else {
c.JSON(http.StatusOK, MySwagger.Result{
Success: false,
Fail: true,
Message: message,
})
return
}
return
}
// 获取es数据 godoc
// @Summary 获取es数据
// @Description 获取es数据
// @Tags datasource
// @ID getESDoc
// @Accept json
// @Produce json
// @Param input body MySwagger.DatasourceESSwag true "es数据"
// @Success 200 {object} MySwagger.Result
// @Failure 400 {object} MySwagger.Result
// @Router /v1/openapi/datasource/GetESDoc [post]
func GetESDoc(c *gin.Context) {
var raw MySwagger.DatasourceESSwag
if err := c.ShouldBindJSON(&raw); err != nil {
c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Message: "JSON格式错误"})
fmt.Println(err)
return
}
datasourceCode := raw.DatasourceCode
dataID := raw.DataId
success, message, esdata := DatasourceService.GetESDoc(datasourceCode, dataID)
if success {
c.JSON(http.StatusOK, MySwagger.Result{
Success: true,

@ -3,7 +3,6 @@ package DatasourceService
import (
"dsSupport/MyModel/AccessSystem/AccessSystemDao"
"dsSupport/MyModel/DataSource/DatasourceDAO"
"dsSupport/MyModel/JYT2012/Jyt2012Service"
"dsSupport/MyModel/MySwagger"
"dsSupport/MyModel/OrgTree/OrgtreeService"
"dsSupport/Utils/CacheUtil"
@ -92,9 +91,6 @@ func CreateDatasource(model models.TDataexDatasource) (bool, string, error) {
if e != nil {
return false, "SystemId不存在", nil
}
if !Jyt2012Service.IsJyt2012ExistsById(model.DicId) {
return false, "DicId不存在", nil
}
if !OrgtreeService.IsOrgtreeExistsById(model.ProvideOrgid) {
return false, "OrgId不存在", nil
}
@ -164,6 +160,24 @@ func RemoveDatasource(id string) (bool, string, error) {
return result, message, error
}
func GetESDoc(datasourceCode string, dataId string) (bool, string, map[string]interface{}) {
result, message, esdata := ES7Util.IndexDocGet(datasourceCode, dataId)
var query = "AND datasource_code='" + datasourceCode + "'"
res, _, data, _ := DatasourceDAO.GetDatasourceRow(query)
var datasourceName interface{}
if res == true {
datasourceName = data["datasource_name"]
}
m := make(map[string]interface{})
j, _ := json.Marshal(esdata)
json.Unmarshal(j, &m)
m["datasource_name"] = datasourceName
return result, message, m
}
func ReadESDoc(datasourceCode string, orgIDs []string, page int, begin string, conditions map[string]interface{}, sort map[string]interface{}) (bool, string, []map[string]interface{}) {
result, message, esdata := ES7Util.SearchDocPage(datasourceCode, orgIDs, page, begin, conditions, sort)
var query = "AND datasource_code='" + datasourceCode + "'"

@ -26,7 +26,7 @@ func ReadESDocAmount(c *gin.Context) {
Fail: false,
Message: message,
Total: count,
Data: data,
Datas: data,
})
return

@ -49,7 +49,7 @@ func ReadJyt2012(c *gin.Context) {
Fail: false,
Message: message,
Total: count,
Data: data,
Datas: data,
})
return

@ -37,7 +37,7 @@ func ReadMetadata(c *gin.Context) {
Fail: false,
Message: message,
Total: count,
Data: data,
Datas: data,
})
return

@ -4,7 +4,8 @@ type DatasourceESSwag struct {
DatasourceCode string `json:"datasource_code" xorm:"not null comment('数据源编码') VARCHAR(8)" example:"org_tree"`
OrgIDs []string `json:"orgids" xorm:"not null comment('提供数据范围【1本机构2本机构以及下属机构-1不限制】') VARCHAR(36)" example:"[F38BD0DB-0142-4356-8F2B-623813FC2578,F38BD0DB-0142-4356-8F2B-623813FC2578]"`
BeginTime string `json:"begin_time" example:"2020-06-22 17:26:53"`
Conditions map[string]interface{} `json:"conditions" example:"[{res_id:12300,res_name:初一语文一单元作业,teacher_id:123001,time_spend:100s}]"`
Sort map[string]interface{} `json:"sort" example:"[{res_id:12300,res_name:初一语文一单元作业,teacher_id:123001,time_spend:100s}]"`
Conditions map[string]interface{} `json:"conditions" example:""`
Sort map[string]interface{} `json:"sort" example:""`
DataId string `json:"data_id" example:"CfBQnRJPyXMEI5nqLT0"`
Page int `json:"page" example:"1"`
}

@ -5,5 +5,6 @@ type Result struct {
Fail bool `json:"fail" example:"false"`
Message string `json:"message" example:"操作成功"`
Total int `json:"total" example:"120"`
Data []map[string]interface{} `json:"data" `
Data map[string]interface{} `json:"data" `
Datas []map[string]interface{} `json:"data" `
}

@ -35,7 +35,7 @@ func ReadOrgtree(c *gin.Context) {
Fail: false,
Message: message,
Total: count,
Data: data,
Datas: data,
})
return

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save