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
657403bc
authored
Aug 03, 2020
by
huangchengyi
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'dev' of
http://119.23.72.7/mushishixian/search_server
into dev
parents
a71b2f30
b17148bf
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
330 additions
and
74 deletions
conf/local/config.ini.local
conf/prod/config.ini.prod
conf/prod/database.ini.prod
controller/quote_controller.go
controller/ziyin_controller.go
model/ziyin.go
pkg/config/mysql.go
routes/router.go
search_server.bash
service/quote_service.go
service/ziyin_service.go
test/test.go
test/test7.go
conf/local/config.ini.local
View file @
657403bc
...
...
@@ -11,6 +11,7 @@ api_md5_str = fh6y5t4rr351d2c3bryi
[goods]
api_url = http://192.168.2.232:60004
sz_api_url = http://192.168.2.232:60004
[es]
url = http://192.168.2.232:9200
...
...
@@ -46,9 +47,9 @@ is_sz = true
#自营mongodb缓存表 正式线ziying_class_aggs
[AGG_TABLE]
agg_table =
sz_
ziying_class_aggs
agg_table = ziying_class_aggs
#自营mongodb缓存表 正式线 ziying_first_lists
[FIRSTLISTS_TABLE]
firstLists_table = sz_ziying_first_lists
\ No newline at end of file
firstLists_table = ziying_first_lists
\ No newline at end of file
conf/prod/config.ini.prod
View file @
657403bc
...
...
@@ -10,6 +10,7 @@ api_md5_str = fh6y5t4rr351d2c3bryi
[goods]
api_url = http://47.106.60.211:60004
sz_api_url = http://47.106.60.211:60004
[es]
url = http://172.18.137.29:9211
...
...
conf/prod/database.ini.prod
View file @
657403bc
...
...
@@ -24,9 +24,9 @@ type = mysql
#线上地址
#mysql://dtuserread:dAtaL#ym2902m2lLX2y33@172.18.137.22:3306/icdata#utf8
[cms]
user_name = dtuser
read
user_name = dtuser
password = `dAtaL#ym2902m2lLX2y33`
host =
172.18.137.22
host =
appdb-master.ichunt.db
database = icdata
table_prefix =
type = mysql
controller/quote_controller.go
View file @
657403bc
...
...
@@ -150,3 +150,7 @@ func GetData(keyword, supplierName string) (res interface{}) {
res
,
_
=
quoteService
.
GetData
(
keyword
,
supplierName
)
return
}
func
QuoteTest
(
c
*
gin
.
Context
)
{
c
.
String
(
200
,
"测试"
)
}
controller/ziyin_controller.go
View file @
657403bc
...
...
@@ -29,11 +29,56 @@ func Zyh(ctx *gin.Context){
if
err
!=
nil
{
zyhResponse
.
ErrorCode
=
1
zyhResponse
.
ErrorMsg
=
fmt
.
Sprintf
(
"%s"
,
err
)
c
tx
.
JSON
(
200
,
zyhResponse
)
c
ommon
.
Output
(
int
(
zyhResponse
.
ErrorCode
),
zyhResponse
.
ErrorMsg
,
zyhResponse
.
Data
)
}
//fmt.Printf("%+v",zyhResponse)
ctx
.
JSON
(
200
,
zyhResponse
)
common
.
Output
(
int
(
zyhResponse
.
ErrorCode
),
zyhResponse
.
ErrorMsg
,
zyhResponse
.
Data
)
}
func
Aggs
(
ctx
*
gin
.
Context
){
zyhRequest
:=
make
(
map
[
string
]
string
,
0
);
ctx
.
MultipartForm
()
for
requestName
,
requstValue
:=
range
ctx
.
Request
.
Form
{
if
requstValue
[
0
]
!=
""
{
zyhRequest
[
requestName
]
=
strings
.
TrimSpace
(
requstValue
[
0
])
}
}
//fmt.Println(zyhRequest)
zyServiceImpl
:=
service
.
NewZyServiceImpl
()
zyhResponse
:=
&
model
.
ZyhResponse
{}
zyhResponse
,
err
:=
zyServiceImpl
.
Aggs
(
ctx
,
zyhRequest
)
if
err
!=
nil
{
zyhResponse
.
ErrorCode
=
1
zyhResponse
.
ErrorMsg
=
fmt
.
Sprintf
(
"%s"
,
err
)
common
.
Output
(
int
(
zyhResponse
.
ErrorCode
),
zyhResponse
.
ErrorMsg
,
zyhResponse
.
Data
)
}
common
.
Output
(
int
(
zyhResponse
.
ErrorCode
),
zyhResponse
.
ErrorMsg
,
zyhResponse
.
Data
)
}
//统计样片一级分类总条数
func
AggSample
(
ctx
*
gin
.
Context
){
zyhRequest
:=
make
(
map
[
string
]
string
,
0
);
ctx
.
MultipartForm
()
for
requestName
,
requstValue
:=
range
ctx
.
Request
.
Form
{
if
requstValue
[
0
]
!=
""
{
zyhRequest
[
requestName
]
=
strings
.
TrimSpace
(
requstValue
[
0
])
}
}
//fmt.Println(zyhRequest)
zyServiceImpl
:=
service
.
NewZyServiceImpl
()
zyhResponse
:=
&
model
.
ZyhResponse
{}
zyhResponse
=
zyServiceImpl
.
AggSample
(
ctx
,
zyhRequest
)
common
.
Output
(
int
(
zyhResponse
.
ErrorCode
),
zyhResponse
.
ErrorMsg
,
zyhResponse
.
Data
)
}
func
Index
(
ctx
*
gin
.
Context
){
...
...
model/ziyin.go
View file @
657403bc
package
model
//type ZyhRequest struct {
// Yo4tewUid string `form:"Yo4teW_uid"`
// ClassIdcondition int64 `form:"class_id/condition"`
// ClassId2condition int64 `form:"class_id2/condition"`
// Brand_idCondition string `form:"brand_id/condition"`
// StockRank string `form:"stock_rank"` //库存排序
// AvailRank string `form:"avail_rank"` //显示有货的
// ComRank string `form:"com_rank"` //综合排序
// SingleRank string `form:"single_rank"` //价格排序
// PackingCondition string `form:"packing/condition"`
// EncapCondition string `form:"encap/condition"`
// P int `form:"p"`
// NeedAggs string `form:"need_aggs"`
// GoodsNameCondition string `form:"goods_name/condition"`
//
//}
import
(
"search_server/pkg/mysql"
)
type
ZhyClassListModel
struct
{
ClassID1Name
string
`json:"class_id1_name"`
...
...
@@ -47,3 +29,16 @@ type ZyhResponse struct {
}
type
LieXinData
struct
{
Id
int
`json:"id" xorm:"id"`
Sort
int
`json:"sort" xorm:"sort"`
}
func
GetSampleClass
()
(
sample_class_data
[]
LieXinData
)
{
sample_class_data
=
make
([]
LieXinData
,
0
)
spuMsql
:=
mysql
.
Conn
(
"liexin_data"
)
sql
:=
"select id,sort from lie_sample_class where status = 1 order by sort asc "
_
=
spuMsql
.
SQL
(
sql
)
.
Find
(
&
sample_class_data
)
return
}
\ No newline at end of file
pkg/config/mysql.go
View file @
657403bc
...
...
@@ -34,5 +34,12 @@ func BuildDatabaseList() (DatabaseList map[string]BaseDatabase) {
Database
:
Get
(
"cms.database"
)
.
String
(),
Prefix
:
Get
(
"cms.table_prefix"
)
.
String
(),
},
"liexin_data"
:
{
UserName
:
Get
(
"liexin_data.user_name"
)
.
String
(),
Password
:
Get
(
"liexin_data.password"
)
.
String
(),
Host
:
Get
(
"liexin_data.host"
)
.
String
(),
Database
:
Get
(
"liexin_data.database"
)
.
String
(),
Prefix
:
Get
(
"liexin_data.table_prefix"
)
.
String
(),
},
}
}
routes/router.go
View file @
657403bc
...
...
@@ -19,6 +19,10 @@ func InitRouter() *gin.Engine {
r
.
GET
(
"search/ZiYing/zyh"
,
controller
.
Zyh
)
r
.
GET
(
"search/ZiYing/index"
,
controller
.
Index
)
r
.
POST
(
"search/ZiYing/index"
,
controller
.
Index
)
r
.
GET
(
"search/ZiYing/aggs"
,
controller
.
Aggs
)
r
.
POST
(
"search/ZiYing/aggs"
,
controller
.
Aggs
)
r
.
GET
(
"search/ZiYing/aggSample"
,
controller
.
AggSample
)
r
.
POST
(
"search/ZiYing/aggSample"
,
controller
.
AggSample
)
r
.
POST
(
"search/mouser/a"
,
controller
.
GetMouserData
)
r
.
GET
(
"search/mouser/a"
,
controller
.
GetMouserData
)
r
.
POST
(
"search/digikey/a"
,
controller
.
GetDigikeyData
)
...
...
@@ -29,6 +33,7 @@ func InitRouter() *gin.Engine {
r
.
POST
(
"/search/bom/recommend"
,
controller
.
Recommend
)
//快手平台相关
r
.
GET
(
"/search/quote/test"
,
controller
.
QuoteTest
)
r
.
GET
(
"/search/quote"
,
controller
.
QuoteIndex
)
r
.
POST
(
"/search/quote"
,
controller
.
QuoteIndex
)
r
.
GET
(
"/search/quote/getDataPur"
,
controller
.
GetDataPur
)
...
...
search_server.bash
View file @
657403bc
#!/bin/bash
cd
/data
2
/gocode/search_server
cd
/data/gocode/search_server
git pull origin dev
cp /data
2/gocode/search_server/config_prod.ini.demo /data2/gocode/search_server
/config.ini
cp /data
2/gocode/search_server/database_prod.ini.demo /data2/gocode/search_server
/database.ini
cp /data
2/gocode/search_server/message_prod.ini.demo /data2/gocode/search_server
/message.ini
cp /data
2/gocode/search_server/rabmq_key_prod.ini.demo /data2/gocode/search_server
/rabmq_key.ini
cp /data
2/gocode/search_server/redis_config_prod.ini.demo /data2/gocode/search_server
/redis_config.ini
cp /data
2/gocode/search_server/redis_key_prod.ini.demo /data2/gocode/search_server
/redis_key.ini
cp /data
2/gocode/search_server/search_prod.ini.demo /data2/gocode/search_server
/search.ini
cp /data
/gocode/search_server/conf/prod/config.ini.prod /data/gocode/search_server/conf
/config.ini
cp /data
/gocode/search_server/conf/prod/database.ini.prod /data/gocode/search_server/conf
/database.ini
cp /data
/gocode/search_server/conf/prod/message.ini.prod /data/gocode/search_server/conf
/message.ini
cp /data
/gocode/search_server/conf/prod/rabmq_key.ini.prod /data/gocode/search_server/conf
/rabmq_key.ini
cp /data
/gocode/search_server/conf/prod/redis_config.ini.prod /data/gocode/search_server/conf
/redis_config.ini
cp /data
/gocode/search_server/conf/prod/redis_key.ini.prod /data/gocode/search_server/conf
/redis_key.ini
cp /data
/gocode/search_server/conf/prod/search.ini.prod /data/gocode/search_server/conf
/search.ini
go build
-o
./cmd/search_http_server ./cmd/search_http_server.go
supervisorctl restart search_server
service/quote_service.go
View file @
657403bc
...
...
@@ -2,6 +2,7 @@ package service
import
(
"encoding/json"
"fmt"
"github.com/imroc/req"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
...
...
@@ -50,7 +51,9 @@ func (qs *QuoteService) GetGoodsBySupplierName(r requests.GetGoodsBySupplierRequ
if
err
!=
nil
{
return
}
fmt
.
Println
(
esResult
)
goodsIds
:=
GetGoodsIdsByEs
(
esResult
)
fmt
.
Println
(
goodsIds
)
goodsList
,
err
:=
GetGoodsInfo
(
goodsIds
)
dullData
,
err
:=
transformer
.
DullDataInfo
(
r
.
Keyword
,
goodsList
)
quoteTransformer
:=
transformer
.
QuoteTransformer
{}
...
...
service/ziyin_service.go
View file @
657403bc
This diff is collapsed.
Click to expand it.
test/test.go
View file @
657403bc
...
...
@@ -7,7 +7,7 @@ import (
"github.com/syyongx/php2go"
"reflect"
"search_server/boot"
"search_server/
pkg/common
"
"search_server/
service
"
)
func
StrRandom
(
lenNum
int
)
string
{
...
...
@@ -39,18 +39,8 @@ func main() {
if
err
:=
boot
.
Boot
(
path
);
err
!=
nil
{
fmt
.
Println
(
err
)
}
//log.SetFormatter(new(LogFormatter))
////设置output,默认为stderr,可以为任何io.Writer,比如文件*os.File
//str, _ := os.Getwd()
//file, _ := os.OpenFile(str+"/logs/search/1.log", os.O_CREATE|os.O_WRONLY, 0666)
//log.SetOutput(file)
//fmt.Println(str)
//log.Error("sadsadsadsa")
//log.Error("sadsadsadsa")
//log_report.WriteSearchErrorLog("sdasdasdas")
common
.
Output
(
1000
,
"ceshiceshi"
,
nil
)
//log.Error("sadsadsadsa")
//controller.GetData("LM358","arrow")
res
,
_
:=
service
.
GetGoodsInfo
([]
string
{
"74163"
,
"116492"
,
"74123"
,
"106095"
,
"116451"
,
"162774"
,
"74152"
,
"116078"
,
"74122"
,
"74132"
})
fmt
.
Println
(
len
(
res
))
}
...
...
test/test7.go
View file @
657403bc
...
...
@@ -2,13 +2,16 @@ package main
import
(
"bytes"
"fmt"
"io"
)
const
debug
=
false
func
main
()
{
var
buf
*
bytes
.
Buffer
//var buf *bytes.Buffer
var
buf
io
.
Writer
fmt
.
Printf
(
"%T
\n
"
,
buf
)
if
debug
{
buf
=
new
(
bytes
.
Buffer
)
// enable collection of output
}
...
...
@@ -21,7 +24,18 @@ func main() {
// If out is non-nil, output will be written to it.
func
f
(
out
io
.
Writer
)
{
// ...do something...
fmt
.
Println
(
out
)
fmt
.
Printf
(
"%T
\n
"
,
out
)
if
out
!=
nil
{
fmt
.
Println
(
"!!!!!!!!!!"
)
out
.
Write
([]
byte
(
"done!
\n
"
))
}
var
a
interface
{}
a
=
map
[
string
]
string
{
"a"
:
"b"
,
}
a
=
nil
b
,
_
:=
a
.
(
map
[
string
]
string
)
fmt
.
Println
(
b
)
}
\ No newline at end of file
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