Skip to end of metadata
Go to start of metadata

 

 

var version = java.lang.System.getProperty("java.version");
if (version.startsWith("1.8.0")) {
    load("nashorn:mozilla_compat.js");
}
importPackage(com.alibaba.fastjson);
var data = new JSONArray();

//连接名称,在"连接管理"中配置相应的数据库连接
var connectionName = "local dataset";
var sql="select usercode from permissiontable";
//查询用户
var userRows = databaseService.query(connectionName, sql, null);
if(userRows.size() > 0){
    for(var i = 0; i < userRows.size(); i++){
        var row = userRows.get(i);
        var userObj = new JSONObject();
        //用户名,必须使用参数username
        userObj.put("username", row.get("usercode"));
        data.add(userObj);
    }
}

//如果设置为false,表示不执行本次同步操作
result.setSuccess(true);
result.setData(data);

 

 

  • No labels