<?php

namespace app\common\service;
use app\common\model\ProjectStatus;

class ProjectStatusService extends Service
{
    public function create($param = [])
    {
        $param = $this->autoParams($param);

        $key = $this->req('key');
        $status = (new ProjectStatus)->where('key', '=', $key)->findOrEmpty();
        if ($status->isExists()) {
            throw $this->exception("状态键($status->key)已存在,对应的值为$status->value");
        }

        return ProjectStatus::create($param);
    }

    public function update($param = [])
    {
        $param = $this->autoParams($param);

        return ProjectStatus::update($param);
    }

    public function list()
    {
        return (new ProjectStatus)->select();
    }
}