Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
homekeeper
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Peter Cheng
homekeeper
Commits
c948a641
Commit
c948a641
authored
Sep 03, 2019
by
Peter Cheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修正Error觸發後動作
parent
6e301e98
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
23 deletions
+23
-23
base.go
controllers/base.go
+6
-6
mail.go
controllers/mail.go
+1
-1
punchclock.go
controllers/punchclock.go
+2
-2
redis.go
controllers/redis.go
+13
-13
holiday.go
models/holiday.go
+1
-1
No files found.
controllers/base.go
View file @
c948a641
...
...
@@ -23,12 +23,12 @@ var cfg = env.GetEnv()
func
GetURL
(
url
string
)
[]
byte
{
request
,
err
:=
http
.
NewRequest
(
"GET"
,
url
,
nil
)
if
err
!=
nil
{
panic
(
err
)
log
.
Panicln
(
err
)
}
client
:=
&
http
.
Client
{}
result
,
err
:=
client
.
Do
(
request
)
if
err
!=
nil
{
panic
(
err
)
log
.
Panicln
(
err
)
}
body
,
_
:=
ioutil
.
ReadAll
(
result
.
Body
)
defer
result
.
Body
.
Close
()
...
...
@@ -43,7 +43,7 @@ func PostURL(url string, params []byte) []byte {
client
:=
&
http
.
Client
{}
result
,
err
:=
client
.
Do
(
request
)
if
err
!=
nil
{
log
.
Panic
(
err
)
log
.
Panic
ln
(
err
)
}
body
,
_
:=
ioutil
.
ReadAll
(
result
.
Body
)
defer
result
.
Body
.
Close
()
...
...
@@ -54,7 +54,7 @@ func PostURL(url string, params []byte) []byte {
func
getParams
(
c
*
gin
.
Context
,
params
interface
{})
{
err
:=
c
.
BindJSON
(
params
)
if
err
!=
nil
{
log
.
P
rint
ln
(
err
)
log
.
P
anic
ln
(
err
)
}
}
...
...
@@ -69,11 +69,11 @@ func getChainParams(url string, params []byte, action string, resultObject Chain
}
err
:=
json
.
Unmarshal
(
result
,
resultObject
)
if
err
!=
nil
{
log
.
P
rint
ln
(
err
)
log
.
P
anic
ln
(
err
)
return
}
if
resultObject
.
GetError
()
!=
nil
{
log
.
P
rint
ln
(
resultObject
.
GetError
()
.
GetMessage
())
log
.
P
anic
ln
(
resultObject
.
GetError
()
.
GetMessage
())
return
}
}
controllers/mail.go
View file @
c948a641
...
...
@@ -30,6 +30,6 @@ func doSendMail(params *beans.SendMail) {
mail
.
SetBody
(
"text/html"
,
params
.
GetContent
())
send
:=
gomail
.
NewPlainDialer
(
cfg
.
Mail
.
Host
,
cfg
.
Mail
.
Port
,
cfg
.
Mail
.
User
,
cfg
.
Mail
.
Password
)
if
err
:=
send
.
DialAndSend
(
mail
);
err
!=
nil
{
log
.
Panic
(
err
)
log
.
Panic
ln
(
err
)
}
}
controllers/punchclock.go
View file @
c948a641
...
...
@@ -305,7 +305,7 @@ func doAddPunchclockOnChain(params *beans.PunchclockOnChain) *beans.GetPunchcloc
url
:=
cfg
.
Hyperledger
.
Host
+
"/api/Punchclock/"
jsonParams
,
err
:=
json
.
Marshal
(
params
)
if
err
!=
nil
{
log
.
P
rint
ln
(
err
)
log
.
P
anic
ln
(
err
)
}
punchclock
:=
&
beans
.
GetPunchclock
{}
getChainParams
(
url
,
jsonParams
,
"POST"
,
punchclock
)
...
...
@@ -321,7 +321,7 @@ func UploadDailyPunchclockData(c *gin.Context) {
if
employee
.
GetError
()
!=
nil
{
employee
=
doAddEmployeeOnChain
(
params
.
GetEmployee
())
if
employee
.
GetError
()
!=
nil
{
log
.
P
rint
ln
(
employee
.
GetError
()
.
GetMessage
())
log
.
P
anic
ln
(
employee
.
GetError
()
.
GetMessage
())
return
}
}
...
...
controllers/redis.go
View file @
c948a641
...
...
@@ -18,7 +18,7 @@ func GetRedis(c *gin.Context) {
client
:=
initRedis
()
value
,
err
:=
redis
.
String
(
client
.
Do
(
"get"
,
params
.
GetKey
()))
if
err
!=
nil
{
log
.
Panic
(
err
)
log
.
Panic
ln
(
err
)
}
defer
client
.
Close
()
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"value"
:
value
})
...
...
@@ -31,7 +31,7 @@ func SetRedis(c *gin.Context) {
client
:=
initRedis
()
value
,
err
:=
client
.
Do
(
"set"
,
params
.
GetKey
(),
params
.
GetValue
())
if
err
!=
nil
{
log
.
Panic
(
err
)
log
.
Panic
ln
(
err
)
}
defer
client
.
Close
()
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"success"
:
value
})
...
...
@@ -44,7 +44,7 @@ func IncrRedis(c *gin.Context) {
client
:=
initRedis
()
value
,
err
:=
client
.
Do
(
"incr"
,
params
.
GetKey
())
if
err
!=
nil
{
log
.
Panic
(
err
)
log
.
Panic
ln
(
err
)
}
defer
client
.
Close
()
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"value"
:
value
})
...
...
@@ -57,7 +57,7 @@ func DecrRedis(c *gin.Context) {
client
:=
initRedis
()
value
,
err
:=
client
.
Do
(
"decr"
,
params
.
GetKey
())
if
err
!=
nil
{
log
.
Panic
(
err
)
log
.
Panic
ln
(
err
)
}
defer
client
.
Close
()
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"value"
:
value
})
...
...
@@ -70,7 +70,7 @@ func HSetRedis(c *gin.Context) {
client
:=
initRedis
()
value
,
err
:=
client
.
Do
(
"hset"
,
params
.
GetKey
(),
params
.
GetHkey
(),
params
.
GetValue
())
if
err
!=
nil
{
log
.
Panic
(
err
)
log
.
Panic
ln
(
err
)
}
defer
client
.
Close
()
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"value"
:
value
})
...
...
@@ -83,7 +83,7 @@ func HGetRedis(c *gin.Context) {
client
:=
initRedis
()
value
,
err
:=
redis
.
String
(
client
.
Do
(
"hget"
,
params
.
GetKey
(),
params
.
GetHkey
()))
if
err
!=
nil
{
log
.
Panic
(
err
)
log
.
Panic
ln
(
err
)
}
defer
client
.
Close
()
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"value"
:
value
})
...
...
@@ -96,7 +96,7 @@ func SAddRedis(c *gin.Context) {
client
:=
initRedis
()
value
,
err
:=
client
.
Do
(
"sadd"
,
params
.
GetKey
(),
params
.
GetValue
())
if
err
!=
nil
{
log
.
Panic
(
err
)
log
.
Panic
ln
(
err
)
}
defer
client
.
Close
()
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"value"
:
value
})
...
...
@@ -109,7 +109,7 @@ func SCardRedis(c *gin.Context) {
client
:=
initRedis
()
value
,
err
:=
client
.
Do
(
"scard"
,
params
.
GetKey
())
if
err
!=
nil
{
log
.
Panic
(
err
)
log
.
Panic
ln
(
err
)
}
defer
client
.
Close
()
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"value"
:
value
})
...
...
@@ -122,7 +122,7 @@ func LPushRedis(c *gin.Context) {
client
:=
initRedis
()
value
,
err
:=
client
.
Do
(
"lpush"
,
params
.
GetKey
(),
params
.
GetValue
())
if
err
!=
nil
{
log
.
Panic
(
err
)
log
.
Panic
ln
(
err
)
}
defer
client
.
Close
()
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"value"
:
value
})
...
...
@@ -135,7 +135,7 @@ func RPushRedis(c *gin.Context) {
client
:=
initRedis
()
value
,
err
:=
client
.
Do
(
"rpush"
,
params
.
GetKey
(),
params
.
GetValue
())
if
err
!=
nil
{
log
.
Panic
(
err
)
log
.
Panic
ln
(
err
)
}
defer
client
.
Close
()
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"value"
:
value
})
...
...
@@ -148,7 +148,7 @@ func LSetRedis(c *gin.Context) {
client
:=
initRedis
()
value
,
err
:=
client
.
Do
(
"lset"
,
params
.
GetKey
(),
params
.
GetHkey
(),
params
.
GetValue
())
if
err
!=
nil
{
log
.
Panic
(
err
)
log
.
Panic
ln
(
err
)
}
defer
client
.
Close
()
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"value"
:
value
})
...
...
@@ -164,7 +164,7 @@ func LRangeRedis(c *gin.Context) {
client
:=
initRedis
()
value
,
err
:=
redis
.
Strings
(
client
.
Do
(
"lrange"
,
params
.
GetKey
(),
begin
,
end
))
if
err
!=
nil
{
log
.
Panic
(
err
)
log
.
Panic
ln
(
err
)
}
defer
client
.
Close
()
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"value"
:
value
})
...
...
@@ -173,7 +173,7 @@ func LRangeRedis(c *gin.Context) {
func
initRedis
()
redis
.
Conn
{
client
,
err
:=
redis
.
Dial
(
cfg
.
Redis
.
Protocol
,
cfg
.
Redis
.
Host
)
if
err
!=
nil
{
log
.
Panic
(
err
)
log
.
Panic
ln
(
err
)
}
return
client
}
models/holiday.go
View file @
c948a641
...
...
@@ -22,7 +22,7 @@ func GetHoliday() []*Holiday {
list
:=
[]
*
Holiday
{}
err
:=
db
.
Db
.
Where
(
"is_holiday = ?"
,
1
)
.
Order
(
"date desc"
)
.
Find
(
&
list
)
.
Error
if
err
!=
nil
{
log
.
Fatal
(
err
)
log
.
Panicln
(
err
)
}
return
list
}
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