Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄成意
/
go_sku_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
b4759a26
authored
Aug 28, 2025
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
加上替换特殊符号逻辑
parent
aa171feb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
service/service_attr.go
service/service_attr.go
View file @
b4759a26
...
...
@@ -2,15 +2,17 @@ package service
import
(
"encoding/json"
"github.com/iancoleman/orderedmap"
"go_sku_server/pkg/logger"
"go_sku_server/pkg/mongo"
"strconv"
"strings"
"github.com/iancoleman/orderedmap"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"strconv"
)
//获取Spu的属性
//
获取Spu的属性
func
(
ls
*
LyService
)
GetSpuAttr
(
spuId
string
)
(
attrsResult
interface
{})
{
var
spuAttr
SpuAttr
var
attrsList
[]
interface
{}
...
...
@@ -26,7 +28,17 @@ func (ls *LyService) GetSpuAttr(spuId string) (attrsResult interface{}) {
//fmt.Println(spuAttr.AttrsExtend)
//如果有attrs_extend,就去取attrs_extend
if
len
(
spuAttr
.
AttrsExtend
)
!=
0
{
return
spuAttr
.
AttrsExtend
//便利AttrsExtend的值
for
_
,
value
:=
range
spuAttr
.
AttrsExtend
{
data
:=
make
(
map
[
string
]
interface
{})
data
[
"attr_name"
]
=
value
.
AttrName
//€符号全部替换为逗号
data
[
"attr_value"
]
=
strings
.
ReplaceAll
(
value
.
AttrValue
,
"€"
,
","
)
data
[
"attr_unit"
]
=
value
.
AttrUnit
attrsList
=
append
(
attrsList
,
data
)
attrsResult
=
attrsList
}
return
attrsResult
}
else
if
spuAttr
.
Attrs
!=
""
{
o
:=
orderedmap
.
New
()
err
:=
json
.
Unmarshal
([]
byte
(
spuAttr
.
Attrs
),
&
o
)
...
...
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