初始化仓库

This commit is contained in:
Yao
2025-08-14 16:44:56 +08:00
commit 45b8c90ad8
5157 changed files with 664203 additions and 0 deletions

View File

@ -0,0 +1,36 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\api\controller;
use app\api\lists\AccountLogLists;
/**
* 账户流水
* Class AccountLogController
* @package app\api\controller
*/
class AccountLogController extends BaseApiController
{
/**
* @notes 账户流水
* @return \think\response\Json
* @author 段誉
* @date 2023/2/24 14:34
*/
public function lists()
{
return $this->dataLists(new AccountLogLists());
}
}

View File

@ -0,0 +1,111 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\api\controller;
use app\api\lists\article\ArticleCollectLists;
use app\api\lists\article\ArticleLists;
use app\api\logic\ArticleLogic;
/**
* 文章管理
* Class ArticleController
* @package app\api\controller
*/
class ArticleController extends BaseApiController
{
public array $notNeedLogin = ['lists', 'cate', 'detail'];
/**
* @notes 文章列表
* @return \think\response\Json
* @author 段誉
* @date 2022/9/20 15:30
*/
public function lists()
{
return $this->dataLists(new ArticleLists());
}
/**
* @notes 文章分类列表
* @return \think\response\Json
* @author 段誉
* @date 2022/9/20 15:30
*/
public function cate()
{
return $this->data(ArticleLogic::cate());
}
/**
* @notes 收藏列表
* @return \think\response\Json
* @author 段誉
* @date 2022/9/20 16:31
*/
public function collect()
{
return $this->dataLists(new ArticleCollectLists());
}
/**
* @notes 文章详情
* @return \think\response\Json
* @author 段誉
* @date 2022/9/20 17:09
*/
public function detail()
{
$id = $this->request->get('id/d');
$result = ArticleLogic::detail($id, $this->userId);
return $this->data($result);
}
/**
* @notes 加入收藏
* @return \think\response\Json
* @author 段誉
* @date 2022/9/20 17:01
*/
public function addCollect()
{
$articleId = $this->request->post('id/d');
ArticleLogic::addCollect($articleId, $this->userId);
return $this->success('操作成功');
}
/**
* @notes 取消收藏
* @return \think\response\Json
* @author 段誉
* @date 2022/9/20 17:01
*/
public function cancelCollect()
{
$articleId = $this->request->post('id/d');
ArticleLogic::cancelCollect($articleId, $this->userId);
return $this->success('操作成功');
}
}

View File

@ -0,0 +1,31 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\api\controller;
use app\common\controller\BaseLikeAdminController;
class BaseApiController extends BaseLikeAdminController
{
protected int $userId = 0;
protected array $userInfo = [];
public function initialize()
{
if (isset($this->request->userInfo) && $this->request->userInfo) {
$this->userInfo = $this->request->userInfo;
$this->userId = $this->request->userInfo['user_id'];
}
}
}

View File

@ -0,0 +1,94 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\api\controller;
use app\api\logic\IndexLogic;
use think\response\Json;
/**
* index
* Class IndexController
* @package app\api\controller
*/
class IndexController extends BaseApiController
{
public array $notNeedLogin = ['index', 'config', 'policy', 'decorate'];
/**
* @notes 首页数据
* @return Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 段誉
* @date 2022/9/21 19:15
*/
public function index()
{
$result = IndexLogic::getIndexData();
return $this->data($result);
}
/**
* @notes 全局配置
* @return Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 段誉
* @date 2022/9/21 19:41
*/
public function config()
{
$result = IndexLogic::getConfigData();
return $this->data($result);
}
/**
* @notes 政策协议
* @return Json
* @author 段誉
* @date 2022/9/20 20:00
*/
public function policy()
{
$type = $this->request->get('type/s', '');
$result = IndexLogic::getPolicyByType($type);
return $this->data($result);
}
/**
* @notes 装修信息
* @return Json
* @author 段誉
* @date 2022/9/21 18:37
*/
public function decorate()
{
$id = $this->request->get('id/d');
$result = IndexLogic::getDecorate($id);
return $this->data($result);
}
}

