作者 Your Name

Merge branch 'dev' of http://47.244.231.31:8099/zhl/globalso-v6 into dev

1 -<?php  
2 -  
3 -namespace App\Http\Controllers\Aside;  
4 -  
5 -class ProjectMenuController extends BaseController  
6 -{  
7 - /**  
8 - * @name :用户菜单列表  
9 - * @return void  
10 - * @author :liyuhang  
11 - * @method  
12 - */  
13 - public function lists(){  
14 -  
15 - }  
16 -}  
1 -<?php  
2 -  
3 -namespace App\Http\Controllers\Aside;  
4 -  
5 -class ProjectRoleController extends BaseController  
6 -{  
7 - /**  
8 - * @name :列表  
9 - * @return void  
10 - * @author :liyuhang  
11 - * @method  
12 - */  
13 - public function lists (){  
14 -  
15 - }  
16 -}  
1 -<?php  
2 -  
3 -namespace App\Http\Controllers\Aside;  
4 -  
5 -class ProjectUserController extends BaseController  
6 -{  
7 - /**  
8 - * @name :用户列表  
9 - * @return void  
10 - * @author :liyuhang  
11 - * @method  
12 - */  
13 - public function lists(){  
14 -  
15 - }  
16 -}  
@@ -97,9 +97,7 @@ class BaseController extends Controller @@ -97,9 +97,7 @@ class BaseController extends Controller
97 $this->map['updated_at'] = ['between', $this->_btw]; 97 $this->map['updated_at'] = ['between', $this->_btw];
98 break; 98 break;
99 default: 99 default:
100 - if (!empty($v)) {  
101 $this->map[$k] = $v; 100 $this->map[$k] = $v;
102 - }  
103 break; 101 break;
104 } 102 }
105 } 103 }
@@ -26,6 +26,8 @@ class CategoryController extends BaseController @@ -26,6 +26,8 @@ class CategoryController extends BaseController
26 } 26 }
27 $sort = ['id' => 'desc']; 27 $sort = ['id' => 'desc'];
28 $data = $logic->getList($map, $sort, ['id', 'pid', 'title', 'image', 'keywords', 'describe', 'status','created_at'],0); 28 $data = $logic->getList($map, $sort, ['id', 'pid', 'title', 'image', 'keywords', 'describe', 'status','created_at'],0);
  29 + var_dump($data);
  30 + die();
