作者 赵彬吉

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

... ... @@ -3,6 +3,7 @@
/public/storage
/storage
/vendor
/uploads
.env
.env.backup
.phpunit.result.cache
... ...
<?php
namespace App\Http\Controllers\Aside;
namespace App\Http\Controllers\Aside\User;
use App\Http\Controllers\Aside\BaseController;
class ProjectMenuController extends BaseController
{
/**
* @name :用户菜单列表
* @return void
* @name :用户菜单列表
* @return json
* @author :liyuhang
* @method
*/
... ...
<?php
namespace App\Http\Controllers\Aside;
namespace App\Http\Controllers\Aside\User;
use App\Http\Controllers\Aside\BaseController;
class ProjectRoleController extends BaseController
{
/**
* @name :列表
* @return void
* @return json
* @author :liyuhang
* @method
*/
... ...
<?php
namespace App\Http\Controllers\Aside;
namespace App\Http\Controllers\Aside\User;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Models\User as UserModel;
class ProjectUserController extends BaseController
{
... ... @@ -11,6 +15,18 @@ class ProjectUserController extends BaseController
* @method
*/
public function lists(){
$userModel = new UserModel();
$lists = $userModel->lists($this->map,$this->page,$this->row,$this->order,['id','mobile','name','created_at','updated_at','image','operator_id']);
$this->response('列表',Code::SUCCESS,$lists);
}
/**
* @name :添加用户
* @return void
* @author :liyuhang
* @method
*/
public function add(){
}
}
... ...
... ... @@ -97,9 +97,7 @@ class BaseController extends Controller
$this->map['updated_at'] = ['between', $this->_btw];
break;
default:
if (!empty($v)) {
$this->map[$k] = $v;
}
$this->map[$k] = $v;
break;
}
}
... ...
... ... @@ -26,6 +26,8 @@ class CategoryController extends BaseController
}
$sort = ['id' => 'desc'];
$data = $logic->getList($map, $sort, ['id', 'pid', 'title', 'image', 'keywords', 'describe', 'status','created_at'],0);
var_dump($data);
die();
return $this->success(Arr::listToTree($data));
}
... ...
... ... @@ -7,7 +7,7 @@ use App\Models\Image as ImageModel;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\DB;
use Intervention\Image\Facades\Image;
class ImageController
... ... @@ -109,27 +109,26 @@ class ImageController
* @method
*/
public function single($files){
if (is_array($files)) {
$file = current($files);
}
$hash = hash_file('md5', $files->getPathname());
$url = './../uploads/images/';
$filename = date('ymdHis').rand(10000,99999);
$res = $files->move($url,$filename);
$res = $this->request->file('image')->move($url,$filename);
if ($res === false) {
return $this->fail($files->getError(), 400);
return $this->fail($files->getError(), Code::USER_ERROR);
}
$imageModel = new ImageModel();
$data = [
'path' => $url.$filename,
'created_at' => date('Y-m-d H:i:s',time()),
'size' => $res->getSize(),
'hash' => hash_file('md5', $res->getPathname()),
'hash' => $hash.$filename,
'type'=>$files->getClientOriginalExtension(),
// 'mime'=>$files->getMimeType()
];
$imageModel = new ImageModel();
$imageModel->add($data);
return $data['hash'];
$rs = $imageModel->add($data);
if ($rs === false) {
return $this->fail('添加失败', Code::USER_ERROR);
}
return $hash.$filename;
}
/**
* 生成缩略图缓存
... ... @@ -146,6 +145,38 @@ class ImageController
}
/**
* 多图片上传
* @param type $files file对象集合
* @return type
*/
private function multi($files) {
if (!is_array($files)) {
$files = [$files];
}
$save_data = [];
$data = [];
foreach ($files as $file) {
$hash = hash_file('md5', $file->getPathname());
$url = './../uploads/images/';
$filename = date('ymdHis').rand(10000,99999);
$res = $file->move($url,$filename);
if ($res === false) {
return $this->fail($file->getError(), 400);
}
$save_data[] = [
'path' => $url.$filename,
'created_at' => date('Y-m-d H:i:s',time()),
'size' => $res->getSize(),
'hash' => $hash.$filename,
'type'=>$files->getClientOriginalExtension(),
];
$data[] = $hash.$filename;
}
$imageModel = new ImageModel();
$imageModel->insertAll($data);
$this->response('上传成功!', 200, $data);
}
/**
* @name 统一返回参数
* @return JsonResponse
* @author :liyuhang
... ...
<?php
namespace App\Http\Logic\Aside;
namespace App\Http\Logic\Aside\User;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Project;
class ProjectLogic extends BaseLogic
... ...
<?php
namespace App\Http\Logic\Aside;
namespace App\Http\Logic\Aside\User;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\ProjectRole;
class ProjectRoleLogic extends BaseLogic
... ...
<?php
namespace App\Http\Logic\Aside;
namespace App\Http\Logic\Aside\User;
use App\Enums\Common\Code;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\User;
class UserLogic extends BaseLogic
... ... @@ -14,4 +16,16 @@ class UserLogic extends BaseLogic
$this->param = $this->requestAll;
}
/**
* @name :添加会员
* @return void
* @author :liyuhang
* @method
*/
public function user_add(){
$info = $this->model->read(['mobile'=>$this->param['mobile']]);
if($info !== false){
$this->fail('error',Code::USER_ERROR);
}
}
}
... ...
... ... @@ -59,19 +59,19 @@ class NewsLogic extends BaseLogic
$this->param['created_at'] = date('Y-m-d H:i:s',time());
$this->param['updated_at'] = date('Y-m-d H:i:s',time());
$this->param['category_id'] = ','.$this->param['category_id'].',';
DB::beginTransaction();
try {
// DB::beginTransaction();
// try {
if(isset($this->param['image'])){
$data = $this->upload();
$this->param['image'] = $data;
}
$rs = $this->model->insertGetId($this->param);
RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('添加失败',Code::USER_ERROR);
}
// DB::commit();
// }catch (\Exception $e){
// DB::rollBack();
// $this->fail('添加失败',Code::USER_ERROR);
// }
//TODO::写入日志
$this->success();
}
... ...
... ... @@ -65,8 +65,8 @@ class UserLogic extends BaseLogic
if($info !== false && !empty($info['image'])){
//TODO::删除资源
$imageModel = new Image();
$image_info = $imageModel->read(['hash'=>$info['hash']],['id','path']);
shell_exec('rm -rf '.$image_info['path'] .'./../uploads/images/cache_'. $info['hash'] . '*');
$image_info = $imageModel->read(['hash'=>$info['image']],['id','path']);
shell_exec('rm -rf '.$image_info['path'] .'./../uploads/images/cache_'. $info['image'] . '*');
$imageModel->del(['hash'=>$info['image']]);
}
$this->param['image'] = $this->upload();
... ...
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型