作者 lyh

gx

@@ -127,15 +127,10 @@ class Common @@ -127,15 +127,10 @@ class Common
127 * @method :post 127 * @method :post
128 * @time :2023/5/9 10:47 128 * @time :2023/5/9 10:47
129 */ 129 */
130 - public static function uniqueMultiArray($multiArray) {  
131 - $flatArray = array();  
132 - foreach ($multiArray as $item) {  
133 - if (is_array($item)) {  
134 - $flatArray = array_merge($flatArray, uniqueMultiArray($item));  
135 - } else {  
136 - $flatArray[] = $item;  
137 - }  
138 - }  
139 - return array_map("unserialize", array_unique(array_map("serialize", $flatArray))); 130 + public static function uniqueMultiArray($arr) {
  131 + $arr = array_map('serialize', $arr);
  132 + $arr = array_unique($arr);
  133 + $arr = array_map('unserialize', $arr);
  134 + return $arr;
140 } 135 }
141 } 136 }
@@ -7,7 +7,6 @@ use App\Helper\AyrShare as AyrShareHelper; @@ -7,7 +7,6 @@ use App\Helper\AyrShare as AyrShareHelper;
7 use App\Http\Controllers\Bside\BaseController; 7 use App\Http\Controllers\Bside\BaseController;
8 use App\Http\Logic\Bside\AyrShare\AyrReleaseLogic; 8 use App\Http\Logic\Bside\AyrShare\AyrReleaseLogic;
9 use App\Http\Logic\Bside\AyrShare\AyrShareLogic; 9 use App\Http\Logic\Bside\AyrShare\AyrShareLogic;
10 -use Illuminate\Support\Facades\DB;  
11 10
12 /** 11 /**
13 * @name:社交发布 12 * @name:社交发布
@@ -15,16 +14,36 @@ use Illuminate\Support\Facades\DB; @@ -15,16 +14,36 @@ use Illuminate\Support\Facades\DB;
15 class AyrReleaseController extends BaseController 14 class AyrReleaseController extends BaseController
16 { 15 {
17 /** 16 /**
  17 + * @name :(获取当前用户已绑定的社交链接)info
  18 + * @author :lyh
  19 + * @method :post
  20 + * @time :2023/5/9 16:00
  21 + */
  22 + public function info(AyrShareLogic $ayrShareLogic){
  23 + $info = $ayrShareLogic->ayr_share_info();
  24 + $this->response('success',Code::SUCCESS,$info);
  25 + }
  26 + /**
18 * @name :(发布社交)send_post 27 * @name :(发布社交)send_post
19 * @author :lyh 28 * @author :lyh
20 * @method :post 29 * @method :post
21 * @time :2023/5/9 9:36 30 * @time :2023/5/9 9:36
22 */ 31 */
23 public function send_post(AyrReleaseLogic $ayrReleaseLogic,AyrShareLogic $ayrShareLogic){ 32 public function send_post(AyrReleaseLogic $ayrReleaseLogic,AyrShareLogic $ayrShareLogic){
24 - DB::beginTransaction();  
25 - try { 33 +// DB::beginTransaction();
  34 +// try {
26 //获取发送账号详情 35 //获取发送账号详情
27 $share_info = $ayrShareLogic->ayr_share_info(); 36 $share_info = $ayrShareLogic->ayr_share_info();
  37 + $data = [
  38 + 'images'=>$this->param['image'],
  39 + 'files'=>$this->param['file'],
  40 + ];
  41 + //参数处理
  42 + $image_data = $this->image_file_param($data);
  43 + $this->param['mediaUrls'] = array_merge($image_data['images_link'],$image_data['files_link']);
  44 + var_dump($this->param);
  45 + die();
  46 + //统一生成链接
28 $param = [ 47 $param = [
29 'post'=>$this->param['content'], 48 'post'=>$this->param['content'],
30 'platforms'=>$this->param['platforms'], 49 'platforms'=>$this->param['platforms'],
@@ -36,9 +55,54 @@ class AyrReleaseController extends BaseController @@ -36,9 +55,54 @@ class AyrReleaseController extends BaseController
36 $this->response('success',Code::SUCCESS,$res); 55 $this->response('success',Code::SUCCESS,$res);
37 //保存数据库 56 //保存数据库
38 $ayrReleaseLogic->release_add(); 57 $ayrReleaseLogic->release_add();
39 - }catch (\Exception $e){ 58 +// DB::commit();
  59 +// }catch (\Exception $e){
  60 +// DB::rollBack();
  61 +// $this->response('error',Code::USER_ERROR);
  62 +// }
  63 + }
40 64
  65 + /**
  66 + * @name :(上传第三方参数参数)get_param
  67 + * @author :lyh
  68 + * @method :post
  69 + * @time :2023/5/10 10:27
  70 + */
  71 + public function image_file_param($data) {
  72 + if (empty($data) || !is_array($data)) {
  73 + return empty($data) ? is_array($data) ? [] : '' : $data;
  74 + }
  75 + foreach ($data as $k => $v) {
  76 + if (is_array($v)) {
  77 + $data[$k] = $this->_extents($v);
  78 + } else {
  79 + if (is_null($v)) {
  80 + $data[$k] = '';
  81 + continue;
  82 + }
  83 + //获取操作人
  84 + switch ((string) $k) {
  85 + case 'image':
  86 + $data['image_link'] = url('/b/image/' . $v . '/2');
  87 + break;
  88 + case 'images':
  89 + $v = explode(',',$v);
  90 + foreach ($v as $k1=>$v1){
  91 + $data['images_link'][$k1] = url('/b/image/' . $v1 . '/2');
  92 + }
  93 + break;
  94 + case 'file':
  95 + $data['file_link'] = url('/b/file_hash/' . $v .'/mp4');
  96 + break;
  97 + case 'files':
  98 + $v = explode(',',$v);
  99 + foreach ($v as $k1=>$v1){
  100 + $data['files_link'][$k1] = url('/b/file_hash/' . $v1 . '/mp4');
  101 + }
  102 + break;
  103 + }
  104 + }
41 } 105 }
  106 + return $data;
42 } 107 }
43 -  
44 } 108 }
@@ -78,7 +78,7 @@ class AyrShareController extends BaseController @@ -78,7 +78,7 @@ class AyrShareController extends BaseController
78 'title'=>$info['title'], 78 'title'=>$info['title'],
79 'profileKey'=>$info['profile_key'] 79 'profileKey'=>$info['profile_key']
80 ]; 80 ];
81 - //发送请求注册社交用户 81 + //发送请求删除社交用户
82 $ayrShareHelper = new AyrShareHelper(); 82 $ayrShareHelper = new AyrShareHelper();
83 $res = $ayrShareHelper->deleted_profiles($data); 83 $res = $ayrShareHelper->deleted_profiles($data);
84 if($res['status'] == 'fail'){ 84 if($res['status'] == 'fail'){
@@ -141,8 +141,7 @@ class BaseController extends Controller @@ -141,8 +141,7 @@ class BaseController extends Controller
141 * @author :liyuhang 141 * @author :liyuhang
142 * @method 142 * @method
143 */ 143 */
144 - public function _extents($data) {  
145 - 144 + protected function _extents($data) {
146 if (empty($data) || !is_array($data)) { 145 if (empty($data) || !is_array($data)) {
147 return empty($data) ? is_array($data) ? [] : '' : $data; 146 return empty($data) ? is_array($data) ? [] : '' : $data;
148 } 147 }
@@ -159,6 +158,12 @@ class BaseController extends Controller @@ -159,6 +158,12 @@ class BaseController extends Controller
159 case 'image': 158 case 'image':
160 $data['image_link'] = url('/b/image/' . $v); 159 $data['image_link'] = url('/b/image/' . $v);
161 break; 160 break;
  161 + case 'images':
  162 + $v = explode(',',$v);
  163 + foreach ($v as $k1=>$v1){
  164 + $data['images_link'][$k1] = url('/b/image/' . $v1);
  165 + }
  166 + break;
162 case 'file': 167 case 'file':
163 $data['file_link'] = url('/b/file_hash/' . $v); 168 $data['file_link'] = url('/b/file_hash/' . $v);
164 break; 169 break;
@@ -11,6 +11,7 @@ use App\Http\Logic\Bside\Setting\WebSettingServiceLogic; @@ -11,6 +11,7 @@ use App\Http\Logic\Bside\Setting\WebSettingServiceLogic;
11 */ 11 */
12 class WebSettingServiceController extends BaseController 12 class WebSettingServiceController extends BaseController
13 { 13 {
  14 + const TYPE_CODE = 6;
14 /** 15 /**
15 * @name :lists 16 * @name :lists
16 * @author :lyh 17 * @author :lyh
@@ -19,6 +20,12 @@ class WebSettingServiceController extends BaseController @@ -19,6 +20,12 @@ class WebSettingServiceController extends BaseController
19 */ 20 */
20 public function lists(WebSettingServiceLogic $webSettingServiceLogic){ 21 public function lists(WebSettingServiceLogic $webSettingServiceLogic){
21 $lists = $webSettingServiceLogic->setting_service_list(); 22 $lists = $webSettingServiceLogic->setting_service_list();
  23 + foreach ($lists as $k => $v){
  24 + if($v['type'] == self::TYPE_CODE){
  25 + $v['values_link'] = url('/b/image/' . $v['values']);
  26 + $lists[$k] = $v;
  27 + }
  28 + }
22 $this->response('success',Code::SUCCESS,$lists); 29 $this->response('success',Code::SUCCESS,$lists);
23 } 30 }
24 /** 31 /**
@@ -25,7 +25,7 @@ class FileController @@ -25,7 +25,7 @@ class FileController
25 25
26 public $config = ''; 26 public $config = '';
27 27
28 - public $thr_path = ''; 28 + public $uploads = '';
29 29
30 public $request = ''; 30 public $request = '';
31 31
@@ -33,7 +33,8 @@ class FileController @@ -33,7 +33,8 @@ class FileController
33 { 33 {
34 $this->request = request(); 34 $this->request = request();
35 $this->config = config('filesystems.disks.upload'); 35 $this->config = config('filesystems.disks.upload');
36 - $this->path = $this->config['root'].'/file/'; 36 + $this->uploads = config('uploads.default_file');
  37 + $this->path = $this->config['root'].$this->uploads['path'].'/';
37 } 38 }
38 39
39 /** 40 /**
@@ -43,7 +44,7 @@ class FileController @@ -43,7 +44,7 @@ class FileController
43 * @method :post 44 * @method :post
44 * @time :2023/5/9 9:15 45 * @time :2023/5/9 9:15
45 */ 46 */
46 - public function index($hash = ''){ 47 + public function index($hash = '',$type = 1){
47 if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) { 48 if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
48 header("HTTP/1.1 304 Not Modified"); 49 header("HTTP/1.1 304 Not Modified");
49 exit; 50 exit;
@@ -59,6 +60,7 @@ class FileController @@ -59,6 +60,7 @@ class FileController
59 } 60 }
60 $content = file_get_contents($path); 61 $content = file_get_contents($path);
61 $header['Content-Length'] = $info['size']; 62 $header['Content-Length'] = $info['size'];
  63 + $header['Content-Type'] = 'video/'.$info['type'];
62 return response($content, 200, $header); 64 return response($content, 200, $header);
63 } 65 }
64 /** 66 /**
@@ -66,9 +68,9 @@ class FileController @@ -66,9 +68,9 @@ class FileController
66 */ 68 */
67 public function upload() { 69 public function upload() {
68 $this->request->validate([ 70 $this->request->validate([
69 - 'image'=>['required'], 71 + 'file'=>['required'],
70 ],[ 72 ],[
71 - 'image.required'=>'图片必须填写', 73 + 'file.required'=>'必须填写',
72 ]); 74 ]);
73 $files = $this->request->file('file'); 75 $files = $this->request->file('file');
74 if (empty($files)) { 76 if (empty($files)) {
@@ -82,7 +84,7 @@ class FileController @@ -82,7 +84,7 @@ class FileController
82 } 84 }
83 } 85 }
84 /** 86 /**
85 - * @name :上传图片 87 + * @name :上传
86 * @return void 88 * @return void
87 * @author :liyuhang 89 * @author :liyuhang
88 * @method 90 * @method
@@ -96,12 +98,13 @@ class FileController @@ -96,12 +98,13 @@ class FileController
96 return $hash; 98 return $hash;
97 } 99 }
98 $url = $this->path; 100 $url = $this->path;
99 - $res = $this->request->file('image')->move($url); 101 + $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
  102 + $res = $files->move($url,$fileName);
100 if ($res === false) { 103 if ($res === false) {
101 return $this->response($files->getError(), Code::USER_ERROR); 104 return $this->response($files->getError(), Code::USER_ERROR);
102 } 105 }
103 $data = [ 106 $data = [
104 - 'path' => $url.'/'.$res->getClientOriginalName(), 107 + 'path' => $url.$fileName,
105 'created_at' => date('Y-m-d H:i:s',time()), 108 'created_at' => date('Y-m-d H:i:s',time()),
106 'size' => $res->getSize(), 109 'size' => $res->getSize(),
107 'hash' => $hash, 110 'hash' => $hash,
@@ -111,7 +114,7 @@ class FileController @@ -111,7 +114,7 @@ class FileController
111 if ($rs === false) { 114 if ($rs === false) {
112 return $this->response('添加失败', Code::USER_ERROR); 115 return $this->response('添加失败', Code::USER_ERROR);
113 } 116 }
114 - return $hash; 117 + return $this->response('资源',Code::SUCCESS,['file'=>$hash]);
115 } 118 }
116 /** 119 /**
117 * 多文件上传 120 * 多文件上传
@@ -133,12 +136,13 @@ class FileController @@ -133,12 +136,13 @@ class FileController
133 continue; 136 continue;
134 } 137 }
135 $url = $this->path; 138 $url = $this->path;
136 - $res = $file->move($url); 139 + $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
  140 + $res = $file->move($url,$fileName);
137 if ($res === false) { 141 if ($res === false) {
138 return $this->response($file->getError(), Code::USER_ERROR); 142 return $this->response($file->getError(), Code::USER_ERROR);
139 } 143 }
140 $save_data[] = [ 144 $save_data[] = [
141 - 'path' => $url.'/'.$res->getClientOriginalName(), 145 + 'path' => $url.$fileName,
142 'created_at' => date('Y-m-d H:i:s',time()), 146 'created_at' => date('Y-m-d H:i:s',time()),
143 'size' => $res->getSize(), 147 'size' => $res->getSize(),
144 'hash' => $hash, 148 'hash' => $hash,
@@ -147,7 +151,7 @@ class FileController @@ -147,7 +151,7 @@ class FileController
147 $data[] = $hash; 151 $data[] = $hash;
148 } 152 }
149 $fileModel->insert($save_data); 153 $fileModel->insert($save_data);
150 - return $data; 154 + return $this->response('资源',Code::SUCCESS,['files'=>$data]);
151 } 155 }
152 /** 156 /**
153 * @name 统一返回参数 157 * @name 统一返回参数
@@ -161,10 +165,46 @@ class FileController @@ -161,10 +165,46 @@ class FileController
161 $result = [ 165 $result = [
162 'msg' => $msg == ' ' ? $code->description : $msg, 166 'msg' => $msg == ' ' ? $code->description : $msg,
163 'code' => $code->value, 167 'code' => $code->value,
164 - 'data' => $data, 168 + 'data' => $this->_extents($data),
165 ]; 169 ];
166 $this->header['Content-Type'] = $type; 170 $this->header['Content-Type'] = $type;
167 $response = response($result,$result_code,$this->header); 171 $response = response($result,$result_code,$this->header);
168 throw new HttpResponseException($response); 172 throw new HttpResponseException($response);
169 } 173 }
  174 +
  175 + /**
  176 + * @param $data
  177 + * @name :返回参数处理
  178 + * @return array|string
  179 + * @author :liyuhang
  180 + * @method
  181 + */
  182 + protected function _extents($data) {
  183 +
  184 + if (empty($data) || !is_array($data)) {
  185 + return empty($data) ? is_array($data) ? [] : '' : $data;
  186 + }
  187 + foreach ($data as $k => $v) {
  188 + if (is_array($v)) {
  189 + $data[$k] = $this->_extents($v);
  190 + } else {
  191 + if (is_null($v)) {
  192 + $data[$k] = '';
  193 + continue;
  194 + }
  195 + switch ((string) $k) {
  196 + case 'file':
  197 + $data['file_link'] = url('/b/file_hash/' . $v .'/'.rand(100,999));
  198 + break;
  199 + case 'files':
  200 + $v = explode(',',$v);
  201 + foreach ($v as $k1=>$v1){
  202 + $data['files_link'][$k1] = url('/b/file_hash/' . $v1 . '/'.rand(100,999));
  203 + }
  204 + break;
  205 + }
  206 + }
  207 + }
  208 + return $data;
  209 + }
170 } 210 }
@@ -6,6 +6,7 @@ use App\Enums\Common\Code; @@ -6,6 +6,7 @@ use App\Enums\Common\Code;
6 use App\Http\Controllers\type; 6 use App\Http\Controllers\type;
7 use App\Http\Controllers\统一返回参数; 7 use App\Http\Controllers\统一返回参数;
8 use App\Models\File\Image as ImageModel; 8 use App\Models\File\Image as ImageModel;
  9 +use App\Models\User\User as UserModel;
9 use Illuminate\Http\Exceptions\HttpResponseException; 10 use Illuminate\Http\Exceptions\HttpResponseException;
10 use Illuminate\Http\JsonResponse; 11 use Illuminate\Http\JsonResponse;
11 use Illuminate\Support\Facades\Storage; 12 use Illuminate\Support\Facades\Storage;
@@ -24,6 +25,8 @@ class ImageController @@ -24,6 +25,8 @@ class ImageController
24 'Content-Description' => 'File Transfer', 25 'Content-Description' => 'File Transfer',
25 ], 26 ],
26 ]; 27 ];
  28 + const TYPE = 1;
  29 +
27 public $path = ''; 30 public $path = '';
28 31
29 public $config = ''; 32 public $config = '';
@@ -36,10 +39,11 @@ class ImageController @@ -36,10 +39,11 @@ class ImageController
36 { 39 {
37 $this->request = request(); 40 $this->request = request();
38 $this->config = config('filesystems.disks.upload'); 41 $this->config = config('filesystems.disks.upload');
39 - $this->path = $this->config['root']; 42 + $this->uploads = config('upload.default_image');
  43 + $this->path = $this->config['root'].$this->uploads['path'].'/';
40 } 44 }
41 45
42 - public function index($hash = '', $w = 0 ,$h = 0){ 46 + public function index($hash = '',$type = self::TYPE, $w = 0 ,$h = 0 ){
43 if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) { 47 if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
44 header("HTTP/1.1 304 Not Modified"); 48 header("HTTP/1.1 304 Not Modified");
45 exit; 49 exit;
@@ -50,6 +54,7 @@ class ImageController @@ -50,6 +54,7 @@ class ImageController
50 $this->response('指定图片不存在!', Code::USER_ERROR); 54 $this->response('指定图片不存在!', Code::USER_ERROR);
51 } 55 }
52 //查看缩略图是否存在 56 //查看缩略图是否存在
  57 +// $header['Content-Type'] = 'image/'.$info['type'];
