57 lines
1.6 KiB
PHP
57 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace service\modules\v1\controllers;
|
|
|
|
use common\core\BaseServiceController;
|
|
use common\modelsgii\oldDb\DoctorNotice;
|
|
use yii\db\Exception;
|
|
|
|
/**
|
|
* @doc-module 医生公告
|
|
*/
|
|
class DoctorNoticeController extends BaseServiceController
|
|
{
|
|
/**
|
|
* @doc-name 添加(开启)或修改停诊公告
|
|
* @doc-param int close_notice 停诊公告0关闭1开启
|
|
* @doc-param string content 内容
|
|
* @doc-param int start_time 开始时间
|
|
* @doc-param int end_time 结束时间
|
|
*/
|
|
public function actionSaveClose()
|
|
{
|
|
$request = \Yii::$app->request;
|
|
$param = $request->post();
|
|
$this->requestValidate($param, [
|
|
['close_notice', 'required', 'message' => '停诊公告不能为空'],
|
|
['content', 'required', 'message' => '内容不能为空'],
|
|
['start_time', 'required', 'message' => '开始时间不能为空'],
|
|
['end_time', 'required', 'message' => '结束时间不能为空'],
|
|
]);
|
|
$notice = DoctorNotice::find()->where(['su_id' => \Yii::$app->user->identity->id])->one();
|
|
|
|
if (!$notice) {
|
|
$notice = new DoctorNotice();
|
|
$notice->su_id = \Yii::$app->user->identity->id;
|
|
}
|
|
$notice->attributes = $param;
|
|
$notice->saveOrFail();
|
|
return [];
|
|
|
|
}
|
|
|
|
/**
|
|
* @doc-name 查询停诊公告
|
|
*/
|
|
public function actionQueryNotice()
|
|
{
|
|
$notice = DoctorNotice::find()->where(['su_id' => \Yii::$app->user->identity->id])->one();
|
|
|
|
if (!$notice) {
|
|
throw new Exception('你还没有公告,可以去添加');
|
|
}
|
|
|
|
return $notice;
|
|
}
|
|
|
|
} |