# DbController.java

    package cloud.wconnect.workperformance.controller.database;

    import cloud.wconnect.commonlib.annotation.ApiId;
    import cloud.wconnect.commonlib.component.SessionContext;
    import cloud.wconnect.commonlib.pojo.dto.ListPagedDTO;
    import cloud.wconnect.commonlib.pojo.dto.result.ResultDTO;
    import cloud.wconnect.workperformance.pojo.query.database.DbPmsHfQuery;
    import cloud.wconnect.workperformance.pojo.vo.database.historyforecast.DbPmsHfVO;
    import cloud.wconnect.workperformance.pojo.vo.database.managerflash.DbPmsManagerFlashVO;
    import cloud.wconnect.workperformance.pojo.vo.database.marketcode.DbPmsMarketCodeStatisticsVO;
    import cloud.wconnect.workperformance.service.database.IDbPmsHfForecastService;
    import cloud.wconnect.workperformance.service.database.IDbPmsHfHistoryService;
    import cloud.wconnect.workperformance.service.database.IDbPmsManagerFlashService;
    import cloud.wconnect.workperformance.service.database.IDbPmsMarketCodeStatisticsService;
    import jakarta.annotation.Resource;
    import jakarta.validation.Valid;
    import org.springframework.web.bind.annotation.GetMapping;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestParam;
    import org.springframework.web.bind.annotation.RestController;

    import java.util.List;

    /**
     * <p>
     * Database 前端控制器
     * </p>
     *
     * @author zc
     * @since 2026-01-12
     */
    @RestController
    @RequestMapping("/database")
    public class DbController {

        @Resource
        private IDbPmsManagerFlashService managerFlashService;
        @Resource
        private IDbPmsMarketCodeStatisticsService marketCodeStatisticsService;
        @Resource
        private IDbPmsHfHistoryService hfHistoryService;
        @Resource
        private IDbPmsHfForecastService hfForecastService;
        @Resource
        private SessionContext sessionContext;

        /**
         * 获取指定日期的 Manager flash 数据详情
         *
         * @param property 资产标识
         * @param date     日期（yyyyMMdd）
         * @return DbPmsManagerFlashVO 集合
         * @author zc
         * @date 2026/1/12
         */
        @ApiId(1686)
        @GetMapping("/manager-flash")
        public ResultDTO<List<DbPmsManagerFlashVO>> managerFlash(@RequestParam String property, @RequestParam long date) {
            int propertyId = sessionContext.getPropertyId(property);
            return ResultDTO.success(managerFlashService.getDetail(propertyId, date));
        }

        /**
         * 获取指定日期的 Market code statistics 数据详情
         *
         * @param property 资产标识
         * @param date     日期（yyyyMMdd）
         * @return DbPmsMarketCodeStatisticsVO
         * @author zc
         * @date 2026/1/12
         */
        @ApiId(1687)
        @GetMapping("/market-code-statistics")
        public ResultDTO<DbPmsMarketCodeStatisticsVO> marketCodeStatistics(@RequestParam String property, @RequestParam long date) {
            int propertyId = sessionContext.getPropertyId(property);
            return ResultDTO.success(marketCodeStatisticsService.getDetail(propertyId, date));
        }

        /**
         * 获取指定日期范围的 History and forecast 数据
         *
         * @param property 资产标识
         * @param query    查询条件
         * @return DbPmsHfVO 集合
         * @author zc
         * @date 2026/1/12
         */
        @ApiId(1688)
        @GetMapping("/history-and-forecast")
        public ResultDTO<ListPagedDTO<DbPmsHfVO>> historyForecast(@RequestParam String property, @Valid DbPmsHfQuery query) {
            int propertyId = sessionContext.getPropertyId(property);
            return ResultDTO.success(hfHistoryService.list(propertyId, query));
        }

        /**
         * 获取指定 Data as of 日期的 History and forecast 数据详情
         *
         * @param property 资产标识
         * @param date     日期（yyyyMMdd）
         * @return DbPmsHfVO 集合
         * @author zc
         * @date 2026/1/12
         */
        @ApiId(1689)
        @GetMapping("/history-and-forecast/data-as-of")
        public ResultDTO<List<DbPmsHfVO>> hfDataAsOf(@RequestParam String property, @RequestParam long date) {
            int propertyId = sessionContext.getPropertyId(property);
            return ResultDTO.success(hfForecastService.detail(propertyId, date));
        }
    }