Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
9f69ba2b
C
cat
项目概览
梦中观雨
/
cat
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
cat
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9f69ba2b
编写于
5月 08, 2013
作者:
A
ainilife
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
New feature : suspend or resume an abtest
上级
d25b9443
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
127 addition
and
16 deletion
+127
-16
cat-home/src/main/java/com/dianping/cat/system/page/abtest/Handler.java
...ain/java/com/dianping/cat/system/page/abtest/Handler.java
+52
-3
cat-home/src/main/java/com/dianping/cat/system/page/abtest/Payload.java
...ain/java/com/dianping/cat/system/page/abtest/Payload.java
+19
-10
cat-home/src/main/resources/META-INF/dal/jdbc/abtest-dal.xml
cat-home/src/main/resources/META-INF/dal/jdbc/abtest-dal.xml
+7
-1
cat-home/src/main/webapp/js/abtestAllTest.js
cat-home/src/main/webapp/js/abtestAllTest.js
+31
-2
cat-home/src/main/webapp/jsp/system/abtestAllTest.jsp
cat-home/src/main/webapp/jsp/system/abtestAllTest.jsp
+18
-0
未找到文件。
cat-home/src/main/java/com/dianping/cat/system/page/abtest/Handler.java
浏览文件 @
9f69ba2b
...
@@ -9,6 +9,7 @@ import javax.servlet.ServletException;
...
@@ -9,6 +9,7 @@ import javax.servlet.ServletException;
import
org.unidal.dal.jdbc.DalException
;
import
org.unidal.dal.jdbc.DalException
;
import
org.unidal.lookup.annotation.Inject
;
import
org.unidal.lookup.annotation.Inject
;
import
org.unidal.web.mvc.ErrorObject
;
import
org.unidal.web.mvc.PageHandler
;
import
org.unidal.web.mvc.PageHandler
;
import
org.unidal.web.mvc.annotation.InboundActionMeta
;
import
org.unidal.web.mvc.annotation.InboundActionMeta
;
import
org.unidal.web.mvc.annotation.OutboundActionMeta
;
import
org.unidal.web.mvc.annotation.OutboundActionMeta
;
...
@@ -34,7 +35,55 @@ public class Handler implements PageHandler<Context> {
...
@@ -34,7 +35,55 @@ public class Handler implements PageHandler<Context> {
@PayloadMeta
(
Payload
.
class
)
@PayloadMeta
(
Payload
.
class
)
@InboundActionMeta
(
name
=
"abtest"
)
@InboundActionMeta
(
name
=
"abtest"
)
public
void
handleInbound
(
Context
ctx
)
throws
ServletException
,
IOException
{
public
void
handleInbound
(
Context
ctx
)
throws
ServletException
,
IOException
{
// TODO
Payload
payload
=
ctx
.
getPayload
();
Action
action
=
payload
.
getAction
();
if
(
action
==
Action
.
LIST
)
{
handleStatusChangeActions
(
ctx
);
}
}
private
void
handleStatusChangeActions
(
Context
ctx
)
{
Payload
payload
=
ctx
.
getPayload
();
ErrorObject
error
=
new
ErrorObject
(
"disable"
);
String
[]
ids
=
payload
.
getIds
();
if
(
ids
!=
null
&&
ids
.
length
!=
0
)
{
for
(
String
id
:
ids
)
{
System
.
out
.
println
(
"change status for "
+
id
);
try
{
int
intID
=
Integer
.
parseInt
(
id
);
Abtest
abtest
=
m_abtestDao
.
findByPK
(
intID
,
AbtestEntity
.
READSET_FULL
);
if
(
payload
.
getDisableAbtest
()
==
-
1
)
{
// suspend
if
(!
abtest
.
isDisabled
())
{
abtest
.
setDisabled
(
true
);
m_abtestDao
.
updateByPK
(
abtest
,
AbtestEntity
.
UPDATESET_DISABLE
);
}
else
{
error
.
addArgument
(
id
,
"Abtest "
+
id
+
" has been already suspended!"
);
}
}
else
if
(
payload
.
getDisableAbtest
()
==
1
)
{
// resume
if
(
abtest
.
isDisabled
())
{
abtest
.
setDisabled
(
false
);
m_abtestDao
.
updateByPK
(
abtest
,
AbtestEntity
.
UPDATESET_DISABLE
);
}
else
{
error
.
addArgument
(
id
,
"Abtest "
+
id
+
" has been already active!"
);
}
}
}
catch
(
NumberFormatException
e
)
{
// do nothing
}
catch
(
DalException
e
)
{
}
}
if
(
error
.
getArguments
().
isEmpty
())
{
ErrorObject
success
=
new
ErrorObject
(
"success"
);
ctx
.
addError
(
success
);
}
else
{
ctx
.
addError
(
error
);
}
}
}
}
@Override
@Override
...
@@ -122,10 +171,10 @@ public class Handler implements PageHandler<Context> {
...
@@ -122,10 +171,10 @@ public class Handler implements PageHandler<Context> {
int
fromIndex
=
(
payload
.
getPageNum
()
-
1
)
*
m_pageSize
;
int
fromIndex
=
(
payload
.
getPageNum
()
-
1
)
*
m_pageSize
;
int
toIndex
=
(
fromIndex
+
m_pageSize
)
<=
totalSize
?
(
fromIndex
+
m_pageSize
)
:
totalSize
;
int
toIndex
=
(
fromIndex
+
m_pageSize
)
<=
totalSize
?
(
fromIndex
+
m_pageSize
)
:
totalSize
;
for
(
int
i
=
fromIndex
;
i
<
toIndex
;
i
++)
{
for
(
int
i
=
fromIndex
;
i
<
toIndex
;
i
++)
{
reports
.
add
(
new
ABTestReport
(
entities
.
get
(
i
),
now
));
reports
.
add
(
new
ABTestReport
(
entities
.
get
(
i
),
now
));
}
}
model
.
setTotalPages
(
totalPages
);
model
.
setTotalPages
(
totalPages
);
model
.
setDate
(
now
);
model
.
setDate
(
now
);
model
.
setReports
(
reports
);
model
.
setReports
(
reports
);
...
...
cat-home/src/main/java/com/dianping/cat/system/page/abtest/Payload.java
浏览文件 @
9f69ba2b
...
@@ -18,8 +18,8 @@ public class Payload implements ActionPayload<SystemPage, Action> {
...
@@ -18,8 +18,8 @@ public class Payload implements ActionPayload<SystemPage, Action> {
@FieldMeta
(
"pageNum"
)
@FieldMeta
(
"pageNum"
)
private
int
m_pageNum
;
private
int
m_pageNum
;
@FieldMeta
(
"
enable
"
)
@FieldMeta
(
"
suspend
"
)
private
boolean
m_en
ableAbtest
;
private
int
m_dis
ableAbtest
;
@FieldMeta
(
"ids"
)
@FieldMeta
(
"ids"
)
private
String
m_ids
;
private
String
m_ids
;
...
@@ -75,16 +75,21 @@ public class Payload implements ActionPayload<SystemPage, Action> {
...
@@ -75,16 +75,21 @@ public class Payload implements ActionPayload<SystemPage, Action> {
m_page
=
SystemPage
.
getByName
(
page
,
SystemPage
.
ABTEST
);
m_page
=
SystemPage
.
getByName
(
page
,
SystemPage
.
ABTEST
);
}
}
public
boolean
isEn
ableAbtest
()
{
public
int
getDis
ableAbtest
()
{
return
m_en
ableAbtest
;
return
m_dis
ableAbtest
;
}
}
public
void
set
EnableAbtest
(
boolean
en
ableAbtest
)
{
public
void
set
DisableAbtest
(
int
dis
ableAbtest
)
{
m_enableAbtest
=
en
ableAbtest
;
m_disableAbtest
=
dis
ableAbtest
;
}
}
public
String
getIds
()
{
public
String
[]
getIds
()
{
return
m_ids
;
if
(
m_ids
!=
null
)
{
String
[]
ids
=
m_ids
.
split
(
"-"
);
return
ids
;
}
else
{
return
null
;
}
}
}
public
void
setIds
(
String
ids
)
{
public
void
setIds
(
String
ids
)
{
...
@@ -99,5 +104,9 @@ public class Payload implements ActionPayload<SystemPage, Action> {
...
@@ -99,5 +104,9 @@ public class Payload implements ActionPayload<SystemPage, Action> {
if
(
m_status
==
null
)
{
if
(
m_status
==
null
)
{
m_status
=
"all"
;
m_status
=
"all"
;
}
}
if
(
m_disableAbtest
!=
-
1
&&
m_disableAbtest
!=
1
)
{
m_disableAbtest
=
0
;
}
}
}
}
}
cat-home/src/main/resources/META-INF/dal/jdbc/abtest-dal.xml
浏览文件 @
9f69ba2b
...
@@ -3,7 +3,13 @@
...
@@ -3,7 +3,13 @@
<entity
name=
"abtest"
table=
"abtest"
alias=
"a"
>
<entity
name=
"abtest"
table=
"abtest"
alias=
"a"
>
<member
name=
"creation-date"
insert-expr=
"NOW()"
/>
<member
name=
"creation-date"
insert-expr=
"NOW()"
/>
<member
name=
"modify-date"
insert-expr=
"NOW()"
update-expr=
"NOW()"
/>
<member
name=
"modify-date"
insert-expr=
"NOW()"
update-expr=
"NOW()"
/>
<member
name=
"disabled"
field=
"isDisabled"
value-type=
"boolean"
length=
"3"
nullable=
"false"
/>
<member
name=
"disabled"
field=
"disabled"
value-type=
"boolean"
length=
"3"
nullable=
"false"
/>
<updatesets>
<updateset
name=
"DISABLE"
>
<member
name=
"disabled"
/>
<member
name=
"modify-date"
/>
</updateset>
</updatesets>
<query-defs>
<query-defs>
<query
name=
"find-all-abtest"
type=
"SELECT"
multiple=
"true"
>
<query
name=
"find-all-abtest"
type=
"SELECT"
multiple=
"true"
>
<statement>
<![CDATA[
<statement>
<![CDATA[
...
...
cat-home/src/main/webapp/js/abtestAllTest.js
浏览文件 @
9f69ba2b
...
@@ -7,7 +7,36 @@ $(document).ready(function() {
...
@@ -7,7 +7,36 @@ $(document).ready(function() {
}
}
});
});
$
(
"
#prevNavigation
"
).
click
(
function
(){
$
(
"
#btnSuspend
"
).
click
(
function
(){
//$(".pager .disabled").not("#prevNavigation").not("nextNavigation").next()
var
checkbox
=
$
(
"
.table input[type='checkbox']:checked
"
);
var
id
=
""
;
for
(
var
i
=
0
;
i
<
checkbox
.
length
;
i
++
){
id
=
id
+
$
(
"
:nth-child(2)
"
,
$
(
checkbox
[
i
]).
closest
(
'
tr
'
)).
html
()
+
"
-
"
;
}
url
=
window
.
location
.
href
;
index
=
url
.
indexOf
(
"
&suspend
"
);
if
(
index
!=
-
1
){
window
.
location
.
href
=
url
.
substring
(
0
,
index
)
+
"
&suspend=-1&ids=
"
+
id
;
}
else
{
window
.
location
.
href
=
url
+
"
&suspend=-1&ids=
"
+
id
;
}
loaction
.
reload
();
});
});
$
(
"
#btnResume
"
).
click
(
function
(){
var
checkbox
=
$
(
"
.table input[type='checkbox']:checked
"
);
var
id
=
""
;
for
(
var
i
=
0
;
i
<
checkbox
.
length
;
i
++
){
id
=
id
+
$
(
"
:nth-child(2)
"
,
$
(
checkbox
[
i
]).
closest
(
'
tr
'
)).
html
()
+
"
-
"
;
}
url
=
window
.
location
.
href
;
index
=
url
.
indexOf
(
"
&suspend
"
);
if
(
index
!=
-
1
){
window
.
location
.
href
=
url
.
substring
(
0
,
index
)
+
"
&suspend=1&ids=
"
+
id
;
}
else
{
window
.
location
.
href
=
url
+
"
&suspend=1&ids=
"
+
id
;
}
loaction
.
reload
();
});
});
});
\ No newline at end of file
cat-home/src/main/webapp/jsp/system/abtestAllTest.jsp
浏览文件 @
9f69ba2b
...
@@ -122,6 +122,24 @@
...
@@ -122,6 +122,24 @@
</div>
</div>
</div>
</div>
<div
class=
"span10 column"
>
<div
class=
"span10 column"
>
<c:if
test=
"
${
not
empty
ctx
.
errors
}
"
>
<c:forEach
var=
"item"
items=
"
${
ctx
.
errors
}
"
>
<c:if
test=
"
${
item
.
code
eq
'disable'
}
"
>
<div
id=
"alertDiv"
class=
"alert alert-error"
style=
" margin-bottom: 10px"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"alert"
>
×
</button>
<c:forEach
var=
"argument"
items=
"
${
item
.
arguments
}
"
>
<strong>
Error!
</strong>
<c:out
value=
"
${
argument
.
value
}
"
/><br>
</c:forEach>
</div>
</c:if>
<c:if
test=
"
${
item
.
code
eq
'success'
}
"
>
<div
id=
"alertDiv"
class=
"alert"
style=
" margin-bottom: 10px"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"alert alert-success"
>
×
</button>
<strong>
Success!
</strong>
</div>
</c:if>
</c:forEach>
</c:if>
<div
style=
"margin-bottom: 10px;"
>
<div
style=
"margin-bottom: 10px;"
>
<button
class=
"btn"
type=
"button"
>
<button
class=
"btn"
type=
"button"
>
<label
class=
"checkbox"
>
<input
id=
"ckall"
type=
"checkbox"
></input></label>
<label
class=
"checkbox"
>
<input
id=
"ckall"
type=
"checkbox"
></input></label>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录