package com.dsk.jsk.controller;

import com.alibaba.fastjson2.JSONObject;
import com.dsk.common.core.domain.AjaxResult;
import com.dsk.jsk.domain.bo.ComposeQueryDto;
import com.dsk.jsk.service.service.RegionalEnterprisesService;
import com.dsk.search.controller.PageQueryLimit;
import org.springframework.beans.factory.annotation.Autowired;
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;

/**
 * @ClassName RegionalEnterprisesController
 * @Description 区域企业
 * @Author Dgm
 * @Date 2023/5/24 16:20
 * @Version
 */
@RestController
@RequestMapping(value="/enterprises")
public class RegionalEnterprisesController {

    @Autowired
    private RegionalEnterprisesService regionalEnterprisesService;

    @PostMapping("/regional/page")
    public AjaxResult page(@RequestBody JSONObject object) throws Exception{
        ComposeQueryDto compose = JSONObject.parseObject(object.toJSONString(), ComposeQueryDto.class);
        if (PageQueryLimit.pageLimit(compose.getPage())){
            return AjaxResult.error("翻页已达到上限");
        }
        return regionalEnterprisesService.enterprisePage(object);
    }
}
