<?php
/*
 本代码由 焕岱科技 创建
 技术支持 WX：15285007200
 严禁反编译、逆向等任何形式的侵权行为，违者将追究法律责任
*/

namespace app\api\controller\workorder;

use app\api\controller\Base;
use think\Db;


class Category extends Base
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];
    
    public $model = null;
    public function _initialize(){
        parent::_initialize();
        $this->model = new \app\common\model\bbfxshop\Workorder;
    }

    public function getList(){
        $where = ["uniacid"=>UNIACID];
        
        $list = Db::name("bbfx_workorder_category")->where($where)->field("id,title,image")->order('sort desc,id desc')->select();

        foreach($list as $key => &$val){
            $val['image'] = cdnurl($val['image']);
        }
        
        __success("操作成功",['list'=>$list]);
    }

    public function detail(){
        $id = $this->param("id/d");
        
        $info = Db::name("bbfx_workorder_category")->where(['id'=>$id])->find();
        
        if(empty($info)){
            __error("数据不存在");
        }
        $info['image'] = cdnurl($info['image']);
        $info['form'] = iunserializer($info['form']);
        
        __success('操作成功',$info);
    }
}