garyvv /
node-sharp
| 1 | const ModelStore = require('../../model/catering/store') |
||
| 2 | const ServiceCustomer = require('../../services/catering/customer') |
||
| 3 | const ApiError = require('../../util/api_error') |
||
|
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||
| 4 | const Validate = require('request-validate') |
||
|
0 ignored issues
–
show
|
|||
| 5 | const _ = require('underscore') |
||
|
0 ignored issues
–
show
|
|||
| 6 | const ConfigOss = require('../../../config/oss') |
||
| 7 | |||
| 8 | module.exports = { |
||
| 9 | storeList: async function (sellerId) { |
||
| 10 | let result = await ModelStore.getSellerStores(sellerId) |
||
| 11 | |||
| 12 | // 默认开店 |
||
| 13 | if (result.length <= 0) { |
||
| 14 | let customerInfo = await ServiceCustomer.getCustomerInfo(sellerId) |
||
| 15 | let storeInfo = { |
||
| 16 | seller_id: customerInfo.id, |
||
| 17 | name: customerInfo.nickname, |
||
| 18 | thumb: customerInfo.avatar, |
||
| 19 | store_type_id: 0, theme: '', tel: '', wechat: '', license: '', address: '', |
||
| 20 | approve_status: 0, status: 1, audit_id: 0 |
||
| 21 | } |
||
| 22 | let storeRes = await ModelStore.add(storeInfo) |
||
| 23 | storeInfo.id = storeRes.insertId |
||
| 24 | result = [storeInfo] |
||
| 25 | } |
||
| 26 | |||
| 27 | result.forEach(element => { |
||
| 28 | element.preview_thumb = element.thumb |
||
| 29 | element.preview_license = element.license |
||
| 30 | if (element.thumb && element.thumb.indexOf('http') < 0) element.preview_thumb = ConfigOss.catering.view_server + element.thumb + '?x-oss-process=style/preview' |
||
|
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. Loading history...
|
|||
| 31 | if (element.license && element.license.indexOf('http') < 0) element.preview_license = ConfigOss.catering.view_server + element.preview_license + '?x-oss-process=style/preview' |
||
|
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. Loading history...
|
|||
| 32 | }) |
||
| 33 | |||
| 34 | return result |
||
| 35 | }, |
||
| 36 | |||
| 37 | } |
||
| 38 |