'use strict';


exports.save = async function () {
    await this.bindDefault();
    this.body =  await this.mongo("Url",this.request.body).saveByKey();
	return
}
exports.save.__method__ = 'POST';

exports.get_item = async function(){
    await this.bindDefault();
    this.body =  await this.mongo("Url").findItemBytId(this.request.query._id);
	return
}
exports.get_item.__method__ = "GET"

exports.query_items = async function(){
    await this.bindDefault();
    this.body =  await this.mongo("Url").findProByProjectId(this.request.query._id);
	return
}
exports.query_items.__method__ = "GET"

exports.query = async function () {
    await this.bindDefault();
    this.body =  await this.mongo("Url").findByProjectId(this.request.query._id);
	return
}
exports.query.__method__ = 'GET';


exports.delete = async function(){
    await this.bindDefault();
    this.body = await this.mongo("Url").delete(this.request.query._id);
    return
}
exports.delete.__method__ = "GET";


exports.update = async function(){
    await this.bindDefault();
    this.body = await this.mongo("Url").updateById(this.request.body);
    return
}
exports.update.__method__ = "POST"

exports.find = async function(){
    await this.bindDefault();
    this.body = await this.mongo("Url").findByObj(this.request.query);
    return
}
exports.find.__method__ = "GET"

exports.find_url_templates_by_id = async function(){
    await this.bindDefault();
    this.body = await this.mongo("Url").findUrlTemplatesById(this.request.query);
    return
}
exports.find_url_templates_by_id.__method__ = "GET"

exports.sub_relace_env = async function(vappOpt){
    await this.bindDefault();
    let url = await this.mongo("Url").findUrlTemplatesByUrlId(this.request.query._id);
    console.log(url);
    // try {
    //     vappOpt.bpModules.setUrlTemplate(url);    
    //     this.body = {code:"0000"}
    // } catch (error) {
    //     this.body = {code:"0001"}
    // }
    return
}
exports.sub_relace_env.__method__ = "GET"
