作者 lyh

gx

@@ -57,7 +57,7 @@ class ManageController extends BaseController @@ -57,7 +57,7 @@ class ManageController extends BaseController
57 ],[ 57 ],[
58 'id.required' => 'ID不能为空' 58 'id.required' => 'ID不能为空'
59 ]); 59 ]);
60 - $data = $logic->getInfo($this->param['id']); 60 + $data = $logic->getManagerInfo();
61 //获取当前用户特殊模块权限 61 //获取当前用户特殊模块权限
62 $specialMenuModel = new MenuSpecial(); 62 $specialMenuModel = new MenuSpecial();
63 $data['special'] = $specialMenuModel->list(['user_list'=>['like','%,'.$this->param['id'].',%']],'id',['id','name','remark']); 63 $data['special'] = $specialMenuModel->list(['user_list'=>['like','%,'.$this->param['id'].',%']],'id',['id','name','remark']);
@@ -77,6 +77,13 @@ class ManageController extends BaseController @@ -77,6 +77,13 @@ class ManageController extends BaseController
77 $this->response('success'); 77 $this->response('success');
78 } 78 }
79 79
  80 + /**
  81 + * @remark :删除
  82 + * @name :delete
  83 + * @author :lyh
  84 + * @method :post
  85 + * @time :2023/8/28 16:11
  86 + */
80 public function delete(ManageLogic $logic){ 87 public function delete(ManageLogic $logic){
81 $this->request->validate([ 88 $this->request->validate([
82 'ids'=>['required', new Ids()] 89 'ids'=>['required', new Ids()]
@@ -77,12 +77,10 @@ class BlogController extends BaseController @@ -77,12 +77,10 @@ class BlogController extends BaseController
77 'id.required' => 'ID不能为空' 77 'id.required' => 'ID不能为空'
78 ]); 78 ]);
79 $info = $blogLogic->blog_info(); 79 $info = $blogLogic->blog_info();
80 - $info['route'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG, $info['id'], $this->user['project_id']);  
81 - $info['url'] = $this->user['domain'] . $info['route'];  
82 - $info['image_link'] = getImageUrl($info['image']);  
83 $this->response('success',Code::SUCCESS,$info); 80 $this->response('success',Code::SUCCESS,$info);
84 } 81 }
85 82
  83 +
86 /** 84 /**
87 * @name :添加博客 85 * @name :添加博客
88 * @author :liyuhang 86 * @author :liyuhang
@@ -35,6 +35,24 @@ class BlogLabelController extends BaseController @@ -35,6 +35,24 @@ class BlogLabelController extends BaseController
35 } 35 }
36 36
37 /** 37 /**
  38 + * @remark :批量添加
  39 + * @name :batchAdd
  40 + * @author :lyh
  41 + * @method :post
  42 + * @time :2023/8/28 14:25
  43 + */
  44 + public function batchAdd(BlogLabelLogic $logic){
  45 + $this->request->validate([
  46 + 'name'=>['required','array']
  47 + ],[
  48 + 'name.required' => 'name不能为空',
  49 + 'name.array' => 'name为数组'
  50 + ]);
  51 + $data = $logic->batchAdd();
  52 + $this->response('success',Code::SUCCESS,$data);
  53 + }
  54 +
  55 + /**
38 * @name :编辑标签 56 * @name :编辑标签
39 * @author :liyuhang 57 * @author :liyuhang
40 * @method 58 * @method
@@ -49,4 +49,19 @@ class ManageLogic extends BaseLogic @@ -49,4 +49,19 @@ class ManageLogic extends BaseLogic
49 } 49 }
50 return $this->success(); 50 return $this->success();
51 } 51 }
  52 +
  53 + /**
  54 + * @remark :获取数据详情
  55 + * @name :getManagerInfo
  56 + * @author :lyh
  57 + * @method :post
  58 + * @time :2023/8/28 16:10
  59 + */
  60 + public function getManagerInfo(){
  61 + $info = $this->model->read(['id'=>$this->param['id']]);
  62 + if($info === false){
  63 + $this->fail('error');
  64 + }
  65 + return $this->success($info);
  66 + }
