初始化仓库
This commit is contained in:
57
service/modules/v1/controllers/DoctorNoticeController.php
Normal file
57
service/modules/v1/controllers/DoctorNoticeController.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace service\modules\v1\controllers;
|
||||
|
||||
use common\core\BaseServiceController;
|
||||
use common\modelsgii\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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user