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
cfd95623
authored
Jul 03, 2020
by
孙龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
up
parent
df8c2603
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
124 additions
and
2 deletions
.gitignore
bat/searchHttp.bat
controller/ziyin_controller.go
go.mod
model/ziyin.go
routes/router.go
service/ziyin_service.go
.gitignore
View file @
cfd95623
...
@@ -8,3 +8,4 @@ cmd.exe~
...
@@ -8,3 +8,4 @@ cmd.exe~
/cmd/logs/
/cmd/logs/
/cmd/*.exe~
/cmd/*.exe~
/cmd/logs
/cmd/logs
/bat/logs/
bat/searchHttp.bat
View file @
cfd95623
set MICRO_REGISTRY=etcd
#
set MICRO_REGISTRY=etcd
set MICRO_REGISTRY_ADDRESS=192.168.2.232:2379
#
set MICRO_REGISTRY_ADDRESS=192.168.2.232:2379
go run ../cmd/search_http_server.go -config=../conf/config.ini
go run ../cmd/search_http_server.go -config=../conf/config.ini
\ No newline at end of file
controller/ziyin_controller.go
0 → 100644
View file @
cfd95623
package
controller
import
(
"github.com/gin-gonic/gin"
"net/http"
"search_server/model"
"search_server/service"
)
func
Zyh
(
ctx
*
gin
.
Context
){
zyServiceImpl
:=
service
.
NewZyServiceImpl
()
zyhRequest
:=
&
model
.
ZyhRequest
{}
zyhResponse
:=
&
model
.
ZyhResponse
{}
if
err
:=
ctx
.
ShouldBind
(
zyhRequest
);
err
!=
nil
{
ctx
.
JSON
(
http
.
StatusBadRequest
,
gin
.
H
{
"error"
:
err
.
Error
()})
return
}
err
:=
zyServiceImpl
.
Zyh
(
ctx
,
zyhRequest
,
zyhResponse
)
if
err
!=
nil
{
}
}
go.mod
View file @
cfd95623
...
@@ -27,11 +27,13 @@ require (
...
@@ -27,11 +27,13 @@ require (
github.com/prometheus/client_golang v1.5.1 // indirect
github.com/prometheus/client_golang v1.5.1 // indirect
github.com/prometheus/common v0.10.0
github.com/prometheus/common v0.10.0
github.com/prometheus/procfs v0.0.11 // indirect
github.com/prometheus/procfs v0.0.11 // indirect
github.com/silenceper/gowatch v0.0.0-20200624073703-8e473a9db258 // indirect
github.com/sirupsen/logrus v1.5.0 // indirect
github.com/sirupsen/logrus v1.5.0 // indirect
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/stretchr/testify v1.5.1 // indirect
github.com/stretchr/testify v1.5.1 // indirect
github.com/syyongx/php2go v0.9.4
github.com/syyongx/php2go v0.9.4
github.com/tidwall/gjson v1.6.0
github.com/tidwall/gjson v1.6.0
github.com/urfave/cli v1.22.4 // indirect
go.uber.org/zap v1.14.1 // indirect
go.uber.org/zap v1.14.1 // indirect
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 // indirect
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 // indirect
golang.org/x/sys v0.0.0-20200523222454-059865788121 // indirect
golang.org/x/sys v0.0.0-20200523222454-059865788121 // indirect
...
...
model/ziyin.go
0 → 100644
View file @
cfd95623
package
model
type
ZyhRequest
struct
{
Yo4tewUid
string
`form:"Yo4teW_uid"`
ClassIdcondition
int64
`form:"class_id/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
string
`form:"p"`
NeedAggs
string
`form:"need_aggs"`
}
type
ZyhResponse
struct
{
error_code
int64
`json:"error_code"`
error_msg
string
`json:"error_msg"`
data
interface
{}
}
\ No newline at end of file
routes/router.go
View file @
cfd95623
...
@@ -14,6 +14,7 @@ func InitRouter() *gin.Engine {
...
@@ -14,6 +14,7 @@ func InitRouter() *gin.Engine {
//路由
//路由
r
.
POST
(
"/search/bom/autospu"
,
controller
.
AutoSpu
)
r
.
POST
(
"/search/bom/autospu"
,
controller
.
AutoSpu
)
r
.
POST
(
"/search/bom/recommend"
,
controller
.
Recommend
)
r
.
POST
(
"/search/bom/recommend"
,
controller
.
Recommend
)
r
.
POST
(
"search/ZiYing/zyh"
,
controller
.
Zyh
)
return
r
return
r
}
}
service/ziyin_service.go
0 → 100644
View file @
cfd95623
package
service
import
(
"fmt"
"github.com/gin-gonic/gin"
"reflect"
"search_server/model"
"search_server/pkg/config"
)
type
ZyServiceImpl
struct
{}
/*
自营搜索
*/
func
(
this
*
ZyServiceImpl
)
Zyh
(
ctx
*
gin
.
Context
,
req
*
model
.
ZyhRequest
,
rsp
*
model
.
ZyhResponse
)
error
{
//fmt.Printf("%+v",req)
fmt
.
Println
(
req
.
NeedAggs
)
fmt
.
Println
(
5566
)
var
(
need_aggs
bool
_type
byte
)
if
req
.
NeedAggs
!=
""
{
need_aggs
=
false
}
else
{
need_aggs
=
true
}
need_aggs
=
need_aggs
if
need_aggs
{
_type
=
1
}
else
{
_type
=
1
}
//设置cookie
setCookie
(
ctx
,
req
)
rsp
=
zy
(
ctx
,
req
,
_type
,
0
)
return
nil
}
func
NewZyServiceImpl
()
*
ZyServiceImpl
{
return
&
ZyServiceImpl
{}
}
func
setCookie
(
ctx
*
gin
.
Context
,
req
*
model
.
ZyhRequest
)
error
{
//接收用户id
if
req
.
Yo4tewUid
!=
""
&&
req
.
Yo4tewUid
!=
"false"
{
domain
:=
config
.
Get
(
"web.domain"
)
.
String
()
ctx
.
SetCookie
(
"Yo4teW_uid"
,
req
.
Yo4tewUid
,
3600
,
"/"
,
domain
,
false
,
true
)
}
return
nil
}
//自营筛选接口数据输出
//@param _type 1:输出所有(属性统计+分类+数据详情),2 只输出属性(属性统计)
func
zy
(
ctx
*
gin
.
Context
,
req
*
model
.
ZyhRequest
,
_type
byte
,
isCheck
byte
)
(
rsp
*
model
.
ZyhResponse
){
fmt
.
Printf
(
"%+v"
,
req
)
fmt
.
Println
(
reflect
.
TypeOf
(
req
.
ClassIdcondition
))
fmt
.
Println
(
req
.
ClassIdcondition
)
return
nil
}
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