52 } 67 }
@@ -41,14 +41,7 @@ class BlogLabelLogic extends BaseLogic @@ -41,14 +41,7 @@ class BlogLabelLogic extends BaseLogic
41 * @method 41 * @method
42 */ 42 */
43 public function add_blog_label(){ 43 public function add_blog_label(){
44 - $condition = [  
45 - 'name'=>$this->param['name']  
46 - ];  
47 - //查看当前分类名称是否存在  
48 - $info = $this->model->read($condition);  
49 - if($info !== false){  
50 - $this->fail('当前标签名称已存在');  
51 - } 44 + $this->verifyParamName($this->param['name']);
52 $this->param['create_id'] = $this->user['id']; 45 $this->param['create_id'] = $this->user['id'];
53 $this->param['operator_id'] = $this->user['id']; 46 $this->param['operator_id'] = $this->user['id'];
54 $this->param['project_id'] = $this->user['project_id']; 47 $this->param['project_id'] = $this->user['project_id'];
@@ -66,17 +59,12 @@ class BlogLabelLogic extends BaseLogic @@ -66,17 +59,12 @@ class BlogLabelLogic extends BaseLogic
66 * @method 59 * @method
67 */ 60 */
68 public function edit_blog_label(){ 61 public function edit_blog_label(){
69 - $condition = [  
70 - 'id'=>['!=',$this->param['id']],  
71 - 'name'=>$this->param['name']  
72 - ];  
73 - //查看当前分类名称是否存在  
74 - $info = $this->model->read($condition);  
75 - if($info !== false){  
76 - $this->fail('当前标签名称已存在');  
77 - } 62 + $this->verifyParamName($this->param['name'],$this->param['id']);
78 $this->param['operator_id'] = $this->user['id']; 63 $this->param['operator_id'] = $this->user['id'];
79 - $this->edit($this->param,['id'=>$this->param['id']]); 64 + $rs = $this->edit($this->param,['id'=>$this->param['id']]);
  65 + if($rs === false){
  66 + $this->fail('error');
  67 + }
80 return $this->success(); 68 return $this->success();
81 } 69 }
82 70
@@ -111,4 +99,51 @@ class BlogLabelLogic extends BaseLogic @@ -111,4 +99,51 @@ class BlogLabelLogic extends BaseLogic
111 $this->del($this->param,$ids); 99 $this->del($this->param,$ids);
112 return $this->success(); 100 return $this->success();
113 } 101 }
  102 +
  103 + /**
  104 + * @remark :批量添加数据
  105 + * @name :batchAdd
  106 + * @author :lyh
  107 + * @method :post
  108 + * @time :2023/8/28 14:03
  109 + */
  110 + public function batchAdd(){
  111 + $ids = [];
  112 + if(!empty($this->param['title']) && is_array($this->param['title'])){
  113 + foreach ($this->param['title'] as $v){
  114 + $this->verifyParamName($v);
  115 + $param['create_id'] = $this->user['id'];
  116 + $param['operator_id'] = $this->user['id'];
  117 + $param['project_id'] = $this->user['project_id'];
  118 + $param['title'] = $v;
  119 + $id = $this->model->insertGetId($param);
  120 + $ids[] = $id;
  121 + }
  122 + }
  123 + return $this->success($ids);
  124 + }
  125 +
  126 + /**
  127 + * @name :(验证名称是否存在)verifyParamName
  128 + * @author :lyh
  129 + * @method :post
  130 + * @time :2023/6/13 11:41
  131 + */
  132 + public function verifyParamName($name,$id = ''){
  133 + if(isset($id) && !empty($id)){
  134 + $condition = [
  135 + 'id'=>['!=',$id],
  136 + 'name'=>$name,
  137 + ];
  138 + }else{
  139 + $condition = [
  140 + 'name'=>$name
  141 + ];
  142 + }
  143 + $info = $this->model->read($condition);
  144 + if($info !== false){
  145 + $this->fail('当前名称已存在');
  146 + }
  147 + return $this->success();
  148 + }