53 $filename = $this->path . $info['hash'] . $w . '_' . $h; 58 $filename = $this->path . $info['hash'] . $w . '_' . $h;
54 if(is_file($filename)){ 59 if(is_file($filename)){
55 $last_modified_time = gmdate(time() + ((30 * 60 * 60 * 24))) . " GMT"; 60 $last_modified_time = gmdate(time() + ((30 * 60 * 60 * 24))) . " GMT";
@@ -78,7 +83,12 @@ class ImageController @@ -78,7 +83,12 @@ class ImageController
78 $img_type = $info['type']; 83 $img_type = $info['type'];
79 $content = base64_encode($content); 84 $content = base64_encode($content);
80 $img_base64 = 'data:image/' . $img_type . ';base64,' . $content; 85 $img_base64 = 'data:image/' . $img_type . ';base64,' . $content;
81 - return response($img_base64, 200, $header); 86 + if($type != self::TYPE){
  87 + header('Content-Type: image/' . $img_type);
  88 + echo base64_decode($content);
  89 + exit;
  90 + }
  91 + return response($img_base64,200,$header);
82 } 92 }
83 93
84 /** 94 /**
@@ -114,15 +124,16 @@ class ImageController @@ -114,15 +124,16 @@ class ImageController
114 $imageModel = new ImageModel(); 124 $imageModel = new ImageModel();
115 $image_hash = $imageModel->read(['hash'=>$hash]); 125 $image_hash = $imageModel->read(['hash'=>$hash]);
116 if($image_hash !== false){ 126 if($image_hash !== false){
117 - return $hash; 127 + return $this->response('图片资源',Code::SUCCESS,['image'=>$hash]);
118 } 128 }
119 $url = $this->path; 129 $url = $this->path;
120 - $res = $this->request->file('image')->move($url); 130 + $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
  131 + $res = $files->move($url,$fileName);
121 if ($res === false) { 132 if ($res === false) {
122 return $this->response($files->getError(), Code::USER_ERROR); 133 return $this->response($files->getError(), Code::USER_ERROR);
123 } 134 }
124 $data = [ 135 $data = [
125 - 'path' => $url.'/'.$res->getClientOriginalName(), 136 + 'path' => $url.$fileName,
126 'created_at' => date('Y-m-d H:i:s',time()), 137 'created_at' => date('Y-m-d H:i:s',time()),
127 'size' => $res->getSize(), 138 'size' => $res->getSize(),
128 'hash' => $hash, 139 'hash' => $hash,
@@ -132,7 +143,7 @@ class ImageController @@ -132,7 +143,7 @@ class ImageController
132 if ($rs === false) { 143 if ($rs === false) {
133 return $this->response('添加失败', Code::USER_ERROR); 144 return $this->response('添加失败', Code::USER_ERROR);
134 } 145 }
135 - return $hash; 146 + return $this->response('图片资源',Code::SUCCESS,['image'=>$hash]);
136 } 147 }
137 /** 148 /**
138 * 生成缩略图缓存 149 * 生成缩略图缓存
@@ -154,6 +165,7 @@ class ImageController @@ -154,6 +165,7 @@ class ImageController
154 * @return type 165 * @return type
155 */ 166 */
156 private function multi($files) { 167 private function multi($files) {
  168 +
157 if (!is_array($files)) { 169 if (!is_array($files)) {
158 $files = [$files]; 170 $files = [$files];
159 } 171 }
@@ -168,12 +180,13 @@ class ImageController @@ -168,12 +180,13 @@ class ImageController
168 continue; 180 continue;
169 } 181 }
170 $url = $this->path; 182 $url = $this->path;
171 - $res = $file->move($url); 183 + $fileName = uniqid().rand(10000,99999).'.'.$file->getClientOriginalExtension();
  184 + $res = $file->move($url,$fileName);