View File

@ -0,0 +1,216 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\api\controller;
use app\api\validate\{LoginAccountValidate, RegisterValidate, WebScanLoginValidate, WechatLoginValidate};
use app\api\logic\LoginLogic;
/**
* 登录注册
* Class LoginController
* @package app\api\controller
*/
class LoginController extends BaseApiController
{
public array $notNeedLogin = ['register', 'account', 'logout', 'codeUrl', 'oaLogin', 'mnpLogin', 'getScanCode', 'scanLogin'];
/**
* @notes 注册账号
* @return \think\response\Json
* @author 段誉
* @date 2022/9/7 15:38
*/
public function register()
{
$params = (new RegisterValidate())->post()->goCheck('register');
$result = LoginLogic::register($params);
if (true === $result) {
return $this->success('注册成功', [], 1, 1);
}
return $this->fail(LoginLogic::getError());
}
/**
* @notes 账号密码/手机号密码/手机号验证码登录
* @return \think\response\Json
* @author 段誉
* @date 2022/9/16 10:42
*/
public function account()
{
$params = (new LoginAccountValidate())->post()->goCheck();
$result = LoginLogic::login($params);
if (false === $result) {
return $this->fail(LoginLogic::getError());
}
return $this->data($result);
}
/**
* @notes 退出登录
* @return \think\response\Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 段誉
* @date 2022/9/16 10:42
*/
public function logout()
{
LoginLogic::logout($this->userInfo);
return $this->success();
}
/**
* @notes 获取微信请求code的链接
* @return \think\response\Json
* @author 段誉
* @date 2022/9/15 18:27
*/
public function codeUrl()
{
$url = $this->request->get('url');
$result = ['url' => LoginLogic::codeUrl($url)];
return $this->success('获取成功', $result);
}
/**
* @notes 公众号登录
* @return \think\response\Json
* @throws \GuzzleHttp\Exception\GuzzleException
* @author 段誉
* @date 2022/9/20 19:48
*/
public function oaLogin()
{
$params = (new WechatLoginValidate())->post()->goCheck('oa');
$res = LoginLogic::oaLogin($params);
if (false === $res) {
return $this->fail(LoginLogic::getError());
}
return $this->success('', $res);
}
/**
* @notes 小程序-登录接口
* @return \think\response\Json
* @author 段誉
* @date 2022/9/20 19:48
*/
public function mnpLogin()
{
$params = (new WechatLoginValidate())->post()->goCheck('mnpLogin');
$res = LoginLogic::mnpLogin($params);
if (false === $res) {
return $this->fail(LoginLogic::getError());
}
return $this->success('', $res);
}
/**
* @notes 小程序绑定微信
* @return \think\response\Json
* @author 段誉
* @date 2022/9/20 19:48
*/
public function mnpAuthBind()
{
$params = (new WechatLoginValidate())->post()->goCheck("wechatAuth");
$params['user_id'] = $this->userId;
$result = LoginLogic::mnpAuthLogin($params);
if ($result === false) {
return $this->fail(LoginLogic::getError());
}
return $this->success('绑定成功', [], 1, 1);
}
/**
* @notes 公众号绑定微信
* @return \think\response\Json
* @throws \GuzzleHttp\Exception\GuzzleException
* @author 段誉
* @date 2022/9/20 19:48
*/
public function oaAuthBind()
{
$params = (new WechatLoginValidate())->post()->goCheck("wechatAuth");
$params['user_id'] = $this->userId;
$result = LoginLogic::oaAuthLogin($params);
if ($result === false) {
return $this->fail(LoginLogic::getError());
}
return $this->success('绑定成功', [], 1, 1);
}
/**
* @notes 获取扫码地址
* @return \think\response\Json
* @author 段誉
* @date 2022/10/20 18:25
*/
public function getScanCode()
{
$redirectUri = $this->request->get('url/s');
$result = LoginLogic::getScanCode($redirectUri);
if (false === $result) {
return $this->fail(LoginLogic::getError() ?? '未知错误');
}
return $this->success('', $result);
}
/**
* @notes 网站扫码登录
* @return \think\response\Json
* @author 段誉
* @date 2022/10/21 10:28
*/
public function scanLogin()
{
$params = (new WebScanLoginValidate())->post()->goCheck();
$result = LoginLogic::scanLogin($params);
if (false === $result) {
return $this->fail(LoginLogic::getError() ?? '登录失败');
}
return $this->success('', $result);
}
/**
* @notes 更新用户头像昵称
* @return \think\response\Json
* @author 段誉
* @date 2023/2/22 11:15
*/
public function updateUser()
{
$params = (new WechatLoginValidate())->post()->goCheck("updateUser");
LoginLogic::updateUser($params, $this->userId);
return $this->success('操作成功', [], 1, 1);
}
}

