ServiceLogic.php 1.8 KB
<?php

namespace App\Http\Logic\Aside\Service;

use App\Http\Logic\Aside\BaseLogic;
use App\Models\Service\Service;

class ServiceLogic extends BaseLogic
{
    public function __construct()
    {
        parent::__construct();
        $this->model = new Service();
        $this->param = $this->requestAll;
    }

    /**
     * @remark :企业服务列表
     * @name   :serviceLists
     * @author :lyh
     * @method :post
     * @time   :2023/6/25 14:32
     */
    public function serviceLists($map){
        $map['type'] = 1;
        $lists = $this->model->list($map,'created_at');
        foreach ($lists as $k => $v){
            switch ($v['key']){
                case 'images':
                    $arr = explode(',',$v['values']);
                    foreach ($arr as $k1 => $v1){
                        $v['images_link'][$k1] = getImageUrl($v1);
                    }
                    break;
                case 'android':
                    $v['android_link'] = getImageUrl($v['values']);
                    break;
                case 'official_account':
                    $v['android_link'] = getImageUrl($v['values']);
                    break;
                case 'ios':
                    $v['ios_link'] = getImageUrl($v['values']);
                    break;
            }
            $lists[$k] = $v;
        }
        return $this->success($lists);
    }


    /**
     * @remark :新增或编辑
     * @name   :serviceSave
     * @author :lyh
     * @method :post
     * @time   :2023/6/25 13:45
     */
    public function serviceSave(){
        //删除以前的配置
        try {
            $this->model->del(['type'=>1]);
            $this->model->insert($this->param['data']);
        }catch (\Exception $e){
            $this->fail('error');
        }
        return $this->success();
    }


}