master
wangshuai 5 years ago
parent 3f3e452f3f
commit be671ac96a

@ -144,10 +144,12 @@ func batchReadRedis(ids []string, prefix string) ([]map[string]interface{}, []st
func count(baseSql string, pkField string, args []interface{}) (int32, error) {
//替换掉分页代码,获取数据量总数
countSql := strings.Replace(baseSql, "SELECT "+pkField+" ", "SELECT count(*) as count ", -1)
fmt.Println("countSql==", countSql)
var count int32
//去掉最后的limit+offset
args = args[0 : len(args)-2]
_, err := DbUtil.Engine.SQL(countSql, args...).Get(&count)
fmt.Println("err==", err)
if err != nil {
LogUtil.Error(ErrorConst.SqlQueryError, err.Error())
return 0, err
@ -177,6 +179,7 @@ func Page(baseSql string, args ...interface{}) ([]map[string]interface{}, int32,
conditionSql := fmt.Sprintf("%s", " limit ? offset ? ")
//分页的语句
pageSql := fmt.Sprintf("%s %s", baseSql, conditionSql)
fmt.Println("pageSql=", pageSql)
//分页数据
list, err := DbUtil.Engine.SQL(pageSql, args...).Query().List()

@ -0,0 +1,64 @@
package DataEX
import (
"fmt"
"time"
)
type ESData struct {
SystemId string `json:"system_id"`
DatasourceId string `json:"datasource_id"`
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"`
}
//add by zhangjun 2020-07-01
type JsonDate time.Time
const (
timeFormat = "2006/01/02 15:04:05"
)
// JsonDate反序列化
func (t *JsonDate) UnmarshalJSON(data []byte) (err error) {
newTime, err := time.ParseInLocation("\""+timeFormat+"\"", string(data), time.Local)
*t = JsonDate(newTime)
return
}
// JsonDate序列化
func (t JsonDate) MarshalJSON() ([]byte, error) {
timeStr := fmt.Sprintf("\"%s\"", time.Time(t).Format(timeFormat))
return []byte(timeStr),nil
}
// string方法
func (t JsonDate) String() string {
return time.Time(t).Format(timeFormat)
}

@ -0,0 +1,24 @@
package DataEX
type KafkaData struct {
SystemId string `json:"system_id"`
DatasourceId string `json:"datasource_id"`
DataId string `json:"data_id"`
UserID string `json:"user_id"`
Identity string `json:"identity"`
AccessID string `json:"access_id"`
AccessIP string `json:"access_ip"`
AccessWay string `json:"access_way"`
EventType string `json:"event_type"`
EventName string `json:"event_name"`
EventTime string `json:"event_time"`
EventURI string `json:"event_uri"`
EventSeqNO string `json:"event_seqno"`
CollectTime string `json:"collect_time"`
UserProperty map[string]interface{} `json:"user_property"`
EventProperty map[string]interface{} `json:"event_property"`
}

@ -0,0 +1,678 @@
package ES7Util
import (
"context"
"dsSupport/Utils/CommonUtil"
"dsSupport/Utils/ConfigUtil"
"dsSupport/Utils/ES7Util/DataEX"
"dsSupport/Utils/ES7Util/MySwagger"
"dsSupport/Utils/RedisUtil"
"encoding/json"
"fmt"
"github.com/olivere/elastic/v7"
"reflect"
"strconv"
"strings"
"time"
)
var ES7Client *elastic.Client
var ServerVersion string
var CTX context.Context
/**
* @Author zhangjun
* @Description ES7
* @Date 2020-06-12 16:34
* @Param
* @return
**/
func init() {
//初始化ES Client使用配置文件
ES7Client, _ = elastic.NewClient(elastic.SetURL(ConfigUtil.ESAddress...))
CTX=context.Background()
//Ping获取ES server启动信息
info, _, _ := ES7Client.Ping(ConfigUtil.ESAddress[0]).Do(CTX)
ServerVersion =ES7Client.String() +"【"+ info.Version.Number+"】"
}
/**
* @Author zhangjun
* @Description ES
* @Date 2020-06-12 14:31
* @Param indexName string ES
* @Param dataMap string ESMapping
* @return bool /
* @return error
**/
func IndexCreate(indexName string,dataMap string) (bool,error){
const emptyMap = `
{
"settings":{
"number_of_shards": 3,
"number_of_replicas": 1
},
"mappings":{
}
}`
if dataMap==""{
dataMap=emptyMap
}
createIndex, err := ES7Client.CreateIndex(indexName).Body(dataMap).Pretty(true).Do(CTX)
if createIndex.Acknowledged {
return true,nil
} else{
return false,err
}
}
/**
* @Author zhangjun
* @Description ES, Redis
* @Date 2020-06-12 14:42
* @Param indexName string ES
* @return bool /
* @return error
**/
func IndexExist(indexName string) (bool,error){
count,_:= RedisUtil.RedisClient.Exists("es_index_"+indexName).Result()
if count>0 {
return true,nil
}else{
exists, _ := ES7Client.IndexExists(indexName).Do(CTX)
if exists {
RedisUtil.SET("es_index_"+indexName,indexName,10*time.Hour)
return true,nil
}else {
return false,nil
}
}
}
/**
* @Author zhangjun
* @Description 使
* @Date 2020-06-12 14:38
* @Param indexName string ES
* @Param data map[string]interface{}
* @return bool /
* @return error
**/
func IndexInit(indexName string,dataex map[string]interface{}) (bool,error) {
IndexCreate(indexName,"")
begin:= time.Now();
end:=time.Date(9999,9,9,9,9,9,0,begin.Location())
//dataex := make(map[string]interface{})
//dataex["org_id"]="123"
//dataex["org_name"]="长春市第一中学"
//dataex["org_type"]=2
var myMap=make(map[string]interface{})
for key, val := range dataex {
switch val.(type){
case int,int32,int64:
new,_:=strconv.ParseFloat(val.(string),64)
myMap[key]=new +0.1
case float64:
new,_:=val.(float64)
myMap[key]=new +0.1
default:
myMap[key]=val
}
}
dataJson := DataEX.ESData{SystemId: "BASE001",
DatasourceId: indexName,
ProvinceId: "220000",
CityId: "220100",
AreaId: "220101",
RegionId: "R22010101",
BureauId: "B22010101",
MainId: "M2201010101",
OrgId: "O22010101010101",
OrgType: 1,
GradeId: "G2020",
ClassId: "C202001",
DeptId: "D20200001",
StageId: "S0001",
DataId: "D22010101010101",
DataContent: myMap,
FileUri: "/path/file",
BeginTime: DataEX.JsonDate(begin) ,
EndTime: DataEX.JsonDate(end),
DelFlag: -1,
EnableFlag: 1,
}
result, err := ES7Client.Index().Index(indexName).Id("2020-2020").BodyJson(dataJson).Do(CTX)
if result.Result=="created" {
//change by zhangjun 2020-06-30
//ES7Client.Delete().Index(indexName).Id("2020-2020").Do(CTX)
res,_:= ES7Client.GetMapping().Index(indexName).Do(CTX)
bytes,_:=json.Marshal( res[indexName] )
mapping :=string(bytes)
new :=strings.Replace(mapping,"\"fields\":{\"keyword\":{\"ignore_above\":256,\"type\":\"keyword\"}},","",-1)
new=strings.Replace(new,"{\"mappings\"","{\"settings\":{\"number_of_shards\": 3,\"number_of_replicas\": 1},\"mappings\"",-1)
new=strings.Replace(new,"\"text\"","\"keyword\"",-1)
//Delete the dafault date format
//new=strings.Replace(new ,"\"format\":\"yyyy/MM/dd HH:mm:ss||yyyy/MM/dd||epoch_millis\",","",-1)
//new=strings.Replace(new,"\"date\"}","\"date\",\"format\":\"yyyy/MM/dd HH:mm:ss||yyyy/MM/dd||epoch_millis\"}",-1)
ES7Client.DeleteIndex(indexName).Do(CTX)
ES7Client.CreateIndex(indexName).Body(new).Pretty(true).Do(CTX)
return true,nil
}else{
return false,err
}
}
/**
* @Author zhangjun
* @Description ES Mapping
* @Date 2020-06-12 17:07
* @Param indexName string ES
* @return map[string]interface mapping data_content
**/
func IndexDatamap(indexName string) map[string]interface{} {
result,_:= ES7Client.GetMapping().Index(indexName).Do(CTX)
return result["data_content"].(map[string]interface{})
}
/**
* @Author zhangjun
* @Description
* @Date 2020-06-15 16:52
* @Param indexName string
* @Param data ESData
* @return
**/
func IndexDocAdd(indexName string,indexData *DataEX.ESData) (bool,string,error){
indexData.BeginTime = DataEX.JsonDate(time.Now());
indexData.EndTime =DataEX.JsonDate(time.Date(9999,9,9,9,9,9,0,time.Now().Location()))
newid:=CommonUtil.GetUUID()
result, err := ES7Client.Index().Index(indexName).Id(newid).BodyJson(indexData).Do(CTX)
if result.Result=="created" {
return true,"文档操作成功",nil
}else{
return false,"文档操作失败",err
}
}
/**
* @Author zhangjun
* @Description Kafka 2 ES
* @Date 2020-08-02 02:44
* @Param
* @return
**/
func IndexDocAdd2(indexName string,indexData *DataEX.ESData){
//defer func() {
// if err := recover(); err != nil {
// fmt.Println("IndexDocAdd2 Panic Recover :", err)
// }
//}()
indexData.BeginTime = DataEX.JsonDate(time.Now());
indexData.EndTime =DataEX.JsonDate(time.Date(9999,9,9,9,9,9,0,time.Now().Location()))
res, err := ES7Client.Index().Index(indexName).Id(indexData.DataId).BodyJson(indexData).Do(CTX)
if err != nil {
fmt.Println("IndexDocAdd2 Error :" +err.Error())
}else {
if res.Result == "created" {
//fmt.Println("IndexDocAdd2 Result :" ,res)
}
if res.Result == "updated"{
//fmt.Println("IndexDocAdd2 Result :" ,res)
}
}
}
/**
* @Author zhangjun
* @Description
* @Date 2020-06-17 09:31
* @Param indexName string
* @Param indexData ESData
* @return bool /
* @return error
* @return string ID
* @return mapstringstring map
**/
func IndexDocAddBatch(indexName string,indexData []*DataEX.ESData) (bool,error,[]string,[]MySwagger.FailResult){
var requests []elastic.BulkableRequest
var tempMap =make(map[string]string)
var IDs []string
var Fails []MySwagger.FailResult
for no:=0;no< len(indexData);no++{
//indexData[no].BeginTime = time.Now();
//indexData[no].EndTime =time.Date(9999,9,9,9,9,9,0,time.Now().Location())
newid:=CommonUtil.GetUUID()
//文档ID 绑定 数据ID
tempMap[newid]=indexData[no].DataId
IDs=append(IDs,indexData[no].DataId)
req := elastic.NewBulkIndexRequest()
req.Index(indexName).Id(newid).Doc(indexData[no])
requests=append(requests,req)
}
//批量添加索引文档,只返回错误记录
result, _ := ES7Client.Bulk().Index(indexName).Add(requests...).FilterPath("items.*.error").Do(CTX)
//result, err := ES7Client.Bulk().Index(indexName).Add(requests...).Do(CTX)
ES7Client.Refresh(indexName).Do(CTX)
if len(result.Items) ==0 {
return true,nil,IDs,nil
}else {
for no:=0;no< len(result.Items);no++{
reason :=result.Items[no]["index"].Error.Reason
docID := reason[strings.Index(reason,"document with id '")+ 18:strings.Index(reason,"document with id '") + 18 + 36]
dataID:= tempMap[docID]
IDs=remove(IDs,dataID)
var fail MySwagger.FailResult
fail.FailID=dataID
fail.FailReason=reason
Fails =append(Fails,fail)
}
return true,nil,IDs,Fails
}
}
/**
* @Author zhangjun
* @Description dataID
* @Date 2020-06-16 15:59
* @Param indexName string
* @Param dataID string ID
* @return
**/
func IndexDocDel(indexName string,dataID string) (bool,string,error){
//change by zhangjun 2020-07-01
//term := elastic.NewTermQuery("data_id.keyword", dataID)
term := elastic.NewTermQuery("data_id", dataID)
term2 := elastic.NewTermQuery("enable_flag", 1)
query:=elastic.NewBoolQuery()
query.Filter(term).Filter(term2)
script := elastic.NewScript("ctx._source.enable_flag = 0 ; ctx._source.end_time = params.now ").Param("now", time.Now())
response,err:= ES7Client.UpdateByQuery().Index(indexName).Query(query).Script(script).Do(CTX)
if err !=nil{
return false,"文档修改失败",err
}
if response.Updated >0{
return true,"文档修改成功",nil
}
return true,"文档修改成功,没有符合筛选条件的文档",nil
}
/**
* @Author zhangjun
* @Description
* @Date 2020-06-17 09:33
* @Param indexName string
* @Param dataIDs string ID
* @return
**/
func IndexDocDelBatch(indexName string, end time.Time, dataIDs []string) (bool,string,error){
//change by zhangjun 2020-07-01
//term := elastic.NewTermsQuery("data_id.keyword", string2interface(dataIDs)...)
term := elastic.NewTermsQuery("data_id", string2interface(dataIDs)...)
term2 := elastic.NewTermQuery("enable_flag", 1)
query:=elastic.NewBoolQuery()
query.Filter(term).Filter(term2)
script := elastic.NewScript("ctx._source.enable_flag = 0 ; ctx._source.end_time = params.now ").Param("now", DataEX.JsonDate(end))
response,err:= ES7Client.UpdateByQuery().Index(indexName).Query(query).Script(script).Do(CTX)
ES7Client.Refresh(indexName).Do(CTX)
if err !=nil{
return false,"文档批量修改失败",err
}
if response.Updated >0{
return true,"文档批量修改成功",nil
}
return true,"文档批量修改成功,没有符合筛选条件的文档",nil
}
func IndexDocDelBatch2(indexName string,end time.Time, dataIDs []string) (bool,string,error){
//change by zhangjun 2020-07-01
//term := elastic.NewTermsQuery("data_id.keyword", string2interface(dataIDs)...)
term := elastic.NewTermsQuery("data_id", string2interface(dataIDs)...)
term2 := elastic.NewTermQuery("enable_flag", 1)
term3 := elastic.NewRangeQuery("begin_time").Lt(end)
query:=elastic.NewBoolQuery()
query.Filter(term).Filter(term2).Filter(term3)
script := elastic.NewScript("ctx._source.enable_flag = 0 ; ctx._source.end_time = params.now ").Param("now", DataEX.JsonDate(end))
response,err:= ES7Client.UpdateByQuery().Index(indexName).Query(query).Script(script).Do(CTX)
ES7Client.Refresh(indexName).Do(CTX)
if err !=nil{
return false,"文档批量修改失败",err
}
if response.Updated >0{
return true,"文档批量修改成功",nil
}
return true,"文档批量修改成功,没有符合筛选条件的文档",nil
}
func IndexDocDelRestore(indexName string, end time.Time, dataIDs []string) (bool,string,error){
//change by zhangjun 2020-07-01
//term := elastic.NewTermsQuery("data_id.keyword", string2interface(dataIDs)...)
term := elastic.NewTermsQuery("data_id", string2interface(dataIDs)...)
term2 := elastic.NewTermQuery("enable_flag", 0)
term3 := elastic.NewTermQuery("end_time",end)
query:=elastic.NewBoolQuery()
query.Filter(term).Filter(term2).Filter(term3)
newEnd :=time.Date(9999,9,9,9,9,9,0,time.Now().Location())
script := elastic.NewScript("ctx._source.enable_flag = 1 ; ctx._source.end_time = params.now ").Param("now", DataEX.JsonDate(newEnd))
response,err:= ES7Client.UpdateByQuery().Index(indexName).Query(query).Script(script).Do(CTX)
ES7Client.Refresh(indexName).Do(CTX)
if err !=nil{
return false,"文档批量修改失败",err
}
if response.Updated >0{
return true,"文档批量修改成功",nil
}
return true,"文档批量修改成功,没有符合筛选条件的文档",nil
}
func IndexDocGet(indexName string,dataID string) (bool,string,DataEX.ESData) {
var data DataEX.ESData
//change by zhangjun 2020-07-01
//term := elastic.NewTermQuery("data_id.keyword", dataID)
term := elastic.NewTermQuery("data_id", dataID)
term2 := elastic.NewTermQuery("enable_flag", 1)
query:=elastic.NewBoolQuery()
query.Filter(term).Filter(term2)
result,err:=ES7Client.Search().Index(indexName).Query(query).Do(CTX)
if err == nil{
var ttyp DataEX.ESData
for _, item := range result.Each(reflect.TypeOf(ttyp)) {
data = item.(DataEX.ESData)
break
}
return true,"获取数据成功", data
}else{
return false,"获取数据失败", data
}
}
func IndexDocPage(indexName string,orgIDs []string,page int,begin string) (bool,string,[]DataEX.ESData) {
var list []DataEX.ESData
term2 := elastic.NewTermQuery("enable_flag", 1)
query:=elastic.NewBoolQuery()
query.Filter(term2)
if len(orgIDs)!=0{
//change by zhangjun 2020-07-01
//term := elastic.NewTermsQuery("org_id.keyword", string2interface(orgIDs)...)
term := elastic.NewTermsQuery("org_id", string2interface(orgIDs)...)
query.Filter(term)
}
if begin!=""{
term3 := elastic.NewRangeQuery("begin_time").Gte(begin)
query.Filter(term3)
}
result,err:=ES7Client.Search().Index(indexName).Query(query).From(page * 100).Size(100).Sort("begin_time",true).Do(CTX)
if err == nil{
var ttyp DataEX.ESData
for _, item := range result.Each(reflect.TypeOf(ttyp)) {
data := item.(DataEX.ESData)
list=append(list,data)
}
return true,"获取数据成功", list
}else{
return false,"获取数据失败", list
}
}
func IndexDocQuery(indexName string,orgIDs []string,page int,conditions []string) (bool,string,[]DataEX.ESData) {
var list []DataEX.ESData
term2 := elastic.NewTermQuery("enable_flag", 1)
query:=elastic.NewBoolQuery()
query.Filter(term2)
if len(orgIDs)!=0{
//change by zhangjun 2020-07-01
//term := elastic.NewTermsQuery("org_id.keyword", string2interface(orgIDs)...)
term := elastic.NewTermsQuery("org_id", string2interface(orgIDs)...)
query.Filter(term)
}
if len(conditions)>0{
for no:=0;no< len(conditions);no++{
if strings.Contains(conditions[no],">="){
arr:=strings.Split(conditions[no],">=")
term3 := elastic.NewRangeQuery(strings.TrimSpace(arr[0])).Gte(strings.TrimSpace(arr[1]))
query.Filter(term3)
continue
}
if strings.Contains(conditions[no],"<="){
arr:=strings.Split(conditions[no],"<=")
term3 := elastic.NewRangeQuery(strings.TrimSpace(arr[0])).Lte(strings.TrimSpace(arr[1]))
query.Filter(term3)
continue
}
if strings.Contains(conditions[no],"="){
arr:=strings.Split(conditions[no],"=")
term3 := elastic.NewTermQuery(strings.TrimSpace(arr[0]) ,strings.TrimSpace(arr[1]))
query.Filter(term3)
continue
}
if strings.Contains(conditions[no],">"){
arr:=strings.Split(conditions[no],">")
term3 := elastic.NewRangeQuery(strings.TrimSpace(arr[0])).Gt(strings.TrimSpace(arr[1]))
query.Filter(term3)
continue
}
if strings.Contains(conditions[no],"<"){
arr:=strings.Split(conditions[no],"<")
term3 := elastic.NewRangeQuery(strings.TrimSpace(arr[0])).Lt(strings.TrimSpace(arr[1]))
query.Filter(term3)
continue
}
}
}
result,err:=ES7Client.Search().Index(indexName).Query(query).From(page * 100).Size(100).Sort("begin_time",true).Do(CTX)
if err == nil{
var ttyp DataEX.ESData
for _, item := range result.Each(reflect.TypeOf(ttyp)) {
data := item.(DataEX.ESData)
list=append(list,data)
}
return true,"获取数据成功", list
}else{
return false,"获取数据失败", list
}
}
func remove(array []string,del string)[]string {
var result []string
for no:=0;no< len(array);no++{
if array[no]!=del{
result=append(result,array[no])
}
}
return result
}
func IndexRefresh(indexName string){
ES7Client.Refresh(indexName).Do(CTX)
}
/**
* @Author zhangjun
* @Description terms query
* @Date 2020-06-17 16:10
* @Param
* @return
**/
func string2interface(arr []string) []interface{} {
var result []interface{}
for no:=0;no< len(arr);no++{
result=append(result,arr[no])
}
return result
}
func SearchDocPage(indexName string,orgIDs []string,page int,begin string, conditions map[string]interface{}, sort map[string]interface{}) (bool,string,[]DataEX.ESData) {
var list []DataEX.ESData
var field string
var ascending bool
term2 := elastic.NewTermQuery("enable_flag", 1)
query:=elastic.NewBoolQuery()
query.Filter(term2)
if len(orgIDs)!=0{
term := elastic.NewTermsQuery("org_id", string2interface(orgIDs)...)
query.Filter(term)
}
if begin!=""{
term3 := elastic.NewRangeQuery("begin_time").Gte(begin)
query.Filter(term3)
}
if conditions != nil {
for k, v := range conditions {
condition := elastic.NewTermsQuery(k, v)
query.Filter(condition)
}
}
if sort == nil {
field = "begin_time"
ascending = true
} else {
field = sort["field"].(string)
ascending = sort["ascending"].(bool)
}
result,err:=ES7Client.Search().Index(indexName).Query(query).From(page * 100).Size(100).Sort(field, ascending).Do(CTX)
if err == nil{
var ttyp DataEX.ESData
for _, item := range result.Each(reflect.TypeOf(ttyp)) {
data := item.(DataEX.ESData)
list=append(list,data)
}
return true,"获取数据成功", list
}else{
return false,"获取数据失败", list
}
}
/**
* @Author wangshuai
* @Description ES Mapping
* @Date 2020-07-31 17:07
* @Param indexName string ES
* @return map[string]interface mapping data_content
**/
func IndexDataContentMapping(indexName string) map[string]interface{} {
result,_:= ES7Client.GetMapping().Index(indexName).Do(CTX)
//fmt.Println(result["user_student"].(map[string]interface{})["mappings"].(map[string]interface{})["properties"].(map[string]interface{})["data_content"].(map[string]interface{})["properties"])
return result[indexName].(map[string]interface{})["mappings"].(map[string]interface{})["properties"].(map[string]interface{})["data_content"].(map[string]interface{})["properties"].(map[string]interface{})
}
func GetDocCount(indexName string) (int64, error) {
count, err := ES7Client.Count(indexName).Do(CTX)
if err != nil {
return count, nil
}else {
return count, err
}
}

@ -0,0 +1,8 @@
package MySwagger
type Auth struct {
SystemID string `json:"system_id" example:"SYS-200201" `
SystemToken string `json:"system_token" example:"a6ce11eab94df48a6ce11eab94df48e38f73cf7e38f73cf7"`
AuthTime string `json:"auth_time" example:"2020/01/02 03:04:05"`
}

@ -0,0 +1,9 @@
package MySwagger
type Data struct {
OrgID string `json:"org_id" example:"200201"`
DataID string `json:"data_id" example:"202008080008"`
Data string `json:"data" example:"{id:12300,name:zhangj,org_id:123001}"`
DelFlag int `json:"del_flag" example:"0"`
}

@ -0,0 +1,10 @@
package MySwagger
type DataCollect struct {
AccessToken string `json:"access_token" example:"system_01##20200102030405##a6ce11eab94df48a6ce11eab" `
DataSource string `json:"data_source" example:"log_login" `
UserDatas []User `json:"user_datas" `
EventDatas []Event `json:"event_datas" `
}

@ -0,0 +1,9 @@
package MySwagger
type DataGet struct {
SystemID string `json:"system_id" example:"SYS-200201"`
AuthToken string `json:"auth_token" example:"DATAEX-TOKEN-a6ce-11ea-b94df48e38f73cf7"`
DataSource string `json:"data_source" example:"org_school"`
OrgID string `json:"org_id" example:"-1"`
DataID string `json:"data_id" example:"202008080008"`
}

@ -0,0 +1,8 @@
package MySwagger
type DataGetResult struct {
Success bool `json:"success" example:"true"`
Datas []Data `json:"datas"`
Message string `json:"message" example:"操作成功"`
}

@ -0,0 +1,8 @@
package MySwagger
type DataIn struct {
SystemID string `json:"system_id" example:"SYS-200201" `
AuthToken string `json:"auth_token" example:"DATAEX-TOKEN-a6ce-11ea-b94df48e38f73cf7" `
DataSource string `json:"data_source" example:"ORG" `
Datas []Data `json:"datas" `
}

@ -0,0 +1,8 @@
package MySwagger
type DataInResult struct {
Success bool `json:"success" example:"true"`
SuccessIDs []string `json:"success_ids" example:"202008080008,202008080009,202008080010"`
FailResults []FailResult `json:"fail_results"`
Message string `json:"message" example:"操作成功"`
}

@ -0,0 +1,10 @@
package MySwagger
type DataPage struct {
SystemID string `json:"system_id" example:"SYS-200201"`
AuthToken string `json:"auth_token" example:"DATAEX-TOKEN-a6ce-11ea-b94df48e38f73cf7"`
DataSource string `json:"data_source" example:"org_school"`
OrgID string `json:"org_id" example:"-1"`
QueryTime string `json:"query_time" example:"2020/01/01 02:03:04"`
QueryPage int `json:"query_page" example:"0"`
}

@ -0,0 +1,10 @@
package MySwagger
type DataQuery struct {
SystemID string `json:"system_id" example:"SYS-200201"`
AuthToken string `json:"auth_token" example:"DATAEX-TOKEN-a6ce-11ea-b94df48e38f73cf7"`
DataSource string `json:"data_source" example:"org_school"`
OrgID string `json:"org_id" example:"-1"`
QueryConditions []string `json:"query_conditions" example:"subject_code=22"`
QueryPage int `json:"query_page" example:"0"`
}

@ -0,0 +1,13 @@
package MySwagger
type Event struct {
EventType string `json:"event_type" example:"1001"`
EventName string `json:"event_name" example:"在线提交作业"`
EventTime string `json:"event_time" example:"2020/08/08 18:19:20"`
EventURI string `json:"event_uri" example:"https://edusoa.com/cloud/study/do_homework"`
EventSeqNO string `json:"event_seqno" example:"事件顺序号1/2/3"`
EventUserID string `json:"event_userid" example:"用户ID"`
Properties string `json:"properties" example:"{res_id:12300,res_name:初一语文一单元作业,teacher_id:123001,time_spend:100s}"`
}

@ -0,0 +1,6 @@
package MySwagger
type FailResult struct {
FailID string `json:"fail_id" example:"202006060001"`
FailReason string `json:"fail_reason" example:"数据ORG_ID访问权限验证失败无法修改数据"`
}

@ -0,0 +1,6 @@
package MySwagger
type Result struct {
Success bool `json:"success" example:"false"`
Message string `json:"message" example:"接入系统票据验证失败"`
}

@ -0,0 +1,12 @@
package MySwagger
type User struct {
UserID string `json:"user_id" example:"用户ID"`
Identity string `json:"identity" example:"用户身份1教师2学生3家长4管理员5访客"`
AccessID string `json:"access_id" example:"访客ID用户未登录"`
AccessIP string `json:"access_ip" example:"10.10.8.88"`
AccessWay string `json:"access_way" example:"app/web/weixin/dingding"`
Properties string `json:"properties" example:"{group_id:12300,group_name:课外学习一组,user_level:2,login_time:2020/08/08 12:13:14}"`
}

@ -0,0 +1,11 @@
package ErrorConst
var
(
SqlQueryError = "SqlQueryError"
SqlUpdateError = "SqlUpdateError"
CreateRedisError = "CreateRedisError"
QueryRedisError = "QueryRedisError"
AnalyzeCookieError = "AnalyzeCookieError"
ConvertError = "ConvertError"
)
Loading…
Cancel
Save