package quant.rich.emoney.controller.manage; import java.io.IOException; import java.util.HashMap; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; 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.ResponseBody; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; import quant.rich.emoney.controller.common.BaseController; import quant.rich.emoney.entity.config.IndexInfoConfig; import quant.rich.emoney.pojo.dto.LayPageResp; import quant.rich.emoney.pojo.dto.R; import quant.rich.emoney.service.IndexDetailService; @Controller @RequestMapping("/admin/v1/manage/indexInfo") public class IndexInfoControllerV1 extends BaseController { @Autowired IndexInfoConfig indexInfo; @Autowired IndexDetailService indexDetailService; @GetMapping({"", "/", "/index"}) public String index() { return "/admin/v1/manage/indexInfo/index"; } @GetMapping("/getIndexDetail") @ResponseBody public R getIndexDetail(String indexCode) { return R.judge(() -> indexDetailService.getIndexDetail(indexCode)); } @GetMapping("/forceRefreshAndGetIndexDetail") @ResponseBody public R forceRefreshAndGetIndexDetail(String indexCode) { return R.judge(() -> indexDetailService.forceRefreshAndGetIndexDetail(indexCode)); } @GetMapping("/configIndOnline") @ResponseBody public R configIndOnline(String url) throws IOException { //return R.judge(() -> indexInfo.getOnlineConfigByUrl(url)); return R.ok(indexInfo.getConfigIndOnline()); } @GetMapping("/getFields") @ResponseBody public R getFields(@RequestParam("fields") String[] fields) { if (fields == null || fields.length == 0) { return R.ok(indexInfo); } ObjectNode indexInfoJson = new ObjectMapper().valueToTree(indexInfo); Map map = new HashMap<>(); for (String field : fields) { map.put(field, indexInfoJson.get(field)); } return R.ok(map); } @GetMapping("/getConfigIndOnlineByUrl") @ResponseBody public R getConfigOnlineByUrl(String url) { return R.judge(() -> indexInfo.getOnlineConfigByUrl()); } @GetMapping("/getIndexInfoConfig") @ResponseBody public R getIndexInfoConfig() { return R.ok(indexInfo); } @GetMapping("/list") @ResponseBody public LayPageResp list() { return null; } }