package com.ylx.home.search.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ylx.common.core.domain.R;
import com.ylx.home.search.domain.dto.SearchMerchantDTO;
import com.ylx.home.search.domain.dto.SearchProjectDTO;
import com.ylx.massage.service.IMaTechnicianService;
import com.ylx.merchant.domain.dto.MerchantListDTO;
import com.ylx.merchant.domain.vo.MerchantListVO;
import com.ylx.project.domain.bookMerchant.vo.ProjectInfoVO;
import com.ylx.project.service.ProjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/home/search")
@Api(tags = {"用户端首页搜索"})
@Slf4j
public class HomeSearchController {

    @Resource
    private ProjectService projectService;
    @Resource
    private IMaTechnicianService maTechnicianService;

    @PostMapping("/merchants")
    @ApiOperation("用户端首页搜索商户接口")
    public R<Page<MerchantListVO>> merchants(@Validated @RequestBody MerchantListDTO dto) {
        Page<MerchantListVO> voPage = this.maTechnicianService.homeSearchPage(dto);
        return R.ok(voPage);
    }

    @PostMapping("/projects")
    @ApiOperation("用户端首页搜索服务接口")
    public R<Page<ProjectInfoVO>> projects(@Validated @RequestBody SearchProjectDTO dto) {
        Page<ProjectInfoVO> voPage = this.projectService.homeSearchPage(dto);
        return R.ok(voPage);
    }
    
}
