Skip to main content

类/定时器

示例:类/定时类

1.触发器使用类

触发器可以直接调用CCService类中的方法,无需实例化CCService对象。这是因为触发器由cloudcc平台动态进行编译,因此触发器可以直接对类进行调用。在触发器中调用,写法同java调用方法。

2.自定义类使用类

自定义类调用该类,需要使用PageClsInvoker类的invoker()方法。PageClsInvoker类是一个包装类,用于将自定义类的方法包装成函数,使自定义类可以直接调用。

// 自定义类中调用自定义类的方法
PageClsInvoker.invoker("Hello","test5",userInfo,map);

详细方法:调用自定义类的方法,需要使用PageClsInvoker类的invoker()方法。

invoker()方法有两个重载版本:

Object invoker(String calssname, String method, List<Map> conlist, List<Map> arglist);
Object invoker(String calssname, String method, List<Map> conlist, Map map);

参数说明:

  • calssname:自定义类的名称。
  • method:需要调用的自定义类的方法名称。
  • conlist:调用的自定义类的构造器参数。如果没有,则可传null。
    • argType:参数类型
    • argValue:参数值
  • arglist:调用的自定义类的方法的参数。如果没有,则可传null。
    • argType:参数类型
    • argValue:参数

使用Object invoker(String calssname, String method, List<Map> conlist, Map map);

public class Hello{

    public Hello(){}
    
    public Hello(UserInfo userInfo){
        System.out.print("测试");
    }
    
    public void test5(Map map) throws Exception{
        System.out.print("获取map中的值"+map.get(“name”));
    }
}
  • 在自定义类中可以通过这样调用:
List<Map> conlist = new ArrayList<Map>();

Map c = new HashMap();
c.put("argType",UserInfo.class);
c.put("argValue",userInfo);
conlist.add(c); 

Map m = new HashMap();
m.put("name",”Alex”); 

new PageClsInvoker(userInfo).invoker("Hello","test5",conlist,m);

使用Object invoker(String calssname, String method, List<Map> conlist, List<Map> arglist);

public class Hello{

    public Hello(){}
    
    public ServiceResult test3(UserInfo userInfo,String leadName) throws Exception{
        CCService cs = new CCService((UserInfo)userInfo);
        CCObject co = new CCObject("Lead");
        co.put("name",name);
        ServiceResult sr = cs.insert(co);return sr;
     }
}
  • 在自定义类中可以通过这样调用:
List<Map> arglist = new ArrayList<Map>();

Map c = new HashMap();
c.put("argType",UserInfo.class);
c.put("argValue",userInfo);
arglist.add(c);

Map n = new HashMap();
n.put("argType",String.class);
n.put("argValue",”Alex”);
arglist.add(n); 

new PageClsInvoker(userInfo).invoker("Hello","test5",null, arglist);