📄 testrightdelegate.java
字号:
System.out.println("成功与否 : "+state.isOK());
System.out.println("-----------------");
System.out.println("一共用时为 : "+(l2-l1));
}
public final void testUpdateRole() {
logger.debug("testUpdateRole");
long l1=System.currentTimeMillis();
Role role=new Role();
String id="35605a-112a9455bed--8000";
role.setId(id);
role.setEnabled("1");
role.setName("name11");
role.setRoleType("type11");
role.setNote("note11");
//pring your code
//
Role role1=BeanFactory.getInstance().getRightDelegate().findRoleById(id, state);
BeanFactory.getInstance().getRightDelegate().updateRole(role, state);
long l2=System.currentTimeMillis();
System.out.println("成功与否 : "+state.isOK());
System.out.println("-----------------");
System.out.println("一共用时为 : "+(l2-l1));
}
public final void findAllRole() {
logger.debug("findAllRole");
long l1=System.currentTimeMillis();
String curPage = "2";
String myaction="xxx.do?"; //Struts action的名字,看工具条的提示
String myform="forms[0]"; //html 里面相应的form的名字
CriteriaQuery cq=new CriteriaQuery(Role.class,curPage,myaction,myform); //Role.class为指定的类
cq.setPageSize(2); //不填默认为10
cq.setCurPage(curPage); //当前页,默认是第一页
cq.addOrder("asc","id"); //根据id来排序,顺序是asc,或者是desc
cq.like("name", "ROLE_SUPERVISOR"); //条件0是name='test',其余大于小于like调用相应的API
cq.eq("enabled", "1");//1 //条件1
cq.eq("roleType", "ROLE_SUPERVISOR");//条件2
//cq.add(); //条件1&&条件2
cq.add(cq.or(cq.and(cq, 0, 1), cq, 2));
//cq.add(); //增加条件,如果没有条件之间的关系则可以直接add()不带参数。
PageSupport ps=BeanFactory.getInstance().getRightDelegate().findAllRole(cq,state);
long l2=System.currentTimeMillis();
System.out.println("list size: "+ps.getResultList().size());
System.out.println("一共用时为 : "+(l2-l1));
for(int i=0;i<ps.getResultList().size();i++){
Role role=(Role)ps.getResultList().get(i);
System.out.println("id = "+ role.getId());
//print your code here
System.out.println("-----------------");
}
AppUtils.printCollection(ps.getResultList());
System.out.println(ps.getToolBar());
}
public final void testFindRoleById() {
logger.debug("testFindRoleById");
long l1=System.currentTimeMillis();
String id="1";
Role role=BeanFactory.getInstance().getRightDelegate().findRoleById(id, state);
long l2=System.currentTimeMillis();
System.out.println("id = "+ role.getId());
System.out.println("RoleType = "+ role.getRoleType());
//print your code here
System.out.println("--------------finish----------------");
System.out.println("一共用时为 : "+(l2-l1));
}
public final void testFindAllRole() {
logger.debug("testFindAllRole");
long l1=System.currentTimeMillis();
String myaction="roleList.do";
String curPageNO = "1";
CriteriaQuery cq=new CriteriaQuery(Role.class,curPageNO,myaction);
cq.setPageSize(10);
PageSupport ps=BeanFactory.getInstance().getRightDelegate().findAllRole(cq, state);
long l2=System.currentTimeMillis();
AppUtils.printCollection(ps.getResultList());
System.out.println("--------------finish----------------");
System.out.println("一共用时为 : "+(l2-l1));
}
public final void testfindRoleByFunction() {
logger.debug("testFindRoleById");
long l1=System.currentTimeMillis();
String functionId="8";
List roles=BeanFactory.getInstance().getRightDelegate().findRoleByFunction(functionId, state);
long l2=System.currentTimeMillis();
if(roles!=null){
Iterator iterator=roles.iterator();
while(iterator.hasNext()){
Role cp=(Role)iterator.next();
System.out.println("cp = "+cp);
System.out.println("cp.getContactPersonId= "+cp.getId());
System.out.println("cp.getName = "+cp.getName());
System.out.println("cp.getUserpwd = "+cp.getNote());
System.out.println("-----------------");
}
}else
System.out.println("--------------result is null----------------");
System.out.println("一共用时为 : "+(l2-l1));
}
public final void testfindRoleByUser() {
logger.debug("testfindRoleByUser");
long l1=System.currentTimeMillis();
String userId="10";
List roles=BeanFactory.getInstance().getRightDelegate().findRoleByUser(userId, state);
long l2=System.currentTimeMillis();
if(roles!=null){
Iterator iterator=roles.iterator();
while(iterator.hasNext()){
Role cp=(Role)iterator.next();
System.out.println("cp = "+cp);
System.out.println("cp.getContactPersonId= "+cp.getId());
System.out.println("cp.getName = "+cp.getName());
System.out.println("cp.getUserpwd = "+cp.getNote());
System.out.println("-----------------");
}
}else
System.out.println("--------------result is null----------------");
System.out.println("state = "+state.getErrCode());
System.out.println("isOK = "+state.isOK());
System.out.println("一共用时为 : "+(l2-l1));
}
public final void testfindFunctionByRole() {
logger.debug("testfindFunctionByRole");
long l1=System.currentTimeMillis();
String roleId="2";
List functions=BeanFactory.getInstance().getRightDelegate().findFunctionByRoleId(roleId, state);
long l2=System.currentTimeMillis();
if(functions!=null){
Iterator iterator=functions.iterator();
while(iterator.hasNext()){
Function o=(Function)iterator.next();
System.out.println("o = "+o);
System.out.println("getId = "+o.getId());
System.out.println("getName = "+o.getName());
System.out.println("getParentName = "+o.getParentName());
System.out.println("-----------------");
}
}else
System.out.println("--------------result is null----------------");
System.out.println("一共用时为 : "+(l2-l1));
}
public final void testfindFunctionByUser() {
logger.debug("testfindFunctionByRole");
long l1=System.currentTimeMillis();
String userId=null;
List functions=BeanFactory.getInstance().getRightDelegate().findFunctionByUser(userId, state);
long l2=System.currentTimeMillis();
if(functions!=null){
Iterator iterator=functions.iterator();
while(iterator.hasNext()){
Function o=(Function)iterator.next();
System.out.println("o = "+o);
System.out.println("getId = "+o.getId());
System.out.println("getName = "+o.getName());
System.out.println("getParentName = "+o.getParentName());
System.out.println("-----------------");
}
}else
System.out.println("--------------result is null----------------");
System.out.println("一共用时为 : "+(l2-l1));
}
public final void testfindOtherFunctionByRole() {
logger.debug("testfindFunctionByRole");
long l1=System.currentTimeMillis();
String roleId="2";
List functions=BeanFactory.getInstance().getRightDelegate().findOtherFunctionByRoleId(roleId, state);
long l2=System.currentTimeMillis();
if(functions!=null){
Iterator iterator=functions.iterator();
while(iterator.hasNext()){
Function o=(Function)iterator.next();
System.out.println("o = "+o);
System.out.println("getId = "+o.getId());
System.out.println("getName = "+o.getName());
System.out.println("getParentName = "+o.getParentName());
System.out.println("-----------------");
}
}else
System.out.println("--------------result is null----------------");
System.out.println("一共用时为 : "+(l2-l1));
}
public final void testfindOtherFunctionByHql() {
logger.debug("testfindFunctionByRole");
long l1=System.currentTimeMillis();
//String queryString="from Function where id not in (select f.id from Role r,Permission p,Function f where r.id=p.id.roleId and f.id=p.id.functionId and r.id = 1)";
String queryString="from Function where id=?";
HqlQuery hqlQuery=new HqlQuery("myaction");
hqlQuery.setCurPage("1");
//hqlQuery.setPageSize(10);
PageSupport functions=BeanFactory.getInstance().getRightDelegate().findOtherFunctionByHql(hqlQuery,"1", state);
long l2=System.currentTimeMillis();
AppUtils.printCollection(functions.getResultList());
List list=functions.getResultList();
for(int i=0;i<list.size();i++){
Function f=(Function)list.get(i);
System.out.println("getId = "+f.getId());
}
System.out.println("一共用时为 : "+(l2-l1));
}
public final void testFindOtherRoleByUser() {
logger.debug("testFindOtherRoleByUser");
long l1=System.currentTimeMillis();
HqlQuery hqlQuery=new HqlQuery("myaction");
//hqlQuery.setCurPage("1");
//hqlQuery.setPageSize(10);
PageSupport roles=BeanFactory.getInstance().getRightDelegate().findOtherRoleByUser(hqlQuery,"1", state);
long l2=System.currentTimeMillis();
AppUtils.printCollection(roles.getResultList());
List list=roles.getResultList();
for(int i=0;i<list.size();i++){
Role r=(Role)list.get(i);
System.out.println("getId = "+r.getId());
}
System.out.println("一共用时为 : "+(l2-l1));
}
public final void testFindAllUser() {
logger.debug("testFindAllUser");
long l1=System.currentTimeMillis();
String myaction="usersList.do";
String curPageNO = "2";
CriteriaQuery cq=new CriteriaQuery(User.class,curPageNO,myaction);
cq.setPageSize(2);
PageSupport ps=BeanFactory.getInstance().getRightDelegate().findAllUser(cq, state);
long l2=System.currentTimeMillis();
AppUtils.printCollection(ps.getResultList());
System.out.println(ps.getToolBar());
System.out.println("--------------finish----------------");
System.out.println("一共用时为 : "+(l2-l1));
}
public final void testFindUserById() {
logger.debug("testFindUserById");
long l1=System.currentTimeMillis();
User user=BeanFactory.getInstance().getRightDelegate().findUserById("1", state);
long l2=System.currentTimeMillis();
System.out.println(user);
System.out.println(user.getName());
System.out.println("一共用时为 : "+(l2-l1));
}
public final void testIsUserExist() {
logger.debug("testIsUserExist");
System.out.println("-----------------");
long l1=System.currentTimeMillis();
boolean b = BeanFactory.getInstance().getRightDelegate().isUserExist("root", state);
System.out.println(" b = "+b);
long l2=System.currentTimeMillis();
System.out.println("-----------------");
System.out.println("一共用时为 : "+(l2-l1));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -