96 lines
2.4 KiB
PHP
96 lines
2.4 KiB
PHP
<?php
|
||
// +------------------------------------------------+
|
||
// |http://www.cjango.com |
|
||
// +------------------------------------------------+
|
||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||
// +------------------------------------------------+
|
||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||
// +------------------------------------------------+
|
||
|
||
namespace app\system\controller;
|
||
|
||
use app\common\model\Score as ScoreModel;
|
||
use app\common\model\ScoreRules as ScoreRulesModel;
|
||
use app\common\service\ScoreRules as ScoreRulesService;
|
||
use think\Request;
|
||
|
||
/**
|
||
* 积分
|
||
*/
|
||
class Score extends _Init
|
||
{
|
||
|
||
/**
|
||
* 列表
|
||
* @return [type] [description]
|
||
*/
|
||
public function index()
|
||
{
|
||
$this->list = ScoreModel::where('')->order('id desc')->paginate();
|
||
return $this->fetch('');
|
||
}
|
||
|
||
public function rules()
|
||
{
|
||
$this->list = ScoreRulesModel::where('status', 1)->paginate();
|
||
return $this->fetch('');
|
||
}
|
||
|
||
/**
|
||
* 添加规则
|
||
* @param Request $Request 数据集
|
||
*/
|
||
public function add(Request $Request)
|
||
{
|
||
if (IS_POST) {
|
||
$data = $Request->post();
|
||
$result = ScoreRulesService::create($data);
|
||
return $this->back($result);
|
||
} else {
|
||
return $this->fetch();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 编辑规则
|
||
* @param Request $Request 数据集
|
||
* @param [type] $id 规则id
|
||
* @return [type] 返回 编辑的结果
|
||
*/
|
||
public function edit(Request $Request, $id)
|
||
{
|
||
if (IS_POST) {
|
||
$data = $Request->post();
|
||
$result = ScoreRulesService::edit($data);
|
||
return $this->back($result);
|
||
} else {
|
||
$this->info = ScoreRulesModel::get($id);
|
||
return $this->fetch('add');
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 删除规则
|
||
* @param [type] $id 规则id
|
||
* @return [type] [description]
|
||
*/
|
||
public function del($id)
|
||
{
|
||
$result = ScoreRulesService::del($id);
|
||
return $this->back($result);
|
||
}
|
||
|
||
/**
|
||
* 修改规则状态
|
||
* @param [type] $id 规则id
|
||
* @param [type] $status 状态
|
||
* @return [type] 修改规则结果
|
||
*/
|
||
public function status($id, $status)
|
||
{
|
||
$result = ScoreRulesService::status($id, $status);
|
||
return $this->back($result);
|
||
}
|
||
|
||
}
|