View File

@ -0,0 +1,139 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\api\controller;
use app\api\validate\PayValidate;
use app\common\enum\user\UserTerminalEnum;
use app\common\logic\PaymentLogic;
use app\common\service\pay\AliPayService;
use app\common\service\pay\WeChatPayService;
/**
* 支付
* Class PayController
* @package app\api\controller
*/
class PayController extends BaseApiController
{
public array $notNeedLogin = ['notifyMnp', 'notifyOa', 'aliNotify'];
/**
* @notes 支付方式
* @return \think\response\Json
* @author 段誉
* @date 2023/2/24 17:54
*/
public function payWay()
{
$params = (new PayValidate())->goCheck('payway');
$result = PaymentLogic::getPayWay($this->userId, $this->userInfo['terminal'], $params);
if ($result === false) {
return $this->fail(PaymentLogic::getError());
}
return $this->data($result);
}
/**
* @notes 预支付
* @return \think\response\Json
* @author 段誉
* @date 2023/2/28 14:21
*/
public function prepay()
{
$params = (new PayValidate())->post()->goCheck();
//订单信息
$order = PaymentLogic::getPayOrderInfo($params);
if (false === $order) {
return $this->fail(PaymentLogic::getError(), $params);
}
//支付流程
$redirectUrl = $params['redirect'] ?? '/pages/payment/payment';
$result = PaymentLogic::pay($params['pay_way'], $params['from'], $order, $this->userInfo['terminal'], $redirectUrl);
if (false === $result) {
return $this->fail(PaymentLogic::getError(), $params);
}
return $this->success('', $result);
}
/**
* @notes 获取支付状态
* @return \think\response\Json
* @author 段誉
* @date 2023/3/1 16:23
*/
public function payStatus()
{
$params = (new PayValidate())->goCheck('status', ['user_id' => $this->userId]);
$result = PaymentLogic::getPayStatus($params);
if ($result === false) {
return $this->fail(PaymentLogic::getError());
}
return $this->data($result);
}
/**
* @notes 小程序支付回调
* @return \Psr\Http\Message\ResponseInterface
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
* @throws \ReflectionException
* @throws \Throwable
* @author 段誉
* @date 2023/2/28 14:21
*/
public function notifyMnp()
{
return (new WeChatPayService(UserTerminalEnum::WECHAT_MMP))->notify();
}
/**
* @notes 公众号支付回调
* @return \Psr\Http\Message\ResponseInterface
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
* @throws \ReflectionException
* @throws \Throwable
* @author 段誉
* @date 2023/2/28 14:21
*/
public function notifyOa()
{
return (new WeChatPayService(UserTerminalEnum::WECHAT_OA))->notify();
}
/**
* @notes 支付宝回调
* @author mjf
* @date 2024/3/18 16:50
*/
public function aliNotify()
{
$params = $this->request->post();
$result = (new AliPayService())->notify($params);
if (true === $result) {
echo 'success';
} else {
echo 'fail';
}
}
}

View File

