package com.persagy.dmp.rwd.simple.controller;

import cn.hutool.core.util.StrUtil;
import com.persagy.dmp.basic.dto.RequestData;
import com.persagy.dmp.common.constant.CommonConstant;
import com.persagy.dmp.common.constant.ResponseCode;
import com.persagy.dmp.common.context.AppContext;
import com.persagy.dmp.common.exception.BusinessException;
import com.persagy.dmp.common.model.response.CommonResult;
import com.persagy.dmp.common.utils.ParamCheckUtil;
import com.persagy.dmp.common.utils.ResultHelper;
import com.persagy.dmp.rwd.simple.service.ISystemService;
import lombok.extern.slf4j.Slf4j;
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;

import java.util.List;
import java.util.Map;

/**
 * 系统业务接口
 * @author lvxy
 * @date 2021/10/9
 */
@Slf4j
@RestController
@RequestMapping("/api/custom/system")
public class SystemController {

    @Autowired
    private ISystemService systemService;
    /**
     * 查询不确定楼层/不确定建筑 的系统
     */
    @PostMapping("/queryNotSureSystem")
    public CommonResult<List<Map<String,Object>>> queryNotSureSystem(@RequestBody RequestData requestData) {
        //基础参数校验
        ParamCheckUtil.checkParam(CommonConstant.QUERY_GROUPCODE);
        if (StrUtil.isAllEmpty(AppContext.getContext().getProjectId(),requestData.getObjType())){
            throw new BusinessException(ResponseCode.A0402.getCode(),ResponseCode.A0402.getDesc());
        }
        List<Map<String, Object>> result = systemService.queryNotSureSystem(requestData);
        return ResultHelper.multi(result);
    }

}
