package com.dsk.search.controller;

import com.alibaba.fastjson2.JSONObject;
import com.dsk.common.core.domain.AjaxResult;
import com.dsk.common.utils.StringUtils;
import com.dsk.jsk.domain.bo.ComposeQueryDto;
import com.dsk.search.service.BusinessOpportunityRadarService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


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


    @Resource
    private BusinessOpportunityRadarService opportunityRadarService;

    /*
     * 模糊查询企业名称
     */
    @RequestMapping("/index")
    public AjaxResult landMarketPage(@RequestBody JSONObject object) {
        ComposeQueryDto compose = JSONObject.parseObject(object.toJSONString(), ComposeQueryDto.class);
        if (PageQueryLimit.pageLimit(compose.getPage())){
            return AjaxResult.error("翻页已达到上限");
        }
        return opportunityRadarService.enterpriseIndex(object);
    }

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

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

    /*
     * 查业主单位
     */
    @RequestMapping("/bossCompany")
    public AjaxResult bossCompany(@RequestBody JSONObject object) {
        return opportunityRadarService.bossCompany(object);
    }
}