@ -0,0 +1,95 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\api\controller;
use app\api\logic\PcLogic;
use think\response\Json;
/**
* PC
* Class PcController
* @package app\api\controller
*/
class PcController extends BaseApiController
{
public array $notNeedLogin = ['index', 'config', 'infoCenter', 'articleDetail'];
/**
* @notes 首页数据
* @return Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 段誉
* @date 2022/9/21 19:15
*/
public function index()
{
$result = PcLogic::getIndexData();
return $this->data($result);
}
/**
* @notes 全局配置
* @return Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 段誉
* @date 2022/9/21 19:41
*/
public function config()
{
$result = PcLogic::getConfigData();
return $this->data($result);
}
/**
* @notes 资讯中心
* @return Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 段誉
* @date 2022/10/19 16:55
*/
public function infoCenter()
{
$result = PcLogic::getInfoCenter();
return $this->data($result);
}
/**
* @notes 获取文章详情
* @return Json
* @author 段誉
* @date 2022/10/20 15:18
*/
public function articleDetail()
{
$id = $this->request->get('id/d', 0);
$source = $this->request->get('source/s', 'default');
$result = PcLogic::getArticleDetail($this->userId, $id, $source);
return $this->data($result);
}
}

View File

@ -0,0 +1,73 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\api\controller;
use app\api\lists\recharge\RechargeLists;
use app\api\logic\RechargeLogic;
use app\api\validate\RechargeValidate;
/**
* 充值控制器
* Class RechargeController
* @package app\shopapi\controller
*/
class RechargeController extends BaseApiController
{
/**
* @notes 获取充值列表
* @return \think\response\Json
* @author 段誉
* @date 2023/2/23 18:55
*/
public function lists()
{
return $this->dataLists(new RechargeLists());
}
/**
* @notes 充值
* @return \think\response\Json
* @author 段誉
* @date 2023/2/23 18:56
*/
public function recharge()
{
$params = (new RechargeValidate())->post()->goCheck('recharge', [
'user_id' => $this->userId,
'terminal' => $this->userInfo['terminal'],
]);
$result = RechargeLogic::recharge($params);
if (false === $result) {
return $this->fail(RechargeLogic::getError());
}
return $this->data($result);
}
/**
* @notes 充值配置
* @return \think\response\Json
* @author 段誉
* @date 2023/2/24 16:56
*/
public function config()
{
return $this->data(RechargeLogic::config($this->userId));
}
}

View File

@ -0,0 +1,41 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\api\controller;
use app\api\logic\SearchLogic;
/**
* 搜索
* Class HotSearchController
* @package app\api\controller
*/
class SearchController extends BaseApiController
{
public array $notNeedLogin = ['hotLists'];
/**
* @notes 热门搜素
* @return \think\response\Json
* @author 段誉
* @date 2022/9/22 10:14
*/
public function hotLists()
{
return $this->data(SearchLogic::hotLists());
}
}

View File

@ -0,0 +1,49 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\api\controller;
use app\api\logic\SmsLogic;
use app\api\validate\SendSmsValidate;
/**
* 短信
* Class SmsController
* @package app\api\controller
*/
class SmsController extends BaseApiController
{
public array $notNeedLogin = ['sendCode'];
/**
* @notes 发送短信验证码
* @return \think\response\Json
* @author 段誉
* @date 2022/9/15 16:17
*/
public function sendCode()
{
$params = (new SendSmsValidate())->post()->goCheck();
$result = SmsLogic::sendCode($params);
if (true === $result) {
return $this->success('发送成功');
}
return $this->fail(SmsLogic::getError());
}
}

View File

@ -0,0 +1,48 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\api\controller;
use app\common\enum\FileEnum;
use app\common\service\UploadService;
use Exception;
use think\response\Json;
/** 上传文件
* Class UploadController
* @package app\api\controller
*/
class UploadController extends BaseApiController
{
/**
* @notes 上传图片
* @return Json
* @author 段誉
* @date 2022/9/20 18:11
*/
public function image()
{
try {
$result = UploadService::image(0, $this->userId,FileEnum::SOURCE_USER);
return $this->success('上传成功', $result);
} catch (Exception $e) {
return $this->fail($e->getMessage());
}
}
}

