package com.sqx.modules.shop.controller.app;

import com.sqx.common.utils.Result;
import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.shop.service.SearchHistoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags={"用户端-历史搜索记录"})
@RestController
@RequestMapping("/app/searchhistory")
public class SearchHistoryController {

    @Autowired
    private SearchHistoryService searchHistoryService;

    @Login
    @ApiOperation("查看用户历史搜索记录")
    @GetMapping(value = "selectSearchHistory")
    public Result selectSearchHistory(@RequestAttribute Long userId, Integer page, Integer limit){

        return searchHistoryService.selectSearchHistory(userId, page, limit);
    }

    @Login
    @ApiOperation("删除历史记录")
    @GetMapping(value = "deleteSearchHistory")
    public Result deleteSearchHistory(@RequestAttribute Long userId){

        return searchHistoryService.deleteSearchHistory(userId);
    }

}
