# InternalHolidayController.java

    package cloud.wconnect.rateshop.controller.internal.rateshop;

    import cloud.wconnect.commonlib.cons.BaseErrorCodeEnum;
    import cloud.wconnect.commonlib.exception.ForbiddenException;
    import cloud.wconnect.commonlib.util.SignUtils;
    import cloud.wconnect.rateshop.pojo.dto.rateshop.holiday.CollectDTO;
    import cloud.wconnect.rateshop.service.rateshop.IHolidayService;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.beans.factory.annotation.Value;
    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 jakarta.validation.Valid;
    import java.text.MessageFormat;
    import java.util.Collections;
    import java.util.Map;

    /**
     * 节假日内部接口 控制层
     *
     * @author lichen
     * @date 2023/6/30
     */
    @RestController
    @RequestMapping("/internal/holiday")
    public class InternalHolidayController {

        @Value("${internal.service.auth-key.basic}")
        private String apiKey;
        @Autowired
        private IHolidayService holidayService;

        /**
         * 采集节假日数据
         *
         * @param collectDTO 节假日采集对象
         * @return java.util.Map
         * @author lichen
         * @date 2023/6/13
         */
        @PostMapping("/collect")
        public Map collect(@RequestBody @Valid CollectDTO collectDTO) {
            //验证签名
            String expectedSign = SignUtils.signWithKey(apiKey, collectDTO.getCountry(), collectDTO.getQueryDate());
            if (!expectedSign.equals(collectDTO.getSign())) {
                String logMsg = MessageFormat.format("The parameters may be modified illegally; expectedSign:{0}, "
                        + "actualSign:{1}, authKey:{2}", expectedSign, collectDTO.getSign(), apiKey);
                throw new ForbiddenException(BaseErrorCodeEnum.DATA_FORBIDDEN.getI18nCode(),
                        BaseErrorCodeEnum.DATA_FORBIDDEN.getCode(), logMsg);
            }
            //采集节假日信息
            holidayService.collect(collectDTO);
            return Collections.emptyMap();
        }

    }