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 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)
ctx.body = {
data: await User.findAll({

@ -52,7 +52,7 @@ router.get('/export/markdown', async ctx => {
if (!(repoId > 0)) {
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 => {
@ -71,7 +71,7 @@ router.get('/export/docx', async ctx => {
ctx.data = COMMON_ERROR_RES.ERROR_PARAMS
}
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(
'Content-Disposition',
`attachment; filename="RAP-${encodeURI(

@ -39,7 +39,7 @@ router.get('/organization/list', async (ctx) => {
const { name } = ctx.query
const total = await OrganizationService.getAllOrganizationIdListNum(curUserId)
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 = {
where: {
id: {
@ -117,7 +117,7 @@ router.get('/organization/get', async (ctx) => {
ctx.body = COMMON_ERROR_RES.ACCESS_DENY
return
}
const organization = await Organization.findByPk(ctx.query.id, {
const organization = await Organization.findByPk(+ctx.query.id, {
attributes: { exclude: [] },
include: [QueryInclude.Creator, QueryInclude.Owner, QueryInclude.Members],
} as any)

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

@ -28,7 +28,7 @@ router.get('/test/test.status', (ctx) => {
// proxy
router.get('/proxy', async(ctx) => {
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.body = json
})

Loading…
Cancel
Save