From 2c9e1cdb912b3dc31304b1cc0b0b9e34b2aaa898 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Sat, 11 May 2024 10:22:32 +0800 Subject: [PATCH] by Robin at 20240511 --- app/mix/dao/elasticsearch.go | 4 ++ app/mix/service/apiservice.go | 46 ------------------- .../client.go | 8 ++-- 3 files changed, 7 insertions(+), 51 deletions(-) create mode 100644 app/mix/dao/elasticsearch.go rename library/{elastic_search => elasticsearchdb}/client.go (66%) diff --git a/app/mix/dao/elasticsearch.go b/app/mix/dao/elasticsearch.go new file mode 100644 index 00000000..59e6464d --- /dev/null +++ b/app/mix/dao/elasticsearch.go @@ -0,0 +1,4 @@ +package dao + +type ElasticSearch struct { +} diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index c9e10bca..d3cb28c2 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -443,52 +443,6 @@ func (s *Service) ApiGetAccountListByUserId(ctx *gin.Context, req *accountproto. return } -// func (s *Service) ApiGetAccountListFuzzilyByUserId(ctx *gin.Context, req *accountproto.ApiListFuzzilyByUserIdReq) (volist []*accountproto.ApiListVO, ec errcode.ErrCode) { -// ec = errcode.ErrCodeAccountSrvOk -// list, err := _DefaultAccount.OpListFuzzilyByUserId(ctx, &accountproto.OpListFuzzilyByUserIdReq{ -// UserId: req.UserId, -// Role: req.Role, -// Offset: req.Offset, -// Limit: req.Limit, -// Sort: req.Sort, -// }) -// if err != nil { -// logger.Error("OpListFuzzilyByUserId fail, err: %v", err) -// ec = errcode.ErrCodeAccountSrvFail -// return -// } - -// volist = make([]*accountproto.ApiListVO, len(list)) -// for i, account := range list { -// volist[i] = &accountproto.ApiListVO{} -// volist[i].CopyAccount(account) -// } -// return -// } - -// func (s *Service) ApiGetAccountListFuzzilyByName(ctx *gin.Context, req *accountproto.ApiListFuzzilyByNameReq) (volist []*accountproto.ApiListVO, ec errcode.ErrCode) { -// ec = errcode.ErrCodeAccountSrvOk -// list, err := _DefaultAccount.OpListFuzzilyByName(ctx, &accountproto.OpListFuzzilyByNameReq{ -// Name: req.Name, -// Role: req.Role, -// Offset: req.Offset, -// Limit: req.Limit, -// Sort: req.Sort, -// }) -// if err != nil { -// logger.Error("OpListFuzzilyByName fail, err: %v", err) -// ec = errcode.ErrCodeAccountSrvFail -// return -// } - -// volist = make([]*accountproto.ApiListVO, len(list)) -// for i, account := range list { -// volist[i] = &accountproto.ApiListVO{} -// volist[i].CopyAccount(account) -// } -// return -// } - func (s *Service) ApiGetAccountListForOthersByMid(ctx *gin.Context, req *accountproto.ApiListOthersByMidReq) (vo *accountproto.ApiListOthersVO, ec errcode.ErrCode) { ec = errcode.ErrCodeAccountSrvOk account, err := _DefaultAccount.OpListByMid(ctx, &accountproto.OpListByMidReq{ diff --git a/library/elastic_search/client.go b/library/elasticsearchdb/client.go similarity index 66% rename from library/elastic_search/client.go rename to library/elasticsearchdb/client.go index f0eaaf86..f93f850b 100644 --- a/library/elastic_search/client.go +++ b/library/elasticsearchdb/client.go @@ -1,4 +1,4 @@ -package elasticsearch +package elasticsearchdb import ( "service/bizcommon/util" @@ -8,10 +8,8 @@ import ( "github.com/olivere/elastic/v7" ) -var defaultElasticSearchClient *elastic.Client - -func Init(cfg *configcenter.ElasticSearchConfig) (err error) { - defaultElasticSearchClient, err = elastic.NewClient( +func Init(cfg *configcenter.ElasticSearchConfig) (client *elastic.Client, err error) { + client, err = elastic.NewClient( elastic.SetURL(cfg.Uri), elastic.SetSniff(cfg.Sniff), elastic.SetBasicAuth(cfg.Username, cfg.Password),