fix: typesciprt bug

rap2org
humphry.hy 2 years ago
parent 5ec7680495
commit d3ea23ed38

@ -58,7 +58,7 @@ router.get('/account/list', isLoggedIn, async (ctx) => {
} }
let options = { where } let options = { where }
let total = await User.count(options) let total = await User.count(options)
let limit = Math.min(ctx.query.limit ?? 10, 100) let limit = Math.min(+ctx.query.limit ?? 10, 100)
let pagination = new Pagination(total, ctx.query.cursor || 1, limit) let pagination = new Pagination(total, ctx.query.cursor || 1, limit)
ctx.body = { ctx.body = {
data: await User.findAll({ data: await User.findAll({

@ -52,7 +52,7 @@ router.get('/export/markdown', async ctx => {
if (!(repoId > 0)) { if (!(repoId > 0)) {
ctx.data = COMMON_ERROR_RES.ERROR_PARAMS ctx.data = COMMON_ERROR_RES.ERROR_PARAMS
} }
ctx.body = await MarkdownService.export(repoId, ctx.query.origin) ctx.body = await MarkdownService.export(repoId, ctx.query.origin as string)
}) })
router.get('/export/docx', async ctx => { router.get('/export/docx', async ctx => {
@ -71,7 +71,7 @@ router.get('/export/docx', async ctx => {
ctx.data = COMMON_ERROR_RES.ERROR_PARAMS ctx.data = COMMON_ERROR_RES.ERROR_PARAMS
} }
const repository = await Repository.findByPk(repoId) const repository = await Repository.findByPk(repoId)
ctx.body = await DocxService.export(repoId, ctx.query.origin) ctx.body = await DocxService.export(repoId, ctx.query.origin as string)
ctx.set( ctx.set(
'Content-Disposition', 'Content-Disposition',
`attachment; filename="RAP-${encodeURI( `attachment; filename="RAP-${encodeURI(

@ -39,7 +39,7 @@ router.get('/organization/list', async (ctx) => {
const { name } = ctx.query const { name } = ctx.query
const total = await OrganizationService.getAllOrganizationIdListNum(curUserId) const total = await OrganizationService.getAllOrganizationIdListNum(curUserId)
const pagination = new Pagination(total, ctx.query.cursor || 1, ctx.query.limit || 100) const pagination = new Pagination(total, ctx.query.cursor || 1, ctx.query.limit || 100)
const organizationIds = await OrganizationService.getAllOrganizationIdList(curUserId, pagination, name) const organizationIds = await OrganizationService.getAllOrganizationIdList(curUserId, pagination, name as string)
const options: FindOptions = { const options: FindOptions = {
where: { where: {
id: { id: {
@ -117,7 +117,7 @@ router.get('/organization/get', async (ctx) => {
ctx.body = COMMON_ERROR_RES.ACCESS_DENY ctx.body = COMMON_ERROR_RES.ACCESS_DENY
return return
} }
const organization = await Organization.findByPk(ctx.query.id, { const organization = await Organization.findByPk(+ctx.query.id, {
attributes: { exclude: [] }, attributes: { exclude: [] },
include: [QueryInclude.Creator, QueryInclude.Owner, QueryInclude.Members], include: [QueryInclude.Creator, QueryInclude.Owner, QueryInclude.Members],
} as any) } as any)

@ -52,7 +52,7 @@ router.get('/repository/list', async (ctx) => {
let { name, user, organization } = ctx.query let { name, user, organization } = ctx.query
if (+organization > 0) { if (+organization > 0) {
const access = await AccessUtils.canUserAccess(ACCESS_TYPE.ORGANIZATION_GET, ctx.session.id, organization) const access = await AccessUtils.canUserAccess(ACCESS_TYPE.ORGANIZATION_GET, ctx.session.id, +organization)
if (access === false) { if (access === false) {
ctx.body = { ctx.body = {
@ -82,7 +82,7 @@ router.get('/repository/list', async (ctx) => {
QueryInclude.Locker QueryInclude.Locker
] ]
}) })
let limit = Math.min(ctx.query.limit ?? 10, 100) let limit = Math.min(+ctx.query.limit ?? 10, 100)
let pagination = new Pagination(total, ctx.query.cursor || 1, limit) let pagination = new Pagination(total, ctx.query.cursor || 1, limit)
let repositories = await Repository.findAll({ let repositories = await Repository.findAll({
where, where,
@ -197,8 +197,8 @@ router.get('/repository/get', async (ctx) => {
const access = await AccessUtils.canUserAccess( const access = await AccessUtils.canUserAccess(
ACCESS_TYPE.REPOSITORY_GET, ACCESS_TYPE.REPOSITORY_GET,
ctx.session.id, ctx.session.id,
ctx.query.id, +ctx.query.id,
ctx.query.token ctx.query.token as string
) )
if (access === false) { if (access === false) {
ctx.body = { ctx.body = {
@ -211,15 +211,15 @@ router.get('/repository/get', async (ctx) => {
const canUserEdit = await AccessUtils.canUserAccess( const canUserEdit = await AccessUtils.canUserAccess(
ACCESS_TYPE.REPOSITORY_SET, ACCESS_TYPE.REPOSITORY_SET,
ctx.session.id, ctx.session.id,
ctx.query.id, +ctx.query.id,
ctx.query.token, ctx.query.token as string,
) )
let repository: Partial<Repository> & { let repository: Partial<Repository> & {
canUserEdit: boolean canUserEdit: boolean
} }
// 分开查询减少查询时间 // 分开查询减少查询时间
let [repositoryOmitModules, repositoryModules] = await Promise.all([ let [repositoryOmitModules, repositoryModules] = await Promise.all([
Repository.findByPk(ctx.query.id, { Repository.findByPk(+ctx.query.id, {
attributes: { exclude: [] }, attributes: { exclude: [] },
include: [ include: [
QueryInclude.Creator, QueryInclude.Creator,
@ -230,7 +230,7 @@ router.get('/repository/get', async (ctx) => {
QueryInclude.Collaborators, QueryInclude.Collaborators,
], ],
}), }),
Repository.findByPk(ctx.query.id, { Repository.findByPk(+ctx.query.id, {
attributes: { exclude: [] }, attributes: { exclude: [] },
include: [ include: [
excludeProperty excludeProperty
@ -476,7 +476,7 @@ router.get('/module/list', async (ctx) => {
router.get('/module/get', async (ctx) => { router.get('/module/get', async (ctx) => {
ctx.body = { ctx.body = {
data: await Module.findByPk(ctx.query.id, { data: await Module.findByPk(+ctx.query.id, {
attributes: { exclude: [] } attributes: { exclude: [] }
}) })
} }
@ -564,7 +564,7 @@ router.get('/module/remove', isLoggedIn, async (ctx, next) => {
}, async (ctx) => { }, async (ctx) => {
if (ctx.body.data === 0) return if (ctx.body.data === 0) return
let { id } = ctx.query let { id } = ctx.query
let mod = await Module.findByPk(id, { paranoid: false }) let mod = await Module.findByPk(+id, { paranoid: false })
await Logger.create({ await Logger.create({
userId: ctx.session.id, userId: ctx.session.id,
type: 'delete', type: 'delete',
@ -615,14 +615,14 @@ router.get('/interface/list', async (ctx) => {
}) })
router.get('/repository/defaultVal/get/:id', async (ctx) => { router.get('/repository/defaultVal/get/:id', async (ctx) => {
const repositoryId: number = ctx.params.id const repositoryId: number = +ctx.params.id
ctx.body = { ctx.body = {
data: await DefaultVal.findAll({ where: { repositoryId } }) data: await DefaultVal.findAll({ where: { repositoryId } })
} }
}) })
router.post('/repository/defaultVal/update/:id', async (ctx) => { router.post('/repository/defaultVal/update/:id', async (ctx) => {
const repositoryId: number = ctx.params.id const repositoryId: number = +ctx.params.id
if (!await AccessUtils.canUserAccess(ACCESS_TYPE.REPOSITORY_SET, ctx.session.id, repositoryId)) { if (!await AccessUtils.canUserAccess(ACCESS_TYPE.REPOSITORY_SET, ctx.session.id, repositoryId)) {
ctx.body = Consts.COMMON_ERROR_RES.ACCESS_DENY ctx.body = Consts.COMMON_ERROR_RES.ACCESS_DENY
return return
@ -658,7 +658,7 @@ router.get('/interface/get', async (ctx) => {
return return
} }
let itf = await Interface.findByPk(id, { let itf = await Interface.findByPk(+id, {
include: [QueryInclude.Locker], include: [QueryInclude.Locker],
attributes: { exclude: [] }, attributes: { exclude: [] },
}) })
@ -789,7 +789,7 @@ router.get('/interface/remove', async (ctx, next) => {
ctx.body = Consts.COMMON_ERROR_RES.ACCESS_DENY ctx.body = Consts.COMMON_ERROR_RES.ACCESS_DENY
return return
} }
const itf = await Interface.findByPk(id) const itf = await Interface.findByPk(+id)
const properties = await Property.findAll({ where: { interfaceId: id } }) const properties = await Property.findAll({ where: { interfaceId: id } })
await RepositoryService.addHistoryLog({ await RepositoryService.addHistoryLog({
entityId: itf.repositoryId, entityId: itf.repositoryId,
@ -807,7 +807,7 @@ router.get('/interface/remove', async (ctx, next) => {
}, async (ctx) => { }, async (ctx) => {
if (ctx.body.data === 0) return if (ctx.body.data === 0) return
let { id } = ctx.query let { id } = ctx.query
let itf = await Interface.findByPk(id, { paranoid: false }) let itf = await Interface.findByPk(+id, { paranoid: false })
await Logger.create({ await Logger.create({
userId: ctx.session.id, userId: ctx.session.id,
type: 'delete', type: 'delete',
@ -930,7 +930,7 @@ router.get('/property/list', async (ctx) => {
router.get('/property/get', async (ctx) => { router.get('/property/get', async (ctx) => {
let { id } = ctx.query let { id } = ctx.query
ctx.body = { ctx.body = {
data: await Property.findByPk(id, { data: await Property.findByPk(+id, {
attributes: { exclude: [] } attributes: { exclude: [] }
}) })
} }
@ -1095,7 +1095,7 @@ router.post('/properties/update', isLoggedIn, async (ctx, next) => {
return next() return next()
}, async (ctx) => { }, async (ctx) => {
if (ctx.body.data === 0) return if (ctx.body.data === 0) return
let itf = await Interface.findByPk(ctx.query.itf, { let itf = await Interface.findByPk(+ctx.query.itf, {
attributes: { exclude: [] } attributes: { exclude: [] }
}) })
await Logger.create({ await Logger.create({
@ -1109,7 +1109,7 @@ router.post('/properties/update', isLoggedIn, async (ctx, next) => {
router.get('/property/remove', isLoggedIn, async (ctx) => { router.get('/property/remove', isLoggedIn, async (ctx) => {
let { id } = ctx.query let { id } = ctx.query
if (!await AccessUtils.canUserAccess(ACCESS_TYPE.PROPERTY_SET, ctx.session.id, id)) { if (!await AccessUtils.canUserAccess(ACCESS_TYPE.PROPERTY_SET, ctx.session.id, +id)) {
ctx.body = Consts.COMMON_ERROR_RES.ACCESS_DENY ctx.body = Consts.COMMON_ERROR_RES.ACCESS_DENY
return return
} }

@ -28,7 +28,7 @@ router.get('/test/test.status', (ctx) => {
// proxy // proxy
router.get('/proxy', async(ctx) => { router.get('/proxy', async(ctx) => {
let { target } = ctx.query let { target } = ctx.query
let json = await fetch(target).then(res => res.json()) let json = await fetch(target as string).then(res => res.json())
ctx.type = 'json' ctx.type = 'json'
ctx.body = json ctx.body = json
}) })

Loading…
Cancel
Save