likang 2 年之前
父節點
當前提交
095a01c349

+ 23 - 1
catch/fan/model/get/FanGet.php

@@ -11,7 +11,29 @@ trait FanGet
         $wind_id = $this->wind_id;
         $wind_name =  Db::name('wind')->where('id',$wind_id)->value('name');
         return $wind_name;
-    }    
+    }
+    public function getImgAttr()
+    {
+        $data = $this->getData('img');
+        if(empty($data))
+        {
+            $data = [];
+        }
+        else
+        {
+            $data = json_decode($data,true);
+        }
+        return $data;
+
+    }
+    public function setImgAttr($value)
+    {
+        
+       return json_encode($value);
+    }
+
+
+       
 
 
 }

+ 0 - 1
catch/system/controller/Upload.php

@@ -41,7 +41,6 @@ class Upload extends CatchController
     public function image(CatchRequest $request, CatchUpload $upload): \think\response\Json
     {
         $images = $request->file();
-        // var_dump($images);
         if (!$images) {
             throw new FailedException('请选择图片上传');
         }

+ 23 - 0
catch/worklocation/WorklocationService.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\worklocation;
+
+use catcher\ModuleService;
+
+class WorklocationService extends ModuleService
+{
+    public function loadRouteFrom()
+    {
+        // TODO: Implement loadRouteFrom() method.
+        return __DIR__ . DIRECTORY_SEPARATOR . 'route.php';
+    }
+}

+ 69 - 0
catch/worklocation/controller/WorkLocation.php

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

+ 47 - 0
catch/worklocation/database/migrations/20220519133643_worklocation.php

@@ -0,0 +1,47 @@
+<?php
+
+use think\migration\Migrator;
+use think\migration\db\Column;
+use Phinx\Db\Adapter\MysqlAdapter;
+
+class Worklocation 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('worklocation', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '工作位置' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
+        $table->addColumn('wind_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '风场编号',])
+			->addColumn('fan_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '风机编号',])
+			->addColumn('work_local', 'string', ['limit' => 250,'null' => true,'signed' => true,'comment' => '工作位置',])
+			->addColumn('parts', 'string', ['limit' => 250,'null' => true,'signed' => true,'comment' => '所属部件',])
+			->addColumn('bolt_style', 'string', ['limit' => 255,'null' => true,'signed' => true,'comment' => '螺栓样式',])
+			->addColumn('boit_type', 'string', ['limit' => 255,'null' => true,'signed' => true,'comment' => '螺栓型号',])
+			->addColumn('number', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '编号',])
+			->addColumn('info', '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();
+    }
+}

+ 39 - 0
catch/worklocation/model/WorkLocation.php

@@ -0,0 +1,39 @@
+<?php
+
+namespace catchAdmin\worklocation\model;
+
+use catcher\base\CatchModel as Model;
+
+class WorkLocation extends Model
+{
+    // 表名
+    public $name = 'worklocation';
+    // 数据库字段映射
+    public $field = array(
+        'id',
+        // 风场编号
+        'wind_id',
+        // 风机编号
+        'fan_id',
+        // 工作位置
+        'work_local',
+        // 所属部件
+        'parts',
+        // 螺栓样式
+        'bolt_style',
+        // 螺栓型号
+        'boit_type',
+        // 编号
+        'number',
+        // 备注说明
+        'info',
+        // 创建人ID
+        'creator_id',
+        // 创建时间
+        'created_at',
+        // 更新时间
+        'updated_at',
+        // 软删除
+        'deleted_at',
+    );
+}

+ 15 - 0
catch/worklocation/module.json

@@ -0,0 +1,15 @@
+{
+    "name": "worklocation",
+    "alias": "worklocation",
+    "description": "工作位置",
+    "version": "1.0.0",
+    "keywords": [""],
+    "order": 0,
+    "services": [
+        "\\catchAdmin\\worklocation\\WorklocationService"
+    ],
+    "aliases": {},
+    "files": [],
+    "requires": [],
+    "enable": true
+}

+ 16 - 0
catch/worklocation/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){
+	// workLocation路由
+	$router->resource('workLocation', '\catchAdmin\worklocation\controller\WorkLocation');
+})->middleware('auth');