Files
tuiguangzhushou/application/common/service/AccountRules.php
2020-08-06 15:26:41 +08:00

102 lines
2.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\service;
use app\common\model\AccountRules as AccountRulesModel;
use app\common\validate\AccountRules as AccountRulesValidate;
class AccountRules extends _Init
{
/**
* [add description]
* @param [type] $data [description]
*/
public static function create($data)
{
$validate = new AccountRulesValidate();
if (!$validate->check($data)) {
return $validate->getError();
}
$info = AccountRulesModel::create($data);
if ($info) {
return true;
} else {
return '添加失败';
}
}
/**
* [edit description]
* @param [type] $data [description]
* @return [type] [description]
*/
public static function edit($data)
{
$validate = new AccountRulesValidate();
if (!$validate->check($data)) {
return $validate->getError();
}
$info = AccountRulesModel::update($data);
if ($info) {
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)
{
$info = AccountRulesModel::get($id);
if (!$info) {
return '规则不存在';
} elseif ($info->save(['status' => $status])) {
return true;
} else {
return '修改状态失败';
}
}
/**
* [del description]
* @param [type] $id [description]
* @return [type] [description]
*/
public static function del($id)
{
$model = new AccountRulesModel();
if ($model->destroy($id)) {
return true;
} else {
return '删除失败';
}
}
public static function get_ids($rules)
{
$ru = explode(',', $rules);
$ids = array();
foreach ($ru as $key => $value) {
$map = [
'name' => $value,
];
$ids[] = \think\Db::name('AccountRules')->where($map)->value('id') ?: '';
}
return $ids;
}
}