Commit a590225d authored by 张育槟's avatar 张育槟

优化调试功能

parent 96d4df07
......@@ -5,6 +5,8 @@ namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
class LdapController extends Controller
{
public $host = '172.20.100.201';
......@@ -26,7 +28,9 @@ class LdapController extends Controller
}
public function handle(Request $request)
{
$data = $request->all();
try{
// //新增人员数据格式:
// $data = [
// 'operation_type'=>'emp',
......@@ -76,13 +80,30 @@ class LdapController extends Controller
if ($data['operation'] == 'add') {
$this->saveDept($data['data']);
} else if ($data['operation'] == 'edit') {
$this->editDept($data['data']);
$this->editDept($data['data']);
} else if ($data['operation'] == 'del') {
$this->delDept($data['data']);
}
}
}
$res= ['status' => true,'msg'=>'success'];
} catch (\Exception $e) {
$res= self::recordLog($e);
}
$res['data']=$data;
response()->json($res);
}
//记录异常出来的错误
public static function recordLog($e) {
$filename = 'ldap/'.date('Ymd').'.log';
$content = "time:".date("Y-m-d H:i:s").trans('service.20700').":".$e->getMessage().'所在文件:'.$e->getFile().'行号:'.$e->getLine();//发生异常
Storage::append($filename, $content);
return ['status' => false, 'msg' => $e->getMessage().$e->getMessage().'所在文件:'.$e->getFile().'行号:'.$e->getLine()];
}
public function saveEmp($data)
{
......
......@@ -52,4 +52,5 @@ Route::get('/ad', function () {
Route::get('/ad2','LdapController@handle');
//$app->get('/ad2','LdapController@handle');
Route::get('/handle','LdapController@handle');
\ No newline at end of file
Route::get('/handle','LdapController@handle');
Route::post('/handle','LdapController@handle');
\ No newline at end of file
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