Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
2db8c753
Commit
2db8c753
authored
Mar 25, 2016
by
JessonChan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bee fix
parent
94bde3a7
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
42 additions
and
41 deletions
+42
-41
cache_test.go
cache/cache_test.go
+7
-7
memcache_test.go
cache/memcache/memcache_test.go
+4
-4
redis_test.go
cache/redis/redis_test.go
+4
-4
ssdb_test.go
cache/ssdb/ssdb_test.go
+4
-4
input_test.go
context/input_test.go
+1
-1
migration.go
migration/migration.go
+17
-17
captcha.go
utils/captcha/captcha.go
+4
-3
controller.go
utils/pagination/controller.go
+1
-1
No files found.
cache/cache_test.go
View file @
2db8c753
...
...
@@ -26,7 +26,7 @@ func TestCache(t *testing.T) {
t
.
Error
(
"init err"
)
}
timeoutDuration
:=
10
*
time
.
Second
if
err
=
bm
.
Put
(
"astaxie"
,
1
,
timeoutDuration
);
err
!=
nil
{
if
err
=
bm
.
Put
(
"astaxie"
,
1
,
timeoutDuration
*
time
.
Second
);
err
!=
nil
{
t
.
Error
(
"set Error"
,
err
)
}
if
!
bm
.
IsExist
(
"astaxie"
)
{
...
...
@@ -43,7 +43,7 @@ func TestCache(t *testing.T) {
t
.
Error
(
"check err"
)
}
if
err
=
bm
.
Put
(
"astaxie"
,
1
,
timeoutDuration
);
err
!=
nil
{
if
err
=
bm
.
Put
(
"astaxie"
,
1
,
timeoutDuration
*
time
.
Second
);
err
!=
nil
{
t
.
Error
(
"set Error"
,
err
)
}
...
...
@@ -68,7 +68,7 @@ func TestCache(t *testing.T) {
}
//test GetMulti
if
err
=
bm
.
Put
(
"astaxie"
,
"author"
,
timeoutDuration
);
err
!=
nil
{
if
err
=
bm
.
Put
(
"astaxie"
,
"author"
,
timeoutDuration
*
time
.
Second
);
err
!=
nil
{
t
.
Error
(
"set Error"
,
err
)
}
if
!
bm
.
IsExist
(
"astaxie"
)
{
...
...
@@ -78,7 +78,7 @@ func TestCache(t *testing.T) {
t
.
Error
(
"get err"
)
}
if
err
=
bm
.
Put
(
"astaxie1"
,
"author1"
,
timeoutDuration
);
err
!=
nil
{
if
err
=
bm
.
Put
(
"astaxie1"
,
"author1"
,
timeoutDuration
*
time
.
Second
);
err
!=
nil
{
t
.
Error
(
"set Error"
,
err
)
}
if
!
bm
.
IsExist
(
"astaxie1"
)
{
...
...
@@ -103,7 +103,7 @@ func TestFileCache(t *testing.T) {
t
.
Error
(
"init err"
)
}
timeoutDuration
:=
10
*
time
.
Second
if
err
=
bm
.
Put
(
"astaxie"
,
1
,
timeoutDuration
);
err
!=
nil
{
if
err
=
bm
.
Put
(
"astaxie"
,
1
,
timeoutDuration
*
time
.
Second
);
err
!=
nil
{
t
.
Error
(
"set Error"
,
err
)
}
if
!
bm
.
IsExist
(
"astaxie"
)
{
...
...
@@ -135,7 +135,7 @@ func TestFileCache(t *testing.T) {
}
//test string
if
err
=
bm
.
Put
(
"astaxie"
,
"author"
,
timeoutDuration
);
err
!=
nil
{
if
err
=
bm
.
Put
(
"astaxie"
,
"author"
,
timeoutDuration
*
time
.
Second
);
err
!=
nil
{
t
.
Error
(
"set Error"
,
err
)
}
if
!
bm
.
IsExist
(
"astaxie"
)
{
...
...
@@ -146,7 +146,7 @@ func TestFileCache(t *testing.T) {
}
//test GetMulti
if
err
=
bm
.
Put
(
"astaxie1"
,
"author1"
,
timeoutDuration
);
err
!=
nil
{
if
err
=
bm
.
Put
(
"astaxie1"
,
"author1"
,
timeoutDuration
*
time
.
Second
);
err
!=
nil
{
t
.
Error
(
"set Error"
,
err
)
}
if
!
bm
.
IsExist
(
"astaxie1"
)
{
...
...
cache/memcache/memcache_test.go
View file @
2db8c753
...
...
@@ -30,7 +30,7 @@ func TestMemcacheCache(t *testing.T) {
t
.
Error
(
"init err"
)
}
timeoutDuration
:=
10
*
time
.
Second
if
err
=
bm
.
Put
(
"astaxie"
,
"1"
,
timeoutDuration
);
err
!=
nil
{
if
err
=
bm
.
Put
(
"astaxie"
,
"1"
,
timeoutDuration
*
time
.
Second
);
err
!=
nil
{
t
.
Error
(
"set Error"
,
err
)
}
if
!
bm
.
IsExist
(
"astaxie"
)
{
...
...
@@ -42,7 +42,7 @@ func TestMemcacheCache(t *testing.T) {
if
bm
.
IsExist
(
"astaxie"
)
{
t
.
Error
(
"check err"
)
}
if
err
=
bm
.
Put
(
"astaxie"
,
"1"
,
timeoutDuration
);
err
!=
nil
{
if
err
=
bm
.
Put
(
"astaxie"
,
"1"
,
timeoutDuration
*
time
.
Second
);
err
!=
nil
{
t
.
Error
(
"set Error"
,
err
)
}
...
...
@@ -71,7 +71,7 @@ func TestMemcacheCache(t *testing.T) {
}
//test string
if
err
=
bm
.
Put
(
"astaxie"
,
"author"
,
timeoutDuration
);
err
!=
nil
{
if
err
=
bm
.
Put
(
"astaxie"
,
"author"
,
timeoutDuration
*
time
.
Second
);
err
!=
nil
{
t
.
Error
(
"set Error"
,
err
)
}
if
!
bm
.
IsExist
(
"astaxie"
)
{
...
...
@@ -83,7 +83,7 @@ func TestMemcacheCache(t *testing.T) {
}
//test GetMulti
if
err
=
bm
.
Put
(
"astaxie1"
,
"author1"
,
timeoutDuration
);
err
!=
nil
{
if
err
=
bm
.
Put
(
"astaxie1"
,
"author1"
,
timeoutDuration
*
time
.
Second
);
err
!=
nil
{
t
.
Error
(
"set Error"
,
err
)
}
if
!
bm
.
IsExist
(
"astaxie1"
)
{
...
...
cache/redis/redis_test.go
View file @
2db8c753
...
...
@@ -29,7 +29,7 @@ func TestRedisCache(t *testing.T) {
t
.
Error
(
"init err"
)
}
timeoutDuration
:=
10
*
time
.
Second
if
err
=
bm
.
Put
(
"astaxie"
,
1
,
timeoutDuration
);
err
!=
nil
{
if
err
=
bm
.
Put
(
"astaxie"
,
1
,
timeoutDuration
*
time
.
Second
);
err
!=
nil
{
t
.
Error
(
"set Error"
,
err
)
}
if
!
bm
.
IsExist
(
"astaxie"
)
{
...
...
@@ -41,7 +41,7 @@ func TestRedisCache(t *testing.T) {
if
bm
.
IsExist
(
"astaxie"
)
{
t
.
Error
(
"check err"
)
}
if
err
=
bm
.
Put
(
"astaxie"
,
1
,
timeoutDuration
);
err
!=
nil
{
if
err
=
bm
.
Put
(
"astaxie"
,
1
,
timeoutDuration
*
time
.
Second
);
err
!=
nil
{
t
.
Error
(
"set Error"
,
err
)
}
...
...
@@ -70,7 +70,7 @@ func TestRedisCache(t *testing.T) {
}
//test string
if
err
=
bm
.
Put
(
"astaxie"
,
"author"
,
timeoutDuration
);
err
!=
nil
{
if
err
=
bm
.
Put
(
"astaxie"
,
"author"
,
timeoutDuration
*
time
.
Second
);
err
!=
nil
{
t
.
Error
(
"set Error"
,
err
)
}
if
!
bm
.
IsExist
(
"astaxie"
)
{
...
...
@@ -82,7 +82,7 @@ func TestRedisCache(t *testing.T) {
}
//test GetMulti
if
err
=
bm
.
Put
(
"astaxie1"
,
"author1"
,
timeoutDuration
);
err
!=
nil
{
if
err
=
bm
.
Put
(
"astaxie1"
,
"author1"
,
timeoutDuration
*
time
.
Second
);
err
!=
nil
{
t
.
Error
(
"set Error"
,
err
)
}
if
!
bm
.
IsExist
(
"astaxie1"
)
{
...
...
cache/ssdb/ssdb_test.go
View file @
2db8c753
...
...
@@ -19,7 +19,7 @@ func TestSsdbcacheCache(t *testing.T) {
}
timeoutDuration
:=
10
*
time
.
Second
//timeoutDuration := -10*time.Second if timeoutDuration is negtive,it means permanent
if
err
=
ssdb
.
Put
(
"ssdb"
,
"ssdb"
,
timeoutDuration
);
err
!=
nil
{
if
err
=
ssdb
.
Put
(
"ssdb"
,
"ssdb"
,
timeoutDuration
*
time
.
Second
);
err
!=
nil
{
t
.
Error
(
"set Error"
,
err
)
}
if
!
ssdb
.
IsExist
(
"ssdb"
)
{
...
...
@@ -27,7 +27,7 @@ func TestSsdbcacheCache(t *testing.T) {
}
// Get test done
if
err
=
ssdb
.
Put
(
"ssdb"
,
"ssdb"
,
timeoutDuration
);
err
!=
nil
{
if
err
=
ssdb
.
Put
(
"ssdb"
,
"ssdb"
,
timeoutDuration
*
time
.
Second
);
err
!=
nil
{
t
.
Error
(
"set Error"
,
err
)
}
...
...
@@ -36,7 +36,7 @@ func TestSsdbcacheCache(t *testing.T) {
}
//inc/dec test done
if
err
=
ssdb
.
Put
(
"ssdb"
,
"2"
,
timeoutDuration
);
err
!=
nil
{
if
err
=
ssdb
.
Put
(
"ssdb"
,
"2"
,
timeoutDuration
*
time
.
Second
);
err
!=
nil
{
t
.
Error
(
"set Error"
,
err
)
}
if
err
=
ssdb
.
Incr
(
"ssdb"
);
err
!=
nil
{
...
...
@@ -52,7 +52,7 @@ func TestSsdbcacheCache(t *testing.T) {
}
// test del
if
err
=
ssdb
.
Put
(
"ssdb"
,
"3"
,
timeoutDuration
);
err
!=
nil
{
if
err
=
ssdb
.
Put
(
"ssdb"
,
"3"
,
timeoutDuration
*
time
.
Second
);
err
!=
nil
{
t
.
Error
(
"set Error"
,
err
)
}
if
v
,
err
:=
strconv
.
Atoi
(
ssdb
.
Get
(
"ssdb"
)
.
(
string
));
err
!=
nil
||
v
!=
3
{
...
...
context/input_test.go
View file @
2db8c753
...
...
@@ -100,7 +100,7 @@ func TestSubDomain(t *testing.T) {
/* TODO Fix this
r, _ = http.NewRequest("GET", "http://127.0.0.1/", nil)
beegoInput.Request = r
beegoInput.
Context.
Request = r
if beegoInput.SubDomains() != "" {
t.Fatal("Subdomain parse error, got " + beegoInput.SubDomains())
}
...
...
migration/migration.go
View file @
2db8c753
...
...
@@ -33,7 +33,7 @@ import (
"strings"
"time"
"github.com/astaxie/beego"
"github.com/astaxie/beego
/logs
"
"github.com/astaxie/beego/orm"
)
...
...
@@ -90,7 +90,7 @@ func (m *Migration) Reset() {
func
(
m
*
Migration
)
Exec
(
name
,
status
string
)
error
{
o
:=
orm
.
NewOrm
()
for
_
,
s
:=
range
m
.
sqls
{
beego
.
Info
(
"exec sql:"
,
s
)
logs
.
Info
(
"exec sql:"
,
s
)
r
:=
o
.
Raw
(
s
)
_
,
err
:=
r
.
Exec
()
if
err
!=
nil
{
...
...
@@ -144,20 +144,20 @@ func Upgrade(lasttime int64) error {
i
:=
0
for
_
,
v
:=
range
sm
{
if
v
.
created
>
lasttime
{
beego
.
Info
(
"start upgrade"
,
v
.
name
)
logs
.
Info
(
"start upgrade"
,
v
.
name
)
v
.
m
.
Reset
()
v
.
m
.
Up
()
err
:=
v
.
m
.
Exec
(
v
.
name
,
"up"
)
if
err
!=
nil
{
beego
.
Error
(
"execute error:"
,
err
)
logs
.
Error
(
"execute error:"
,
err
)
time
.
Sleep
(
2
*
time
.
Second
)
return
err
}
beego
.
Info
(
"end upgrade:"
,
v
.
name
)
logs
.
Info
(
"end upgrade:"
,
v
.
name
)
i
++
}
}
beego
.
Info
(
"total success upgrade:"
,
i
,
" migration"
)
logs
.
Info
(
"total success upgrade:"
,
i
,
" migration"
)
time
.
Sleep
(
2
*
time
.
Second
)
return
nil
}
...
...
@@ -165,20 +165,20 @@ func Upgrade(lasttime int64) error {
// Rollback rollback the migration by the name
func
Rollback
(
name
string
)
error
{
if
v
,
ok
:=
migrationMap
[
name
];
ok
{
beego
.
Info
(
"start rollback"
)
logs
.
Info
(
"start rollback"
)
v
.
Reset
()
v
.
Down
()
err
:=
v
.
Exec
(
name
,
"down"
)
if
err
!=
nil
{
beego
.
Error
(
"execute error:"
,
err
)
logs
.
Error
(
"execute error:"
,
err
)
time
.
Sleep
(
2
*
time
.
Second
)
return
err
}
beego
.
Info
(
"end rollback"
)
logs
.
Info
(
"end rollback"
)
time
.
Sleep
(
2
*
time
.
Second
)
return
nil
}
beego
.
Error
(
"not exist the migrationMap name:"
+
name
)
logs
.
Error
(
"not exist the migrationMap name:"
+
name
)
time
.
Sleep
(
2
*
time
.
Second
)
return
errors
.
New
(
"not exist the migrationMap name:"
+
name
)
}
...
...
@@ -191,23 +191,23 @@ func Reset() error {
for
j
:=
len
(
sm
)
-
1
;
j
>=
0
;
j
--
{
v
:=
sm
[
j
]
if
isRollBack
(
v
.
name
)
{
beego
.
Info
(
"skip the"
,
v
.
name
)
logs
.
Info
(
"skip the"
,
v
.
name
)
time
.
Sleep
(
1
*
time
.
Second
)
continue
}
beego
.
Info
(
"start reset:"
,
v
.
name
)
logs
.
Info
(
"start reset:"
,
v
.
name
)
v
.
m
.
Reset
()
v
.
m
.
Down
()
err
:=
v
.
m
.
Exec
(
v
.
name
,
"down"
)
if
err
!=
nil
{
beego
.
Error
(
"execute error:"
,
err
)
logs
.
Error
(
"execute error:"
,
err
)
time
.
Sleep
(
2
*
time
.
Second
)
return
err
}
i
++
beego
.
Info
(
"end reset:"
,
v
.
name
)
logs
.
Info
(
"end reset:"
,
v
.
name
)
}
beego
.
Info
(
"total success reset:"
,
i
,
" migration"
)
logs
.
Info
(
"total success reset:"
,
i
,
" migration"
)
time
.
Sleep
(
2
*
time
.
Second
)
return
nil
}
...
...
@@ -216,7 +216,7 @@ func Reset() error {
func
Refresh
()
error
{
err
:=
Reset
()
if
err
!=
nil
{
beego
.
Error
(
"execute error:"
,
err
)
logs
.
Error
(
"execute error:"
,
err
)
time
.
Sleep
(
2
*
time
.
Second
)
return
err
}
...
...
@@ -265,7 +265,7 @@ func isRollBack(name string) bool {
var
maps
[]
orm
.
Params
num
,
err
:=
o
.
Raw
(
"select * from migrations where `name` = ? order by id_migration desc"
,
name
)
.
Values
(
&
maps
)
if
err
!=
nil
{
beego
.
Info
(
"get name has error"
,
err
)
logs
.
Info
(
"get name has error"
,
err
)
return
false
}
if
num
<=
0
{
...
...
utils/captcha/captcha.go
View file @
2db8c753
...
...
@@ -69,6 +69,7 @@ import (
"github.com/astaxie/beego"
"github.com/astaxie/beego/cache"
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/utils"
)
...
...
@@ -139,7 +140,7 @@ func (c *Captcha) Handler(ctx *context.Context) {
if
err
:=
c
.
store
.
Put
(
key
,
chars
,
c
.
Expiration
);
err
!=
nil
{
ctx
.
Output
.
SetStatus
(
500
)
ctx
.
WriteString
(
"captcha reload error"
)
beego
.
Error
(
"Reload Create Captcha Error:"
,
err
)
logs
.
Error
(
"Reload Create Captcha Error:"
,
err
)
return
}
}
else
{
...
...
@@ -154,7 +155,7 @@ func (c *Captcha) Handler(ctx *context.Context) {
img
:=
NewImage
(
chars
,
c
.
StdWidth
,
c
.
StdHeight
)
if
_
,
err
:=
img
.
WriteTo
(
ctx
.
ResponseWriter
);
err
!=
nil
{
beego
.
Error
(
"Write Captcha Image Error:"
,
err
)
logs
.
Error
(
"Write Captcha Image Error:"
,
err
)
}
}
...
...
@@ -162,7 +163,7 @@ func (c *Captcha) Handler(ctx *context.Context) {
func
(
c
*
Captcha
)
CreateCaptchaHTML
()
template
.
HTML
{
value
,
err
:=
c
.
CreateCaptcha
()
if
err
!=
nil
{
beego
.
Error
(
"Create Captcha Error:"
,
err
)
logs
.
Error
(
"Create Captcha Error:"
,
err
)
return
""
}
...
...
utils/pagination/controller.go
View file @
2db8c753
...
...
@@ -18,7 +18,7 @@ import (
"github.com/astaxie/beego/context"
)
// SetPaginator Instantiates a Paginator and assigns it to context.Input.Data
["paginator"]
.
// SetPaginator Instantiates a Paginator and assigns it to context.Input.Data
("paginator")
.
func
SetPaginator
(
context
*
context
.
Context
,
per
int
,
nums
int64
)
(
paginator
*
Paginator
)
{
paginator
=
NewPaginator
(
context
.
Request
,
per
,
nums
)
context
.
Input
.
SetData
(
"paginator"
,
&
paginator
)
...
...
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