114 } 149 }
@@ -59,7 +59,8 @@ class BlogLogic extends BaseLogic @@ -59,7 +59,8 @@ class BlogLogic extends BaseLogic
59 try { 59 try {
60 $this->param = $this->paramProcessing($this->param); 60 $this->param = $this->paramProcessing($this->param);
61 $rs = $this->model->insertGetId($this->param); 61 $rs = $this->model->insertGetId($this->param);
62 - $route = $this->param['url'] = RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_BLOG, $rs, $this->user['project_id']); 62 + $route = $this->param['url'] = RouteMap::setRoute($this->param['url'] ?: $this->param['name'],
  63 + RouteMap::SOURCE_BLOG, $rs, $this->user['project_id']);
63 DB::commit(); 64 DB::commit();
64 }catch (\Exception $e){ 65 }catch (\Exception $e){
65 DB::rollBack(); 66 DB::rollBack();
@@ -81,7 +82,8 @@ class BlogLogic extends BaseLogic @@ -81,7 +82,8 @@ class BlogLogic extends BaseLogic
81 $this->param = $this->paramProcessing($this->param); 82 $this->param = $this->paramProcessing($this->param);
82 DB::beginTransaction(); 83 DB::beginTransaction();
83 try { 84 try {
84 - $route = RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_BLOG, $this->param['id'], $this->user['project_id']); 85 + $route = RouteMap::setRoute($this->param['url'] ?: $this->param['name'],
  86 + RouteMap::SOURCE_BLOG, $this->param['id'], $this->user['project_id']);
85 $this->edit($this->param,['id'=>$this->param['id']]); 87 $this->edit($this->param,['id'=>$this->param['id']]);
86 DB::commit(); 88 DB::commit();
87 }catch (\Exception $e){ 89 }catch (\Exception $e){
@@ -126,6 +128,9 @@ class BlogLogic extends BaseLogic @@ -126,6 +128,9 @@ class BlogLogic extends BaseLogic
126 //获取标签名称 128 //获取标签名称
127 $blogLabelLogic = new BlogLabelLogic(); 129 $blogLabelLogic = new BlogLabelLogic();
128 $info = $blogLabelLogic->get_label_name($info); 130 $info = $blogLabelLogic->get_label_name($info);
  131 + $info['route'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG, $info['id'], $this->user['project_id']);
  132 + $info['url'] = $this->user['domain'] . $info['route'];
  133 + $info['image_link'] = getImageUrl($info['image']);
129 //写入缓存 134 //写入缓存
130 Common::set_user_cache($info,$this->model->getTable(),$this->param['id']); 135 Common::set_user_cache($info,$this->model->getTable(),$this->param['id']);
131 } 136 }
@@ -227,4 +232,5 @@ class BlogLogic extends BaseLogic @@ -227,4 +232,5 @@ class BlogLogic extends BaseLogic
227 } 232 }
228 return $this->success(); 233 return $this->success();
229 } 234 }
  235 +
230 } 236 }
1 -<?php  
2 -  
3 -  
4 -use Illuminate\Http\Request;  
5 -use SwooleTW\Http\Websocket\Facades\Websocket;  
6 -  
7 -/*  
8 -|--------------------------------------------------------------------------  
9 -| Websocket Routes  
10 -|--------------------------------------------------------------------------  
11 -|  
12 -| Here is where you can register websocket events for your application.  
13 -|  
14 -*/  
15 -  
16 -Websocket::on('connect', function ($websocket, Request $request) {  
17 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export(111111, true) . PHP_EOL, FILE_APPEND);  
18 - // called while socket on connect  
19 -});  
20 -  
21 -Websocket::on('disconnect', function ($websocket) {  
22 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export(22222, true) . PHP_EOL, FILE_APPEND);  
23 - // called while socket on disconnect  
24 -});  
25 -  
26 -Websocket::on('example', function ($websocket, $data) {  
27 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export(3333, true) . PHP_EOL, FILE_APPEND);  
28 - $websocket->emit('message', $data);  
29 -});  
30 -  
31 -Websocket::on('message', function ($websocket, $data) {  
32 - // 处理接收到消息时的逻辑  
33 - // 假设 $data 是客户端发送过来的数据  
34 - // 在这里您可以根据接收到的消息进行处理  
35 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export(4444444, true) . PHP_EOL, FILE_APPEND);  
36 - // 回复消息给客户端  
37 - $websocket->send("Hello, Client! You sent: $data");  
38 -});