172 if ($res === false) { 185 if ($res === false) {
173 return $this->response($file->getError(), Code::USER_ERROR); 186 return $this->response($file->getError(), Code::USER_ERROR);
174 } 187 }
175 $save_data[] = [ 188 $save_data[] = [
176 - 'path' => $url.'/'.$file->getClientOriginalName(), 189 + 'path' => $url.$fileName,
177 'created_at' => date('Y-m-d H:i:s',time()), 190 'created_at' => date('Y-m-d H:i:s',time()),
178 'updated_at'=>date('Y-m-d H:i:s',time()), 191 'updated_at'=>date('Y-m-d H:i:s',time()),
179 'size' => $res->getSize(), 192 'size' => $res->getSize(),
@@ -183,7 +196,7 @@ class ImageController @@ -183,7 +196,7 @@ class ImageController
183 $data[] = $hash; 196 $data[] = $hash;
184 } 197 }
185 $imageModel->insert($save_data); 198 $imageModel->insert($save_data);
186 - return $data; 199 + return $this->response('图片资源',Code::SUCCESS,['image'=>$data]);
187 } 200 }
188 201
189 //下载 202 //下载
@@ -203,10 +216,50 @@ class ImageController @@ -203,10 +216,50 @@ class ImageController
203 $result = [ 216 $result = [
204 'msg' => $msg == ' ' ? $code->description : $msg, 217 'msg' => $msg == ' ' ? $code->description : $msg,
205 'code' => $code->value, 218 'code' => $code->value,
206 - 'data' => $data, 219 + 'data' => $this->_extents($data),
207 ]; 220 ];
208 $this->header['Content-Type'] = $type; 221 $this->header['Content-Type'] = $type;
209 $response = response($result,$result_code,$this->header); 222 $response = response($result,$result_code,$this->header);
210 throw new HttpResponseException($response); 223 throw new HttpResponseException($response);
211 } 224 }
  225 +
  226 + /**
  227 + * @param $data
  228 + * @name :返回参数处理
  229 + * @return array|string
  230 + * @author :liyuhang
  231 + * @method
  232 + */
  233 + protected function _extents($data) {
  234 +
  235 + if (empty($data) || !is_array($data)) {
  236 + return empty($data) ? is_array($data) ? [] : '' : $data;
  237 + }
  238 + foreach ($data as $k => $v) {
  239 + if (is_array($v)) {
  240 + $data[$k] = $this->_extents($v);
  241 + } else {
  242 + if (is_null($v)) {
  243 + $data[$k] = '';
  244 + continue;
  245 + }
  246 + //获取操作人
  247 + switch ((string) $k) {
  248 + case 'image':
  249 + $data['image_link'] = url('/b/image/' . $v);
  250 + break;
  251 + case 'images':
  252 + $v = explode(',',$v);
  253 + foreach ($v as $k1=>$v1){
  254 + $data['images_link'][$k1] = url('/b/image/' . $v1);
  255 + }
  256 + break;
  257 + case 'file':
  258 + $data['file_link'] = url('/b/file_hash/' . $v);
  259 + break;
  260 + }
  261 + }
  262 + }
  263 + return $data;
  264 + }
