作者 lyh

gx

... ... @@ -57,7 +57,7 @@ class ManageController extends BaseController
],[
'id.required' => 'ID不能为空'
]);
$data = $logic->getInfo($this->param['id']);
$data = $logic->getManagerInfo();
//获取当前用户特殊模块权限
$specialMenuModel = new MenuSpecial();
$data['special'] = $specialMenuModel->list(['user_list'=>['like','%,'.$this->param['id'].',%']],'id',['id','name','remark']);
... ... @@ -77,6 +77,13 @@ class ManageController extends BaseController
$this->response('success');
}
/**
* @remark :删除
* @name :delete
* @author :lyh
* @method :post
* @time :2023/8/28 16:11
*/
public function delete(ManageLogic $logic){
$this->request->validate([
'ids'=>['required', new Ids()]
... ...
... ... @@ -77,12 +77,10 @@ class BlogController extends BaseController
'id.required' => 'ID不能为空'
]);
$info = $blogLogic->blog_info();
$info['route'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG, $info['id'], $this->user['project_id']);
$info['url'] = $this->user['domain'] . $info['route'];
$info['image_link'] = getImageUrl($info['image']);
$this->response('success',Code::SUCCESS,$info);
}
/**
* @name :添加博客
* @author :liyuhang
... ...
... ... @@ -35,6 +35,24 @@ class BlogLabelController extends BaseController
}
/**
* @remark :批量添加
* @name :batchAdd
* @author :lyh
* @method :post
* @time :2023/8/28 14:25
*/
public function batchAdd(BlogLabelLogic $logic){
$this->request->validate([
'name'=>['required','array']
],[
'name.required' => 'name不能为空',
'name.array' => 'name为数组'
]);
$data = $logic->batchAdd();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @name :编辑标签
* @author :liyuhang
* @method
... ...
... ... @@ -49,4 +49,19 @@ class ManageLogic extends BaseLogic
}
return $this->success();
}
/**
* @remark :获取数据详情
* @name :getManagerInfo
* @author :lyh
* @method :post
* @time :2023/8/28 16:10
*/
public function getManagerInfo(){
$info = $this->model->read(['id'=>$this->param['id']]);
if($info === false){
$this->fail('error');
}
return $this->success($info);
}
}
... ...
... ... @@ -41,14 +41,7 @@ class BlogLabelLogic extends BaseLogic
* @method
*/
public function add_blog_label(){
$condition = [
'name'=>$this->param['name']
];
//查看当前分类名称是否存在
$info = $this->model->read($condition);
if($info !== false){
$this->fail('当前标签名称已存在');
}
$this->verifyParamName($this->param['name']);
$this->param['create_id'] = $this->user['id'];
$this->param['operator_id'] = $this->user['id'];
$this->param['project_id'] = $this->user['project_id'];
... ... @@ -66,17 +59,12 @@ class BlogLabelLogic extends BaseLogic
* @method
*/
public function edit_blog_label(){
$condition = [
'id'=>['!=',$this->param['id']],
'name'=>$this->param['name']
];
//查看当前分类名称是否存在
$info = $this->model->read($condition);
if($info !== false){
$this->fail('当前标签名称已存在');
}
$this->verifyParamName($this->param['name'],$this->param['id']);
$this->param['operator_id'] = $this->user['id'];
$this->edit($this->param,['id'=>$this->param['id']]);
$rs = $this->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->fail('error');
}
return $this->success();
}
... ... @@ -111,4 +99,51 @@ class BlogLabelLogic extends BaseLogic
$this->del($this->param,$ids);
return $this->success();
}
/**
* @remark :批量添加数据
* @name :batchAdd
* @author :lyh
* @method :post
* @time :2023/8/28 14:03
*/
public function batchAdd(){
$ids = [];
if(!empty($this->param['title']) && is_array($this->param['title'])){
foreach ($this->param['title'] as $v){
$this->verifyParamName($v);
$param['create_id'] = $this->user['id'];
$param['operator_id'] = $this->user['id'];
$param['project_id'] = $this->user['project_id'];
$param['title'] = $v;
$id = $this->model->insertGetId($param);
$ids[] = $id;
}
}
return $this->success($ids);
}
/**
* @name :(验证名称是否存在)verifyParamName
* @author :lyh
* @method :post
* @time :2023/6/13 11:41
*/
public function verifyParamName($name,$id = ''){
if(isset($id) && !empty($id)){
$condition = [
'id'=>['!=',$id],
'name'=>$name,
];
}else{
$condition = [
'name'=>$name
];
}
$info = $this->model->read($condition);
if($info !== false){
$this->fail('当前名称已存在');
}
return $this->success();
}
}
... ...
... ... @@ -59,7 +59,8 @@ class BlogLogic extends BaseLogic
try {
$this->param = $this->paramProcessing($this->param);
$rs = $this->model->insertGetId($this->param);
$route = $this->param['url'] = RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_BLOG, $rs, $this->user['project_id']);
$route = $this->param['url'] = RouteMap::setRoute($this->param['url'] ?: $this->param['name'],
RouteMap::SOURCE_BLOG, $rs, $this->user['project_id']);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
... ... @@ -81,7 +82,8 @@ class BlogLogic extends BaseLogic
$this->param = $this->paramProcessing($this->param);
DB::beginTransaction();
try {
$route = RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_BLOG, $this->param['id'], $this->user['project_id']);
$route = RouteMap::setRoute($this->param['url'] ?: $this->param['name'],
RouteMap::SOURCE_BLOG, $this->param['id'], $this->user['project_id']);
$this->edit($this->param,['id'=>$this->param['id']]);
DB::commit();
}catch (\Exception $e){
... ... @@ -126,6 +128,9 @@ class BlogLogic extends BaseLogic
//获取标签名称
$blogLabelLogic = new BlogLabelLogic();
$info = $blogLabelLogic->get_label_name($info);
$info['route'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG, $info['id'], $this->user['project_id']);
$info['url'] = $this->user['domain'] . $info['route'];
$info['image_link'] = getImageUrl($info['image']);
//写入缓存
Common::set_user_cache($info,$this->model->getTable(),$this->param['id']);
}
... ... @@ -227,4 +232,5 @@ class BlogLogic extends BaseLogic
}
return $this->success();
}
}
... ...
<?php
use Illuminate\Http\Request;
use SwooleTW\Http\Websocket\Facades\Websocket;
/*
|--------------------------------------------------------------------------
| Websocket Routes
|--------------------------------------------------------------------------
|
| Here is where you can register websocket events for your application.
|
*/
Websocket::on('connect', function ($websocket, Request $request) {
@file_put_contents(storage_path('logs/lyh_error.log'), var_export(111111, true) . PHP_EOL, FILE_APPEND);
// called while socket on connect
});
Websocket::on('disconnect', function ($websocket) {
@file_put_contents(storage_path('logs/lyh_error.log'), var_export(22222, true) . PHP_EOL, FILE_APPEND);
// called while socket on disconnect
});
Websocket::on('example', function ($websocket, $data) {
@file_put_contents(storage_path('logs/lyh_error.log'), var_export(3333, true) . PHP_EOL, FILE_APPEND);
$websocket->emit('message', $data);
});
Websocket::on('message', function ($websocket, $data) {
// 处理接收到消息时的逻辑
// 假设 $data 是客户端发送过来的数据
// 在这里您可以根据接收到的消息进行处理
@file_put_contents(storage_path('logs/lyh_error.log'), var_export(4444444, true) . PHP_EOL, FILE_APPEND);
// 回复消息给客户端
$websocket->send("Hello, Client! You sent: $data");
});