Browse Source

-antd 风格UI

pull/217/head
decoder 4 years ago
parent
commit
6e827e5f97
  1. 4
      pom.xml
  2. 7
      src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java
  3. 95
      src/main/java/com/genersoft/iot/vmp/common/MyPageInfo.java
  4. 95
      src/main/java/com/genersoft/iot/vmp/common/Page.java
  5. 136
      src/main/java/com/genersoft/iot/vmp/common/VersionPo.java
  6. 5
      src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java
  7. 28
      src/main/java/com/genersoft/iot/vmp/common/reponse/ErrorResponseData.java
  8. 98
      src/main/java/com/genersoft/iot/vmp/common/reponse/ResponseData.java
  9. 15
      src/main/java/com/genersoft/iot/vmp/common/reponse/SuccessResponseData.java
  10. 23
      src/main/java/com/genersoft/iot/vmp/conf/ApiAccessFilter.java
  11. 3
      src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java
  12. 113
      src/main/java/com/genersoft/iot/vmp/conf/RedisConfig.java
  13. 1
      src/main/java/com/genersoft/iot/vmp/conf/SipDeviceRunner.java
  14. 6
      src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java
  15. 1
      src/main/java/com/genersoft/iot/vmp/conf/UserSetup.java
  16. 25
      src/main/java/com/genersoft/iot/vmp/conf/VManagerConfig.java
  17. 37
      src/main/java/com/genersoft/iot/vmp/conf/VersionConfig.java
  18. 37
      src/main/java/com/genersoft/iot/vmp/conf/VersionInfo.java
  19. 28
      src/main/java/com/genersoft/iot/vmp/conf/WebConfig.java
  20. 43
      src/main/java/com/genersoft/iot/vmp/conf/security/AnonymousAuthenticationEntryPoint.java
  21. 47
      src/main/java/com/genersoft/iot/vmp/conf/security/DefaultUserDetailsServiceImpl.java
  22. 24
      src/main/java/com/genersoft/iot/vmp/conf/security/InvalidSessionHandler.java
  23. 65
      src/main/java/com/genersoft/iot/vmp/conf/security/LoginFailureHandler.java
  24. 24
      src/main/java/com/genersoft/iot/vmp/conf/security/LoginSuccessHandler.java
  25. 27
      src/main/java/com/genersoft/iot/vmp/conf/security/LogoutHandler.java
  26. 78
      src/main/java/com/genersoft/iot/vmp/conf/security/SecurityUtils.java
  27. 169
      src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java
  28. 102
      src/main/java/com/genersoft/iot/vmp/conf/security/dto/LoginUser.java
  29. 6
      src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java
  30. 2
      src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java
  31. 8
      src/main/java/com/genersoft/iot/vmp/service/IRecordInfoServer.java
  32. 3
      src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java
  33. 22
      src/main/java/com/genersoft/iot/vmp/service/IUserService.java
  34. 10
      src/main/java/com/genersoft/iot/vmp/service/IVideoSquareService.java
  35. 4
      src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java
  36. 81
      src/main/java/com/genersoft/iot/vmp/service/impl/RecordInfoServerImpl.java
  37. 5
      src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
  38. 56
      src/main/java/com/genersoft/iot/vmp/service/impl/UserServiceImpl.java
  39. 52
      src/main/java/com/genersoft/iot/vmp/service/impl/VideoSquareServiceImpl.java
  40. 733
      src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java
  41. 2
      src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
  42. 11
      src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java
  43. 12
      src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java
  44. 10
      src/main/java/com/genersoft/iot/vmp/storager/dao/RecordInfoDao.java
  45. 17
      src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java
  46. 20
      src/main/java/com/genersoft/iot/vmp/storager/dao/VideoSquareMapper.java
  47. 1183
      src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
  48. 44
      src/main/java/com/genersoft/iot/vmp/utils/GitUtil.java
  49. 73
      src/main/java/com/genersoft/iot/vmp/utils/JarFileUtils.java
  50. 31
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java
  51. 93
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java
  52. 463
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java
  53. 30
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java
  54. 49
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java
  55. 7
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platformGbStream/PlatformGbStreamController.java
  56. 19
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java
  57. 9
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java
  58. 74
      src/main/java/com/genersoft/iot/vmp/vmanager/record/RecordController.java
  59. 81
      src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java
  60. 17
      src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java
  61. 101
      src/main/java/com/genersoft/iot/vmp/vmanager/user/RoleController.java
  62. 182
      src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java
  63. 20
      src/main/java/com/genersoft/iot/vmp/vmanager/videoSquare/VideoSquareController.java
  64. 56
      src/main/java/com/genersoft/iot/vmp/web/ApiDeviceController.java
  65. 25
      src/main/java/com/genersoft/iot/vmp/web/AuthController.java
  66. 44
      src/main/resources/application-dev.yml
  67. 2
      src/main/resources/application.yml
  68. 58
      src/test/java/com/genersoft/iot/vmp/service/impl/RoleServiceImplTest.java
  69. 72
      src/test/java/com/genersoft/iot/vmp/service/impl/UserServiceImplTest.java
  70. 12
      web_src/.babelrc
  71. 3
      web_src/.browserslistrc
  72. 46
      web_src/.editorconfig
  73. 3
      web_src/.env
  74. 3
      web_src/.env.development
  75. 3
      web_src/.env.preview
  76. 1
      web_src/.gitattributes
  77. 12
      web_src/.gitignore
  78. 14
      web_src/.postcssrc.js
  79. 6
      web_src/.prettierrc
  80. 7
      web_src/.travis.yml
  81. 6
      web_src/Dockerfile
  82. 21
      web_src/LICENSE
  83. 22
      web_src/README.md
  84. 30
      web_src/babel.config.js
  85. 41
      web_src/build/build.js
  86. 54
      web_src/build/check-versions.js
  87. BIN
      web_src/build/logo.png
  88. 101
      web_src/build/utils.js
  89. 22
      web_src/build/vue-loader.conf.js
  90. 83
      web_src/build/webpack.base.conf.js
  91. 95
      web_src/build/webpack.dev.conf.js
  92. 145
      web_src/build/webpack.prod.conf.js
  93. 8
      web_src/config/dev.env.js
  94. 85
      web_src/config/index.js
  95. 49
      web_src/config/plugin.config.js
  96. 4
      web_src/config/prod.env.js
  97. 115
      web_src/config/themePluginConfig.js
  98. 9
      web_src/deploy/caddy.conf
  99. 24
      web_src/deploy/nginx.conf
  100. 18
      web_src/index.html

4
pom.xml

@ -77,10 +77,6 @@
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>redis.clients</groupId>

7
src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java

@ -1,7 +1,5 @@
package com.genersoft.iot.vmp;
import java.util.logging.LogManager;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
@ -9,9 +7,8 @@ import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.scheduling.annotation.EnableScheduling;
import springfox.documentation.oas.annotations.EnableOpenApi;
/**
*
*/
import java.util.logging.LogManager;
@ServletComponentScan("com.genersoft.iot.vmp.conf")
@SpringBootApplication
@EnableScheduling

95
src/main/java/com/genersoft/iot/vmp/common/MyPageInfo.java

@ -0,0 +1,95 @@
package com.genersoft.iot.vmp.common;
import java.util.ArrayList;
import java.util.List;
public class MyPageInfo<T> {
//当前页
private int pageNo;
//每页的数量
private int pageSize;
//当前页的数量
private int size;
//总页数
private int pages;
//总数
private int total;
private List<T> resultData;
private List<T> list;
public MyPageInfo(List<T> resultData) {
this.resultData = resultData;
}
public void startPage(int page, int count) {
if (page <= 0) page = 1;
this.pageNo = page;
this.pageSize = count;
this.total = resultData.size();
this.pages = total%count == 0 ? total/count : total/count + 1;
int fromIndx = (page - 1) * count;
if ( fromIndx > this.total - 1) {
this.list = new ArrayList<>();
this.size = 0;
return;
}
int toIndx = page * count;
if (toIndx > this.total) {
toIndx = this.total;
}
this.list = this.resultData.subList(fromIndx, toIndx);
this.size = this.list.size();
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
public int getPages() {
return pages;
}
public void setPages(int pages) {
this.pages = pages;
}
public int getTotal() {
return total;
}
public void setTotal(int total) {
this.total = total;
}
public List<T> getList() {
return list;
}
public void setList(List<T> list) {
this.list = list;
}
}

95
src/main/java/com/genersoft/iot/vmp/common/Page.java

@ -0,0 +1,95 @@
package com.genersoft.iot.vmp.common;
import com.github.pagehelper.PageInfo;
import java.util.List;
public class Page<T> {
private Integer pageSize;
private Integer pageNo;
private Integer totalPage;
private Long totalCount;
private List<T> data;
public Page() {
}
public Page(Integer pageSize, Integer pageNo, Integer totalPage, Long totalCount, List<T> data) {
this.pageSize = pageSize;
this.pageNo = pageNo;
this.totalPage = totalPage;
this.totalCount = totalCount;
this.data = data;
}
public Page(PageInfo<T> pageInfo) {
Integer pageNo = pageInfo.getPageNum();
Integer pageSize = pageInfo.getPageSize();
Integer totalPage = pageInfo.getPages();
Long totalCount = pageInfo.getTotal();
List<T> data = pageInfo.getList();
setPageNo(pageNo);
setPageSize(pageSize);
setTotalPage(totalPage);
setTotalCount(totalCount);
setData(data);
}
public Page(MyPageInfo<T> myPageInfo){
Integer pageNo = myPageInfo.getPageNo();
Integer pageSize = myPageInfo.getPageSize();
Integer totalPage = myPageInfo.getPages();
int totalCount = myPageInfo.getTotal();
List<T> data = myPageInfo.getList();
setPageNo(pageNo);
setPageSize(pageSize);
setTotalPage(totalPage);
setTotalCount((long) totalCount);
setData(data);
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public Integer getPageNo() {
return pageNo;
}
public void setPageNo(Integer pageNo) {
this.pageNo = pageNo;
}
public Integer getTotalPage() {
return totalPage;
}
public void setTotalPage(Integer totalPage) {
this.totalPage = totalPage;
}
public Long getTotalCount() {
return totalCount;
}
public void setTotalCount(Long totalCount) {
this.totalCount = totalCount;
}
public List<T> getData() {
return data;
}
public void setData(List<T> data) {
this.data = data;
}
}

136
src/main/java/com/genersoft/iot/vmp/common/VersionPo.java

@ -1,136 +0,0 @@
package com.genersoft.iot.vmp.common;
import com.alibaba.fastjson.annotation.JSONField;
public class VersionPo {
/**
* git的全版本号
*/
@JSONField(name="GIT-Revision")
private String GIT_Revision;
/**
* maven版本
*/
@JSONField(name = "Create-By")
private String Create_By;
/**
* git的分支
*/
@JSONField(name = "GIT-BRANCH")
private String GIT_BRANCH;
/**
* git的url
*/
@JSONField(name = "GIT-URL")
private String GIT_URL;
/**
* 构建日期
*/
@JSONField(name = "BUILD-DATE")
private String BUILD_DATE;
/**
* 项目名称 配合pom使用
*/
@JSONField(name = "artifactId")
private String artifactId;
/**
* git局部版本号
*/
@JSONField(name = "GIT-Revision-SHORT")
private String GIT_Revision_SHORT;
/**
* 项目的版本如2.0.1.0 配合pom使用
*/
@JSONField(name = "version")
private String version;
/**
* 子系统名称
*/
@JSONField(name = "project")
private String project;
/**
* jdk版本
*/
@JSONField(name="Build_Jdk")
private String Build_Jdk;
public void setGIT_Revision(String GIT_Revision) {
this.GIT_Revision = GIT_Revision;
}
public void setCreate_By(String create_By) {
Create_By = create_By;
}
public void setGIT_BRANCH(String GIT_BRANCH) {
this.GIT_BRANCH = GIT_BRANCH;
}
public void setGIT_URL(String GIT_URL) {
this.GIT_URL = GIT_URL;
}
public void setBUILD_DATE(String BUILD_DATE) {
this.BUILD_DATE = BUILD_DATE;
}
public void setArtifactId(String artifactId) {
this.artifactId = artifactId;
}
public void setGIT_Revision_SHORT(String GIT_Revision_SHORT) {
this.GIT_Revision_SHORT = GIT_Revision_SHORT;
}
public void setVersion(String version) {
this.version = version;
}
public void setProject(String project) {
this.project = project;
}
public void setBuild_Jdk(String build_Jdk) {
Build_Jdk = build_Jdk;
}
public String getGIT_Revision() {
return GIT_Revision;
}
public String getCreate_By() {
return Create_By;
}
public String getGIT_BRANCH() {
return GIT_BRANCH;
}
public String getGIT_URL() {
return GIT_URL;
}
public String getBUILD_DATE() {
return BUILD_DATE;
}
public String getArtifactId() {
return artifactId;
}
public String getGIT_Revision_SHORT() {
return GIT_Revision_SHORT;
}
public String getVersion() {
return version;
}
public String getProject() {
return project;
}
public String getBuild_Jdk() {
return Build_Jdk;
}
}

5
src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java

@ -1,10 +1,7 @@
package com.genersoft.iot.vmp.common;
/**
* @description: 定义常量
* @author: swwheihei
* @date: 2019年5月30日 下午3:04:04
*
* 定义常量
*/
public class VideoManagerConstants {

28
src/main/java/com/genersoft/iot/vmp/common/reponse/ErrorResponseData.java

@ -0,0 +1,28 @@
package com.genersoft.iot.vmp.common.reponse;
public class ErrorResponseData extends ResponseData{
/**
* 异常的具体类名称
*/
private String exceptionClazz;
public String getExceptionClazz() {
return exceptionClazz;
}
public void setExceptionClazz(String exceptionClazz) {
this.exceptionClazz = exceptionClazz;
}
ErrorResponseData(String message) {
super(false, DEFAULT_ERROR_CODE, message, null);
}
public ErrorResponseData(Integer code, String message) {
super(false, code, message, null);
}
ErrorResponseData(Integer code, String message, Object object) {
super(false, code, message, object);
}
}

98
src/main/java/com/genersoft/iot/vmp/common/reponse/ResponseData.java

@ -0,0 +1,98 @@
package com.genersoft.iot.vmp.common.reponse;
public class ResponseData {
public static final String DEFAULT_SUCCESS_MESSAGE = "请求成功";
public static final String DEFAULT_ERROR_MESSAGE = "网络异常";
public static final Integer DEFAULT_SUCCESS_CODE = 200;
public static final Integer DEFAULT_ERROR_CODE = 500;
/**
* 请求是否成功
*/
private Boolean success;
/**
* 响应状态码
*/
private Integer code;
/**
* 响应信息
*/
private String message;
/**
* 响应对象
*/
private Object data;
public ResponseData() {
}
public ResponseData(Boolean success, Integer code, String message, Object data) {
this.success = success;
this.code = code;
this.message = message;
this.data = data;
}
public static SuccessResponseData success() {
return new SuccessResponseData();
}
public static SuccessResponseData success(Object object) {
return new SuccessResponseData(object);
}
public static SuccessResponseData success(Integer code, String message, Object object) {
return new SuccessResponseData(code, message, object);
}
public static ErrorResponseData error(String message) {
return new ErrorResponseData(message);
}
public static ErrorResponseData error(Integer code, String message) {
return new ErrorResponseData(code, message);
}
public static ErrorResponseData error(Integer code, String message, Object object) {
return new ErrorResponseData(code, message, object);
}
public Boolean getSuccess() {
return success;
}
public void setSuccess(Boolean success) {
this.success = success;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
}

15
src/main/java/com/genersoft/iot/vmp/common/reponse/SuccessResponseData.java

@ -0,0 +1,15 @@
package com.genersoft.iot.vmp.common.reponse;
public class SuccessResponseData extends ResponseData {
public SuccessResponseData() {
super(true, DEFAULT_SUCCESS_CODE, DEFAULT_SUCCESS_MESSAGE, null);
}
public SuccessResponseData(Object object) {
super(true, DEFAULT_SUCCESS_CODE, DEFAULT_SUCCESS_MESSAGE, object);
}
public SuccessResponseData(Integer code, String message, Object object) {
super(true, code, message, object);
}
}

23
src/main/java/com/genersoft/iot/vmp/conf/ApiAccessFilter.java

@ -1,7 +1,6 @@
package com.genersoft.iot.vmp.conf;
import com.genersoft.iot.vmp.common.ApiSaveConstant;
import com.genersoft.iot.vmp.conf.security.SecurityUtils;
import com.genersoft.iot.vmp.service.ILogService;
import com.genersoft.iot.vmp.storager.dao.dto.LogDto;
import org.apache.commons.lang3.StringUtils;
@ -18,14 +17,9 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
/**
* @author lin
*/
@WebFilter(filterName = "ApiAccessFilter", urlPatterns = "/api/*", asyncSupported=true)
@WebFilter(filterName = "ApiAccessFilter", urlPatterns = "/api/*", asyncSupported = true)
public class ApiAccessFilter extends OncePerRequestFilter {
private final static Logger logger = LoggerFactory.getLogger(ApiAccessFilter.class);
private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Autowired
@ -34,25 +28,14 @@ public class ApiAccessFilter extends OncePerRequestFilter {
@Autowired
private ILogService logService;
@Override
protected void doFilterInternal(HttpServletRequest servletRequest, HttpServletResponse servletResponse, FilterChain filterChain) throws ServletException, IOException {
String username = null;
if (SecurityUtils.getUserInfo() == null) {
username = servletRequest.getParameter("username");
}else {
username = SecurityUtils.getUserInfo().getUsername();
}
long start = System.currentTimeMillis(); // 请求进入时间
String uriName = ApiSaveConstant.getVal(servletRequest.getRequestURI());
filterChain.doFilter(servletRequest, servletResponse);
if (uriName != null && userSetup.getLogInDatebase()) {
LogDto logDto = new LogDto();
logDto.setName(uriName);
logDto.setUsername(username);
logDto.setAddress(servletRequest.getRemoteAddr());
logDto.setResult(HttpStatus.valueOf(servletResponse.getStatus()).toString());
logDto.setTiming(System.currentTimeMillis() - start);
@ -60,10 +43,6 @@ public class ApiAccessFilter extends OncePerRequestFilter {
logDto.setUri(servletRequest.getRequestURI());
logDto.setCreateTime(format.format(System.currentTimeMillis()));
logService.add(logDto);
// logger.warn("[Api Access] [{}] [{}] [{}] [{}] [{}] {}ms",
// uriName, servletRequest.getMethod(), servletRequest.getRequestURI(), servletRequest.getRemoteAddr(), HttpStatus.valueOf(servletResponse.getStatus()),
// System.currentTimeMillis() - start);
}
}

3
src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java

@ -21,9 +21,6 @@ import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.net.ConnectException;
/**
* @author lin
*/
@SuppressWarnings(value = {"rawtypes", "unchecked"})
@Configuration
public class ProxyServletConfig {

113
src/main/java/com/genersoft/iot/vmp/conf/RedisConfig.java

@ -16,73 +16,66 @@ import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
/**
* @description:Redis中间件配置类使用spring-data-redis集成自动从application.yml中加载redis配置
* @author: swwheihei
* @date: 2019年5月30日 上午10:58:25
*
* 中间件配置类使用spring-data-redis集成自动从application.yml中加载redis配置
*/
@Configuration
public class RedisConfig extends CachingConfigurerSupport {
@Value("${spring.redis.host}")
private String host;
@Value("${spring.redis.port}")
private int port;
@Value("${spring.redis.database}")
private int database;
@Value("${spring.redis.password}")
private String password;
@Value("${spring.redis.timeout}")
private int timeout;
@Value("${spring.redis.poolMaxTotal:1000}")
private int poolMaxTotal;
@Value("${spring.redis.poolMaxIdle:500}")
private int poolMaxIdle;
@Value("${spring.redis.poolMaxWait:5}")
private int poolMaxWait;
@Value("${spring.redis.host}")
private String host;
@Value("${spring.redis.port}")
private int port;
@Value("${spring.redis.database}")
private int database;
@Value("${spring.redis.password}")
private String password;
@Value("${spring.redis.timeout}")
private int timeout;
@Value("${spring.redis.poolMaxTotal:1000}")
private int poolMaxTotal;
@Value("${spring.redis.poolMaxIdle:500}")
private int poolMaxIdle;
@Value("${spring.redis.poolMaxWait:5}")
private int poolMaxWait;
@Bean
public JedisPool jedisPool() {
if (StringUtils.isBlank(password)) {
password = null;
}
JedisPoolConfig poolConfig = new JedisPoolConfig();
poolConfig.setMaxIdle(poolMaxIdle);
poolConfig.setMaxTotal(poolMaxTotal);
// 秒转毫秒
poolConfig.setMaxWaitMillis(poolMaxWait * 1000L);
JedisPool jp = new JedisPool(poolConfig, host, port, timeout * 1000, password, database);
return jp;
}
@Bean("redisTemplate")
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate<Object, Object> template = new RedisTemplate<>();
template.setConnectionFactory(redisConnectionFactory);
// 使用fastjson进行序列化处理,提高解析效率
FastJsonRedisSerializer<Object> serializer = new FastJsonRedisSerializer<Object>(Object.class);
// value值的序列化采用fastJsonRedisSerializer
template.setValueSerializer(serializer);
template.setHashValueSerializer(serializer);
// key的序列化采用StringRedisSerializer
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());
template.setConnectionFactory(redisConnectionFactory);
// 使用fastjson时需设置此项,否则会报异常not support type
ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
return template;
}
@Bean
public JedisPool jedisPool() {
if (StringUtils.isBlank(password)) {
password = null;
}
JedisPoolConfig poolConfig = new JedisPoolConfig();
poolConfig.setMaxIdle(poolMaxIdle);
poolConfig.setMaxTotal(poolMaxTotal);
// 秒转毫秒
poolConfig.setMaxWaitMillis(poolMaxWait * 1000L);
JedisPool jp = new JedisPool(poolConfig, host, port, timeout * 1000, password, database);
return jp;
}
/**
* redis消息监听器容器 可以添加多个监听不同话题的redis监听器只需要把消息监听器和相应的消息订阅处理器绑定该消息监听器
* 通过反射技术调用消息订阅处理器的相关方法进行一些业务处理
*
* @param connectionFactory
* @return
*/
@Bean
RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory) {
@Bean("redisTemplate")
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate<Object, Object> template = new RedisTemplate<>();
template.setConnectionFactory(redisConnectionFactory);
// 使用fastjson进行序列化处理,提高解析效率
FastJsonRedisSerializer<Object> serializer = new FastJsonRedisSerializer<Object>(Object.class);
// value值的序列化采用fastJsonRedisSerializer
template.setValueSerializer(serializer);
template.setHashValueSerializer(serializer);
// key的序列化采用StringRedisSerializer
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());
template.setConnectionFactory(redisConnectionFactory);
// 使用fastjson时需设置此项,否则会报异常not support type
ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
return template;
}
/**
* redis消息监听器容器 可以添加多个监听不同话题的redis监听器只需要把消息监听器和相应的消息订阅处理器绑定该消息监听器
* 通过反射技术调用消息订阅处理器的相关方法进行一些业务处理
*/
@Bean
RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory) {
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
container.setConnectionFactory(connectionFactory);
return container;

1
src/main/java/com/genersoft/iot/vmp/conf/SipDeviceRunner.java

@ -9,7 +9,6 @@ import org.springframework.stereotype.Component;
import java.util.List;
/**
* 系统启动时控制设备离线
*/

6
src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java

@ -29,10 +29,6 @@ public class SipPlatformRunner implements CommandLineRunner {
@Autowired
private EventPublisher publisher;
@Autowired
private ZLMRTPServerFactory zlmrtpServerFactory;
@Override
public void run(String... args) throws Exception {
// 设置所有平台离线
@ -42,7 +38,7 @@ public class SipPlatformRunner implements CommandLineRunner {
redisCatchStorage.cleanPlatformRegisterInfos();
// 停止所有推流
// zlmrtpServerFactory.closeAllSendRtpStream();
// zlmrtpServerFactory.closeAllSendRtpStream();
List<ParentPlatform> parentPlatforms = storager.queryEnableParentPlatformList(true);

1
src/main/java/com/genersoft/iot/vmp/conf/UserSetup.java

@ -6,7 +6,6 @@ import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
@Component
@ConfigurationProperties(prefix = "user-settings", ignoreInvalidFields = true)
public class UserSetup {

25
src/main/java/com/genersoft/iot/vmp/conf/VManagerConfig.java

@ -1,25 +0,0 @@
package com.genersoft.iot.vmp.conf;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
/**
* @description: 获取数据库配置
* @author: swwheihei
* @date: 2020年5月6日 下午2:46:00
*/
@Configuration("vmConfig")
public class VManagerConfig {
@Value("${spring.application.database:redis}")
private String database;
public String getDatabase() {
return database;
}
public void setDatabase(String database) {
this.database = database;
}
}

37
src/main/java/com/genersoft/iot/vmp/conf/VersionConfig.java

@ -1,37 +0,0 @@
package com.genersoft.iot.vmp.conf;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@ConfigurationProperties(prefix = "version")
public class VersionConfig {
private String version;
private String artifactId;
private String description;
public void setVersion(String version) {
this.version = version;
}
public void setArtifactId(String artifactId) {
this.artifactId = artifactId;
}
public void setDescription(String description) {
this.description = description;
}
public String getVersion() {
return version;
}
public String getArtifactId() {
return artifactId;
}
public String getDescription() {
return description;
}
}

37
src/main/java/com/genersoft/iot/vmp/conf/VersionInfo.java

@ -1,37 +0,0 @@
package com.genersoft.iot.vmp.conf;
import com.genersoft.iot.vmp.common.VersionPo;
import com.genersoft.iot.vmp.utils.GitUtil;
import com.genersoft.iot.vmp.utils.JarFileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Map;
@Component
public class VersionInfo {
@Autowired
VersionConfig config;
@Autowired
GitUtil gitUtil;
@Autowired
JarFileUtils jarFileUtils;
public VersionPo getVersion() {
VersionPo versionPo = new VersionPo();
Map<String,String> map=jarFileUtils.readJarFile();
versionPo.setGIT_Revision(gitUtil.getGitCommitId());
versionPo.setCreate_By(map.get("Created-By"));
versionPo.setGIT_BRANCH(gitUtil.getBranch());
versionPo.setGIT_URL(gitUtil.getGitUrl());
versionPo.setBUILD_DATE(gitUtil.getBuildDate());
versionPo.setArtifactId(config.getArtifactId());
versionPo.setGIT_Revision_SHORT(gitUtil.getCommitIdShort());
versionPo.setVersion(config.getVersion());
versionPo.setProject(config.getDescription());
versionPo.setBuild_Jdk(map.get("Build-Jdk"));
return versionPo;
}
}

28
src/main/java/com/genersoft/iot/vmp/conf/WebConfig.java

@ -0,0 +1,28 @@
package com.genersoft.iot.vmp.conf;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfig implements WebMvcConfigurer {
// 设置允许跨域请求
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*") // 允许所有域
.allowedMethods("*") // 允许任何方法(post、get等)
.allowedHeaders("*") // 允许任何请求头
.allowCredentials(true) // 允许证书、cookie
.exposedHeaders(HttpHeaders.SET_COOKIE)
.maxAge(3600L); // maxAge(3600)表明在3600秒内,不需要再发送预检验请求,可以缓存该结果
}
};
}
}

43
src/main/java/com/genersoft/iot/vmp/conf/security/AnonymousAuthenticationEntryPoint.java

@ -1,43 +0,0 @@
package com.genersoft.iot.vmp.conf.security;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* 处理匿名用户访问逻辑
*/
@Component
public class AnonymousAuthenticationEntryPoint implements AuthenticationEntryPoint {
private final static Logger logger = LoggerFactory.getLogger(DefaultUserDetailsServiceImpl.class);
@Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) {
logger.debug("用户需要登录,访问[{}]失败,AuthenticationException=[{}]", request.getRequestURI(), e.getMessage());
// 允许跨域
response.setHeader("Access-Control-Allow-Origin", "*");
// 允许自定义请求头token(允许head跨域)
response.setHeader("Access-Control-Allow-Headers", "token, Accept, Origin, X-Requested-With, Content-Type, Last-Modified");
response.setHeader("Content-type", "application/json;charset=UTF-8");
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", "-1");
jsonObject.put("msg", "请登录后重新请求");
if (request.getRequestURI().contains("api/user/login")){
jsonObject.put("msg", e.getMessage());
}
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
try {
response.getWriter().print(jsonObject.toJSONString());
} catch (IOException ioException) {
ioException.printStackTrace();
}
}
}

47
src/main/java/com/genersoft/iot/vmp/conf/security/DefaultUserDetailsServiceImpl.java

@ -1,47 +0,0 @@
package com.genersoft.iot.vmp.conf.security;
import com.genersoft.iot.vmp.conf.security.dto.LoginUser;
import com.genersoft.iot.vmp.service.IUserService;
import com.genersoft.iot.vmp.storager.dao.dto.User;
import com.github.xiaoymin.knife4j.core.util.StrUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
/**
* 用户登录认证逻辑
*/
@Component
public class DefaultUserDetailsServiceImpl implements UserDetailsService {
private final static Logger logger = LoggerFactory.getLogger(DefaultUserDetailsServiceImpl.class);
@Autowired
private IUserService userService;
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
if (StrUtil.isBlank(username)) {
logger.info("登录用户:{} 不存在", username);
throw new UsernameNotFoundException("登录用户:" + username + " 不存在");
}
// 查出密码
User user = userService.getUserByUsername(username);
if (user == null) {
logger.info("登录用户:{} 不存在", username);
throw new UsernameNotFoundException("登录用户:" + username + " 不存在");
}
String password = SecurityUtils.encryptPassword(user.getPassword());
user.setPassword(password);
return new LoginUser(user, LocalDateTime.now());
}
}

24
src/main/java/com/genersoft/iot/vmp/conf/security/InvalidSessionHandler.java

@ -1,24 +0,0 @@
package com.genersoft.iot.vmp.conf.security;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.web.session.InvalidSessionStrategy;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* 登录超时的处理
*/
public class InvalidSessionHandler implements InvalidSessionStrategy {
private final static Logger logger = LoggerFactory.getLogger(InvalidSessionHandler.class);
@Override
public void onInvalidSessionDetected(HttpServletRequest request, HttpServletResponse httpServletResponse) throws IOException, ServletException {
String username = request.getParameter("username");
logger.info("[登录超时] - [{}]", username);
}
}

65
src/main/java/com/genersoft/iot/vmp/conf/security/LoginFailureHandler.java

@ -1,65 +0,0 @@
package com.genersoft.iot.vmp.conf.security;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.*;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.stereotype.Component;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@Component
public class LoginFailureHandler implements AuthenticationFailureHandler {
private final static Logger logger = LoggerFactory.getLogger(LoginFailureHandler.class);
@Autowired
private ObjectMapper objectMapper;
@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) throws IOException, ServletException {
String username = request.getParameter("username");
if (e instanceof AccountExpiredException) {
// 账号过期
logger.info("[登录失败] - 用户[{}]账号过期", username);
} else if (e instanceof BadCredentialsException) {
// 密码错误
logger.info("[登录失败] - 用户[{}]密码/SIP服务器ID 错误", username);
} else if (e instanceof CredentialsExpiredException) {
// 密码过期
logger.info("[登录失败] - 用户[{}]密码过期", username);
} else if (e instanceof DisabledException) {
// 用户被禁用
logger.info("[登录失败] - 用户[{}]被禁用", username);
} else if (e instanceof LockedException) {
// 用户被锁定
logger.info("[登录失败] - 用户[{}]被锁定", username);
} else if (e instanceof InternalAuthenticationServiceException) {
// 内部错误
logger.error(String.format("[登录失败] - [%s]内部错误", username), e);
} else {
// 其他错误
logger.error(String.format("[登录失败] - [%s]其他错误", username), e);
}
Map<String, Object> map = new HashMap<>();
map.put("code","0");
map.put("msg","登录失败");
response.setContentType("application/json;charset=UTF-8");
response.getWriter().write(objectMapper.writeValueAsString(map));
}
}

24
src/main/java/com/genersoft/iot/vmp/conf/security/LoginSuccessHandler.java

@ -1,24 +0,0 @@
package com.genersoft.iot.vmp.conf.security;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.stereotype.Component;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@Component
public class LoginSuccessHandler implements AuthenticationSuccessHandler {
private final static Logger logger = LoggerFactory.getLogger(LoginSuccessHandler.class);
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
String username = request.getParameter("username");
logger.info("[登录成功] - [{}]", username);
}
}

27
src/main/java/com/genersoft/iot/vmp/conf/security/LogoutHandler.java

@ -1,27 +0,0 @@
package com.genersoft.iot.vmp.conf.security;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
import org.springframework.stereotype.Component;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* 退出登录成功
*/
@Component
public class LogoutHandler implements LogoutSuccessHandler {
private final static Logger logger = LoggerFactory.getLogger(LogoutHandler.class);
@Override
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
String username = request.getParameter("username");
logger.info("[退出登录成功] - [{}]", username);
}
}

78
src/main/java/com/genersoft/iot/vmp/conf/security/SecurityUtils.java

@ -1,78 +0,0 @@
package com.genersoft.iot.vmp.conf.security;
import com.genersoft.iot.vmp.conf.security.dto.LoginUser;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import javax.security.sasl.AuthenticationException;
public class SecurityUtils {
/**
* 描述根据账号密码进行调用security进行认证授权 主动调
* 用AuthenticationManager的authenticate方法实现
* 授权成功后将用户信息存入SecurityContext当中
* @param username 用户名
* @param password 密码
* @param authenticationManager 认证授权管理器,
* @see AuthenticationManager
* @return UserInfo 用户信息
*/
public static LoginUser login(String username, String password, AuthenticationManager authenticationManager) throws AuthenticationException {
//使用security框架自带的验证token生成器 也可以自定义。
UsernamePasswordAuthenticationToken token =new UsernamePasswordAuthenticationToken(username,password);
Authentication authenticate = authenticationManager.authenticate(token);
SecurityContextHolder.getContext().setAuthentication(authenticate);
LoginUser user = (LoginUser) authenticate.getPrincipal();
return user;
}
/**
* 获取当前登录的所有认证信息
* @return
*/
public static Authentication getAuthentication(){
SecurityContext context = SecurityContextHolder.getContext();
return context.getAuthentication();
}
/**
* 获取当前登录用户信息
* @return
*/
public static LoginUser getUserInfo(){
Authentication authentication = getAuthentication();
if(authentication!=null){
Object principal = authentication.getPrincipal();
if(principal!=null && !"anonymousUser".equals(principal)){
LoginUser user = (LoginUser) authentication.getPrincipal();
return user;
}
}
return null;
}
/**
* 获取当前登录用户ID
* @return
*/
public static int getUserId(){
LoginUser user = getUserInfo();
return user.getId();
}
/**
* 生成BCryptPasswordEncoder密码
*
* @param password 密码
* @return 加密字符串
*/
public static String encryptPassword(String password) {
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
return passwordEncoder.encode(password);
}
}

169
src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java

@ -1,169 +0,0 @@
package com.genersoft.iot.vmp.conf.security;
import com.genersoft.iot.vmp.conf.UserSetup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import java.util.List;
/**
* 配置Spring Security
*/
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
private final static Logger logger = LoggerFactory.getLogger(WebSecurityConfig.class);
@Autowired
private UserSetup userSetup;
@Autowired
private DefaultUserDetailsServiceImpl userDetailsService;
/**
* 登出成功的处理
*/
@Autowired
private LoginFailureHandler loginFailureHandler;
/**
* 登录成功的处理
*/
@Autowired
private LoginSuccessHandler loginSuccessHandler;
/**
* 登出成功的处理
*/
@Autowired
private LogoutHandler logoutHandler;
/**
* 未登录的处理
*/
@Autowired
private AnonymousAuthenticationEntryPoint anonymousAuthenticationEntryPoint;
// /**
// * 超时处理
// */
// @Autowired
// private InvalidSessionHandler invalidSessionHandler;
// /**
// * 顶号处理
// */
// @Autowired
// private SessionInformationExpiredHandler sessionInformationExpiredHandler;
// /**
// * 登录用户没有权限访问资源
// */
// @Autowired
// private LoginUserAccessDeniedHandler accessDeniedHandler;
/**
* 描述: 静态资源放行这里的放行是不走 Spring Security 过滤器链
**/
@Override
public void configure(WebSecurity web) {
if (!userSetup.isInterfaceAuthentication()) {
web.ignoring().antMatchers("**");
}else {
// 可以直接访问的静态数据
web.ignoring()
.antMatchers("/")
.antMatchers("/#/**")
.antMatchers("/static/**")
.antMatchers("/index.html")
.antMatchers("/doc.html") // "/webjars/**", "/swagger-resources/**", "/v3/api-docs/**"
.antMatchers("/webjars/**")
.antMatchers("/swagger-resources/**")
.antMatchers("/v3/api-docs/**")
.antMatchers("/js/**");
List<String> interfaceAuthenticationExcludes = userSetup.getInterfaceAuthenticationExcludes();
for (String interfaceAuthenticationExclude : interfaceAuthenticationExcludes) {
if (interfaceAuthenticationExclude.split("/").length < 4 ) {
logger.warn("{}不满足两级目录,已忽略", interfaceAuthenticationExclude);
}else {
web.ignoring().antMatchers(interfaceAuthenticationExclude);
}
}
}
}
/**
* 配置认证方式
* @param auth
* @throws Exception
*/
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
// 设置不隐藏 未找到用户异常
provider.setHideUserNotFoundExceptions(true);
// 用户认证service - 查询数据库的逻辑
provider.setUserDetailsService(userDetailsService);
// 设置密码加密算法
provider.setPasswordEncoder(passwordEncoder());
auth.authenticationProvider(provider);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.cors().and().csrf().disable();
// 设置允许添加静态文件
http.headers().contentTypeOptions().disable();
http.authorizeRequests()
// 放行接口
.antMatchers("/api/user/login","/index/hook/**").permitAll()
// 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated()
// 异常处理(权限拒绝、登录失效等)
.and().exceptionHandling()
.authenticationEntryPoint(anonymousAuthenticationEntryPoint)//匿名用户访问无权限资源时的异常处理
// .accessDeniedHandler(accessDeniedHandler)//登录用户没有权限访问资源
// 登入
.and().formLogin().permitAll()//允许所有用户
.successHandler(loginSuccessHandler)//登录成功处理逻辑
.failureHandler(loginFailureHandler)//登录失败处理逻辑
// 登出
.and().logout().logoutUrl("/api/user/logout").permitAll()//允许所有用户
.logoutSuccessHandler(logoutHandler)//登出成功处理逻辑
.deleteCookies("JSESSIONID")
// 会话管理
// .and().sessionManagement().invalidSessionStrategy(invalidSessionHandler) // 超时处理
// .maximumSessions(1)//同一账号同时登录最大用户数
// .expiredSessionStrategy(sessionInformationExpiredHandler) // 顶号处理
;
}
/**
* 描述: 密码加密算法 BCrypt 推荐使用
**/
@Bean
public BCryptPasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
/**
* 描述: 注入AuthenticationManager管理器
**/
@Override
@Bean
public AuthenticationManager authenticationManager() throws Exception {
return super.authenticationManager();
}
}

102
src/main/java/com/genersoft/iot/vmp/conf/security/dto/LoginUser.java

@ -1,102 +0,0 @@
package com.genersoft.iot.vmp.conf.security.dto;
import com.genersoft.iot.vmp.storager.dao.dto.Role;
import com.genersoft.iot.vmp.storager.dao.dto.User;
import org.springframework.security.core.CredentialsContainer;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.SpringSecurityCoreVersion;
import org.springframework.security.core.userdetails.UserDetails;
import java.time.LocalDateTime;
import java.util.Collection;
public class LoginUser implements UserDetails, CredentialsContainer {
private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;
/**
* 用户
*/
private User user;
/**
* 登录时间
*/
private LocalDateTime loginTime;
public LoginUser(User user, LocalDateTime loginTime) {
this.user = user;
this.loginTime = loginTime;
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return null;
}
@Override
public String getPassword() {
return user.getPassword();
}
@Override
public String getUsername() {
return user.getUsername();
}
/**
* 账户是否未过期过期无法验证
*/
@Override
public boolean isAccountNonExpired() {
return true;
}
/**
* 指定用户是否解锁锁定的用户无法进行身份验证
* <p>
* 密码锁定
* </p>
*/
@Override
public boolean isAccountNonLocked() {
return true;
}
/**
* 指示是否已过期的用户的凭据(密码)过期的凭据防止认证
*/
@Override
public boolean isCredentialsNonExpired() {
return true;
}
/**
* 用户是否被启用或禁用禁用的用户无法进行身份验证
*/
@Override
public boolean isEnabled() {
return true;
}
/**
* 认证完成后擦除密码
*/
@Override
public void eraseCredentials() {
user.setPassword(null);
}
public int getId() {
return user.getId();
}
public Role getRole() {
return user.getRole();
}
}

6
src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java

@ -60,7 +60,7 @@ public class Device {
/**
* 在线
*/
private int online;
private Integer online;
/**
@ -196,11 +196,11 @@ public class Device {
this.hostAddress = hostAddress;
}
public int getOnline() {
public Integer getOnline() {
return online;
}
public void setOnline(int online) {
public void setOnline(Integer online) {
this.online = online;
}

2
src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java

@ -16,7 +16,7 @@ public interface IGbStreamService {
* @param count
* @return
*/
PageInfo<GbStream> getAll(Integer page, Integer count);
PageInfo<GbStream> getAll(Integer page, Integer count, String query);
/**

8
src/main/java/com/genersoft/iot/vmp/service/IRecordInfoServer.java

@ -1,8 +1,16 @@
package com.genersoft.iot.vmp.service;
import com.genersoft.iot.vmp.common.reponse.ResponseData;
import com.genersoft.iot.vmp.storager.dao.dto.RecordInfo;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
import com.github.pagehelper.PageInfo;
import java.util.List;
import java.util.Map;
public interface IRecordInfoServer {
PageInfo<RecordInfo> getRecordList(int page, int count);
ResponseData resetRecords(Map<String, Object> params);
}

3
src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java

@ -1,6 +1,7 @@
package com.genersoft.iot.vmp.service;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.Page;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
import com.github.pagehelper.PageInfo;
@ -33,7 +34,7 @@ public interface IStreamProxyService {
* @param count
* @return
*/
PageInfo<StreamProxyItem> getAll(Integer page, Integer count);
Page<StreamProxyItem> getAll(Integer page, Integer count, String query, Boolean enable);
/**
* 删除视频代理

22
src/main/java/com/genersoft/iot/vmp/service/IUserService.java

@ -1,22 +0,0 @@
package com.genersoft.iot.vmp.service;
import com.genersoft.iot.vmp.storager.dao.dto.User;
import java.util.List;
public interface IUserService {
User getUser(String username, String password);
boolean changePassword(int id, String password);
User getUserByUsername(String username);
int addUser(User user);
int deleteUser(int id);
List<User> getAllUsers();
int updateUsers(User user);
}

10
src/main/java/com/genersoft/iot/vmp/service/IVideoSquareService.java

@ -0,0 +1,10 @@
package com.genersoft.iot.vmp.service;
import com.alibaba.fastjson.JSONArray;
public interface IVideoSquareService {
//获取视屏树tree
JSONArray selectVideoTree();
}

4
src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java

@ -34,9 +34,9 @@ public class GbStreamServiceImpl implements IGbStreamService {
private PlatformGbStreamMapper platformGbStreamMapper;
@Override
public PageInfo<GbStream> getAll(Integer page, Integer count) {
public PageInfo<GbStream> getAll(Integer page, Integer count, String query) {
PageHelper.startPage(page, count);
List<GbStream> all = gbStreamMapper.selectAll();
List<GbStream> all = gbStreamMapper.selectAll(query);
return new PageInfo<>(all);
}

81
src/main/java/com/genersoft/iot/vmp/service/impl/RecordInfoServerImpl.java

@ -1,14 +1,22 @@
package com.genersoft.iot.vmp.service.impl;
import com.genersoft.iot.vmp.common.MyPageInfo;
import com.genersoft.iot.vmp.common.Page;
import com.genersoft.iot.vmp.common.reponse.ErrorResponseData;
import com.genersoft.iot.vmp.common.reponse.ResponseData;
import com.genersoft.iot.vmp.service.IRecordInfoServer;
import com.genersoft.iot.vmp.storager.dao.RecordInfoDao;
import com.genersoft.iot.vmp.storager.dao.dto.RecordInfo;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service
public class RecordInfoServerImpl implements IRecordInfoServer {
@ -22,4 +30,77 @@ public class RecordInfoServerImpl implements IRecordInfoServer {
List<RecordInfo> all = recordInfoDao.selectAll();
return new PageInfo<>(all);
}
@Override
public ResponseData resetRecords(Map<String, Object> params) {
Object listObj = params.get("list");
List<Map<String, Object>> list;
if (ObjectUtils.anyNotNull(listObj)) {
list = (List<Map<String, Object>>) listObj;
} else {
return ErrorResponseData.error("未查询到记录");
}
int pageNo = Integer.parseInt(params.get("pageNo").toString());
int pageSize = Integer.parseInt(params.get("pageSize").toString());
ChannelReduce channelReduce = new ChannelReduce();
if (params.get("deviceId") != null) channelReduce.setDeviceId(params.get("deviceId").toString());
if (params.get("manufacturer") != null) channelReduce.setManufacturer(params.get("manufacturer").toString());
if (params.get("name") != null) channelReduce.setName(params.get("name").toString());
List<Map<String, Object>> resultList = new ArrayList<>();
List<ChannelReduce> channelReduces = recordInfoDao.selectAllChannel(channelReduce);
String isNVRRecord = params.get("NVR").toString();
if ("NVR".equals(isNVRRecord)) {
boolean stream = ObjectUtils.anyNotNull(params.get("stream"));
boolean time = ObjectUtils.anyNotNull(params.get("time"));
list.stream().filter(item -> {
String streamId = item.get("stream").toString();
String originalTime = item.get("time").toString();
boolean isOK = !streamId.contains("_");
if (isOK){
if (stream && time){
String paramStream = params.get("stream").toString();
String paramTime = params.get("time").toString();
return streamId.contains(paramStream) && originalTime.contains(paramTime);
}else if (stream){
return streamId.contains(params.get("stream").toString());
}else if (time){
return originalTime.contains(params.get("time").toString());
}
return true;
}
return false;
}).forEach(resultList::add);
} else {
list.stream()
.filter(item -> {
String streamId = item.get("stream").toString();
return streamId.contains("_");
})
.forEach(item -> { //修改list内容
String streamId = item.get("stream").toString();
String[] streamIds = streamId.split("_");
String paramDeviceId = streamIds[0];
String paramChannelId = streamIds[1];
channelReduces.forEach(tempChannelReduce -> {
boolean isEq = tempChannelReduce.getDeviceId().equals(paramDeviceId) && tempChannelReduce.getChannelId().equals(paramChannelId);
if (isEq) {
item.put("manufacturer", tempChannelReduce.getManufacturer());
item.put("name", tempChannelReduce.getName());
item.put("channelId", tempChannelReduce.getChannelId());
item.put("deviceId", tempChannelReduce.getDeviceId());
item.put("hostAddress", tempChannelReduce.getHostAddress());
resultList.add(item);
}
});
});
}
MyPageInfo<Map<String, Object>> myPageInfo = new MyPageInfo<>(resultList);
myPageInfo.startPage(pageNo, pageSize);
return ResponseData.success(new Page<>(myPageInfo));
}
}

5
src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java

@ -1,6 +1,7 @@
package com.genersoft.iot.vmp.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.Page;
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
@ -146,8 +147,8 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
}
@Override
public PageInfo<StreamProxyItem> getAll(Integer page, Integer count) {
return videoManagerStorager.queryStreamProxyList(page, count);
public Page<StreamProxyItem> getAll(Integer page, Integer count, String query, Boolean enable) {
return videoManagerStorager.queryStreamProxyList(page, count, query, enable);
}
@Override

56
src/main/java/com/genersoft/iot/vmp/service/impl/UserServiceImpl.java

@ -1,56 +0,0 @@
package com.genersoft.iot.vmp.service.impl;
import com.genersoft.iot.vmp.service.IUserService;
import com.genersoft.iot.vmp.storager.dao.UserMapper;
import com.genersoft.iot.vmp.storager.dao.dto.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class UserServiceImpl implements IUserService {
@Autowired
private UserMapper userMapper;
@Override
public User getUser(String username, String password) {
return userMapper.select(username, password);
}
@Override
public boolean changePassword(int id, String password) {
User user = userMapper.selectById(id);
user.setPassword(password);
return userMapper.update(user) > 0;
}
@Override
public User getUserByUsername(String username) {
return userMapper.getUserByUsername(username);
}
@Override
public int addUser(User user) {
User userByUsername = userMapper.getUserByUsername(user.getUsername());
if (userByUsername != null) return 0;
return userMapper.add(user);
}
@Override
public int deleteUser(int id) {
return userMapper.delete(id);
}
@Override
public List<User> getAllUsers() {
return userMapper.selectAll();
}
@Override
public int updateUsers(User user) {
return userMapper.update(user);
}
}

52
src/main/java/com/genersoft/iot/vmp/service/impl/VideoSquareServiceImpl.java

@ -0,0 +1,52 @@
package com.genersoft.iot.vmp.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.service.IVideoSquareService;
import com.genersoft.iot.vmp.storager.dao.VideoSquareMapper;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@Service
public class VideoSquareServiceImpl implements IVideoSquareService {
@Autowired
private VideoSquareMapper videoSquareMapper;
@Override
public JSONArray selectVideoTree() {
JSONArray jsonArray = new JSONArray();
List<Device> devices = videoSquareMapper.selectDevices();
if (ObjectUtils.anyNotNull(devices)) {
List<DeviceChannel> deviceChannels = videoSquareMapper.selectDeviceChannels();
devices.forEach(device -> {
String deviceId1 = device.getDeviceId();
JSONObject parent = new JSONObject();
parent.put("title", deviceId1);
parent.put("key", deviceId1);
jsonArray.add(parent);
JSONArray children = new JSONArray();
parent.put("children", children);
deviceChannels.forEach(deviceChannel -> {
String deviceId2 = deviceChannel.getDeviceId();
if (deviceId1.equals(deviceId2)) {
JSONObject childrenObj = new JSONObject();
childrenObj.put("title", deviceChannel.getName());
childrenObj.put("key", deviceId1 + "_" + deviceChannel.getChannelId());
childrenObj.put("slots", JSON.parse("{icon: 'cameraVideo'}"));
children.add(childrenObj);
}
});
});
}
return jsonArray;
}
}

733
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java

@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.storager;
import com.genersoft.iot.vmp.common.Page;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
@ -8,233 +9,245 @@ import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
import com.github.pagehelper.PageInfo;
import java.util.List;
/**
/**
* @description:视频设备数据存储接口
* @author: swwheihei
* @date: 2020年5月6日 下午2:14:31
* @date: 2020年5月6日 下午2:14:31
*/
@SuppressWarnings("rawtypes")
public interface IVideoManagerStorager {
/**
* 根据设备ID判断设备是否存在
*
* @param deviceId 设备ID
* @return true:存在 false不存在
*/
public boolean exists(String deviceId);
/**
* 视频设备创建
*
* @param device 设备对象
* @return true创建成功 false创建失败
*/
public boolean create(Device device);
/**
* 视频设备更新
*
* @param device 设备对象
* @return true创建成功 false创建失败
*/
public boolean updateDevice(Device device);
/**
* 添加设备通道
*
* @param deviceId 设备id
* @param channel 通道
*/
public void updateChannel(String deviceId, DeviceChannel channel);
/**
* 开始播放
* @param deviceId 设备id
* @param channelId 通道ID
* @param streamId 流地址
*/
public void startPlay(String deviceId, String channelId, String streamId);
/**
* 停止播放
* @param deviceId 设备id
* @param channelId 通道ID
*/
public void stopPlay(String deviceId, String channelId);
/**
* 获取设备
*
* @param deviceId 设备ID
* @return DShadow 设备对象
*/
public Device queryVideoDevice(String deviceId);
/**
* 获取某个设备的通道列表
*
* @param deviceId 设备ID
* @param page 分页 当前页
* @param count 每页数量
* @return
*/
public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, int page, int count);
/**
* 获取某个设备的通道列表
*
* @param deviceId 设备ID
* @return
*/
public List<DeviceChannel> queryChannelsByDeviceId(String deviceId);
/**
* 获取某个设备的通道
* @param deviceId 设备ID
* @param channelId 通道ID
*/
public DeviceChannel queryChannel(String deviceId, String channelId);
/**
* 获取多个设备
* @param page 当前页数
* @param count 每页数量
* @return List<Device> 设备对象数组
*/
public PageInfo<Device> queryVideoDeviceList(int page, int count);
/**
* 获取多个设备
*
* @return List<Device> 设备对象数组
*/
public List<Device> queryVideoDeviceList();
/**
* 删除设备
*
* @param deviceId 设备ID
* @return true删除成功 false删除失败
*/
public boolean delete(String deviceId);
/**
* 更新设备在线
*
* @param deviceId 设备ID
* @return true更新成功 false更新失败
*/
public boolean online(String deviceId);
/**
* 更新设备离线
*
* @param deviceId 设备ID
* @return true更新成功 false更新失败
*/
public boolean outline(String deviceId);
/**
* 更新所有设备离线
*
* @return true更新成功 false更新失败
*/
public boolean outlineForAll();
/**
* 查询子设备
*
* @param deviceId
* @param channelId
* @param page
* @param count
* @return
*/
PageInfo querySubChannels(String deviceId, String channelId, String query, Boolean hasSubChannel, String online, int page, int count);
/**
* 清空通道
* @param deviceId
*/
void cleanChannelsForDevice(String deviceId);
/**
* 更新上级平台
* @param parentPlatform
*/
boolean updateParentPlatform(ParentPlatform parentPlatform);
/**
* 添加上级平台
* @param parentPlatform
*/
boolean addParentPlatform(ParentPlatform parentPlatform);
/**
* 删除上级平台
* @param parentPlatform
*/
boolean deleteParentPlatform(ParentPlatform parentPlatform);
/**
* 分页获取上级平台
* @param page
* @param count
* @return
*/
PageInfo<ParentPlatform> queryParentPlatformList(int page, int count);
/**
* 获取所有已启用的平台
* @return
*/
List<ParentPlatform> queryEnableParentPlatformList(boolean enable);
/**
* 获取上级平台
* @param platformGbId
* @return
*/
ParentPlatform queryParentPlatByServerGBId(String platformGbId);
/**
* 所有平台离线
*/
void outlineForAllParentPlatform();
/**
* 查询通道信息不区分设备(已关联平台或全部)
*/
PageInfo<ChannelReduce> queryAllChannelList(int page, int count, String query, Boolean online, Boolean channelType, String platformId, Boolean inPlatform);
/**
* 查询设备的通道信息
*/
List<ChannelReduce> queryChannelListInParentPlatform(String platformId);
/**
* 更新上级平台的通道信息
* @param platformId
* @param channelReduces
* @return
*/
int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces);
/**
* 移除上级平台的通道信息
* @param platformId
* @param channelReduces
* @return
*/
int delChannelForGB(String platformId, List<ChannelReduce> channelReduces);
/**
* 根据设备ID判断设备是否存在
*
* @param deviceId 设备ID
* @return true:存在 false不存在
*/
boolean exists(String deviceId);
/**
* 视频设备创建
*
* @param device 设备对象
* @return true创建成功 false创建失败
*/
boolean create(Device device);
/**
* 视频设备更新
*
* @param device 设备对象
* @return true创建成功 false创建失败
*/
boolean updateDevice(Device device);
/**
* 添加设备通道
*
* @param deviceId 设备id
* @param channel 通道
*/
void updateChannel(String deviceId, DeviceChannel channel);
/**
* 开始播放
*
* @param deviceId 设备id
* @param channelId 通道ID
* @param streamId 流地址
*/
void startPlay(String deviceId, String channelId, String streamId);
/**
* 停止播放
*
* @param deviceId 设备id
* @param channelId 通道ID
*/
void stopPlay(String deviceId, String channelId);
/**
* 获取设备
*
* @param deviceId 设备ID
* @return DShadow 设备对象
*/
Device queryVideoDevice(String deviceId);
/**
* 获取某个设备的通道列表
*
* @param deviceId 设备ID
* @param pageNo 分页 当前页
* @param pageSize 每页数量
* @return
*/
Page<DeviceChannel> queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, int pageNo, int pageSize);
/**
* 获取某个设备的通道列表
*
* @param deviceId 设备ID
* @return
*/
List<DeviceChannel> queryChannelsByDeviceId(String deviceId);
/**
* 获取某个设备的通道
*
* @param deviceId 设备ID
* @param channelId 通道ID
*/
DeviceChannel queryChannel(String deviceId, String channelId);
/**
* 获取多个设备
*
* @param page 当前页数
* @param count 每页数量
* @return List<Device> 设备对象数组
*/
Page<Device> queryVideoDeviceList(int page, int count, Device device);
/**
* 获取多个设备
*
* @return List<Device> 设备对象数组
*/
List<Device> queryVideoDeviceList();
/**
* 删除设备
*
* @param deviceId 设备ID
* @return true删除成功 false删除失败
*/
boolean delete(String deviceId);
/**
* 更新设备在线
*
* @param deviceId 设备ID
* @return true更新成功 false更新失败
*/
boolean online(String deviceId);
/**
* 更新设备离线
*
* @param deviceId 设备ID
* @return true更新成功 false更新失败
*/
boolean outline(String deviceId);
/**
* 更新所有设备离线
*
* @return true更新成功 false更新失败
*/
boolean outlineForAll();
/**
* 查询子设备
*
* @param deviceId
* @param channelId
* @param page
* @param count
* @return
*/
PageInfo querySubChannels(String deviceId, String channelId, String query, Boolean hasSubChannel, String online, int page, int count);
/**
* 清空通道
*
* @param deviceId
*/
void cleanChannelsForDevice(String deviceId);
/**
* 更新上级平台
*
* @param parentPlatform
*/
boolean updateParentPlatform(ParentPlatform parentPlatform);
/**
* 添加上级平台
*
* @param parentPlatform
*/
boolean addParentPlatform(ParentPlatform parentPlatform);
/**
* 删除上级平台
*
* @param parentPlatform
*/
boolean deleteParentPlatform(ParentPlatform parentPlatform);
/**
* 分页获取上级平台
*
* @param page
* @param count
* @return
*/
Page<ParentPlatform> queryParentPlatformList(int page, int count);
/**
* 获取所有已启用的平台
*
* @return
*/
List<ParentPlatform> queryEnableParentPlatformList(boolean enable);
/**
* 获取上级平台
*
* @param platformGbId
* @return
*/
ParentPlatform queryParentPlatByServerGBId(String platformGbId);
/**
* 所有平台离线
*/
void outlineForAllParentPlatform();
/**
* 查询通道信息不区分设备(已关联平台或全部)
*/
PageInfo<ChannelReduce> queryAllChannelList(int page, int count, String query, Boolean online, Boolean channelType, String platformId, Boolean inPlatform);
/**
* 查询设备的通道信息
*/
List<ChannelReduce> queryChannelListInParentPlatform(String platformId);
/**
* 更新上级平台的通道信息
*
* @param platformId
* @param channelReduces
* @return
*/
int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces);
/**
* 移除上级平台的通道信息
*
* @param platformId
* @param channelReduces
* @return
*/
int delChannelForGB(String platformId, List<ChannelReduce> channelReduces);
DeviceChannel queryChannelInParentPlatform(String platformId, String channelId);
@ -242,136 +255,154 @@ public interface IVideoManagerStorager {
Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId);
/**
* 添加Mobile Position设备移动位置
* @param mobilePosition
* @return
*/
public boolean insertMobilePosition(MobilePosition mobilePosition);
/**
* 查询移动位置轨迹
* @param deviceId
* @param startTime
* @param endTime
*/
public List<MobilePosition> queryMobilePositions(String deviceId, String startTime, String endTime);
/**
* 查询最新移动位置
* @param deviceId
*/
public MobilePosition queryLatestPosition(String deviceId);
/**
* 删除指定设备的所有移动位置
* @param deviceId
*/
public int clearMobilePositionsByDeviceId(String deviceId);
/**
* 新增代理流
* @param streamProxyDto
* @return
*/
public boolean addStreamProxy(StreamProxyItem streamProxyDto);
/**
* 更新代理流
* @param streamProxyDto
* @return
*/
public boolean updateStreamProxy(StreamProxyItem streamProxyDto);
/**
* 移除代理流
* @param app
* @param stream
* @return
*/
public int deleteStreamProxy(String app, String stream);
/**
* 按照是否启用获取代理流
* @param enable
* @return
*/
public List<StreamProxyItem> getStreamProxyListForEnable(boolean enable);
/**
* 按照是app和stream获取代理流
* @param app
* @param stream
* @return
*/
public StreamProxyItem queryStreamProxy(String app, String stream);
/**
* 获取代理流
* @param page
* @param count
* @return
*/
PageInfo<StreamProxyItem> queryStreamProxyList(Integer page, Integer count);
/**
* 根据国标ID获取平台关联的直播流
* @param platformId
* @param channelId
* @return
*/
GbStream queryStreamInParentPlatform(String platformId, String channelId);
/**
* 获取平台关联的直播流
* @param platformId
* @return
*/
List<GbStream> queryGbStreamListInPlatform(String platformId);
/**
* 批量更新推流列表
* @param streamPushItems
*/
void updateMediaList(List<StreamPushItem> streamPushItems);
/**
* 更新单个推流
* @param streamPushItem
*/
void updateMedia(StreamPushItem streamPushItem);
/**
* 移除单个推流
* @param app
* @param stream
*/
void removeMedia(String app, String stream);
/**
* 清空推流列表
*/
void clearMediaList();
/**
* 设置流离线
* @param app
* @param streamId
*/
void mediaOutline(String app, String streamId);
/**
* 设置平台在线/离线
* @param online
*/
void updateParentPlatformStatus(String platformGbID, boolean online);
/**
* 更新媒体节点
* @param mediaServerItem
*/
void updateMediaServer(MediaServerItem mediaServerItem);
/**
* 添加Mobile Position设备移动位置
*
* @param mobilePosition
* @return
*/
boolean insertMobilePosition(MobilePosition mobilePosition);
/**
* 查询移动位置轨迹
*
* @param deviceId
* @param startTime
* @param endTime
*/
List<MobilePosition> queryMobilePositions(String deviceId, String startTime, String endTime);
/**
* 查询最新移动位置
*
* @param deviceId
*/
MobilePosition queryLatestPosition(String deviceId);
/**
* 删除指定设备的所有移动位置
*
* @param deviceId
*/
int clearMobilePositionsByDeviceId(String deviceId);
/**
* 新增代理流
*
* @param streamProxyDto
* @return
*/
boolean addStreamProxy(StreamProxyItem streamProxyDto);
/**
* 更新代理流
*
* @param streamProxyDto
* @return
*/
boolean updateStreamProxy(StreamProxyItem streamProxyDto);
/**
* 移除代理流
*
* @param app
* @param stream
* @return
*/
int deleteStreamProxy(String app, String stream);
/**
* 按照是否启用获取代理流
*
* @param enable
* @return
*/
List<StreamProxyItem> getStreamProxyListForEnable(boolean enable);
/**
* 按照是app和stream获取代理流
*
* @param app
* @param stream
* @return
*/
StreamProxyItem queryStreamProxy(String app, String stream);
/**
* 获取代理流
*
* @param page
* @param count
* @return
*/
Page<StreamProxyItem> queryStreamProxyList(Integer page, Integer count, String query, Boolean enable);
/**
* 根据国标ID获取平台关联的直播流
*
* @param platformId
* @param channelId
* @return
*/
GbStream queryStreamInParentPlatform(String platformId, String channelId);
/**
* 获取平台关联的直播流
*
* @param platformId
* @return
*/
List<GbStream> queryGbStreamListInPlatform(String platformId);
/**
* 批量更新推流列表
*
* @param streamPushItems
*/
void updateMediaList(List<StreamPushItem> streamPushItems);
/**
* 更新单个推流
*
* @param streamPushItem
*/
void updateMedia(StreamPushItem streamPushItem);
/**
* 移除单个推流
*
* @param app
* @param stream
*/
void removeMedia(String app, String stream);
/**
* 清空推流列表
*/
void clearMediaList();
/**
* 设置流离线
*
* @param app
* @param streamId
*/
void mediaOutline(String app, String streamId);
/**
* 设置平台在线/离线
*
* @param online
*/
void updateParentPlatformStatus(String platformGbID, boolean online);
/**
* 更新媒体节点
*
* @param mediaServerItem
*/
void updateMediaServer(MediaServerItem mediaServerItem);
/**
* 根据媒体ID获取启用/不启用的代理列表

2
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java

@ -57,7 +57,7 @@ public interface DeviceChannelMapper {
"SELECT * FROM ( "+
" SELECT * , (SELECT count(0) FROM device_channel WHERE parentId=dc.channelId) as subCount FROM device_channel dc " +
" WHERE dc.deviceId=#{deviceId} " +
" <if test=\"query != null\"> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
" <if test=\"query != null\"> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
" <if test=\"parentChannelId != null\"> AND dc.parentId=#{parentChannelId} </if> " +
" <if test=\"online == true\" > AND dc.status=1</if>" +
" <if test=\"online == false\" > AND dc.status=0</if>) dcr" +

11
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java

@ -76,8 +76,15 @@ public interface DeviceMapper {
" </script>"})
int update(Device device);
@Select("SELECT *, (SELECT count(0) FROM device_channel WHERE deviceId=de.deviceId) as channelCount FROM device de")
List<Device> getDevices();
@Select(value = {"<script>" +
"SELECT *, (SELECT count(0) FROM device_channel WHERE deviceId=de.deviceId) as channelCount FROM device de where 1 = 1" +
"<if test=\"name != null\">and name like'%${name}%'</if>" +
"<if test=\"manufacturer != null\">and manufacturer like '%${manufacturer}%'</if>"+
"<if test=\"model != null\">and model like '%${model}%'</if>"+
"<if test=\"online != null\">and online=${online}</if>"+
"</script>"})
List<Device> getDevices(Device device);
@Delete("DELETE FROM device WHERE deviceId=#{deviceId}")
int del(String deviceId);

12
src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java

@ -34,8 +34,16 @@ public interface GbStreamMapper {
@Delete("DELETE FROM gb_stream WHERE app=#{app} AND stream=#{stream}")
int del(String app, String stream);
@Select("SELECT gs.*, pgs.platformId FROM gb_stream gs LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream")
List<GbStream> selectAll();
@Select("<script> " +
"SELECT gs.*, pgs.platformId FROM gb_stream gs LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream " +
"where 1=1 " +
"<if test=\"query != null\"> AND ( " +
"gs.app LIKE '%${query}%' " +
"OR gs.name LIKE '%${query}%' " +
"OR gs.stream LIKE '%${query}%' " +
"OR gs.streamType LIKE '%${query}%' )</if>" +
"</script>")
List<GbStream> selectAll(String query);
@Select("SELECT * FROM gb_stream WHERE app=#{app} AND stream=#{stream}")
StreamProxyItem selectOne(String app, String stream);

10
src/main/java/com/genersoft/iot/vmp/storager/dao/RecordInfoDao.java

@ -1,6 +1,8 @@
package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.storager.dao.dto.RecordInfo;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
@ -22,4 +24,12 @@ public interface RecordInfoDao {
@Select("select * FROM recordInfo")
List<RecordInfo> selectAll();
@Select(value = {"<script> SELECT dc.channelId, dc.deviceId, dc.name, de.manufacturer, de.hostAddress from device_channel dc " +
"LEFT JOIN device de ON dc.deviceId = de.deviceId where 1=1" +
"<if test=\"manufacturer != null and manufacturer!=''\"> AND de.manufacturer LIKE '%${manufacturer}%'</if>" +
"<if test=\"name != null and name!=''\"> AND dc.name LIKE '%${name}%'</if>" +
"<if test=\"deviceId != null and deviceId!=''\"> AND de.deviceId LIKE '%${deviceId}%'</if>" +
"</script>"})
List<ChannelReduce> selectAllChannel(ChannelReduce channelReduce);
}

17
src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java

@ -36,8 +36,21 @@ public interface StreamProxyMapper {
@Delete("DELETE FROM stream_proxy WHERE app=#{app} AND stream=#{stream}")
int del(String app, String stream);
@Select("SELECT st.*, pgs.gbId, pgs.name, pgs.longitude, pgs.latitude FROM stream_proxy st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream order by st.createTime desc")
List<StreamProxyItem> selectAll();
@Select("<script>" +
"SELECT st.*, pgs.gbId, pgs.name, pgs.longitude, pgs.latitude FROM stream_proxy st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream where 1=1" +
" <if test=\"query != null\"> AND (" +
"st.app LIKE '%${query}%' " +
"OR pgs.name LIKE '%${query}%' " +
"OR pgs.gbId LIKE '%${query}%' " +
"OR st.stream LIKE '%${query}%' " +
"OR st.mediaServerId LIKE '%${query}%' " +
"OR st.url LIKE '%${query}%' " +
"OR st.src_url LIKE '%${query}%' " +
"OR st.dst_url LIKE '%${query}%' " +
"OR pgs.streamType LIKE '%${query}%')</if>" +
"<if test=\"enable != null\"> AND st.enable = ${enable} </if> " +
" order by st.createTime desc </script>")
List<StreamProxyItem> selectAll(String query, Boolean enable);
@Select("SELECT st.*, pgs.gbId, pgs.name, pgs.longitude, pgs.latitude FROM stream_proxy st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream WHERE st.enable=${enable} order by st.createTime desc")
List<StreamProxyItem> selectForEnable(boolean enable);

20
src/main/java/com/genersoft/iot/vmp/storager/dao/VideoSquareMapper.java

@ -0,0 +1,20 @@
package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
@Repository
public interface VideoSquareMapper {
@Select("select * FROM device")
List<Device> selectDevices();
@Select("select * from device_channel")
List<DeviceChannel> selectDeviceChannels();
}

1183
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java

File diff suppressed because it is too large

44
src/main/java/com/genersoft/iot/vmp/utils/GitUtil.java

@ -1,44 +0,0 @@
package com.genersoft.iot.vmp.utils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
/**
* 一个优秀的颓废程序猿CSDN
*/
@Component
@PropertySource(value = {"classpath:git.properties" }, ignoreResourceNotFound = true)
public class GitUtil {
@Value("${git.branch:null}")
private String branch;
@Value("${git.commit.id:null}")
private String gitCommitId;
@Value("${git.remote.origin.url:null}")
private String gitUrl;
@Value("${git.build.time:null}")
private String buildDate;
@Value("${git.commit.id.abbrev:null}")
private String commitIdShort;
public String getGitCommitId() {
return gitCommitId;
}
public String getBranch() {
return branch;
}
public String getGitUrl() {
return gitUrl;
}
public String getBuildDate() {
return buildDate;
}
public String getCommitIdShort() {
return commitIdShort;
}
}

