| 
					
				 | 
			
			
				@ -36,17 +36,20 @@ class AppStatusRepo { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 保存App的最新状态。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param userId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param token 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param deviceToken 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param client_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param platform 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param handler 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    static save(userId, token, client_id, platform, handler) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    static save(userId, deviceToken, client_id, platform, handler) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        let sql = "INSERT INTO app_status (user_id, platform, token, client_id, app_in_bg, last_login_time) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            "VALUES (?, ?, ?, ?, 0, now()) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            "ON DUPLICATE KEY UPDATE platform=?, token=?, client_id=?, app_in_bg=0,last_login_time=now()"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        ImDb.execQuery({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            "sql": "INSERT INTO app_status (user_id, platform, token, client_id, app_in_bg, last_login_time) VALUES (?,?,?,?,1,1) ON" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            " DUPLICATE KEY UPDATE token=?,client_id=?,platform=?,is_online=1,status=1", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            "args": [userId, token, client_id, platform, token, client_id, platform], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            "handler": handler 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql: sql, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            args: [userId, platform, deviceToken, client_id, platform, deviceToken, client_id], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            handler: handler 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -64,14 +67,6 @@ class AppStatusRepo { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            "handler": handler 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    static delete(token, handler) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        ImDb.execQuery({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            "sql": "DELETE FROM user WHERE token=?", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            "args": [token], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            "handler": handler 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				module.exports = AppStatusRepo; 
			 |