新增敏感词库

This commit is contained in:
JaguarJack 2020-06-17 14:29:31 +08:00
parent 13d3734dba
commit c450c4afc5
4 changed files with 137 additions and 0 deletions

View File

@ -0,0 +1,67 @@
<?php
namespace catchAdmin\system\controller;
use catcher\base\CatchController;
use catchAdmin\system\model\SensitiveWord as Model;
use catcher\base\CatchRequest;
use catcher\CatchResponse;
class SensitiveWord extends CatchController
{
protected $sensitiveWord;
public function __construct(Model $model)
{
$this->sensitiveWord = $model;
}
/**
* 列表
*
* @time 2020年06月17日
* @return \think\response\Json
*/
public function index()
{
return CatchResponse::paginate($this->sensitiveWord->getList());
}
/**
* 保存
*
* @time 2020年06月17日
* @param CatchRequest $request
* @return \think\response\Json
*/
public function save(CatchRequest $request)
{
return CatchResponse::success($this->sensitiveWord->storeBy($request->param()));
}
/**
* 更新
*
* @time 2020年06月17日
* @param $id
* @param CatchRequest $request
* @return \think\response\Json
*/
public function update($id, CatchRequest $request)
{
return CatchResponse::success($this->sensitiveWord->updateBy($id, $request->param()));
}
/**
* 删除
*
* @time 2020年06月17日
* @param $id
* @return \think\response\Json
*/
public function delete($id)
{
return CatchResponse::success($this->sensitiveWord->deleteBy($id));
}
}

View File

@ -0,0 +1,39 @@
<?php
use think\migration\Migrator;
use think\migration\db\Column;
class SensitiveWord extends Migrator
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* renameColumn
* addIndex
* addForeignKey
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$table = $this->table('sensitive_word',['engine'=>'InnoDB', 'comment' => '敏感词库', 'signed' => false]);
$table->addColumn('word', 'string',['limit' => 50,'default'=>'','comment'=>'词汇'])
->addColumn('creator_id', 'integer', array('default'=>0, 'comment'=>'创建人ID', 'signed' => false ))
->addColumn('created_at', 'integer', array('default'=>0, 'comment'=>'创建时间', 'signed' => false ))
->addColumn('updated_at', 'integer', array('default'=>0, 'comment'=>'更新时间', 'signed' => false ))
->addColumn('deleted_at', 'integer', array('default'=>0, 'comment'=>'删除时间', 'signed' => false ))
->create();
}
}

View File

@ -0,0 +1,28 @@
<?php
// +----------------------------------------------------------------------
// | CatchAdmin [Just Like ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
// +----------------------------------------------------------------------
// | Author: JaguarJack [ njphper@gmail.com ]
// +----------------------------------------------------------------------
namespace catchAdmin\system\model;
use catcher\base\CatchModel;
class SensitiveWord extends CatchModel
{
protected $name = 'sensitive_word';
protected $field = [
'id', //
'word', // 词汇
'creator_id', // 创建人ID
'created_at', // 创建时间
'updated_at', // 更新时间
'deleted_at', // 删除时间
];
}

View File

@ -26,3 +26,6 @@ $router->resource('config', '\catchAdmin\system\controller\Config');
// 代码生成
$router->post('generate', '\catchAdmin\system\controller\Generate@save');
$router->post('generate/preview', '\catchAdmin\system\controller\Generate@preview'); // 预览
// 敏感词
$router->resource('sensitive/word', '\catchAdmin\system\controller\SensitiveWord');