点赞,收藏,消息,分类图标

This commit is contained in:
2025-11-25 15:39:16 +08:00
parent 48a77a09b0
commit 71c7d886cf
26 changed files with 1055 additions and 79 deletions
@@ -0,0 +1,33 @@
<?php
namespace app\admin\controller;
use app\common\controller\BaseController;
use app\common\traits\crud\CrudControllerTrait;
use app\common\service\MessageNoticeService;
class MessageNoticeController extends BaseController
{
use CrudControllerTrait;
protected $service;
public function __construct()
{
$this->service = new MessageNoticeService();
}
/**
* 列表页数据格式化
*
* @param array $data
* @return array
*/
// protected function indexFormat($data)
// {
// if (isset($data['created_at']))
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
// if (isset($data['updated_at']))
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
// return $data;
// }
}
@@ -2,6 +2,7 @@
namespace app\admin\controller;
use app\common\controller\BaseController;
use app\common\service\OssService;
use app\common\traits\crud\CrudControllerTrait;
use app\common\service\PostCategoryService;
use support\Request;
@@ -46,6 +47,10 @@ class PostCategoryController extends BaseController
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
if (isset($data['updated_at']))
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
if (!empty($data['icon'])){
$ossservice = new OssService();
$data['icon_pull'] = $ossservice->generatePrivateUrl($data['icon']);
}
return $data;
}
}
@@ -0,0 +1,33 @@
<?php
namespace app\admin\controller;
use app\common\controller\BaseController;
use app\common\traits\crud\CrudControllerTrait;
use app\common\service\PostFavoriteService;
class PostFavoriteController extends BaseController
{
use CrudControllerTrait;
protected $service;
public function __construct()
{
$this->service = new PostFavoriteService();
}
/**
* 列表页数据格式化
*
* @param array $data
* @return array
*/
// protected function indexFormat($data)
// {
// if (isset($data['created_at']))
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
// if (isset($data['updated_at']))
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
// return $data;
// }
}
@@ -0,0 +1,33 @@
<?php
namespace app\admin\controller;
use app\common\controller\BaseController;
use app\common\traits\crud\CrudControllerTrait;
use app\common\service\PostLikeService;
class PostLikeController extends BaseController
{
use CrudControllerTrait;
protected $service;
public function __construct()
{
$this->service = new PostLikeService();
}
/**
* 列表页数据格式化
*
* @param array $data
* @return array
*/
// protected function indexFormat($data)
// {
// if (isset($data['created_at']))
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
// if (isset($data['updated_at']))
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
// return $data;
// }
}
@@ -0,0 +1,59 @@
<?php
namespace app\common\controller;
use app\common\controller\BaseController;
use app\common\model\Post;
use app\common\model\PostMedia;
use app\common\traits\crud\CrudControllerTrait;
use app\common\service\MessageNoticeService;
use support\Request;
class MessageNoticeController extends BaseController
{
use CrudControllerTrait;
protected $service;
public function __construct()
{
$this->service = new MessageNoticeService();
}
/**
* 获取列表
*
* @param Request $request 请求对象
* @return mixed 返回分页数据及总数
*/
public function index(Request $request)
{
try {
$raw = $this->service->serviceSelfList($request);
$data = $this->transformData($raw, method_exists($this, 'indexFormat')
? [$this, 'indexFormat']
: null);
return $this->success($data);
} catch (\Throwable $e) {
return $this->error($e->getMessage());
}
}
/**
* 列表页数据格式化
*
* @param array $data
* @return array
*/
protected function indexFormat($data)
{
if (isset($data['created_at']))
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
if (isset($data['updated_at']))
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
if (isset($data['post_id'])){
$data['post'] = Post::where('id', $data['post_id'])->first();
$data['post']['media'] = PostMedia::where('post_id', $data['post_id'])->get();
}
return $data;
}
}
@@ -2,6 +2,7 @@
namespace app\common\controller;
use app\common\controller\BaseController;
use app\common\service\OssService;
use app\common\traits\crud\CrudControllerTrait;
use app\common\service\PostCategoryService;
@@ -22,12 +23,16 @@ class PostCategoryController extends BaseController
* @param array $data
* @return array
*/
// protected function indexFormat($data)
// {
// if (isset($data['created_at']))
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
// if (isset($data['updated_at']))
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
// return $data;
// }
protected function indexFormat($data)
{
if (isset($data['created_at']))
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
if (isset($data['updated_at']))
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
if (!empty($data['icon'])){
$ossservice = new OssService();
$data['icon_pull'] = $ossservice->generatePrivateUrl($data['icon']);
}
return $data;
}
}
@@ -0,0 +1,53 @@
<?php
namespace app\common\controller;
use app\common\controller\BaseController;
use app\common\traits\crud\CrudControllerTrait;
use app\common\service\PostFavoriteService;
use support\Request;
class PostFavoriteController extends BaseController
{
use CrudControllerTrait;
protected $service;
public function __construct()
{
$this->service = new PostFavoriteService();
}
/**
* 获取列表
*
* @param Request $request 请求对象
* @return mixed 返回分页数据及总数
*/
public function index(Request $request)
{
try {
$raw = $this->service->serviceSelfList($request);
$data = $this->transformData($raw, method_exists($this, 'indexFormat')
? [$this, 'indexFormat']
: null);
return $this->success($data);
} catch (\Throwable $e) {
return $this->error($e->getMessage());
}
}
/**
* 列表页数据格式化
*
* @param array $data
* @return array
*/
protected function indexFormat($data)
{
if (isset($data['created_at']))
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
if (isset($data['updated_at']))
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
return $data;
}
}
@@ -0,0 +1,53 @@
<?php
namespace app\common\controller;
use app\common\controller\BaseController;
use app\common\traits\crud\CrudControllerTrait;
use app\common\service\PostLikeService;
use support\Request;
class PostLikeController extends BaseController
{
use CrudControllerTrait;
protected $service;
public function __construct()
{
$this->service = new PostLikeService();
}
/**
* 获取列表
*
* @param Request $request 请求对象
* @return mixed 返回分页数据及总数
*/
public function index(Request $request)
{
try {
$raw = $this->service->serviceSelfList($request);
$data = $this->transformData($raw, method_exists($this, 'indexFormat')
? [$this, 'indexFormat']
: null);
return $this->success($data);
} catch (\Throwable $e) {
return $this->error($e->getMessage());
}
}
/**
* 列表页数据格式化
*
* @param array $data
* @return array
*/
protected function indexFormat($data)
{
if (isset($data['created_at']))
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
if (isset($data['updated_at']))
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
return $data;
}
}
+22 -42
View File
@@ -7,6 +7,7 @@ use app\common\traits\crud\CrudControllerTrait;
use app\common\service\UserService;
use app\common\service\WechatService;
use support\Request;
use support\Response;
class UserController extends BaseController
{
@@ -143,51 +144,30 @@ class UserController extends BaseController
public function wechatLogin1($request)
/**
* 小程序登录
*/
public function miniappLogin(Request $request): Response
{
$loginCode = $request->post('login_code');
$phoneCode = $request->post('phone_code');
if (!$loginCode || !$phoneCode) {
return json(['code'=>0, 'msg'=>'缺少参数']);
try {
$result = $this->service->miniappLogin($request->all());
return $this->success($result);
} catch (\Throwable $th) {
return $this->error($th->getMessage());
}
}
// 1) code2Session
$session = $this->code2Session($loginCode);
if (!isset($session['openid'])) {
return json(['code'=>0, 'msg'=>'登录失败', 'data'=>$session]);
/**
* 获取手机号
*/
public function miniappPhoneNumber(Request $request): Response
{
try {
$result = $this->service->miniappPhoneNumber($request->all());
return $this->success($result);
} catch (\Throwable $th) {
return $this->error($th->getMessage());
}
$openid = $session['openid'];
// 2) access_token
$tokenData = $this->getAccessToken();
$token = $tokenData['access_token'];
// 3) 换手机号
$phoneData = $this->getPhoneNumber($token, $phoneCode);
if (!isset($phoneData['phone_info']['phoneNumber'])) {
return json(['code'=>0, 'msg'=>'获取手机号失败', 'data'=>$phoneData]);
}
$phone = $phoneData['phone_info']['phoneNumber'];
// 4) 写入数据库或登录逻辑
// 比如自动注册
$user = User::firstOrCreate(['openid'=>$openid], [
'phone' => $phone
]);
return json([
'code' => 1,
'msg' => '登录成功',
'data' => [
'openid' => $openid,
'phone' => $phone,
'token' => md5($openid.time()), // 你自己的登录 token
]
]);
}
}
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace app\common\logic;
use app\common\traits\crud\CrudLogicTrait;
use app\common\model\MessageNotice;
class MessageNoticeLogic
{
use CrudLogicTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = MessageNotice::class;
}
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace app\common\logic;
use app\common\traits\crud\CrudLogicTrait;
use app\common\model\PostFavorite;
class PostFavoriteLogic
{
use CrudLogicTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = PostFavorite::class;
}
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace app\common\logic;
use app\common\traits\crud\CrudLogicTrait;
use app\common\model\PostLike;
class PostLikeLogic
{
use CrudLogicTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = PostLike::class;
}
+49
View File
@@ -0,0 +1,49 @@
<?php
namespace app\common\model;
use support\Model;
class MessageNotice extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'message_notice';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'receiver_user_id', 'sender_user_id', 'post_id', 'comment_id', 'type', 'content', 'is_read', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
}
+1 -1
View File
@@ -40,7 +40,7 @@ class PostCategory extends Model
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'parent_id', 'icon', 'name', 'level', 'path', 'sort', 'status', 'created_at', 'updated_at'];
protected $fillable = ['id', 'parent_id', 'icon_active', 'icon_inactive', 'name', 'level', 'path', 'sort', 'status', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
+49
View File
@@ -0,0 +1,49 @@
<?php
namespace app\common\model;
use support\Model;
class PostFavorite extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'post_favorite';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'post_id', 'user_id', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
}
+49
View File
@@ -0,0 +1,49 @@
<?php
namespace app\common\model;
use support\Model;
class PostLike extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'post_like';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'post_id', 'user_id', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
}
@@ -0,0 +1,92 @@
<?php
namespace app\common\service;
use app\common\validate\MessageNoticeValidate;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\MessageNotice;
use support\Request;
class MessageNoticeService
{
use CrudServiceTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = MessageNotice::class;
/**
* 验证器
*/
protected $validator = MessageNoticeValidate::class;
/**
* 获取验证器
*/
public function getValidator()
{
return new $this->validator;
}
/** 分页列表 */
public function serviceSelfList(Request $request, string $scene = 'self')
{
$result = $this->cqyProcess(ucfirst($scene), $request);
if ($result === false) {
$config = $this->buildQueryConfig($request, $scene);
$limit = (int)$request->get('size', 15);
$page = (int)$request->get('current', 1);
$result = $this->logicList($config, $limit, $page);
}
return $this->postProcess(ucfirst($scene), $result);
}
/**
* 构造 CrudUtil 查询配置
*/
protected function buildQueryConfig(Request $request, string $scene = 'default'): array
{
$p = $request->all();
$config = [];
$config['model'] = $this->modelClass;
switch ($scene) {
case 'default':
$config['order']['id'] = 'desc';
break;
case 'self':
$config['where']['receiver_user_id'] = $request->user->uid;
$config['order']['id'] = 'desc';
break;
case 'index':
$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;
}
/**
* 添加后置处理
*/
public function beforeServiceSelf($data, Request $request)
{
MessageNotice::where('receiver_user_id', $request->user->uid)->update(['is_read' => 1]);
return $data;
}
}
+107
View File
@@ -0,0 +1,107 @@
<?php
namespace app\common\service;
use app\common\model\MessageNotice;
use app\common\model\Post;
use app\common\validate\PostFavoriteValidate;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\PostFavorite;
use support\Request;
class PostFavoriteService
{
use CrudServiceTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = PostFavorite::class;
/**
* 验证器
*/
protected $validator = PostFavoriteValidate::class;
/**
* 获取验证器
*/
public function getValidator()
{
return new $this->validator;
}
/** 分页列表 */
public function serviceSelfList(Request $request, string $scene = 'self')
{
$result = $this->cqyProcess(ucfirst($scene), $request);
if ($result === false) {
$config = $this->buildQueryConfig($request, $scene);
$limit = (int)$request->get('size', 15);
$page = (int)$request->get('current', 1);
$result = $this->logicList($config, $limit, $page);
}
return $this->postProcess(ucfirst($scene), $result);
}
/**
* 构造 CrudUtil 查询配置
*/
protected function buildQueryConfig(Request $request, string $scene = 'default'): array
{
$p = $request->all();
$config = [];
$config['model'] = $this->modelClass;
switch ($scene) {
case 'default':
$config['order']['id'] = 'desc';
break;
case 'self':
$config['where']['user_id'] = $request->user->uid;
$config['order']['id'] = 'desc';
break;
case 'index':
$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;
}
/**
* 添加前置处理
*/
public function beforeServiceStore($data, Request $request)
{
$data['user_id'] = $request->user->uid;;
return $data;
}
/**
* 添加后置处理
*/
public function afterServiceStore($res)
{
$data = [];
$data['post_id'] = $res['post_id'];
$data['receiver_user_id'] = Post::where(['id' => $data['post_id']])->value('user_id');
$data['sender_user_id'] = $res['user_id'];
$data['type'] = 2;
MessageNotice::create($data);
}
}
+109
View File
@@ -0,0 +1,109 @@
<?php
namespace app\common\service;
use app\common\model\MessageNotice;
use app\common\model\Post;
use app\common\model\PostMedia;
use app\common\validate\PostLikeValidate;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\PostLike;
use support\Redis;
use support\Request;
class PostLikeService
{
use CrudServiceTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = PostLike::class;
/**
* 验证器
*/
protected $validator = PostLikeValidate::class;
/**
* 获取验证器
*/
public function getValidator()
{
return new $this->validator;
}
/** 分页列表 */
public function serviceSelfList(Request $request, string $scene = 'self')
{
$result = $this->cqyProcess(ucfirst($scene), $request);
if ($result === false) {
$config = $this->buildQueryConfig($request, $scene);
$limit = (int)$request->get('size', 15);
$page = (int)$request->get('current', 1);
$result = $this->logicList($config, $limit, $page);
}
return $this->postProcess(ucfirst($scene), $result);
}
/**
* 构造 CrudUtil 查询配置
*/
protected function buildQueryConfig(Request $request, string $scene = 'default'): array
{
$p = $request->all();
$config = [];
$config['model'] = $this->modelClass;
switch ($scene) {
case 'default':
$config['order']['id'] = 'desc';
break;
case 'self':
$config['where']['user_id'] = $request->user->uid;
$config['order']['id'] = 'desc';
break;
case 'index':
$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;
}
/**
* 添加前置处理
*/
public function beforeServiceStore($data, Request $request)
{
$data['user_id'] = $request->user->uid;;
return $data;
}
/**
* 添加后置处理
*/
public function afterServiceStore($res)
{
$data = [];
$data['post_id'] = $res['post_id'];
$data['receiver_user_id'] = Post::where(['id' => $data['post_id']])->value('user_id');
$data['sender_user_id'] = $res['user_id'];
$data['type'] = 1;
MessageNotice::create($data);
}
}
+43 -2
View File
@@ -3,7 +3,6 @@
namespace app\common\service;
use app\common\logic\AuthLogic;
use app\common\model\Corp;
use app\common\validate\UserValidate;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\User;
@@ -178,7 +177,7 @@ class UserService
/**
* 获取微信小程序用户信息
* 获取微信小程序用户信息(登录及获取手机号)
*/
public function wechatLogin(string $loginCode, string $phoneCode)
{
@@ -228,4 +227,46 @@ class UserService
$refreshToken = (new AuthLogic())->generateRefreshToken($user->id, 'info');
return array_merge($user->toArray(), ['access_token' => $token, 'is_bind' => true, 'refresh_token'=> $refreshToken, 'expires_in' => config('jwt.jwt_expiration')]);
}
/**
* 小程序登录
*/
public function miniappLogin(array $data)
{
$logic = new UserLogic();
$wechatService = new WechatService();
$wxinfo = $wechatService->xcxOpenid($data['code']);
// 用户信息
$user = User::firstOrCreate(
['openid' => $wxinfo['openid']],
['nickname' => '微信用户_'.$wxinfo['openid'], 'avatar' => getenv('MAIN_DOMAIN').'/avatar.png']
);
$jwt = new Jwt();
$JwtPayload = $logic->buildJwtPayload($user);
$JwtPayload['exp'] = $JwtPayload['exp'] + (86400 * 30);
$token = $jwt->generateToken($JwtPayload);
$refreshToken = (new AuthLogic())->generateRefreshToken($user->id, 'info');
return array_merge($user->toArray(), ['token' => $token, 'is_bind' => true, 'refresh_token'=> $refreshToken, 'expires_in' => config('jwt.jwt_expiration')]);
}
/**
* 获取手机号
*/
public function miniappPhoneNumber(array $data)
{
// 手机号
$wechatService = new WechatService();
$wxinfo = $wechatService->xcxPhoneNumber($data['phone_code']);
$uinfo = User::where('id', $data['user_id'])->first();
$uinfo->phone = $wxinfo['phone_info']['phoneNumber'];
$uinfo->save();
return $wxinfo;
}
}
+55
View File
@@ -4,6 +4,7 @@ namespace app\common\service;
use app\common\model\User;
use EasyWeChat\MiniApp\Application as xcxApplication;
use EasyWeChat\OpenPlatform\Application;
use support\Redis;
use GuzzleHttp\Client;
@@ -178,4 +179,58 @@ class WechatService
return json_decode(file_get_contents($url, false, stream_context_create($options)), true);
}
/**
* 小程序获取openid
* @param string $code
* @return array
* @throws BusinessException
*/
public function xcxOpenid(string $code): array
{
$config = [
'app_id' => getenv('WECHAT_MINI_APPID'),
'secret' => getenv('WECHAT_MINI_SECRET'),
'response_type' => 'array',
'log' => [
'level' => 'debug',
'file' => runtime_path().'/mzl/wechat.log',
]
];
// 创建微信小程序对象
$wechat = new xcxApplication($config);
// 获取 session_key 和 openid
return $wechat->getUtils()->codeToSession($code);
}
/**
* 小程序获取手机号
* @param string $phone_code
* @return mixed
* @throws BusinessException
*/
public function xcxPhoneNumber(string $phone_code)
{
$config = [
'app_id' => getenv('WECHAT_MINI_APPID'),
'secret' => getenv('WECHAT_MINI_SECRET'),
'response_type' => 'array',
'log' => [
'level' => 'debug',
'file' => runtime_path().'/mzl/wechat.log',
]
];
// 创建微信小程序对象
$wechat = new xcxApplication($config);
// getPhoneNumber
$data = ['code' => $phone_code];
$result = $wechat->getClient()->postJson('wxa/business/getuserphonenumber', $data);
if (isset($result['phone_info'])) {
// 业务处理 $result['phone_info']['phoneNumber']
return $result;
} else {
throw new BusinessException($result['errmsg']);
}
}
}
@@ -0,0 +1,29 @@
<?php
namespace app\common\validate;
use think\Validate;
class MessageNoticeValidate extends Validate
{
// 规则
protected $rule = [
];
// 提示
protected $message = [
];
// 场景
protected $scene = [
'store' => [
],
'update' => [
]
];
}
@@ -0,0 +1,29 @@
<?php
namespace app\common\validate;
use think\Validate;
class PostFavoriteValidate extends Validate
{
// 规则
protected $rule = [
];
// 提示
protected $message = [
];
// 场景
protected $scene = [
'store' => [
],
'update' => [
]
];
}
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace app\common\validate;
use think\Validate;
class PostLikeValidate extends Validate
{
// 规则
protected $rule = [
];
// 提示
protected $message = [
];
// 场景
protected $scene = [
'store' => [
],
'update' => [
]
];
}
+7 -7
View File
@@ -26,26 +26,26 @@ class IndexController
{
$options = [
'controller' => [
'module' => 'common',
'name' => 'agreement'
'module' => 'admin',
'name' => 'message_notice'
],
'model' => [
'module' => 'common',
'name' => 'agreement'
'name' => 'message_notice'
],
'service' => [
'module' => 'common',
'name' => 'agreement'
'name' => 'message_notice'
],
'logic' => [
'module' => 'common',
'name' => 'agreement'
'name' => 'message_notice'
],
'validate' => [
'module' => 'common',
'name' => 'agreement'
'name' => 'message_notice'
],
'table' => 'agreement'
'table' => 'message_notice'
];
$result = (new Generate($options))->doGenerate();
+52 -19
View File
@@ -21,7 +21,11 @@ Route::any('/qrcode/url', [app\common\controller\UserController::class, 'getQrUr
Route::any('/user/info', [app\common\controller\UserController::class, 'getUserInfo']);
Route::any('/bind/user', [app\common\controller\UserController::class, 'bindUser']);
Route::post('/wechat/login', [app\common\controller\UserController::class, 'wechatLogin']);
//Route::post('/wechat/login', [app\common\controller\UserController::class, 'wechatLogin']);
// 登录
Route::post('/miniapp/login', [app\common\controller\UserController::class, 'miniappLogin']);
// 手机号
Route::post('/miniapp/phone', [app\common\controller\UserController::class, 'miniappPhoneNumber']);
// 代理oss文件地址
Route::any('/proxy/ossurl', [app\common\controller\UploadController::class, 'proxy']);
@@ -59,6 +63,25 @@ Route::group('/common', function () {
Route::any('/store', [app\common\controller\PostCommentController::class, 'store']);
Route::any('/destroy', [app\common\controller\PostCommentController::class, 'destroy']);
});
// 点赞
Route::group('/like', function () {
Route::any('/list', [app\common\controller\PostLikeController::class, 'index']);
Route::any('/store', [app\common\controller\PostLikeController::class, 'store']);
Route::any('/destroy', [app\common\controller\PostLikeController::class, 'destroy']);
});
// 收藏
Route::group('/favorite', function () {
Route::any('/list', [app\common\controller\PostFavoriteController::class, 'index']);
Route::any('/store', [app\common\controller\PostFavoriteController::class, 'store']);
Route::any('/destroy', [app\common\controller\PostFavoriteController::class, 'destroy']);
});
// 消息
Route::group('/messageNotice', function () {
Route::any('/list', [app\common\controller\MessageNoticeController::class, 'index']);
});
});
//协议
@@ -126,16 +149,6 @@ Route::group('/admin', function () {
Route::any('/set/resources', [app\admin\controller\UserController::class, 'updateResources']);
Route::any('/update/password', [app\admin\controller\UserController::class, 'savePassword']);
});
// 帖子分类
Route::group('/post/category', function () {
Route::any('/list', [app\admin\controller\PostCategoryController::class, 'index']);
Route::any('/tree', [app\admin\controller\PostCategoryController::class, 'tree']);
Route::any('/show', [app\admin\controller\PostCategoryController::class, 'show']);
Route::any('/store', [app\admin\controller\PostCategoryController::class, 'store']);
Route::any('/update', [app\admin\controller\PostCategoryController::class, 'update']);
Route::any('/destroy', [app\admin\controller\PostCategoryController::class, 'destroy']);
});
// 帖子
Route::group('/post', function () {
Route::any('/list', [app\admin\controller\PostController::class, 'index']);
@@ -143,15 +156,35 @@ Route::group('/admin', function () {
Route::any('/store', [app\admin\controller\PostController::class, 'store']);
Route::any('/update', [app\admin\controller\PostController::class, 'update']);
Route::any('/destroy', [app\admin\controller\PostController::class, 'destroy']);
});
// 评论
Route::group('/post/comment', function () {
Route::any('/list', [app\admin\controller\PostCommentController::class, 'index']);
Route::any('/show', [app\admin\controller\PostCommentController::class, 'show']);
Route::any('/store', [app\admin\controller\PostCommentController::class, 'store']);
Route::any('/update', [app\admin\controller\PostCommentController::class, 'update']);
Route::any('/destroy', [app\admin\controller\PostCommentController::class, 'destroy']);
// 评论
Route::group('/comment', function () {
Route::any('/list', [app\admin\controller\PostCommentController::class, 'index']);
Route::any('/show', [app\admin\controller\PostCommentController::class, 'show']);
Route::any('/store', [app\admin\controller\PostCommentController::class, 'store']);
Route::any('/update', [app\admin\controller\PostCommentController::class, 'update']);
Route::any('/destroy', [app\admin\controller\PostCommentController::class, 'destroy']);
});
// 帖子分类
Route::group('/category', function () {
Route::any('/list', [app\admin\controller\PostCategoryController::class, 'index']);
Route::any('/tree', [app\admin\controller\PostCategoryController::class, 'tree']);
Route::any('/show', [app\admin\controller\PostCategoryController::class, 'show']);
Route::any('/store', [app\admin\controller\PostCategoryController::class, 'store']);
Route::any('/update', [app\admin\controller\PostCategoryController::class, 'update']);
Route::any('/destroy', [app\admin\controller\PostCategoryController::class, 'destroy']);
});
// 点赞
Route::group('/like', function () {
Route::any('/list', [app\admin\controller\PostLikeController::class, 'index']);
});
// 收藏
Route::group('/favorite', function () {
Route::any('/list', [app\admin\controller\PostFavoriteController::class, 'index']);
});
});
// // 分类下内容