作者 lyh

Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6 into develop

... ... @@ -79,7 +79,7 @@ class PushAiccData extends Command
$data['friend_id'] = $isExists->friend_id;
$data['user_id'] = $isExists->user_id;
$url = env('AICC_URL');
$url = env('AICC_URL') . env('AICC_PUSH_API_URL');
$msg = http_post($url, json_encode(compact('data')));
$status_code = 0;
if ($msg) {
... ... @@ -105,7 +105,7 @@ class PushAiccData extends Command
public function post_data($data)
{
$url = env('AICC_URL');
$url = env('AICC_URL') . env('AICC_PUSH_API_URL');
$msg = http_post($url, json_encode(compact('data')));
print_r($msg);
}
... ...
... ... @@ -33,10 +33,11 @@ class UpdateController extends BaseController
* @method :post
* @time :2023/8/19 9:25
*/
public function updateSeoTdk(){
public function updateSeoTdk()
{
$this->request->validate([
'project_id'=>'required',
],[
'project_id' => 'required',
], [
'project_id.required' => 'project_id不能为空',
]);
ProjectUpdateTdk::add_task($this->param['project_id']);
... ... @@ -48,14 +49,42 @@ class UpdateController extends BaseController
* @author Akun
* @date 2023/11/24 11:33
*/
public function dataCollect(){
public function dataCollect()
{
$this->request->validate([
'project_id'=>'required',
],[
'project_id' => 'required',
'type' => 'required',
], [
'project_id.required' => 'project_id不能为空',
'type.required' => '采集类型不能为空',
]);
UpdateLog::updateLog($this->param['project_id']);
$this->response('任务添加成功');
$update_info = UpdateLog::where('project_id', $this->param['project_id'])->first();
if (!$update_info) {
$this->fail('当前项目非升级项目,无法采集');
}
$project = ProjectServer::useProject($this->param['project_id']);
if ($project) {
try {
DB::connection('custom_mysql')->statement("DELETE FROM `gl_collect_source` WHERE `origin` LIKE '%.css%' OR `origin` LIKE '%.js%'");
DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0 WHERE `language` = ''");
} catch (\Exception $e) {
errorLog('重新采集升级项目数据', $this->param, $e);
$this->fail('采集任务添加失败');
}
}
//关闭数据库
DB::disconnect('custom_mysql');
$update = ['collect_status' => 0];
if ($this->param['type'] == 2) {
$update['status'] = 0;
}
UpdateLog::where('project_id', $this->param['project_id'])->whereIn('api_type', ['post', 'page', 'news', 'blog'])->update($update);
$this->response('采集任务添加成功');
}
}
... ...
... ... @@ -6,7 +6,9 @@ use App\Enums\Common\Code;
use App\Exceptions\BsideGlobalException;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Aside\ProjectAssociation\ProjectAssociationLogic;
use App\Models\ProjectAssociation\ProjectAssociation;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
... ... @@ -48,4 +50,64 @@ class ProjectAssociationController extends BaseController
$this->ProjectAssociationLogic->saveWeChatData($data);
$this->response('success');
}
public function check()
{
$project_id = (int)request()->input('project_id', 0);
$status = request()->input('status');
// 重载redis缓存
$cache = request()->input('cache');
if (isset($status)) {
$status = (int)$status ? ProjectAssociation::STATUS_NORMAL : ProjectAssociation::STATUS_DISABLED;
}
$isRes = $this->ProjectAssociationLogic->normal($project_id);
DB::beginTransaction();
try {
// 当数据不存在时并开启状态,自动添加一条数据
if (is_null($isRes) && (!is_null($status) && $status)) {
$isRes = $this->ProjectAssociationLogic->disabled($project_id);
if (is_null($isRes)) {
$isRes = new ProjectAssociation();
}
$isRes->project_id = $project_id;
$isRes->user_id = (int)env('AICC_WECHAT_USER_ID');
$isRes->status = $status;
$isRes->save();
DB::commit();
} // 关闭状态
elseif (!is_null($isRes) && (!is_null($status) && empty($status))) {
$isRes->status = $status;
$isRes->save();
DB::commit();
return [
'code' => Code::SUCCESS,
'data' => [],
'message' => '关闭AICC绑定成功!',
];
}
} catch (\Exception $exception) {
DB::rollBack();
$this->response('数据错误,请重试!', Code::SERVER_ERROR);
}
if (is_null($isRes)) {
$this->response('请开启AICC绑定!', Code::USER_ERROR, []);
}
$redis_key = 'aicc_friend_lists_' . (int)env('AICC_WECHAT_USER_ID');
$result = isset($cache) ? false : redis_get($redis_key);
if (empty($result)) {
$url = env('AICC_URL') . env('AICC_WECHAT_FRIEND_API_URL');
$result = curlGet($url);
redis_set($redis_key, json_encode($result));
} else {
$result = json_decode($result, true);
}
$result['info'] = [
'friend_id' => $isRes->friend_id ?? 0,
'nickname' => $isRes->nickname ?? '',
'user_name' => $isRes->user_name ?? '',
'image' => $isRes->image ?? '',
];
$this->response('success', Code::SUCCESS, $result);
}
}
... ...
... ... @@ -110,26 +110,23 @@ class DomainInfoLogic extends BaseLogic
}
/**
* @remark :删除域名
* @name :delDomain
* @author :lyh
* @method :post
* @time :2023/8/1 15:41
* 删除域名
* @return array
* @throws \App\Exceptions\AsideGlobalException
* @throws \App\Exceptions\BsideGlobalException
*/
public function delDomain(){
$ids = $this->param['id'];
// 初始化数据
if (FALSE == is_array($ids))
$ids = [$ids];
foreach ($ids as $k => $v){
$info = $this->model->read(['id'=>$v]);
$deployOptimizeModel = new DeployOptimize();
$domainInfo = $deployOptimizeModel->read(['domain'=>$info['domain']]);
if($domainInfo !== false){
$this->fail('当前域名正在使用中');
}
}
$this->param['id'] = ['in',$ids];
$rs = $this->model->del($this->param);
if($rs === false){
$this->fail('error');
$domain = DomainInfo::where(['id' => $v])->first();
if (empty($domain))
continue;
if (FALSE == empty($domain['project_id']))
$this->fail($domain->domain . '域名正在使用中, 删除失败!');
$domain->delete();
}
return $this->success();
}
... ...
... ... @@ -5,6 +5,8 @@ namespace App\Http\Logic\Aside\ProjectAssociation;
use App\Enums\Common\Code;
use App\Http\Logic\Logic;
use App\Models\ProjectAssociation\ProjectAssociation;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
class ProjectAssociationLogic extends Logic
... ... @@ -24,4 +26,25 @@ class ProjectAssociationLogic extends Logic
}
return $status;
}
/**
* status - 正常
* @param $project_id
* @return ProjectAssociation|Builder|Model|object|null
*/
public function normal($project_id)
{
return ProjectAssociation::query()->whereProjectId($project_id)->whereStatus(ProjectAssociation::STATUS_NORMAL)->first();
}
/**
* status - 禁用
* @param $project_id
* @return ProjectAssociation|Builder|Model|object|null
*/
public function disabled($project_id)
{
return ProjectAssociation::query()->whereProjectId($project_id)->whereStatus(ProjectAssociation::STATUS_DISABLED)->first();
}
}
... ...
... ... @@ -73,6 +73,8 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/log', [Aside\Ai\AiLogController::class, 'lists'])->name('admin.lists');
// 绑定AICC微信应用
Route::post('/wechat', [ProjectAssociationController::class, 'saveWeChatData'])->name('admin.aicc.wechat');
// OA后台开启关闭AICC用户绑定
Route::post('/check', [ProjectAssociationController::class, 'check'])->name('admin.aicc.check');
});
//特殊模块权限设置
Route::prefix('special')->group(function () {
... ...