feat 添加首页接口
This commit is contained in:
parent
6212f9e864
commit
cbda35e257
63
app/api/controller/Home/Home.php
Normal file
63
app/api/controller/Home/Home.php
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller\Home;
|
||||||
|
|
||||||
|
use app\BaseController;
|
||||||
|
use app\common\model\WishList\WishList as ModelWishList;
|
||||||
|
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 Home extends BaseController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 获取首页数据
|
||||||
|
*/
|
||||||
|
public function getHomeData(Request $request): array
|
||||||
|
{
|
||||||
|
$params = $request->param();
|
||||||
|
$con = [];
|
||||||
|
|
||||||
|
$loveStoryList = 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')
|
||||||
|
->limit(4)
|
||||||
|
->select();
|
||||||
|
|
||||||
|
|
||||||
|
$wishList = ModelWishList::where($con)
|
||||||
|
->field([
|
||||||
|
'wish_list_id',
|
||||||
|
'wish_list_name',
|
||||||
|
'wish_list_author',
|
||||||
|
'wish_list_status',
|
||||||
|
'wish_list_create_time',
|
||||||
|
'wish_list_sort'
|
||||||
|
])
|
||||||
|
->order('wish_list_sort', 'desc')
|
||||||
|
->limit(3)
|
||||||
|
->select();
|
||||||
|
|
||||||
|
return msg(0, "获取心愿单列表成功!", [
|
||||||
|
'data' => [
|
||||||
|
'wishList' => $wishList,
|
||||||
|
'loveStoryList' => $loveStoryList
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user