作者 zhl

u

... ... @@ -5,6 +5,8 @@ namespace App\Http\Controllers\Bside\Setting;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Setting\WebSettingLogic;
use App\Models\Com\UpdateNotify;
use Illuminate\Http\Request;
/**
* @name:项目首页设置
... ... @@ -34,14 +36,16 @@ class WebSettingController extends BaseController
}
/**
* @remark :更新通知C端
* @name :updateNotify
* @author :lyh
* @method :post
* @time :2023/8/1 9:33
* 更新通知C端
* @param Request $request
* @param WebSettingLogic $webSettingLogic
*/
public function sendNotify(WebSettingLogic $webSettingLogic){
$list = $webSettingLogic->sendNotifyMessage();
public function sendNotify(Request $request, WebSettingLogic $webSettingLogic){
$type = $request->input('type', UpdateNotify::TYPE_MASTER);
if (FALSE == in_array($type, [UpdateNotify::TYPE_MASTER, UpdateNotify::TYPE_MINOR]))
$this->response('非法参数!', Code::USER_ERROR);
$list = $webSettingLogic->sendNotifyMessage($type);
if(!empty($list)){
$this->response('当前页面正在生成了,请完成后再点击',Code::USER_ERROR,$list);
}
... ...
... ... @@ -58,21 +58,26 @@ class WebSettingLogic extends BaseLogic
}
/**
* @remark :通知c端
* @name :sendNotifyMessage
* @author :lyh
* @method :post
* @time :2023/8/1 9:36
* 通知c端
* @param string $type
* @return array
*/
public function sendNotifyMessage(){
public function sendNotifyMessage($type = ''){
//获取当前项目所有未处理的更新并更换为1:处理中 2:处理完成
$updateNotifyModel = new UpdateNotify();
$list = $updateNotifyModel->list(['project_id'=>$this->user['project_id'],'status'=>1]);
if(!empty($list)){
return $this->success($list);
}
$updateNotifyModel->edit(['status'=>1],['project_id'=>$this->user['project_id'],'status'=>0]);
$urlStr = 'https://'.$this->user['domain'].'/api/updateHtmlNotify?project_id='.$this->user['project_id'];
// $list = $updateNotifyModel->list(['project_id'=>$this->user['project_id'],'status'=>1]);
// if(!empty($list)){
// return $this->success($list);
// }
$field = $type == UpdateNotify::TYPE_MINOR ? 'minor_languages_status' : 'status';
$updateNotifyModel->edit(['status'=>1],['project_id' => $this->user['project_id'], $field => 0]);
$param = [
'project_id' => $this->user['project_id'],
'type' => $type,
'route' => 'all'
];
$string = http_build_query($param);
$urlStr = 'https://'.$this->user['domain'].'/api/updateHtmlNotify?' . $string;
http_get($urlStr);
return $this->success();
}
... ...
... ... @@ -16,4 +16,7 @@ class UpdateNotify extends Base
protected $table = 'gl_update_notify';
//连接数据库
protected $connection = 'custom_mysql';
const TYPE_MASTER = 'master_website';
const TYPE_MINOR = 'minor_languages';
}
... ...