package com.bjtdba.wares.controller;

import com.bjtdba.wares.dto.SearchCriteriaDto;
import com.bjtdba.wares.service.MerchantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("wares_service/waresServiceMerchant")
public class MerchantController {

    @Autowired
    private MerchantService merchantService;

    /**
     * 店铺分类接 口
     */
    @GetMapping("/selectMerchantSort")
    public Object selectMerchantSort(){
        return merchantService.SelectMerchantSort();
    }

    /**
     * 搜索店铺店铺接口
     */
    @GetMapping("/selectMerchant")
    public Object selectMerchant(@RequestHeader Map<String,String> Hmap, Integer pageNum, Integer pageSize, SearchCriteriaDto searchCriteriaDto){
        if(Hmap.containsKey("uid")  && (searchCriteriaDto.getMer_keyword()==null || searchCriteriaDto.getMer_keyword().equals(""))){
                //通過用戶信息查詢店鋪信息
             Integer uid=Integer.parseInt(Hmap.get("uid"));
             searchCriteriaDto.setUid(uid);
        }
        return  merchantService.selectMerchantLeft(pageNum,pageSize,searchCriteriaDto);
//        return  merchantService.selectMerchant(pageNum,pageSize,searchCriteriaDto);
    }
}
