Merge branch 'master' of 10.10.14.250:huanghai/dsMin

master
wubin 5 years ago
commit 7cae0e3a5d

@ -52427,3 +52427,7 @@
[Error]2020/10/15 15:25:42 SqlQueryError bad connection
[Error]2020/10/15 15:25:42 SqlQueryError bad connection
[Error]2020/10/15 15:25:42 SqlQueryError bad connection
[Error]2020/11/23 14:24:28 SqlQueryError Error 1146: Table 'base_db_zhangjun.t_app_base' doesn't exist
[Error]2020/11/23 14:27:23 SqlQueryError Error 1146: Table 'base_db_zhangjun.t_app_base' doesn't exist
[Error]2020/11/23 14:27:37 SqlQueryError Error 1146: Table 'base_db_zhangjun.t_app_base' doesn't exist
[Error]2020/11/23 14:29:21 SqlQueryError Error 1146: Table 'base_db_zhangjun.t_app_base' doesn't exist

@ -1,20 +1,25 @@
[mysql]
ip = 10.10.6.200
port = 22066
database = base_db_zhangjun
user = root
pwd = DsideaL147258369
;ip = 10.10.14.187
;ip = 10.10.6.200
;port = 22066
;database = base_db_zhangjun
;user = root
;pwd = DsideaL147258369
ip = 10.10.14.187
port = 22066
database = base_db_dev
user = root
pwd = DsideaL147258369
[redis]
ip = 127.0.0.1
port = 6379
db = 1
;ip = 127.0.0.1
;port = 6379
;db = 1
;expireTime = 86400
ip = 10.10.14.187
port = 18890
db = 0
expireTime = 86400
;ip =server.dsmin.com
@ -33,8 +38,8 @@ process_no = 1
[elasticsearch]
;nodes = http://10.10.14.188:9200,
nodes = http://10.10.14.61:9200,http://10.10.14.62:9200,http://10.10.14.63:9200
user =
pwd =
user = root
pwd = dsideal
[project]
project_name = dsDataex

@ -0,0 +1,16 @@
package models
type TAppBase struct {
AppId string `json:"app_id" xorm:"not null pk comment('系统ID') CHAR(36)"`
AppCode string `json:"app_code" xorm:"not null comment('系统编码') VARCHAR(50)"`
AppName string `json:"app_name" xorm:"not null comment('系统名称') VARCHAR(100)"`
AccessKey string `json:"access_key" xorm:"not null comment('AK') CHAR(20)"`
SecretKey string `json:"secret_key" xorm:"not null comment('SK') CHAR(26)"`
AppToken string `json:"app_token" xorm:"not null comment('系统鉴权票据') CHAR(26)"`
AppUrl string `json:"app_url" xorm:"default 'NULL' comment('系统集成页面调用地址') VARCHAR(1024)"`
AppIcon string `json:"app_icon" xorm:"default 'NULL' comment('系统图标的路径') VARCHAR(1024)"`
RedirectUri string `json:"redirect_uri" xorm:"default 'NULL' comment('统一认证回调地址') VARCHAR(1024)"`
LogoutUri string `json:"logout_uri" xorm:"default 'NULL' comment('统一认证登出地址') VARCHAR(1024)"`
BUse int32 `json:"b_use" xorm:"not null comment('是否可用 -2不可用 1可用') TINYINT(1)"`
SortId int32 `json:"sort_id" xorm:"not null default 1 comment('排序号') INT(11)"`
}

