Commit 94d53cd4 authored by 侯贺政's avatar 侯贺政

删除商品详情页模板,新建、更新验证时预处理时间

Signed-off-by: 侯贺政's avatarhouhezheng <houhezheng@romens.cn>
parent d39e64a7
......@@ -66,6 +66,10 @@ class GoodsDetailSettingController extends BaseController
* END_TIME:生效结束时间,
* HEAD_PIC_URL:顶部内容,
* FOOT_PIC_URL:底部内容"),
* @OA\Response(
* response=422,
* description="数据验证错误,错误信息(数组)。",
* ),
* security={{"Authorization": {}}}
* )
*/
......@@ -88,7 +92,7 @@ class GoodsDetailSettingController extends BaseController
* description="更新商品详情页模板设置",
* @OA\RequestBody(
* required=true,
* description="注:时间格式为 Y-m-d H:i:s;启用按钮也用此接口,传入GUID,STATUS即可。",
* description="注:时间格式为 Y-m-d H:i:s ; 启用按钮也用此接口,传入GUID,STATUS即可。",
* @OA\MediaType(
* mediaType="application/x-www-form-urlencoded",
* @OA\Schema(
......@@ -177,7 +181,7 @@ class GoodsDetailSettingController extends BaseController
$params = Yii::$app->request->bodyParams;
$orgGuid = Yii::$app->user->identity->ORG_GUID;
$model = new $this->modelClass();
$model->senario = 'creation';
$model->scenario = 'creation';
$model->attributes = $params;
$model->ORG_GUID = $orgGuid;
$model->GUID = str_shuffle(uniqid() . rand(1000, 9999)) . $orgGuid;;
......@@ -212,7 +216,16 @@ class GoodsDetailSettingController extends BaseController
*/
public function actionSettingDel()
{
$guid = Yii::$app->request->get('GUID');
$model = new $this->modelClass();
$_model = $model::findOne($guid);
if (!$_model) {
throw new BadRequestHttpException('该模板不存在');
}
if (!$_model->delete()) {
throw new ServerErrorHttpException('删除失败!');
}
throw new HttpException(200, "删除成功!");
}
/**
......
......@@ -43,6 +43,8 @@ class ShopGoodsDetailSetting extends \app\models\v1\BaseModel
[['GUID', 'ORG_GUID'], 'string', 'max' => 50],
[['NAME'], 'string', 'max' => 255],
[['GUID'], 'unique', 'on' => 'creation'],
[['START_TIME'], 'validateStartTime'],
[['END_TIME'], 'validateEndTime'],
];
}
......@@ -63,6 +65,22 @@ class ShopGoodsDetailSetting extends \app\models\v1\BaseModel
];
}
/**
* 预处理生效开始时间为时间戳
*/
public function validateStartTime()
{
$this->START_TIME = strtotime($this->START_TIME);
}
/**
* 预处理生效结束时间为时间戳
*/
public function validateEndTime()
{
$this->END_TIME = strtotime($this->END_TIME);
}
/**
* {@inheritdoc}
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment