package com.bootdo.portal.controller;

import com.bootdo.common.utils.EhcacheUtil;
import com.bootdo.common.utils.R;
import com.bootdo.data.entity.TfInfoEnterprise;
import com.bootdo.data.service.TfInfoEnterpriseService;
import com.bootdo.datas.domain.DataDO;
import com.bootdo.datas.service.DataService;
import com.bootdo.portal.common.CommonConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * 备案数据api控制层
 *
 * @author Mr.xiBel
 * @date 2022/4/24
 **/
@CrossOrigin
@RestController
@RequestMapping("/portal/data")
public class RecordDataApiController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    /**
     * data service层
     */
    @Autowired
    private DataService dataService;

    @ResponseBody
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public R getCarouselDetail(@RequestBody Map<String, Object> parameter) {
        // 条件获取 备案数据列表
        List<DataDO> portalDataList = dataService.portalDataList(parameter);
        Long total = dataService.portalDataListCount(parameter);
        if (Objects.nonNull(portalDataList)) {
            return Objects.requireNonNull(R.ok().put(CommonConstants.DATA_FIELD_DATA, portalDataList)).
                    put(CommonConstants.DATA_FIELD_TOTAL, total);
        }

        return R.ok();
    }
}