212 } 265 }
@@ -17,6 +17,19 @@ class AyrReleaseLogic extends BaseLogic @@ -17,6 +17,19 @@ class AyrReleaseLogic extends BaseLogic
17 } 17 }
18 18
19 /** 19 /**
  20 + * @name :()release_info
  21 + * @author :lyh
  22 + * @method :post
  23 + * @time :2023/5/9 16:27
  24 + */
  25 + public function release_info(){
  26 + $info = $this->model->read($this->param);
  27 + if($info === false){
  28 + $this->fail('error');
  29 + }
  30 + return $this->success($info);
  31 + }
  32 + /**
20 * @name :(发布社交写入数据库)release_add 33 * @name :(发布社交写入数据库)release_add
21 * @author :lyh 34 * @author :lyh
22 * @method :post 35 * @method :post
@@ -40,8 +40,14 @@ class WebSettingFromLogic extends BaseLogic @@ -40,8 +40,14 @@ class WebSettingFromLogic extends BaseLogic
40 try { 40 try {
41 //删除以前的数据 41 //删除以前的数据
42 $this->model->del(['project_id'=>$this->user['project_id']]); 42 $this->model->del(['project_id'=>$this->user['project_id']]);
  43 + foreach ($this->param['data'] as $k => $v){
  44 + $v['created_at'] = date('Y-m-d H:i:s');
  45 + $v['updated_at'] = date('Y-m-d H:i:s');
  46 + $v['project_id'] = $this->user['project_id'];
  47 + $this->param['data'][$k] = $v;
  48 + }
43 //新增 49 //新增
44 - $this->model->add_all($this->param['data']); 50 + $this->model->insert($this->param['data']);
45 }catch (\Exception $e){ 51 }catch (\Exception $e){
46 $this->fail('error'); 52 $this->fail('error');
47 } 53 }
@@ -37,9 +37,11 @@ class WebSettingReceivingLogic extends BaseLogic @@ -37,9 +37,11 @@ class WebSettingReceivingLogic extends BaseLogic
37 $this->model->del(['project_id'=>$this->user['project_id']]); 37 $this->model->del(['project_id'=>$this->user['project_id']]);
38 foreach ($this->param['data'] as $k => $v){ 38 foreach ($this->param['data'] as $k => $v){
39 $v['project_id'] = $this->user['project_id']; 39 $v['project_id'] = $this->user['project_id'];
  40 + $v['created_at'] = date('Y-m-d H:i:s');
  41 + $v['updated_at'] = date('Y-m-d H:i:s');
40 $this->param['data'][$k] = $v; 42 $this->param['data'][$k] = $v;
41 } 43 }
42 - $this->model->add_all($this->param['data']); 44 + $this->model->insert($this->param['data']);
43 }catch (\Exception $e){ 45 }catch (\Exception $e){
44 $this->fail('error'); 46 $this->fail('error');
45 } 47 }
@@ -36,17 +36,21 @@ class WebSettingServiceLogic extends BaseLogic @@ -36,17 +36,21 @@ class WebSettingServiceLogic extends BaseLogic
36 * @time :2023/5/4 11:10 36 * @time :2023/5/4 11:10
37 */ 37 */
38 public function setting_service_save(){ 38 public function setting_service_save(){
  39 + DB::beginTransaction();
39 try { 40 try {
40 $this->param['data'] = Common::uniqueMultiArray($this->param['data']); 41 $this->param['data'] = Common::uniqueMultiArray($this->param['data']);
41 //删除以前的数据 42 //删除以前的数据
42 $this->model->del(['project_id'=>$this->user['project_id']]); 43 $this->model->del(['project_id'=>$this->user['project_id']]);
43 foreach ($this->param['data'] as $k => $v){ 44 foreach ($this->param['data'] as $k => $v){
44 - //查询数据是否在数组中存在  
45 $v['project_id'] = $this->user['project_id']; 45 $v['project_id'] = $this->user['project_id'];
  46 + $v['created_at'] = date('Y-m-d H:i:s');
  47 + $v['updated_at'] = date('Y-m-d H:i:s');
46 $this->param['data'][$k] = $v; 48 $this->param['data'][$k] = $v;
47 } 49 }
48 - $this->model->add_all($this->param['data']); 50 + $this->model->insert($this->param['data']);
  51 + DB::commit();
49 }catch (\Exception $e){ 52 }catch (\Exception $e){
  53 + DB::rollBack();
50 $this->fail('error'); 54 $this->fail('error');
51 } 55 }
52 return $this->success(); 56 return $this->success();
@@ -51,8 +51,7 @@ class WebSettingTextLogic extends BaseLogic @@ -51,8 +51,7 @@ class WebSettingTextLogic extends BaseLogic
51 */ 51 */
52 public function setting_text_save(){ 52 public function setting_text_save(){
53 $web_setting = new WebSetting(); 53 $web_setting = new WebSetting();
54 - $setting_info = $this->setting_read();  
55 - if(count($this->param['data']) > $setting_info['anchor_num']){ 54 + if(count($this->param['data']) > $this->param['anchor_num']){
56 $this->fail('超过最大设置限制'); 55 $this->fail('超过最大设置限制');
57 } 56 }
58 DB::beginTransaction(); 57 DB::beginTransaction();
@@ -66,10 +65,12 @@ class WebSettingTextLogic extends BaseLogic @@ -66,10 +65,12 @@ class WebSettingTextLogic extends BaseLogic
66 $web_setting->edit($data,['project_id'=>$this->user['project_id']]); 65 $web_setting->edit($data,['project_id'=>$this->user['project_id']]);
67 $this->model->del(['project_id'=>$this->user['project_id']]); 66 $this->model->del(['project_id'=>$this->user['project_id']]);
68 foreach ($this->param['data'] as $k => $v){ 67 foreach ($this->param['data'] as $k => $v){
  68 + $v['created_at'] = date('Y-m-d H:i:s');
  69 + $v['updated_at'] = date('Y-m-d H:i:s');
69 $v['project_id'] = $this->user['project_id']; 70 $v['project_id'] = $this->user['project_id'];
70 $this->param['data'][$k] = $v; 71 $this->param['data'][$k] = $v;
71 } 72 }
72 - $this->model->add_all($this->param['data']); 73 + $this->model->insert($this->param['data']);
73 DB::commit(); 74 DB::commit();
74 }catch (\Exception $e){ 75 }catch (\Exception $e){
75 DB::rollBack(); 76 DB::rollBack();
@@ -114,16 +114,6 @@ class Base extends Model @@ -114,16 +114,6 @@ class Base extends Model
114 } 114 }
115 115
116 /** 116 /**
117 - * @name :(获取数据条数)count  
118 - * @author :lyh  
119 - * @method :post  
120 - * @time :2023/5/8 15:51  
121 - */  
122 - public function get_count($condition){  
123 - $query = $this->formatQuery($condition);  
124 - $query->count();  
125 - }  
126 - /**  
127 * @name :新增 117 * @name :新增
128 * @return void 118 * @return void
129 * @author :liyuhang 119 * @author :liyuhang
@@ -136,20 +126,6 @@ class Base extends Model @@ -136,20 +126,6 @@ class Base extends Model
136 } 126 }
137 127
138 /** 128 /**
139 - * @name :(批量插入)add_all  
140 - * @author :lyh  
141 - * @method :post  
142 - * @time :2023/5/8 17:41  
143 - */  
144 - public function add_all($data){  
145 - foreach ($data as $k => $v){  
146 - $v['created_at'] = date('Y-m-d H:i:s');  
147 - $v['updated_at'] = date('Y-m-d H:i:s');  
148 - $data[$k] = $v;  
149 - }  
150 - return $this->insert($data);  
151 - }  
152 - /**  
153 * @name :编辑 129 * @name :编辑
154 * @return void 130 * @return void
155 * @author :liyuhang 131 * @author :liyuhang
@@ -14,12 +14,19 @@ return [ @@ -14,12 +14,19 @@ return [
14 ], 14 ],
15 'path' => '/product' 15 'path' => '/product'
16 ], 16 ],
17 - //用户头像  
18 - 'user' =>[ 17 + //默认
  18 + 'default_image' =>[
19 'size' => [ 19 'size' => [
20 'max' => 1024*1024*2, // 2M 20 'max' => 1024*1024*2, // 2M
21 ], 21 ],
22 - 'path' => '/user' 22 + 'path' => '/image'
  23 + ],
  24 + //默认视频
  25 + 'default_file' =>[
  26 + 'size' => [
  27 + 'max' => 1024*1024*200, // 2M
  28 + ],
  29 + 'path' => '/file'
23 ], 30 ],
24 //博客图 31 //博客图
25 'blog' =>[ 32 'blog' =>[
@@ -216,12 +216,21 @@ Route::middleware(['bloginauth'])->group(function () { @@ -216,12 +216,21 @@ Route::middleware(['bloginauth'])->group(function () {
216 Route::any('/create', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'create_account'])->name('ayr_create_account'); 216 Route::any('/create', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'create_account'])->name('ayr_create_account');
217 Route::any('/del', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'del_account'])->name('ayr_del_account'); 217 Route::any('/del', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'del_account'])->name('ayr_del_account');
218 Route::any('/bind', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'bind_account'])->name('ayr_bind_account'); 218 Route::any('/bind', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'bind_account'])->name('ayr_bind_account');
  219 + //社交绑定
  220 + Route::prefix('release')->group(function () {
  221 + Route::any('/', [\App\Http\Controllers\Bside\AyrShare\AyrReleaseController::class, 'info'])->name('ayr_release_info');
  222 + Route::any('/send', [\App\Http\Controllers\Bside\AyrShare\AyrReleaseController::class, 'send_post'])->name('ayr_release_send');
  223 + });
219 }); 224 });
220 225
  226 +<<<<<<< HEAD
221 227
222 228
223 229
224 // 模板 230 // 模板
  231 +=======
  232 + // 自定义页面
  233 +>>>>>>> dev
225 Route::prefix('template')->group(function () { 234 Route::prefix('template')->group(function () {
226 Route::get('/', [\App\Http\Controllers\Bside\TemplateController::class, 'index'])->name('bside_template'); 235 Route::get('/', [\App\Http\Controllers\Bside\TemplateController::class, 'index'])->name('bside_template');
227 Route::any('/use-template', [\App\Http\Controllers\Bside\TemplateController::class, 'info'])->name('bside_template_use'); 236 Route::any('/use-template', [\App\Http\Controllers\Bside\TemplateController::class, 'info'])->name('bside_template_use');
@@ -257,6 +266,6 @@ Route::group([], function () { @@ -257,6 +266,6 @@ Route::group([], function () {
257 Route::any('/login', [\App\Http\Controllers\Bside\ComController::class, 'login'])->name('login'); 266 Route::any('/login', [\App\Http\Controllers\Bside\ComController::class, 'login'])->name('login');
258 // Route::any('/', [\App\Http\Controllers\Bside\ComController::class, 'get_country'])->name('get_country'); 267 // Route::any('/', [\App\Http\Controllers\Bside\ComController::class, 'get_country'])->name('get_country');
259 Route::get('/file/download', [\App\Http\Controllers\Bside\FileController::class, 'download'])->name('file_download'); 268 Route::get('/file/download', [\App\Http\Controllers\Bside\FileController::class, 'download'])->name('file_download');
260 - Route::any('/image/{hash}/{w?}/{h?}', [\App\Http\Controllers\file\ImageController::class,'index'])->name('image_show');  
261 - Route::any('/file_hash/{hash}', [\App\Http\Controllers\file\FileController::class,'index'])->name('file_show'); 269 + Route::any('/image/{hash}/{type?}/{w?}/{h?}', [\App\Http\Controllers\file\ImageController::class,'index'])->name('image_show');
  270 + Route::any('/file_hash/{hash}/{type?}/', [\App\Http\Controllers\file\FileController::class,'index'])->name('file_show');
262 }); 271 });