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
77fa04d6
Commit
77fa04d6
authored
Feb 21, 2020
by
刘星星@五瓣科技
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify update err
parent
5e4cc8af
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
43 deletions
+31
-43
workspace.xml
.idea/workspace.xml
+18
-30
gongxianghui.go
gongxianghui/gongxianghui.go
+13
-13
No files found.
.idea/workspace.xml
View file @
77fa04d6
...
...
@@ -16,8 +16,8 @@
<file
pinned=
"false"
current-in-tab=
"false"
>
<entry
file=
"file://$PROJECT_DIR$/gongxianghui/gongxianghui.go"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"
141
"
>
<caret
line=
"
72"
selection-start-line=
"72"
selection-end-line=
"72
"
/>
<state
relative-caret-position=
"
407
"
>
<caret
line=
"
186"
column=
"14"
lean-forward=
"true"
selection-start-line=
"186"
selection-start-column=
"14"
selection-end-line=
"186"
selection-end-column=
"14
"
/>
</state>
</provider>
</entry>
...
...
@@ -25,8 +25,8 @@
<file
pinned=
"false"
current-in-tab=
"true"
>
<entry
file=
"file://$PROJECT_DIR$/gongxianghui/gongxianghui_test.go"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<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
relative-caret-position=
"
1278
"
>
<caret
line=
"
76"
column=
"80"
selection-start-line=
"76"
selection-start-column=
"80"
selection-end-line=
"76"
selection-end-column=
"80
"
/>
</state>
</provider>
</entry>
...
...
@@ -42,8 +42,8 @@
<list>
<option
value=
"$PROJECT_DIR$/gongxianghui/schema.go"
/>
<option
value=
"$PROJECT_DIR$/gongxianghui/deposit.go"
/>
<option
value=
"$PROJECT_DIR$/gongxianghui/gongxianghui.go"
/>
<option
value=
"$PROJECT_DIR$/gongxianghui/gongxianghui_test.go"
/>
<option
value=
"$PROJECT_DIR$/gongxianghui/gongxianghui.go"
/>
</list>
</option>
</component>
...
...
@@ -131,15 +131,6 @@
</recent_temporary>
</component>
<component
name=
"TestHistory"
>
<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"
/>
</history-entry>
<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"
/>
</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>
...
...
@@ -161,6 +152,15 @@
<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>
<history-entry
file=
"TestGXHSchema_in_github_com_hyperledger_chaincode_gongxianghui - 2020.02.21 at 20h 01m 24s.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 20h 01m 40s.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 20h 03m 09s.xml"
>
<configuration
name=
"TestGXHSchema in github.com/hyperledger/chaincode/gongxianghui"
configurationId=
"GoTestRunConfiguration"
/>
</history-entry>
</component>
<component
name=
"ToolWindowManager"
>
<frame
x=
"67"
y=
"25"
width=
"1853"
height=
"925"
extended-state=
"6"
/>
...
...
@@ -192,18 +192,6 @@
<component
name=
"TypeScriptGeneratedFilesManager"
>
<option
name=
"version"
value=
"1"
/>
</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"
>
<entry
file=
"file://$PROJECT_DIR$/gongxianghui/schema.go"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
...
...
@@ -217,15 +205,15 @@
</entry>
<entry
file=
"file://$PROJECT_DIR$/gongxianghui/gongxianghui.go"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"
141
"
>
<caret
line=
"
72"
selection-start-line=
"72"
selection-end-line=
"72
"
/>
<state
relative-caret-position=
"
407
"
>
<caret
line=
"
186"
column=
"14"
lean-forward=
"true"
selection-start-line=
"186"
selection-start-column=
"14"
selection-end-line=
"186"
selection-end-column=
"14
"
/>
</state>
</provider>
</entry>
<entry
file=
"file://$PROJECT_DIR$/gongxianghui/gongxianghui_test.go"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<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
relative-caret-position=
"
1278
"
>
<caret
line=
"
76"
column=
"80"
selection-start-line=
"76"
selection-start-column=
"80"
selection-end-line=
"76"
selection-end-column=
"80
"
/>
</state>
</provider>
</entry>
...
...
gongxianghui/gongxianghui.go
View file @
77fa04d6
...
...
@@ -45,13 +45,13 @@ func (t *GXHCC) Invoke(stub shim.ChaincodeStubInterface) pb.Response {
case
"get"
:
res
,
err
:=
get
(
args
,
stub
)
if
err
!=
nil
{
return
shim
.
Error
(
fmt
.
Sprintf
(
"
pu
t function err: %s"
,
err
))
return
shim
.
Error
(
fmt
.
Sprintf
(
"
ge
t function err: %s"
,
err
))
}
return
shim
.
Success
([]
byte
(
res
))
case
"update"
:
res
,
err
:=
update
(
args
,
stub
)
if
err
!=
nil
{
return
shim
.
Error
(
fmt
.
Sprintf
(
"
put
function err: %s"
,
err
))
return
shim
.
Error
(
fmt
.
Sprintf
(
"
update
function err: %s"
,
err
))
}
return
shim
.
Success
([]
byte
(
res
))
...
...
@@ -74,7 +74,7 @@ func put(args []string, stub shim.ChaincodeStubInterface) (string, error) {
if
len
(
args
)
<
2
{
return
""
,
fmt
.
Errorf
(
"Expected more than 2 parameters to function put!"
)
}
var
map
Result
[]
map
[
string
]
interface
{}
var
Result
[]
map
[
string
]
interface
{}
var
schemaMap
map
[
string
]
interface
{}
schema
:=
&
Schema
{}
result
,
err
:=
schema
.
get
(
args
[
0
],
stub
)
...
...
@@ -83,11 +83,11 @@ func put(args []string, stub shim.ChaincodeStubInterface) (string, error) {
}
json
.
Unmarshal
([]
byte
(
result
),
&
schemaMap
)
if
err
:=
json
.
Unmarshal
([]
byte
(
args
[
1
]),
&
map
Result
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
([]
byte
(
args
[
1
]),
&
Result
);
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"parameters Unmarshal fail,args string not json string, err:%s"
,
err
)
}
for
k
,
v
:=
range
map
Result
{
Id
,
ok
:=
v
[
"id"
]
for
k
,
mapres
:=
range
Result
{
Id
,
ok
:=
mapres
[
"id"
]
if
!
ok
{
return
""
,
fmt
.
Errorf
(
"The id field must exist "
)
}
...
...
@@ -96,10 +96,10 @@ func put(args []string, stub shim.ChaincodeStubInterface) (string, error) {
}
else
if
result
!=
nil
{
return
""
,
fmt
.
Errorf
(
"%s data already exist"
,
args
[
0
]
+
Id
.
(
string
))
}
if
!
SchemaCheck
(
schemaMap
,
v
){
if
!
SchemaCheck
(
schemaMap
,
mapres
){
return
""
,
fmt
.
Errorf
(
"SchemaCheck fail,args index %d string doesn't match %s format"
,
k
,
args
[
0
])
}
putDate
,
_
:=
json
.
Marshal
(
map
Result
)
putDate
,
_
:=
json
.
Marshal
(
map
res
)
if
err
:=
stub
.
PutState
(
args
[
0
]
+
Id
.
(
string
),
putDate
);
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"PutState fail, err :%s"
,
err
)
}
...
...
@@ -113,12 +113,12 @@ func put(args []string, stub shim.ChaincodeStubInterface) (string, error) {
*/
func
update
(
args
[]
string
,
stub
shim
.
ChaincodeStubInterface
)
(
string
,
error
)
{
if
len
(
args
)
!=
2
{
return
""
,
fmt
.
Errorf
(
"Expected 2 parameters to function
put
! "
)
return
""
,
fmt
.
Errorf
(
"Expected 2 parameters to function
update
! "
)
}
var
mapResult
map
[
string
]
interface
{}
var
allMap
map
[
string
]
interface
{}
if
err
:=
json
.
Unmarshal
([]
byte
(
args
[
1
]),
&
mapResult
);
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"parameters Unmarshal fail,args
index %d string not json string,err:
"
,
err
)
return
""
,
fmt
.
Errorf
(
"parameters Unmarshal fail,args
string not json string,err: %s
"
,
err
)
}
Id
,
ok
:=
mapResult
[
"id"
]
...
...
@@ -135,7 +135,7 @@ func update(args []string, stub shim.ChaincodeStubInterface) (string, error) {
if
err
:=
Deassign
(
mapResult
,
allMap
);
err
!=
nil
{
return
""
,
err
}
else
{
resultByte
,
_
:=
json
.
Marshal
(
mapResult
)
resultByte
,
_
:=
json
.
Marshal
(
allMap
)
if
err
:=
stub
.
PutState
(
args
[
0
]
+
Id
.
(
string
),
resultByte
);
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"updateState date fail, err :%s "
,
err
)
}
...
...
@@ -146,11 +146,11 @@ func update(args []string, stub shim.ChaincodeStubInterface) (string, error) {
func
get
(
args
[]
string
,
stub
shim
.
ChaincodeStubInterface
)
(
string
,
error
)
{
if
len
(
args
)
!=
2
{
return
""
,
fmt
.
Errorf
(
"Expected 2 parameters to function
pu
t!"
)
return
""
,
fmt
.
Errorf
(
"Expected 2 parameters to function
ge
t!"
)
}
var
mapResult
map
[
string
]
interface
{}
if
err
:=
json
.
Unmarshal
([]
byte
(
args
[
1
]),
&
mapResult
);
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"parameters Unmarshal fail,args
index
string not json string,err: %s"
,
err
)
return
""
,
fmt
.
Errorf
(
"parameters Unmarshal fail,args string not json string,err: %s"
,
err
)
}
Id
:=
mapResult
[
"id"
]
...
...
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