Commit 35d91068 by huangchengyi

Merge branch 'hcy-2020.11.25-soucegine'

# Conflicts:
#	service/ly/sourceability.go
parents d9bd172e 7f202186
package controller
import (
"github.com/gin-gonic/gin"
"search_server/pkg/common"
"search_server/service/ly"
)
//搜索 sourcegine 型号,返回格式化后的原始数据
func GetSourceabilityData(ctx *gin.Context) {
goodsName := ctx.Request.FormValue("k") //关键词
common.PrintDebugHeader(ctx) //debug
if ctx.Request.FormValue("flag") == "1" {
ctx.String(200,`{"error_code":0,"err_msg":"","data":{"LM358AD-1438416474":{"goods_sn":"LM358AD-1438416474","goods_name":"LM358AD","brand_name":"STMICROELECTRONICS","desc":"Low input bias current","docurl":"","url":"","goods_img":"","cat":"","stock":[1613,19924],"increment":1,"price_temp":[[1613,0.13307],[10000,0.12621]],"tiered":[{"purchases":1613,"price_us":0.13307,"price_cn":0,"price_ac":0},{"purchases":10000,"price_us":0.12621,"price_cn":0,"price_ac":0}],"single_price":0.12621},"LM358MX-1840114430":{"goods_sn":"LM358MX-1840114430","goods_name":"LM358MX","brand_name":"Texas Instruments Incorporated","desc":"Operational Amplifier, 2 Func, 7000uV Offset-Max, BIPolar, PDSO8","docurl":"","url":"","goods_img":"","cat":"","stock":[782,2187],"increment":1,"price_temp":[[782,0.4928],[790,0.48752],[1600,0.47608]],"tiered":[{"purchases":782,"price_us":0.4928,"price_cn":0,"price_ac":0},{"purchases":790,"price_us":0.48752,"price_cn":0,"price_ac":0},{"purchases":1600,"price_us":0.47608,"price_cn":0,"price_ac":0}],"single_price":0.47608},"LM358H-1840114428":{"goods_sn":"LM358H-1840114428","goods_name":"LM358H","brand_name":"Texas Instruments Incorporated","desc":"Operational Amplifier, 2 Func, 9000uV Offset-Max, BIPolar, MBCY8","docurl":"","url":"","goods_img":"","cat":"","stock":[68,2736],"increment":1,"price_temp":[[68,5.7134],[70,5.65219],[140,5.51956],[340,5.40733],[680,5.3053]],"tiered":[{"purchases":68,"price_us":5.7134,"price_cn":0,"price_ac":0},{"purchases":70,"price_us":5.65219,"price_cn":0,"price_ac":0},{"purchases":140,"price_us":5.51956,"price_cn":0,"price_ac":0},{"purchases":340,"price_us":5.40733,"price_cn":0,"price_ac":0},{"purchases":680,"price_us":5.3053,"price_cn":0,"price_ac":0}],"single_price":5.3053},"LM358P-1503747557":{"goods_sn":"LM358P-1503747557","goods_name":"LM358P","brand_name":"Texas Instruments Incorporated","desc":"Operational Amplifier, 2 Func, 7000uV Offset-Max, BIPolar, PDIP8","docurl":"","url":"","goods_img":"","cat":"","stock":[709,1520],"increment":1,"price_temp":[[709,0.07768]],"tiered":[{"purchases":709,"price_us":0.07768,"price_cn":0,"price_ac":0}],"single_price":0.07768},"LM358ST-1932800621":{"goods_sn":"LM358ST-1932800621","goods_name":"LM358ST","brand_name":"STMICROELECTRONICS","desc":"Low-power dual op-amps with low input bias current","docurl":"","url":"","goods_img":"","cat":"","stock":[4000,20000],"increment":1,"price_temp":[[4000,0.09544],[8000,0.09471],[16000,0.09398]],"tiered":[{"purchases":4000,"price_us":0.09544,"price_cn":0,"price_ac":0},{"purchases":8000,"price_us":0.09471,"price_cn":0,"price_ac":0},{"purchases":16000,"price_us":0.09398,"price_cn":0,"price_ac":0}],"single_price":0.09398},"LM358DR-1503747545":{"goods_sn":"LM358DR-1503747545","goods_name":"LM358DR","brand_name":"Texas Instruments Incorporated","desc":"Operational Amplifier, 2 Func, 7000uV Offset-Max, BIPolar, PDSO8","docurl":"","url":"","goods_img":"","cat":"","stock":[1021,5190],"increment":1,"price_temp":[[1021,0.0539]],"tiered":[{"purchases":1021,"price_us":0.0539,"price_cn":0,"price_ac":0}],"single_price":0.0539}}}`)
return
}
if goodsName == "" {
common.Output(ctx,1001, "查询关键词不得为空", "")
return
}
//调外链拿数据
apiData := ly.OutLinkSource(ctx,&goodsName)
common.Output(ctx,0,"",apiData)
}
\ No newline at end of file
package controller
import (
"github.com/gin-gonic/gin"
"search_server/pkg/common"
"search_server/service/ly"
)
//搜索 sourcegine 型号,返回格式化后的原始数据
func GetSourcengineData(ctx *gin.Context) {
goodsName := ctx.Request.FormValue("k") //关键词
common.PrintDebugHeader(ctx) //debug
if goodsName == "" {
common.Output(ctx,1001, "查询关键词不得为空", "")
return
}
//调外链拿数据
apiData := ly.OutLinkSource(ctx,&goodsName)
common.Output(ctx,0,"",apiData)
}
\ No newline at end of file
package main
import (
"fmt"
"sort"
)
// 按map的key排序
func main() {
params := make(map[string]interface{})
params["name"] = "xxx"
params["age"] = 23
params["sex"] = 0
params["level"] = 1
// 1.取出所有的key
var keys []string
for k := range params{
keys = append(keys, k)
}
// 对字符串切片排序
sort.Strings(keys)
fmt.Println(keys)
// 打印key, val
for _, k := range keys{
fmt.Printf("key: %v val:%v \n", k, params[k])
}
}
package main
import (
"fmt"
"sync"
)
var wg sync.WaitGroup
func main() {
userCount := 1
ch := make(chan bool, 2)
for i := 0; i < userCount; i++ {
wg.Add(1)
//fmt.Println(i)
ch <- true
//fmt.Println("ddd")
go send(ch, i)
}
wg.Wait()
//time.Sleep(time.Second)
}
func send(ch chan bool, i int) {
defer wg.Done()
//time.Sleep(time.Second*i)
fmt.Println("dddd",i)
//fmt.Printf("go func: %d\n", i)
<- ch
}
......@@ -47,8 +47,8 @@ func InitRouter() *gin.Engine {
v4.GET("digikey/a", controller.GetDigikeyData)
v4.POST("tme/a", controller.GetTmeData)
v4.GET("tme/a", controller.GetTmeData)
v4.POST("sourcengine/raw", controller.GetSourcengineData)
v4.GET("sourcengine/raw", controller.GetSourcengineData)
v4.POST("sourceability/raw", controller.GetSourceabilityData)
v4.GET("sourceability/raw", controller.GetSourceabilityData)
}
//路由
......
......@@ -2,7 +2,7 @@
#!/bin/bash
cd /data/golang/search_server
git reset --hard HEAD
git pull origin master
git pull origin dev
filename="/data/golang/search_server/cmd/http/http"
rm -f $filename
export GO111MODULE=on
......
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