作者 lyh

gx

... ... @@ -31,15 +31,6 @@ class DomainInfoController extends BaseController
$this->map['domain'] = ['like','%'.$this->map['domain'],'%'];
}
$lists = $domainModel->lists($this->map,$this->page,$this->row,$this->order);
$projectModel = new Project();
if(!empty($lists)){
foreach ($lists['list'] as $k => $v){
if(!empty($info['project_id'])){
$v['company'] = $projectModel->read(['id'=>$info['project_id']],['title'])['title'];
}
$lists['list'][$k] = $v;
}
}
return $this->response('success', Code::SUCCESS, $lists);
}
... ...
... ... @@ -40,12 +40,16 @@ class WebSettingController extends BaseController
* @param Request $request
* @param WebSettingLogic $webSettingLogic
*/
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]))
public function sendNotify(WebSettingLogic $webSettingLogic){
$type = $this->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);
}
$page = $this->request->input('page', UpdateNotify::PAGE_ALL);
if (FALSE == in_array($type, [UpdateNotify::PAGE_ALL, UpdateNotify::PAGE_SINGLE])){
$this->response('非法参数!', Code::USER_ERROR);
}
$list = $webSettingLogic->sendNotifyMessage($type,$page);
if(!empty($list)){
$this->response('当前页面正在生成了,请完成后再点击',Code::USER_ERROR,$list);
}
... ...
... ... @@ -5,6 +5,8 @@ namespace App\Http\Logic\Bside\Setting;
use App\Helper\Common as CommonHelper;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Com\UpdateNotify;
use App\Models\Com\UpdateProgress;
use App\Models\RouteMap\RouteMap;
use App\Models\WebSetting\WebSetting;
class WebSettingLogic extends BaseLogic
... ... @@ -62,24 +64,59 @@ class WebSettingLogic extends BaseLogic
* @param string $type
* @return array
*/
public function sendNotifyMessage($type = ''){
//获取当前项目所有未处理的更新并更换为1:处理中 2:处理完成
public function sendNotifyMessage($type,$page){
$updateProgressModel = new UpdateProgress();
$progressInfo = $updateProgressModel->formatQuery(['project_id'=>$this->user['project_id'],'type'=>$type])->orderBy('id','desc')->first()->toArray();
if((!empty($progressInfo)) && ($progressInfo['total_num'] > $progressInfo['current_num'])){
return $this->success($progressInfo);
}
$updateNotifyModel = new UpdateNotify();
// $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';
$field = ($type == UpdateNotify::TYPE_MINOR) ? 'minor_languages_status' : 'status';
$count = $updateNotifyModel->formatQuery(['project_id' => $this->user['project_id'], $field => 0])->count();
if($page == UpdateNotify::PAGE_ALL){
//如果是更新所有
$routeMapModel = new RouteMap();
$count = $routeMapModel->formatQuery(['project_id'=>$this->user['project_id'],'source'=>['!=','product_keyword']])->count();
}
$this->addProgress($count);
$updateNotifyModel->edit([$field => 1], ['project_id' => $this->user['project_id'], $field => 0]);
$urlStr = $this->getString();
http_get($urlStr,["charset = UTF-8"]);
return $this->success();
}
/**
* @remark :生成一条更新记录
* @name :addProgress
* @author :lyh
* @method :post
* @time :2023/9/6 17:01
*/
public function addProgress($count,$type){
$data = [
'total_num'=>$count,
'current_num'=>0,
'type'=>$type,
'created_at'=>date('Y-m-d H;i:s')
];
$updateProgressModel = new UpdateProgress();
return $updateProgressModel->insert($data);
}
/**
* @remark :通知参数处理
* @name :getString
* @author :lyh
* @method :post
* @time :2023/9/6 17:03
*/
public function getString($type,$page){
$param = [
'project_id' => $this->user['project_id'],
'type' => $type,
'route' => 'all'
'route' => $page
];
$string = http_build_query($param);
$urlStr = $this->user['domain'].'api/updateHtmlNotify/?' . $string;
http_get($urlStr,["charset = UTF-8"]);
return $this->success();
return $this->user['domain'].'api/updateHtmlNotify/?' . $string;
}
}
... ...
... ... @@ -17,6 +17,9 @@ class UpdateNotify extends Base
//连接数据库
protected $connection = 'custom_mysql';
const TYPE_MASTER = 'master_website';
const TYPE_MINOR = 'minor_languages';
const TYPE_MASTER = 1;//主站
const TYPE_MINOR = 2;//小语种
const PAGE_ALL= 1;//所有
const PAGE_SINGLE = 2;//按需
}
... ...
<?php
/**
* @remark :
* @name :UpdateProgress.php
* @author :lyh
* @method :post
* @time :2023/9/6 16:19
*/
namespace App\Models\Com;
use App\Models\Base;
class UpdateProgress extends Base
{
protected $table = 'gl_update_progress';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...