View File

@ -0,0 +1,147 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\api\controller;
use app\api\logic\UserLogic;
use app\api\validate\PasswordValidate;
use app\api\validate\SetUserInfoValidate;
use app\api\validate\UserValidate;
/**
* 用户控制器
* Class UserController
* @package app\api\controller
*/
class UserController extends BaseApiController
{
public array $notNeedLogin = ['resetPassword'];
/**
* @notes 获取个人中心
* @return \think\response\Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 段誉
* @date 2022/9/16 18:19
*/
public function center()
{
$data = UserLogic::center($this->userInfo);
return $this->success('', $data);
}
/**
* @notes 获取个人信息
* @return \think\response\Json
* @author 段誉
* @date 2022/9/20 19:46
*/
public function info()
{
$result = UserLogic::info($this->userId);
return $this->data($result);
}
/**
* @notes 重置密码
* @return \think\response\Json
* @author 段誉
* @date 2022/9/16 18:06
*/
public function resetPassword()
{
$params = (new PasswordValidate())->post()->goCheck('resetPassword');
$result = UserLogic::resetPassword($params);
if (true === $result) {
return $this->success('操作成功', [], 1, 1);
}
return $this->fail(UserLogic::getError());
}
/**
* @notes 修改密码
* @return \think\response\Json
* @author 段誉
* @date 2022/9/20 19:16
*/
public function changePassword()
{
$params = (new PasswordValidate())->post()->goCheck('changePassword');
$result = UserLogic::changePassword($params, $this->userId);
if (true === $result) {
return $this->success('操作成功', [], 1, 1);
}
return $this->fail(UserLogic::getError());
}
/**
* @notes 获取小程序手机号
* @return \think\response\Json
* @author 段誉
* @date 2022/9/21 16:46
*/
public function getMobileByMnp()
{
$params = (new UserValidate())->post()->goCheck('getMobileByMnp');
$params['user_id'] = $this->userId;
$result = UserLogic::getMobileByMnp($params);
if ($result === false) {
return $this->fail(UserLogic::getError());
}
return $this->success('绑定成功', [], 1, 1);
}
/**
* @notes 编辑用户信息
* @return \think\response\Json
* @author 段誉
* @date 2022/9/21 17:01
*/
public function setInfo()
{
$params = (new SetUserInfoValidate())->post()->goCheck(null, ['id' => $this->userId]);
$result = UserLogic::setInfo($this->userId, $params);
if (false === $result) {
return $this->fail(UserLogic::getError());
}
return $this->success('操作成功', [], 1, 1);
}
/**
* @notes 绑定/变更 手机号
* @return \think\response\Json
* @author 段誉
* @date 2022/9/21 17:29
*/
public function bindMobile()
{
$params = (new UserValidate())->post()->goCheck('bindMobile');
$params['user_id'] = $this->userId;
$result = UserLogic::bindMobile($params);
if($result) {
return $this->success('绑定成功', [], 1, 1);
}
return $this->fail(UserLogic::getError());
}
}

View File

@ -0,0 +1,46 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\api\controller;
use app\api\logic\WechatLogic;
use app\api\validate\WechatValidate;
/**
* 微信
* Class WechatController
* @package app\api\controller
*/
class WechatController extends BaseApiController
{
public array $notNeedLogin = ['jsConfig'];
/**
* @notes 微信JSSDK授权接口
* @return mixed
* @author 段誉
* @date 2023/3/1 11:39
*/
public function jsConfig()
{
$params = (new WechatValidate())->goCheck('jsConfig');
$result = WechatLogic::jsConfig($params);
if ($result === false) {
return $this->fail(WechatLogic::getError(), [], 0, 0);
}
return $this->data($result);
}
}