作者 liyuhang

gx

... ... @@ -16,7 +16,7 @@ class AiCommandController extends BaseController
* @method
*/
public function lists(AiCommandModel $aiCommandModel){
$lists = $aiCommandModel->lists($this->map,);
$lists = $aiCommandModel->lists($this->map);
$this->response('success',Code::SUCCESS,$lists);
}
... ...
... ... @@ -158,7 +158,7 @@ class BaseController extends Controller
}
switch ((string) $k) {
case 'image':
$v['image_link'] = file_get_contents($v);
$v['image_link'] = ($v);
break;
}
}
... ...
<?php
namespace App\Http\Controllers\Bside;
class MailController extends BaseController
{
}
... ...
<?php
namespace App\Http\Controllers\Bside;
use App\Enums\Common\Code;
use App\Models\Notice as NoticeModel;
class NoticeController extends BaseController
{
/**
* @name :登录首页获取通知列表
* @return void
* @author :liyuhang
* @method
*/
public function lists(){
$noticeModel = new NoticeModel();
//获取当前用户的通知消息列表
$this->map['user_list'] = ['like','%'.$this->uid,'%'];
$lists = $noticeModel->lists($this->map,$this->page,$this->row,'id',['title','content']);
$this->response('success',Code::SUCCESS,$lists);
}
}
<?php
namespace App\Http\Controllers;
use App\Enums\Common\Code;
use App\Models\Image as ImageModel;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Http\JsonResponse;
class ImageController
{
/**
* @name 统一返回参数
* @return JsonResponse
* @author :liyuhang
* @method
*/
public function response($msg = null,string $code = Code::SUCCESS,$data = [],$result_code = 200,$type = 'application/json'): JsonResponse
{
$code = Code::fromValue($code);
$result = [
'msg' => $msg == ' ' ? $code->description : $msg,
'code' => $code->value,
'data' => $this->_extents($data),
];
$this->header['Content-Type'] = $type;
$this->header['token'] = $this->token;
$response = response($result,$result_code,$this->header);;
throw new HttpResponseException($response);
}
public function index($hash){
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
header("HTTP/1.1 304 Not Modified");
exit;
}
$imageModel = new ImageModel();
$info = $imageModel->read(['hash'=>$hash]);
if ($info === false) {
$this->response('指定图片不存在!', 404);
}
$path = './../'.$info['path'];
if (!is_file($path)) {
$this->response('指定图片已被系统删除!', 404,$path);
}
$content = '';
$last_modified_time = gmdate(time() + ((30 * 60 * 60 * 24))) . " GMT";
$header = str_replace(['%Expires%', "%etag%", '%Last-Modified%'], [$last_modified_time, $hash, $last_modified_time], $this->config['header_cache']);
$content = file_get_contents($path);
$header['Content-Length'] = $info['size'];
return response($content, 200, $header);
}
}
... ...
... ... @@ -4,6 +4,7 @@ namespace App\Http\Logic\Bside;
use App\Exceptions\BsideGlobalException;
use App\Http\Logic\Logic;
use App\Models\Image as ImageModel;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
... ... @@ -91,7 +92,7 @@ class BaseLogic extends Logic
* @author :liyuhang
* @method
*/
public function upload(Request $request){
public function upload(Request $request,ImageModel $imageModel){
$image = $request->file('image');
if(empty($image)){
return $this->fail('没有上传图片',Code::USER_ERROR);
... ... @@ -104,9 +105,11 @@ class BaseLogic extends Logic
}
$data = [
'path' => $url.$filename,
'create_time' => date('Y-m-d H:i:s',time()),
'created_at' => date('Y-m-d H:i:s',time()),
'size' => $res->getSize(),
'hash' => $res->hash(),
];
return data;
$imageModel->add($data);
return $data;
}
}
... ...
<?php
namespace App\Models;
class Image extends Base
{
protected $table = 'gl_group';
public $timestamps = true;
}
... ...
... ... @@ -2,9 +2,9 @@
namespace App\Models;
class Notice extends Base
class Mail extends Base
{
protected $table = 'gl_notice';
protected $table = 'gl_mail';
//自动维护create_at创建时间 updated_at修改时间
public $timestamps = true;
}
... ...