作者 赵彬吉

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

@@ -72,14 +72,13 @@ class DevopsTask extends Command @@ -72,14 +72,13 @@ class DevopsTask extends Command
72 continue; 72 continue;
73 } 73 }
74 //DB类是单例模式,生命周期内修改配置不会生效 74 //DB类是单例模式,生命周期内修改配置不会生效
75 - $encrypt = new EncryptUtils();  
76 try { 75 try {
77 $conn = new \mysqli( 76 $conn = new \mysqli(
78 $project->mysqlConfig->host, 77 $project->mysqlConfig->host,
79 - $encrypt->unlock_url($project->mysqlConfig->user),  
80 - $encrypt->unlock_url($project->mysqlConfig->password), 78 + $project->mysqlConfig->user,
  79 + $project->mysqlConfig->password,
81 $project->databaseName(), 80 $project->databaseName(),
82 - $encrypt->unlock_url($project->mysqlConfig->port), 81 + $project->mysqlConfig->port,
83 ); 82 );
84 }catch (\Exception $e){ 83 }catch (\Exception $e){
85 $log->remark = mb_substr('数据库连接失败:' . $e->getMessage(), 0, 500); 84 $log->remark = mb_substr('数据库连接失败:' . $e->getMessage(), 0, 500);
@@ -6,6 +6,7 @@ use App\Enums\Common\Code; @@ -6,6 +6,7 @@ use App\Enums\Common\Code;
6 use App\Http\Controllers\Aside\BaseController; 6 use App\Http\Controllers\Aside\BaseController;
7 use App\Http\Logic\Aside\Manage\ManageLogic; 7 use App\Http\Logic\Aside\Manage\ManageLogic;
8 use App\Http\Requests\Aside\Manage\ManageRequest; 8 use App\Http\Requests\Aside\Manage\ManageRequest;
  9 +use App\Models\Manage\Manage;
9 use App\Models\Manage\MenuSpecial; 10 use App\Models\Manage\MenuSpecial;
10 use App\Models\User\ProjectRole; 11 use App\Models\User\ProjectRole;
11 use App\Rules\Ids; 12 use App\Rules\Ids;
@@ -28,19 +29,10 @@ class ManageController extends BaseController @@ -28,19 +29,10 @@ class ManageController extends BaseController
28 * @method :post 29 * @method :post
29 * @time :2023/8/28 10:04 30 * @time :2023/8/28 10:04
30 */ 31 */
31 - public function list(Request $request, ManageLogic $logic) 32 + public function list()
32 { 33 {
33 - $map = [];  
34 - if(!empty($this->param['search'])){  
35 - $map[] = ['name|mobile', 'like', "%{$this->param['search']}%"];  
36 - }  
37 - if(!empty($this->param['dept_id'])){  
38 - $map[] = ['dept_id', $this->param['dept_id']];  
39 - }  
40 - if(!empty($this->param['gid'])){  
41 - $map[] = ['gid', $this->param['gid']];  
42 - }  
43 - $list = $logic->getList($map,['sort' => 'desc'],['*'],$this->row); 34 + $managerModel = new Manage();
  35 + $list = $managerModel->lists($this->map,$this->page,$this->row,$this->order);
44 $this->response('success',Code::SUCCESS,$list); 36 $this->response('success',Code::SUCCESS,$list);
45 } 37 }
46 38
@@ -496,6 +496,9 @@ class ProjectController extends BaseController @@ -496,6 +496,9 @@ class ProjectController extends BaseController
496 public function getManagerList(){ 496 public function getManagerList(){
497 $hrManagerModel = new ManageHr(); 497 $hrManagerModel = new ManageHr();
498 $this->map['status'] = $hrManagerModel::STATUS_ONE; 498 $this->map['status'] = $hrManagerModel::STATUS_ONE;
  499 + if(isset($this->map['entry_position']) && is_array($this->param['entry_position'])){
  500 + $this->map['entry_position'] = ['in',$this->map['entry_position']];
  501 + }
499 $lists = $hrManagerModel->list($this->map,'id',['id','manage_id','name','entry_position','is_leader']); 502 $lists = $hrManagerModel->list($this->map,'id',['id','manage_id','name','entry_position','is_leader']);
500 $this->response('success',Code::SUCCESS,$lists); 503 $this->response('success',Code::SUCCESS,$lists);
501 } 504 }
@@ -49,6 +49,7 @@ class CNoticeController extends BaseController @@ -49,6 +49,7 @@ class CNoticeController extends BaseController
49 $this->updateMinorLanguages(); 49 $this->updateMinorLanguages();
50 } 50 }
51 $urlStr = $this->getString($this->param['type'],$this->param['page']); 51 $urlStr = $this->getString($this->param['type'],$this->param['page']);
  52 + @file_put_contents(storage_path('logs/lyh_error.log'), var_export($urlStr, true) . PHP_EOL, FILE_APPEND);
