Commit a5c8bb5c authored by nano's avatar nano

language platform Unique

parent 4c17e724
This diff is collapsed.
......@@ -104,6 +104,19 @@ router.post('/v1/package', async (ctx: Context, next) => {
else if (!_p.version) {
ctx.throw(400, `请填写版本号:${_p.id}`)
}
let exists_platform = await mongodb.Packages.find({ id: {$ne: _p.id}, appId: _p.appId, platforms: { $in: _p.platforms }, type: 'editing' }).count()
if(exists_platform) {
console.log(exists_platform)
ctx.throw(400, '平台已存在')
}
let exists_locales = await mongodb.Packages.find({ id: {$ne: _p.id}, appId: _p.appId, locales: { $in: _p.locales }, type: 'editing' }).count()
if(exists_locales) {
console.log(exists_locales)
ctx.throw(400, '语言已存在')
}
await mongodb.Packages.update({id: _p.id}, {$set: { type: 'edited' }}, {multi: true})
let _pack: Package = {
......@@ -137,6 +150,19 @@ router.patch('/v1/package', async (ctx: Context, next) => {
ctx.throw(400, `请填写版本号:${_p.id}`)
}
let exists_platform = await mongodb.Packages.find({ id: {$ne: _p.id}, appId: _p.appId, platforms: { $in: _p.platforms }, type: 'editing' }).count()
if(exists_platform) {
console.log(exists_platform)
ctx.throw(400, '平台已存在')
}
let exists_locales = await mongodb.Packages.find({ id: {$ne: _p.id}, appId: _p.appId, locales: { $in: _p.locales }, type: 'editing' }).count()
if(exists_locales) {
console.log(exists_locales)
ctx.throw(400, '语言已存在')
}
if (p.status == 'init') {
p.handleUpdate(_p)
ctx.body = await p.save()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment