Commit aaee50f9 by 杨昕

test

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