Comparing version 0.1.13 to 0.1.14
@@ -280,2 +280,16 @@ /** | ||
/** | ||
* 获取对应的模型 | ||
* 默认获取当前controller对应的模型 | ||
* @param {[type]} name [description] | ||
* @return {[type]} [description] | ||
*/ | ||
model: function(name){ | ||
if (!name) { | ||
var filename = this.__filename; | ||
name = filename.split("/").pop().replace(C('class_file_suffix'), ""); | ||
name = name.substr(0, name.length - 10); | ||
}; | ||
return D(name); | ||
}, | ||
/** | ||
* 下载文件 | ||
@@ -282,0 +296,0 @@ * @return {[type]} [description] |
@@ -51,3 +51,7 @@ /** | ||
if (is_number(value)) { | ||
return this.id(value); | ||
value = this.id(value); | ||
if (value) { | ||
return [value]; | ||
}; | ||
return []; | ||
}; | ||
@@ -54,0 +58,0 @@ if (is_string(value)) { |
@@ -23,3 +23,3 @@ /** | ||
this._response(); | ||
var method = this.req.method; | ||
var method = this.req.method.toLowerCase(); | ||
var methods = ["post", "put", "patch"]; | ||
@@ -33,2 +33,11 @@ if (methods.indexOf(method) > -1) { | ||
/** | ||
* 检测含有post数据 | ||
* @return {Boolean} [description] | ||
*/ | ||
hasBody: function(){ | ||
var encoding = 'transfer-encoding' in this.req.headers; | ||
var length = 'content-length' in this.req.headers && this.req.headers['content-length'] !== '0'; | ||
return encoding || length; | ||
}, | ||
/** | ||
* 获取POST过来的数据,包含上传的文件 | ||
@@ -40,5 +49,25 @@ * 依赖multiparty库 | ||
getData: function(callback){ | ||
//没有post数据,直接回调 | ||
if (!this.hasBody()) { | ||
return callback && callback(this.http); | ||
}; | ||
var self = this; | ||
var contentType = this.req.headers["content-type"] || ""; | ||
var ajaxContentType = "application/x-www-form-urlencoded"; | ||
//ajax数据提交 | ||
if (contentType.indexOf(ajaxContentType) === 0) { | ||
var buffer = ""; | ||
this.req.setEncoding(C('encoding')); | ||
this.req.on("data", function(chunk){ | ||
buffer += chunk; | ||
}) | ||
this.req.on("end", function(){ | ||
self.http.post = querystring.parse(buffer) || {}; | ||
callback && callback(self.http); | ||
}) | ||
return; | ||
}; | ||
//表单数据提交 | ||
var multiparty = require("multiparty"); | ||
var form = new multiparty.Form(); | ||
var self = this; | ||
form.on("file", function(name, value){ | ||
@@ -45,0 +74,0 @@ self.http.file[name] = value; |
@@ -587,3 +587,3 @@ var util = require('util'); | ||
update: function(data, options){ | ||
if (!data) { | ||
if (is_empty(data)) { | ||
if (this._data) { | ||
@@ -590,0 +590,0 @@ data = this._data; |
{ | ||
"name": "thinkjs", | ||
"description": "thinkphp web framework for nodejs", | ||
"version": "0.1.13", | ||
"version": "0.1.14", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "welefen", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
166750
4974