作者 lyh

gx

@@ -52,6 +52,24 @@ class ServerConfigController extends BaseController @@ -52,6 +52,24 @@ class ServerConfigController extends BaseController
52 } 52 }
53 53
54 /** 54 /**
  55 + * @remark :删除配置
  56 + * @name :del
  57 + * @author :lyh
  58 + * @method :post
  59 + * @time :2023/8/2 15:41
  60 + */
  61 + public function del(ServerConfigLogic $logic){
  62 + $this->request->validate([
  63 + 'id'=>'required'
  64 + ],[
  65 + 'id.required' => 'ID不能为空'
  66 + ]);
  67 + $logic->delServiceConfig();
  68 + return $this->response('success');
  69 + }
  70 +
  71 +
  72 + /**
55 * 更新表结构 73 * 更新表结构
56 * @param ServerConfigLogic $logic 74 * @param ServerConfigLogic $logic
57 * @author zbj 75 * @author zbj
@@ -82,26 +100,7 @@ class ServerConfigController extends BaseController @@ -82,26 +100,7 @@ class ServerConfigController extends BaseController
82 $data = $logic->updateAllTable($this->param); 100 $data = $logic->updateAllTable($this->param);
83 break; 101 break;
84 } 102 }
85 -  
86 return $this->success($data); 103 return $this->success($data);
87 } 104 }
88 105
89 - /**  
90 - * 更新代码  
91 - * @param ServerConfigLogic $logic  
92 - * @author zbj  
93 - * @date 2023/4/24  
94 - */  
95 - public function updateCode(){  
96 - //todo  
97 - //C端  
98 -// $process = new Process(['git', 'pull']);  
99 -// $process->run();  
100 -// dump($process->getExitCodeText());  
101 -// dump($process->getExitCode());  
102 -// dump($process->getErrorOutput());  
103 -// $output = explode(PHP_EOL, $process->getOutput());  
104 -// dump($output);  
105 -// exit;  
106 - }  
107 } 106 }
@@ -24,7 +24,7 @@ class MenuController extends BaseController @@ -24,7 +24,7 @@ class MenuController extends BaseController
24 24
25 public function list(Request $request, MenuLogic $logic) 25 public function list(Request $request, MenuLogic $logic)
26 { 26 {
27 - $map = []; 27 + $map = ['type'=>1];
28 $sort = ['id' => 'desc']; 28 $sort = ['id' => 'desc'];
29 $list = $logic->getList($map, $sort, ['id', 'pid', 'title', 'icon', 'type', 'menu_path'],0); 29 $list = $logic->getList($map, $sort, ['id', 'pid', 'title', 'icon', 'type', 'menu_path'],0);
30 return $this->success(Arr::listToTree($list)); 30 return $this->success(Arr::listToTree($list));
@@ -36,6 +36,12 @@ class ServerConfigLogic extends BaseLogic @@ -36,6 +36,12 @@ class ServerConfigLogic extends BaseLogic
36 */ 36 */
37 public function serviceConfigList($map,$page,$row,$order = 'id',$filed = ['*']){ 37 public function serviceConfigList($map,$page,$row,$order = 'id',$filed = ['*']){
38 $lists = $this->model->lists($map,$page,$row,$order,$filed); 38 $lists = $this->model->lists($map,$page,$row,$order,$filed);
  39 + if(!empty($lists['list'])){
  40 + foreach ($lists['list'] as $k => $v){
  41 + $v['project_title'] = (new Project())->read(['id'=>$v['project_id']])['title'];
  42 + $lists['list'][$k] = $v;
  43 + }
  44 + }
39 return $this->success($lists); 45 return $this->success($lists);
40 } 46 }
41 47
@@ -59,7 +65,6 @@ class ServerConfigLogic extends BaseLogic @@ -59,7 +65,6 @@ class ServerConfigLogic extends BaseLogic
59 $data['mysql_id'] = $res['id']; 65 $data['mysql_id'] = $res['id'];
60 } 66 }
61 $project_logic->save($data); 67 $project_logic->save($data);
62 -  
63 //初始化数据库 68 //初始化数据库
64 if ($param['type'] == ServerConfig::TYPE_MYSQL) { 69 if ($param['type'] == ServerConfig::TYPE_MYSQL) {
65 //切换数据库配置 70 //切换数据库配置
@@ -69,7 +74,6 @@ class ServerConfigLogic extends BaseLogic @@ -69,7 +74,6 @@ class ServerConfigLogic extends BaseLogic
69 //创建表 74 //创建表
70 ProjectServer::initTable($project); 75 ProjectServer::initTable($project);
71 } 76 }
72 -  
73 DB::commit(); 77 DB::commit();
74 } catch (\Exception $e) { 78 } catch (\Exception $e) {
75 DB::rollBack(); 79 DB::rollBack();
@@ -79,6 +83,29 @@ class ServerConfigLogic extends BaseLogic @@ -79,6 +83,29 @@ class ServerConfigLogic extends BaseLogic
79 return $this->success(); 83 return $this->success();
80 } 84 }
81 85
  86 + /**
  87 + * @remark :删除记录
  88 + * @name :delServiceConfig
  89 + * @author :lyh
  90 + * @method :post
  91 + * @time :2023/8/2 15:43
  92 + */
  93 + public function delServiceConfig(){
  94 + $info = $this->model->read(['id'=>$this->requestAll['id']]);
  95 + if($info === false){
  96 + $this->fail('当前数据不存在或已被删除');
  97 + }
  98 + $rs = $this->model->del(['id'=>$this->requestAll['id']]);
  99 + if($rs === false){
  100 + $this->fail('删除失败');
  101 + }
  102 + //TODO::上线放开
  103 +// if($info['type'] == $this->model::TYPE_MYSQL){
  104 +// $sql = 'DROP DATABASE '.$info['title'];
  105 +// DB::connection('custom_mysql')->statement($sql);
  106 +// }
  107 + return $this->success();
  108 + }
82 109
83 /** 110 /**
84 * 更新指定项目 数据库 111 * 更新指定项目 数据库