作者 lyh

gx

... ... @@ -22,7 +22,12 @@ class CustomModuleCategoryController extends BaseController
* @method :post
* @time :2023/12/4 15:43
*/
public function list(CustomModuleCategory $customModuleCategory){
public function lists(CustomModuleCategory $customModuleCategory){
$this->request->validate([
'module_id'=>['required'],
],[
'module_id.required' => 'module_id不能为空',
]);
$this->map['project_id'] = $this->user['project_id'];
$lists = $customModuleCategory->lists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$lists);
... ... @@ -37,9 +42,13 @@ class CustomModuleCategoryController extends BaseController
*/
public function info(CustomModuleCategoryLogic $logic){
$this->request->validate([
'id'=>['required'],
'name'=>['required'],
'route'=>['required'],
'module_id'=>['required']
],[
'id.required' => 'ID不能为空',
'name.required' => '分类名称不能为空',
'route.required' => '分类路由不能为空',
'module_id.required' => '所选模块id不能为空'
]);
$info = $logic->getCustomModuleCategoryInfo();
$this->response('success',Code::SUCCESS,$info);
... ...
... ... @@ -30,7 +30,7 @@ class CustomModuleController extends BaseController
* @method :post
* @time :2023/12/4 15:43
*/
public function list(CustomModule $customModule){
public function lists(CustomModule $customModule){
$this->map['project_id'] = $this->user['project_id'];
$lists = $customModule->lists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$lists);
... ... @@ -61,10 +61,22 @@ class CustomModuleController extends BaseController
* @time :2023/12/4 15:45
*/
public function save(CustomModuleLogic $logic){
$this->request->validate([
'name'=>['required'],
],[
'name.required' => '模块名称不能为空',
]);
$logic->customModuleSave();
$this->response('success');
}
/**
* @remark :删除
* @name :del
* @author :lyh
* @method :post
* @time :2023/12/5 9:53
*/
public function del(CustomModuleLogic $logic){
$this->request->validate([
'id'=>['required'],
... ...
... ... @@ -195,6 +195,9 @@ class ImageController extends Controller
//保存路径
$url = $this->config['root'].$this->path;
$image_type = $files->getClientOriginalExtension();
if(strlen($image_type) > 7){
$this->response('不支持当前格式',Code::SYSTEM_ERROR);
}
$fileName = uniqid().rand(10000,99999).'.'.$image_type;
//上传到cos
if($this->upload_location == 1){
... ...
... ... @@ -11,6 +11,8 @@ namespace App\Http\Logic\Bside\CustomModule;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\CustomModule\CustomModule;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\CustomModule\CustomModuleContent;
class CustomModuleLogic extends BaseLogic
{
... ... @@ -29,7 +31,11 @@ class CustomModuleLogic extends BaseLogic
* @time :2023/12/4 16:10
*/
public function getCustomModuleInfo(){
$info = $this->model->read($this->param);
if($info === false){
$this->fail('当前数据不存在或已被删除');
}
return $this->success($info);
}
/**
... ... @@ -40,7 +46,42 @@ class CustomModuleLogic extends BaseLogic
* @time :2023/12/4 15:47
*/
public function customModuleSave(){
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->moduleEdit();
}else{
$this->moduleAdd();
}
return $this->success();
}
/**
* @remark :新增
* @name :moduleAdd
* @author :lyh
* @method :post
* @time :2023/12/5 9:39
*/
public function moduleAdd(){
$rs = $this->model->add($this->param);
if($rs === false){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
/**
* @remark :编辑
* @name :moduleEdit
* @author :lyh
* @method :post
* @time :2023/12/5 9:39
*/
public function moduleEdit(){
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
/**
... ... @@ -51,6 +92,21 @@ class CustomModuleLogic extends BaseLogic
* @time :2023/12/4 15:47
*/
public function customModuleDel(){
//查看当前模块是否拥有数据
$contentModel = new CustomModuleContent();
$contentInfo = $contentModel->read(['module_id'=>$this->param['id']],['id']);
if($contentInfo !== false){
$this->fail('当前模块拥有内容不允许删除');
}
$categoryModel = new CustomModuleCategory();
$categoryInfo = $categoryModel->read(['module_id'=>$this->param['id']],['id']);
if($categoryInfo !== false){
$this->fail('当前模块拥有分类不允许删除');
}
$rs = $this->model->del($this->param);
if($rs === false){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
}
... ...
... ... @@ -422,6 +422,19 @@ Route::middleware(['bloginauth'])->group(function () {
Route::prefix('language')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\Setting\LanguageController::class, 'lists'])->name('language_lists');
});
//自定义模板
Route::prefix('custom')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'lists'])->name('custom_lists');
Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'save'])->name('custom_save');
Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'del'])->name('custom_del');
Route::prefix('category')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'lists'])->name('custom_lists');
Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'save'])->name('custom_save');
Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'del'])->name('custom_del');
});
});
});
//无需登录验证的路由组
Route::group([], function () {
... ...