@@ 1-45 (lines=45) @@ | ||
1 | const DB = require('../libraries/db') |
|
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 | } |
@@ 1-44 (lines=44) @@ | ||
1 | const DB = require('../../libraries/db') |
|
2 | const config = require('../../../config/config') |
|
3 | const ModelBase = require('../../model/base') |
|
4 | const ApiError = require('../../util/api_error') |
|
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 | } |
@@ 1-43 (lines=43) @@ | ||
1 | const DB = require('../../libraries/db') |
|
2 | const ModelBase = require('../../model/base') |
|
3 | ||
4 | const table = 'mist_desk' |
|
5 | ||
6 | module.exports = { |
|
7 | add: async function (data) { |
|
8 | let res = await ModelBase.execInsert(table, data) |
|
9 | return res; |
|
10 | }, |
|
11 | ||
12 | list: async function (storeId) { |
|
13 | ||
14 | let result = await DB.readMysql.select( |
|
15 | '*' |
|
16 | ) |
|
17 | .from(table) |
|
18 | .where('store_id', storeId) |
|
19 | .where('status', '!=', -1) |
|
20 | ||
21 | return result |
|
22 | ||
23 | }, |
|
24 | ||
25 | first: async function (id) { |
|
26 | ||
27 | let result = await DB.readMysql.first( |
|
28 | '*' |
|
29 | ) |
|
30 | .from(table) |
|
31 | .where('id', id) |
|
32 | ||
33 | return result |
|
34 | ||
35 | }, |
|
36 | ||
37 | edit: async function (data, where, notWhere = {}) { |
|
38 | let result = await ModelBase.execUpdate(table, data, where, notWhere) |
|
39 | ||
40 | return result |
|
41 | } |
|
42 | ||
43 | } |
|
44 |
@@ 1-43 (lines=43) @@ | ||
1 | const DB = require('../../libraries/db') |
|
2 | const ModelBase = require('../../model/base') |
|
3 | ||
4 | const table = 'mist_seller' |
|
5 | ||
6 | module.exports = { |
|
7 | add: async function (data) { |
|
8 | let res = ModelBase.execInsert(table, data) |
|
9 | return await res; |
|
10 | }, |
|
11 | ||
12 | list: async function (kid) { |
|
13 | ||
14 | let result = DB.readMysql.select( |
|
15 | '*' |
|
16 | ) |
|
17 | .from(table) |
|
18 | .where('kid', kid) |
|
19 | .where('status', '!=', -1) |
|
20 | ||
21 | return await result |
|
22 | ||
23 | }, |
|
24 | ||
25 | first: async function (id) { |
|
26 | ||
27 | let result = DB.readMysql.first( |
|
28 | '*' |
|
29 | ) |
|
30 | .from(table) |
|
31 | .where('seller_id', id) |
|
32 | ||
33 | return await result |
|
34 | ||
35 | }, |
|
36 | ||
37 | edit: async function (data, where, notWhere = {}) { |
|
38 | let result = ModelBase.execUpdate(table, data, where, notWhere) |
|
39 | ||
40 | return await result |
|
41 | } |
|
42 | ||
43 | } |
|
44 |
@@ 1-42 (lines=42) @@ | ||
1 | const DB = require('../../libraries/db') |
|
2 | const ModelBase = require('../../model/base') |
|
3 | ||
4 | const table = 'mist_store' |
|
5 | ||
6 | module.exports = { |
|
7 | add: async function (data) { |
|
8 | let res = await ModelBase.execInsert(table, data) |
|
9 | return res; |
|
10 | }, |
|
11 | ||
12 | first: async function (id) { |
|
13 | ||
14 | let result = DB.readMysql.first( |
|
15 | '*' |
|
16 | ) |
|
17 | .from(table) |
|
18 | .where('id', id) |
|
19 | ||
20 | return await result |
|
21 | ||
22 | }, |
|
23 | ||
24 | getSellerStores: async function (sellerId) { |
|
25 | ||
26 | let result = DB.readMysql.select( |
|
27 | '*' |
|
28 | ) |
|
29 | .from(table) |
|
30 | .where('seller_id', sellerId) |
|
31 | ||
32 | return await result |
|
33 | ||
34 | }, |
|
35 | ||
36 | edit: async function (data, where, notWhere = {}) { |
|
37 | let result = ModelBase.execUpdate(table, data, where, notWhere) |
|
38 | ||
39 | return await result |
|
40 | } |
|
41 | ||
42 | } |