@ -7,7 +7,6 @@ import (
"dsDataex/Utils/ErrorConst"
"dsDataex/Utils/LogUtil"
"html"
"time"
)
//数据库
@ -27,7 +26,7 @@ func GetbyID(id string) (bool, string, map[string]interface{}, error){
ids:=[]string{id}
result := CacheUtil.GetListByIds( ids ,CacheUtil.GetBean("t_dataex_linksystem"))
result := CacheUtil.GetListByIds( ids ,CacheUtil.GetBean("t_app_base"))
if len(result)==1 {
return true, "数据获取成功", result[0],nil
@ -48,7 +47,7 @@ func GetbyID(id string) (bool, string, map[string]interface{}, error){
**/
func GetbyCode(code string) (bool, string, map[string]interface{}, error){
sql := "SELECT id from t_dataex_linksystem where delete_flag = -1 and enable_flag = 1 and system_code = '" + html.EscapeString(code) + "'"
sql := "SELECT app_id from t_app_base where b_use = 1 and app_code = '" + html.EscapeString(code) + "'"
//通过SQL获取带缓存的数据
list, count, _ := CacheUtil.Page(sql, 10,0)
@ -72,21 +71,19 @@ func GetbyCode(code string) (bool, string, map[string]interface{}, error){
* @return string
* @return error
**/
func Update(id string, authToken string ,authTime time.Time) (bool, string, error){
business := new(models.TDataexLinksystem)
func Update(appId string, authToken string) (bool, string, error){
business := new(models.TAppBase)
//清除Redis缓存
var ids = []string{id}
var selector = CacheUtil.GetBean("t_dataex_linksystem")
var ids = []string{appId}
var selector = CacheUtil.GetBean("t_app_base")
CacheUtil.DeleteCacheByIds(ids, selector)
business.Id = html.EscapeString(id)
business.AuthToken = html.EscapeString(authToken)
business.AuthTime = authTime
business.ChangeTime = time.Now()
business.AppId = html.EscapeString(appId)
business.AppToken = html.EscapeString(authToken)
//通过添加Cols函数指定需要更新结构体中的哪些值未指定的将不更新指定了的即使为0也会更新。
_, err := db.Where(" id = ?", id ).Cols("auth_time", "auth_token", "change_time").Update(business)
_, err := db.Where(" app_id = ?", appId ).Cols("app_token").Update(business)
if err != nil {
LogUtil.Error(ErrorConst.SqlUpdateError, "接入系统authToken Update数据库操作发生严重错误"+err.Error())

@ -26,15 +26,15 @@ func CreateToken(systemID string,systemToken string,authTime string) (bool, stri
return false,result,""
}else {
systemKey:= data["system_key"].(string)
id:= data["id"].(string)
systemKey:= data["secret_key"].(string)
appId:= data["app_id"].(string)
if systemToken==MD5Util.MD5V1(MD5Util.MD5V1(systemID + authTime) + systemKey){
nowTime := time.Now()
authToken := "DSDataex_Token_"+MD5Util.MD5V1(systemID + nowTime.Format("2004-01-02 15:04:05") + systemKey)
authToken := "DSDataex_Token_"+MD5Util.MD5V1(systemID + nowTime.Format("2006-01-02 15:04:05") + systemKey)
AuthDAO.Update(id,authToken,nowTime)
AuthDAO.Update(appId,authToken)
return true,"接入系统Token验证成功",authToken
}else {
@ -63,7 +63,7 @@ func CheckToken(systemID string,authToken string) (bool, string,string){
return false,result,""
}else {
myToken:= data["auth_token"].(string)
myToken:= data["app_token"].(string)
if myToken==authToken{
@ -83,14 +83,14 @@ func CheckAccessToken(systemID string,accessTime string,accessToken string) (boo
return false,result,""
}else {
if data["auth_token"] != nil {
myToken:= data["auth_token"].(string)
if data["app_token"] != nil {
myToken:= data["app_token"].(string)
var testToken=MD5Util.MD5V1(systemID + accessTime + myToken)
if testToken==accessToken{
return true,"接入系统票据验证成功",data["id"].(string)
return true,"接入系统票据验证成功",data["app_id"].(string)
}else {
return false,"接入系统票据验证失败",""

@ -25,7 +25,7 @@ pwd = DsideaL147258369
;expireTime = 86400
ip = 10.10.14.187
port = 18890
db = 0
db = 1
expireTime = 86400
#gin服务器的端口

@ -96,7 +96,8 @@ func CurrentUser(username string) (bool, string) {
* @return error
**/
func GetbyCode(code string) (bool, string, map[string]interface{}, error){
sql := "SELECT * from t_dataex_linksystem where delete_flag = -1 and enable_flag = 1 and system_code = '" + html.EscapeString(code) + "'"
//sql := "SELECT * from t_dataex_linksystem where delete_flag = -1 and enable_flag = 1 and system_code = '" + html.EscapeString(code) + "'"
sql := "SELECT * from t_app_base where b_use = 1 and app_code = '" + html.EscapeString(code) + "'"
var limit = 100
var offset = 0

@ -256,7 +256,7 @@ func ReadESDoc(c *gin.Context) {
success, message, count, esdata := DatasourceService.ReadESDoc(datasourceCode, orgIDs, page, begin, conditions, sort)
if success {
c.JSON(http.StatusOK, MySwagger.Result{
c.JSON(http.StatusOK, MySwagger.Result2{
Success: true,
Fail: false,
Message: message,
@ -266,7 +266,7 @@ func ReadESDoc(c *gin.Context) {
return
} else {
c.JSON(http.StatusOK, MySwagger.Result{
c.JSON(http.StatusOK, MySwagger.Result2{
Success: false,
Fail: true,
Message: message,

@ -8,6 +8,7 @@ import (
"dsSupport/Utils/CacheUtil"
"dsSupport/Utils/CommonUtil"
"dsSupport/Utils/ES7Util"
"dsSupport/Utils/ES7Util/DataEX"
"dsSupport/models"
"encoding/json"
"fmt"
@ -216,31 +217,74 @@ func GetESDoc(datasourceCode string, dataId string) (bool, string, map[string]in
return result, message, m
}
func ReadESDoc(datasourceCode string, orgIDs []string, page int, begin string, conditions map[string]interface{}, sort map[string]interface{}) (bool, string, int, []map[string]interface{}) {
func ReadESDoc(datasourceCode string, orgIDs []string, page int, begin string, conditions map[string]interface{}, sort map[string]interface{}) (bool, string, int, []DataEX.ESData2) {
t1 := time.Now()
count, _ := ES7Util.GetDocCount(datasourceCode, begin, conditions)
t2 := time.Now()
fmt.Println("t2与t1相差", t2.Sub(t1))
result, message, esdata := ES7Util.SearchDocPage(datasourceCode, orgIDs, page, begin, conditions, sort)
t3 := time.Now()
fmt.Println("t3与t2相差", t3.Sub(t2))
var ESData2 []DataEX.ESData2
var esData2 DataEX.ESData2
for _, value := range esdata {
var query = "AND datasource_code='" + datasourceCode + "'"
res, _, data, _ := DatasourceDAO.GetDatasourceRow(query)
var datasourceName interface{}
if res == true {
datasourceName = data["datasource_name"]
esData2.DatasourceName = datasourceName.(string)
}
esData2.SystemId = value.SystemId
esData2.DatasourceId = value.DatasourceId
//
esData2.ProvinceId = value.ProvinceId
esData2.ProvinceName = value.ProvinceName
esData2.CityId = value.CityId
esData2.CityName = value.CityName
esData2.AreaId = value.AreaId
esData2.AreaName = value.AreaName
esData2.BureauId = value.BureauId
esData2.RegionId = value.RegionId
esData2.MainId = value.MainId
esData2.OrgId = value.OrgId
esData2.OrgName = value.OrgName
esData2.OrgType = value.OrgType
esData2.SchoolType = value.SchoolType
esData2.SchoolTypeName = value.SchoolTypeName
esData2.DeptId = value.DeptId
esData2.StageId = value.StageId
esData2.GradeId = value.GradeId
esData2.ClassId = value.ClassId
esData2.DataId = value.DataId
esData2.FileUri = value.FileUri
esData2.BeginTime = value.BeginTime
esData2.EndTime = value.EndTime
esData2.DelFlag = value.DelFlag
esData2.EnableFlag = value.EnableFlag
esData2.DataContent = value.DataContent
ESData2 = append(ESData2, esData2)
}
/*
var esDatas []map[string]interface{}
var datas []map[string]interface{}
// 写法2
//esDatas := make([]interface{}, count)
fmt.Println(esDatas)
for _, value := range esdata {
esData := make(map[string]interface{})
j, _ := json.Marshal(value)
json.Unmarshal(j, &esData)
//esData["datasource_name"] = datasourceName
//fmt.Println("esData:", esData)
esDatas = append(esDatas, esData)
// 写法2
//esDatas[k] = make(map[string]interface{}, 1)
//esDatas[k] = esData
}
*/
t4 := time.Now()
fmt.Println("t4与t3相差", t4.Sub(t3))
/*
var query = ""
res, _, _, datasources, _ := DatasourceDAO.GetAllDatasourceResults(query)
fmt.Println(datasources)
@ -251,9 +295,12 @@ func ReadESDoc(datasourceCode string, orgIDs []string, page int, begin string, c
json.Unmarshal([]byte(mergedesDatas), &datas)
}
fmt.Println("datas:", datas)
return result, message, count, datas
*/
//t4 := time.Now()
//fmt.Println("t4与t3相差", t4.Sub(t3))
fmt.Println("ESData2:", ESData2)
//var datas []map[string]interface{}
return result, message, count, ESData2
}
//func IsDatasourceExistsByCode(code string) bool {

@ -0,0 +1,11 @@
package MySwagger
import "dsSupport/Utils/ES7Util/DataEX"
type Result2 struct {
Success bool `json:"success" example:"true"`
Fail bool `json:"fail" example:"false"`
Message string `json:"message" example:"操作成功"`
Total int `json:"total" example:"120"`
Data []DataEX.ESData2 `json:"data" `
}

@ -0,0 +1,35 @@
package DataEX
type ESData2 struct {
SystemId string `json:"system_id"`
DatasourceId string `json:"datasource_id"`
DatasourceName string `json:"datasource_name"`
ProvinceId string `json:"province_code"`
ProvinceName string `json:"province_name"`
CityId string `json:"city_code"`
CityName string `json:"city_name"`
AreaId string `json:"district_code"`
AreaName string `json:"district_name"`
BureauId string `json:"bureau_id"`
RegionId string `json:"region_id"`
MainId string `json:"main_id"`
OrgId string `json:"org_id"`
OrgName string `json:"org_name" `
OrgType int `json:"org_type"`
SchoolType string `json:"school_type"`
SchoolTypeName string `json:"school_typename"`
DeptId string `json:"dept_id"`
StageId string `json:"stage_id"`
GradeId string `json:"grade_id"`
ClassId string `json:"class_id"`
DataId string `json:"data_id"`
FileUri string `json:"file_uri"`
BeginTime JsonDate `json:"begin_time"`
EndTime JsonDate `json:"end_time"`
DelFlag int `json:"del_flag"`
EnableFlag int `json:"enable_flag"`
DataContent map[string]interface{} `json:"data_content"`
}
Loading…
Cancel
Save