123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- /*
- * @Descripttion:
- * @version: 1.0.0
- * @Author: likang
- * @Date: 2022-07-26 16:16:11
- * @LastEditors: likang
- * @LastEditTime: 2022-07-29 16:00:37
- */
- namespace catchAdmin\system\controller;
- use catchAdmin\api\Directive;
- use catchAdmin\hydraulic\controller\HydEquipment;
- use catchAdmin\hydraulic\model\HydEquipment as ModelHydEquipment;
- use catcher\base\CatchRequest as Request;
- use catcher\CatchResponse;
- use catcher\base\CatchController;
- use catchAdmin\system\model\Lssue as lssueModel;
- use catcher\CatchAdmin;
- class Lssue extends CatchController
- {
- protected $lssueModel;
- public function __construct(LssueModel $lssueModel)
- {
- $this->lssueModel = $lssueModel;
- }
- /**
- * 列表
- * @time 2022年07月26日 16:16
- * @param Request $request
- */
- public function index(Request $request): \think\Response
- {
- return CatchResponse::paginate($this->lssueModel->getList());
- }
- /**
- * 保存信息
- * @time 2022年07月26日 16:16
- * @param Request $request
- */
- public function save(Request $request): \think\Response
- {
- $data = $request->post();
- $this->lssueModel->storeBy($request->post());
- $list = ModelHydEquipment::alias('e')->leftJoin('hydraulic h', 'e.id = h.eq_id')
- ->where('e.id', 'in', $data['equ_ids'])->column('h.imei');
- if ($data['directive'] == 'File') {
- $content = [
- 'file_name' => $data['file_name']
- ];
- } else if ($data['directive'] == 'Config') {
- $content = json_decode($data['file_name'], true);
- if (json_last_error() != 0) {
- return CatchResponse::fail(json_last_error_msg());
- }
- } else if ($data['directive'] = 'SysCMD') {
- $content = [
- 'cmd_content' => trim($data['file_name'])
- ];
- }
- Directive::Issued($data['type'], $content, $data['directive'], $list);
- // $this->lssueModel->IssueAll($content);
- return CatchResponse::success();
- }
- /**
- * 读取
- * @time 2022年07月26日 16:16
- * @param $id
- */
- public function read($id): \think\Response
- {
- return CatchResponse::success($this->lssueModel->findBy($id));
- }
- /**
- * 更新
- * @time 2022年07月26日 16:16
- * @param Request $request
- * @param $id
- */
- public function update(Request $request, $id): \think\Response
- {
- return CatchResponse::success($this->lssueModel->updateBy($id, $request->post()));
- }
- /**
- * 删除
- * @time 2022年07月26日 16:16
- * @param $id
- */
- public function delete($id): \think\Response
- {
- return CatchResponse::success($this->lssueModel->deleteBy($id, true));
- }
- }
|