Commit 657403bc by huangchengyi

Merge branch 'dev' of http://119.23.72.7/mushishixian/search_server into dev

parents a71b2f30 b17148bf
...@@ -11,6 +11,7 @@ api_md5_str = fh6y5t4rr351d2c3bryi ...@@ -11,6 +11,7 @@ api_md5_str = fh6y5t4rr351d2c3bryi
[goods] [goods]
api_url = http://192.168.2.232:60004 api_url = http://192.168.2.232:60004
sz_api_url = http://192.168.2.232:60004
[es] [es]
url = http://192.168.2.232:9200 url = http://192.168.2.232:9200
...@@ -46,9 +47,9 @@ is_sz = true ...@@ -46,9 +47,9 @@ is_sz = true
#自营mongodb缓存表 正式线ziying_class_aggs #自营mongodb缓存表 正式线ziying_class_aggs
[AGG_TABLE] [AGG_TABLE]
agg_table = sz_ziying_class_aggs agg_table = ziying_class_aggs
#自营mongodb缓存表 正式线 ziying_first_lists #自营mongodb缓存表 正式线 ziying_first_lists
[FIRSTLISTS_TABLE] [FIRSTLISTS_TABLE]
firstLists_table = sz_ziying_first_lists firstLists_table = ziying_first_lists
\ No newline at end of file \ No newline at end of file
...@@ -10,6 +10,7 @@ api_md5_str = fh6y5t4rr351d2c3bryi ...@@ -10,6 +10,7 @@ api_md5_str = fh6y5t4rr351d2c3bryi
[goods] [goods]
api_url = http://47.106.60.211:60004 api_url = http://47.106.60.211:60004
sz_api_url = http://47.106.60.211:60004
[es] [es]
url = http://172.18.137.29:9211 url = http://172.18.137.29:9211
......
...@@ -24,9 +24,9 @@ type = mysql ...@@ -24,9 +24,9 @@ type = mysql
#线上地址 #线上地址
#mysql://dtuserread:dAtaL#ym2902m2lLX2y33@172.18.137.22:3306/icdata#utf8 #mysql://dtuserread:dAtaL#ym2902m2lLX2y33@172.18.137.22:3306/icdata#utf8
[cms] [cms]
user_name = dtuserread user_name = dtuser
password = `dAtaL#ym2902m2lLX2y33` password = `dAtaL#ym2902m2lLX2y33`
host = 172.18.137.22 host = appdb-master.ichunt.db
database = icdata database = icdata
table_prefix = table_prefix =
type = mysql type = mysql
...@@ -150,3 +150,7 @@ func GetData(keyword, supplierName string) (res interface{}) { ...@@ -150,3 +150,7 @@ func GetData(keyword, supplierName string) (res interface{}) {
res, _ = quoteService.GetData(keyword, supplierName) res, _ = quoteService.GetData(keyword, supplierName)
return return
} }
func QuoteTest(c *gin.Context) {
c.String(200, "测试")
}
...@@ -29,11 +29,56 @@ func Zyh(ctx *gin.Context){ ...@@ -29,11 +29,56 @@ func Zyh(ctx *gin.Context){
if err != nil{ if err != nil{
zyhResponse.ErrorCode = 1 zyhResponse.ErrorCode = 1
zyhResponse.ErrorMsg = fmt.Sprintf("%s",err) zyhResponse.ErrorMsg = fmt.Sprintf("%s",err)
ctx.JSON(200,zyhResponse) common.Output(int(zyhResponse.ErrorCode), zyhResponse.ErrorMsg, zyhResponse.Data)
} }
//fmt.Printf("%+v",zyhResponse) common.Output(int(zyhResponse.ErrorCode), zyhResponse.ErrorMsg, zyhResponse.Data)
ctx.JSON(200,zyhResponse) }
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){ func Index(ctx *gin.Context){
......
package model package model
//type ZyhRequest struct { import (
// Yo4tewUid string `form:"Yo4teW_uid"` "search_server/pkg/mysql"
// 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"`
//
//}
type ZhyClassListModel struct { type ZhyClassListModel struct {
ClassID1Name string `json:"class_id1_name"` ClassID1Name string `json:"class_id1_name"`
...@@ -47,3 +29,16 @@ type ZyhResponse struct { ...@@ -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
...@@ -34,5 +34,12 @@ func BuildDatabaseList() (DatabaseList map[string]BaseDatabase) { ...@@ -34,5 +34,12 @@ func BuildDatabaseList() (DatabaseList map[string]BaseDatabase) {
Database: Get("cms.database").String(), Database: Get("cms.database").String(),
Prefix: Get("cms.table_prefix").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(),
},
} }
} }
...@@ -19,6 +19,10 @@ func InitRouter() *gin.Engine { ...@@ -19,6 +19,10 @@ func InitRouter() *gin.Engine {
r.GET("search/ZiYing/zyh", controller.Zyh) r.GET("search/ZiYing/zyh", controller.Zyh)
r.GET("search/ZiYing/index", controller.Index) r.GET("search/ZiYing/index", controller.Index)
r.POST("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.POST("search/mouser/a", controller.GetMouserData)
r.GET("search/mouser/a", controller.GetMouserData) r.GET("search/mouser/a", controller.GetMouserData)
r.POST("search/digikey/a", controller.GetDigikeyData) r.POST("search/digikey/a", controller.GetDigikeyData)
...@@ -29,6 +33,7 @@ func InitRouter() *gin.Engine { ...@@ -29,6 +33,7 @@ func InitRouter() *gin.Engine {
r.POST("/search/bom/recommend", controller.Recommend) r.POST("/search/bom/recommend", controller.Recommend)
//快手平台相关 //快手平台相关
r.GET("/search/quote/test", controller.QuoteTest)
r.GET("/search/quote", controller.QuoteIndex) r.GET("/search/quote", controller.QuoteIndex)
r.POST("/search/quote", controller.QuoteIndex) r.POST("/search/quote", controller.QuoteIndex)
r.GET("/search/quote/getDataPur", controller.GetDataPur) r.GET("/search/quote/getDataPur", controller.GetDataPur)
......
#!/bin/bash #!/bin/bash
cd /data2/gocode/search_server cd /data/gocode/search_server
git pull origin dev git pull origin dev
cp /data2/gocode/search_server/config_prod.ini.demo /data2/gocode/search_server/config.ini cp /data/gocode/search_server/conf/prod/config.ini.prod /data/gocode/search_server/conf/config.ini
cp /data2/gocode/search_server/database_prod.ini.demo /data2/gocode/search_server/database.ini cp /data/gocode/search_server/conf/prod/database.ini.prod /data/gocode/search_server/conf/database.ini
cp /data2/gocode/search_server/message_prod.ini.demo /data2/gocode/search_server/message.ini cp /data/gocode/search_server/conf/prod/message.ini.prod /data/gocode/search_server/conf/message.ini
cp /data2/gocode/search_server/rabmq_key_prod.ini.demo /data2/gocode/search_server/rabmq_key.ini cp /data/gocode/search_server/conf/prod/rabmq_key.ini.prod /data/gocode/search_server/conf/rabmq_key.ini
cp /data2/gocode/search_server/redis_config_prod.ini.demo /data2/gocode/search_server/redis_config.ini cp /data/gocode/search_server/conf/prod/redis_config.ini.prod /data/gocode/search_server/conf/redis_config.ini
cp /data2/gocode/search_server/redis_key_prod.ini.demo /data2/gocode/search_server/redis_key.ini cp /data/gocode/search_server/conf/prod/redis_key.ini.prod /data/gocode/search_server/conf/redis_key.ini
cp /data2/gocode/search_server/search_prod.ini.demo /data2/gocode/search_server/search.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 go build -o ./cmd/search_http_server ./cmd/search_http_server.go
supervisorctl restart search_server supervisorctl restart search_server
...@@ -2,6 +2,7 @@ package service ...@@ -2,6 +2,7 @@ package service
import ( import (
"encoding/json" "encoding/json"
"fmt"
"github.com/imroc/req" "github.com/imroc/req"
"github.com/syyongx/php2go" "github.com/syyongx/php2go"
"github.com/tidwall/gjson" "github.com/tidwall/gjson"
...@@ -50,7 +51,9 @@ func (qs *QuoteService) GetGoodsBySupplierName(r requests.GetGoodsBySupplierRequ ...@@ -50,7 +51,9 @@ func (qs *QuoteService) GetGoodsBySupplierName(r requests.GetGoodsBySupplierRequ
if err != nil { if err != nil {
return return
} }
fmt.Println(esResult)
goodsIds := GetGoodsIdsByEs(esResult) goodsIds := GetGoodsIdsByEs(esResult)
fmt.Println(goodsIds)
goodsList, err := GetGoodsInfo(goodsIds) goodsList, err := GetGoodsInfo(goodsIds)
dullData, err := transformer.DullDataInfo(r.Keyword, goodsList) dullData, err := transformer.DullDataInfo(r.Keyword, goodsList)
quoteTransformer := transformer.QuoteTransformer{} quoteTransformer := transformer.QuoteTransformer{}
......
...@@ -7,7 +7,7 @@ import ( ...@@ -7,7 +7,7 @@ import (
"github.com/syyongx/php2go" "github.com/syyongx/php2go"
"reflect" "reflect"
"search_server/boot" "search_server/boot"
"search_server/pkg/common" "search_server/service"
) )
func StrRandom(lenNum int) string { func StrRandom(lenNum int) string {
...@@ -39,18 +39,8 @@ func main() { ...@@ -39,18 +39,8 @@ func main() {
if err := boot.Boot(path); err != nil { if err := boot.Boot(path); err != nil {
fmt.Println(err) fmt.Println(err)
} }
//log.SetFormatter(new(LogFormatter)) res, _ := service.GetGoodsInfo([]string{"74163","116492","74123","106095","116451","162774","74152","116078","74122","74132"})
////设置output,默认为stderr,可以为任何io.Writer,比如文件*os.File fmt.Println(len(res))
//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")
} }
......
...@@ -2,13 +2,16 @@ package main ...@@ -2,13 +2,16 @@ package main
import ( import (
"bytes" "bytes"
"fmt"
"io" "io"
) )
const debug = false const debug = false
func main() { func main() {
var buf *bytes.Buffer //var buf *bytes.Buffer
var buf io.Writer
fmt.Printf("%T \n",buf)
if debug { if debug {
buf = new(bytes.Buffer) // enable collection of output buf = new(bytes.Buffer) // enable collection of output
} }
...@@ -21,7 +24,18 @@ func main() { ...@@ -21,7 +24,18 @@ func main() {
// If out is non-nil, output will be written to it. // If out is non-nil, output will be written to it.
func f(out io.Writer) { func f(out io.Writer) {
// ...do something... // ...do something...
fmt.Println(out)
fmt.Printf("%T \n",out)
if out != nil { if out != nil {
fmt.Println("!!!!!!!!!!")
out.Write([]byte("done!\n")) 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment