package com.base.track.controller;

import com.base.orbit.utils.StringUtil;
import com.base.orbit.web.Result;
import com.base.track.model.dto.request.QueryEphListDTO;
import com.base.track.service.EphDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.CrossOrigin;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;

@Api(tags = "星历", description = "星历基础查询")
@RestController

@RequestMapping("/api/eph")
public class EphController {

    @Resource
    EphDataService ephDataService;

    /**
     * 根据条件查询eph文件读取星历数据
     *
     * @param
     * @return
     */
    @ApiOperation(value = "据条件查询eph文件读取星历数据")
    @GetMapping(value = "/list")
    public Object selEphDataByFile(@RequestParam String code, @RequestParam Date startTime, @RequestParam Date endTime) {
        // 如果开始结束时间为同一天，则结束时间+1
        QueryEphListDTO queryEphListDTO = new QueryEphListDTO();
        queryEphListDTO.setStartTime(startTime);
        queryEphListDTO.setEndTime(endTime);
        queryEphListDTO.setCode(StringUtil.change(code));
        return Result.success(ephDataService.getEphList(queryEphListDTO));
    }
}
