常用场景:通过脚本直接在前台操作表单生成用户,不需要到企业域里面进行操作。
脚本示例如下:- (function(){
- var name = "calltest";
- var loginno = "calltest1";
- var loginpwd = "123456";
- var base64pwd ="";
- var base64 = new packages.cn.myapps.common.util.base64util();
- var loginpwdsbase = new packages.java.lang.string(loginpwd);
- var bytes = loginpwdsbase.getbytes();
- var encoded = base64.encode(bytes);
- if(encoded.length()>2){
- var lp = encoded.substring(0,2);
- var rp = encoded.substring(2,encoded.length());
- base64pwd = rp lp;
- }
- var email = "email@qq.com"
- var status =1;
- var domainid=getdomainid(); //域id
- var telephone = "18379855594";
- var deptid="";
- var department = "总经办";
- var rolename = "员工";
- var process = getdepartmentprocess();
- var depts= process.getdepartmentbyname(department,getdomainid());
- for(var it=depts.iterator();depts!=null && it.hasnext();){
- var dept = it.next();
- deptid=dept.getid();
- break;
- }
-
- var uservo = new packages.cn.myapps.common.model.user.uservo();//实例化一个用户对象
- var uuid = new packages.cn.myapps.util.sequence.sequence().getsequence();//创建uuid
- uservo.setid(uuid);
- uservo.setname(name);
- uservo.setloginno(loginno);
- uservo.setloginpwd(base64pwd);
- uservo.setemail(email);
- uservo.setstatus(status);
- uservo.setdomainid(domainid);
- uservo.settelephone(telephone);
- uservo.setdefaultdepartment(deptid);
- var roleid = getroleidbyname(rolename);
- var uprocess = getuserprocess();
- var userdepartmentroleset = new packages.cn.myapps.common.model.user.userdepartmentroleset(uuid,deptid,roleid);
- var list = new packages.java.util.hashset();
- list.add(userdepartmentroleset);
- uservo.setuserdepartmentrolesets(list);
- uprocess.docreate(uservo);
- })()
复制代码 |