83 lines
2.2 KiB
PHP
83 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace app\api\controller\LoveStory;
|
|
|
|
use app\BaseController;
|
|
use app\common\model\LoveStory\LoveStory as ModelLoveStory;
|
|
use app\Request;
|
|
use think\Validate;
|
|
use think\exception\ValidateException;
|
|
use think\facade\Filesystem;
|
|
use app\common\arw\adjfut\src\Excel;
|
|
use app\common\arw\adjfut\src\UploadFile;
|
|
use think\facade\Db;
|
|
use app\common\exception\Tool;
|
|
use think\facade\Env;
|
|
|
|
|
|
class LoveStory extends BaseController
|
|
{
|
|
/**
|
|
* 获取爱情故事列表
|
|
*/
|
|
public function getLoveStoryList(Request $request): array
|
|
{
|
|
$params = $request->param();
|
|
$con = [];
|
|
|
|
$con = Tool::getOptionalQuery(['love_story_title', 'LIKE'], ['love_story_place', 'LIKE'],);
|
|
|
|
$query = ModelLoveStory::where($con)
|
|
->field([
|
|
'love_story_id',
|
|
'love_story_title',
|
|
'love_story_author',
|
|
'love_story_place',
|
|
'love_story_date',
|
|
'love_story_cover',
|
|
])
|
|
->order('love_story_sort', 'asc');
|
|
|
|
return msg("获取爱情故事列表成功!", $query);
|
|
}
|
|
|
|
/**
|
|
* 获取爱情故事详情
|
|
*/
|
|
public function getLoveStoryInfo(Request $request): array
|
|
{
|
|
$params = $request->param();
|
|
|
|
$this->validate($params, ['love_story_id' => 'require']);
|
|
|
|
$find = ModelLoveStory::field([
|
|
'love_story_id',
|
|
'love_story_title',
|
|
'love_story_author',
|
|
'love_story_place',
|
|
'love_story_date',
|
|
'love_story_cover',
|
|
'love_story_sort',
|
|
'love_story_music',
|
|
'love_story_content'
|
|
])
|
|
->append(['love_story_music_name'])
|
|
->where('love_story_id', $params['love_story_id'])
|
|
->find();
|
|
|
|
// 上下个数据返回
|
|
$last_next = Tool::getLastNextData(
|
|
ModelLoveStory::class,
|
|
$find->love_story_sort,
|
|
[
|
|
'field' => ['love_story_id', 'love_story_title'],
|
|
'extraWhere' => [],
|
|
]
|
|
);
|
|
$find['prve'] = $last_next[0];
|
|
$find['next'] = $last_next[1];
|
|
|
|
return msg(0, '获取爱情故事详情成功!', ['data' => $find]);
|
|
}
|
|
}
|