1
0

first commit

This commit is contained in:
2020-08-06 14:58:51 +08:00
commit 17096657dc
780 changed files with 92857 additions and 0 deletions

View File

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