正在显示
9 个修改的文件
包含
92 行增加
和
21 行删除
| 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 | } |
| @@ -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 | +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 | } |
| @@ -53,6 +53,8 @@ class NewsLogic extends BaseLogic | @@ -53,6 +53,8 @@ class NewsLogic extends BaseLogic | ||
| 53 | * @method | 53 | * @method |
| 54 | */ | 54 | */ |
| 55 | public function news_add(){ | 55 | public function news_add(){ |
| 56 | + var_dump($this->param); | ||
| 57 | + die(); | ||
| 56 | $this->param['create_id'] = $this->user['id']; | 58 | $this->param['create_id'] = $this->user['id']; |
| 57 | $this->param['operator_id'] = $this->user['id']; | 59 | $this->param['operator_id'] = $this->user['id']; |
| 58 | $this->param['project_id'] = $this->user['project_id']; | 60 | $this->param['project_id'] = $this->user['project_id']; |
-
请 注册 或 登录 后发表评论