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
21d37cdf
authored
Jul 02, 2020
by
huangchengyi
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1.0
parent
cf0e9eb5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
101 additions
and
22 deletions
model/ly.go
test/test2.go
test/test3.go
model/ly.go
View file @
21d37cdf
package
model
//联营请求外链后格式化数据
type
LyClearData
struct
{
GoodsID
string
GoodsName
string
type
LyClearGoodsList
struct
{
GoodsName
string
`json:"goods_name"`
GoodsNameTemp
string
`json:"goods_name_temp"`
BrandName
string
`json:"brand_name"`
Desc
string
`json:"desc"`
GoodsSn
string
`json:"goods_sn"`
Docurl
string
`json:"docurl"`
Url
string
`json:"url"`
GoodsImg
string
`json:"goods_img"`
Cat
string
`json:"cat"`
RestrictionMessage
string
`json:"RestrictionMessage"`
increment
int
`json:"increment"`
SinglePrice
float64
`json:"single_price"`
Tiered
[]
*
TierItem
}
//联营请求外链后格式化数据
type
LyClearDataItem
struct
{
GoodsName
string
GoodsNameTemp
string
BrandName
string
Desc
string
GoodsSn
string
Docurl
string
Url
string
GoodsImg
string
Cat
string
RestrictionMessage
string
increment
int
SinglePrice
float64
PriceTemp
[]
PriceTempItem
}
type
PriceTempItem
struct
{
type
TierItem
struct
{
Purchases
int
PriceUs
float64
PriceCn
float64
PriceAc
float64
}
test/test2.go
0 → 100644
View file @
21d37cdf
package
main
import
(
"fmt"
"encoding/json"
)
func
main
()
{
var
goodsList
[]
interface
{}
var
productList
map
[
string
]
interface
{}
var
price_temp
[]
interface
{}
var
tiered
[]
interface
{}
m
:=
make
(
map
[
string
]
interface
{})
m
[
"goods_names"
]
=
"LM358"
m
[
"stock"
]
=
[
...
]
int64
{
1
,
23
}
price_temp
=
append
(
price_temp
,[
...
]
int64
{
3
,
5
})
m
[
"price_temp"
]
=
price_temp
;
s
:=
make
(
map
[
string
]
interface
{})
s
[
"purchases"
]
=
1
s
[
"price_us"
]
=
0.66
s
[
"price_us"
]
=
0.67
s
[
"price_cn"
]
=
0.33
tiered
=
append
(
tiered
,
s
);
m
[
"tiered"
]
=
tiered
;
goodsList
=
append
(
goodsList
,
m
)
productList
=
make
(
map
[
string
]
interface
{})
productList
[
"595-LM358BIDR"
]
=
goodsList
productList
[
"595-LM358LVIDDFR"
]
=
goodsList
//map的遍历
for
k
,
v
:=
range
productList
{
fmt
.
Println
(
k
,
v
)
}
jsonStr
,
err
:=
json
.
Marshal
(
productList
)
if
err
!=
nil
{
return
}
fmt
.
Printf
(
"%s
\n
"
,
jsonStr
)
}
\ No newline at end of file
test/test3.go
0 → 100644
View file @
21d37cdf
package
main
import
(
"fmt"
"encoding/json"
"search_server/model"
)
func
main
()
{
var
LyClearGoodsList
model
.
LyClearGoodsList
LyClearGoodsList
.
GoodsName
=
"LM358"
ladderPrice
:=
make
([]
*
model
.
TierItem
,
0
)
ladder
:=
model
.
TierItem
{
Purchases
:
1
,
PriceUs
:
0.44
,
PriceCn
:
1.55
,
}
ladderPrice
=
append
(
ladderPrice
,
&
ladder
)
LyClearGoodsList
.
Tiered
=
ladderPrice
var
productList
map
[
string
]
*
model
.
LyClearGoodsList
productList
=
make
(
map
[
string
]
*
model
.
LyClearGoodsList
,
0
)
productList
[
"595-LM358BIDR"
]
=
&
LyClearGoodsList
//map的遍历
for
k
,
v
:=
range
productList
{
fmt
.
Println
(
k
,
v
)
}
jsonStr
,
err
:=
json
.
Marshal
(
productList
)
if
err
!=
nil
{
return
}
fmt
.
Printf
(
"%s
\n
"
,
jsonStr
)
}
\ 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