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