79 lines
2.1 KiB
PHP
79 lines
2.1 KiB
PHP
<?php
|
||
// +------------------------------------------------+
|
||
// |http://www.cjango.com |
|
||
// +------------------------------------------------+
|
||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||
// +------------------------------------------------+
|
||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||
// +------------------------------------------------+
|
||
namespace app\common\service;
|
||
|
||
use app\common\model\AdvertDetail as AdvertDetailModel;
|
||
use app\common\validate\AdvertDetail as AdvertDetailValidate;
|
||
|
||
class AdvertDetail extends _Init
|
||
{
|
||
public static function add($data)
|
||
{
|
||
$validate = new AdvertDetailValidate();
|
||
|
||
if (!$validate->check($data)) {
|
||
return $validate->getError();
|
||
}
|
||
|
||
if (AdvertDetailModel::create($data)) {
|
||
return true;
|
||
} else {
|
||
return '添加失败';
|
||
}
|
||
}
|
||
|
||
public static function edit($data)
|
||
{
|
||
$validate = new AdvertDetailValidate();
|
||
|
||
if (!$validate->check($data)) {
|
||
return $validate->getError();
|
||
}
|
||
|
||
if (AdvertDetailModel::update($data)) {
|
||
return true;
|
||
} else {
|
||
return '修改失败';
|
||
}
|
||
}
|
||
|
||
public static function del($id)
|
||
{
|
||
$info = AdvertDetailModel::get($id);
|
||
|
||
if (!$info) {
|
||
return $this->error('数据不存在');
|
||
} elseif ($info->save(['status' => -1])) {
|
||
return true;
|
||
} else {
|
||
return '删除失败';
|
||
}
|
||
}
|
||
|
||
/**
|
||
* [status description]
|
||
* @param [type] $id [description]
|
||
* @param [type] $status [description]
|
||
* @param [type] $type [description]
|
||
* @return [type] [description]
|
||
*/
|
||
public static function status($id, $status, $type)
|
||
{
|
||
$info = AdvertDetailModel::get($id);
|
||
if (!$info) {
|
||
return $this->error('数据不存在');
|
||
} elseif ($info->save([$type => $status])) {
|
||
Logs::write('修改状态', [$type => $status]);
|
||
return true;
|
||
} else {
|
||
return '设置失败';
|
||
}
|
||
}
|
||
}
|