Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
search_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
460cb341
authored
Jun 08, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
readme
parent
63e2112f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
0 deletions
conf/config.ini
pkg/es/es.go
readme.md
conf/config.ini
View file @
460cb341
...
...
@@ -8,6 +8,11 @@ api_md5_str = fh6y5t4rr351d2c3bryi
[goods]
api_url
=
http://192.168.2.232:60004
[es]
url
=
http://192.168.2.232:9200
urls
=
http://192.168.2.232:9200,http://192.168.2.232:9200
index_name
=
future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,peigenesis,powell,rs,buerklin
[database]
user_name
=
root
password
=
root
...
...
pkg/es/es.go
0 → 100644
View file @
460cb341
package
es
import
(
"github.com/imroc/req"
"search_server/pkg/config"
)
func
CurlEs
(
param
string
)
{
goodsServerUrl
:=
config
.
Get
(
"es.api_url"
)
.
String
()
params
:=
req
.
BodyJSON
(
param
)
resp
,
err
:=
req
.
Post
(
goodsServerUrl
+
"/synchronization"
,
params
)
if
err
!=
nil
{
return
}
return
resp
.
String
()
}
readme.md
View file @
460cb341
...
...
@@ -23,16 +23,21 @@
#### 1.配置读取
接在
```conf/config.ini```
文件添加自己的配置项
然后使用
```config.Get("xxx.xxx").String()```
或者
```config.Get("xxx.xxx").Int()```
即可
配置包的文档 : https://ini.unknwon.io/docs
#### 2.mysql连接实例
使用
```mysql.GetDB()```
即可获取对应的实例,不同数据库的连接可以自己定义不同的GetDB方法
gorm包的文档 : https://gorm.io/zh_CN/docs/index.html
#### 3.redis使用
可以直接调用
```gredis.Hset(),gredis.Hget()```
等方法,具体使用请参考代码,其中返回的结果是一个redis对象,需要自己转成自己需要的类型,比如 :
```redis.String(gredis.HGet("test",1))```
.
redis包文档 : https://pkg.go.dev/gopkg.in/DataDog/dd-trace-go.v1/contrib/garyburd/redigo?tab=doc
#### 4.mgo连接实例
使用
```mongo.GetDB()```
即可,不同数据库的连接可以自己定义不同的GetDB方法
然后用C方法指定集合进行操作即可:
```mongo.GetDB().C("xxx").Find(bson.M{}).Count()```
.
mgo包的文档 : https://godoc.org/gopkg.in/mgo.v2
文档2 : https://zhuanlan.zhihu.com/p/99731299
#### 5.钉钉群消息以及短信
直接在pkg/message包调用对应的函数即可:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment