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
38bd01b0
authored
Jul 23, 2020
by
孙龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
up
parent
5f5216e7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
241 additions
and
25 deletions
controller/ziyin_controller.go
model/goods.go
pkg/common/page.go
routes/router.go
service/ziyin_service.go
test/test7.go
controller/ziyin_controller.go
View file @
38bd01b0
...
...
@@ -18,7 +18,7 @@ func Zyh(ctx *gin.Context){
zyhRequest
[
requestName
]
=
strings
.
TrimSpace
(
requstValue
[
0
])
}
}
fmt
.
Println
(
zyhRequest
)
//
fmt.Println(zyhRequest)
zyServiceImpl
:=
service
.
NewZyServiceImpl
()
...
...
model/goods.go
View file @
38bd01b0
...
...
@@ -72,6 +72,11 @@ type ApiGoods struct {
type
ZiyinGoodsInfo
struct
{
GoodsNameOrg
string
`json:"goods_name_org"`
SampleStatus
string
`json:"sample_status"`
SampleMaxNumber
string
`json:"sample_max_number"`
SampleClassId
string
`json:"sample_class_id"`
SampleClassIdName
string
`json:"sample_class_id_name"`
Quota
int
`json:"quota"`
DullGoodsData
}
...
...
pkg/common/page.go
0 → 100644
View file @
38bd01b0
package
common
import
"math"
//分页方法,根据传递过来的页数,每页数,总数,返回分页的内容 7个页数 前 1,2,3,4,5 后 的格式返回,小于5页返回具体页数
func
Paginator
(
page
,
prepage
int
,
nums
int64
)
map
[
string
]
interface
{}
{
var
firstpage
int
//前一页地址
var
lastpage
int
//后一页地址
//根据nums总数,和prepage每页数量 生成分页总数
totalpages
:=
int
(
math
.
Ceil
(
float64
(
nums
)
/
float64
(
prepage
)))
//page总数
if
page
>
totalpages
{
page
=
totalpages
}
if
page
<=
0
{
page
=
1
}
var
pages
[]
int
switch
{
case
page
>=
totalpages
-
5
&&
totalpages
>
5
:
//最后5页
start
:=
totalpages
-
5
+
1
firstpage
=
page
-
1
lastpage
=
int
(
math
.
Min
(
float64
(
totalpages
),
float64
(
page
+
1
)))
pages
=
make
([]
int
,
5
)
for
i
,
_
:=
range
pages
{
pages
[
i
]
=
start
+
i
}
case
page
>=
3
&&
totalpages
>
5
:
start
:=
page
-
3
+
1
pages
=
make
([]
int
,
5
)
firstpage
=
page
-
3
for
i
,
_
:=
range
pages
{
pages
[
i
]
=
start
+
i
}
firstpage
=
page
-
1
lastpage
=
page
+
1
default
:
pages
=
make
([]
int
,
int
(
math
.
Min
(
5
,
float64
(
totalpages
))))
for
i
,
_
:=
range
pages
{
pages
[
i
]
=
i
+
1
}
firstpage
=
int
(
math
.
Max
(
float64
(
1
),
float64
(
page
-
1
)))
lastpage
=
page
+
1
//fmt.Println(pages)
}
paginatorMap
:=
make
(
map
[
string
]
interface
{})
paginatorMap
[
"pages"
]
=
pages
paginatorMap
[
"totalpages"
]
=
totalpages
paginatorMap
[
"firstpage"
]
=
firstpage
paginatorMap
[
"lastpage"
]
=
lastpage
paginatorMap
[
"currpage"
]
=
page
return
paginatorMap
}
\ No newline at end of file
routes/router.go
View file @
38bd01b0
...
...
@@ -20,6 +20,7 @@ func InitRouter() *gin.Engine {
r
.
POST
(
"/search/bom/autospu"
,
controller
.
AutoSpu
)
r
.
POST
(
"/search/bom/recommend"
,
controller
.
Recommend
)
r
.
POST
(
"search/ZiYing/zyh"
,
controller
.
Zyh
)
r
.
GET
(
"search/ZiYing/zyh"
,
controller
.
Zyh
)
r
.
POST
(
"search/mouser/GetMouserData"
,
controller
.
GetMouserData
)
r
.
GET
(
"search/mouser/GetMouserData"
,
controller
.
GetMouserData
)
...
...
service/ziyin_service.go
View file @
38bd01b0
This diff is collapsed.
Click to expand it.
test/test7.go
0 → 100644
View file @
38bd01b0
package
main
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