q-koa 13.3.7 → 13.3.8
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.
|
@@ -29,3 +29,16 @@ exports.clearWeixin = async (ctx) => {
|
|
|
29
29
|
})
|
|
30
30
|
)
|
|
31
31
|
}
|
|
32
|
+
|
|
33
|
+
exports.push = async (ctx) => {
|
|
34
|
+
const { app, appName } = getAppByCtx(ctx)
|
|
35
|
+
|
|
36
|
+
const { message = '测试通知' } = ctx.request.body
|
|
37
|
+
|
|
38
|
+
await app.service.log.push({
|
|
39
|
+
app,
|
|
40
|
+
message,
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
ctx.SUCCESS('ok')
|
|
44
|
+
}
|
|
@@ -188,6 +188,9 @@ exports.initModel = async (ctx) => {
|
|
|
188
188
|
}
|
|
189
189
|
)
|
|
190
190
|
.then((res) => res.data)
|
|
191
|
+
.catch((e) => {
|
|
192
|
+
return Promise.resolve({})
|
|
193
|
+
})
|
|
191
194
|
if (code === 200) {
|
|
192
195
|
const findList = Object.keys(productionModel || {}).filter((key) => {
|
|
193
196
|
return (
|
|
@@ -990,8 +993,10 @@ exports.changeIdType = async (ctx) => {
|
|
|
990
993
|
|
|
991
994
|
const mapper = {
|
|
992
995
|
INTEGER: 'INT',
|
|
996
|
+
SMALLINT: 'SMALLINT',
|
|
993
997
|
TINYINT: 'TINYINT',
|
|
994
998
|
MEDIUMINT: 'MEDIUMINT',
|
|
999
|
+
BIGINT: 'BIGINT',
|
|
995
1000
|
}
|
|
996
1001
|
if (!mapper[idType]) return ctx.ERROR(`not accept ${idType}`)
|
|
997
1002
|
|
|
@@ -1002,19 +1007,43 @@ exports.changeIdType = async (ctx) => {
|
|
|
1002
1007
|
|
|
1003
1008
|
const query = `ALTER TABLE \`${model}\` MODIFY COLUMN id ${updateTo} NOT NULL AUTO_INCREMENT`
|
|
1004
1009
|
|
|
1005
|
-
const target = lodash.pickBy(app.attributes, (obj) =>
|
|
1006
|
-
|
|
1010
|
+
const target = lodash.pickBy(app.attributes, (obj) => {
|
|
1011
|
+
return (
|
|
1012
|
+
`${model}_id` in obj ||
|
|
1013
|
+
Object.keys(obj).some(
|
|
1014
|
+
(k) => obj[k].belongsTo && obj[k].belongsTo === model
|
|
1015
|
+
)
|
|
1016
|
+
)
|
|
1017
|
+
})
|
|
1018
|
+
// console.log('target', app.attributes.store_balance_date)
|
|
1007
1019
|
console.log(`即将更新${model}的ID类型为${updateTo}`)
|
|
1008
1020
|
let error_message = ''
|
|
1009
1021
|
let flag = true
|
|
1010
1022
|
for (const _model of Object.keys(target)) {
|
|
1011
1023
|
const _res = await app.sequelize.getQueryInterface().describeTable(_model)
|
|
1012
|
-
if (
|
|
1013
|
-
|
|
1014
|
-
_res[`${model}_id`].type
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1024
|
+
if (_res[`${model}_id`]) {
|
|
1025
|
+
if (
|
|
1026
|
+
updateTo !== _res[`${model}_id`].type &&
|
|
1027
|
+
!['JSON'].includes(_res[`${model}_id`].type)
|
|
1028
|
+
) {
|
|
1029
|
+
error_message = `请先处理好${_model}的字段类型${model}_id,当前是${
|
|
1030
|
+
_res[`${model}_id`].type
|
|
1031
|
+
}`
|
|
1032
|
+
console.error(error_message)
|
|
1033
|
+
flag = false
|
|
1034
|
+
}
|
|
1035
|
+
} else {
|
|
1036
|
+
const targetAttribute = lodash.pickBy(app.attributes[_model], (obj) => {
|
|
1037
|
+
return obj.belongsTo && obj.belongsTo === model
|
|
1038
|
+
})
|
|
1039
|
+
|
|
1040
|
+
if (updateTo !== _res[Object.keys(targetAttribute)[0]].type) {
|
|
1041
|
+
error_message = `请先处理好${_model}的字段类型${
|
|
1042
|
+
Object.keys(targetAttribute)[0]
|
|
1043
|
+
},当前是${_res[Object.keys(targetAttribute)[0]].type}`
|
|
1044
|
+
console.error(error_message)
|
|
1045
|
+
flag = false
|
|
1046
|
+
}
|
|
1018
1047
|
}
|
|
1019
1048
|
}
|
|
1020
1049
|
if (obj.type === updateTo) {
|
|
@@ -1917,11 +1917,11 @@ exports.getUserPortrait = async (ctx) => {
|
|
|
1917
1917
|
ctx.SUCCESS(result)
|
|
1918
1918
|
}
|
|
1919
1919
|
|
|
1920
|
-
exports.getVisitTrend = async (ctx) => {
|
|
1920
|
+
exports.getVisitTrend = async (ctx, _data) => {
|
|
1921
1921
|
const { app, appName } = getAppByCtx(ctx)
|
|
1922
1922
|
const appConfig = getConfig(app)
|
|
1923
1923
|
|
|
1924
|
-
const { config = 'weixin_mp', type = 'day', date } = ctx.request.body
|
|
1924
|
+
const { config = 'weixin_mp', type = 'day', date } = _data || ctx.request.body
|
|
1925
1925
|
const { app_id, app_secrect } = await appConfig.getObject(config)
|
|
1926
1926
|
|
|
1927
1927
|
const diff = moment().hour() > 8 ? -1 : -2
|
|
@@ -1963,8 +1963,17 @@ exports.getVisitTrend = async (ctx) => {
|
|
|
1963
1963
|
weixinMp.init()
|
|
1964
1964
|
|
|
1965
1965
|
const result = await weixinMp.getVisitTrend({ ...obj, type })
|
|
1966
|
-
|
|
1966
|
+
if (result && result.list && result.list[0]) {
|
|
1967
|
+
await app.model.weixin_visit.create(result.list[0])
|
|
1968
|
+
} else {
|
|
1969
|
+
return app.controller.weixin.getVisitTrend(ctx, {
|
|
1970
|
+
type,
|
|
1971
|
+
date: moment(date).add(-1, 'days').format('YYYYMMDD'),
|
|
1972
|
+
})
|
|
1973
|
+
}
|
|
1974
|
+
|
|
1967
1975
|
ctx.SUCCESS(result)
|
|
1976
|
+
return result
|
|
1968
1977
|
}
|
|
1969
1978
|
|
|
1970
1979
|
exports.getCommentInfo = async (ctx, _data) => {
|