29 return $this->success(Arr::listToTree($data)); 31 return $this->success(Arr::listToTree($data));
30 } 32 }
31 33
@@ -7,7 +7,7 @@ use App\Models\Image as ImageModel; @@ -7,7 +7,7 @@ use App\Models\Image as ImageModel;
7 use Illuminate\Http\Exceptions\HttpResponseException; 7 use Illuminate\Http\Exceptions\HttpResponseException;
8 use Illuminate\Http\JsonResponse; 8 use Illuminate\Http\JsonResponse;
9 use Illuminate\Http\Request; 9 use Illuminate\Http\Request;
10 -use Illuminate\Support\Facades\Hash; 10 +use Illuminate\Support\Facades\DB;
11 use Intervention\Image\Facades\Image; 11 use Intervention\Image\Facades\Image;
12 12
13 class ImageController 13 class ImageController
@@ -109,27 +109,26 @@ class ImageController @@ -109,27 +109,26 @@ class ImageController
109 * @method 109 * @method
110 */ 110 */
111 public function single($files){ 111 public function single($files){
112 - if (is_array($files)) {  
113 - $file = current($files);  
114 - } 112 + $hash = hash_file('md5', $files->getPathname());
115 $url = './../uploads/images/'; 113 $url = './../uploads/images/';
116 $filename = date('ymdHis').rand(10000,99999); 114 $filename = date('ymdHis').rand(10000,99999);
117 - $res = $files->move($url,$filename); 115 + $res = $this->request->file('image')->move($url,$filename);
118 if ($res === false) { 116 if ($res === false) {
119 - return $this->fail($files->getError(), 400); 117 + return $this->fail($files->getError(), Code::USER_ERROR);
120 } 118 }
121 - 119 + $imageModel = new ImageModel();
122 $data = [ 120 $data = [
123 'path' => $url.$filename, 121 'path' => $url.$filename,
124 'created_at' => date('Y-m-d H:i:s',time()), 122 'created_at' => date('Y-m-d H:i:s',time()),
125 'size' => $res->getSize(), 123 'size' => $res->getSize(),
126 - 'hash' => hash_file('md5', $res->getPathname()), 124 + 'hash' => $hash.$filename,
127 'type'=>$files->getClientOriginalExtension(), 125 'type'=>$files->getClientOriginalExtension(),
128 -// 'mime'=>$files->getMimeType()  
129 ]; 126 ];
130 - $imageModel = new ImageModel();  
131 - $imageModel->add($data);  
132 - return $data['hash']; 127 + $rs = $imageModel->add($data);
  128 + if ($rs === false) {
  129 + return $this->fail('添加失败', Code::USER_ERROR);
  130 + }
  131 + return $hash.$filename;
133 } 132 }
134 /** 133 /**
135 * 生成缩略图缓存 134 * 生成缩略图缓存
@@ -146,6 +145,38 @@ class ImageController @@ -146,6 +145,38 @@ class ImageController
146 } 145 }
147 146
148 /** 147 /**
  148 + * 多图片上传
  149 + * @param type $files file对象集合
  150 + * @return type
  151 + */
  152 + private function multi($files) {
  153 + if (!is_array($files)) {
  154 + $files = [$files];
  155 + }
  156 + $save_data = [];
  157 + $data = [];
  158 + foreach ($files as $file) {
  159 + $hash = hash_file('md5', $file->getPathname());
  160 + $url = './../uploads/images/';
  161 + $filename = date('ymdHis').rand(10000,99999);
  162 + $res = $file->move($url,$filename);
  163 + if ($res === false) {
  164 + return $this->fail($file->getError(), 400);
  165 + }
  166 + $save_data[] = [
  167 + 'path' => $url.$filename,
  168 + 'created_at' => date('Y-m-d H:i:s',time()),
  169 + 'size' => $res->getSize(),
  170 + 'hash' => $hash.$filename,
  171 + 'type'=>$files->getClientOriginalExtension(),
  172 + ];
  173 + $data[] = $hash.$filename;
  174 + }
  175 + $imageModel = new ImageModel();
  176 + $imageModel->insertAll($data);
  177 + $this->response('上传成功!', 200, $data);
  178 + }
  179 + /**
149 * @name 统一返回参数 180 * @name 统一返回参数
150 * @return JsonResponse 181 * @return JsonResponse
151 * @author :liyuhang 182 * @author :liyuhang
1 -<?php  
2 -  
3 -namespace App\Http\Logic\Aside;  
4 -  
5 -  
6 -use App\Models\Project;  
7 -  
8 -class ProjectLogic extends BaseLogic  
9 -{  
10 - public function __construct()  
11 - {  
12 - parent::__construct();  
13 - $this->model = new Project();  
14 - $this->param = $this->requestAll;  
15 - }  
16 -  
17 -}  
1 -<?php  
2 -  
3 -namespace App\Http\Logic\Aside;  
4 -  
5 -use App\Models\ProjectRole;  
6 -  
7 -class ProjectRoleLogic extends BaseLogic  
8 -{  
9 - public function __construct()  
10 - {  
11 - parent::__construct();  
12 -  
13 - $this->model = new ProjectRole();  
14 - $this->param = $this->requestAll;  
15 - }  
16 -  
17 -}  
1 -<?php  
2 -  
3 -namespace App\Http\Logic\Aside;  
4 -  
5 -use App\Models\User;  
6 -  
7 -class UserLogic extends BaseLogic  
8 -{  
9 - public function __construct()  
10 - {  
11 - parent::__construct();  
12 -  
13 - $this->model = new User();  
14 - $this->param = $this->requestAll;  
15 - }  
16 -  
17 -}  
@@ -65,8 +65,8 @@ class UserLogic extends BaseLogic @@ -65,8 +65,8 @@ class UserLogic extends BaseLogic
65 if($info !== false && !empty($info['image'])){ 65 if($info !== false && !empty($info['image'])){
66 //TODO::删除资源 66 //TODO::删除资源
67 $imageModel = new Image(); 67 $imageModel = new Image();
68 - $image_info = $imageModel->read(['hash'=>$info['hash']],['id','path']);  
69 - shell_exec('rm -rf '.$image_info['path'] .'./../uploads/images/cache_'. $info['hash'] . '*'); 68 + $image_info = $imageModel->read(['hash'=>$info['image']],['id','path']);
  69 + shell_exec('rm -rf '.$image_info['path'] .'./../uploads/images/cache_'. $info['image'] . '*');
70 $imageModel->del(['hash'=>$info['image']]); 70 $imageModel->del(['hash'=>$info['image']]);
71 } 71 }
72 $this->param['image'] = $this->upload(); 72 $this->param['image'] = $this->upload();