首页列表、广场、我的发布
This commit is contained in:
@@ -31,7 +31,7 @@ class PostCategoryController extends BaseController
|
|||||||
$result = $this->service->getList($params);
|
$result = $this->service->getList($params);
|
||||||
return $this->success($result, '获取分类列表');
|
return $this->success($result, '获取分类列表');
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->error($e->getMessage().$e->getFile().$e->getLine());
|
return $this->error($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace app\common\controller;
|
|||||||
use app\common\controller\BaseController;
|
use app\common\controller\BaseController;
|
||||||
use app\common\traits\crud\CrudControllerTrait;
|
use app\common\traits\crud\CrudControllerTrait;
|
||||||
use app\common\service\BannerService;
|
use app\common\service\BannerService;
|
||||||
|
use support\Request;
|
||||||
|
|
||||||
class BannerController extends BaseController
|
class BannerController extends BaseController
|
||||||
{
|
{
|
||||||
@@ -16,6 +17,22 @@ class BannerController extends BaseController
|
|||||||
$this->service = new BannerService();
|
$this->service = new BannerService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 轮播
|
||||||
|
* @param Request $request
|
||||||
|
* @return \support\Response
|
||||||
|
*/
|
||||||
|
public function getAll(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$params = $request->all();
|
||||||
|
$result = $this->service->getBanner($params);
|
||||||
|
return $this->success($result, '获取轮播列表');
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return $this->error($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表页数据格式化
|
* 列表页数据格式化
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ class PostController extends BaseController
|
|||||||
foreach ($records as &$record) {
|
foreach ($records as &$record) {
|
||||||
if (!isset($record['id']))
|
if (!isset($record['id']))
|
||||||
break;
|
break;
|
||||||
var_dump($record['id']);
|
|
||||||
$where = [
|
$where = [
|
||||||
'post_id' => $record['id'],
|
'post_id' => $record['id'],
|
||||||
'user_id' => $request->user->uid
|
'user_id' => $request->user->uid
|
||||||
|
|||||||
@@ -30,6 +30,14 @@ class BannerService
|
|||||||
return new $this->validator;
|
return new $this->validator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getBanner($params){
|
||||||
|
$where = [];
|
||||||
|
if(isset($params['module'])){
|
||||||
|
$where['module'] = $params['module'];
|
||||||
|
}
|
||||||
|
return Banner::where('status','1')->where($where)->get();
|
||||||
|
}
|
||||||
|
|
||||||
public function getBannerModule(){
|
public function getBannerModule(){
|
||||||
return BannerModule::where('status','1')->get();
|
return BannerModule::where('status','1')->get();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,49 @@ class PostService
|
|||||||
return new $this->validator;
|
return new $this->validator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造 CrudUtil 查询配置
|
||||||
|
*/
|
||||||
|
protected function buildQueryConfig(Request $request, string $scene = 'default'): array
|
||||||
|
{
|
||||||
|
$p = $request->all();
|
||||||
|
|
||||||
|
$config = [];
|
||||||
|
$config['model'] = $this->modelClass;
|
||||||
|
switch ($scene) {
|
||||||
|
case 'default':
|
||||||
|
$config['where']['status'] = 1;
|
||||||
|
$config['order']['sort'] = 'desc';
|
||||||
|
$config['order']['id'] = 'desc';
|
||||||
|
break;
|
||||||
|
case 'index':
|
||||||
|
if (isset($p['category_id']) && $p['category_id']) {
|
||||||
|
$config['where']['category_id'] = $p['category_id'];
|
||||||
|
}
|
||||||
|
if (isset($p['self']) && $p['self']) {
|
||||||
|
$config['where']['user_id'] = $request->user->uid;
|
||||||
|
}
|
||||||
|
$config['where']['status'] = 1;
|
||||||
|
$config['order']['sort'] = 'desc';
|
||||||
|
$config['order']['id'] = 'desc';
|
||||||
|
break;
|
||||||
|
case 'show':
|
||||||
|
$config['where']['id'] = $p['id'];
|
||||||
|
$config['where']['status'] = 1;
|
||||||
|
break;
|
||||||
|
case 'store':
|
||||||
|
break;
|
||||||
|
case 'update':
|
||||||
|
$config['where']['id'] = $p['id'];
|
||||||
|
break;
|
||||||
|
case 'destroy':
|
||||||
|
$config['where']['id'] = $p['id'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加前置处理
|
* 添加前置处理
|
||||||
*/
|
*/
|
||||||
|
|||||||
+4
-16
@@ -92,22 +92,10 @@ Route::group('/common', function () {
|
|||||||
//协议
|
//协议
|
||||||
Route::any('/agreement', [app\admin\controller\AgreementController::class, 'show']);
|
Route::any('/agreement', [app\admin\controller\AgreementController::class, 'show']);
|
||||||
|
|
||||||
// 分类
|
// 轮播
|
||||||
// Route::group('/nav/categories', function () {
|
Route::group('/banner', function () {
|
||||||
// Route::any('/preset', [app\common\controller\NavCategoriesController::class, 'preset']);
|
Route::any('/list', [app\common\controller\BannerController::class, 'getAll']);
|
||||||
// Route::any('/complete', [app\common\controller\NavCategoriesController::class, 'complete']);
|
});
|
||||||
// });
|
|
||||||
|
|
||||||
// 分类下内容
|
|
||||||
// Route::group('/nav/item', function () {
|
|
||||||
// Route::any('/list', [app\common\controller\NavItemsController::class, 'index']);
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// // 设置
|
|
||||||
// Route::group('/config', function () {
|
|
||||||
// Route::any('/show', [app\common\controller\ConfigController::class, 'show']);
|
|
||||||
// Route::any('/find', [app\common\controller\ConfigController::class, 'find']);
|
|
||||||
// });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user