73
src/main/java/com/genersoft/iot/vmp/utils/JarFileUtils.java

@ -1,73 +0,0 @@
package com.genersoft.iot.vmp.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.util.ClassUtils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
/**
* 一个优秀的颓废程序猿
*/
@Component
public class JarFileUtils {
private static Logger log = LoggerFactory.getLogger(JarFileUtils.class);
private static Map<String, String> map = new HashMap<>();
public Map<String, String> readJarFile() {
JarFile jarFile = null;
BufferedReader br = null;
try {
// 获取jar的运行路径,因linux下jar的路径为”file:/app/.../test.jar!/BOOT-INF/class!/“这种格式,所以需要去掉”file:“和”!/BOOT-INF/class!/“
String jarFilePath = ClassUtils.getDefaultClassLoader().getResource("").getPath().replace("!/BOOT-INF/classes!/", "");
if (jarFilePath.startsWith("file")) {
jarFilePath = jarFilePath.substring(5);
}
log.debug("jarFilePath:" + jarFilePath);
// 通过JarFile的getJarEntry方法读取META-INF/MANIFEST.MF
jarFile = new JarFile(jarFilePath);
JarEntry entry = jarFile.getJarEntry("META-INF/MANIFEST.MF");
log.info("读取的内容:" + entry.toString());
// 如果读取到MANIFEST.MF文件内容,则转换为string
if (entry != null) {
InputStream in = jarFile.getInputStream(entry);
StringBuilder sb = new StringBuilder();
br = new BufferedReader(new InputStreamReader(in));
String line = "";
while ((line = br.readLine()) != null) {
if (line != null && line.contains(":")) {
int index = line.indexOf(":");
map.put(line.substring(0, index).trim(), line.substring(index + 1, line.length()).trim());
}
}
return map;
}
} catch (IOException e) {
log.debug("读取MANIFEST.MF文件异常:" + e.getMessage());
} finally {
try {
if (null != br) {
br.close();
}
if (null != jarFile) {
jarFile.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return map;
}
}

31
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java

@ -5,6 +5,7 @@ import java.util.UUID;
import javax.sip.message.Response;
import com.genersoft.iot.vmp.common.reponse.ResponseData;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
@ -64,12 +65,12 @@ public class MobilePositionController {
@ApiImplicitParam(name = "end", value = "结束时间", required = true, dataTypeClass = String.class),
})
@GetMapping("/history/{deviceId}")
public ResponseEntity<List<MobilePosition>> positions(@PathVariable String deviceId,
@RequestParam(required = false) String start,
@RequestParam(required = false) String end) {
// if (logger.isDebugEnabled()) {
// logger.debug("查询设备" + deviceId + "的历史轨迹");
// }
public ResponseData positions(@PathVariable String deviceId,
@RequestParam(required = false) String start,
@RequestParam(required = false) String end) {
if (logger.isDebugEnabled()) {
logger.debug("查询设备" + deviceId + "的历史轨迹");
}
if (StringUtil.isEmpty(start)) {
start = null;
@ -79,7 +80,7 @@ public class MobilePositionController {
}
List<MobilePosition> result = storager.queryMobilePositions(deviceId, start, end);
return new ResponseEntity<>(result, HttpStatus.OK);
return ResponseData.success(result);
}
/**
@ -92,12 +93,12 @@ public class MobilePositionController {
@ApiImplicitParam(name = "deviceId", value = "设备ID", required = true, dataTypeClass = String.class),
})
@GetMapping("/latest/{deviceId}")
public ResponseEntity<MobilePosition> latestPosition(@PathVariable String deviceId) {
// if (logger.isDebugEnabled()) {
// logger.debug("查询设备" + deviceId + "的最新位置");
// }
public ResponseData latestPosition(@PathVariable String deviceId) {
if (logger.isDebugEnabled()) {
logger.debug("查询设备" + deviceId + "的最新位置");
}
MobilePosition result = storager.queryLatestPosition(deviceId);
return new ResponseEntity<>(result, HttpStatus.OK);
return ResponseData.success(result);
}
/**
@ -149,7 +150,7 @@ public class MobilePositionController {
@ApiImplicitParam(name = "interval", value = "上报时间间隔", dataTypeClass = String.class),
})
@GetMapping("/subscribe/{deviceId}")
public ResponseEntity<String> positionSubscribe(@PathVariable String deviceId,
public ResponseData positionSubscribe(@PathVariable String deviceId,
@RequestParam String expires,
@RequestParam String interval) {
String msg = ((expires.equals("0")) ? "取消" : "") + "订阅设备" + deviceId + "的移动位置";
@ -165,10 +166,10 @@ public class MobilePositionController {
String result = msg;
if (cmder.mobilePositionSubscribe(device, Integer.parseInt(expires), Integer.parseInt(interval))) {
result += ",成功";
return ResponseData.success(result);
} else {
result += ",失败";
return ResponseData.error(result);
}
return new ResponseEntity<>(result, HttpStatus.OK);
}
}

93
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java

@ -1,15 +1,15 @@
package com.genersoft.iot.vmp.vmanager.gb28181.alarm;
import com.genersoft.iot.vmp.common.Page;
import com.genersoft.iot.vmp.common.reponse.ResponseData;
import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
import com.genersoft.iot.vmp.service.IDeviceAlarmService;
import com.genersoft.iot.vmp.service.IGbStreamService;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@ -19,7 +19,6 @@ import org.springframework.web.bind.annotation.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@Api(tags = "报警信息管理")
@ -34,80 +33,76 @@ public class AlarmController {
private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
/**
* 分页查询报警
* 分页查询报警
*
* @param deviceId 设备id
* @param page 当前页
* @param count 每页查询数量
* @param alarmPriority 报警级别
* @param alarmMethod 报警方式
* @param alarmType 报警类型
* @param startTime 开始时间
* @param endTime 结束时间
* @param pageNo 当前页
* @param pageSize 每页查询数量
* @param deviceId 设备id
* @param alarmPriority 报警级别
* @param alarmMethod 报警方式
* @param alarmType 报警类型
* @param startTime 开始时间
* @param endTime 结束时间
* @return
*/
@ApiOperation("分页查询报警")
@GetMapping("/all")
@ApiImplicitParams({
@ApiImplicitParam(name="deviceId", value = "设备id", dataTypeClass = String.class),
@ApiImplicitParam(name="page", value = "当前页", required = true ,dataTypeClass = Integer.class),
@ApiImplicitParam(name="count", value = "每页查询数量", required = true ,dataTypeClass = Integer.class),
@ApiImplicitParam(name="alarmPriority", value = "查询内容" ,dataTypeClass = String.class),
@ApiImplicitParam(name="alarmMethod", value = "查询内容" ,dataTypeClass = String.class),
@ApiImplicitParam(name="alarmMethod", value = "查询内容" ,dataTypeClass = String.class),
@ApiImplicitParam(name="alarmType", value = "查询内容" ,dataTypeClass = String.class),
@ApiImplicitParam(name="startTime", value = "查询内容" ,dataTypeClass = String.class),
@ApiImplicitParam(name="endTime", value = "查询内容" ,dataTypeClass = String.class),
@ApiImplicitParam(name = "deviceId", value = "设备id", dataTypeClass = String.class),
@ApiImplicitParam(name = "pageNo", value = "当前页", required = true, dataTypeClass = Integer.class),
@ApiImplicitParam(name = "pageSize", value = "每页查询数量", required = true, dataTypeClass = Integer.class),
@ApiImplicitParam(name = "alarmPriority", value = "查询内容", dataTypeClass = String.class),
@ApiImplicitParam(name = "alarmMethod", value = "查询内容", dataTypeClass = String.class),
@ApiImplicitParam(name = "alarmMethod", value = "查询内容", dataTypeClass = String.class),
@ApiImplicitParam(name = "alarmType", value = "查询内容", dataTypeClass = String.class),
@ApiImplicitParam(name = "startTime", value = "查询内容", dataTypeClass = String.class),
@ApiImplicitParam(name = "endTime", value = "查询内容", dataTypeClass = String.class),
})
public ResponseEntity<PageInfo<DeviceAlarm>> getAll(
@RequestParam int page,
@RequestParam int count,
@RequestParam(required = false) String deviceId,
@RequestParam(required = false) String alarmPriority,
@RequestParam(required = false) String alarmMethod,
@RequestParam(required = false) String alarmType,
@RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime
) {
public ResponseData getAll(@RequestParam int pageNo,
@RequestParam int pageSize,
@RequestParam(required = false) String deviceId,
@RequestParam(required = false) String alarmPriority,
@RequestParam(required = false) String alarmMethod,
@RequestParam(required = false) String alarmType,
@RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime) {
if (StringUtils.isEmpty(alarmPriority)) alarmPriority = null;
if (StringUtils.isEmpty(alarmMethod)) alarmMethod = null;
if (StringUtils.isEmpty(alarmType)) alarmType = null;
if (StringUtils.isEmpty(startTime)) startTime = null;
if (StringUtils.isEmpty(endTime)) endTime = null;
try {
if (startTime != null) format.parse(startTime);
if (endTime != null) format.parse(endTime);
if (startTime != null) format.parse(startTime);
if (endTime != null) format.parse(endTime);
} catch (ParseException e) {
return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST);
return ResponseData.error("时间转换错误");
}
PageInfo<DeviceAlarm> allAlarm = deviceAlarmService.getAllAlarm(page, count, deviceId, alarmPriority, alarmMethod,
alarmType, startTime, endTime);
return new ResponseEntity<>(allAlarm, HttpStatus.OK);
PageInfo<DeviceAlarm> allAlarm = deviceAlarmService.getAllAlarm(pageNo, pageSize,
deviceId, alarmPriority, alarmMethod, alarmType, startTime, endTime);
Page<DeviceAlarm> page = new Page<>(allAlarm);
return ResponseData.success(page);
}
/**
* 删除报警
* 删除报警
*
* @param id 报警id
* @param id 报警id
* @param deviceIds 多个设备id,逗号分隔
* @param time 结束时间(这个时间之前的报警会被删除)
* @param time 结束时间(这个时间之前的报警会被删除)
* @return
*/
@ApiOperation("删除报警")
@DeleteMapping("/delete")
@ApiImplicitParams({
@ApiImplicitParam(name="id", value = "ID", required = false ,dataTypeClass = Integer.class),
@ApiImplicitParam(name="deviceIds", value = "多个设备id,逗号分隔", required = false ,dataTypeClass = String.class),
@ApiImplicitParam(name="time", value = "结束时间", required = false ,dataTypeClass = String.class),
@ApiImplicitParam(name = "id", value = "ID", required = false, dataTypeClass = Integer.class),
@ApiImplicitParam(name = "deviceIds", value = "多个设备id,逗号分隔", required = false, dataTypeClass = String.class),
@ApiImplicitParam(name = "time", value = "结束时间", required = false, dataTypeClass = String.class),
})
public ResponseEntity<WVPResult<String>> delete(
@RequestParam(required = false) Integer id,
@RequestParam(required = false) String deviceIds,
@RequestParam(required = false) String time
@RequestParam(required = false) Integer id,
@RequestParam(required = false) String deviceIds,
@RequestParam(required = false) String time
) {
if (StringUtils.isEmpty(id)) id = null;
if (StringUtils.isEmpty(deviceIds)) deviceIds = null;

463
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java

@ -1,6 +1,8 @@
package com.genersoft.iot.vmp.vmanager.gb28181.device;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.Page;
import com.genersoft.iot.vmp.common.reponse.ResponseData;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector;
@ -10,7 +12,6 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@ -33,104 +34,115 @@ import java.util.UUID;
@RestController
@RequestMapping("/api/device/query")
public class DeviceQuery {
private final static Logger logger = LoggerFactory.getLogger(DeviceQuery.class);
@Autowired
private IVideoManagerStorager storager;
@Autowired
private IRedisCatchStorage redisCatchStorage;
@Autowired
private SIPCommander cmder;
@Autowired
private DeferredResultHolder resultHolder;
@Autowired
private DeviceOffLineDetector offLineDetector;
private final static Logger logger = LoggerFactory.getLogger(DeviceQuery.class);
@Autowired
private IDeviceService deviceService;
@Autowired
private IVideoManagerStorager storager;
/**
* 使用ID查询国标设备
* @param deviceId 国标ID
* @return 国标设备
*/
@ApiOperation("使用ID查询国标设备")
@ApiImplicitParams({
@Autowired
private IRedisCatchStorage redisCatchStorage;
@Autowired
private SIPCommander cmder;
@Autowired
private DeferredResultHolder resultHolder;
@Autowired
private DeviceOffLineDetector offLineDetector;
@Autowired
private IDeviceService deviceService;
/**
* 使用ID查询国标设备
* @param deviceId 国标ID
* @return 国标设备
*/
@ApiOperation("使用ID查询国标设备")
@ApiImplicitParams({
@ApiImplicitParam(name = "deviceId", value = "设备ID", required = true, dataTypeClass = String.class),
})
@GetMapping("/devices/{deviceId}")
public ResponseEntity<Device> devices(@PathVariable String deviceId){
// if (logger.isDebugEnabled()) {
// logger.debug("查询视频设备API调用,deviceId:" + deviceId);
// }
Device device = storager.queryVideoDevice(deviceId);
return new ResponseEntity<>(device,HttpStatus.OK);
}
})
@GetMapping("/devices/{deviceId}")
public ResponseEntity<Device> devices(@PathVariable String deviceId) {
/**
* 分页查询国标设备
* @param page 当前页
* @param count 每页查询数量
* @return 分页国标列表
*/
@ApiOperation("分页查询国标设备")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "当前页", required = true, dataTypeClass = Integer.class),
@ApiImplicitParam(name = "count", value = "每页查询数量", required = true, dataTypeClass = Integer.class),
})
@GetMapping("/devices")
public PageInfo<Device> devices(int page, int count){
// if (logger.isDebugEnabled()) {
// logger.debug("查询所有视频设备API调用");
// }
return storager.queryVideoDeviceList(page, count);
}
if (logger.isDebugEnabled()) {
logger.debug("查询视频设备API调用,deviceId:" + deviceId);
}
/**
* 分页查询通道数
*
* @param deviceId 设备id
* @param page 当前页
* @param count 每页条数
* @param query 查询内容
* @param online 是否在线 在线 true / 离线 false
* @param channelType 设备 false/子目录 true
* @return 通道列表
*/
@ApiOperation("分页查询通道")
@GetMapping("/devices/{deviceId}/channels")
@ApiImplicitParams({
@ApiImplicitParam(name="deviceId", value = "设备id", required = true ,dataTypeClass = String.class),
@ApiImplicitParam(name="page", value = "当前页", required = true ,dataTypeClass = Integer.class),
@ApiImplicitParam(name="count", value = "每页查询数量", required = true ,dataTypeClass = Integer.class),
@ApiImplicitParam(name="query", value = "查询内容" ,dataTypeClass = String.class),
@ApiImplicitParam(name="online", value = "是否在线" ,dataTypeClass = Boolean.class),
@ApiImplicitParam(name="channelType", value = "设备/子目录-> false/true" ,dataTypeClass = Boolean.class),
})
public ResponseEntity<PageInfo> channels(@PathVariable String deviceId,
int page, int count,
@RequestParam(required = false) String query,
@RequestParam(required = false) Boolean online,
@RequestParam(required = false) Boolean channelType) {
// if (logger.isDebugEnabled()) {
// logger.debug("查询视频设备通道API调用");
// }
if (StringUtils.isEmpty(query)) {
query = null;
}
Device device = storager.queryVideoDevice(deviceId);
return new ResponseEntity<>(device, HttpStatus.OK);
}
PageInfo pageResult = storager.queryChannelsByDeviceId(deviceId, query, channelType, online, page, count);
return new ResponseEntity<>(pageResult,HttpStatus.OK);
}
/**
* 分页查询国标设备
*
* @param pageNo 当前页
* @param pageSize 每页查询数量
* @return 分页国标列表
*/
@ApiOperation("分页查询国标设备")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNo", value = "当前页", required = true, dataTypeClass = Integer.class),
@ApiImplicitParam(name = "pageSize", value = "每页查询数量", required = true, dataTypeClass = Integer.class),
})
@GetMapping("/devices")
public ResponseData devices(@RequestParam int pageNo,
@RequestParam int pageSize,
String name,
String online,
String manufacturer,
String model) {
if (logger.isDebugEnabled()) {
logger.debug("分页查询国标设备");
}
Device device = new Device();
if (!StringUtils.isEmpty(name)) device.setName(name);
if (!StringUtils.isEmpty(online)) device.setOnline(Integer.parseInt(online));
if (!StringUtils.isEmpty(manufacturer)) device.setManufacturer(manufacturer);
if (!StringUtils.isEmpty(model)) device.setModel(model);
Page<Device> page = storager.queryVideoDeviceList(pageNo, pageSize, device);
return ResponseData.success(page);
}
/**
* 分页查询通道数
*
* @param deviceId 设备id
* @param pageNo 当前页
* @param pageSize 每页条数
* @param query 查询内容
* @param online 是否在线 在线 true / 离线 false
* @param channelType 设备 false/子目录 true
* @return 通道列表
*/
@ApiOperation("分页查询通道")
@GetMapping("/devices/channels")
@ApiImplicitParams({
@ApiImplicitParam(name = "deviceId", value = "设备id", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name = "pageNo", value = "当前页", required = true, dataTypeClass = Integer.class),
@ApiImplicitParam(name = "pageSize", value = "每页查询数量", required = true, dataTypeClass = Integer.class),
@ApiImplicitParam(name = "query", value = "查询内容", dataTypeClass = String.class),
@ApiImplicitParam(name = "online", value = "是否在线", dataTypeClass = Boolean.class),
@ApiImplicitParam(name = "channelType", value = "设备/子目录-> false/true", dataTypeClass = Boolean.class),
})
public ResponseData channels(
@RequestParam String deviceId,
@RequestParam int pageNo,
@RequestParam int pageSize,
@RequestParam(required = false) String query,
@RequestParam(required = false) Boolean online,
@RequestParam(required = false) Boolean channelType) {
if (logger.isDebugEnabled()) {
logger.debug("分页查询通道");
}
if (StringUtils.isEmpty(query)) {
query = null;
}
Page<DeviceChannel> page = storager.queryChannelsByDeviceId(deviceId, query, channelType, online, pageNo, pageSize);
return ResponseData.success(page);
}
/**
* 同步设备通道
@ -174,139 +186,142 @@ public class DeviceQuery {
resultHolder.put(key, uuid, result);
return result;
}
}
/**
* 移除设备
* @param deviceId 设备id
* @return
*/
@ApiOperation("移除设备")
@ApiImplicitParams({
@ApiImplicitParam(name="deviceId", value = "设备id", required = true, dataTypeClass = String.class),
})
@DeleteMapping("/devices/{deviceId}/delete")
public ResponseEntity<String> delete(@PathVariable String deviceId){
if (logger.isDebugEnabled()) {
logger.debug("设备信息删除API调用,deviceId:" + deviceId);
}
if (offLineDetector.isOnline(deviceId)) {
return new ResponseEntity<String>("不允许删除在线设备!", HttpStatus.NOT_ACCEPTABLE);
}
// 清除redis记录
boolean isSuccess = storager.delete(deviceId);
if (isSuccess) {
redisCatchStorage.clearCatchByDeviceId(deviceId);
JSONObject json = new JSONObject();
json.put("deviceId", deviceId);
return new ResponseEntity<>(json.toString(),HttpStatus.OK);
} else {
logger.warn("设备信息删除API调用失败!");
return new ResponseEntity<String>("设备信息删除API调用失败!", HttpStatus.INTERNAL_SERVER_ERROR);
}
}
/**
* 移除设备
*
* @param deviceId 设备id
* @return
*/
@ApiOperation("移除设备")
@ApiImplicitParams({
@ApiImplicitParam(name = "deviceId", value = "设备id", required = true, dataTypeClass = String.class),
})
@DeleteMapping("/devices/{deviceId}/delete")
public ResponseEntity<String> delete(@PathVariable String deviceId) {
/**
* 分页查询子目录通道
* @param deviceId 通道id
* @param channelId 通道id
* @param page 当前页
* @param count 每页条数
* @param query 查询内容
* @param online 是否在线
* @param channelType 通道类型
* @return 子通道列表
*/
@ApiOperation("分页查询子目录通道")
@ApiImplicitParams({
@ApiImplicitParam(name="deviceId", value = "设备id", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name="channelId", value = "通道id", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name="page", value = "当前页", required = true, dataTypeClass = Integer.class),
@ApiImplicitParam(name="count", value = "每页条数", required = true, dataTypeClass = Integer.class),
@ApiImplicitParam(name="query", value = "查询内容", dataTypeClass = String.class),
@ApiImplicitParam(name="online", value = "是否在线", dataTypeClass = String.class),
@ApiImplicitParam(name="channelType", value = "通道类型, 子目录", dataTypeClass = Boolean.class),
})
@GetMapping("/sub_channels/{deviceId}/{channelId}/channels")
public ResponseEntity<PageInfo> subChannels(@PathVariable String deviceId,
@PathVariable String channelId,
int page,
int count,
@RequestParam(required = false) String query,
@RequestParam(required = false) String online,
@RequestParam(required = false) Boolean channelType){
if (logger.isDebugEnabled()) {
logger.debug("设备信息删除API调用,deviceId:" + deviceId);
}
// if (logger.isDebugEnabled()) {
// logger.debug("查询所有视频通道API调用");
// }
DeviceChannel deviceChannel = storager.queryChannel(deviceId,channelId);
if (deviceChannel == null) {
PageInfo<DeviceChannel> deviceChannelPageResult = new PageInfo<>();
return new ResponseEntity<>(deviceChannelPageResult,HttpStatus.OK);
}
if (offLineDetector.isOnline(deviceId)) {
return new ResponseEntity<String>("不允许删除在线设备!", HttpStatus.NOT_ACCEPTABLE);
}
// 清除redis记录
boolean isSuccess = storager.delete(deviceId);
if (isSuccess) {
redisCatchStorage.clearCatchByDeviceId(deviceId);
JSONObject json = new JSONObject();
json.put("deviceId", deviceId);
return new ResponseEntity<>(json.toString(), HttpStatus.OK);
} else {
logger.warn("设备信息删除API调用失败!");
return new ResponseEntity<String>("设备信息删除API调用失败!", HttpStatus.INTERNAL_SERVER_ERROR);
}
}
PageInfo pageResult = storager.querySubChannels(deviceId, channelId, query, channelType, online, page, count);
return new ResponseEntity<>(pageResult,HttpStatus.OK);
}
/**
* 分页查询子目录通道
*
* @param deviceId 通道id
* @param channelId 通道id
* @param page 当前页
* @param count 每页条数
* @param query 查询内容
* @param online 是否在线
* @param channelType 通道类型
* @return 子通道列表
*/
@ApiOperation("分页查询子目录通道")
@ApiImplicitParams({
@ApiImplicitParam(name = "deviceId", value = "设备id", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name = "channelId", value = "通道id", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name = "page", value = "当前页", required = true, dataTypeClass = Integer.class),
@ApiImplicitParam(name = "count", value = "每页条数", required = true, dataTypeClass = Integer.class),
@ApiImplicitParam(name = "query", value = "查询内容", dataTypeClass = String.class),
@ApiImplicitParam(name = "online", value = "是否在线", dataTypeClass = String.class),
@ApiImplicitParam(name = "channelType", value = "通道类型, 子目录", dataTypeClass = Boolean.class),
})
@GetMapping("/sub_channels/{deviceId}/{channelId}/channels")
public ResponseEntity<PageInfo> subChannels(@PathVariable String deviceId,
@PathVariable String channelId,
int page,
int count,
@RequestParam(required = false) String query,
@RequestParam(required = false) String online,
@RequestParam(required = false) Boolean channelType) {
/**
* 更新通道信息
* @param deviceId 设备id
* @param channel 通道
* @return
*/
@ApiOperation("更新通道信息")
@ApiImplicitParams({
@ApiImplicitParam(name="deviceId", value = "设备id", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name="channel", value = "通道", required = true, dataTypeClass = String.class),
})
@PostMapping("/channel/update/{deviceId}")
public ResponseEntity<PageInfo> updateChannel(@PathVariable String deviceId,DeviceChannel channel){
storager.updateChannel(deviceId, channel);
return new ResponseEntity<>(null,HttpStatus.OK);
}
if (logger.isDebugEnabled()) {
logger.debug("查询所有视频通道API调用");
}
DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
if (deviceChannel == null) {
PageInfo<DeviceChannel> deviceChannelPageResult = new PageInfo<>();
return new ResponseEntity<>(deviceChannelPageResult, HttpStatus.OK);
}
/**
* 修改数据流传输模式
* @param deviceId 设备id
* @param streamMode 数据流传输模式
* @return
*/
@ApiOperation("修改数据流传输模式")
@ApiImplicitParams({
@ApiImplicitParam(name = "deviceId", value = "设备id", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name = "streamMode", value = "数据流传输模式, 取值:" +
"UDP(udp传输),TCP-ACTIVE(tcp主动模式,暂不支持),TCP-PASSIVE(tcp被动模式)", dataTypeClass = String.class),
})
@PostMapping("/transport/{deviceId}/{streamMode}")
public ResponseEntity<PageInfo> updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){
Device device = storager.queryVideoDevice(deviceId);
device.setStreamMode(streamMode);
storager.updateDevice(device);
return new ResponseEntity<>(null,HttpStatus.OK);
}
PageInfo pageResult = storager.querySubChannels(deviceId, channelId, query, channelType, online, page, count);
return new ResponseEntity<>(pageResult, HttpStatus.OK);
}
/**
* 更新设备信息
* @param device 设备信息
* @return
*/
@ApiOperation("更新设备信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "device", value = "设备信息", required = true, dataTypeClass = Device.class)
})
@PostMapping("/device/update/")
public ResponseEntity<WVPResult<String>> updateDevice(Device device){
/**
* 更新通道信息
*
* @param deviceId 设备id
* @param channel 通道
* @return
*/
@ApiOperation("更新通道信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "deviceId", value = "设备id", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name = "channel", value = "通道", required = true, dataTypeClass = String.class),
})
@PostMapping("/channel/update/{deviceId}")
public ResponseData updateChannel(@PathVariable String deviceId, @RequestBody DeviceChannel channel) {
storager.updateChannel(deviceId, channel);
return ResponseData.success();
}
if (device != null && device.getDeviceId() != null) {
Device deviceInStore = storager.queryVideoDevice(device.getDeviceId());
if (!StringUtils.isEmpty(device.getName())) deviceInStore.setName(device.getName());
if (!StringUtils.isEmpty(device.getCharset())) deviceInStore.setCharset(device.getCharset());
if (!StringUtils.isEmpty(device.getMediaServerId())) deviceInStore.setMediaServerId(device.getMediaServerId());
/**
* 修改数据流传输模式
*
* @param deviceId 设备id
* @param streamMode 数据流传输模式
* @return
*/
@ApiOperation("修改数据流传输模式")
@ApiImplicitParams({
@ApiImplicitParam(name = "deviceId", value = "设备id", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name = "streamMode", value = "数据流传输模式, 取值:" +
"UDP(udp传输),TCP-ACTIVE(tcp主动模式,暂不支持),TCP-PASSIVE(tcp被动模式)", dataTypeClass = String.class),
})
@PostMapping("/transport/{deviceId}/{streamMode}")
public ResponseEntity<PageInfo> updateTransport(@PathVariable String deviceId, @PathVariable String streamMode) {
Device device = storager.queryVideoDevice(deviceId);
device.setStreamMode(streamMode);
storager.updateDevice(device);
return new ResponseEntity<>(null, HttpStatus.OK);
}
if (deviceInStore.getSubscribeCycleForCatalog() <=0 && device.getSubscribeCycleForCatalog() > 0) {
/**
* 更新设备信息
*
* @param device 设备信息
* @return
*/
@ApiOperation("更新设备信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "device", value = "设备信息", required = true, dataTypeClass = Device.class)
})
@PostMapping("/device/update/")
public ResponseData updateDevice(@RequestBody Device device) {
if (device != null && device.getDeviceId() != null) {
Device deviceInStore = storager.queryVideoDevice(device.getDeviceId());
if (!StringUtils.isEmpty(device.getName())) deviceInStore.setName(device.getName());
if (!StringUtils.isEmpty(device.getCharset())) deviceInStore.setCharset(device.getCharset());
if (!StringUtils.isEmpty(device.getMediaServerId())) deviceInStore.setMediaServerId(device.getMediaServerId());
if (deviceInStore.getSubscribeCycleForCatalog() <=0 && device.getSubscribeCycleForCatalog() > 0) {
deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog());
// 开启订阅
deviceService.addCatalogSubscribe(deviceInStore);
@ -316,15 +331,11 @@ public class DeviceQuery {
// 取消订阅
deviceService.removeCatalogSubscribe(deviceInStore);
}
storager.updateDevice(deviceInStore);
cmder.deviceInfoQuery(deviceInStore);
}
WVPResult<String> result = new WVPResult<>();
result.setCode(0);
result.setMsg("success");
return new ResponseEntity<>(result,HttpStatus.OK);
}
cmder.deviceInfoQuery(deviceInStore);
}
return ResponseData.success();
}
/**
* 设备状态查询请求API接口
@ -387,8 +398,8 @@ public class DeviceQuery {
})
@GetMapping("/alarm/{deviceId}")
public DeferredResult<ResponseEntity<String>> alarmApi(@PathVariable String deviceId,
@RequestParam(required = false) String startPriority,
@RequestParam(required = false) String endPriority,
@RequestParam(required = false) String startPriority,
@RequestParam(required = false) String endPriority,
@RequestParam(required = false) String alarmMethod,
@RequestParam(required = false) String alarmType,
@RequestParam(required = false) String startTime,

30
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java

@ -1,5 +1,7 @@
package com.genersoft.iot.vmp.vmanager.gb28181.gbStream;
import com.genersoft.iot.vmp.common.Page;
import com.genersoft.iot.vmp.common.reponse.ResponseData;
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.genersoft.iot.vmp.vmanager.gb28181.gbStream.bean.GbStreamParam;
@ -31,26 +33,31 @@ public class GbStreamController {
/**
* 查询国标通道
* @param page 当前页
* @param count 每页条数
*
* @param pageNo 当前页
* @param pageSize 每页条数
* @return
*/
@ApiOperation("查询国标通道")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "当前页", required = true , dataTypeClass = Integer.class),
@ApiImplicitParam(name = "count", value = "每页条数", required = true , dataTypeClass = Integer.class),
@ApiImplicitParam(name = "pageNo", value = "当前页", required = true, dataTypeClass = Integer.class),
@ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, dataTypeClass = Integer.class),
})
@GetMapping(value = "/list")
@ResponseBody
public PageInfo<GbStream> list(@RequestParam(required = false)Integer page,
@RequestParam(required = false)Integer count){
public ResponseData list(@RequestParam(required = false) Integer pageNo,
@RequestParam(required = false) Integer pageSize,
@RequestParam(required = false) String query) {
return gbStreamService.getAll(page, count);
PageInfo<GbStream> pageInfo = gbStreamService.getAll(pageNo, pageSize, query);
Page<GbStream> newPage = new Page<>(pageInfo);
return ResponseData.success(newPage);
}
/**
* 移除国标关联
*
* @param gbStreamParam
* @return
*/
@ -61,10 +68,10 @@ public class GbStreamController {
})
@DeleteMapping(value = "/del")
@ResponseBody
public Object del(@RequestBody GbStreamParam gbStreamParam){
public Object del(@RequestBody GbStreamParam gbStreamParam) {
if (gbStreamService.delPlatformInfo(gbStreamParam.getGbStreams())) {
return "success";
}else {
} else {
return "fail";
}
@ -72,6 +79,7 @@ public class GbStreamController {
/**
* 保存国标关联
*
* @param gbStreamParam
* @return
*/
@ -81,10 +89,10 @@ public class GbStreamController {
})
@PostMapping(value = "/add")
@ResponseBody
public Object add(@RequestBody GbStreamParam gbStreamParam){
public Object add(@RequestBody GbStreamParam gbStreamParam) {
if (gbStreamService.addPlatformInfo(gbStreamParam.getGbStreams(), gbStreamParam.getPlatformId())) {
return "success";
}else {
} else {
return "fail";
}
}

49
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java

@ -1,6 +1,8 @@
package com.genersoft.iot.vmp.vmanager.gb28181.platform;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.Page;
import com.genersoft.iot.vmp.common.reponse.ResponseData;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
@ -61,22 +63,23 @@ public class PlatformController {
/**
* 分页查询级联平台
* @param page 当前页
* @param count 每页条数
* @param pageNo 当前页
* @param pageSize 每页条数
* @return
*/
@ApiOperation("分页查询级联平台")
@GetMapping("/query/{count}/{page}")
@GetMapping("/query/{pageSize}/{pageNo}")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "当前页", dataTypeClass = Integer.class),
@ApiImplicitParam(name = "count", value = "每页条数", dataTypeClass = Integer.class),
@ApiImplicitParam(name = "pageNo", value = "当前页", dataTypeClass = Integer.class),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataTypeClass = Integer.class),
})
public PageInfo<ParentPlatform> platforms(@PathVariable int page, @PathVariable int count){
public ResponseData platforms(@PathVariable int pageNo, @PathVariable int pageSize){
// if (logger.isDebugEnabled()) {
// logger.debug("查询所有上级设备API调用");
// }
return storager.queryParentPlatformList(page, count);
if (logger.isDebugEnabled()) {
logger.debug("查询所有上级设备API调用");
}
Page<ParentPlatform> parentPlatformPage = storager.queryParentPlatformList(pageNo, pageSize);
return ResponseData.success(parentPlatformPage);
}
/**
@ -187,9 +190,9 @@ public class PlatformController {
@ResponseBody
public ResponseEntity<String> exitPlatform(@PathVariable String serverGBId){
// if (logger.isDebugEnabled()) {
// logger.debug("查询上级平台是否存在API调用:" + serverGBId);
// }
if (logger.isDebugEnabled()) {
logger.debug("查询上级平台是否存在API调用:" + serverGBId);
}
ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(serverGBId);
return new ResponseEntity<>(String.valueOf(parentPlatform != null), HttpStatus.OK);
}
@ -207,8 +210,8 @@ public class PlatformController {
*/
@ApiOperation("分页查询级联平台的所有所有通道")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "当前页", dataTypeClass = Integer.class),
@ApiImplicitParam(name = "count", value = "每页条数", dataTypeClass = Integer.class),
@ApiImplicitParam(name = "pageNo", value = "当前页", dataTypeClass = Integer.class),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataTypeClass = Integer.class),
@ApiImplicitParam(name = "platformId", value = "上级平台ID", dataTypeClass = String.class),
@ApiImplicitParam(name = "query", value = "查询内容", dataTypeClass = String.class),
@ApiImplicitParam(name = "online", value = "是否在线", dataTypeClass = Boolean.class),
@ -217,24 +220,24 @@ public class PlatformController {
})
@GetMapping("/channel_list")
@ResponseBody
public PageInfo<ChannelReduce> channelList(int page, int count,
public ResponseData channelList(int pageNo, int pageSize,
@RequestParam(required = false) String platformId,
@RequestParam(required = false) String query,
@RequestParam(required = false) Boolean online,
@RequestParam(required = false) Boolean choosed,
@RequestParam(required = false) Boolean channelType){
// if (logger.isDebugEnabled()) {
// logger.debug("查询所有所有通道API调用");
// }
if (logger.isDebugEnabled()) {
logger.debug("查询所有所有通道API调用");
}
PageInfo<ChannelReduce> channelReduces = null;
if (platformId != null ) {
channelReduces = storager.queryAllChannelList(page, count, query, online, channelType, platformId, choosed);
channelReduces = storager.queryAllChannelList(pageNo, pageSize, query, online, channelType, platformId, choosed);
}else {
channelReduces = storager.queryAllChannelList(page, count, query, online, channelType, null, false);
channelReduces = storager.queryAllChannelList(pageNo, pageSize, query, online, channelType, null, false);
}
return channelReduces;
Page<ChannelReduce> newPage = new Page<>(channelReduces);
return ResponseData.success(newPage);
}
/**

7
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platformGbStream/PlatformGbStreamController.java

@ -34,10 +34,11 @@ public class PlatformGbStreamController {
})
@GetMapping(value = "/list")
@ResponseBody
public PageInfo<GbStream> list(@RequestParam(required = false)Integer page,
@RequestParam(required = false)Integer count){
public PageInfo<GbStream> list(@RequestParam(required = false) Integer page,
@RequestParam(required = false) Integer count,
@RequestParam(required = false) String query) {
return gbStreamService.getAll(page, count);
return gbStreamService.getAll(page, count, query);
}

19
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java

@ -24,12 +24,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
@ -81,15 +76,13 @@ public class PlayController {
@ApiImplicitParam(name = "deviceId", value = "设备ID", dataTypeClass = String.class),
@ApiImplicitParam(name = "channelId", value = "通道ID", dataTypeClass = String.class),
})
@GetMapping("/start/{deviceId}/{channelId}")
public DeferredResult<ResponseEntity<String>> play(@PathVariable String deviceId,
@PathVariable String channelId) {
// 获取可用的zlm
Device device = storager.queryVideoDevice(deviceId);
@GetMapping("/start")
public DeferredResult<ResponseEntity<String>> play(
@RequestParam String deviceId,
@RequestParam String channelId) {
Device device = storager.queryVideoDevice(deviceId);// 获取可用的zlm
MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device);
PlayResult playResult = playService.play(newMediaServerItem, deviceId, channelId, null, null);
return playResult.getResult();
}

9
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java

@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.vmanager.gb28181.ptz;
import com.genersoft.iot.vmp.common.reponse.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@ -60,7 +61,7 @@ public class PtzController {
@ApiImplicitParam(name = "zoomSpeed", value = "缩放速度", dataTypeClass = Integer.class),
})
@PostMapping("/control/{deviceId}/{channelId}")
public ResponseEntity<String> ptz(@PathVariable String deviceId,@PathVariable String channelId, String command, int horizonSpeed, int verticalSpeed, int zoomSpeed){
public ResponseData ptz(@PathVariable String deviceId,@PathVariable String channelId, String command, int horizonSpeed, int verticalSpeed, int zoomSpeed){
if (logger.isDebugEnabled()) {
logger.debug(String.format("设备云台控制 API调用,deviceId:%s ,channelId:%s ,command:%s ,horizonSpeed:%d ,verticalSpeed:%d ,zoomSpeed:%d",deviceId, channelId, command, horizonSpeed, verticalSpeed, zoomSpeed));
@ -105,7 +106,7 @@ public class PtzController {
break;
}
cmder.frontEndCmd(device, channelId, cmdCode, horizonSpeed, verticalSpeed, zoomSpeed);
return new ResponseEntity<String>("success",HttpStatus.OK);
return ResponseData.success("success");
}
@ApiOperation("通用前端控制命令")
@ -118,7 +119,7 @@ public class PtzController {
@ApiImplicitParam(name = "combindCode2", value = "组合码二", dataTypeClass = Integer.class),
})
@PostMapping("/front_end_command/{deviceId}/{channelId}")
public ResponseEntity<String> frontEndCommand(@PathVariable String deviceId,@PathVariable String channelId,int cmdCode, int parameter1, int parameter2, int combindCode2){
public ResponseData frontEndCommand(@PathVariable String deviceId, @PathVariable String channelId, int cmdCode, int parameter1, int parameter2, int combindCode2){
if (logger.isDebugEnabled()) {
logger.debug(String.format("设备云台控制 API调用,deviceId:%s ,channelId:%s ,cmdCode:%d parameter1:%d parameter2:%d",deviceId, channelId, cmdCode, parameter1, parameter2));
@ -126,7 +127,7 @@ public class PtzController {
Device device = storager.queryVideoDevice(deviceId);
cmder.frontEndCmd(device, channelId, cmdCode, parameter1, parameter2, combindCode2);
return new ResponseEntity<String>("success",HttpStatus.OK);
return ResponseData.success();
}
@ApiOperation("预置位查询")

74
src/main/java/com/genersoft/iot/vmp/vmanager/record/RecordController.java

@ -1,51 +1,23 @@
//package com.genersoft.iot.vmp.vmanager.record;
//
//import com.alibaba.fastjson.JSONObject;
//import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
//import com.genersoft.iot.vmp.service.IRecordInfoServer;
//import com.genersoft.iot.vmp.storager.dao.dto.RecordInfo;
//import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
//import com.github.pagehelper.PageInfo;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//
//@Api(tags = "云端录像")
//@CrossOrigin
//@RestController
//@RequestMapping("/api/record")
//public class RecordController {
//
// @Autowired
// private IRecordInfoServer recordInfoServer;
//
// @ApiOperation("录像列表查询")
// @ApiImplicitParams({
// @ApiImplicitParam(name="page", value = "当前页", required = true, dataTypeClass = Integer.class),
// @ApiImplicitParam(name="count", value = "每页查询数量", required = true, dataTypeClass = Integer.class),
// @ApiImplicitParam(name="query", value = "查询内容", dataTypeClass = String.class),
// })
// @GetMapping(value = "/app/list")
// @ResponseBody
// public Object list(@RequestParam(required = false)Integer page,
// @RequestParam(required = false)Integer count ){
//
// PageInfo<RecordInfo> recordList = recordInfoServer.getRecordList(page - 1, page - 1 + count);
// return recordList;
// }
//
// @ApiOperation("获取录像详情")
// @ApiImplicitParams({
// @ApiImplicitParam(name="recordInfo", value = "录像记录", required = true, dataTypeClass = RecordInfo.class)
// })
// @GetMapping(value = "/detail")
// @ResponseBody
// public JSONObject list(RecordInfo recordInfo, String time ){
//
//
// return null;
// }
//}
package com.genersoft.iot.vmp.vmanager.record;
import com.genersoft.iot.vmp.common.reponse.ResponseData;
import com.genersoft.iot.vmp.service.IRecordInfoServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@RestController
@RequestMapping("/api/record")
public class RecordController {
@Autowired
private IRecordInfoServer recordInfoServer;
@PostMapping(value = "/resetRecords")
@ResponseBody
public ResponseData resetRecords(@RequestBody Map<String, Object> params) {
return recordInfoServer.resetRecords(params);
}
}

81
src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java

@ -3,10 +3,10 @@ package com.genersoft.iot.vmp.vmanager.server;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.VManageBootstrap;
import com.genersoft.iot.vmp.common.VersionPo;
import com.genersoft.iot.vmp.common.reponse.ResponseData;
import com.genersoft.iot.vmp.common.reponse.SuccessResponseData;
import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.conf.UserSetup;
import com.genersoft.iot.vmp.conf.VersionInfo;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.utils.SpringBeanFactory;
@ -18,32 +18,26 @@ import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.sip.ListeningPoint;
import javax.sip.ObjectInUseException;
import javax.sip.SipProvider;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@SuppressWarnings("rawtypes")
@Api(tags = "服务控制")
@CrossOrigin
@RestController
@RequestMapping("/api/server")
public class ServerController {
@Autowired
private ConfigurableApplicationContext context;
@Autowired
private IMediaServerService mediaServerService;
@Autowired
VersionInfo versionInfo;
@Autowired
SipConfig sipConfig;
@ -57,7 +51,7 @@ public class ServerController {
@ApiOperation("流媒体服务列表")
@GetMapping(value = "/media_server/list")
@ResponseBody
public WVPResult<List<MediaServerItem>> getMediaServerList(boolean detail){
public WVPResult<List<MediaServerItem>> getMediaServerList(boolean detail) {
List<MediaServerItem> all = mediaServerService.getAll();
WVPResult<List<MediaServerItem>> result = new WVPResult<>();
@ -68,20 +62,17 @@ public class ServerController {
}
@ApiOperation("在线流媒体服务列表")
@GetMapping(value = "/media_server/online/list")
@GetMapping(value = "/mediaServer/online/list")
@ResponseBody
public WVPResult<List<MediaServerItem>> getOnlineMediaServerList(){
WVPResult<List<MediaServerItem>> result = new WVPResult<>();
result.setCode(0);
result.setMsg("success");
result.setData(mediaServerService.getAllOnline());
return result;
public ResponseData getOnlineMediaServerList() {
return new SuccessResponseData(mediaServerService.getAllOnline());
}
@ApiOperation("获取流媒体服务")
@GetMapping(value = "/media_server/one/{id}")
@ResponseBody
public WVPResult<MediaServerItem> getMediaServer(@PathVariable String id){
public WVPResult<MediaServerItem> getMediaServer(@PathVariable String id) {
WVPResult<MediaServerItem> result = new WVPResult<>();
result.setCode(0);
result.setMsg("success");
@ -91,32 +82,32 @@ public class ServerController {
@ApiOperation("测试流媒体服务")
@ApiImplicitParams({
@ApiImplicitParam(name="ip", value = "流媒体服务IP", dataTypeClass = String.class),
@ApiImplicitParam(name="port", value = "流媒体服务HTT端口", dataTypeClass = Integer.class),
@ApiImplicitParam(name="secret", value = "流媒体服务secret", dataTypeClass = String.class),
@ApiImplicitParam(name = "ip", value = "流媒体服务IP", dataTypeClass = String.class),
@ApiImplicitParam(name = "port", value = "流媒体服务HTT端口", dataTypeClass = Integer.class),
@ApiImplicitParam(name = "secret", value = "流媒体服务secret", dataTypeClass = String.class),
})
@GetMapping(value = "/media_server/check")
@ResponseBody
public WVPResult<MediaServerItem> checkMediaServer(@RequestParam String ip, @RequestParam int port, @RequestParam String secret){
public WVPResult<MediaServerItem> checkMediaServer(@RequestParam String ip, @RequestParam int port, @RequestParam String secret) {
return mediaServerService.checkMediaServer(ip, port, secret);
}
@ApiOperation("测试流媒体录像管理服务")
@ApiImplicitParams({
@ApiImplicitParam(name="ip", value = "流媒体服务IP", dataTypeClass = String.class),
@ApiImplicitParam(name="port", value = "流媒体服务HTT端口", dataTypeClass = Integer.class),
@ApiImplicitParam(name="secret", value = "流媒体服务secret", dataTypeClass = String.class),
@ApiImplicitParam(name = "ip", value = "流媒体服务IP", dataTypeClass = String.class),
@ApiImplicitParam(name = "port", value = "流媒体服务HTT端口", dataTypeClass = Integer.class),
@ApiImplicitParam(name = "secret", value = "流媒体服务secret", dataTypeClass = String.class),
})
@GetMapping(value = "/media_server/record/check")
@ResponseBody
public WVPResult<String> checkMediaRecordServer(@RequestParam String ip, @RequestParam int port){
public WVPResult<String> checkMediaRecordServer(@RequestParam String ip, @RequestParam int port) {
boolean checkResult = mediaServerService.checkMediaRecordServer(ip, port);
WVPResult<String> result = new WVPResult<>();
if (checkResult) {
result.setCode(0);
result.setMsg("success");
}else {
} else {
result.setCode(-1);
result.setMsg("连接失败");
}
@ -125,7 +116,7 @@ public class ServerController {
@ApiOperation("保存流媒体服务")
@ApiImplicitParams({
@ApiImplicitParam(name="mediaServerItem", value = "流媒体信息", dataTypeClass = MediaServerItem.class)
@ApiImplicitParam(name = "mediaServerItem", value = "流媒体信息", dataTypeClass = MediaServerItem.class)
})
@PostMapping(value = "/media_server/save")
@ResponseBody
@ -144,7 +135,6 @@ public class ServerController {
}
return mediaServerService.add(mediaServerItem);
}
WVPResult<String> result = new WVPResult<>();
result.setCode(0);
result.setMsg("success");
@ -153,14 +143,14 @@ public class ServerController {
@ApiOperation("移除流媒体服务")
@ApiImplicitParams({
@ApiImplicitParam(name="id", value = "流媒体ID", dataTypeClass = String.class)
@ApiImplicitParam(name = "id", value = "流媒体ID", dataTypeClass = String.class)
})
@DeleteMapping(value = "/media_server/delete")
@ResponseBody
public WVPResult<String> deleteMediaServer(@RequestParam String id){
public WVPResult<String> deleteMediaServer(@RequestParam String id) {
if (mediaServerService.getOne(id) != null) {
mediaServerService.delete(id);
}else {
} else {
WVPResult<String> result = new WVPResult<>();
result.setCode(-1);
result.setMsg("未找到此节点");
@ -173,18 +163,17 @@ public class ServerController {
}
@ApiOperation("重启服务")
@GetMapping(value = "/restart")
@ResponseBody
public Object restart(){
public Object restart() {
Thread restartThread = new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(3000);
SipProvider up = (SipProvider) SpringBeanFactory.getBean("udpSipProvider");
SipStackImpl stack = (SipStackImpl)up.getSipStack();
SipStackImpl stack = (SipStackImpl) up.getSipStack();
stack.stop();
Iterator listener = stack.getListeningPoints();
while (listener.hasNext()) {
@ -210,21 +199,21 @@ public class ServerController {
@ApiOperation("版本信息")
@GetMapping(value = "/version")
@ResponseBody
public WVPResult<VersionPo> getVersion(){
WVPResult<VersionPo> result = new WVPResult<>();
result.setCode(0);
result.setMsg("success");
result.setData(versionInfo.getVersion());
return result;
public Map<String, Object> getVersion() {
Map<String, Object> map = new HashMap<>();
map.put("code", 0);
map.put("msg", "success");
map.put("data", null);
return map;
}
@ApiOperation("配置信息")
@GetMapping(value = "/config")
@ApiImplicitParams({
@ApiImplicitParam(name="type", value = "配置类型(sip, base)", dataTypeClass = String.class),
@ApiImplicitParam(name = "type", value = "配置类型(sip, base)", dataTypeClass = String.class),
})
@ResponseBody
public WVPResult<JSONObject> getVersion(String type){
public WVPResult<JSONObject> getVersion(String type) {
WVPResult<JSONObject> result = new WVPResult<>();
result.setCode(0);
result.setMsg("success");
@ -234,8 +223,8 @@ public class ServerController {
if (StringUtils.isEmpty(type)) {
jsonObject.put("sip", JSON.toJSON(sipConfig));
jsonObject.put("base", JSON.toJSON(userSetup));
}else {
switch (type){
} else {
switch (type) {
case "sip":
jsonObject.put("sip", sipConfig);
break;

17
src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java

@ -1,6 +1,7 @@
package com.genersoft.iot.vmp.vmanager.streamProxy;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.reponse.ResponseData;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
import com.genersoft.iot.vmp.service.IMediaServerService;
@ -44,19 +45,19 @@ public class StreamProxyController {
@ApiOperation("分页查询流代理")
@ApiImplicitParams({
@ApiImplicitParam(name="page", value = "当前页", required = true, dataTypeClass = Integer.class),
@ApiImplicitParam(name="count", value = "每页查询数量", required = true, dataTypeClass = Integer.class),
@ApiImplicitParam(name="pageNo", value = "当前页", required = true, dataTypeClass = Integer.class),
@ApiImplicitParam(name="pageSize", value = "每页查询数量", required = true, dataTypeClass = Integer.class),
@ApiImplicitParam(name="query", value = "查询内容", dataTypeClass = String.class),
@ApiImplicitParam(name="online", value = "是否在线", dataTypeClass = Boolean.class),
@ApiImplicitParam(name="enable", value = "是否启用", dataTypeClass = Boolean.class),
})
@GetMapping(value = "/list")
@ResponseBody
public PageInfo<StreamProxyItem> list(@RequestParam(required = false)Integer page,
@RequestParam(required = false)Integer count,
@RequestParam(required = false)String query,
@RequestParam(required = false)Boolean online ){
public ResponseData list(@RequestParam(required = false)Integer pageNo,
@RequestParam(required = false)Integer pageSize,
@RequestParam(required = false)String query,
@RequestParam(required = false)Boolean enable ){
return streamProxyService.getAll(page, count);
return ResponseData.success(streamProxyService.getAll(pageNo, pageSize, query, enable));
}
@ApiOperation("保存代理")

101
src/main/java/com/genersoft/iot/vmp/vmanager/user/RoleController.java

@ -1,101 +0,0 @@
package com.genersoft.iot.vmp.vmanager.user;
import com.genersoft.iot.vmp.conf.security.SecurityUtils;
import com.genersoft.iot.vmp.service.IRoleService;
import com.genersoft.iot.vmp.service.IUserService;
import com.genersoft.iot.vmp.storager.dao.dto.Role;
import com.genersoft.iot.vmp.storager.dao.dto.User;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.util.DigestUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.List;
@Api(tags = "角色管理")
@CrossOrigin
@RestController
@RequestMapping("/api/role")
public class RoleController {
@Autowired
private IRoleService roleService;
private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@ApiOperation("添加角色")
@ApiImplicitParams({
@ApiImplicitParam(name = "name", required = true, value = "角色名", dataTypeClass = String.class),
@ApiImplicitParam(name = "authority", required = true, value = "权限(自行定义内容,目前未使用)", dataTypeClass = String.class),
})
@PostMapping("/add")
public ResponseEntity<WVPResult<Integer>> add(@RequestParam String name,
@RequestParam(required = false) String authority){
WVPResult<Integer> result = new WVPResult<>();
// 获取当前登录用户id
int currenRoleId = SecurityUtils.getUserInfo().getRole().getId();
if (currenRoleId != 1) {
// 只用角色id为1才可以删除和添加用户
result.setCode(-1);
result.setMsg("用户无权限");
return new ResponseEntity<>(result, HttpStatus.FORBIDDEN);
}
Role role = new Role();
role.setName(name);
role.setAuthority(authority);
role.setCreateTime(format.format(System.currentTimeMillis()));
role.setUpdateTime(format.format(System.currentTimeMillis()));
int addResult = roleService.add(role);
result.setCode(addResult > 0 ? 0 : -1);
result.setMsg(addResult > 0 ? "success" : "fail");
result.setData(addResult);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@ApiOperation("删除角色")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", required = true, value = "用户Id", dataTypeClass = Integer.class),
})
@DeleteMapping("/delete")
public ResponseEntity<WVPResult<String>> delete(@RequestParam Integer id){
// 获取当前登录用户id
int currenRoleId = SecurityUtils.getUserInfo().getRole().getId();
WVPResult<String> result = new WVPResult<>();
if (currenRoleId != 1) {
// 只用角色id为0才可以删除和添加用户
result.setCode(-1);
result.setMsg("用户无权限");
return new ResponseEntity<>(result, HttpStatus.FORBIDDEN);
}
int deleteResult = roleService.delete(id);
result.setCode(deleteResult>0? 0 : -1);
result.setMsg(deleteResult>0? "success" : "fail");
return new ResponseEntity<>(result, HttpStatus.OK);
}
@ApiOperation("查询角色")
@ApiImplicitParams({})
@GetMapping("/all")
public ResponseEntity<WVPResult<List<Role>>> all(){
// 获取当前登录用户id
List<Role> allRoles = roleService.getAll();
WVPResult<List<Role>> result = new WVPResult<>();
result.setCode(0);
result.setMsg("success");
result.setData(allRoles);
return new ResponseEntity<>(result, HttpStatus.OK);
}
}

182
src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java

@ -1,182 +0,0 @@
package com.genersoft.iot.vmp.vmanager.user;
import com.genersoft.iot.vmp.conf.security.SecurityUtils;
import com.genersoft.iot.vmp.conf.security.dto.LoginUser;
import com.genersoft.iot.vmp.service.IRoleService;
import com.genersoft.iot.vmp.service.IUserService;
import com.genersoft.iot.vmp.storager.dao.dto.Role;
import com.genersoft.iot.vmp.storager.dao.dto.User;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.util.DigestUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.security.sasl.AuthenticationException;
import java.text.SimpleDateFormat;
import java.util.List;
@Api(tags = "用户管理")
@CrossOrigin
@RestController
@RequestMapping("/api/user")
public class UserController {
@Autowired
private AuthenticationManager authenticationManager;
@Autowired
private IUserService userService;
@Autowired
private IRoleService roleService;
private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@ApiOperation("登录")
@ApiImplicitParams({
@ApiImplicitParam(name = "username", required = true, value = "用户名", dataTypeClass = String.class),
@ApiImplicitParam(name = "password", required = true, value = "密码(32位md5加密)", dataTypeClass = String.class),
})
@GetMapping("/login")
public WVPResult<LoginUser> login(@RequestParam String username, @RequestParam String password){
LoginUser user = null;
WVPResult<LoginUser> result = new WVPResult<>();
try {
user = SecurityUtils.login(username, password, authenticationManager);
} catch (AuthenticationException e) {
e.printStackTrace();
result.setCode(-1);
result.setMsg("fail");
}
if (user != null) {
result.setCode(0);
result.setMsg("success");
result.setData(user);
}else {
result.setCode(-1);
result.setMsg("fail");
}
return result;
}
@ApiOperation("修改密码")
@ApiImplicitParams({
@ApiImplicitParam(name = "username", required = true, value = "用户名", dataTypeClass = String.class),
@ApiImplicitParam(name = "oldpassword", required = true, value = "旧密码(已md5加密的密码)", dataTypeClass = String.class),
@ApiImplicitParam(name = "password", required = true, value = "新密码(未md5加密的密码)", dataTypeClass = String.class),
})
@PostMapping("/changePassword")
public String changePassword(@RequestParam String oldPassword, @RequestParam String password){
// 获取当前登录用户id
LoginUser userInfo = SecurityUtils.getUserInfo();
if (userInfo== null) {
return "fail";
}
String username = userInfo.getUsername();
LoginUser user = null;
try {
user = SecurityUtils.login(username, oldPassword, authenticationManager);
if (user != null) {
int userId = SecurityUtils.getUserId();
boolean result = userService.changePassword(userId, DigestUtils.md5DigestAsHex(password.getBytes()));
if (result) {
return "success";
}
}
} catch (AuthenticationException e) {
e.printStackTrace();
}
return "fail";
}
@ApiOperation("添加用户")
@ApiImplicitParams({
@ApiImplicitParam(name = "username", required = true, value = "用户名", dataTypeClass = String.class),
@ApiImplicitParam(name = "password", required = true, value = "密码(未md5加密的密码)", dataTypeClass = String.class),
@ApiImplicitParam(name = "roleId", required = true, value = "角色ID", dataTypeClass = String.class),
})
@PostMapping("/add")
public ResponseEntity<WVPResult<Integer>> add(@RequestParam String username,
@RequestParam String password,
@RequestParam Integer roleId){
WVPResult<Integer> result = new WVPResult<>();
if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password) || roleId == null) {
result.setCode(-1);
result.setMsg("参数不可为空");
return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST);
}
// 获取当前登录用户id
int currenRoleId = SecurityUtils.getUserInfo().getRole().getId();
if (currenRoleId != 1) {
// 只用角色id为1才可以删除和添加用户
result.setCode(-1);
result.setMsg("用户无权限");
return new ResponseEntity<>(result, HttpStatus.FORBIDDEN);
}
User user = new User();
user.setUsername(username);
user.setPassword(DigestUtils.md5DigestAsHex(password.getBytes()));
Role role = roleService.getRoleById(roleId);
if (role == null) {
result.setCode(-1);
result.setMsg("roleId is not found");
// 角色不存在
return new ResponseEntity<>(result, HttpStatus.OK);
}
user.setRole(role);
user.setCreateTime(format.format(System.currentTimeMillis()));
user.setUpdateTime(format.format(System.currentTimeMillis()));
int addResult = userService.addUser(user);
result.setCode(addResult > 0 ? 0 : -1);
result.setMsg(addResult > 0 ? "success" : "fail");
result.setData(addResult);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@ApiOperation("删除用户")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", required = true, value = "用户Id", dataTypeClass = Integer.class),
})
@DeleteMapping("/delete")
public ResponseEntity<WVPResult<String>> delete(@RequestParam Integer id){
// 获取当前登录用户id
int currenRoleId = SecurityUtils.getUserInfo().getRole().getId();
WVPResult<String> result = new WVPResult<>();
if (currenRoleId != 1) {
// 只用角色id为0才可以删除和添加用户
result.setCode(-1);
result.setMsg("用户无权限");
return new ResponseEntity<>(result, HttpStatus.FORBIDDEN);
}
int deleteResult = userService.deleteUser(id);
result.setCode(deleteResult>0? 0 : -1);
result.setMsg(deleteResult>0? "success" : "fail");
return new ResponseEntity<>(result, HttpStatus.OK);
}
@ApiOperation("查询用户")
@ApiImplicitParams({})
@GetMapping("/all")
public ResponseEntity<WVPResult<List<User>>> all(){
// 获取当前登录用户id
List<User> allUsers = userService.getAllUsers();
WVPResult<List<User>> result = new WVPResult<>();
result.setCode(0);
result.setMsg("success");
result.setData(allUsers);
return new ResponseEntity<>(result, HttpStatus.OK);
}
}

20
src/main/java/com/genersoft/iot/vmp/vmanager/videoSquare/VideoSquareController.java

@ -0,0 +1,20 @@
package com.genersoft.iot.vmp.vmanager.videoSquare;
import com.genersoft.iot.vmp.common.reponse.ResponseData;
import com.genersoft.iot.vmp.service.IVideoSquareService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api/square")
public class VideoSquareController {
@Autowired
private IVideoSquareService videoSquareService;
@GetMapping(value = "/video/tree")
@ResponseBody
public ResponseData queryVideoTree() {
return ResponseData.success(videoSquareService.selectVideoTree());
}
}

56
src/main/java/com/genersoft/iot/vmp/web/ApiDeviceController.java

@ -2,6 +2,8 @@ package com.genersoft.iot.vmp.web;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.Page;
import com.genersoft.iot.vmp.common.reponse.ResponseData;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
@ -9,6 +11,7 @@ import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -38,6 +41,7 @@ public class ApiDeviceController {
/**
* 分页获取设备列表 TODO 现在直接返回尚未实现分页
*
* @param start
* @param limit
* @param q
@ -45,23 +49,23 @@ public class ApiDeviceController {
* @return
*/
@RequestMapping(value = "/list")
public JSONObject list( @RequestParam(required = false)Integer start,
@RequestParam(required = false)Integer limit,
@RequestParam(required = false)String q,
@RequestParam(required = false)Boolean online ){
public JSONObject list(@RequestParam(required = false) Integer start,
@RequestParam(required = false) Integer limit,
@RequestParam(required = false) String q,
@RequestParam(required = false) Boolean online) {
// if (logger.isDebugEnabled()) {
// logger.debug("查询所有视频设备API调用");
// }
JSONObject result = new JSONObject();
List<Device> devices;
if (start == null || limit ==null) {
if (start == null || limit == null) {
devices = storager.queryVideoDeviceList();
result.put("DeviceCount", devices.size());
}else {
PageInfo<Device> deviceList = storager.queryVideoDeviceList(start/limit, limit);
result.put("DeviceCount", deviceList.getTotal());
devices = deviceList.getList();
} else {
Page<Device> devicePage = storager.queryVideoDeviceList(start / limit, limit, null);
result.put("DeviceCount", devicePage.getTotalCount());
devices = devicePage.getData();
}
JSONArray deviceJSONList = new JSONArray();
@ -85,18 +89,18 @@ public class ApiDeviceController {
deviceJsonObject.put("CreatedAt", "");
deviceJSONList.add(deviceJsonObject);
}
result.put("DeviceList",deviceJSONList);
result.put("DeviceList", deviceJSONList);
return result;
}
@RequestMapping(value = "/channellist")
public JSONObject channellist( String serial,
@RequestParam(required = false)String channel_type,
@RequestParam(required = false)String dir_serial ,
@RequestParam(required = false)Integer start,
@RequestParam(required = false)Integer limit,
@RequestParam(required = false)String q,
@RequestParam(required = false)Boolean online ){
public JSONObject channellist(String serial,
@RequestParam(required = false) String channel_type,
@RequestParam(required = false) String dir_serial,
@RequestParam(required = false) Integer start,
@RequestParam(required = false) Integer limit,
@RequestParam(required = false) String q,
@RequestParam(required = false) Boolean online) {
// if (logger.isDebugEnabled()) {
// logger.debug("查询所有视频设备API调用");
@ -110,13 +114,13 @@ public class ApiDeviceController {
return result;
}
List<DeviceChannel> deviceChannels;
if (start == null || limit ==null) {
if (start == null || limit == null) {
deviceChannels = storager.queryChannelsByDeviceId(serial);
result.put("ChannelCount", deviceChannels.size());
}else {
PageInfo<DeviceChannel> pageResult = storager.queryChannelsByDeviceId(serial, null, null, null,start/limit, limit);
result.put("ChannelCount", pageResult.getTotal());
deviceChannels = pageResult.getList();
} else {
Page<DeviceChannel> page = storager.queryChannelsByDeviceId(serial, null, null, null, start / limit, limit);
result.put("ChannelCount", page.getTotalCount());
deviceChannels = page.getData();
}
JSONArray channleJSONList = new JSONArray();
@ -141,14 +145,14 @@ public class ApiDeviceController {
deviceJOSNChannel.put("ParentID", deviceChannel.getParentId()); // 直接上级编号
deviceJOSNChannel.put("Secrecy", deviceChannel.getSecrecy());
deviceJOSNChannel.put("RegisterWay", 1); // 注册方式, 缺省为1, 允许值: 1, 2, 3
// 1-IETF RFC3261,
// 2-基于口令的双向认证,
// 3-基于数字证书的双向认证
// 1-IETF RFC3261,
// 2-基于口令的双向认证,
// 3-基于数字证书的双向认证
deviceJOSNChannel.put("Status", deviceChannel.getStatus());
deviceJOSNChannel.put("Longitude", deviceChannel.getLongitude());
deviceJOSNChannel.put("Latitude", deviceChannel.getLatitude());
deviceJOSNChannel.put("PTZType ", deviceChannel.getPTZType()); // 云台类型, 0 - 未知, 1 - 球机, 2 - 半球,
// 3 - 固定枪机, 4 - 遥控枪机
// 3 - 固定枪机, 4 - 遥控枪机
deviceJOSNChannel.put("CustomPTZType", "");
deviceJOSNChannel.put("StreamID", deviceChannel.getStreamId()); // StreamID 直播流ID, 有值表示正在直播
deviceJOSNChannel.put("NumOutputs ", -1); // 直播在线人数

25
src/main/java/com/genersoft/iot/vmp/web/AuthController.java

@ -1,25 +0,0 @@
package com.genersoft.iot.vmp.web;
import com.genersoft.iot.vmp.service.IUserService;
import com.genersoft.iot.vmp.storager.dao.dto.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@CrossOrigin
@RestController
@RequestMapping(value = "/auth")
public class AuthController {
@Autowired
private IUserService userService;
@RequestMapping("/login")
public String devices(String name, String passwd){
User user = userService.getUser(name, passwd);
if (user != null) {
return "success";
}else {
return "fail";
}
}
}

44
src/main/resources/application-dev.yml

@ -2,30 +2,30 @@ spring:
# REDIS数据库配置
redis:
# [必须修改] Redis服务器IP, REDIS安装在本机的,使用127.0.0.1
host: ${REDIS_HOST:127.0.0.1}
host: 127.0.0.1
# [必须修改] 端口号
port: ${REDIS_PORT:6379}
port: 6379
# [可选] 数据库 DB
database: ${REDIS_DB:6}
database: 6
# [可选] 访问密码,若你的redis服务器没有设置密码,就不需要用密码去连接
password: ${REDIS_PWD}
password:
# [可选] 超时时间
timeout: 10000
# [可选] jdbc数据库配置, 项目使用sqlite作为数据库,一般不需要配置
datasource:
# 使用mysql 打开23-28行注释, 删除29-36行
# name: wvp
# url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true
name: wvp
url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&&serverTimezone=Asia/Shanghai
username: root
password: root123
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
# name: eiot
# url: jdbc:sqlite::resource:wvp.sqlite
# username:
# password:
# type: com.alibaba.druid.pool.DruidDataSource
# driver-class-name: com.mysql.cj.jdbc.Driver
name: eiot
url: jdbc:sqlite::resource:wvp.sqlite
username:
password:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: org.sqlite.JDBC
# driver-class-name: org.sqlite.JDBC
max-active: 1
min-idle: 1
@ -36,23 +36,25 @@ server:
# 作为28181服务器的配置
sip:
# [必须修改] 本机的IP
ip: ${WVP_HOST}
ip: 192.168.10.96
# [可选] 28181服务监听的端口
port: 5060
# 根据国标6.1.2中规定,domain宜采用ID统一编码的前十位编码。国标附录D中定义前8位为中心编码(由省级、市级、区级、基层编号组成,参照GB/T 2260-2007)
# 后两位为行业编码,定义参照附录D.3
# 3701020049标识山东济南历下区 信息行业接入
# [可选]
domain: ${WVP_DOMAIN:4401020049}
domain: 4401020049
# [可选]
id: ${WVP_ID:44010200492000000001}
id: 44010200492000000001
# [可选] 默认设备认证密码,后续扩展使用设备单独密码, 移除密码将不进行校验
password: ${WVP_PWD:admin123}
password: admin123
#zlm 默认服务器配置
media:
# [可选] zlm服务器唯一id,用于触发hook时区别是哪台服务器,general.mediaServerId
id: vm-windows
# [必须修改] zlm服务器的内网IP
ip: 127.0.0.1
ip: 192.168.10.96
# [必须修改] zlm服务器的http.port
http-port: 80
# [可选] zlm服务器的hook.admin_params=secret
@ -67,8 +69,6 @@ media:
send-port-range: 30000,30500 # 端口范围
# 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载, 0 表示不使用
record-assist-port: 18081
sdp-ip: ${WVP_HOST}
stream-ip: ${WVP_HOST}
# [可选] 日志配置, 一般不需要改
logging:
file:
@ -84,7 +84,7 @@ logging:
# [根据业务需求配置]
user-settings:
# 推流直播是否录制
record-push-live: true
record-push-live: false
auto-apply-play: false
# 在线文档: swagger-ui(生产环境建议关闭)
@ -95,4 +95,4 @@ swagger-ui:
version:
version: "@project.version@"
description: "@project.description@"
artifact-id: "@project.artifactId@"
artifact-id: "@project.artifactId@"

2
src/main/resources/application.yml

@ -1,3 +1,3 @@
spring:
profiles:
active: dev
active: dev

58
src/test/java/com/genersoft/iot/vmp/service/impl/RoleServiceImplTest.java

@ -1,58 +0,0 @@
package com.genersoft.iot.vmp.service.impl;
import com.genersoft.iot.vmp.service.IRoleService;
import com.genersoft.iot.vmp.service.IUserService;
import com.genersoft.iot.vmp.storager.dao.dto.Role;
import com.genersoft.iot.vmp.storager.dao.dto.User;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.List;
@SpringBootTest
@RunWith(SpringRunner.class)
class RoleServiceImplTest {
@Resource
private IRoleService roleService;
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@org.junit.jupiter.api.Test
void getAllUser() {
List<Role> all = roleService.getAll();
Role roleById = roleService.getRoleById(1);
System.out.println();
}
@org.junit.jupiter.api.Test
void add() {
for (int i = 0; i < 10; i++) {
Role role = new Role();
role.setName("test+" + i);
role.setAuthority("adadadda");
role.setCreateTime(format.format(System.currentTimeMillis()));
role.setUpdateTime(format.format(System.currentTimeMillis()));
roleService.add(role);
}
}
@org.junit.jupiter.api.Test
void delete() {
roleService.delete(20);
}
@org.junit.jupiter.api.Test
void update() {
Role role = new Role();
role.setId(21);
role.setName("TTTTTT");
role.setAuthority("adadadda");
roleService.update(role);
}
}

72
src/test/java/com/genersoft/iot/vmp/service/impl/UserServiceImplTest.java

@ -1,72 +0,0 @@
package com.genersoft.iot.vmp.service.impl;
import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
import com.genersoft.iot.vmp.service.IDeviceAlarmService;
import com.genersoft.iot.vmp.service.IUserService;
import com.genersoft.iot.vmp.storager.dao.dto.Role;
import com.genersoft.iot.vmp.storager.dao.dto.User;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@SpringBootTest
@RunWith(SpringRunner.class)
class UserServiceImplTest {
@Resource
private IUserService userService;
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@org.junit.jupiter.api.Test
void getAllUser() {
List<User> allUsers = userService.getAllUsers();
System.out.println(userService.getAllUsers().size());
User admin = userService.getUser("admin", "21232f297a57a5a743894a0e4a801fc3");
User admin1 = userService.getUserByUsername("admin");
System.out.println(12);
}
@org.junit.jupiter.api.Test
void add() {
for (int i = 0; i < 10; i++) {
User user = new User();
user.setUsername("admin_" + i);
user.setPassword("admin_password_" + i);
Role role = new Role();
role.setId(1);
user.setRole(role);
user.setCreateTime(format.format(System.currentTimeMillis()));
user.setUpdateTime(format.format(System.currentTimeMillis()));
userService.addUser(user);
}
}
@org.junit.jupiter.api.Test
void delete() {
userService.deleteUser(1002);
}
@org.junit.jupiter.api.Test
void update() {
User user = new User();
user.setId(11);
user.setUsername("update" );
user.setPassword("update");
Role role = new Role();
role.setId(2);
user.setRole(role);
user.setUpdateTime(format.format(System.currentTimeMillis()));
userService.updateUsers(user);
}
}

12
web_src/.babelrc

@ -1,12 +0,0 @@
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": ["transform-vue-jsx", "transform-runtime"]
}

3
web_src/.browserslistrc

@ -0,0 +1,3 @@
> 1%
last 2 versions
not ie <= 10

46
web_src/.editorconfig

@ -1,9 +1,39 @@
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset=utf-8
end_of_line=lf
insert_final_newline=false
indent_style=space
indent_size=2
[{*.ng,*.sht,*.html,*.shtm,*.shtml,*.htm}]
indent_style=space
indent_size=2
[{*.jhm,*.xslt,*.xul,*.rng,*.xsl,*.xsd,*.ant,*.tld,*.fxml,*.jrxml,*.xml,*.jnlp,*.wsdl}]
indent_style=space
indent_size=2
[{.babelrc,.stylelintrc,jest.config,.eslintrc,.prettierrc,*.json,*.jsb3,*.jsb2,*.bowerrc}]
indent_style=space
indent_size=2
[*.svg]
indent_style=space
indent_size=2
[*.js.map]
indent_style=space
indent_size=2
[*.less]
indent_style=space
indent_size=2
[*.vue]
indent_style=space
indent_size=2
[{.analysis_options,*.yml,*.yaml}]
indent_style=space
indent_size=2

3
web_src/.env

@ -0,0 +1,3 @@
NODE_ENV=production
VUE_APP_PREVIEW=false
VUE_APP_API_BASE_URL=/

3
web_src/.env.development

@ -0,0 +1,3 @@
NODE_ENV=development
VUE_APP_PREVIEW=true
VUE_APP_API_BASE_URL=/debug

3
web_src/.env.preview

@ -0,0 +1,3 @@
NODE_ENV=production
VUE_APP_PREVIEW=true
VUE_APP_API_BASE_URL=/debug

1
web_src/.gitattributes

@ -0,0 +1 @@
public/* linguist-vendored

12
web_src/.gitignore

@ -1,6 +1,12 @@
.DS_Store
node_modules/
/dist/
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
@ -12,3 +18,5 @@ yarn-error.log*
*.ntvs*
*.njsproj
*.sln
*.sw*
package-lock.json

14
web_src/.postcssrc.js

@ -1,14 +0,0 @@
// https://github.com/michael-ciniawsky/postcss-load-config
module.exports = {
"plugins": {
"postcss-import": {},
"postcss-url": {},
// to edit target browsers: use "browserslist" field in package.json
"autoprefixer": {},
'postcss-pxtorem': {
rootValue: 16,
propList: ['font-size'] // 只转化font-size
}
}
}

6
web_src/.prettierrc

@ -0,0 +1,6 @@
{
"printWidth": 120,
"semi": false,
"singleQuote": true,
"prettier.spaceBeforeFunctionParen": true
}

7
web_src/.travis.yml

@ -0,0 +1,7 @@
language: node_js
node_js:
- 10.15.0
cache: yarn
script:
- yarn
- yarn run lint --no-fix && yarn run build

6
web_src/Dockerfile

@ -0,0 +1,6 @@
FROM nginx
RUN rm /etc/nginx/conf.d/default.conf
ADD deploy/nginx.conf /etc/nginx/conf.d/default.conf
COPY dist/ /usr/share/nginx/html/

21
web_src/LICENSE

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Anan Yang
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

22
web_src/README.md

@ -1,21 +1 @@
# gb_web
> A Vue.js project
## Build Setup
``` bash
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build
# build for production and view the bundle analyzer report
npm run build --report
```
For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
WVP视频平台ant-design风格前端

30
web_src/babel.config.js

@ -0,0 +1,30 @@
const IS_PROD = ['production', 'prod'].includes(process.env.NODE_ENV)
const IS_PREVIEW = process.env.VUE_APP_PREVIEW === 'true'
const plugins = []
if (IS_PROD && !IS_PREVIEW) {
// 去除日志的插件,
plugins.push('transform-remove-console')
}
// lazy load ant-design-vue
// if your use import on Demand, Use this code
plugins.push(['import', {
'libraryName': 'ant-design-vue',
'libraryDirectory': 'es',
'style': true // `style: true` 会加载 less 文件
}])
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset',
[
'@babel/preset-env',
{
'useBuiltIns': 'entry',
'corejs': 3
}
]
],
plugins
}

41
web_src/build/build.js

@ -1,41 +0,0 @@
'use strict'
require('./check-versions')()
process.env.NODE_ENV = 'production'
const ora = require('ora')
const rm = require('rimraf')
const path = require('path')
const chalk = require('chalk')
const webpack = require('webpack')
const config = require('../config')
const webpackConfig = require('./webpack.prod.conf')
const spinner = ora('building for production...')
spinner.start()
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
if (err) throw err
webpack(webpackConfig, (err, stats) => {
spinner.stop()
if (err) throw err
process.stdout.write(stats.toString({
colors: true,
modules: false,
children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
chunks: false,
chunkModules: false
}) + '\n\n')
if (stats.hasErrors()) {
console.log(chalk.red(' Build failed with errors.\n'))
process.exit(1)
}
console.log(chalk.cyan(' Build complete.\n'))
console.log(chalk.yellow(
' Tip: built files are meant to be served over an HTTP server.\n' +
' Opening index.html over file:// won\'t work.\n'
))
})
})

54
web_src/build/check-versions.js

@ -1,54 +0,0 @@
'use strict'
const chalk = require('chalk')
const semver = require('semver')
const packageConfig = require('../package.json')
const shell = require('shelljs')
function exec (cmd) {
return require('child_process').execSync(cmd).toString().trim()
}
const versionRequirements = [
{
name: 'node',
currentVersion: semver.clean(process.version),
versionRequirement: packageConfig.engines.node
}
]
if (shell.which('npm')) {
versionRequirements.push({
name: 'npm',
currentVersion: exec('npm --version'),
versionRequirement: packageConfig.engines.npm
})
}
module.exports = function () {
const warnings = []
for (let i = 0; i < versionRequirements.length; i++) {
const mod = versionRequirements[i]
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
warnings.push(mod.name + ': ' +
chalk.red(mod.currentVersion) + ' should be ' +
chalk.green(mod.versionRequirement)
)
}
}
if (warnings.length) {
console.log('')
console.log(chalk.yellow('To use this template, you must update following to modules:'))
console.log()
for (let i = 0; i < warnings.length; i++) {
const warning = warnings[i]
console.log(' ' + warning)
}
console.log()
process.exit(1)
}
}

BIN
web_src/build/logo.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

101
web_src/build/utils.js

@ -1,101 +0,0 @@
'use strict'
const path = require('path')
const config = require('../config')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const packageConfig = require('../package.json')
exports.assetsPath = function (_path) {
const assetsSubDirectory = process.env.NODE_ENV === 'production'
? config.build.assetsSubDirectory
: config.dev.assetsSubDirectory
return path.posix.join(assetsSubDirectory, _path)
}
exports.cssLoaders = function (options) {
options = options || {}
const cssLoader = {
loader: 'css-loader',
options: {
sourceMap: options.sourceMap
}
}
const postcssLoader = {
loader: 'postcss-loader',
options: {
sourceMap: options.sourceMap
}
}
// generate loader string to be used with extract text plugin
function generateLoaders (loader, loaderOptions) {
const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader]
if (loader) {
loaders.push({
loader: loader + '-loader',
options: Object.assign({}, loaderOptions, {
sourceMap: options.sourceMap
})
})
}
// Extract CSS when that option is specified
// (which is the case during production build)
if (options.extract) {
return ExtractTextPlugin.extract({
use: loaders,
fallback: 'vue-style-loader'
})
} else {
return ['vue-style-loader'].concat(loaders)
}
}
// https://vue-loader.vuejs.org/en/configurations/extract-css.html
return {
css: generateLoaders(),
postcss: generateLoaders(),
less: generateLoaders('less'),
sass: generateLoaders('sass', { indentedSyntax: true }),
scss: generateLoaders('sass'),
stylus: generateLoaders('stylus'),
styl: generateLoaders('stylus')
}
}
// Generate loaders for standalone style files (outside of .vue)
exports.styleLoaders = function (options) {
const output = []
const loaders = exports.cssLoaders(options)
for (const extension in loaders) {
const loader = loaders[extension]
output.push({
test: new RegExp('\\.' + extension + '$'),
use: loader
})
}
return output
}
exports.createNotifierCallback = () => {
const notifier = require('node-notifier')
return (severity, errors) => {
if (severity !== 'error') return
const error = errors[0]
const filename = error.file && error.file.split('!').pop()
notifier.notify({
title: packageConfig.name,
message: severity + ': ' + error.name,
subtitle: filename || '',
icon: path.join(__dirname, 'logo.png')
})
}
}

22
web_src/build/vue-loader.conf.js

@ -1,22 +0,0 @@
'use strict'
const utils = require('./utils')
const config = require('../config')
const isProduction = process.env.NODE_ENV === 'production'
const sourceMapEnabled = isProduction
? config.build.productionSourceMap
: config.dev.cssSourceMap
module.exports = {
loaders: utils.cssLoaders({
sourceMap: sourceMapEnabled,
extract: isProduction
}),
cssSourceMap: sourceMapEnabled,
cacheBusting: config.dev.cacheBusting,
transformToRequire: {
video: ['src', 'poster'],
source: 'src',
img: 'src',
image: 'xlink:href'
}
}

83
web_src/build/webpack.base.conf.js

@ -1,83 +0,0 @@
'use strict'
const path = require('path')
const utils = require('./utils')
const config = require('../config')
const vueLoaderConfig = require('./vue-loader.conf')
function resolve (dir) {
return path.join(__dirname, '..', dir)
}
module.exports = {
context: path.resolve(__dirname, '../'),
entry: {
app: './src/main.js'
},
output: {
path: config.build.assetsRoot,
filename: '[name].js',
publicPath: process.env.NODE_ENV === 'production'
? config.build.assetsPublicPath
: config.dev.assetsPublicPath
},
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': resolve('src'),
'@static': resolve('static'),
}
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: vueLoaderConfig
},
{
test: /\.js$/,
loader: 'babel-loader',
include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('img/[name].[hash:7].[ext]')
}
},
{
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('media/[name].[hash:7].[ext]')
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
}
]
},
node: {
// prevent webpack from injecting useless setImmediate polyfill because Vue
// source contains it (although only uses it if it's native).
setImmediate: false,
// prevent webpack from injecting mocks to Node native modules
// that does not make sense for the client
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty'
}
}

95
web_src/build/webpack.dev.conf.js

@ -1,95 +0,0 @@
'use strict'
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const path = require('path')
const baseWebpackConfig = require('./webpack.base.conf')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
const portfinder = require('portfinder')
const HOST = process.env.HOST
const PORT = process.env.PORT && Number(process.env.PORT)
const devWebpackConfig = merge(baseWebpackConfig, {
module: {
rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true })
},
// cheap-module-eval-source-map is faster for development
devtool: config.dev.devtool,
// these devServer options should be customized in /config/index.js
devServer: {
clientLogLevel: 'warning',
historyApiFallback: {
rewrites: [
{ from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') },
],
},
hot: true,
contentBase: false, // since we use CopyWebpackPlugin.
compress: true,
host: HOST || config.dev.host,
port: PORT || config.dev.port,
open: config.dev.autoOpenBrowser,
overlay: config.dev.errorOverlay
? { warnings: false, errors: true }
: false,
publicPath: config.dev.assetsPublicPath,
proxy: config.dev.proxyTable,
quiet: true, // necessary for FriendlyErrorsPlugin
watchOptions: {
poll: config.dev.poll,
}
},
plugins: [
new webpack.DefinePlugin({
'process.env': require('../config/dev.env')
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update.
new webpack.NoEmitOnErrorsPlugin(),
// https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true
}),
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.dev.assetsSubDirectory,
ignore: ['.*']
}
])
]
})
module.exports = new Promise((resolve, reject) => {
portfinder.basePort = process.env.PORT || config.dev.port
portfinder.getPort((err, port) => {
if (err) {
reject(err)
} else {
// publish the new Port, necessary for e2e tests
process.env.PORT = port
// add port to devServer config
devWebpackConfig.devServer.port = port
// Add FriendlyErrorsPlugin
devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({
compilationSuccessInfo: {
messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`],
},
onErrors: config.dev.notifyOnErrors
? utils.createNotifierCallback()
: undefined
}))
resolve(devWebpackConfig)
}
})
})

145
web_src/build/webpack.prod.conf.js

@ -1,145 +0,0 @@
'use strict'
const path = require('path')
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const baseWebpackConfig = require('./webpack.base.conf')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const env = require('../config/prod.env')
const webpackConfig = merge(baseWebpackConfig, {
module: {
rules: utils.styleLoaders({
sourceMap: config.build.productionSourceMap,
extract: true,
usePostCSS: true
})
},
devtool: config.build.productionSourceMap ? config.build.devtool : false,
output: {
path: config.build.assetsRoot,
filename: utils.assetsPath('js/[name].[chunkhash].js'),
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
},
plugins: [
// http://vuejs.github.io/vue-loader/en/workflow/production.html
new webpack.DefinePlugin({
'process.env': env
}),
new UglifyJsPlugin({
uglifyOptions: {
compress: {
warnings: false
}
},
sourceMap: config.build.productionSourceMap,
parallel: true
}),
// extract css into its own file
new ExtractTextPlugin({
filename: utils.assetsPath('css/[name].[contenthash].css'),
// Setting the following option to `false` will not extract CSS from codesplit chunks.
// Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack.
// It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`,
// increasing file size: https://github.com/vuejs-templates/webpack/issues/1110
allChunks: true,
}),
// Compress extracted CSS. We are using this plugin so that possible
// duplicated CSS from different components can be deduped.
new OptimizeCSSPlugin({
cssProcessorOptions: config.build.productionSourceMap
? { safe: true, map: { inline: false } }
: { safe: true }
}),
// generate dist index.html with correct asset hash for caching.
// you can customize output by editing /index.html
// see https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: config.build.index,
template: 'index.html',
inject: true,
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
// more options:
// https://github.com/kangax/html-minifier#options-quick-reference
},
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
chunksSortMode: 'dependency'
}),
// keep module.id stable when vendor modules does not change
new webpack.HashedModuleIdsPlugin(),
// enable scope hoisting
new webpack.optimize.ModuleConcatenationPlugin(),
// split vendor js into its own file
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks (module) {
// any required modules inside node_modules are extracted to vendor
return (
module.resource &&
/\.js$/.test(module.resource) &&
module.resource.indexOf(
path.join(__dirname, '../node_modules')
) === 0
)
}
}),
// extract webpack runtime and module manifest to its own file in order to
// prevent vendor hash from being updated whenever app bundle is updated
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
minChunks: Infinity
}),
// This instance extracts shared chunks from code splitted chunks and bundles them
// in a separate chunk, similar to the vendor chunk
// see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk
new webpack.optimize.CommonsChunkPlugin({
name: 'app',
async: 'vendor-async',
children: true,
minChunks: 3
}),
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.build.assetsSubDirectory,
ignore: ['.*']
}
])
]
})
if (config.build.productionGzip) {
const CompressionWebpackPlugin = require('compression-webpack-plugin')
webpackConfig.plugins.push(
new CompressionWebpackPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: new RegExp(
'\\.(' +
config.build.productionGzipExtensions.join('|') +
')$'
),
threshold: 10240,
minRatio: 0.8
})
)
}
if (config.build.bundleAnalyzerReport) {
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
}
module.exports = webpackConfig

8
web_src/config/dev.env.js

@ -1,8 +0,0 @@
'use strict'
const merge = require('webpack-merge')
const prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {
NODE_ENV: '"development"',
BASE_API: '"/debug"'
})

85
web_src/config/index.js

@ -1,85 +0,0 @@
'use strict'
// Template version: 1.3.1
// see http://vuejs-templates.github.io/webpack for documentation.
const path = require('path')
module.exports = {
dev: {
// Paths
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {
'/debug': {
target: 'http://localhost:18080',
changeOrigin: true,
pathRewrite: {
'^/debug': '/'
}
},
'/static/snap': {
target: 'http://localhost:18080',
changeOrigin: true,
// pathRewrite: {
// '^/static/snap': '/static/snap'
// }
},
},
// Various Dev Server settings
host: 'localhost', // can be overwritten by process.env.HOST
port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: false,
errorOverlay: true,
notifyOnErrors: true,
poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
/**
* Source Maps
*/
// https://webpack.js.org/configuration/devtool/#development
devtool: 'cheap-module-eval-source-map',
// If you have problems debugging vue-files in devtools,
// set this to false - it *may* help
// https://vue-loader.vuejs.org/en/options.html#cachebusting
cacheBusting: true,
cssSourceMap: true
},
build: {
// Template for index.html
index: path.resolve(__dirname, '../../src/main/resources/static/index.html'),
// Paths
assetsRoot: path.resolve(__dirname, '../../src/main/resources/static/'),
assetsSubDirectory: './static',
assetsPublicPath: '/',
/**
* Source Maps
*/
productionSourceMap: true,
// https://webpack.js.org/configuration/devtool/#production
devtool: '#source-map',
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
// Before setting to `true`, make sure to:
// npm install --save-dev compression-webpack-plugin
productionGzip: false,
productionGzipExtensions: ['js', 'css'],
// Run the build command with an extra argument to
// View the bundle analyzer report after build finishes:
// `npm run build --report`
// Set to `true` or `false` to always turn it on or off
bundleAnalyzerReport: process.env.npm_config_report
}
}

49
web_src/config/plugin.config.js

@ -0,0 +1,49 @@
const ThemeColorReplacer = require('webpack-theme-color-replacer')
const generate = require('@ant-design/colors/lib/generate').default
const getAntdSerials = (color) => {
// 淡化(即less的tint)
const lightens = new Array(9).fill().map((t, i) => {
return ThemeColorReplacer.varyColor.lighten(color, i / 10)
})
const colorPalettes = generate(color)
const rgb = ThemeColorReplacer.varyColor.toNum3(color.replace('#', '')).join(',')
return lightens.concat(colorPalettes).concat(rgb)
}
const themePluginOption = {
fileName: 'css/theme-colors-[contenthash:8].css',
matchColors: getAntdSerials('#1890ff'), // 主色系列
// 改变样式选择器,解决样式覆盖问题
changeSelector (selector) {
switch (selector) {
case '.ant-calendar-today .ant-calendar-date':
return ':not(.ant-calendar-selected-date):not(.ant-calendar-selected-day)' + selector
case '.ant-btn:focus,.ant-btn:hover':
return '.ant-btn:focus:not(.ant-btn-primary):not(.ant-btn-danger),.ant-btn:hover:not(.ant-btn-primary):not(.ant-btn-danger)'
case '.ant-btn.active,.ant-btn:active':
return '.ant-btn.active:not(.ant-btn-primary):not(.ant-btn-danger),.ant-btn:active:not(.ant-btn-primary):not(.ant-btn-danger)'
case '.ant-steps-item-process .ant-steps-item-icon > .ant-steps-icon':
case '.ant-steps-item-process .ant-steps-item-icon>.ant-steps-icon':
return ':not(.ant-steps-item-process)' + selector
// fixed https://github.com/vueComponent/ant-design-vue-pro/issues/876
case '.ant-steps-item-process .ant-steps-item-icon':
return ':not(.ant-steps-item-custom)' + selector
case '.ant-menu-horizontal>.ant-menu-item-active,.ant-menu-horizontal>.ant-menu-item-open,.ant-menu-horizontal>.ant-menu-item-selected,.ant-menu-horizontal>.ant-menu-item:hover,.ant-menu-horizontal>.ant-menu-submenu-active,.ant-menu-horizontal>.ant-menu-submenu-open,.ant-menu-horizontal>.ant-menu-submenu-selected,.ant-menu-horizontal>.ant-menu-submenu:hover':
case '.ant-menu-horizontal > .ant-menu-item-active,.ant-menu-horizontal > .ant-menu-item-open,.ant-menu-horizontal > .ant-menu-item-selected,.ant-menu-horizontal > .ant-menu-item:hover,.ant-menu-horizontal > .ant-menu-submenu-active,.ant-menu-horizontal > .ant-menu-submenu-open,.ant-menu-horizontal > .ant-menu-submenu-selected,.ant-menu-horizontal > .ant-menu-submenu:hover':
return '.ant-menu-horizontal > .ant-menu-item-active,.ant-menu-horizontal > .ant-menu-item-open,.ant-menu-horizontal > .ant-menu-item-selected,.ant-menu-horizontal:not(.ant-menu-dark) > .ant-menu-item:hover,.ant-menu-horizontal > .ant-menu-submenu-active,.ant-menu-horizontal > .ant-menu-submenu-open,.ant-menu-horizontal:not(.ant-menu-dark) > .ant-menu-submenu-selected,.ant-menu-horizontal:not(.ant-menu-dark) > .ant-menu-submenu:hover'
case '.ant-menu-horizontal > .ant-menu-item-selected > a':
case '.ant-menu-horizontal>.ant-menu-item-selected>a':
return '.ant-menu-horizontal:not(ant-menu-light):not(.ant-menu-dark) > .ant-menu-item-selected > a'
case '.ant-menu-horizontal > .ant-menu-item > a:hover':
case '.ant-menu-horizontal>.ant-menu-item>a:hover':
return '.ant-menu-horizontal:not(ant-menu-light):not(.ant-menu-dark) > .ant-menu-item > a:hover'
default :
return selector
}
}
}
const createThemeColorReplacerPlugin = () => new ThemeColorReplacer(themePluginOption)
module.exports = createThemeColorReplacerPlugin

4
web_src/config/prod.env.js

@ -1,4 +0,0 @@
'use strict'
module.exports = {
NODE_ENV: '"production"'
}

115
web_src/config/themePluginConfig.js

@ -0,0 +1,115 @@
export default {
theme: [
{
key: 'dark',
fileName: 'dark.css',
theme: 'dark'
},
{
key: '#F5222D',
fileName: '#F5222D.css',
modifyVars: {
'@primary-color': '#F5222D'
}
},
{
key: '#FA541C',
fileName: '#FA541C.css',
modifyVars: {
'@primary-color': '#FA541C'
}
},
{
key: '#FAAD14',
fileName: '#FAAD14.css',
modifyVars: {
'@primary-color': '#FAAD14'
}
},
{
key: '#13C2C2',
fileName: '#13C2C2.css',
modifyVars: {
'@primary-color': '#13C2C2'
}
},
{
key: '#52C41A',
fileName: '#52C41A.css',
modifyVars: {
'@primary-color': '#52C41A'
}
},
{
key: '#2F54EB',
fileName: '#2F54EB.css',
modifyVars: {
'@primary-color': '#2F54EB'
}
},
{
key: '#722ED1',
fileName: '#722ED1.css',
modifyVars: {
'@primary-color': '#722ED1'
}
},
{
key: '#F5222D',
theme: 'dark',
fileName: 'dark-#F5222D.css',
modifyVars: {
'@primary-color': '#F5222D'
}
},
{
key: '#FA541C',
theme: 'dark',
fileName: 'dark-#FA541C.css',
modifyVars: {
'@primary-color': '#FA541C'
}
},
{
key: '#FAAD14',
theme: 'dark',
fileName: 'dark-#FAAD14.css',
modifyVars: {
'@primary-color': '#FAAD14'
}
},
{
key: '#13C2C2',
theme: 'dark',
fileName: 'dark-#13C2C2.css',
modifyVars: {
'@primary-color': '#13C2C2'
}
},
{
key: '#52C41A',
theme: 'dark',
fileName: 'dark-#52C41A.css',
modifyVars: {
'@primary-color': '#52C41A'
}
},
{
key: '#2F54EB',
theme: 'dark',
fileName: 'dark-#2F54EB.css',
modifyVars: {
'@primary-color': '#2F54EB'
}
},
{
key: '#722ED1',
theme: 'dark',
fileName: 'dark-#722ED1.css',
modifyVars: {
'@primary-color': '#722ED1'
}
}
]
}

9
web_src/deploy/caddy.conf

@ -0,0 +1,9 @@
0.0.0.0:80 {
gzip
root /usr/share/nginx/html
rewrite {
r .*
to {path} /
}
}

24
web_src/deploy/nginx.conf

@ -0,0 +1,24 @@
server {
listen 80;
server_name _;
# gzip config
gzip on;
gzip_min_length 1k;
gzip_comp_level 6;
gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
root /usr/share/nginx/html;
include /etc/nginx/mime.types;
location / {
try_files $uri $uri/ /index.html;
}
# location /api {
# proxy_pass https://preview.pro.antdv.com/api;
# proxy_set_header X-Forwarded-Proto $scheme;
# proxy_set_header X-Real-IP $remote_addr;
# }
}

18
web_src/index.html

@ -1,18 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>国标28181</title>
<link rel="stylesheet" type="text/css" href="./static/css/iconfont.css">
<link rel="stylesheet" type="text/css" href="./static/css/login.css">
</head>
<body>
<script type="text/javascript" src="./static/js/jessibuca/index.js"></script>
<script type="text/javascript" src="./static/js/EasyWasmPlayer.js"></script>
<script type="text/javascript" src="./static/js/ZLMRTCClient.js"></script>
<script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&ak=rk73w8dv1rkE4UdZsataG68VarhYQzrx&s=1"></script>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save