# OooRoomOpenApiController.java

    package cloud.wconnect.frontoffice.controller.oooroom.openapi;

    import cloud.wconnect.commonlib.cons.BaseConstant;
    import cloud.wconnect.commonlib.controller.BaseInternalController;
    import cloud.wconnect.commonlib.pojo.dto.PropertyDTO;
    import cloud.wconnect.commonlib.service.PropertyInternalService;
    import cloud.wconnect.frontoffice.pojo.bo.clc.DataBO;
    import cloud.wconnect.frontoffice.pojo.bo.oooroom.OutOfOrderBO;
    import cloud.wconnect.frontoffice.service.oooroom.IOooRoomService;
    import com.google.common.collect.ImmutableMap;
    import net.sf.jsqlparser.expression.operators.arithmetic.Addition;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.beans.factory.annotation.Value;
    import org.springframework.validation.annotation.Validated;
    import org.springframework.web.bind.annotation.*;

    import jakarta.servlet.http.HttpServletResponse;
    import java.util.Collections;
    import java.util.Map;

    /**
     * 控制层：OOO Room Open Api
     *
     * @author yyt
     * 2023/8/7
     */
    @Validated
    @RestController
    @RequestMapping("/openapi/v1/ooo-room")
    public class OooRoomOpenApiController extends BaseInternalController {

        @Autowired
        private PropertyInternalService propertyInternalService;
        @Autowired
        private IOooRoomService oooRoomService;

        @Value("${internal.service.auth-key.basic}")
        private String basicDataAuthKey;

        /**
         * 处理 ooo room 数据
         *
         * @param appId    第三方应用注册时被分配的id标识（w-connect内部请求时为0）
         * @param sign     签名
         * @param property 资产标识（w-connect内部请求时才需要）
         * @param tenant   租户标识（w-connect内部请求时才需要）
         * @param dataBO   ooo room 数据
         * @param response 响应信息
         * @author yyt
         * @date 2023/8/7
         */
        @PostMapping("/records.json")
        public Map handleOooRoomData(@RequestHeader Integer appId, @RequestHeader String sign, String property, String tenant,
                                     @Validated(Addition.class) @RequestBody DataBO<OutOfOrderBO> dataBO, HttpServletResponse response) {

            if (appId != 0) {
                response.setStatus(HttpServletResponse.SC_FORBIDDEN);
                return Collections.emptyMap();
            }

            try {
                // 验签
                checkIntranetParams(basicDataAuthKey, sign, dataBO);

                // 处理数据
                PropertyDTO propertyDTO = propertyInternalService.getOne(property, tenant);
                oooRoomService.handleOooRoomData(propertyDTO, BaseConstant.ZERO, dataBO);
            } catch (Exception e) {
                response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
                return ImmutableMap.of("error", e.getMessage());
            }

            response.setStatus(HttpServletResponse.SC_OK);
            return Collections.emptyMap();
        }

    }