weich 2 년 전
부모
커밋
18941fb2c2
6개의 변경된 파일206개의 추가작업 그리고 0개의 파일을 삭제
  1. 23 0
      catch/wind/WindService.php
  2. 69 0
      catch/wind/controller/Wind.php
  3. 46 0
      catch/wind/database/migrations/20220427104913_wind.php
  4. 37 0
      catch/wind/model/Wind.php
  5. 15 0
      catch/wind/module.json
  6. 16 0
      catch/wind/route.php

+ 23 - 0
catch/wind/WindService.php

@@ -0,0 +1,23 @@
+<?php
+// +----------------------------------------------------------------------
+// | CatchAdmin [Just Like ~ ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~{$year} http://catchadmin.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
+// +----------------------------------------------------------------------
+// | Author: JaguarJack [ njphper@gmail.com ]
+// +----------------------------------------------------------------------
+
+namespace catchAdmin\wind;
+
+use catcher\ModuleService;
+
+class WindService extends ModuleService
+{
+    public function loadRouteFrom()
+    {
+        // TODO: Implement loadRouteFrom() method.
+        return __DIR__ . DIRECTORY_SEPARATOR . 'route.php';
+    }
+}

+ 69 - 0
catch/wind/controller/Wind.php

@@ -0,0 +1,69 @@
+<?php
+
+namespace catchAdmin\wind\controller;
+
+use catcher\base\CatchRequest as Request;
+use catcher\CatchResponse;
+use catcher\base\CatchController;
+use catchAdmin\wind\model\Wind as windModel;
+
+class Wind extends CatchController
+{
+    protected $windModel;
+    
+    public function __construct(WindModel $windModel)
+    {
+        $this->windModel = $windModel;
+    }
+    
+    /**
+     * 列表
+     * @time 2022年04月27日 10:49
+     * @param Request $request 
+     */
+    public function index(Request $request) : \think\Response
+    {
+        return CatchResponse::paginate($this->windModel->getList());
+    }
+    
+    /**
+     * 保存信息
+     * @time 2022年04月27日 10:49
+     * @param Request $request 
+     */
+    public function save(Request $request) : \think\Response
+    {
+        return CatchResponse::success($this->windModel->storeBy($request->post()));
+    }
+    
+    /**
+     * 读取
+     * @time 2022年04月27日 10:49
+     * @param $id 
+     */
+    public function read($id) : \think\Response
+    {
+        return CatchResponse::success($this->windModel->findBy($id));
+    }
+    
+    /**
+     * 更新
+     * @time 2022年04月27日 10:49
+     * @param Request $request 
+     * @param $id
+     */
+    public function update(Request $request, $id) : \think\Response
+    {
+        return CatchResponse::success($this->windModel->updateBy($id, $request->post()));
+    }
+    
+    /**
+     * 删除
+     * @time 2022年04月27日 10:49
+     * @param $id
+     */
+    public function delete($id) : \think\Response
+    {
+        return CatchResponse::success($this->windModel->deleteBy($id));
+    }
+}

+ 46 - 0
catch/wind/database/migrations/20220427104913_wind.php

@@ -0,0 +1,46 @@
+<?php
+
+use think\migration\Migrator;
+use think\migration\db\Column;
+use Phinx\Db\Adapter\MysqlAdapter;
+
+class Wind extends Migrator
+{
+    /**
+     * Change Method.
+     *
+     * Write your reversible migrations using this method.
+     *
+     * More information on writing migrations is available here:
+     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
+     *
+     * The following commands can be used in this method and Phinx will
+     * automatically reverse them when rolling back:
+     *
+     *    createTable
+     *    renameTable
+     *    addColumn
+     *    renameColumn
+     *    addIndex
+     *    addForeignKey
+     *
+     * Remember to call "create()" or "update()" and NOT "save()" when working
+     * with the Table class.
+     */
+    public function change()
+    {
+        $table = $this->table('wind', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
+        $table->addColumn('name', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '风场名称',])
+			->addColumn('number', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '编号',])
+			->addColumn('department_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '所属部门',])
+			->addColumn('address', 'string', ['limit' => 100,'null' => true,'signed' => true,'comment' => '风场地址',])
+			->addColumn('maintenance_count', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '维保设备数量',])
+			->addColumn('pump_count', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '泵设备数量',])
+			->addColumn('remark', 'string', ['limit' => 100,'null' => true,'signed' => true,'comment' => '备注',])
+			->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建人ID',])
+			->addColumn('created_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建时间',])
+			->addColumn('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '更新时间',])
+			->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '软删除',])
+            ->create();
+    }
+}

+ 37 - 0
catch/wind/model/Wind.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace catchAdmin\wind\model;
+
+use catcher\base\CatchModel as Model;
+
+class Wind extends Model
+{
+    // 表名
+    public $name = 'wind';
+    // 数据库字段映射
+    public $field = array(
+        'id',
+        // 风场名称
+        'name',
+        // 编号
+        'number',
+        // 所属部门
+        'department_id',
+        // 风场地址
+        'address',
+        // 维保设备数量
+        'maintenance_count',
+        // 泵设备数量
+        'pump_count',
+        // 备注
+        'remark',
+        // 创建人ID
+        'creator_id',
+        // 创建时间
+        'created_at',
+        // 更新时间
+        'updated_at',
+        // 软删除
+        'deleted_at',
+    );
+}

+ 15 - 0
catch/wind/module.json

@@ -0,0 +1,15 @@
+{
+    "name": "wind",
+    "alias": "wind",
+    "description": "风场风机管理",
+    "version": "1.0.0",
+    "keywords": [""],
+    "order": 0,
+    "services": [
+        "\\catchAdmin\\wind\\WindService"
+    ],
+    "aliases": {},
+    "files": [],
+    "requires": [],
+    "enable": true
+}

+ 16 - 0
catch/wind/route.php

@@ -0,0 +1,16 @@
+<?php
+// +----------------------------------------------------------------------
+// | CatchAdmin [Just Like ~ ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~{$year} http://catchadmin.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
+// +----------------------------------------------------------------------
+// | Author: JaguarJack [ njphper@gmail.com ]
+// +----------------------------------------------------------------------
+
+// you should use `$router`
+$router->group(function () use ($router){
+	// wind路由
+	$router->resource('wind', '\catchAdmin\wind\controller\wind');
+})->middleware('auth');