作者 赵彬吉

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

@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 /public/storage 3 /public/storage
4 /storage 4 /storage
5 /vendor 5 /vendor
  6 +/uploads
6 .env 7 .env
7 .env.backup 8 .env.backup
8 .phpunit.result.cache 9 .phpunit.result.cache
1 <?php 1 <?php
2 2
3 -namespace App\Http\Controllers\Aside; 3 +namespace App\Http\Controllers\Aside\User;
  4 +
  5 +use App\Http\Controllers\Aside\BaseController;
4 6
5 class ProjectMenuController extends BaseController 7 class ProjectMenuController extends BaseController
6 { 8 {
7 /** 9 /**
8 - * @name :用户菜单列表  
9 - * @return void 10 + * @name :用户菜单列表
  11 + * @return json
10 * @author :liyuhang 12 * @author :liyuhang
11 * @method 13 * @method
12 */ 14 */
1 <?php 1 <?php
2 2
3 -namespace App\Http\Controllers\Aside; 3 +namespace App\Http\Controllers\Aside\User;
  4 +
  5 +use App\Http\Controllers\Aside\BaseController;
4 6
5 class ProjectRoleController extends BaseController 7 class ProjectRoleController extends BaseController
6 { 8 {
7 /** 9 /**
8 * @name :列表 10 * @name :列表
9 - * @return void 11 + * @return json
10 * @author :liyuhang 12 * @author :liyuhang
11 * @method 13 * @method
12 */ 14 */
1 <?php 1 <?php
2 2
3 -namespace App\Http\Controllers\Aside; 3 +namespace App\Http\Controllers\Aside\User;
  4 +
  5 +use App\Enums\Common\Code;
  6 +use App\Http\Controllers\Aside\BaseController;
  7 +use App\Models\User as UserModel;
4 8
5 class ProjectUserController extends BaseController 9 class ProjectUserController extends BaseController
6 { 10 {
@@ -11,6 +15,18 @@ class ProjectUserController extends BaseController @@ -11,6 +15,18 @@ class ProjectUserController extends BaseController
11 * @method 15 * @method
12 */ 16 */
13 public function lists(){ 17 public function lists(){
  18 + $userModel = new UserModel();
  19 + $lists = $userModel->lists($this->map,$this->page,$this->row,$this->order,['id','mobile','name','created_at','updated_at','image','operator_id']);
  20 + $this->response('列表',Code::SUCCESS,$lists);
  21 + }
  22 +
  23 + /**
  24 + * @name :添加用户
  25 + * @return void
  26 + * @author :liyuhang
  27 + * @method
  28 + */
  29 + public function add(){
14 30
15 } 31 }
16 } 32 }
@@ -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;  
102 - } 100 + $this->map[$k] = $v;
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 1 <?php
2 2
3 -namespace App\Http\Logic\Aside; 3 +namespace App\Http\Logic\Aside\User;
4 4
5 5
  6 +use App\Http\Logic\Aside\BaseLogic;
6 use App\Models\Project; 7 use App\Models\Project;
7 8
8 class ProjectLogic extends BaseLogic 9 class ProjectLogic extends BaseLogic
1 <?php 1 <?php
2 2
3 -namespace App\Http\Logic\Aside; 3 +namespace App\Http\Logic\Aside\User;
4 4
  5 +use App\Http\Logic\Aside\BaseLogic;
5 use App\Models\ProjectRole; 6 use App\Models\ProjectRole;
6 7
7 class ProjectRoleLogic extends BaseLogic 8 class ProjectRoleLogic extends BaseLogic
1 <?php 1 <?php
2 2
3 -namespace App\Http\Logic\Aside; 3 +namespace App\Http\Logic\Aside\User;
4 4
  5 +use App\Enums\Common\Code;
  6 +use App\Http\Logic\Aside\BaseLogic;
5 use App\Models\User; 7 use App\Models\User;
6 8
7 class UserLogic extends BaseLogic 9 class UserLogic extends BaseLogic
@@ -14,4 +16,16 @@ class UserLogic extends BaseLogic @@ -14,4 +16,16 @@ class UserLogic extends BaseLogic
14 $this->param = $this->requestAll; 16 $this->param = $this->requestAll;
15 } 17 }
16 18
  19 + /**
  20 + * @name :添加会员
  21 + * @return void
  22 + * @author :liyuhang
  23 + * @method
  24 + */
  25 + public function user_add(){
  26 + $info = $this->model->read(['mobile'=>$this->param['mobile']]);
  27 + if($info !== false){
  28 + $this->fail('error',Code::USER_ERROR);
  29 + }
  30 + }
17 } 31 }
@@ -59,19 +59,19 @@ class NewsLogic extends BaseLogic @@ -59,19 +59,19 @@ class NewsLogic extends BaseLogic
59 $this->param['created_at'] = date('Y-m-d H:i:s',time()); 59 $this->param['created_at'] = date('Y-m-d H:i:s',time());
60 $this->param['updated_at'] = date('Y-m-d H:i:s',time()); 60 $this->param['updated_at'] = date('Y-m-d H:i:s',time());
61 $this->param['category_id'] = ','.$this->param['category_id'].','; 61 $this->param['category_id'] = ','.$this->param['category_id'].',';
62 - DB::beginTransaction();  
63 - try { 62 +// DB::beginTransaction();
  63 +// try {
64 if(isset($this->param['image'])){ 64 if(isset($this->param['image'])){
65 $data = $this->upload(); 65 $data = $this->upload();
66 $this->param['image'] = $data; 66 $this->param['image'] = $data;
67 } 67 }
68 $rs = $this->model->insertGetId($this->param); 68 $rs = $this->model->insertGetId($this->param);
69 RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']); 69 RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']);
70 - DB::commit();  
71 - }catch (\Exception $e){  
72 - DB::rollBack();  
73 - $this->fail('添加失败',Code::USER_ERROR);  
74 - } 70 +// DB::commit();
  71 +// }catch (\Exception $e){
  72 +// DB::rollBack();
  73 +// $this->fail('添加失败',Code::USER_ERROR);
  74 +// }
75 //TODO::写入日志 75 //TODO::写入日志
76 $this->success(); 76 $this->success();
77 } 77 }
@@ -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();
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型