//#import @include/checklogin.jsx
//#import $owl_website:services/modelService.jsx
//#import Util.js

function main(){
    $.log("before checklogin");
    var env = checklogin();
    $.log("after checklogin");
    if(!env){
        var ret = {
            state: 'err',
            code:'NotLoginedIn'
        }
        out.print(JSON.stringify(ret));
        return;
    }
    $.log("env != null");
    var uid = env.loginId;
    var params = JSON.parse($body);
    var id = params.id;
    $.log("id=" + id);
    var website = owl_websiteService.get(id);
    if(!website){
        var ret = {
            state:"err",
            code:"not found",
            msg:"错误数据"
        }
        out.print(JSON.stringify(ret));
        return;
    }
    if(website.ownerId!=uid){
        var ret = {
            state:'err',
            msg:'错误数据'
        }
        out.print(JSON.stringify(ret));
        return;
    }
    var ret = {
        state: 'ok',
        website:website

    }
    out.print(JSON.stringify(ret));
    return;
}

main();