q-koa 13.3.1 → 13.3.2

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.
package/core/app.js CHANGED
@@ -163,9 +163,12 @@ class APP {
163
163
  return ctx.ERROR('error')
164
164
  }
165
165
  const appName = url.split('/')[1]
166
- if (!appName || !(ctx.app[appName] && ctx.app[appName].appConfig)) {
167
- return ctx.ERROR('error')
166
+ if (appName !== '.well-known') {
167
+ if (!appName || !(ctx.app[appName] && ctx.app[appName].appConfig)) {
168
+ return ctx.ERROR('error')
169
+ }
168
170
  }
171
+
169
172
  const { secret, whiteList, _whiteList, tokenKey, expiresIn } =
170
173
  ctx.app[appName] && ctx.app[appName].appConfig
171
174
  ? ctx.app[appName].appConfig.jwt
@@ -536,7 +539,10 @@ class APP {
536
539
  if (this.config.router) {
537
540
  this.config.router(router)
538
541
  }
539
- router.post('*', () => {
542
+ router.get('/.well-known/pki-validation/fileauth.txt', (ctx) => {
543
+ ctx.body = this.config.fileauth || '没找到config里的fileauth'
544
+ })
545
+ router.post('*', (ctx) => {
540
546
  throw new Error('接口路径不符合规范')
541
547
  })
542
548
  this.app.use(router.routes()).use(router.allowedMethods())
@@ -961,6 +967,23 @@ class APP {
961
967
  return ctx.SUCCESS(await app[appName].mock[controller]())
962
968
  }
963
969
 
970
+ if (fn === 'groupCount') {
971
+ if (!ctx.request.body.group) throw new Error('必须要有group')
972
+ const result = await app[appName].model[controller].findAll({
973
+ attributes: [
974
+ ctx.request.body.group,
975
+ [
976
+ Sequelize.fn('count', Sequelize.col(ctx.request.body.group)),
977
+ 'count',
978
+ ],
979
+ ],
980
+ group: [ctx.request.body.group],
981
+ where: ctx.request.body.where,
982
+ order: [[Sequelize.literal('count'), 'DESC']],
983
+ })
984
+ ctx.SUCCESS(result)
985
+ return
986
+ }
964
987
  if (
965
988
  !_.get(app, `${appName}.model.${controller}.${fn}`) &&
966
989
  !_.get(app, `${appName}.controller.${controller}.${fn}`)
@@ -90,7 +90,8 @@ exports.permission_id = {
90
90
  defaultValue: [],
91
91
  sortOrder: 5,
92
92
  get: function () {
93
- return this.getDataValue('permission_id') === null
93
+ return this.getDataValue('permission_id') === null ||
94
+ !Array.isArray(this.getDataValue('permission_id'))
94
95
  ? []
95
96
  : this.getDataValue('permission_id')
96
97
  },
@@ -1005,15 +1005,15 @@ exports.changeIdType = async (ctx) => {
1005
1005
  const target = lodash.pickBy(app.attributes, (obj) => `${model}_id` in obj)
1006
1006
 
1007
1007
  console.log(`即将更新${model}的ID类型为${updateTo}`)
1008
+ let error_message = ''
1008
1009
  let flag = true
1009
1010
  for (const _model of Object.keys(target)) {
1010
1011
  const _res = await app.sequelize.getQueryInterface().describeTable(_model)
1011
1012
  if (updateTo !== _res[`${model}_id`].type) {
1012
- console.error(
1013
- `请先处理好${_model}的字段类型${model}_id,当前是${
1014
- _res[`${model}_id`].type
1015
- }`
1016
- )
1013
+ error_message = `请先处理好${_model}的字段类型${model}_id,当前是${
1014
+ _res[`${model}_id`].type
1015
+ }`
1016
+ console.error(error_message)
1017
1017
  flag = false
1018
1018
  }
1019
1019
  }
@@ -1022,7 +1022,7 @@ exports.changeIdType = async (ctx) => {
1022
1022
  }
1023
1023
 
1024
1024
  if (!flag) {
1025
- return ctx.ERROR('更新失败')
1025
+ return ctx.ERROR(error_message)
1026
1026
  }
1027
1027
  // ctx.SUCCESS(query)
1028
1028
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "13.3.1",
3
+ "version": "13.3.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {