捕梦者基础框架API接口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

79 lines
1.7 KiB

<?php
declare (strict_types=1);
namespace app\api\model;
use think\Model;
/**
* @mixin think\Model
*/
class MessageContent extends Common
{
protected $table = 'system_message_content'; //如cloud_开头不需要
/**
* 字典列表数据模型
* @return array|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
//自定义处理逻辑
$dict_name = $this->request->param('title', '');
$_op = $this->whereLike('title', "{$dict_name}%");
//通用逻辑
return parent::parentLists($_op);
}
/**
* 读取后
* @param Model $model
* @return bool|void
*/
public static function onAfterRead(Model $model)
{
//读取数据前格式化数据
if (in_array(request()->action(), ['edit', 'delete', 'status'])) {
return true;
}
//业务逻辑
}
/**
* 新增或修改前
* @param Model $model
* @return mixed|void
*/
public static function onBeforeWrite(Model $model)
{
parent::onBeforeWrite($model);
//写入数据前格式化数据
if (!in_array(request()->action(), ['add', 'edit'])) {
return true;
}
//业务逻辑
// code...
}
public static function onAfterDelete(Model $model)
{
parent::onAfterDelete($model); // TODO: Change the autogenerated stub
}
public static function onAfterWrite(Model $model)
{
parent::onAfterWrite($model); // TODO: Change the autogenerated stub
}
}