Giải pháp chuyển đổi số trọn gói cho doanh nghiệp Việt
Tạo thư mục apps/ecommerce/controllers
tạo file carcategory.js
Nội dung file
var controllerbackenditem = require('../../../lib/mvc/controllers/controllerbackenditem');
var model = require('../../../lib/mvc/models/model');
const factory = require(`${path_root}/lib/Factory.js`);
class carcategory extends controllerbackenditem {
getListViewName(){
return "carcategories";
}
getFormViewName(){
return "carcategories";
}
async apply(data) {
const input=factory.getInput(this.req);
let a_return=input.getString('return',"");
let model=this.getModel();
if( typeof data==="undefined"){
data=input.getData();
}
let form_name=this.getFormViewName();
let form_layout=this.getFormLayoutName();
let carcategory=await model.save(data);
let id=carcategory.data._id;
if(a_return!=="")
{
this.res.redirect(`/${form_name}/${form_layout}/${id}?return=${a_return}`);
}else{
this.res.redirect(`/${form_name}/${form_layout}/${id}`);
}
}
}
module.exports = carcategory;
Chưa có câu hỏi nào cho bài này.