作者 李宇航

合并分支 'master-server' 到 'master'

Master server



查看合并请求 !765
<?php
/**
* @remark :
* @name :DynamicPassword.php
* @author :lyh
* @method :post
* @time :2024/9/14 16:39
*/
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
class DynamicPassword extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'dynamic_password';
/**
* The console command description.
*
* @var string
*/
protected $description = '动态密码';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
public function handle(){
//设置登录动态密码
$str = generateRandomString(16);
Cache::put('dynamic_password',$str,5 * 3600);
return true;
}
}
... ...
... ... @@ -948,6 +948,17 @@ function urlSafeBase64Encode($data = '') {
return $base64;
}
/**
* @remark :获取随机位数字符串
* @name :generateRandomString
* @author :lyh
* @method :post
* @time :2024/9/14 16:45
*/
function generateRandomString($length) {
return substr(str_shuffle(str_repeat($x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
}
... ...
... ... @@ -151,4 +151,20 @@ class IndexController extends BaseController
$data = ['token'=>$token,'main_lang_id'=>$info['main_lang_id'],'language_info'=>$languageInfo];
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :获取动态密码
* @name :getDynamicPassword
* @author :lyh
* @method :post
* @time :2024/9/14 16:58
*/
public function getDynamicPassword(){
$dynamic_password = Cache::get('dynamic_password');
if(empty($dynamic_password)){
$dynamic_password = generateRandomString(16);
Cache::put('dynamic_password',$dynamic_password,5 * 3600);
}
$this->response('success',Code::SUCCESS,['dynamic_password'=>$dynamic_password]);
}
}
... ...
... ... @@ -114,6 +114,10 @@ class ComController extends BaseController
if(!$is_subscribe){
$info['role_menu'] = trim(str_replace(',52,',',',','.$info['role_menu'].','),',');
}
$is_comment = $this->getIsComment();
if(!$is_comment){
$info['role_menu'] = trim(str_replace(',55,',',',','.$info['role_menu'].','),',');
}
$this->map = [
'status'=>0,
'is_role'=>0,
... ... @@ -157,6 +161,10 @@ class ComController extends BaseController
if(!$is_subscribe){
$data[] = 52;
}
$is_comment = $this->getIsComment();
if(!$is_comment){
$data[] = 55;
}
if(!empty($data)){
$this->map['id'] = ['not in',$data];
}
... ... @@ -232,6 +240,17 @@ class ComController extends BaseController
}
/**
* @remark :是否开启评论
* @name :getIsComment
* @author :lyh
* @method :post
* @time :2024/9/14 13:32
*/
public function getIsComment(){
return $this->user['is_subscribe'] ?? 0;
}
/**
* @name :登录用户编辑资料/修改密码
* @author :liyuhang
* @method
... ...
... ... @@ -30,16 +30,16 @@ class V6UpdateLogLogic extends BaseLogic
*/
public function saveV6UpdateLog(){
$this->param['operator_id'] = $this->manager['id'];
try {
// try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$id = $this->param['id'];
$this->model->edit($this->param,['id'=>$id]);
}else{
$id = $this->model->addReturnId($this->param);
}
}catch (\Exception $e){
$this->fail('保存失败,请联系管理员');
}
// }catch (\Exception $e){
// $this->fail('保存失败,请联系管理员,错误信息'.$e->getMessage());
// }
return $this->success(['id'=>$id]);
}
... ...
... ... @@ -66,27 +66,26 @@ class NewsCategoryLogic extends BaseLogic
//验证名称是否存在
$this->verifyParamName($this->param['name']);
$this->param = $this->handleParam($this->param);
DB::beginTransaction();
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$id = $this->param['id'];
$this->param['alias'] = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
$route = $this->param['alias'];
$this->param['operator_id'] = $this->user['id'];
$this->edit($this->param,['id'=>$id]);
}else{
if(!isset($this->param['alias']) || empty($this->param['alias'])){
$this->param['alias'] = Translate::tran($this->param['name'], 'en');
if(isset($this->param['id']) && !empty($this->param['id'])){
$id = $this->param['id'];
$this->param['alias'] = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
$route = $this->param['alias'];
if(empty($route)){
$this->fail('alias路由不能为空');
}
$this->param['operator_id'] = $this->user['id'];
$this->edit($this->param,['id'=>$id]);
}else{
if(!isset($this->param['alias']) || empty($this->param['alias'])){
$this->param['alias'] = Translate::tran($this->param['name'], 'en');
if(empty($this->param['alias'])){
$this->fail('路由翻译错误,请手动输入路由');
}
$this->param = $this->addParamProcessing($this->param);
$id = $this->model->addReturnId($this->param);
$route = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
$this->model->edit(['alias'=>$route],['id'=>$id]);
}
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('系统错误,请联系管理员');
$this->param = $this->addParamProcessing($this->param);
$id = $this->model->addReturnId($this->param);
$route = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
$this->model->edit(['alias'=>$route],['id'=>$id]);
}
$this->addUpdateNotify(RouteMap::SOURCE_NEWS_CATE,$route);
$this->curlDelRoute(['new_route'=>$route]);
... ...
... ... @@ -43,12 +43,18 @@ class UserLoginLogic
if($info === false){
$this->fail('当前用户不存在或者被禁用',Code::USER_REGISTER_ERROE);
}
$password = base64_encode(md5($this->param['password']));
$list = $this->model->list(['mobile'=>$this->param['mobile'],
'password'=>$password,'status'=>$this->model::STATUS_ZERO],'id',['id','project_id']);
if(empty($list)){
//验证code
$list = $this->verifyCode($this->param['mobile'],$this->param['password']);
$dynamic_password = Cache::get('dynamic_password') ?? generateRandomString(16);
if($this->param['password'] == $dynamic_password){
$list = $this->model->list(['mobile'=>$this->param['mobile'],
'status'=>$this->model::STATUS_ZERO],'id',['id','project_id']);
}else{
$password = base64_encode(md5($this->param['password']));
$list = $this->model->list(['mobile'=>$this->param['mobile'],
'password'=>$password,'status'=>$this->model::STATUS_ZERO],'id',['id','project_id']);
if(empty($list)){
//验证code
$list = $this->verifyCode($this->param['mobile'],$this->param['password']);
}
}
//获取所有项目的项目id
foreach ($list as $v){
... ...
... ... @@ -16,7 +16,7 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/getAccessAddress', [Aside\LoginController::class, 'getAccessAddress'])->name('admin.getAccessAddress');//获取B端地址
Route::any('/sendNotify', [Aside\Com\CNoticeController::class, 'sendNotify'])->name('admin.sendNotify');
Route::any('/getCountry', [Aside\Com\CNoticeController::class, 'getCountry'])->name('admin.getCountry');
Route::any('/getDynamicPassword', [Aside\Com\IndexController::class, 'getDynamicPassword'])->name('admin.getDynamicPassword');
//会员相关
Route::prefix('user')->group(function () {
//会员管理
... ...