FastMovieAI AI短剧创作平台 二开基线
- 源码: xhadmincn/FastMovieAI (Apache 2.0) - 二开: Docker部署, Swoole改Select, route.php修复, 补update/VERSION - vendor/示例资源已gitignore
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace app;
|
||||
|
||||
use app\expose\trait\Json;
|
||||
use support\Request;
|
||||
|
||||
class Basic
|
||||
{
|
||||
protected $model;
|
||||
use Json;
|
||||
/**
|
||||
* 更新指定字段
|
||||
* @method POST
|
||||
*/
|
||||
public function indexUpdateField(Request $request)
|
||||
{
|
||||
$id = $request->post('id');
|
||||
$field = $request->post('field');
|
||||
$value = $request->post('value');
|
||||
$model = $this->model->where(['id' => $id])->find();
|
||||
if (!$model) {
|
||||
return $this->fail('数据不存在');
|
||||
}
|
||||
$model->{$field} = $value;
|
||||
if ($model->save()) {
|
||||
return $this->success();
|
||||
}
|
||||
return $this->fail('操作失败');
|
||||
}
|
||||
/**
|
||||
* 更新状态字段
|
||||
* @method POST
|
||||
*/
|
||||
public function indexUpdateState(Request $request)
|
||||
{
|
||||
$id = $request->post('id');
|
||||
$field = $request->post('field');
|
||||
$value = $request->post('value');
|
||||
$model = $this->model->where(['id' => $id])->find();
|
||||
if (!$model) {
|
||||
return $this->fail('数据不存在');
|
||||
}
|
||||
$model->{$field} = $value;
|
||||
if ($model->save()) {
|
||||
return $this->success();
|
||||
}
|
||||
return $this->fail('操作失败');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user