| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- // +----------------------------------------------------------------------
- // | Laravel框架 [ Laravel ]
- // +----------------------------------------------------------------------
- // | 版权所有 2017~2021 Laravel研发中心
- // +----------------------------------------------------------------------
- // | 官方网站: http://www.laravel.cn
- // +----------------------------------------------------------------------
- // | Author: wesmiler <12345678@qq.com>
- // +----------------------------------------------------------------------
- namespace App\Services;
- use App\Models\ItemModel;
- /**
- * 站点管理-服务类
- * @author wesmiler
- * @since 2020/11/11
- * Class ItemService
- * @package App\Services
- */
- class ItemService extends BaseService
- {
- /**
- * 构造函数
- * @author wesmiler
- * @since 2020/11/11
- * ItemService constructor.
- */
- public function __construct()
- {
- $this->model = new ItemModel();
- }
- /**
- * 获取站点列表
- * @return array
- * @since 2020/11/11
- * @author wesmiler
- */
- public function getList()
- {
- $param = request()->all();
- // 查询条件
- $map = [];
- // 站点类型
- $type = getter($param, "type", 0);
- if ($type) {
- $map[] = ["type", '=', $type];
- }
- return parent::getList($map); // TODO: Change the autogenerated stub
- }
- /**
- * 添加或编辑
- * @return array
- * @since 2020/11/11
- * @author wesmiler
- */
- public function edit()
- {
- $data = request()->all();
- // 图片处理
- $image = trim($data['image']);
- if (!$data['id'] && !$image) {
- return message('请上传站点图片', false);
- }
- if (strpos($image, "temp")) {
- $data['image'] = save_image($image, 'item');
- } else {
- $data['image'] = str_replace(IMG_URL, "", $data['image']);
- }
- return parent::edit($data); // TODO: Change the autogenerated stub
- }
- /**
- * 获取站点列表
- * @return array
- * @since 2020/11/11
- * @author wesmiler
- */
- public function getItemList()
- {
- $list = $this->model->where("status", "=", 1)
- ->where("mark", "=", 1)
- ->orderBy("sort", "asc")
- ->get()
- ->toArray();
- return message("操作成功", true, $list);
- }
- }
|