ApiController.java 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. package com.genersoft.iot.vmp.web.gb28181;
  2. import com.alibaba.fastjson2.JSONObject;
  3. import com.genersoft.iot.vmp.conf.SipConfig;
  4. import org.slf4j.Logger;
  5. import org.slf4j.LoggerFactory;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.stereotype.Controller;
  8. import org.springframework.web.bind.annotation.CrossOrigin;
  9. import org.springframework.web.bind.annotation.RequestMapping;
  10. import org.springframework.web.bind.annotation.ResponseBody;
  11. /**
  12. * API兼容:系统接口
  13. */
  14. @Controller
  15. @CrossOrigin
  16. @RequestMapping(value = "/api/v1")
  17. public class ApiController {
  18. private final static Logger logger = LoggerFactory.getLogger(ApiController.class);
  19. @Autowired
  20. private SipConfig sipConfig;
  21. @RequestMapping("/getserverinfo")
  22. private JSONObject getserverinfo(){
  23. JSONObject result = new JSONObject();
  24. result.put("Authorization","ceshi");
  25. result.put("Hardware","");
  26. result.put("InterfaceVersion","2.5.5");
  27. result.put("IsDemo","");
  28. result.put("Hardware","false");
  29. result.put("APIAuth","false");
  30. result.put("RemainDays","永久");
  31. result.put("RunningTime","");
  32. result.put("ServerTime","2020-09-02 17:11");
  33. result.put("StartUpTime","2020-09-02 17:11");
  34. result.put("Server","");
  35. result.put("SIPSerial", sipConfig.getId());
  36. result.put("SIPRealm", sipConfig.getDomain());
  37. result.put("SIPHost", sipConfig.getIp());
  38. result.put("SIPPort", sipConfig.getPort());
  39. result.put("ChannelCount","1000");
  40. result.put("VersionType","");
  41. result.put("LogoMiniText","");
  42. result.put("LogoText","");
  43. result.put("CopyrightText","");
  44. return result;
  45. }
  46. @RequestMapping(value = "/userinfo")
  47. private JSONObject userinfo(){
  48. // JSONObject result = new JSONObject();
  49. // result.put("ID","ceshi");
  50. // result.put("Hardware","");
  51. // result.put("InterfaceVersion","2.5.5");
  52. // result.put("IsDemo","");
  53. // result.put("Hardware","false");
  54. // result.put("APIAuth","false");
  55. // result.put("RemainDays","永久");
  56. // result.put("RunningTime","");
  57. // result.put("ServerTime","2020-09-02 17:11");
  58. // result.put("StartUpTime","2020-09-02 17:11");
  59. // result.put("Server","");
  60. // result.put("SIPSerial", sipConfig.getId());
  61. // result.put("SIPRealm", sipConfig.getDomain());
  62. // result.put("SIPHost", sipConfig.getIp());
  63. // result.put("SIPPort", sipConfig.getPort());
  64. // result.put("ChannelCount","1000");
  65. // result.put("VersionType","");
  66. // result.put("LogoMiniText","");
  67. // result.put("LogoText","");
  68. // result.put("CopyrightText","");
  69. return null;
  70. }
  71. /**
  72. * 系统接口 - 登录
  73. * @param username 用户名
  74. * @param password 密码(经过md5加密,32位长度,不带中划线,不区分大小写)
  75. * @return
  76. */
  77. @RequestMapping(value = "/login")
  78. @ResponseBody
  79. private JSONObject login(String username,String password ){
  80. if (logger.isDebugEnabled()) {
  81. logger.debug(String.format("模拟接口> 登录 API调用,username:%s ,password:%s ",
  82. username, password));
  83. }
  84. JSONObject result = new JSONObject();
  85. result.put("CookieToken","ynBDDiKMg");
  86. result.put("URLToken","MOBkORkqnrnoVGcKIAHXppgfkNWRdV7utZSkDrI448Q.oxNjAxNTM4NDk3LCJwIjoiZGJjODg5NzliNzVj" +
  87. "Nzc2YmU5MzBjM2JjNjg1ZWFiNGI5ZjhhN2Y0N2RlZjg3NWUyOTJkY2VkYjkwYmEwMTA0NyIsInQiOjE2MDA5MzM2OTcsInUiOiI" +
  88. "4ODlkZDYyM2ViIn0eyJlIj.GciOiJIUzI1NiIsInR5cCI6IkpXVCJ9eyJhb");
  89. result.put("TokenTimeout",604800);
  90. result.put("AuthToken","MOBkORkqnrnoVGcKIAHXppgfkNWRdV7utZSkDrI448Q.oxNjAxNTM4NDk3LCJwIjoiZGJjODg5NzliNzVj" +
  91. "Nzc2YmU5MzBjM2JjNjg1ZWFiNGI5ZjhhN2Y0N2RlZjg3NWUyOTJkY2VkYjkwYmEwMTA0NyIsInQiOjE2MDA5MzM2OTcsInUiOiI" +
  92. "4ODlkZDYyM2ViIn0eyJlIj.GciOiJIUzI1NiIsInR5cCI6IkpXVCJ9eyJhb");
  93. result.put("Token","ynBDDiKMg");
  94. return result;
  95. }
  96. }