* get or set post data * @param {String} name * @param {Mixed} value
(name, value)
| 200 | * @param {Mixed} value |
| 201 | */ |
| 202 | post(name, value) { |
| 203 | if (!this[POST]) { |
| 204 | const json = this.request.body && this.request.body.post; |
| 205 | this[POST] = think.isArray(json) ? Array.from(json) : Object.assign({}, json); |
| 206 | this.app.emit('filterParam', this[POST]); |
| 207 | } |
| 208 | if (!name) return this[POST]; |
| 209 | if (helper.isObject(name)) { |
| 210 | this[POST] = Object.assign(this[POST], name); |
| 211 | return this; |
| 212 | } |
| 213 | if (value === undefined) { |
| 214 | // this.param('a,b') |
| 215 | if (helper.isString(name) && name.indexOf(',') > -1) { |
| 216 | name = name.split(/\s*,\s*/); |
| 217 | } |
| 218 | if (helper.isArray(name)) { |
| 219 | const value = {}; |
| 220 | name.forEach(item => { |
| 221 | const val = this[POST][item]; |
| 222 | if (val !== undefined) { |
| 223 | value[item] = val; |
| 224 | } |
| 225 | }); |
| 226 | return value; |
| 227 | } |
| 228 | return this[POST][name]; |
| 229 | } |
| 230 | this[POST][name] = value; |
| 231 | return this; |
| 232 | }, |
| 233 | /** |
| 234 | * get or set file data |
| 235 | * @param {String} name |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…