Commit aaee50f9 by 杨昕

test

parent 6395be7b
Pipeline #9765 passed with stages
in 32 seconds
...@@ -22,7 +22,7 @@ class MediaController extends Controller ...@@ -22,7 +22,7 @@ class MediaController extends Controller
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\ControllerException * @throws \App\Exceptions\ControllerException
*/ */
public function getMediaNum(Request $request){ public function index(Request $request){
$result = handler_drive(function () use ($request) { $result = handler_drive(function () use ($request) {
return ["mediaID" => date('YmdHis',time()).generateRandomNum(8)]; return ["mediaID" => date('YmdHis',time()).generateRandomNum(8)];
......
...@@ -58,8 +58,14 @@ class UsersController extends Controller ...@@ -58,8 +58,14 @@ class UsersController extends Controller
'create_time' => date('Y-m-d H:i:s',time()), 'create_time' => date('Y-m-d H:i:s',time()),
'user_type' => 1 'user_type' => 1
]; ];
DB::connection("mongodb")->collection("users")->insertGetId($data); $id = DB::connection("mongodb")->collection("users")->insertGetId($data);
if (!$id){
$result = false;
}else{
$result = true; $result = true;
}
}else{ }else{
if ($user['password'] == md5($password)){ if ($user['password'] == md5($password)){
...@@ -102,6 +108,11 @@ class UsersController extends Controller ...@@ -102,6 +108,11 @@ class UsersController extends Controller
$idArr = ($user['_id'])->jsonSerialize(); $idArr = ($user['_id'])->jsonSerialize();
}else{ }else{
$id = DB::connection("mongodb")->collection("users")->insertGetId($data); $id = DB::connection("mongodb")->collection("users")->insertGetId($data);
if (!$id){
throw new DatabaseException('用户存储失败');
}
$idArr = ($id)->jsonSerialize(); $idArr = ($id)->jsonSerialize();
} }
...@@ -109,7 +120,11 @@ class UsersController extends Controller ...@@ -109,7 +120,11 @@ class UsersController extends Controller
$newtoken = encrypt($_id.'|'.$token."|1ZGHd3pCc87AsQFBLLJeMjM4t57cli6Ar78qowe7"); $newtoken = encrypt($_id.'|'.$token."|1ZGHd3pCc87AsQFBLLJeMjM4t57cli6Ar78qowe7");
$data['token'] = $newtoken; $data['token'] = $newtoken;
DB::connection('mongodb')->collection('users')->where('_id',$_id)->update($data); $flag = DB::connection('mongodb')->collection('users')->where('_id',$_id)->update($data);
if (!$flag){
throw new DatabaseException('用户名信息更新失败');
}
return $newtoken; return $newtoken;
......
...@@ -14,7 +14,7 @@ class MediaRoute extends AuthenRoute ...@@ -14,7 +14,7 @@ class MediaRoute extends AuthenRoute
{ {
public function map(Registrar $router,$callback){ public function map(Registrar $router,$callback){
parent::map($router,function() use ($router){ parent::map($router,function() use ($router){
$router->resource('media','MediaController'); $router->resource('media_manager','MediaController');
}); });
} }
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
namespace App\Model; namespace App\Model;
use App\Exceptions\DatabaseException;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
class MediaModel extends Model class MediaModel extends Model
{ {
...@@ -22,26 +24,21 @@ class MediaModel extends Model ...@@ -22,26 +24,21 @@ class MediaModel extends Model
$where['name'] = $request->name; $where['name'] = $request->name;
} }
$medias = DB::connection('mongodb')->collection('media')
$users = DB::connection('mongodb')->collection('media')
->where($where) ->where($where)
->paginate(10); ->paginate(10);
foreach ( $medias as &$user){
// dd($users);die;
foreach ( $users as &$user){
$idArr = ($user['_id'])->jsonSerialize(); $idArr = ($user['_id'])->jsonSerialize();
$user['_id'] = $idArr['$oid']; $user['_id'] = $idArr['$oid'];
} }
}catch (\Exception $exception){ }catch (\Exception $exception){
throw new DatabaseException($exception->getMessage()); throw new DatabaseException($exception->getMessage());
} }
return $users; return $medias;
} }
......
...@@ -130,14 +130,25 @@ ...@@ -130,14 +130,25 @@
"description": "", "description": "",
"show": 1, "show": 1,
"sort": 2, "sort": 2,
"key_name": "manager_role_block", "key_name": "manager_media",
"son": [{ "son": [{
"id": 15,
"pid": 11,
"name": "媒资列表",
"icon": "",
"link": "/media_manager",
"slug": "media_manager.index",
"description": "",
"show": 1,
"sort": 25,
"key_name": "media_list"
},{
"id": 23, "id": 23,
"pid": 11, "pid": 11,
"name": "媒资删除", "name": "媒资删除",
"icon": "", "icon": "",
"link": "", "link": "",
"slug": "media.destroy", "slug": "media_manager.destroy",
"description": "", "description": "",
"show": 0, "show": 0,
"sort": 25, "sort": 25,
...@@ -148,7 +159,7 @@ ...@@ -148,7 +159,7 @@
"name": "媒资添加保存", "name": "媒资添加保存",
"icon": "", "icon": "",
"link": "", "link": "",
"slug": "media.store", "slug": "media_manager.store",
"description": "", "description": "",
"show": 0, "show": 0,
"sort": 25, "sort": 25,
...@@ -159,7 +170,7 @@ ...@@ -159,7 +170,7 @@
"name": "媒资修改保存", "name": "媒资修改保存",
"icon": "", "icon": "",
"link": "", "link": "",
"slug": "media.update", "slug": "media_manager.update",
"description": "", "description": "",
"show": 0, "show": 0,
"sort": 25, "sort": 25,
...@@ -170,7 +181,7 @@ ...@@ -170,7 +181,7 @@
"name": "媒资编辑", "name": "媒资编辑",
"icon": "", "icon": "",
"link": "", "link": "",
"slug": "media.edit", "slug": "media_manager.edit",
"description": "", "description": "",
"show": 0, "show": 0,
"sort": 25, "sort": 25,
...@@ -180,22 +191,11 @@ ...@@ -180,22 +191,11 @@
"pid": 11, "pid": 11,
"name": "媒资添加", "name": "媒资添加",
"icon": "", "icon": "",
"link": "/media/create", "link": "/media_manager/create",
"slug": "media.create", "slug": "media_manager.create",
"description": "", "description": "",
"show": 0, "show": 0,
"sort": 25, "sort": 25,
"key_name": "media_create" "key_name": "media_create"
},{
"id": 15,
"pid": 11,
"name": "媒资列表",
"icon": "",
"link": "/media",
"slug": "media.index",
"description": "",
"show": 1,
"sort": 25,
"key_name": "media_list"
}] }]
}] }]
\ No newline at end of file
...@@ -105,6 +105,8 @@ ...@@ -105,6 +105,8 @@
//设置选择项颜色 //设置选择项颜色
$(li_arr[i]).children("a:eq(0)").addClass('choice'); $(li_arr[i]).children("a:eq(0)").addClass('choice');
console.log('$(li_arr[i])', $(li_arr[i])) console.log('$(li_arr[i])', $(li_arr[i]))
} }
} }
......
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