初始版本
This commit is contained in:
62
server/app/adminapi/logic/setting/TextLogic.php
Executable file
62
server/app/adminapi/logic/setting/TextLogic.php
Executable file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace app\adminapi\logic\setting;
|
||||
use app\common\model\TextList;
|
||||
|
||||
class TextLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @param $params
|
||||
* @return true
|
||||
* @author cjhao
|
||||
* @date 2024/11/1 10:14
|
||||
*/
|
||||
public function add($params)
|
||||
{
|
||||
TextList::create([
|
||||
'title' => $params['title'],
|
||||
'content' => $params['content'],
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @param $params
|
||||
* @return true
|
||||
* @author cjhao
|
||||
* @date 2024/11/1 10:15
|
||||
*/
|
||||
public function edit($params)
|
||||
{
|
||||
|
||||
TextList::update([
|
||||
'title' => $params['title'],
|
||||
'content' => $params['content'],
|
||||
],['id'=>$params['id']]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @param $id
|
||||
* @return bool
|
||||
* @author cjhao
|
||||
* @date 2024/11/1 10:16
|
||||
*/
|
||||
public function del($id)
|
||||
{
|
||||
$text = TextList::where(['id'=>$id])->findOrEmpty();
|
||||
if($text->isEmpty()){
|
||||
return '数据不存在';
|
||||
}
|
||||
if($text->is_default){
|
||||
return '默认数据不允许删除';
|
||||
}
|
||||
$text->delete();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user