作者 lyh

gx

  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :InquiryFieldController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/8/13 10:45
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\Inquiry;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Bside\BaseController;
  14 +use App\Models\Inquiry\InquiryField;
  15 +
  16 +/**
  17 + * @remark :詢盤字段映射
  18 + * @name :InquiryFieldController
  19 + * @author :lyh
  20 + * @method :post
  21 + * @time :2024/8/13 10:45
  22 + */
  23 +class InquiryFieldController extends BaseController
  24 +{
  25 + /**
  26 + * @remark :詢盤字段映射
  27 + * @name :lists
  28 + * @author :lyh
  29 + * @method :post
  30 + * @time :2024/8/13 10:59
  31 + */
  32 + public function lists(){
  33 + $inquiryModel = new InquiryField();
  34 + $lists = $inquiryModel->list($this->map);
  35 + $this->response('success',Code::SUCCESS,$lists);
  36 + }
  37 +
  38 + /**
  39 + * @remark :保存數據
  40 + * @name :save
  41 + * @author :lyh
  42 + * @method :post
  43 + * @time :2024/8/13 11:13
  44 + */
  45 + public function save(){
  46 + $this->request->validate([
  47 + 'data'=>'required',
  48 + ],[
  49 + 'data.required' => 'data不能为空',
  50 + ]);
  51 + $inquiryModel = new InquiryField();
  52 + foreach ($this->param['data'] as $v){
  53 + if(isset($v['id']) && !empty($v['id'])){
  54 + $inquiryModel->edit(['en_name'=>$v['en_name']],['id'=>$v['id']]);
  55 + }else{
  56 + $inquiryModel->addReturnId(['name'=>$v['name'], 'en_name'=>$v['en_name']]);
  57 + }
  58 + }
  59 + $this->response('success');
  60 + }
  61 +
  62 + /**
  63 + * @remark :刪除數據
  64 + * @name :del
  65 + * @author :lyh
  66 + * @method :post
  67 + * @time :2024/8/13 11:14
  68 + */
  69 + public function del(){
  70 +
  71 + $this->request->validate([
  72 + 'id'=>'required',
  73 + ],[
  74 + 'id.required' => 'name不能为空',
  75 + ]);
  76 + $inquiryModel = new InquiryField();
  77 + $inquiryModel->del(['id'=>['in',$this->param['id']]]);
  78 + $this->response('success');
  79 + }
  80 +}