package com.tourism.webadmin.app.website.controller;
import com.tourism.common.core.object.MyPageData;
import com.tourism.common.core.object.ResponseResult;
import com.tourism.common.log.annotation.OperationLog;
import com.tourism.common.log.model.constant.SysOperationLogType;
import com.tourism.webadmin.app.website.dto.PageDto;
import com.tourism.webadmin.app.website.dto.TourTourismProjectSearchRecordsDto;
import com.tourism.webadmin.app.website.service.TourismProjectSearchRecordsService;
import com.tourism.webadmin.app.website.vo.TourismProjectSearchRecordsVo;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "旅游游记列表搜索接口")
@Slf4j
@RestController
@Validated
@RequestMapping("/website/tourism/projectSearchRecords")
public class WebSiteTourismProjectSearchRecordsController {

	@Autowired
	private TourismProjectSearchRecordsService tourismProjectSearchRecordsService;

	/**
	 * 用过游记搜索记录id删除记录
	 * @param idString 搜索记录id
	 * @return 结果
	 */
	@OperationLog(type = SysOperationLogType.DELETE)
	@PostMapping("/deleteSearchRecordById")
	public ResponseResult<Void> removeProjectSearchRecordsById(@RequestBody String idString){
		return tourismProjectSearchRecordsService.removeProjectSearchRecordsById(idString);
	}


	/**
	 * 清空游记历史搜索记录（searchType:1）
	 * @return 结果
	 */
	@OperationLog(type = SysOperationLogType.DELETE_BATCH)
	@PostMapping("/clearSearchRecord")
	public ResponseResult<Void> clearProjectSearchRecords(@RequestBody String searchType){

		return tourismProjectSearchRecordsService.clearProjectSearchRecords(searchType);
	}


	/**
	 * 获取游记搜索记录列表
	 * @param tourTourismProjectSearchRecordsDto 参数DTO对象
	 * @return 结果
	 */
	@OperationLog(type = SysOperationLogType.LIST)
	@GetMapping("/searchRecordList")
	public ResponseResult<MyPageData<TourismProjectSearchRecordsVo>> getSearchRecordList(TourTourismProjectSearchRecordsDto tourTourismProjectSearchRecordsDto){
		return tourismProjectSearchRecordsService.getSearchRecordList(tourTourismProjectSearchRecordsDto);
	}

}
