Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
chain33-pai
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ligaishun
chain33-pai
Commits
865a9bcd
Commit
865a9bcd
authored
Oct 09, 2019
by
szh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update models and sql
parent
a4447955
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
5 deletions
+9
-5
raspberry.sql
docs/sql/raspberry.sql
+4
-2
raspConfig.go
models/raspConfig.go
+5
-3
No files found.
docs/sql/raspberry.sql
View file @
865a9bcd
...
@@ -10,7 +10,7 @@ Target Server Type : MYSQL
...
@@ -10,7 +10,7 @@ Target Server Type : MYSQL
Target Server Version : 50553
Target Server Version : 50553
File Encoding : 65001
File Encoding : 65001
Date: 2019-10-09
09:31:51
Date: 2019-10-09
11:53:20
*/
*/
SET
FOREIGN_KEY_CHECKS
=
0
;
SET
FOREIGN_KEY_CHECKS
=
0
;
...
@@ -20,7 +20,9 @@ SET FOREIGN_KEY_CHECKS=0;
...
@@ -20,7 +20,9 @@ SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- ----------------------------
DROP
TABLE
IF
EXISTS
`rasp_config`
;
DROP
TABLE
IF
EXISTS
`rasp_config`
;
CREATE
TABLE
`rasp_config`
(
CREATE
TABLE
`rasp_config`
(
`height`
bigint
(
20
)
DEFAULT
'0'
`height`
bigint
(
20
)
DEFAULT
'0'
,
`config`
varchar
(
64
)
NOT
NULL
,
PRIMARY
KEY
(
`config`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
;
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
;
-- ----------------------------
-- ----------------------------
...
...
models/raspConfig.go
View file @
865a9bcd
...
@@ -3,19 +3,20 @@ package models
...
@@ -3,19 +3,20 @@ package models
type
RaspConfig
struct
{
type
RaspConfig
struct
{
Model
Model
Height
int64
`json:"height"`
Height
int64
`json:"height"`
Config
string
`json:"config"`
}
}
// GetHeight get lastheight in chain33
// GetHeight get lastheight in chain33
func
GetHeight
()
(
int64
,
error
)
{
func
GetHeight
()
(
int64
,
error
)
{
var
list
[]
*
RaspConfig
var
rasp
RaspConfig
err
:=
db
.
Find
(
&
list
)
.
Error
err
:=
db
.
Select
(
"Height"
)
.
Where
(
"config = ?"
,
"height"
)
.
First
(
&
rasp
)
.
Error
if
err
!=
nil
{
if
err
!=
nil
{
//if err == gorm.ErrRecordNotFound {
//if err == gorm.ErrRecordNotFound {
// return 0, err
// return 0, err
//}
//}
return
0
,
err
return
0
,
err
}
}
return
list
[
0
]
.
Height
,
nil
return
rasp
.
Height
,
nil
}
}
// EditArticle modify a single article
// EditArticle modify a single article
...
@@ -31,6 +32,7 @@ func UpdateHeight(height int64) error {
...
@@ -31,6 +32,7 @@ func UpdateHeight(height int64) error {
func
InitHeight
()
error
{
func
InitHeight
()
error
{
config
:=
RaspConfig
{
config
:=
RaspConfig
{
Height
:
0
,
Height
:
0
,
Config
:
"height"
,
}
}
if
err
:=
db
.
Create
(
&
config
)
.
Error
;
err
!=
nil
{
if
err
:=
db
.
Create
(
&
config
)
.
Error
;
err
!=
nil
{
return
err
return
err
...
...
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