package com.yami.shop.api.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yami.shop.bean.model.SearchTerm;
import com.yami.shop.common.util.PageParam;
import com.yami.shop.service.SearchTermService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "搜索词")
@AllArgsConstructor
@RequestMapping("/searchTerm")
public class SearchTermController {

    private final SearchTermService searchTermService;

    @GetMapping("/hotSearchWord")
    @ApiOperation(value = "小程序主页-热门搜索词")
    public ResponseEntity<IPage<SearchTerm>> hotSearchWord(PageParam<SearchTerm> page) {
        IPage<SearchTerm> searchTermIPage = searchTermService.hotSearchWord(page);
        return ResponseEntity.ok(searchTermIPage);
    }

    @GetMapping("/recommendSearchWord")
    @ApiOperation(value = "小程序主页-推荐搜索词")
    public ResponseEntity<IPage<SearchTerm>> recommendSearchWord(PageParam<SearchTerm> page) {
        IPage<SearchTerm> searchTermIPage = searchTermService.recommendSearchWord(page);
        return ResponseEntity.ok(searchTermIPage);
    }
}
