作者 liyuhang

gx

@@ -16,7 +16,7 @@ class AiCommandController extends BaseController @@ -16,7 +16,7 @@ class AiCommandController extends BaseController
16 * @method 16 * @method
17 */ 17 */
18 public function lists(AiCommandModel $aiCommandModel){ 18 public function lists(AiCommandModel $aiCommandModel){
19 - $lists = $aiCommandModel->lists($this->map,); 19 + $lists = $aiCommandModel->lists($this->map);
20 $this->response('success',Code::SUCCESS,$lists); 20 $this->response('success',Code::SUCCESS,$lists);
21 } 21 }
22 22
@@ -158,7 +158,7 @@ class BaseController extends Controller @@ -158,7 +158,7 @@ class BaseController extends Controller
158 } 158 }
159 switch ((string) $k) { 159 switch ((string) $k) {
160 case 'image': 160 case 'image':
161 - $v['image_link'] = file_get_contents($v); 161 + $v['image_link'] = ($v);
162 break; 162 break;
163 } 163 }
164 } 164 }
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Bside;
  4 +
  5 +class MailController extends BaseController
  6 +{
  7 +
  8 +}
1 -<?php  
2 -  
3 -namespace App\Http\Controllers\Bside;  
4 -  
5 -use App\Enums\Common\Code;  
6 -use App\Models\Notice as NoticeModel;  
7 -  
8 -class NoticeController extends BaseController  
9 -{  
10 - /**  
11 - * @name :登录首页获取通知列表  
12 - * @return void  
13 - * @author :liyuhang  
14 - * @method  
15 - */  
16 - public function lists(){  
17 - $noticeModel = new NoticeModel();  
18 - //获取当前用户的通知消息列表  
19 - $this->map['user_list'] = ['like','%'.$this->uid,'%'];  
20 - $lists = $noticeModel->lists($this->map,$this->page,$this->row,'id',['title','content']);  
21 - $this->response('success',Code::SUCCESS,$lists);  
22 - }  
23 -  
24 -}  
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers;
  4 +
  5 +use App\Enums\Common\Code;
  6 +use App\Models\Image as ImageModel;
  7 +use Illuminate\Http\Exceptions\HttpResponseException;
  8 +use Illuminate\Http\JsonResponse;
  9 +
  10 +class ImageController
  11 +{
  12 + /**
  13 + * @name 统一返回参数
  14 + * @return JsonResponse
  15 + * @author :liyuhang
  16 + * @method
  17 + */
  18 + public function response($msg = null,string $code = Code::SUCCESS,$data = [],$result_code = 200,$type = 'application/json'): JsonResponse
  19 + {
  20 + $code = Code::fromValue($code);
  21 + $result = [
  22 + 'msg' => $msg == ' ' ? $code->description : $msg,
  23 + 'code' => $code->value,
  24 + 'data' => $this->_extents($data),
  25 + ];
  26 + $this->header['Content-Type'] = $type;
  27 + $this->header['token'] = $this->token;
  28 + $response = response($result,$result_code,$this->header);;
  29 + throw new HttpResponseException($response);
  30 + }
  31 +
  32 +
  33 + public function index($hash){
  34 + if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
  35 + header("HTTP/1.1 304 Not Modified");
  36 + exit;
  37 + }
  38 + $imageModel = new ImageModel();
  39 + $info = $imageModel->read(['hash'=>$hash]);
  40 + if ($info === false) {
  41 + $this->response('指定图片不存在!', 404);
  42 + }
  43 + $path = './../'.$info['path'];
  44 + if (!is_file($path)) {
  45 + $this->response('指定图片已被系统删除!', 404,$path);
  46 + }
  47 + $content = '';
  48 + $last_modified_time = gmdate(time() + ((30 * 60 * 60 * 24))) . " GMT";
  49 + $header = str_replace(['%Expires%', "%etag%", '%Last-Modified%'], [$last_modified_time, $hash, $last_modified_time], $this->config['header_cache']);
  50 + $content = file_get_contents($path);
  51 + $header['Content-Length'] = $info['size'];
  52 + return response($content, 200, $header);
  53 + }
  54 +}
@@ -4,6 +4,7 @@ namespace App\Http\Logic\Bside; @@ -4,6 +4,7 @@ namespace App\Http\Logic\Bside;
4 4
5 use App\Exceptions\BsideGlobalException; 5 use App\Exceptions\BsideGlobalException;
6 use App\Http\Logic\Logic; 6 use App\Http\Logic\Logic;
  7 +use App\Models\Image as ImageModel;
7 use Illuminate\Http\Request; 8 use Illuminate\Http\Request;
8 use Illuminate\Support\Facades\Cache; 9 use Illuminate\Support\Facades\Cache;
9 10
@@ -91,7 +92,7 @@ class BaseLogic extends Logic @@ -91,7 +92,7 @@ class BaseLogic extends Logic
91 * @author :liyuhang 92 * @author :liyuhang
92 * @method 93 * @method
93 */ 94 */
94 - public function upload(Request $request){ 95 + public function upload(Request $request,ImageModel $imageModel){
95 $image = $request->file('image'); 96 $image = $request->file('image');
96 if(empty($image)){ 97 if(empty($image)){
97 return $this->fail('没有上传图片',Code::USER_ERROR); 98 return $this->fail('没有上传图片',Code::USER_ERROR);
@@ -104,9 +105,11 @@ class BaseLogic extends Logic @@ -104,9 +105,11 @@ class BaseLogic extends Logic
104 } 105 }
105 $data = [ 106 $data = [
106 'path' => $url.$filename, 107 'path' => $url.$filename,
107 - 'create_time' => date('Y-m-d H:i:s',time()), 108 + 'created_at' => date('Y-m-d H:i:s',time()),
108 'size' => $res->getSize(), 109 'size' => $res->getSize(),
  110 + 'hash' => $res->hash(),
109 ]; 111 ];
110 - return data; 112 + $imageModel->add($data);
  113 + return $data;
111 } 114 }
112 } 115 }
  1 +<?php
  2 +
  3 +namespace App\Models;
  4 +
  5 +class Image extends Base
  6 +{
  7 + protected $table = 'gl_group';
  8 +
  9 + public $timestamps = true;
  10 +}
@@ -2,9 +2,9 @@ @@ -2,9 +2,9 @@
2 2
3 namespace App\Models; 3 namespace App\Models;
4 4
5 -class Notice extends Base 5 +class Mail extends Base
6 { 6 {
7 - protected $table = 'gl_notice'; 7 + protected $table = 'gl_mail';
8 //自动维护create_at创建时间 updated_at修改时间 8 //自动维护create_at创建时间 updated_at修改时间
9 public $timestamps = true; 9 public $timestamps = true;
10 } 10 }