| 
						
						
							
								
							
						
						
					 | 
					@ -3,6 +3,32 @@ const fs = require('fs'); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					const moment = require('moment') | 
					 | 
					 | 
					const moment = require('moment') | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					const uuid = require('uuid'); | 
					 | 
					 | 
					const uuid = require('uuid'); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					async function check (ctx) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    try { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        const { models } = this.fs.dc; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        const { appKey, appSecret } = this.request.body; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        const existRes = await models.Application.findOne({ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            where: { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                appKey: appKey, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                appSecret: appSecret, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        }) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (!existRes) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            throw '应用不存在' | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        } else if (existRes.forbidden) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            throw '应用已被禁用' | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        ctx.status = 204; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    } catch (error) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        ctx.status = 400; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        ctx.body = | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            typeof error == 'string' ? { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                message: error | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            } : error | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					async function edit (ctx, next) { | 
					 | 
					 | 
					async function edit (ctx, next) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    let errMsg = '创建应用失败' | 
					 | 
					 | 
					    let errMsg = '创建应用失败' | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    const transaction = await ctx.fs.dc.orm.transaction(); | 
					 | 
					 | 
					    const transaction = await ctx.fs.dc.orm.transaction(); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -21,7 +47,7 @@ async function edit (ctx, next) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                transaction | 
					 | 
					 | 
					                transaction | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            }) | 
					 | 
					 | 
					            }) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } else { | 
					 | 
					 | 
					        } else { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					             | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					            // 添加           
 | 
					 | 
					 | 
					            // 添加           
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            const storageData = Object.assign({}, data, { | 
					 | 
					 | 
					            const storageData = Object.assign({}, data, { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                appKey: uuid.v4(), | 
					 | 
					 | 
					                appKey: uuid.v4(), | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -51,6 +77,7 @@ async function edit (ctx, next) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					module.exports = { | 
					 | 
					 | 
					module.exports = { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    check, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    edit, | 
					 | 
					 | 
					    edit, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    get, | 
					 | 
					 | 
					    get, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					}; | 
					 | 
					 | 
					}; |