@kne/fastify-account 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -78,17 +78,33 @@ const userService = fp(async (fastify, options) => {
78
78
  const getUserList = async ({ filter, perPage, currentPage }) => {
79
79
  const queryFilter = {};
80
80
 
81
- ['nickname'].forEach(key => {
81
+ ['nickname', 'phone', 'email'].forEach(key => {
82
82
  if (filter && filter[key]) {
83
83
  queryFilter[key] = {
84
84
  [Op.like]: `%${filter[key]}%`
85
85
  };
86
86
  }
87
87
  });
88
+ ['status'].forEach(key => {
89
+ if (filter && filter[key]) {
90
+ queryFilter[key] = filter[key];
91
+ }
92
+ });
93
+ if (filter?.isSuperAdmin !== undefined) {
94
+ if (filter.isSuperAdmin === 'true') {
95
+ queryFilter.isSuperAdmin = true;
96
+ } else {
97
+ queryFilter.isSuperAdmin = {
98
+ [Op.or]: [false, null]
99
+ };
100
+ }
101
+ }
102
+
88
103
  const { count, rows } = await models.user.findAndCountAll({
89
104
  where: queryFilter,
90
105
  offset: perPage * (currentPage - 1),
91
- limit: perPage
106
+ limit: perPage,
107
+ order: [['createdAt', 'DESC']]
92
108
  });
93
109
  return {
94
110
  pageData: rows.map(item => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kne/fastify-account",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "用于用户注册登录认证.",
5
5
  "main": "index.js",
6
6
  "scripts": {