作者 赵彬吉

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

... ... @@ -72,14 +72,13 @@ class DevopsTask extends Command
continue;
}
//DB类是单例模式,生命周期内修改配置不会生效
$encrypt = new EncryptUtils();
try {
$conn = new \mysqli(
$project->mysqlConfig->host,
$encrypt->unlock_url($project->mysqlConfig->user),
$encrypt->unlock_url($project->mysqlConfig->password),
$project->mysqlConfig->user,
$project->mysqlConfig->password,
$project->databaseName(),
$encrypt->unlock_url($project->mysqlConfig->port),
$project->mysqlConfig->port,
);
}catch (\Exception $e){
$log->remark = mb_substr('数据库连接失败:' . $e->getMessage(), 0, 500);
... ...
... ... @@ -6,6 +6,7 @@ use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Manage\ManageLogic;
use App\Http\Requests\Aside\Manage\ManageRequest;
use App\Models\Manage\Manage;
use App\Models\Manage\MenuSpecial;
use App\Models\User\ProjectRole;
use App\Rules\Ids;
... ... @@ -28,19 +29,10 @@ class ManageController extends BaseController
* @method :post
* @time :2023/8/28 10:04
*/
public function list(Request $request, ManageLogic $logic)
public function list()
{
$map = [];
if(!empty($this->param['search'])){
$map[] = ['name|mobile', 'like', "%{$this->param['search']}%"];
}
if(!empty($this->param['dept_id'])){
$map[] = ['dept_id', $this->param['dept_id']];
}
if(!empty($this->param['gid'])){
$map[] = ['gid', $this->param['gid']];
}
$list = $logic->getList($map,['sort' => 'desc'],['*'],$this->row);
$managerModel = new Manage();
$list = $managerModel->lists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$list);
}
... ...
... ... @@ -496,6 +496,9 @@ class ProjectController extends BaseController
public function getManagerList(){
$hrManagerModel = new ManageHr();
$this->map['status'] = $hrManagerModel::STATUS_ONE;
if(isset($this->map['entry_position']) && is_array($this->param['entry_position'])){
$this->map['entry_position'] = ['in',$this->map['entry_position']];
}
$lists = $hrManagerModel->list($this->map,'id',['id','manage_id','name','entry_position','is_leader']);
$this->response('success',Code::SUCCESS,$lists);
}
... ...
... ... @@ -49,6 +49,7 @@ class CNoticeController extends BaseController
$this->updateMinorLanguages();
}
$urlStr = $this->getString($this->param['type'],$this->param['page']);
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($urlStr, true) . PHP_EOL, FILE_APPEND);
$this->curlGet($urlStr);
$this->response('success');
}
... ... @@ -68,17 +69,17 @@ class CNoticeController extends BaseController
$routeMapModel = new RouteMap();
$count = $routeMapModel->formatQuery(['project_id'=>$this->user['project_id']])->count();
$updateNotifyModel->edit(['status' => 1], ['project_id' => $this->user['project_id'], 'status' => 0]);
$this->addProgress($count,$this->param['type']);
$this->addProgress($count,$this->param['type'],$this->param['page']);
}elseif($this->param['page'] == UpdateNotify::PAGE_SINGLE){
//更新所有已修改的更新
$count = $updateNotifyModel->formatQuery(['project_id' => $this->user['project_id'], 'status' => 0])->count();
$updateNotifyModel->edit(['status' => 1], ['project_id' => $this->user['project_id'], 'status' => 0]);
$this->addProgress($count,$this->param['type']);
$this->addProgress($count,$this->param['type'],$this->param['page']);
}else{
//根据传递的参数更新
$count = count($this->param['url']);
$extent = json_encode(['url'=>$this->param['url']]);
$this->addProgress($count,$this->param['type'],$extent);
$this->addProgress($count,$this->param['type'],$this->param['page'],$extent);
}
}catch (\Exception $e){
$this->response('error',Code::USER_ERROR);
... ... @@ -107,7 +108,7 @@ class CNoticeController extends BaseController
$count = $routeMapModel->formatQuery(['project_id'=>$this->user['project_id']])->count();
$updateNotifyModel->edit(['minor_languages_status' => 1], ['project_id' => $this->user['project_id'], 'minor_languages_status' => 0]);
$extent = json_encode(['language'=>$this->param['language']]);
$this->addProgress($count,$this->param['type'],$extent);
$this->addProgress($count,$this->param['type'],$this->param['page'],$extent);
}else{
$this->request->validate([
'url'=>'required',
... ... @@ -119,7 +120,7 @@ class CNoticeController extends BaseController
//根据传递的参数更新
$count = count($this->param['url']);
$extent = json_encode(['url'=>$this->param['url'],'language'=>$this->param['language']]);
$this->addProgress($count,$this->param['type'],$extent);
$this->addProgress($count,$this->param['type'],$this->param['page'],$extent);
}
}catch (\Exception $e){
$this->response('error',Code::USER_ERROR);
... ... @@ -135,19 +136,22 @@ class CNoticeController extends BaseController
* @time :2023/9/12 10:10
*/
public function curlGet($url){
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
));
$response = curl_exec($curl);
curl_close($curl);
$ch1 = curl_init();
$timeout = 0;
curl_setopt($ch1, CURLOPT_URL, $url);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch1, CURLOPT_ENCODING, '');
curl_setopt($ch1, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch1, CURLOPT_HTTPHEADER, array());
curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch1, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch1, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
$access_txt = curl_exec($ch1);
curl_close($ch1);
return json_decode($access_txt, true);
}
/**
... ... @@ -157,12 +161,13 @@ class CNoticeController extends BaseController
* @method :post
* @time :2023/9/6 17:01
*/
public function addProgress($count,$type,$extend = ''){
public function addProgress($count,$type,$page,$extend = ''){
$data = [
'total_num'=>$count,
'current_num'=>0,
'type'=>$type,
'extend'=>$extend,
'page'=>$page,
'extends'=>$extend,
'project_id'=>$this->user['project_id'],
'created_at'=>date('Y-m-d H;i:s')
];
... ...
... ... @@ -297,6 +297,4 @@ class LoginController extends BaseController
return $data;
}
public function ceshi(){
}
}
... ...
... ... @@ -79,8 +79,7 @@ class NewsController extends BaseController
'id.required' => 'ID不能为空',
]);
$info = $newsLogic->newsInfo();
$info['url'] = $this->user['domain'] . $info['route'];
$info['image_link'] = getImageUrl($info['image']);
$this->response('success',Code::SUCCESS,$info);
}
... ...
... ... @@ -71,8 +71,8 @@ class BTemplateController extends BaseController
* @time :2023/6/29 10:02
*/
public function save(TemplateRequest $templateRequest,BTemplateLogic $BTemplateLogic){
//演示项目,不允许其他号码编辑
if(($this->user['project_id'] == 1) && ($this->user['mobile'] != '15928018676' || $this->user['mobile'] != '15680871314') && ($this->param['source'] == 1)){
//演示项目,不允许其他号码编辑$this->user['mobile'] != '15928018676' ||
if(($this->user['project_id'] == 1) && ($this->user['mobile'] != '18328465854') && ($this->param['source'] == 1)){
$this->response('演示项目仅支持演示功能,无法更改首页',Code::USER_ERROR);
}
$templateRequest->validated();
... ...
... ... @@ -50,11 +50,7 @@ class ServerConfigLogic extends BaseLogic
* @time :2023/8/2 17:53
*/
public function getServiceConfig(){
$encrypt = new EncryptUtils();
$info = $this->model->read(['id'=>$this->param['id']]);
$info['user'] = $encrypt->unlock_url($info['user']);
$info['password'] = $encrypt->unlock_url($info['password']);
$info['port'] = $encrypt->unlock_url($info['port']);
if($info === false){
$this->fail('当前数据不存在或者被删除');
}
... ...
... ... @@ -48,20 +48,19 @@ class HrLogic extends BaseLogic
* @time :2023/9/6 10:17
*/
public function hrSave(){
try {
//处理参数
foreach ($this->model::specieField() as $v){
$this->param = $this->setJson($v,$this->param);
}
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->model->edit($this->param,['id'=>$this->param['id']]);
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
//添加管理员账号
$this->param['manage_id'] = $this->addManager($this->param['mobile'],$this->param['name']);
$this->model->add($this->param);
$rs = $this->model->add($this->param);
}
}catch (\Exception $e){
$this->fail('error');
if($rs === false){
$this->fail('系统错误');
}
return $this->success();
}
... ... @@ -212,7 +211,7 @@ class HrLogic extends BaseLogic
public function addManager($mobile,$name){
$managerModel = new Manage();
$info = $managerModel->read(['mobile'=>$mobile]);
if($info === false){
if($info !== false){
$this->fail('当前号码已存在');
}
$data = [
... ...
... ... @@ -47,11 +47,6 @@ class ManageLogic extends BaseLogic
}
public function getCacheName($id){
$info = $this->model->read(['id'=>$id]);
return $info['name'] ?? '';
}
/**
* @remark :设置排序
* @name :setSort
... ...
... ... @@ -140,6 +140,8 @@ class NewsLogic extends BaseLogic
*/
public function newsInfo(){
$info = $this->model->read($this->param);
$info['url'] = $this->user['domain'] . $info['url'];
$info['image_link'] = getImageUrl($info['image']);
$newsCategoryLogic = new NewsCategoryLogic();
$info = $newsCategoryLogic->get_category_name($info);
return $this->success($info);
... ...
... ... @@ -8,7 +8,9 @@
namespace App\Models\Devops;
use App\Helper\Arr;
use App\Models\Base;
use App\Utils\EncryptUtils;
/**
* 服务账户信息
... ... @@ -32,4 +34,36 @@ class ServerConfig extends Base
const STATUS_ONE = 1;
/**
* @remark :获取数据用户名解密
* @name :getUserAttribute
* @author :lyh
* @method :post
* @time :2023/9/12 16:05
*/
public function getUserAttribute($value){
return (new EncryptUtils())->unlock_url($value);
}
/**
* @remark :密码解密
* @name :getPasswordAttribute
* @author :lyh
* @method :post
* @time :2023/9/12 16:05
*/
public function getPasswordAttribute($value){
return (new EncryptUtils())->unlock_url($value);
}
/**
* @remark :端口解密
* @name :getPasswordAttribute
* @author :lyh
* @method :post
* @time :2023/9/12 16:05
*/
public function getPortAttribute($value){
return (new EncryptUtils())->unlock_url($value);
}
}
... ...
... ... @@ -32,13 +32,12 @@ class ProjectServer extends BaseService
if(!$project->mysqlConfig){
return false;
}
$encrypt = new EncryptUtils();
// 设置 database.connections.custom_mysql 配置
config(['database.connections.custom_mysql.host' => $project->mysqlConfig->host]);
config(['database.connections.custom_mysql.port' => (int)$encrypt->unlock_url($project->mysqlConfig->port)]);
config(['database.connections.custom_mysql.port' => $project->mysqlConfig->port]);
config(['database.connections.custom_mysql.database' => $project->databaseName()]);
config(['database.connections.custom_mysql.username' => $encrypt->unlock_url($project->mysqlConfig->user)]);
config(['database.connections.custom_mysql.password' => $encrypt->unlock_url($project->mysqlConfig->password)]);
config(['database.connections.custom_mysql.username' => $project->mysqlConfig->user]);
config(['database.connections.custom_mysql.password' => $project->mysqlConfig->password]);
// 设置 redis 配置
return $project;
}
... ... @@ -53,13 +52,12 @@ class ProjectServer extends BaseService
*/
public static function createDatabase($project)
{
$encrypt = new EncryptUtils();
$conn = new \mysqli(
$project->mysqlConfig->host,
$encrypt->unlock_url($project->mysqlConfig->user),
$encrypt->unlock_url($project->mysqlConfig->password),
$project->mysqlConfig->user,
$project->mysqlConfig->password,
'',
(int)$encrypt->unlock_url($project->mysqlConfig->port)
$project->mysqlConfig->port
);
$conn->query("CREATE DATABASE IF NOT EXISTS {$project->databaseName()}");
return true;
... ...