Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
chaincode
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
袁邓@五瓣科技
chaincode
Commits
5e4cc8af
Commit
5e4cc8af
authored
Feb 21, 2020
by
刘星星@五瓣科技
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify data put function
parent
ec5a9afa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
30 deletions
+67
-30
workspace.xml
.idea/workspace.xml
+60
-23
gongxianghui.go
gongxianghui/gongxianghui.go
+7
-7
No files found.
.idea/workspace.xml
View file @
5e4cc8af
...
@@ -3,9 +3,7 @@
...
@@ -3,9 +3,7 @@
<component
name=
"ChangeListManager"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"de83b181-e854-4be8-81f5-73a2fdb02762"
name=
"Default Changelist"
comment=
""
>
<list
default=
"true"
id=
"de83b181-e854-4be8-81f5-73a2fdb02762"
name=
"Default Changelist"
comment=
""
>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/gongxianghui/deposit.go"
beforeDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/gongxianghui/gongxianghui.go"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/gongxianghui/gongxianghui.go"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/gongxianghui/gongxianghui.go"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/gongxianghui/gongxianghui.go"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/gongxianghui/schema.go"
beforeDir=
"false"
/>
</list>
</list>
<option
name=
"EXCLUDED_CONVERTED_TO_IGNORED"
value=
"true"
/>
<option
name=
"EXCLUDED_CONVERTED_TO_IGNORED"
value=
"true"
/>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
...
@@ -15,19 +13,21 @@
...
@@ -15,19 +13,21 @@
</component>
</component>
<component
name=
"FileEditorManager"
>
<component
name=
"FileEditorManager"
>
<leaf
SIDE_TABS_SIZE_LIMIT_KEY=
"300"
>
<leaf
SIDE_TABS_SIZE_LIMIT_KEY=
"300"
>
<file
pinned=
"false"
current-in-tab=
"
tru
e"
>
<file
pinned=
"false"
current-in-tab=
"
fals
e"
>
<entry
file=
"file://$PROJECT_DIR$/gongxianghui/gongxianghui.go"
>
<entry
file=
"file://$PROJECT_DIR$/gongxianghui/gongxianghui.go"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"
-3990
"
>
<state
relative-caret-position=
"
141
"
>
<caret
line=
"
62"
column=
"59"
selection-start-line=
"62"
selection-start-column=
"59"
selection-end-line=
"62"
selection-end-column=
"59
"
/>
<caret
line=
"
72"
selection-start-line=
"72"
selection-end-line=
"72
"
/>
</state>
</state>
</provider>
</provider>
</entry>
</entry>
</file>
</file>
<file
pinned=
"false"
current-in-tab=
"
fals
e"
>
<file
pinned=
"false"
current-in-tab=
"
tru
e"
>
<entry
file=
"file://$PROJECT_DIR$/gongxianghui/gongxianghui_test.go"
>
<entry
file=
"file://$PROJECT_DIR$/gongxianghui/gongxianghui_test.go"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"-522"
/>
<state
relative-caret-position=
"271"
>
<caret
line=
"57"
column=
"17"
lean-forward=
"true"
selection-start-line=
"57"
selection-start-column=
"17"
selection-end-line=
"57"
selection-end-column=
"17"
/>
</state>
</provider>
</provider>
</entry>
</entry>
</file>
</file>
...
@@ -41,16 +41,17 @@
...
@@ -41,16 +41,17 @@
<option
name=
"CHANGED_PATHS"
>
<option
name=
"CHANGED_PATHS"
>
<list>
<list>
<option
value=
"$PROJECT_DIR$/gongxianghui/schema.go"
/>
<option
value=
"$PROJECT_DIR$/gongxianghui/schema.go"
/>
<option
value=
"$PROJECT_DIR$/gongxianghui/gongxianghui.go"
/>
<option
value=
"$PROJECT_DIR$/gongxianghui/deposit.go"
/>
<option
value=
"$PROJECT_DIR$/gongxianghui/deposit.go"
/>
<option
value=
"$PROJECT_DIR$/gongxianghui/gongxianghui.go"
/>
<option
value=
"$PROJECT_DIR$/gongxianghui/gongxianghui_test.go"
/>
</list>
</list>
</option>
</option>
</component>
</component>
<component
name=
"ProjectFrameBounds"
extendedState=
"6"
>
<component
name=
"ProjectFrameBounds"
extendedState=
"6"
>
<option
name=
"x"
value=
"1"
/>
<option
name=
"x"
value=
"1
20
"
/>
<option
name=
"y"
value=
"2
5
"
/>
<option
name=
"y"
value=
"2
7
"
/>
<option
name=
"width"
value=
"
639
"
/>
<option
name=
"width"
value=
"
1657
"
/>
<option
name=
"height"
value=
"
455
"
/>
<option
name=
"height"
value=
"
861
"
/>
</component>
</component>
<component
name=
"ProjectLevelVcsManager"
settingsEditedManually=
"true"
/>
<component
name=
"ProjectLevelVcsManager"
settingsEditedManually=
"true"
/>
<component
name=
"ProjectView"
>
<component
name=
"ProjectView"
>
...
@@ -130,25 +131,47 @@
...
@@ -130,25 +131,47 @@
</recent_temporary>
</recent_temporary>
</component>
</component>
<component
name=
"TestHistory"
>
<component
name=
"TestHistory"
>
<history-entry
file=
"TestGXHCC_in_github_com_hyperledger_chaincode_gongxianghui - 2020.02.18 at 18h 01m 03s.xml"
>
<configuration
name=
"TestGXHCC in github.com/hyperledger/chaincode/gongxianghui"
configurationId=
"GoTestRunConfiguration"
/>
</history-entry>
<history-entry
file=
"TestGXHCC_in_github_com_hyperledger_chaincode_gongxianghui - 2020.02.21 at 10h 01m 08s.xml"
>
<history-entry
file=
"TestGXHCC_in_github_com_hyperledger_chaincode_gongxianghui - 2020.02.21 at 10h 01m 08s.xml"
>
<configuration
name=
"TestGXHCC in github.com/hyperledger/chaincode/gongxianghui"
configurationId=
"GoTestRunConfiguration"
/>
<configuration
name=
"TestGXHCC in github.com/hyperledger/chaincode/gongxianghui"
configurationId=
"GoTestRunConfiguration"
/>
</history-entry>
</history-entry>
<history-entry
file=
"TestGXHSchema_in_github_com_hyperledger_chaincode_gongxianghui - 2020.02.21 at 10h 03m 03s.xml"
>
<history-entry
file=
"TestGXHSchema_in_github_com_hyperledger_chaincode_gongxianghui - 2020.02.21 at 10h 03m 03s.xml"
>
<configuration
name=
"TestGXHSchema in github.com/hyperledger/chaincode/gongxianghui"
configurationId=
"GoTestRunConfiguration"
/>
<configuration
name=
"TestGXHSchema in github.com/hyperledger/chaincode/gongxianghui"
configurationId=
"GoTestRunConfiguration"
/>
</history-entry>
</history-entry>
<history-entry
file=
"TestGXHSchema_in_github_com_hyperledger_chaincode_gongxianghui - 2020.02.21 at 14h 06m 50s.xml"
>
<configuration
name=
"TestGXHSchema in github.com/hyperledger/chaincode/gongxianghui"
configurationId=
"GoTestRunConfiguration"
/>
</history-entry>
<history-entry
file=
"TestGXHSchema_in_github_com_hyperledger_chaincode_gongxianghui - 2020.02.21 at 14h 08m 03s.xml"
>
<configuration
name=
"TestGXHSchema in github.com/hyperledger/chaincode/gongxianghui"
configurationId=
"GoTestRunConfiguration"
/>
</history-entry>
<history-entry
file=
"TestGXHSchema_in_github_com_hyperledger_chaincode_gongxianghui - 2020.02.21 at 14h 09m 01s.xml"
>
<configuration
name=
"TestGXHSchema in github.com/hyperledger/chaincode/gongxianghui"
configurationId=
"GoTestRunConfiguration"
/>
</history-entry>
<history-entry
file=
"TestGXHSchema_in_github_com_hyperledger_chaincode_gongxianghui - 2020.02.21 at 14h 09m 43s.xml"
>
<configuration
name=
"TestGXHSchema in github.com/hyperledger/chaincode/gongxianghui"
configurationId=
"GoTestRunConfiguration"
/>
</history-entry>
<history-entry
file=
"TestGXHSchema_in_github_com_hyperledger_chaincode_gongxianghui - 2020.02.21 at 14h 45m 07s.xml"
>
<configuration
name=
"TestGXHSchema in github.com/hyperledger/chaincode/gongxianghui"
configurationId=
"GoTestRunConfiguration"
/>
</history-entry>
<history-entry
file=
"TestGXHSchema_in_github_com_hyperledger_chaincode_gongxianghui - 2020.02.21 at 14h 48m 06s.xml"
>
<configuration
name=
"TestGXHSchema in github.com/hyperledger/chaincode/gongxianghui"
configurationId=
"GoTestRunConfiguration"
/>
</history-entry>
<history-entry
file=
"TestGXHSchema_in_github_com_hyperledger_chaincode_gongxianghui - 2020.02.21 at 14h 48m 32s.xml"
>
<configuration
name=
"TestGXHSchema in github.com/hyperledger/chaincode/gongxianghui"
configurationId=
"GoTestRunConfiguration"
/>
</history-entry>
<history-entry
file=
"TestGXHSchema_in_github_com_hyperledger_chaincode_gongxianghui - 2020.02.21 at 14h 55m 01s.xml"
>
<configuration
name=
"TestGXHSchema in github.com/hyperledger/chaincode/gongxianghui"
configurationId=
"GoTestRunConfiguration"
/>
</history-entry>
</component>
</component>
<component
name=
"ToolWindowManager"
>
<component
name=
"ToolWindowManager"
>
<frame
x=
"67"
y=
"25"
width=
"1853"
height=
"925"
extended-state=
"6"
/>
<frame
x=
"67"
y=
"25"
width=
"1853"
height=
"925"
extended-state=
"6"
/>
<editor
active=
"true"
/>
<layout>
<layout>
<window_info
content_ui=
"combo"
id=
"Project"
order=
"0"
visible=
"true"
weight=
"0.
2559556
7"
/>
<window_info
content_ui=
"combo"
id=
"Project"
order=
"0"
visible=
"true"
weight=
"0.
1290858
7"
/>
<window_info
id=
"Structure"
order=
"1"
side_tool=
"true"
weight=
"0.25"
/>
<window_info
id=
"Structure"
order=
"1"
side_tool=
"true"
weight=
"0.25"
/>
<window_info
id=
"Favorites"
order=
"2"
side_tool=
"true"
/>
<window_info
id=
"Favorites"
order=
"2"
side_tool=
"true"
/>
<window_info
anchor=
"bottom"
id=
"Message"
order=
"0"
/>
<window_info
anchor=
"bottom"
id=
"Message"
order=
"0"
/>
<window_info
anchor=
"bottom"
id=
"Find"
order=
"1"
/>
<window_info
anchor=
"bottom"
id=
"Find"
order=
"1"
/>
<window_info
a
nchor=
"bottom"
id=
"Run"
order=
"2
"
weight=
"0.3308176"
/>
<window_info
a
ctive=
"true"
anchor=
"bottom"
id=
"Run"
order=
"2"
visible=
"true
"
weight=
"0.3308176"
/>
<window_info
anchor=
"bottom"
id=
"Debug"
order=
"3"
weight=
"0.4"
/>
<window_info
anchor=
"bottom"
id=
"Debug"
order=
"3"
weight=
"0.4"
/>
<window_info
anchor=
"bottom"
id=
"Cvs"
order=
"4"
weight=
"0.25"
/>
<window_info
anchor=
"bottom"
id=
"Cvs"
order=
"4"
weight=
"0.25"
/>
<window_info
anchor=
"bottom"
id=
"Inspection"
order=
"5"
weight=
"0.4"
/>
<window_info
anchor=
"bottom"
id=
"Inspection"
order=
"5"
weight=
"0.4"
/>
...
@@ -157,7 +180,7 @@
...
@@ -157,7 +180,7 @@
<window_info
anchor=
"bottom"
id=
"Version Control"
order=
"8"
/>
<window_info
anchor=
"bottom"
id=
"Version Control"
order=
"8"
/>
<window_info
anchor=
"bottom"
id=
"Database Changes"
order=
"9"
/>
<window_info
anchor=
"bottom"
id=
"Database Changes"
order=
"9"
/>
<window_info
anchor=
"bottom"
id=
"Statistic"
order=
"10"
/>
<window_info
anchor=
"bottom"
id=
"Statistic"
order=
"10"
/>
<window_info
a
ctive=
"true"
anchor=
"bottom"
id=
"Terminal"
order=
"11"
visible=
"true
"
weight=
"0.32955974"
/>
<window_info
a
nchor=
"bottom"
id=
"Terminal"
order=
"11
"
weight=
"0.32955974"
/>
<window_info
anchor=
"bottom"
id=
"Event Log"
order=
"12"
side_tool=
"true"
/>
<window_info
anchor=
"bottom"
id=
"Event Log"
order=
"12"
side_tool=
"true"
/>
<window_info
anchor=
"right"
id=
"Commander"
internal_type=
"SLIDING"
order=
"0"
type=
"SLIDING"
weight=
"0.4"
/>
<window_info
anchor=
"right"
id=
"Commander"
internal_type=
"SLIDING"
order=
"0"
type=
"SLIDING"
weight=
"0.4"
/>
<window_info
anchor=
"right"
id=
"Ant Build"
order=
"1"
weight=
"0.25"
/>
<window_info
anchor=
"right"
id=
"Ant Build"
order=
"1"
weight=
"0.25"
/>
...
@@ -169,6 +192,18 @@
...
@@ -169,6 +192,18 @@
<component
name=
"TypeScriptGeneratedFilesManager"
>
<component
name=
"TypeScriptGeneratedFilesManager"
>
<option
name=
"version"
value=
"1"
/>
<option
name=
"version"
value=
"1"
/>
</component>
</component>
<component
name=
"XDebuggerManager"
>
<breakpoint-manager>
<breakpoints>
<line-breakpoint
enabled=
"true"
type=
"DlvLineBreakpoint"
>
<url>
file://$PROJECT_DIR$/gongxianghui/gongxianghui.go
</url>
<line>
72
</line>
<properties
/>
<option
name=
"timeStamp"
value=
"1"
/>
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
<component
name=
"editorHistoryManager"
>
<component
name=
"editorHistoryManager"
>
<entry
file=
"file://$PROJECT_DIR$/gongxianghui/schema.go"
>
<entry
file=
"file://$PROJECT_DIR$/gongxianghui/schema.go"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
...
@@ -180,15 +215,17 @@
...
@@ -180,15 +215,17 @@
<entry
file=
"file://$PROJECT_DIR$/gongxianghui/deposit.go"
>
<entry
file=
"file://$PROJECT_DIR$/gongxianghui/deposit.go"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
/>
<provider
selected=
"true"
editor-type-id=
"text-editor"
/>
</entry>
</entry>
<entry
file=
"file://$PROJECT_DIR$/gongxianghui/gongxianghui
_test
.go"
>
<entry
file=
"file://$PROJECT_DIR$/gongxianghui/gongxianghui.go"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"-522"
/>
<state
relative-caret-position=
"141"
>
<caret
line=
"72"
selection-start-line=
"72"
selection-end-line=
"72"
/>
</state>
</provider>
</provider>
</entry>
</entry>
<entry
file=
"file://$PROJECT_DIR$/gongxianghui/gongxianghui.go"
>
<entry
file=
"file://$PROJECT_DIR$/gongxianghui/gongxianghui
_test
.go"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"
-3990
"
>
<state
relative-caret-position=
"
271
"
>
<caret
line=
"
62"
column=
"59"
selection-start-line=
"62"
selection-start-column=
"59"
selection-end-line=
"62"
selection-end-column=
"59
"
/>
<caret
line=
"
57"
column=
"17"
lean-forward=
"true"
selection-start-line=
"57"
selection-start-column=
"17"
selection-end-line=
"57"
selection-end-column=
"17
"
/>
</state>
</state>
</provider>
</provider>
</entry>
</entry>
...
...
gongxianghui/gongxianghui.go
View file @
5e4cc8af
...
@@ -74,7 +74,7 @@ func put(args []string, stub shim.ChaincodeStubInterface) (string, error) {
...
@@ -74,7 +74,7 @@ func put(args []string, stub shim.ChaincodeStubInterface) (string, error) {
if
len
(
args
)
<
2
{
if
len
(
args
)
<
2
{
return
""
,
fmt
.
Errorf
(
"Expected more than 2 parameters to function put!"
)
return
""
,
fmt
.
Errorf
(
"Expected more than 2 parameters to function put!"
)
}
}
var
mapResult
map
[
string
]
interface
{}
var
mapResult
[]
map
[
string
]
interface
{}
var
schemaMap
map
[
string
]
interface
{}
var
schemaMap
map
[
string
]
interface
{}
schema
:=
&
Schema
{}
schema
:=
&
Schema
{}
result
,
err
:=
schema
.
get
(
args
[
0
],
stub
)
result
,
err
:=
schema
.
get
(
args
[
0
],
stub
)
...
@@ -83,11 +83,11 @@ func put(args []string, stub shim.ChaincodeStubInterface) (string, error) {
...
@@ -83,11 +83,11 @@ func put(args []string, stub shim.ChaincodeStubInterface) (string, error) {
}
}
json
.
Unmarshal
([]
byte
(
result
),
&
schemaMap
)
json
.
Unmarshal
([]
byte
(
result
),
&
schemaMap
)
for
k
,
v
:=
range
args
[
1
:
]
{
if
err
:=
json
.
Unmarshal
([]
byte
(
args
[
1
]),
&
mapResult
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
([]
byte
(
v
),
&
mapResult
);
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"parameters Unmarshal fail,args string not json string, err:%s"
,
err
)
return
""
,
fmt
.
Errorf
(
"parameters Unmarshal fail,args index %d string not json string, err:%s"
,
k
,
err
)
}
}
for
k
,
v
:=
range
mapResult
{
Id
,
ok
:=
mapResult
[
"id"
]
Id
,
ok
:=
v
[
"id"
]
if
!
ok
{
if
!
ok
{
return
""
,
fmt
.
Errorf
(
"The id field must exist "
)
return
""
,
fmt
.
Errorf
(
"The id field must exist "
)
}
}
...
@@ -96,7 +96,7 @@ func put(args []string, stub shim.ChaincodeStubInterface) (string, error) {
...
@@ -96,7 +96,7 @@ func put(args []string, stub shim.ChaincodeStubInterface) (string, error) {
}
else
if
result
!=
nil
{
}
else
if
result
!=
nil
{
return
""
,
fmt
.
Errorf
(
"%s data already exist"
,
args
[
0
]
+
Id
.
(
string
))
return
""
,
fmt
.
Errorf
(
"%s data already exist"
,
args
[
0
]
+
Id
.
(
string
))
}
}
if
!
SchemaCheck
(
schemaMap
,
mapResult
){
if
!
SchemaCheck
(
schemaMap
,
v
){
return
""
,
fmt
.
Errorf
(
"SchemaCheck fail,args index %d string doesn't match %s format"
,
k
,
args
[
0
])
return
""
,
fmt
.
Errorf
(
"SchemaCheck fail,args index %d string doesn't match %s format"
,
k
,
args
[
0
])
}
}
putDate
,
_
:=
json
.
Marshal
(
mapResult
)
putDate
,
_
:=
json
.
Marshal
(
mapResult
)
...
...
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