garyvv /
node-sharp
| 1 | View Code Duplication | const DB = require('../../libraries/db') |
|
|
0 ignored issues
–
show
Duplication
introduced
by
Loading history...
|
|||
| 2 | const config = require('../../../config/config') |
||
|
0 ignored issues
–
show
|
|||
| 3 | const ModelBase = require('../../model/base') |
||
| 4 | const ApiError = require('../../util/api_error') |
||
|
0 ignored issues
–
show
|
|||
| 5 | |||
| 6 | const table = 'mist_customer' |
||
| 7 | |||
| 8 | module.exports = { |
||
| 9 | add: async function (data) { |
||
| 10 | let res = await ModelBase.execInsert(table, data) |
||
| 11 | return res; |
||
| 12 | }, |
||
| 13 | |||
| 14 | getCustomerByOpenId: async function (openid) { |
||
| 15 | |||
| 16 | let user = await DB.readMysql.first( |
||
| 17 | '*' |
||
| 18 | ) |
||
| 19 | .from(table) |
||
| 20 | .where('openid', openid) |
||
| 21 | |||
| 22 | return user |
||
| 23 | |||
| 24 | }, |
||
| 25 | |||
| 26 | first: async function (customerId) { |
||
| 27 | |||
| 28 | let user = await DB.readMysql.first( |
||
| 29 | '*' |
||
| 30 | ) |
||
| 31 | .from(table) |
||
| 32 | .where('id', customerId) |
||
| 33 | |||
| 34 | return user |
||
| 35 | |||
| 36 | }, |
||
| 37 | |||
| 38 | edit: async function (data, where, notWhere = {}) { |
||
| 39 | let result = await ModelBase.execUpdate(table, data, where, notWhere) |
||
| 40 | |||
| 41 | return result |
||
| 42 | } |
||
| 43 | |||
| 44 | } |