合并分支 'lyh-server' 到 'master'
Lyh server 查看合并请求 !3013
正在显示
5 个修改的文件
包含
182 行增加
和
137 行删除
| @@ -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,13 +65,8 @@ class GeoController extends BaseController | @@ -87,13 +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 | - $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']); | ||
| 92 | - # FIXME 保存GEO状态 达标数量 | 68 | + $data = $this->logic->saveConfig($this->param); |
| 93 | $this->response('success', Code::SUCCESS, $data); | 69 | $this->response('success', Code::SUCCESS, $data); |
| 94 | - } catch (\Exception $e) { | ||
| 95 | - $this->fail('配置保存失败, error:' . $e->getMessage()); | ||
| 96 | - } | ||
| 97 | } | 70 | } |
| 98 | 71 | ||
| 99 | 72 |
| @@ -11,7 +11,7 @@ namespace App\Http\Controllers\Aside\Geo; | @@ -11,7 +11,7 @@ namespace App\Http\Controllers\Aside\Geo; | ||
| 11 | 11 | ||
| 12 | use App\Enums\Common\Code; | 12 | use App\Enums\Common\Code; |
| 13 | use App\Http\Controllers\Aside\BaseController; | 13 | use App\Http\Controllers\Aside\BaseController; |
| 14 | -use App\Http\Logic\Aside\Geo\GeoLogic; | 14 | +use App\Http\Logic\Aside\Geo\GeoQuestionLogic; |
| 15 | use Illuminate\Http\Request; | 15 | use Illuminate\Http\Request; |
| 16 | 16 | ||
| 17 | /** | 17 | /** |
| @@ -26,7 +26,7 @@ class GeoQuestionController extends BaseController | @@ -26,7 +26,7 @@ class GeoQuestionController extends BaseController | ||
| 26 | public function __construct(Request $request) | 26 | public function __construct(Request $request) |
| 27 | { | 27 | { |
| 28 | parent::__construct($request); | 28 | parent::__construct($request); |
| 29 | - $this->logic = new GeoLogic(); | 29 | + $this->logic = new GeoQuestionLogic(); |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | /** | 32 | /** |
| @@ -4,109 +4,96 @@ | @@ -4,109 +4,96 @@ | ||
| 4 | * @name :GeoLogic.php | 4 | * @name :GeoLogic.php |
| 5 | * @author :lyh | 5 | * @author :lyh |
| 6 | * @method :post | 6 | * @method :post |
| 7 | - * @time :2025/7/2 17:51 | 7 | + * @time :2025/10/25 11:08 |
| 8 | */ | 8 | */ |
| 9 | 9 | ||
| 10 | namespace App\Http\Logic\Aside\Geo; | 10 | namespace App\Http\Logic\Aside\Geo; |
| 11 | 11 | ||
| 12 | +use App\Enums\Common\Code; | ||
| 12 | use App\Http\Logic\Aside\BaseLogic; | 13 | use App\Http\Logic\Aside\BaseLogic; |
| 13 | -use App\Models\Geo\GeoPlatform; | 14 | +use App\Models\Geo\GeoConf; |
| 14 | use App\Models\Geo\GeoQuestion; | 15 | use App\Models\Geo\GeoQuestion; |
| 16 | +use App\Models\Manage\ManageHr; | ||
| 17 | +use App\Models\Project\KeywordPrefix; | ||
| 15 | use App\Models\Project\Project; | 18 | use App\Models\Project\Project; |
| 16 | 19 | ||
| 20 | +/** | ||
| 21 | + * @remark :geo设置 | ||
| 22 | + * @name :GeoLogic | ||
| 23 | + * @author :lyh | ||
| 24 | + * @method :post | ||
| 25 | + * @time :2025/10/25 11:08 | ||
| 26 | + */ | ||
| 17 | class GeoLogic extends BaseLogic | 27 | class GeoLogic extends BaseLogic |
| 18 | { | 28 | { |
| 19 | public function __construct() | 29 | public function __construct() |
| 20 | { | 30 | { |
| 21 | parent::__construct(); | 31 | parent::__construct(); |
| 22 | $this->param = $this->requestAll; | 32 | $this->param = $this->requestAll; |
| 23 | - $this->model = new GeoQuestion(); | 33 | + $this->model = new GeoConf(); |
| 24 | } | 34 | } |
| 25 | 35 | ||
| 26 | /** | 36 | /** |
| 27 | - * @remark :设置geo状态 | ||
| 28 | - * @name :setGeoStatus | 37 | + * @remark :获取geo设置数据详情 |
| 38 | + * @name :getCongInfo | ||
| 29 | * @author :lyh | 39 | * @author :lyh |
| 30 | * @method :post | 40 | * @method :post |
| 31 | - * @time :2025/7/2 17:51 | 41 | + * @time :2025/10/25 11:10 |
| 32 | */ | 42 | */ |
| 33 | - public function setGeoStatus(){ | 43 | + public function getCongInfo($project_id) |
| 44 | + { | ||
| 34 | $projectModel = new Project(); | 45 | $projectModel = new Project(); |
| 35 | - $data = $projectModel->edit(['geo_status'=>$this->param['geo_status'],'geo_frequency'=>$this->param['geo_frequency']],['id'=>$this->param['project_id']]); | ||
| 36 | - $questionModel = new GeoQuestion(); | ||
| 37 | - $questionModel->edit(['status'=>$this->param['geo_status']],['project_id'=>$this->param['project_id']]); | ||
| 38 | - return $this->success($data); | ||
| 39 | - } | ||
| 40 | - | ||
| 41 | - /** | ||
| 42 | - * @remark :获取类型 | ||
| 43 | - * @name :getType | ||
| 44 | - * @author :lyh | ||
| 45 | - * @method :post | ||
| 46 | - * @time :2025/7/3 10:47 | ||
| 47 | - */ | ||
| 48 | - public function getType(){ | ||
| 49 | - $data['type'] = $this->model->brandType(); | ||
| 50 | - $data['frequency'] = $this->model->frequency; | ||
| 51 | - $geoPlatformModel = new GeoPlatform(); | ||
| 52 | - $data['platform'] = $geoPlatformModel->getList(); | ||
| 53 | - return $this->success($data); | ||
| 54 | - } | ||
| 55 | - | ||
| 56 | - /** | ||
| 57 | - * @remark :获取问题列表 | ||
| 58 | - * @name :getGeoQuestionList | ||
| 59 | - * @author :lyh | ||
| 60 | - * @method :post | ||
| 61 | - * @time :2025/7/3 9:12 | ||
| 62 | - */ | ||
| 63 | - public function getGeoQuestionList($map,$page,$row,$order,$field = ['*']){ | ||
| 64 | - $data = $this->model->lists($map,$page,$row,$order,$field); | ||
| 65 | - if(!empty($data) && !empty($data['list'])){ | ||
| 66 | - foreach ($data['list'] as $key => $item){ | ||
| 67 | - $item['type_name'] = $this->model->brandType()[$item['type']]; | ||
| 68 | - $data['list'][$key] = $item; | 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 | + ]; | ||
| 69 | } | 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); | ||
| 70 | } | 60 | } |
| 71 | - return $this->success($data); | 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); | ||
| 72 | } | 71 | } |
| 73 | 72 | ||
| 74 | /** | 73 | /** |
| 75 | - * @remark :保存数据 | ||
| 76 | - * @name :saveGeoQuestion | 74 | + * @remark :保存数据详情 |
| 75 | + * @name :saveCongInfo | ||
| 77 | * @author :lyh | 76 | * @author :lyh |
| 78 | * @method :post | 77 | * @method :post |
| 79 | - * @time :2025/7/3 9:47 | ||
| 80 | - * @param : question->提交的问题 | ||
| 81 | - * @param : url->提交的网址 | ||
| 82 | - * @param : keywords->提交的关键字 | ||
| 83 | - * @param : project_id->项目id | 78 | + * @time :2025/10/25 11:14 |
| 79 | + * @param :project_id->项目id;manager_id->管理员id;company->公司名称;brand->品牌名;description->描述(必传) | ||
| 80 | + * @param :prefix->前缀;suffix->后缀(非必传) | ||
| 84 | */ | 81 | */ |
| 85 | - public function saveGeoQuestion(){ | ||
| 86 | - //处理数据 | ||
| 87 | - $this->param['question'] = json_encode($this->param['question'] ?? [],true); | ||
| 88 | - $this->param['url'] = json_encode($this->param['url'] ?? [],true); | ||
| 89 | - $this->param['keywords'] = json_encode($this->param['keywords'] ?? [],true); | ||
| 90 | - //执行时间设置为今天 | ||
| 91 | - if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 92 | - $id = $this->param['id']; | ||
| 93 | - $this->model->edit($this->param,['id'=>$id]); | 82 | + public function saveConfig($param) |
| 83 | + { | ||
| 84 | + $projectModel = new Project(); | ||
| 85 | + $projectModel->edit(['geo_status'=>$param['geo_status'],'geo_qualify_num'=>$param['geo_qualify_num']],['id'=>$param['project_id']]); | ||
| 86 | + try { | ||
| 87 | + $info = $this->model->read(['project_id' => $param['project_id']]); | ||
| 88 | + if($info === false){ | ||
| 89 | + $id = $this->model->addReturnId($param); | ||
| 94 | }else{ | 90 | }else{ |
| 95 | - $this->param['next_time'] = date('Y-m-d'); | ||
| 96 | - $id = $this->model->addReturnId($this->param); | 91 | + $id = $param['id']; |
| 92 | + $this->model->edit($param,['id'=>$info['id']]); | ||
| 97 | } | 93 | } |
| 98 | - return $this->success(['id'=>$id]); | 94 | + } catch (\Exception $e) { |
| 95 | + $this->fail('配置保存失败, error:' . $e->getMessage()); | ||
| 99 | } | 96 | } |
| 100 | - | ||
| 101 | - /** | ||
| 102 | - * @remark :删除数据 | ||
| 103 | - * @name :delGeoQuestion | ||
| 104 | - * @author :lyh | ||
| 105 | - * @method :post | ||
| 106 | - * @time :2025/7/3 10:13 | ||
| 107 | - */ | ||
| 108 | - public function delGeoQuestion(){ | ||
| 109 | - $data = $this->model->del(['id'=>['in',$this->param['ids']]]); | ||
| 110 | - return $this->success($data); | 97 | + return $this->success(['id'=>$id]); |
| 111 | } | 98 | } |
| 112 | } | 99 | } |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :GeoQuestionLogic.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/7/2 17:51 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Logic\Aside\Geo; | ||
| 11 | + | ||
| 12 | +use App\Http\Logic\Aside\BaseLogic; | ||
| 13 | +use App\Models\Geo\GeoPlatform; | ||
| 14 | +use App\Models\Geo\GeoQuestion; | ||
| 15 | +use App\Models\Project\Project; | ||
| 16 | + | ||
| 17 | +class GeoQuestionLogic extends BaseLogic | ||
| 18 | +{ | ||
| 19 | + public function __construct() | ||
| 20 | + { | ||
| 21 | + parent::__construct(); | ||
| 22 | + $this->param = $this->requestAll; | ||
| 23 | + $this->model = new GeoQuestion(); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * @remark :设置geo状态 | ||
| 28 | + * @name :setGeoStatus | ||
| 29 | + * @author :lyh | ||
| 30 | + * @method :post | ||
| 31 | + * @time :2025/7/2 17:51 | ||
| 32 | + */ | ||
| 33 | + public function setGeoStatus(){ | ||
| 34 | + $projectModel = new Project(); | ||
| 35 | + $data = $projectModel->edit(['geo_status'=>$this->param['geo_status'],'geo_frequency'=>$this->param['geo_frequency']],['id'=>$this->param['project_id']]); | ||
| 36 | + $questionModel = new GeoQuestion(); | ||
| 37 | + $questionModel->edit(['status'=>$this->param['geo_status']],['project_id'=>$this->param['project_id']]); | ||
| 38 | + return $this->success($data); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * @remark :获取类型 | ||
| 43 | + * @name :getType | ||
| 44 | + * @author :lyh | ||
| 45 | + * @method :post | ||
| 46 | + * @time :2025/7/3 10:47 | ||
| 47 | + */ | ||
| 48 | + public function getType(){ | ||
| 49 | + $data['type'] = $this->model->brandType(); | ||
| 50 | + $data['frequency'] = $this->model->frequency; | ||
| 51 | + $geoPlatformModel = new GeoPlatform(); | ||
| 52 | + $data['platform'] = $geoPlatformModel->getList(); | ||
| 53 | + return $this->success($data); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * @remark :获取问题列表 | ||
| 58 | + * @name :getGeoQuestionList | ||
| 59 | + * @author :lyh | ||
| 60 | + * @method :post | ||
| 61 | + * @time :2025/7/3 9:12 | ||
| 62 | + */ | ||
| 63 | + public function getGeoQuestionList($map,$page,$row,$order,$field = ['*']){ | ||
| 64 | + $data = $this->model->lists($map,$page,$row,$order,$field); | ||
| 65 | + if(!empty($data) && !empty($data['list'])){ | ||
| 66 | + foreach ($data['list'] as $key => $item){ | ||
| 67 | + $item['type_name'] = $this->model->brandType()[$item['type']]; | ||
| 68 | + $data['list'][$key] = $item; | ||
| 69 | + } | ||
| 70 | + } | ||
| 71 | + return $this->success($data); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + /** | ||
| 75 | + * @remark :保存数据 | ||
| 76 | + * @name :saveGeoQuestion | ||
| 77 | + * @author :lyh | ||
| 78 | + * @method :post | ||
| 79 | + * @time :2025/7/3 9:47 | ||
| 80 | + * @param : question->提交的问题 | ||
| 81 | + * @param : url->提交的网址 | ||
| 82 | + * @param : keywords->提交的关键字 | ||
| 83 | + * @param : project_id->项目id | ||
| 84 | + */ | ||
| 85 | + public function saveGeoQuestion(){ | ||
| 86 | + //处理数据 | ||
| 87 | + $this->param['question'] = json_encode($this->param['question'] ?? [],true); | ||
| 88 | + $this->param['url'] = json_encode($this->param['url'] ?? [],true); | ||
| 89 | + $this->param['keywords'] = json_encode($this->param['keywords'] ?? [],true); | ||
| 90 | + //执行时间设置为今天 | ||
| 91 | + if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 92 | + $id = $this->param['id']; | ||
| 93 | + $this->model->edit($this->param,['id'=>$id]); | ||
| 94 | + }else{ | ||
| 95 | + $this->param['next_time'] = date('Y-m-d'); | ||
| 96 | + $id = $this->model->addReturnId($this->param); | ||
| 97 | + } | ||
| 98 | + return $this->success(['id'=>$id]); | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + /** | ||
| 102 | + * @remark :删除数据 | ||
| 103 | + * @name :delGeoQuestion | ||
| 104 | + * @author :lyh | ||
| 105 | + * @method :post | ||
| 106 | + * @time :2025/7/3 10:13 | ||
| 107 | + */ | ||
| 108 | + public function delGeoQuestion(){ | ||
| 109 | + $data = $this->model->del(['id'=>['in',$this->param['ids']]]); | ||
| 110 | + return $this->success($data); | ||
| 111 | + } | ||
| 112 | +} |
| @@ -23,33 +23,6 @@ class GeoConf extends Base | @@ -23,33 +23,6 @@ class GeoConf extends Base | ||
| 23 | */ | 23 | */ |
| 24 | protected $table = 'gl_project_geo_conf'; | 24 | protected $table = 'gl_project_geo_conf'; |
| 25 | 25 | ||
| 26 | - /** | ||
| 27 | - * 保存GEO相关配置 | ||
| 28 | - * @param $project_id | ||
| 29 | - * @param $manager_id | ||
| 30 | - * @param $company | ||
| 31 | - * @param $brand | ||
| 32 | - * @param $description | ||
| 33 | - * @param $prefix | ||
| 34 | - * @param $suffix | ||
| 35 | - * @return GeoConf | ||
| 36 | - */ | ||
| 37 | - public static function saveConf($project_id, $manager_id, $company, $brand, $description, $prefix, $suffix) | ||
| 38 | - { | ||
| 39 | - $data = self::where(compact('project_id'))->first(); | ||
| 40 | - if (empty($data)) { | ||
| 41 | - $data = new self(); | ||
| 42 | - $data->project_id = $project_id; | ||
| 43 | - } | ||
| 44 | - $data->manager_id = $manager_id; | ||
| 45 | - $data->company = $company; | ||
| 46 | - $data->brand = $brand; | ||
| 47 | - $data->description = $description; | ||
| 48 | - $data->prefix = $prefix; | ||
| 49 | - $data->suffix = $suffix; | ||
| 50 | - $data->save(); | ||
| 51 | - return $data; | ||
| 52 | - } | ||
| 53 | 26 | ||
| 54 | /** | 27 | /** |
| 55 | * GEO 负责人集合 | 28 | * GEO 负责人集合 |
-
请 注册 或 登录 后发表评论