package com.dsk.jsk.controller;


import com.dsk.common.core.domain.AjaxResult;
import com.dsk.jsk.domain.PageQueryLimit;
import com.dsk.jsk.domain.bo.ComposeQueryDto;
import com.dsk.jsk.service.BusinessOpportunityRadarService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * 查企业
 * @author Administrator
 *
 */
@RequestMapping("/enterprise")
@RestController
public class CompanySearchController {


    @Resource
    BusinessOpportunityRadarService opportunityRadarService;

    /*
     * 模糊查询企业名称
     */
    @PostMapping("/index")
    public AjaxResult landMarketPage(@RequestBody ComposeQueryDto dto) {
        if (PageQueryLimit.pageLimit(dto.getPage())){
            return AjaxResult.error("翻页已达到上限");
        }
        return opportunityRadarService.enterpriseIndex(dto);
    }

    /*
     * 完全匹配企业名称
     */
    @GetMapping("/findByName/{keyword}")
    public AjaxResult findByName(@PathVariable String keyword) {
        return opportunityRadarService.enterpriseByName(keyword);
    }

    /*
     * 完全匹配企业名称
     */
    @PostMapping("/page")
    public AjaxResult page(@RequestBody ComposeQueryDto dto) {
        if (PageQueryLimit.pageLimit(dto.getPage())){
            return AjaxResult.error("翻页已达到上限");
        }
        return opportunityRadarService.enterprisePage(dto);
    }
}
