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);
    }


    //---------------------------------------中建一局-------------------------------------------

    /*
     * 查资质
     */
    @RequestMapping("/zjyjAptitude")
    public AjaxResult zjyjAptitude(@RequestBody JSONObject object) {
        return opportunityRadarService.zjyjAptitude(object);
    }

    /*
     * 符合条件的资质
     */
    @RequestMapping("/zjyj/enterpriseAptitude")
    public AjaxResult zjyjEnterpriseAptitude(@RequestBody JSONObject object) {
        return opportunityRadarService.zjyjEnterpriseAptitude(object);
    }

    /*
     * 查资质   不满足
     */
    @RequestMapping("/zjyjAptitude/contrary")
    public AjaxResult zjyjAptitudeContrary(@RequestBody JSONObject object) {
        return opportunityRadarService.zjyjAptitudeContrary(object);
    }

    /*
     * 资质标准
     */
    @RequestMapping("/zjyj/cert/standard")
    public AjaxResult zjyjCertStandard(@RequestBody JSONObject object) {
        return opportunityRadarService.zjyjCertStandard(object);
    }

    /*
     * 咨询机构
     */
    @PostMapping("/consult/page")
    public AjaxResult consultPage(@RequestBody JSONObject object) {
        ComposeQueryDto compose = JSONObject.parseObject(object.toJSONString(), ComposeQueryDto.class);
        if (PageQueryLimit.pageLimit(compose.getPage())){
            return AjaxResult.error("翻页已达到上限");
        }
        return opportunityRadarService.consultPage(object);
    }
}