52 $this->curlGet($urlStr); 53 $this->curlGet($urlStr);
53 $this->response('success'); 54 $this->response('success');
54 } 55 }
@@ -68,17 +69,17 @@ class CNoticeController extends BaseController @@ -68,17 +69,17 @@ class CNoticeController extends BaseController
68 $routeMapModel = new RouteMap(); 69 $routeMapModel = new RouteMap();
69 $count = $routeMapModel->formatQuery(['project_id'=>$this->user['project_id']])->count(); 70 $count = $routeMapModel->formatQuery(['project_id'=>$this->user['project_id']])->count();
70 $updateNotifyModel->edit(['status' => 1], ['project_id' => $this->user['project_id'], 'status' => 0]); 71 $updateNotifyModel->edit(['status' => 1], ['project_id' => $this->user['project_id'], 'status' => 0]);
71 - $this->addProgress($count,$this->param['type']); 72 + $this->addProgress($count,$this->param['type'],$this->param['page']);
72 }elseif($this->param['page'] == UpdateNotify::PAGE_SINGLE){ 73 }elseif($this->param['page'] == UpdateNotify::PAGE_SINGLE){
73 //更新所有已修改的更新 74 //更新所有已修改的更新
74 $count = $updateNotifyModel->formatQuery(['project_id' => $this->user['project_id'], 'status' => 0])->count(); 75 $count = $updateNotifyModel->formatQuery(['project_id' => $this->user['project_id'], 'status' => 0])->count();
75 $updateNotifyModel->edit(['status' => 1], ['project_id' => $this->user['project_id'], 'status' => 0]); 76 $updateNotifyModel->edit(['status' => 1], ['project_id' => $this->user['project_id'], 'status' => 0]);
76 - $this->addProgress($count,$this->param['type']); 77 + $this->addProgress($count,$this->param['type'],$this->param['page']);
77 }else{ 78 }else{
78 //根据传递的参数更新 79 //根据传递的参数更新
79 $count = count($this->param['url']); 80 $count = count($this->param['url']);
80 $extent = json_encode(['url'=>$this->param['url']]); 81 $extent = json_encode(['url'=>$this->param['url']]);
81 - $this->addProgress($count,$this->param['type'],$extent); 82 + $this->addProgress($count,$this->param['type'],$this->param['page'],$extent);
82 } 83 }
83 }catch (\Exception $e){ 84 }catch (\Exception $e){
84 $this->response('error',Code::USER_ERROR); 85 $this->response('error',Code::USER_ERROR);
@@ -107,7 +108,7 @@ class CNoticeController extends BaseController @@ -107,7 +108,7 @@ class CNoticeController extends BaseController
107 $count = $routeMapModel->formatQuery(['project_id'=>$this->user['project_id']])->count(); 108 $count = $routeMapModel->formatQuery(['project_id'=>$this->user['project_id']])->count();
108 $updateNotifyModel->edit(['minor_languages_status' => 1], ['project_id' => $this->user['project_id'], 'minor_languages_status' => 0]); 109 $updateNotifyModel->edit(['minor_languages_status' => 1], ['project_id' => $this->user['project_id'], 'minor_languages_status' => 0]);
109 $extent = json_encode(['language'=>$this->param['language']]); 110 $extent = json_encode(['language'=>$this->param['language']]);
110 - $this->addProgress($count,$this->param['type'],$extent); 111 + $this->addProgress($count,$this->param['type'],$this->param['page'],$extent);
111 }else{ 112 }else{
112 $this->request->validate([ 113 $this->request->validate([
113 'url'=>'required', 114 'url'=>'required',
@@ -119,7 +120,7 @@ class CNoticeController extends BaseController @@ -119,7 +120,7 @@ class CNoticeController extends BaseController
119 //根据传递的参数更新 120 //根据传递的参数更新
120 $count = count($this->param['url']); 121 $count = count($this->param['url']);
121 $extent = json_encode(['url'=>$this->param['url'],'language'=>$this->param['language']]); 122 $extent = json_encode(['url'=>$this->param['url'],'language'=>$this->param['language']]);
122 - $this->addProgress($count,$this->param['type'],$extent); 123 + $this->addProgress($count,$this->param['type'],$this->param['page'],$extent);
123 } 124 }
124 }catch (\Exception $e){ 125 }catch (\Exception $e){
125 $this->response('error',Code::USER_ERROR); 126 $this->response('error',Code::USER_ERROR);
@@ -135,19 +136,22 @@ class CNoticeController extends BaseController @@ -135,19 +136,22 @@ class CNoticeController extends BaseController
135 * @time :2023/9/12 10:10 136 * @time :2023/9/12 10:10
136 */ 137 */
137 public function curlGet($url){ 138 public function curlGet($url){
138 - $curl = curl_init();  
139 - curl_setopt_array($curl, array(  
140 - CURLOPT_URL => $url,  
141 - CURLOPT_RETURNTRANSFER => true,  
142 - CURLOPT_ENCODING => '',  
143 - CURLOPT_MAXREDIRS => 10,  
144 - CURLOPT_TIMEOUT => 0,  
145 - CURLOPT_FOLLOWLOCATION => true,  
146 - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,  
147 - CURLOPT_CUSTOMREQUEST => 'GET',  
148 - ));  
149 - $response = curl_exec($curl);  
150 - curl_close($curl); 139 + $ch1 = curl_init();
  140 + $timeout = 0;
  141 + curl_setopt($ch1, CURLOPT_URL, $url);
  142 + curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
  143 + curl_setopt($ch1, CURLOPT_ENCODING, '');
  144 + curl_setopt($ch1, CURLOPT_MAXREDIRS, 10);
  145 + curl_setopt($ch1, CURLOPT_HTTPHEADER, array());
  146 + curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, $timeout);
  147 + curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, FALSE);
  148 + curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, FALSE);
  149 + curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, true);
  150 + curl_setopt($ch1, CURLOPT_CUSTOMREQUEST, 'GET');
  151 + curl_setopt($ch1, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
  152 + $access_txt = curl_exec($ch1);
  153 + curl_close($ch1);
  154 + return json_decode($access_txt, true);
151 } 155 }
152 156
153 /** 157 /**
@@ -157,12 +161,13 @@ class CNoticeController extends BaseController @@ -157,12 +161,13 @@ class CNoticeController extends BaseController
157 * @method :post 161 * @method :post
158 * @time :2023/9/6 17:01 162 * @time :2023/9/6 17:01
159 */ 163 */
160 - public function addProgress($count,$type,$extend = ''){ 164 + public function addProgress($count,$type,$page,$extend = ''){
161 $data = [ 165 $data = [
162 'total_num'=>$count, 166 'total_num'=>$count,
163 'current_num'=>0, 167 'current_num'=>0,
164 'type'=>$type, 168 'type'=>$type,
165 - 'extend'=>$extend, 169 + 'page'=>$page,
  170 + 'extends'=>$extend,
166 'project_id'=>$this->user['project_id'], 171 'project_id'=>$this->user['project_id'],
167 'created_at'=>date('Y-m-d H;i:s') 172 'created_at'=>date('Y-m-d H;i:s')
168 ]; 173 ];
@@ -297,6 +297,4 @@ class LoginController extends BaseController @@ -297,6 +297,4 @@ class LoginController extends BaseController
297 return $data; 297 return $data;
298 } 298 }
299 299
300 - public function ceshi(){  
301 - }  
302 } 300 }
@@ -79,8 +79,7 @@ class NewsController extends BaseController @@ -79,8 +79,7 @@ class NewsController extends BaseController
79 'id.required' => 'ID不能为空', 79 'id.required' => 'ID不能为空',
80 ]); 80 ]);
81 $info = $newsLogic->newsInfo(); 81 $info = $newsLogic->newsInfo();
82 - $info['url'] = $this->user['domain'] . $info['route'];  
83 - $info['image_link'] = getImageUrl($info['image']); 82 +
84 $this->response('success',Code::SUCCESS,$info); 83 $this->response('success',Code::SUCCESS,$info);
85 } 84 }
86 85
@@ -71,8 +71,8 @@ class BTemplateController extends BaseController @@ -71,8 +71,8 @@ class BTemplateController extends BaseController
71 * @time :2023/6/29 10:02 71 * @time :2023/6/29 10:02
72 */ 72 */
73 public function save(TemplateRequest $templateRequest,BTemplateLogic $BTemplateLogic){ 73 public function save(TemplateRequest $templateRequest,BTemplateLogic $BTemplateLogic){
74 - //演示项目,不允许其他号码编辑  
75 - if(($this->user['project_id'] == 1) && ($this->user['mobile'] != '15928018676' || $this->user['mobile'] != '15680871314') && ($this->param['source'] == 1)){ 74 + //演示项目,不允许其他号码编辑$this->user['mobile'] != '15928018676' ||
  75 + if(($this->user['project_id'] == 1) && ($this->user['mobile'] != '18328465854') && ($this->param['source'] == 1)){
76 $this->response('演示项目仅支持演示功能,无法更改首页',Code::USER_ERROR); 76 $this->response('演示项目仅支持演示功能,无法更改首页',Code::USER_ERROR);
77 } 77 }
78 $templateRequest->validated(); 78 $templateRequest->validated();
@@ -50,11 +50,7 @@ class ServerConfigLogic extends BaseLogic @@ -50,11 +50,7 @@ class ServerConfigLogic extends BaseLogic
50 * @time :2023/8/2 17:53 50 * @time :2023/8/2 17:53
51 */ 51 */
52 public function getServiceConfig(){ 52 public function getServiceConfig(){
53 - $encrypt = new EncryptUtils();  
54 $info = $this->model->read(['id'=>$this->param['id']]); 53 $info = $this->model->read(['id'=>$this->param['id']]);
55 - $info['user'] = $encrypt->unlock_url($info['user']);  
56 - $info['password'] = $encrypt->unlock_url($info['password']);  
57 - $info['port'] = $encrypt->unlock_url($info['port']);  
58 if($info === false){ 54 if($info === false){
59 $this->fail('当前数据不存在或者被删除'); 55 $this->fail('当前数据不存在或者被删除');
60 } 56 }
@@ -48,20 +48,19 @@ class HrLogic extends BaseLogic @@ -48,20 +48,19 @@ class HrLogic extends BaseLogic
48 * @time :2023/9/6 10:17 48 * @time :2023/9/6 10:17
49 */ 49 */
50 public function hrSave(){ 50 public function hrSave(){
51 - try {  
52 //处理参数 51 //处理参数
53 foreach ($this->model::specieField() as $v){ 52 foreach ($this->model::specieField() as $v){
54 $this->param = $this->setJson($v,$this->param); 53 $this->param = $this->setJson($v,$this->param);
55 } 54 }
56 if(isset($this->param['id']) && !empty($this->param['id'])){ 55 if(isset($this->param['id']) && !empty($this->param['id'])){
57 - $this->model->edit($this->param,['id'=>$this->param['id']]); 56 + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
58 }else{ 57 }else{
59 //添加管理员账号 58 //添加管理员账号
60 $this->param['manage_id'] = $this->addManager($this->param['mobile'],$this->param['name']); 59 $this->param['manage_id'] = $this->addManager($this->param['mobile'],$this->param['name']);
61 - $this->model->add($this->param); 60 + $rs = $this->model->add($this->param);
62 } 61 }
63 - }catch (\Exception $e){  
64 - $this->fail('error'); 62 + if($rs === false){
  63 + $this->fail('系统错误');
65 } 64 }
66 return $this->success(); 65 return $this->success();
67 } 66 }
@@ -212,7 +211,7 @@ class HrLogic extends BaseLogic @@ -212,7 +211,7 @@ class HrLogic extends BaseLogic
212 public function addManager($mobile,$name){ 211 public function addManager($mobile,$name){
213 $managerModel = new Manage(); 212 $managerModel = new Manage();
214 $info = $managerModel->read(['mobile'=>$mobile]); 213 $info = $managerModel->read(['mobile'=>$mobile]);
215 - if($info === false){ 214 + if($info !== false){
216 $this->fail('当前号码已存在'); 215 $this->fail('当前号码已存在');
217 } 216 }
218 $data = [ 217 $data = [
@@ -47,11 +47,6 @@ class ManageLogic extends BaseLogic @@ -47,11 +47,6 @@ class ManageLogic extends BaseLogic
47 } 47 }
48 48
49 49
50 - public function getCacheName($id){  
51 - $info = $this->model->read(['id'=>$id]);  
52 - return $info['name'] ?? '';  
53 - }  
54 -  
55 /** 50 /**
56 * @remark :设置排序 51 * @remark :设置排序
57 * @name :setSort 52 * @name :setSort
@@ -140,6 +140,8 @@ class NewsLogic extends BaseLogic @@ -140,6 +140,8 @@ class NewsLogic extends BaseLogic
140 */ 140 */
141 public function newsInfo(){ 141 public function newsInfo(){
142 $info = $this->model->read($this->param); 142 $info = $this->model->read($this->param);
  143 + $info['url'] = $this->user['domain'] . $info['url'];
  144 + $info['image_link'] = getImageUrl($info['image']);
143 $newsCategoryLogic = new NewsCategoryLogic(); 145 $newsCategoryLogic = new NewsCategoryLogic();
144 $info = $newsCategoryLogic->get_category_name($info); 146 $info = $newsCategoryLogic->get_category_name($info);
145 return $this->success($info); 147 return $this->success($info);
@@ -8,7 +8,9 @@ @@ -8,7 +8,9 @@
8 8
9 namespace App\Models\Devops; 9 namespace App\Models\Devops;
10 10
  11 +use App\Helper\Arr;
11 use App\Models\Base; 12 use App\Models\Base;
  13 +use App\Utils\EncryptUtils;
12 14
13 /** 15 /**
14 * 服务账户信息 16 * 服务账户信息
@@ -32,4 +34,36 @@ class ServerConfig extends Base @@ -32,4 +34,36 @@ class ServerConfig extends Base
32 34
33 const STATUS_ONE = 1; 35 const STATUS_ONE = 1;
34 36
  37 + /**
  38 + * @remark :获取数据用户名解密
  39 + * @name :getUserAttribute
  40 + * @author :lyh
  41 + * @method :post
  42 + * @time :2023/9/12 16:05
  43 + */
  44 + public function getUserAttribute($value){
  45 + return (new EncryptUtils())->unlock_url($value);
  46 + }
  47 +
  48 + /**
  49 + * @remark :密码解密
  50 + * @name :getPasswordAttribute
  51 + * @author :lyh
  52 + * @method :post
  53 + * @time :2023/9/12 16:05
  54 + */
  55 + public function getPasswordAttribute($value){
  56 + return (new EncryptUtils())->unlock_url($value);
  57 + }
  58 +
  59 + /**
  60 + * @remark :端口解密
  61 + * @name :getPasswordAttribute
  62 + * @author :lyh
  63 + * @method :post
  64 + * @time :2023/9/12 16:05
  65 + */
  66 + public function getPortAttribute($value){
  67 + return (new EncryptUtils())->unlock_url($value);
  68 + }
35 } 69 }
@@ -32,13 +32,12 @@ class ProjectServer extends BaseService @@ -32,13 +32,12 @@ class ProjectServer extends BaseService
32 if(!$project->mysqlConfig){ 32 if(!$project->mysqlConfig){
33 return false; 33 return false;
34 } 34 }
35 - $encrypt = new EncryptUtils();  
36 // 设置 database.connections.custom_mysql 配置 35 // 设置 database.connections.custom_mysql 配置
37 config(['database.connections.custom_mysql.host' => $project->mysqlConfig->host]); 36 config(['database.connections.custom_mysql.host' => $project->mysqlConfig->host]);
38 - config(['database.connections.custom_mysql.port' => (int)$encrypt->unlock_url($project->mysqlConfig->port)]); 37 + config(['database.connections.custom_mysql.port' => $project->mysqlConfig->port]);
39 config(['database.connections.custom_mysql.database' => $project->databaseName()]); 38 config(['database.connections.custom_mysql.database' => $project->databaseName()]);
40 - config(['database.connections.custom_mysql.username' => $encrypt->unlock_url($project->mysqlConfig->user)]);  
41 - config(['database.connections.custom_mysql.password' => $encrypt->unlock_url($project->mysqlConfig->password)]); 39 + config(['database.connections.custom_mysql.username' => $project->mysqlConfig->user]);
  40 + config(['database.connections.custom_mysql.password' => $project->mysqlConfig->password]);
42 // 设置 redis 配置 41 // 设置 redis 配置
43 return $project; 42 return $project;
44 } 43 }
@@ -53,13 +52,12 @@ class ProjectServer extends BaseService @@ -53,13 +52,12 @@ class ProjectServer extends BaseService
53 */ 52 */
54 public static function createDatabase($project) 53 public static function createDatabase($project)
55 { 54 {
56 - $encrypt = new EncryptUtils();  
57 $conn = new \mysqli( 55 $conn = new \mysqli(
58 $project->mysqlConfig->host, 56 $project->mysqlConfig->host,
59 - $encrypt->unlock_url($project->mysqlConfig->user),  
60 - $encrypt->unlock_url($project->mysqlConfig->password), 57 + $project->mysqlConfig->user,
  58 + $project->mysqlConfig->password,
61 '', 59 '',
62 - (int)$encrypt->unlock_url($project->mysqlConfig->port) 60 + $project->mysqlConfig->port
63 ); 61 );
64 $conn->query("CREATE DATABASE IF NOT EXISTS {$project->databaseName()}"); 62 $conn->query("CREATE DATABASE IF NOT EXISTS {$project->databaseName()}");
65 return true; 63 return true;