正在显示
2 个修改的文件
包含
108 行增加
和
38 行删除
| @@ -9,6 +9,7 @@ namespace App\Http\Controllers\Aside\Geo; | @@ -9,6 +9,7 @@ namespace App\Http\Controllers\Aside\Geo; | ||
| 9 | 9 | ||
| 10 | use App\Enums\Common\Code; | 10 | use App\Enums\Common\Code; |
| 11 | use App\Http\Controllers\Aside\BaseController; | 11 | use App\Http\Controllers\Aside\BaseController; |
| 12 | +use App\Http\Logic\Aside\Geo\GeoLogic; | ||
| 12 | use App\Models\Geo\GeoConf; | 13 | use App\Models\Geo\GeoConf; |
| 13 | use App\Models\Geo\GeoConfirm; | 14 | use App\Models\Geo\GeoConfirm; |
| 14 | use App\Models\Manage\ManageHr; | 15 | use App\Models\Manage\ManageHr; |
| @@ -23,6 +24,11 @@ use Illuminate\Http\Request; | @@ -23,6 +24,11 @@ use Illuminate\Http\Request; | ||
| 23 | */ | 24 | */ |
| 24 | class GeoController extends BaseController | 25 | class GeoController extends BaseController |
| 25 | { | 26 | { |
| 27 | + public function __construct(){ | ||
| 28 | + parent::__construct(); | ||
| 29 | + $this->logic = new GeoLogic(); | ||
| 30 | + } | ||
| 31 | + | ||
| 26 | /** | 32 | /** |
| 27 | * 获取GEO相关配置 | 33 | * 获取GEO相关配置 |
| 28 | * @param Request $request | 34 | * @param Request $request |
| @@ -34,36 +40,8 @@ class GeoController extends BaseController | @@ -34,36 +40,8 @@ class GeoController extends BaseController | ||
| 34 | ], [ | 40 | ], [ |
| 35 | 'project_id.required' => '项目ID不能为空', | 41 | 'project_id.required' => '项目ID不能为空', |
| 36 | ]); | 42 | ]); |
| 37 | - $projectModel = new Project(); | ||
| 38 | - $project_geo_conf = $projectModel->read(['id' => $this->param['project_id']],['title', 'version', 'geo_status', 'geo_qualify_num']); | ||
| 39 | - $geoConfModel = new GeoConf(); | ||
| 40 | - $geo_conf = $geoConfModel->read(['project_id' => $this->param['project_id']]); | ||
| 41 | - if($geo_conf === false){//数据未初始化 | ||
| 42 | - $geo_conf = [ | ||
| 43 | - 'project_id' => $this->param['project_id'], | ||
| 44 | - 'manager_id'=>0, | ||
| 45 | - 'company'=>$project_geo_conf['title'], | ||
| 46 | - 'brand'=>'', | ||
| 47 | - 'description'=>'' | ||
| 48 | - ]; | ||
| 49 | - } | ||
| 50 | - //负责人集合 | ||
| 51 | - $geo_manage_list = $geoConfModel->geoManage(); | ||
| 52 | - // geo配置管理员,已经移除管理员列表,补充管理员信息 | ||
| 53 | - if ($geo_conf && $geo_conf['manager_id'] && empty($geo_manage_list[$geo_conf['manager_id']])) { | ||
| 54 | - $manage = ManageHr::where(['id' => $geo_conf['manager_id']])->pluck('name', 'id')->toArray(); | ||
| 55 | - $geo_manage_list = array_merge($geo_manage_list, $manage); | ||
| 56 | - } | ||
| 57 | - $result = [ | ||
| 58 | - 'project_geo_conf' => $project_geo_conf, | ||
| 59 | - 'geo_conf' => $geo_conf, | ||
| 60 | - 'geo_manage_list' => $geo_manage_list, | ||
| 61 | - 'geo_keyword' => [ | ||
| 62 | - 'prefix' => KeywordPrefix::getKeyword($this->param['project_id'], KeywordPrefix::TYPE_GEO_PREFIX), | ||
| 63 | - 'suffix' => KeywordPrefix::getKeyword($this->param['project_id'], KeywordPrefix::TYPE_GEO_SUFFIX), | ||
| 64 | - ], | ||
| 65 | - ]; | ||
| 66 | - $this->response('success', Code::SUCCESS, $result); | 43 | + $data = $this->logic->getCongInfo($this->param['project_id']); |
| 44 | + $this->response('success', Code::SUCCESS, $data); | ||
| 67 | } | 45 | } |
| 68 | 46 | ||
| 69 | /** | 47 | /** |
| @@ -87,14 +65,8 @@ class GeoController extends BaseController | @@ -87,14 +65,8 @@ class GeoController extends BaseController | ||
| 87 | 'brand.max' => '品牌名不能超过200个字符', | 65 | 'brand.max' => '品牌名不能超过200个字符', |
| 88 | 'description.max' => '描述不能超过500个字符', | 66 | 'description.max' => '描述不能超过500个字符', |
| 89 | ]); | 67 | ]); |
| 90 | - try { | ||
| 91 | - $ | ||
| 92 | - $data = GeoConf::saveConf($this->param['project_id'], $this->param['manager_id'], $this->param['company'], $this->param['brand'], $this->param['description'], $this->param['prefix'], $this->param['suffix']); | ||
| 93 | - # FIXME 保存GEO状态 达标数量 | ||
| 94 | - $this->response('success', Code::SUCCESS, $data); | ||
| 95 | - } catch (\Exception $e) { | ||
| 96 | - $this->fail('配置保存失败, error:' . $e->getMessage()); | ||
| 97 | - } | 68 | + $data = $this->logic->saveConfig($this->param); |
| 69 | + $this->response('success', Code::SUCCESS, $data); | ||
| 98 | } | 70 | } |
| 99 | 71 | ||
| 100 | 72 |
app/Http/Logic/Aside/Geo/GeoLogic.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :GeoLogic.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/10/25 11:08 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Logic\Aside\Geo; | ||
| 11 | + | ||
| 12 | +use App\Enums\Common\Code; | ||
| 13 | +use App\Http\Logic\Aside\BaseLogic; | ||
| 14 | +use App\Models\Geo\GeoConf; | ||
| 15 | +use App\Models\Geo\GeoQuestion; | ||
| 16 | +use App\Models\Manage\ManageHr; | ||
| 17 | +use App\Models\Project\KeywordPrefix; | ||
| 18 | +use App\Models\Project\Project; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * @remark :geo设置 | ||
| 22 | + * @name :GeoLogic | ||
| 23 | + * @author :lyh | ||
| 24 | + * @method :post | ||
| 25 | + * @time :2025/10/25 11:08 | ||
| 26 | + */ | ||
| 27 | +class GeoLogic extends BaseLogic | ||
| 28 | +{ | ||
| 29 | + public function __construct() | ||
| 30 | + { | ||
| 31 | + parent::__construct(); | ||
| 32 | + $this->param = $this->requestAll; | ||
| 33 | + $this->model = new GeoConf(); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * @remark :获取geo设置数据详情 | ||
| 38 | + * @name :getCongInfo | ||
| 39 | + * @author :lyh | ||
| 40 | + * @method :post | ||
| 41 | + * @time :2025/10/25 11:10 | ||
| 42 | + */ | ||
| 43 | + public function getCongInfo($project_id) | ||
| 44 | + { | ||
| 45 | + $projectModel = new Project(); | ||
| 46 | + $project_geo_conf = $projectModel->read(['id' => $project_id],['title', 'version', 'geo_status', 'geo_qualify_num']); | ||
| 47 | + $geoConfModel = new GeoConf(); | ||
| 48 | + $geo_conf = $geoConfModel->read(['project_id' => $project_id]); | ||
| 49 | + if($geo_conf === false){//数据未初始化 | ||
| 50 | + $geo_conf = [ | ||
| 51 | + 'project_id' => $project_id, 'manager_id'=>0, 'company'=>$project_geo_conf['title'], 'brand'=>'', 'description'=>'' | ||
| 52 | + ]; | ||
| 53 | + } | ||
| 54 | + //负责人集合 | ||
| 55 | + $geo_manage_list = $geoConfModel->geoManage(); | ||
| 56 | + // geo配置管理员,已经移除管理员列表,补充管理员信息 | ||
| 57 | + if ($geo_conf && $geo_conf['manager_id'] && empty($geo_manage_list[$geo_conf['manager_id']])) { | ||
| 58 | + $manage = ManageHr::where(['id' => $geo_conf['manager_id']])->pluck('name', 'id')->toArray(); | ||
| 59 | + $geo_manage_list = array_merge($geo_manage_list, $manage); | ||
| 60 | + } | ||
| 61 | + $result = [ | ||
| 62 | + 'project_geo_conf' => $project_geo_conf, | ||
| 63 | + 'geo_conf' => $geo_conf, | ||
| 64 | + 'geo_manage_list' => $geo_manage_list, | ||
| 65 | + 'geo_keyword' => [ | ||
| 66 | + 'prefix' => KeywordPrefix::getKeyword($project_id, KeywordPrefix::TYPE_GEO_PREFIX), | ||
| 67 | + 'suffix' => KeywordPrefix::getKeyword($project_id, KeywordPrefix::TYPE_GEO_SUFFIX), | ||
| 68 | + ], | ||
| 69 | + ]; | ||
| 70 | + $this->success($result); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + /** | ||
| 74 | + * @remark :保存数据详情 | ||
| 75 | + * @name :saveCongInfo | ||
| 76 | + * @author :lyh | ||
| 77 | + * @method :post | ||
| 78 | + * @time :2025/10/25 11:14 | ||
| 79 | + * @param :project_id->项目id;manager_id->管理员id;company->公司名称;brand->品牌名;description->描述(必传) | ||
| 80 | + * @param :prefix->前缀;suffix->后缀(非必传) | ||
| 81 | + */ | ||
| 82 | + public function saveConfig($param) | ||
| 83 | + { | ||
| 84 | + try { | ||
| 85 | + $info = $this->model->read(['project_id' => $param['project_id']]); | ||
| 86 | + if($info === false){ | ||
| 87 | + $id = $this->model->addReturnId($param); | ||
| 88 | + }else{ | ||
| 89 | + $id = $param['id']; | ||
| 90 | + $this->model->edit($param,['id'=>$info['id']]); | ||
| 91 | + } | ||
| 92 | + # FIXME 保存GEO状态 达标数量 | ||
| 93 | + } catch (\Exception $e) { | ||
| 94 | + $this->fail('配置保存失败, error:' . $e->getMessage()); | ||
| 95 | + } | ||
| 96 | + return $this->success(['id'=>$id]); | ||
| 97 | + } | ||
| 98 | +} |
-
请 注册 或 登录 后发表评论