Commit 9e8cab609d32a5f2143a726a26437cc4d7b8c8da
1 parent
dbc525e8
添加角色相关的接口,用户信息添加角色信息
Showing
29 changed files
with
598 additions
and
134 deletions
sql/mysql.sql
| @@ -227,12 +227,22 @@ create table user | @@ -227,12 +227,22 @@ create table user | ||
| 227 | username varchar(255) not null, | 227 | username varchar(255) not null, |
| 228 | password varchar(255) not null, | 228 | password varchar(255) not null, |
| 229 | roleId int not null, | 229 | roleId int not null, |
| 230 | - create_time varchar(50) not null, | ||
| 231 | - update_time varchar(50) not null | 230 | + createTime varchar(50) not null, |
| 231 | + updateTime varchar(50) not null | ||
| 232 | ); | 232 | ); |
| 233 | 233 | ||
| 234 | create unique index user_username_uindex | 234 | create unique index user_username_uindex |
| 235 | on user (username); | 235 | on user (username); |
| 236 | 236 | ||
| 237 | -insert into user (username, password, roleId, create_time, update_time) values ('admin', '21232f297a57a5a743894a0e4a801fc3', '0', '2021-04-13 14:14:57', '2021-04-13 14:14:57'); | 237 | +insert into user (username, password, roleId, createTime, updateTime) values ('admin', '21232f297a57a5a743894a0e4a801fc3', '1', '2021-04-13 14:14:57', '2021-04-13 14:14:57'); |
| 238 | + | ||
| 239 | +create table role ( | ||
| 240 | + id int auto_increment | ||
| 241 | + primary key, | ||
| 242 | + name TEXT NOT NULL, | ||
| 243 | + authority TEXT NOT NULL, | ||
| 244 | + createTime varchar(50) not null, | ||
| 245 | + updateTime varchar(50) not null | ||
| 246 | +); | ||
| 247 | +insert into role (id, name, authority, createTime, updateTime) values ('1', 'admin', '0', '2021-04-13 14:14:57', '2021-04-13 14:14:57'); | ||
| 238 | 248 |
src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java
| @@ -2,71 +2,101 @@ package com.genersoft.iot.vmp.conf; | @@ -2,71 +2,101 @@ package com.genersoft.iot.vmp.conf; | ||
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | import org.springframework.beans.factory.annotation.Value; | 4 | import org.springframework.beans.factory.annotation.Value; |
| 5 | +import org.springframework.boot.context.properties.ConfigurationProperties; | ||
| 5 | import org.springframework.context.annotation.Configuration; | 6 | import org.springframework.context.annotation.Configuration; |
| 7 | +import org.springframework.stereotype.Component; | ||
| 6 | 8 | ||
| 7 | -@Configuration("sipConfig") | 9 | +@Component |
| 10 | +@ConfigurationProperties(prefix = "sip", ignoreInvalidFields = true) | ||
| 8 | public class SipConfig { | 11 | public class SipConfig { |
| 9 | 12 | ||
| 10 | - @Value("${sip.ip}") | ||
| 11 | - private String sipIp; | 13 | + private String ip; |
| 12 | 14 | ||
| 13 | /** | 15 | /** |
| 14 | - * 默认使用sip.ip | 16 | + * 默认使用 0.0.0.0 |
| 15 | */ | 17 | */ |
| 16 | - @Value("${sip.monitor-ip:0.0.0.0}") | ||
| 17 | - private String monitorIp; | 18 | + private String monitorIp = "0.0.0.0"; |
| 18 | 19 | ||
| 19 | - @Value("${sip.port}") | ||
| 20 | - private Integer sipPort; | 20 | + private Integer port; |
| 21 | 21 | ||
| 22 | - @Value("${sip.domain}") | ||
| 23 | - private String sipDomain; | 22 | + private String domain; |
| 24 | 23 | ||
| 25 | - @Value("${sip.id}") | ||
| 26 | - private String sipId; | 24 | + private String id; |
| 27 | 25 | ||
| 28 | - @Value("${sip.password}") | ||
| 29 | - private String sipPassword; | 26 | + private String password; |
| 30 | 27 | ||
| 31 | - @Value("${sip.ptz.speed:50}") | ||
| 32 | - Integer speed; | 28 | + Integer ptzSpeed = 50; |
| 33 | 29 | ||
| 34 | - @Value("${sip.keepalive-timeout:180}") | ||
| 35 | - Integer keepaliveTimeOut; | 30 | + Integer keepaliveTimeOut = 180; |
| 36 | 31 | ||
| 37 | - @Value("${sip.register-time-interval:60}") | ||
| 38 | - Integer registerTimeInterval; | 32 | + Integer registerTimeInterval = 60; |
| 33 | + | ||
| 34 | + public void setIp(String ip) { | ||
| 35 | + this.ip = ip; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + public void setMonitorIp(String monitorIp) { | ||
| 39 | + this.monitorIp = monitorIp; | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + public void setPort(Integer port) { | ||
| 43 | + this.port = port; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + public void setDomain(String domain) { | ||
| 47 | + this.domain = domain; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + public void setId(String id) { | ||
| 51 | + this.id = id; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + public void setPassword(String password) { | ||
| 55 | + this.password = password; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + public void setPtzSpeed(Integer ptzSpeed) { | ||
| 59 | + this.ptzSpeed = ptzSpeed; | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + public void setKeepaliveTimeOut(Integer keepaliveTimeOut) { | ||
| 63 | + this.keepaliveTimeOut = keepaliveTimeOut; | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + public void setRegisterTimeInterval(Integer registerTimeInterval) { | ||
| 67 | + this.registerTimeInterval = registerTimeInterval; | ||
| 68 | + } | ||
| 39 | 69 | ||
| 40 | public String getMonitorIp() { | 70 | public String getMonitorIp() { |
| 41 | return monitorIp; | 71 | return monitorIp; |
| 42 | } | 72 | } |
| 43 | 73 | ||
| 44 | - public String getSipIp() { | ||
| 45 | - return sipIp; | 74 | + public String getIp() { |
| 75 | + return ip; | ||
| 46 | } | 76 | } |
| 47 | 77 | ||
| 48 | 78 | ||
| 49 | - public Integer getSipPort() { | ||
| 50 | - return sipPort; | 79 | + public Integer getPort() { |
| 80 | + return port; | ||
| 51 | } | 81 | } |
| 52 | 82 | ||
| 53 | 83 | ||
| 54 | - public String getSipDomain() { | ||
| 55 | - return sipDomain; | 84 | + public String getDomain() { |
| 85 | + return domain; | ||
| 56 | } | 86 | } |
| 57 | 87 | ||
| 58 | 88 | ||
| 59 | - public String getSipId() { | ||
| 60 | - return sipId; | 89 | + public String getId() { |
| 90 | + return id; | ||
| 61 | } | 91 | } |
| 62 | 92 | ||
| 63 | - public String getSipPassword() { | ||
| 64 | - return sipPassword; | 93 | + public String getPassword() { |
| 94 | + return password; | ||
| 65 | } | 95 | } |
| 66 | 96 | ||
| 67 | 97 | ||
| 68 | - public Integer getSpeed() { | ||
| 69 | - return speed; | 98 | + public Integer getPtzSpeed() { |
| 99 | + return ptzSpeed; | ||
| 70 | } | 100 | } |
| 71 | 101 | ||
| 72 | public Integer getKeepaliveTimeOut() { | 102 | public Integer getKeepaliveTimeOut() { |
src/main/java/com/genersoft/iot/vmp/conf/security/AnonymousAuthenticationEntryPoint.java
| @@ -28,8 +28,8 @@ public class AnonymousAuthenticationEntryPoint implements AuthenticationEntryPoi | @@ -28,8 +28,8 @@ public class AnonymousAuthenticationEntryPoint implements AuthenticationEntryPoi | ||
| 28 | response.setHeader("Access-Control-Allow-Headers", "token, Accept, Origin, X-Requested-With, Content-Type, Last-Modified"); | 28 | response.setHeader("Access-Control-Allow-Headers", "token, Accept, Origin, X-Requested-With, Content-Type, Last-Modified"); |
| 29 | response.setHeader("Content-type", "application/json;charset=UTF-8"); | 29 | response.setHeader("Content-type", "application/json;charset=UTF-8"); |
| 30 | JSONObject jsonObject = new JSONObject(); | 30 | JSONObject jsonObject = new JSONObject(); |
| 31 | - jsonObject.put("msg", e.getMessage()); | ||
| 32 | jsonObject.put("code", "-1"); | 31 | jsonObject.put("code", "-1"); |
| 32 | + jsonObject.put("msg", "请登录后重新请求"); | ||
| 33 | response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); | 33 | response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); |
| 34 | try { | 34 | try { |
| 35 | response.getWriter().print(jsonObject.toJSONString()); | 35 | response.getWriter().print(jsonObject.toJSONString()); |
src/main/java/com/genersoft/iot/vmp/conf/security/dto/LoginUser.java
| 1 | package com.genersoft.iot.vmp.conf.security.dto; | 1 | package com.genersoft.iot.vmp.conf.security.dto; |
| 2 | 2 | ||
| 3 | +import com.genersoft.iot.vmp.storager.dao.dto.Role; | ||
| 3 | import com.genersoft.iot.vmp.storager.dao.dto.User; | 4 | import com.genersoft.iot.vmp.storager.dao.dto.User; |
| 4 | import org.springframework.security.core.CredentialsContainer; | 5 | import org.springframework.security.core.CredentialsContainer; |
| 5 | import org.springframework.security.core.GrantedAuthority; | 6 | import org.springframework.security.core.GrantedAuthority; |
| @@ -93,8 +94,8 @@ public class LoginUser implements UserDetails, CredentialsContainer { | @@ -93,8 +94,8 @@ public class LoginUser implements UserDetails, CredentialsContainer { | ||
| 93 | return user.getId(); | 94 | return user.getId(); |
| 94 | } | 95 | } |
| 95 | 96 | ||
| 96 | - public int getRoleId() { | ||
| 97 | - return user.getRoleId(); | 97 | + public Role getRole() { |
| 98 | + return user.getRole(); | ||
| 98 | } | 99 | } |
| 99 | 100 | ||
| 100 | 101 |
src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java
| @@ -93,15 +93,15 @@ public class SipLayer implements SipListener { | @@ -93,15 +93,15 @@ public class SipLayer implements SipListener { | ||
| 93 | ListeningPoint tcpListeningPoint = null; | 93 | ListeningPoint tcpListeningPoint = null; |
| 94 | SipProviderImpl tcpSipProvider = null; | 94 | SipProviderImpl tcpSipProvider = null; |
| 95 | try { | 95 | try { |
| 96 | - tcpListeningPoint = sipStack.createListeningPoint(sipConfig.getMonitorIp(), sipConfig.getSipPort(), "TCP"); | 96 | + tcpListeningPoint = sipStack.createListeningPoint(sipConfig.getMonitorIp(), sipConfig.getPort(), "TCP"); |
| 97 | tcpSipProvider = (SipProviderImpl)sipStack.createSipProvider(tcpListeningPoint); | 97 | tcpSipProvider = (SipProviderImpl)sipStack.createSipProvider(tcpListeningPoint); |
| 98 | tcpSipProvider.addSipListener(this); | 98 | tcpSipProvider.addSipListener(this); |
| 99 | - logger.info("Sip Server TCP 启动成功 port {" + sipConfig.getMonitorIp() + ":" + sipConfig.getSipPort() + "}"); | 99 | + logger.info("Sip Server TCP 启动成功 port {" + sipConfig.getMonitorIp() + ":" + sipConfig.getPort() + "}"); |
| 100 | } catch (TransportNotSupportedException e) { | 100 | } catch (TransportNotSupportedException e) { |
| 101 | e.printStackTrace(); | 101 | e.printStackTrace(); |
| 102 | } catch (InvalidArgumentException e) { | 102 | } catch (InvalidArgumentException e) { |
| 103 | logger.error("无法使用 [ {}:{} ]作为SIP[ TCP ]服务,可排查: 1. sip.monitor-ip 是否为本机网卡IP; 2. sip.port 是否已被占用" | 103 | logger.error("无法使用 [ {}:{} ]作为SIP[ TCP ]服务,可排查: 1. sip.monitor-ip 是否为本机网卡IP; 2. sip.port 是否已被占用" |
| 104 | - , sipConfig.getMonitorIp(), sipConfig.getSipPort()); | 104 | + , sipConfig.getMonitorIp(), sipConfig.getPort()); |
| 105 | } catch (TooManyListenersException e) { | 105 | } catch (TooManyListenersException e) { |
| 106 | e.printStackTrace(); | 106 | e.printStackTrace(); |
| 107 | } catch (ObjectInUseException e) { | 107 | } catch (ObjectInUseException e) { |
| @@ -116,7 +116,7 @@ public class SipLayer implements SipListener { | @@ -116,7 +116,7 @@ public class SipLayer implements SipListener { | ||
| 116 | ListeningPoint udpListeningPoint = null; | 116 | ListeningPoint udpListeningPoint = null; |
| 117 | SipProviderImpl udpSipProvider = null; | 117 | SipProviderImpl udpSipProvider = null; |
| 118 | try { | 118 | try { |
| 119 | - udpListeningPoint = sipStack.createListeningPoint(sipConfig.getMonitorIp(), sipConfig.getSipPort(), "UDP"); | 119 | + udpListeningPoint = sipStack.createListeningPoint(sipConfig.getMonitorIp(), sipConfig.getPort(), "UDP"); |
| 120 | udpSipProvider = (SipProviderImpl)sipStack.createSipProvider(udpListeningPoint); | 120 | udpSipProvider = (SipProviderImpl)sipStack.createSipProvider(udpListeningPoint); |
| 121 | udpSipProvider.addSipListener(this); | 121 | udpSipProvider.addSipListener(this); |
| 122 | // udpSipProvider.setAutomaticDialogSupportEnabled(false); | 122 | // udpSipProvider.setAutomaticDialogSupportEnabled(false); |
| @@ -124,13 +124,13 @@ public class SipLayer implements SipListener { | @@ -124,13 +124,13 @@ public class SipLayer implements SipListener { | ||
| 124 | e.printStackTrace(); | 124 | e.printStackTrace(); |
| 125 | } catch (InvalidArgumentException e) { | 125 | } catch (InvalidArgumentException e) { |
| 126 | logger.error("无法使用 [ {}:{} ]作为SIP[ UDP ]服务,可排查: 1. sip.monitor-ip 是否为本机网卡IP; 2. sip.port 是否已被占用" | 126 | logger.error("无法使用 [ {}:{} ]作为SIP[ UDP ]服务,可排查: 1. sip.monitor-ip 是否为本机网卡IP; 2. sip.port 是否已被占用" |
| 127 | - , sipConfig.getMonitorIp(), sipConfig.getSipPort()); | 127 | + , sipConfig.getMonitorIp(), sipConfig.getPort()); |
| 128 | } catch (TooManyListenersException e) { | 128 | } catch (TooManyListenersException e) { |
| 129 | e.printStackTrace(); | 129 | e.printStackTrace(); |
| 130 | } catch (ObjectInUseException e) { | 130 | } catch (ObjectInUseException e) { |
| 131 | e.printStackTrace(); | 131 | e.printStackTrace(); |
| 132 | } | 132 | } |
| 133 | - logger.info("Sip Server UDP 启动成功 port [" + sipConfig.getMonitorIp() + ":" + sipConfig.getSipPort() + "]"); | 133 | + logger.info("Sip Server UDP 启动成功 port [" + sipConfig.getMonitorIp() + ":" + sipConfig.getPort() + "]"); |
| 134 | return udpSipProvider; | 134 | return udpSipProvider; |
| 135 | } | 135 | } |
| 136 | 136 |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java
| @@ -39,13 +39,13 @@ public class SIPRequestHeaderPlarformProvider { | @@ -39,13 +39,13 @@ public class SIPRequestHeaderPlarformProvider { | ||
| 39 | SipURI requestURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIP() + ":" + parentPlatform.getServerPort()); | 39 | SipURI requestURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIP() + ":" + parentPlatform.getServerPort()); |
| 40 | // via | 40 | // via |
| 41 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); | 41 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 42 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getSipIp(), sipConfig.getSipPort(), | 42 | + ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), |
| 43 | parentPlatform.getTransport(), viaTag); | 43 | parentPlatform.getTransport(), viaTag); |
| 44 | viaHeader.setRPort(); | 44 | viaHeader.setRPort(); |
| 45 | viaHeaders.add(viaHeader); | 45 | viaHeaders.add(viaHeader); |
| 46 | // from | 46 | // from |
| 47 | SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), | 47 | SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), |
| 48 | - sipConfig.getSipIp() + ":" + sipConfig.getSipPort()); | 48 | + sipConfig.getIp() + ":" + sipConfig.getPort()); |
| 49 | Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | 49 | Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); |
| 50 | FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); | 50 | FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); |
| 51 | // to | 51 | // to |
| @@ -75,7 +75,7 @@ public class SIPRequestHeaderPlarformProvider { | @@ -75,7 +75,7 @@ public class SIPRequestHeaderPlarformProvider { | ||
| 75 | 75 | ||
| 76 | public Request createRegisterRequest(@NotNull ParentPlatform platform, long CSeq, String fromTag, String viaTag, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException { | 76 | public Request createRegisterRequest(@NotNull ParentPlatform platform, long CSeq, String fromTag, String viaTag, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException { |
| 77 | Request request = null; | 77 | Request request = null; |
| 78 | - String sipAddress = sipConfig.getSipIp() + ":" + sipConfig.getSipPort(); | 78 | + String sipAddress = sipConfig.getIp() + ":" + sipConfig.getPort(); |
| 79 | //请求行 | 79 | //请求行 |
| 80 | SipURI requestLine = sipFactory.createAddressFactory().createSipURI(platform.getServerGBId(), | 80 | SipURI requestLine = sipFactory.createAddressFactory().createSipURI(platform.getServerGBId(), |
| 81 | platform.getServerIP() + ":" + platform.getServerPort()); | 81 | platform.getServerIP() + ":" + platform.getServerPort()); |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
| @@ -37,16 +37,16 @@ public class SIPRequestHeaderProvider { | @@ -37,16 +37,16 @@ public class SIPRequestHeaderProvider { | ||
| 37 | SipURI requestURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); | 37 | SipURI requestURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); |
| 38 | // via | 38 | // via |
| 39 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); | 39 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 40 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getSipIp(), sipConfig.getSipPort(), device.getTransport(), viaTag); | 40 | + ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag); |
| 41 | viaHeader.setRPort(); | 41 | viaHeader.setRPort(); |
| 42 | viaHeaders.add(viaHeader); | 42 | viaHeaders.add(viaHeader); |
| 43 | // from | 43 | // from |
| 44 | - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getSipId(), | ||
| 45 | - sipConfig.getSipIp() + ":" + sipConfig.getSipPort()); | 44 | + SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), |
| 45 | + sipConfig.getIp() + ":" + sipConfig.getPort()); | ||
| 46 | Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | 46 | Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); |
| 47 | FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); | 47 | FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); |
| 48 | // to | 48 | // to |
| 49 | - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), sipConfig.getSipDomain()); | 49 | + SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), sipConfig.getDomain()); |
| 50 | Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | 50 | Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); |
| 51 | ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, toTag); | 51 | ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, toTag); |
| 52 | 52 | ||
| @@ -68,16 +68,16 @@ public class SIPRequestHeaderProvider { | @@ -68,16 +68,16 @@ public class SIPRequestHeaderProvider { | ||
| 68 | SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress()); | 68 | SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress()); |
| 69 | //via | 69 | //via |
| 70 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); | 70 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 71 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getSipIp(), sipConfig.getSipPort(), device.getTransport(), viaTag); | 71 | + ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag); |
| 72 | viaHeader.setRPort(); | 72 | viaHeader.setRPort(); |
| 73 | viaHeaders.add(viaHeader); | 73 | viaHeaders.add(viaHeader); |
| 74 | 74 | ||
| 75 | //from | 75 | //from |
| 76 | - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getSipId(),sipConfig.getSipDomain()); | 76 | + SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain()); |
| 77 | Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | 77 | Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); |
| 78 | FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack | 78 | FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack |
| 79 | //to | 79 | //to |
| 80 | - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId,sipConfig.getSipDomain()); | 80 | + SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId,sipConfig.getDomain()); |
| 81 | Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | 81 | Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); |
| 82 | ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress,null); | 82 | ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress,null); |
| 83 | 83 | ||
| @@ -88,11 +88,11 @@ public class SIPRequestHeaderProvider { | @@ -88,11 +88,11 @@ public class SIPRequestHeaderProvider { | ||
| 88 | CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(1L, Request.INVITE); | 88 | CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(1L, Request.INVITE); |
| 89 | request = sipFactory.createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | 89 | request = sipFactory.createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); |
| 90 | 90 | ||
| 91 | - Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getSipId(), sipConfig.getSipIp()+":"+sipConfig.getSipPort())); | ||
| 92 | - // Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getSipId(), device.getHost().getIp()+":"+device.getHost().getPort())); | 91 | + Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); |
| 92 | + // Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort())); | ||
| 93 | request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); | 93 | request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); |
| 94 | // Subject | 94 | // Subject |
| 95 | - SubjectHeader subjectHeader = sipFactory.createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getSipId(), 0)); | 95 | + SubjectHeader subjectHeader = sipFactory.createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0)); |
| 96 | request.addHeader(subjectHeader); | 96 | request.addHeader(subjectHeader); |
| 97 | ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP"); | 97 | ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP"); |
| 98 | request.setContent(content, contentTypeHeader); | 98 | request.setContent(content, contentTypeHeader); |
| @@ -109,11 +109,11 @@ public class SIPRequestHeaderProvider { | @@ -109,11 +109,11 @@ public class SIPRequestHeaderProvider { | ||
| 109 | viaHeader.setRPort(); | 109 | viaHeader.setRPort(); |
| 110 | viaHeaders.add(viaHeader); | 110 | viaHeaders.add(viaHeader); |
| 111 | //from | 111 | //from |
| 112 | - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getSipId(),sipConfig.getSipDomain()); | 112 | + SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain()); |
| 113 | Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | 113 | Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); |
| 114 | FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack | 114 | FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack |
| 115 | //to | 115 | //to |
| 116 | - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId,sipConfig.getSipDomain()); | 116 | + SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId,sipConfig.getDomain()); |
| 117 | Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | 117 | Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); |
| 118 | ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress,null); | 118 | ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress,null); |
| 119 | 119 | ||
| @@ -124,8 +124,8 @@ public class SIPRequestHeaderProvider { | @@ -124,8 +124,8 @@ public class SIPRequestHeaderProvider { | ||
| 124 | CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(1L, Request.INVITE); | 124 | CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(1L, Request.INVITE); |
| 125 | request = sipFactory.createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | 125 | request = sipFactory.createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); |
| 126 | 126 | ||
| 127 | - Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getSipId(), sipConfig.getSipIp()+":"+sipConfig.getSipPort())); | ||
| 128 | - // Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getSipId(), device.getHost().getIp()+":"+device.getHost().getPort())); | 127 | + Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); |
| 128 | + // Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort())); | ||
| 129 | request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); | 129 | request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); |
| 130 | 130 | ||
| 131 | ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP"); | 131 | ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP"); |
| @@ -139,14 +139,14 @@ public class SIPRequestHeaderProvider { | @@ -139,14 +139,14 @@ public class SIPRequestHeaderProvider { | ||
| 139 | SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress()); | 139 | SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress()); |
| 140 | // via | 140 | // via |
| 141 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); | 141 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 142 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getSipIp(), sipConfig.getSipPort(), device.getTransport(), viaTag); | 142 | + ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag); |
| 143 | viaHeaders.add(viaHeader); | 143 | viaHeaders.add(viaHeader); |
| 144 | //from | 144 | //from |
| 145 | - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getSipId(),sipConfig.getSipDomain()); | 145 | + SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain()); |
| 146 | Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | 146 | Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); |
| 147 | FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack | 147 | FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack |
| 148 | //to | 148 | //to |
| 149 | - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId,sipConfig.getSipDomain()); | 149 | + SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId,sipConfig.getDomain()); |
| 150 | Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | 150 | Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); |
| 151 | ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress,toTag); | 151 | ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress,toTag); |
| 152 | 152 | ||
| @@ -158,7 +158,7 @@ public class SIPRequestHeaderProvider { | @@ -158,7 +158,7 @@ public class SIPRequestHeaderProvider { | ||
| 158 | CallIdHeader callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(callId); | 158 | CallIdHeader callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(callId); |
| 159 | request = sipFactory.createMessageFactory().createRequest(requestLine, Request.BYE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | 159 | request = sipFactory.createMessageFactory().createRequest(requestLine, Request.BYE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); |
| 160 | 160 | ||
| 161 | - Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getSipId(), sipConfig.getSipIp()+":"+sipConfig.getSipPort())); | 161 | + Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); |
| 162 | 162 | ||
| 163 | return request; | 163 | return request; |
| 164 | } | 164 | } |
| @@ -169,17 +169,17 @@ public class SIPRequestHeaderProvider { | @@ -169,17 +169,17 @@ public class SIPRequestHeaderProvider { | ||
| 169 | SipURI requestURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); | 169 | SipURI requestURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); |
| 170 | // via | 170 | // via |
| 171 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); | 171 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 172 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getSipIp(), sipConfig.getSipPort(), | 172 | + ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), |
| 173 | device.getTransport(), viaTag); | 173 | device.getTransport(), viaTag); |
| 174 | viaHeader.setRPort(); | 174 | viaHeader.setRPort(); |
| 175 | viaHeaders.add(viaHeader); | 175 | viaHeaders.add(viaHeader); |
| 176 | // from | 176 | // from |
| 177 | - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getSipId(), | ||
| 178 | - sipConfig.getSipIp() + ":" + sipConfig.getSipPort()); | 177 | + SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), |
| 178 | + sipConfig.getIp() + ":" + sipConfig.getPort()); | ||
| 179 | Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | 179 | Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); |
| 180 | FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); | 180 | FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); |
| 181 | // to | 181 | // to |
| 182 | - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), sipConfig.getSipDomain()); | 182 | + SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), sipConfig.getDomain()); |
| 183 | Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | 183 | Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); |
| 184 | ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, toTag); | 184 | ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, toTag); |
| 185 | 185 | ||
| @@ -192,7 +192,7 @@ public class SIPRequestHeaderProvider { | @@ -192,7 +192,7 @@ public class SIPRequestHeaderProvider { | ||
| 192 | toHeader, viaHeaders, maxForwards); | 192 | toHeader, viaHeaders, maxForwards); |
| 193 | 193 | ||
| 194 | 194 | ||
| 195 | - Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getSipId(), sipConfig.getSipIp()+":"+sipConfig.getSipPort())); | 195 | + Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); |
| 196 | request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); | 196 | request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); |
| 197 | 197 | ||
| 198 | // Expires | 198 | // Expires |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| @@ -105,7 +105,7 @@ public class SIPCommander implements ISIPCommander { | @@ -105,7 +105,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 105 | */ | 105 | */ |
| 106 | @Override | 106 | @Override |
| 107 | public boolean ptzdirectCmd(Device device, String channelId, int leftRight, int upDown) { | 107 | public boolean ptzdirectCmd(Device device, String channelId, int leftRight, int upDown) { |
| 108 | - return ptzCmd(device, channelId, leftRight, upDown, 0, sipConfig.getSpeed(), 0); | 108 | + return ptzCmd(device, channelId, leftRight, upDown, 0, sipConfig.getPtzSpeed(), 0); |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | /** | 111 | /** |
| @@ -131,7 +131,7 @@ public class SIPCommander implements ISIPCommander { | @@ -131,7 +131,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 131 | */ | 131 | */ |
| 132 | @Override | 132 | @Override |
| 133 | public boolean ptzZoomCmd(Device device, String channelId, int inOut) { | 133 | public boolean ptzZoomCmd(Device device, String channelId, int inOut) { |
| 134 | - return ptzCmd(device, channelId, 0, 0, inOut, 0, sipConfig.getSpeed()); | 134 | + return ptzCmd(device, channelId, 0, 0, inOut, 0, sipConfig.getPtzSpeed()); |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | /** | 137 | /** |
| @@ -468,7 +468,7 @@ public class SIPCommander implements ISIPCommander { | @@ -468,7 +468,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 468 | 468 | ||
| 469 | StringBuffer content = new StringBuffer(200); | 469 | StringBuffer content = new StringBuffer(200); |
| 470 | content.append("v=0\r\n"); | 470 | content.append("v=0\r\n"); |
| 471 | - content.append("o="+sipConfig.getSipId()+" 0 0 IN IP4 "+sipConfig.getSipIp()+"\r\n"); | 471 | + content.append("o="+sipConfig.getId()+" 0 0 IN IP4 "+sipConfig.getIp()+"\r\n"); |
| 472 | content.append("s=Playback\r\n"); | 472 | content.append("s=Playback\r\n"); |
| 473 | content.append("u="+channelId+":0\r\n"); | 473 | content.append("u="+channelId+":0\r\n"); |
| 474 | content.append("c=IN IP4 "+mediaServerItem.getSdpIp()+"\r\n"); | 474 | content.append("c=IN IP4 "+mediaServerItem.getSdpIp()+"\r\n"); |
| @@ -575,7 +575,7 @@ public class SIPCommander implements ISIPCommander { | @@ -575,7 +575,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 575 | 575 | ||
| 576 | StringBuffer content = new StringBuffer(200); | 576 | StringBuffer content = new StringBuffer(200); |
| 577 | content.append("v=0\r\n"); | 577 | content.append("v=0\r\n"); |
| 578 | - content.append("o="+sipConfig.getSipId()+" 0 0 IN IP4 "+sipConfig.getSipIp()+"\r\n"); | 578 | + content.append("o="+sipConfig.getId()+" 0 0 IN IP4 "+sipConfig.getIp()+"\r\n"); |
| 579 | content.append("s=Download\r\n"); | 579 | content.append("s=Download\r\n"); |
| 580 | content.append("u="+channelId+":0\r\n"); | 580 | content.append("u="+channelId+":0\r\n"); |
| 581 | content.append("c=IN IP4 "+mediaServerItem.getSdpIp()+"\r\n"); | 581 | content.append("c=IN IP4 "+mediaServerItem.getSdpIp()+"\r\n"); |
| @@ -749,7 +749,7 @@ public class SIPCommander implements ISIPCommander { | @@ -749,7 +749,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 749 | broadcastXml.append("<Notify>\r\n"); | 749 | broadcastXml.append("<Notify>\r\n"); |
| 750 | broadcastXml.append("<CmdType>Broadcast</CmdType>\r\n"); | 750 | broadcastXml.append("<CmdType>Broadcast</CmdType>\r\n"); |
| 751 | broadcastXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n"); | 751 | broadcastXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n"); |
| 752 | - broadcastXml.append("<SourceID>" + sipConfig.getSipId() + "</SourceID>\r\n"); | 752 | + broadcastXml.append("<SourceID>" + sipConfig.getId() + "</SourceID>\r\n"); |
| 753 | broadcastXml.append("<TargetID>" + device.getDeviceId() + "</TargetID>\r\n"); | 753 | broadcastXml.append("<TargetID>" + device.getDeviceId() + "</TargetID>\r\n"); |
| 754 | broadcastXml.append("</Notify>\r\n"); | 754 | broadcastXml.append("</Notify>\r\n"); |
| 755 | 755 | ||
| @@ -774,7 +774,7 @@ public class SIPCommander implements ISIPCommander { | @@ -774,7 +774,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 774 | broadcastXml.append("<Notify>\r\n"); | 774 | broadcastXml.append("<Notify>\r\n"); |
| 775 | broadcastXml.append("<CmdType>Broadcast</CmdType>\r\n"); | 775 | broadcastXml.append("<CmdType>Broadcast</CmdType>\r\n"); |
| 776 | broadcastXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n"); | 776 | broadcastXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n"); |
| 777 | - broadcastXml.append("<SourceID>" + sipConfig.getSipId() + "</SourceID>\r\n"); | 777 | + broadcastXml.append("<SourceID>" + sipConfig.getId() + "</SourceID>\r\n"); |
| 778 | broadcastXml.append("<TargetID>" + device.getDeviceId() + "</TargetID>\r\n"); | 778 | broadcastXml.append("<TargetID>" + device.getDeviceId() + "</TargetID>\r\n"); |
| 779 | broadcastXml.append("</Notify>\r\n"); | 779 | broadcastXml.append("</Notify>\r\n"); |
| 780 | 780 |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
| @@ -550,7 +550,7 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { | @@ -550,7 +550,7 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { | ||
| 550 | deviceChannel.setStatus(gbStream.isStatus()?1:0); | 550 | deviceChannel.setStatus(gbStream.isStatus()?1:0); |
| 551 | // deviceChannel.setParentId(parentPlatform.getDeviceGBId()); | 551 | // deviceChannel.setParentId(parentPlatform.getDeviceGBId()); |
| 552 | deviceChannel.setRegisterWay(1); | 552 | deviceChannel.setRegisterWay(1); |
| 553 | - deviceChannel.setCivilCode(cmder.getSipConfig().getSipDomain()); | 553 | + deviceChannel.setCivilCode(cmder.getSipConfig().getDomain()); |
| 554 | deviceChannel.setModel("live"); | 554 | deviceChannel.setModel("live"); |
| 555 | deviceChannel.setOwner("wvp-pro"); | 555 | deviceChannel.setOwner("wvp-pro"); |
| 556 | // deviceChannel.setAddress("test"); | 556 | // deviceChannel.setAddress("test"); |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/RegisterRequestProcessor.java
| @@ -79,9 +79,9 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor { | @@ -79,9 +79,9 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor { | ||
| 79 | // 校验密码是否正确 | 79 | // 校验密码是否正确 |
| 80 | if (authorhead != null) { | 80 | if (authorhead != null) { |
| 81 | passwordCorrect = new DigestServerAuthenticationHelper().doAuthenticatePlainTextPassword(request, | 81 | passwordCorrect = new DigestServerAuthenticationHelper().doAuthenticatePlainTextPassword(request, |
| 82 | - sipConfig.getSipPassword()); | 82 | + sipConfig.getPassword()); |
| 83 | } | 83 | } |
| 84 | - if (StringUtils.isEmpty(sipConfig.getSipPassword())){ | 84 | + if (StringUtils.isEmpty(sipConfig.getPassword())){ |
| 85 | passwordCorrect = true; | 85 | passwordCorrect = true; |
| 86 | } | 86 | } |
| 87 | 87 | ||
| @@ -94,7 +94,7 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor { | @@ -94,7 +94,7 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor { | ||
| 94 | logger.info("[{}] 密码错误 回复401", requestAddress); | 94 | logger.info("[{}] 密码错误 回复401", requestAddress); |
| 95 | } | 95 | } |
| 96 | response = getMessageFactory().createResponse(Response.UNAUTHORIZED, request); | 96 | response = getMessageFactory().createResponse(Response.UNAUTHORIZED, request); |
| 97 | - new DigestServerAuthenticationHelper().generateChallenge(getHeaderFactory(), response, sipConfig.getSipDomain()); | 97 | + new DigestServerAuthenticationHelper().generateChallenge(getHeaderFactory(), response, sipConfig.getDomain()); |
| 98 | }else { | 98 | }else { |
| 99 | if (!passwordCorrect){ | 99 | if (!passwordCorrect){ |
| 100 | // 注册失败 | 100 | // 注册失败 |
src/main/java/com/genersoft/iot/vmp/service/IRoleService.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.service; | ||
| 2 | + | ||
| 3 | +import com.genersoft.iot.vmp.storager.dao.dto.Role; | ||
| 4 | + | ||
| 5 | +import java.util.List; | ||
| 6 | + | ||
| 7 | +public interface IRoleService { | ||
| 8 | + | ||
| 9 | + Role getRoleById(int id); | ||
| 10 | + | ||
| 11 | + int add(Role role); | ||
| 12 | + | ||
| 13 | + int delete(int id); | ||
| 14 | + | ||
| 15 | + List<Role> getAll(); | ||
| 16 | + | ||
| 17 | + int update(Role role); | ||
| 18 | +} |
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
| @@ -83,7 +83,7 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | @@ -83,7 +83,7 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | ||
| 83 | for (MediaServerItem mediaServerItem : mediaServerItemList) { | 83 | for (MediaServerItem mediaServerItem : mediaServerItemList) { |
| 84 | // 更新 | 84 | // 更新 |
| 85 | if (mediaServerItem.getSsrcConfig() == null) { | 85 | if (mediaServerItem.getSsrcConfig() == null) { |
| 86 | - SsrcConfig ssrcConfig = new SsrcConfig(mediaServerItem.getId(), null, sipConfig.getSipDomain()); | 86 | + SsrcConfig ssrcConfig = new SsrcConfig(mediaServerItem.getId(), null, sipConfig.getDomain()); |
| 87 | mediaServerItem.setSsrcConfig(ssrcConfig); | 87 | mediaServerItem.setSsrcConfig(ssrcConfig); |
| 88 | redisUtil.set(VideoManagerConstants.MEDIA_SERVER_PREFIX + mediaServerItem.getId(), mediaServerItem); | 88 | redisUtil.set(VideoManagerConstants.MEDIA_SERVER_PREFIX + mediaServerItem.getId(), mediaServerItem); |
| 89 | } | 89 | } |
| @@ -145,7 +145,7 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | @@ -145,7 +145,7 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | ||
| 145 | */ | 145 | */ |
| 146 | @Override | 146 | @Override |
| 147 | public void clearRTPServer(MediaServerItem mediaServerItem) { | 147 | public void clearRTPServer(MediaServerItem mediaServerItem) { |
| 148 | - mediaServerItem.setSsrcConfig(new SsrcConfig(mediaServerItem.getId(), null, sipConfig.getSipDomain())); | 148 | + mediaServerItem.setSsrcConfig(new SsrcConfig(mediaServerItem.getId(), null, sipConfig.getDomain())); |
| 149 | redisUtil.zAdd(VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX, mediaServerItem.getId(), 0); | 149 | redisUtil.zAdd(VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX, mediaServerItem.getId(), 0); |
| 150 | } | 150 | } |
| 151 | 151 | ||
| @@ -162,7 +162,7 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | @@ -162,7 +162,7 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | ||
| 162 | new SsrcConfig( | 162 | new SsrcConfig( |
| 163 | mediaServerItemInDataBase.getId(), | 163 | mediaServerItemInDataBase.getId(), |
| 164 | null, | 164 | null, |
| 165 | - sipConfig.getSipDomain() | 165 | + sipConfig.getDomain() |
| 166 | ) | 166 | ) |
| 167 | ); | 167 | ); |
| 168 | } | 168 | } |
| @@ -264,12 +264,12 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | @@ -264,12 +264,12 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | ||
| 264 | if (serverItemInRedis != null) { | 264 | if (serverItemInRedis != null) { |
| 265 | serverItemFromConfig.setSsrcConfig(serverItemInRedis.getSsrcConfig()); | 265 | serverItemFromConfig.setSsrcConfig(serverItemInRedis.getSsrcConfig()); |
| 266 | }else { | 266 | }else { |
| 267 | - serverItemFromConfig.setSsrcConfig(new SsrcConfig(serverItemFromConfig.getId(), null, sipConfig.getSipDomain())); | 267 | + serverItemFromConfig.setSsrcConfig(new SsrcConfig(serverItemFromConfig.getId(), null, sipConfig.getDomain())); |
| 268 | } | 268 | } |
| 269 | redisUtil.set(key, serverItemFromConfig); | 269 | redisUtil.set(key, serverItemFromConfig); |
| 270 | }else { | 270 | }else { |
| 271 | String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + serverItemFromConfig.getId(); | 271 | String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + serverItemFromConfig.getId(); |
| 272 | - serverItemFromConfig.setSsrcConfig(new SsrcConfig(serverItemFromConfig.getId(), null, sipConfig.getSipDomain())); | 272 | + serverItemFromConfig.setSsrcConfig(new SsrcConfig(serverItemFromConfig.getId(), null, sipConfig.getDomain())); |
| 273 | redisUtil.set(key, serverItemFromConfig); | 273 | redisUtil.set(key, serverItemFromConfig); |
| 274 | mediaServerMapper.add(serverItemFromConfig); | 274 | mediaServerMapper.add(serverItemFromConfig); |
| 275 | } | 275 | } |
| @@ -279,11 +279,11 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | @@ -279,11 +279,11 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | ||
| 279 | String now = this.format.format(System.currentTimeMillis()); | 279 | String now = this.format.format(System.currentTimeMillis()); |
| 280 | if (serverItem == null){ | 280 | if (serverItem == null){ |
| 281 | // 一个新的zlm接入wvp | 281 | // 一个新的zlm接入wvp |
| 282 | - serverItem = new MediaServerItem(zlmServerConfig, sipConfig.getSipIp()); | 282 | + serverItem = new MediaServerItem(zlmServerConfig, sipConfig.getIp()); |
| 283 | serverItem.setCreateTime(now); | 283 | serverItem.setCreateTime(now); |
| 284 | serverItem.setUpdateTime(now); | 284 | serverItem.setUpdateTime(now); |
| 285 | String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + serverItem.getId(); | 285 | String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + serverItem.getId(); |
| 286 | - serverItem.setSsrcConfig(new SsrcConfig(serverItem.getId(), null, sipConfig.getSipDomain())); | 286 | + serverItem.setSsrcConfig(new SsrcConfig(serverItem.getId(), null, sipConfig.getDomain())); |
| 287 | redisUtil.set(key, serverItem); | 287 | redisUtil.set(key, serverItem); |
| 288 | // 存入数据库 | 288 | // 存入数据库 |
| 289 | mediaServerMapper.add(serverItem); | 289 | mediaServerMapper.add(serverItem); |
src/main/java/com/genersoft/iot/vmp/service/impl/RoleServerImpl.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.service.impl; | ||
| 2 | + | ||
| 3 | +import com.genersoft.iot.vmp.service.IRoleService; | ||
| 4 | +import com.genersoft.iot.vmp.storager.dao.RoleMapper; | ||
| 5 | +import com.genersoft.iot.vmp.storager.dao.dto.Role; | ||
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 7 | +import org.springframework.stereotype.Service; | ||
| 8 | + | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +@Service | ||
| 12 | +public class RoleServerImpl implements IRoleService { | ||
| 13 | + | ||
| 14 | + @Autowired | ||
| 15 | + private RoleMapper roleMapper; | ||
| 16 | + | ||
| 17 | + @Override | ||
| 18 | + public Role getRoleById(int id) { | ||
| 19 | + return roleMapper.selectById(id); | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + @Override | ||
| 23 | + public int add(Role role) { | ||
| 24 | + return roleMapper.add(role); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + @Override | ||
| 28 | + public int delete(int id) { | ||
| 29 | + return roleMapper.delete(id); | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + @Override | ||
| 33 | + public List<Role> getAll() { | ||
| 34 | + return roleMapper.selectAll(); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + @Override | ||
| 38 | + public int update(Role role) { | ||
| 39 | + return roleMapper.update(role); | ||
| 40 | + } | ||
| 41 | +} |
src/main/java/com/genersoft/iot/vmp/storager/dao/RoleMapper.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.storager.dao; | ||
| 2 | + | ||
| 3 | +import com.genersoft.iot.vmp.storager.dao.dto.Role; | ||
| 4 | +import com.genersoft.iot.vmp.storager.dao.dto.User; | ||
| 5 | +import org.apache.ibatis.annotations.*; | ||
| 6 | +import org.springframework.stereotype.Repository; | ||
| 7 | + | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +@Mapper | ||
| 11 | +@Repository | ||
| 12 | +public interface RoleMapper { | ||
| 13 | + | ||
| 14 | + @Insert("INSERT INTO role (name, authority, createTime, updateTime) VALUES" + | ||
| 15 | + "('${name}', '${authority}', '${createTime}', '${updateTime}')") | ||
| 16 | + int add(Role role); | ||
| 17 | + | ||
| 18 | + @Update(value = {" <script>" + | ||
| 19 | + "UPDATE role " + | ||
| 20 | + "SET updateTime='${updateTime}' " + | ||
| 21 | + "<if test=\"name != null\">, name='${name}'</if>" + | ||
| 22 | + "<if test=\"authority != null\">, authority='${authority}'</if>" + | ||
| 23 | + "WHERE id != 1 and id=#{id}" + | ||
| 24 | + " </script>"}) | ||
| 25 | + int update(Role role); | ||
| 26 | + | ||
| 27 | + @Delete("DELETE FROM role WHERE id != 1 and id=#{id}") | ||
| 28 | + int delete(int id); | ||
| 29 | + | ||
| 30 | + @Select("select * FROM role WHERE id=#{id}") | ||
| 31 | + Role selectById(int id); | ||
| 32 | + | ||
| 33 | + @Select("select * FROM role") | ||
| 34 | + List<Role> selectAll(); | ||
| 35 | +} |
src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java
| @@ -10,32 +10,42 @@ import java.util.List; | @@ -10,32 +10,42 @@ import java.util.List; | ||
| 10 | @Repository | 10 | @Repository |
| 11 | public interface UserMapper { | 11 | public interface UserMapper { |
| 12 | 12 | ||
| 13 | - @Insert("INSERT INTO user (username, password, roleId, create_time, update_time) VALUES" + | ||
| 14 | - "('${username}', '${password}', '${roleId}', '${createTime}', '${updateTime}')") | 13 | + @Insert("INSERT INTO user (username, password, roleId, createTime, updateTime) VALUES" + |
| 14 | + "('${username}', '${password}', '${role.id}', '${createTime}', '${updateTime}')") | ||
| 15 | int add(User user); | 15 | int add(User user); |
| 16 | 16 | ||
| 17 | @Update(value = {" <script>" + | 17 | @Update(value = {" <script>" + |
| 18 | "UPDATE user " + | 18 | "UPDATE user " + |
| 19 | - "SET update_time='${updateTime}' " + | ||
| 20 | - "<if test=\"roleId != null\">, roleId='${roleId}'</if>" + | 19 | + "SET updateTime='${updateTime}' " + |
| 20 | + "<if test=\"role != null\">, roleId='${role.id}'</if>" + | ||
| 21 | "<if test=\"password != null\">, password='${password}'</if>" + | 21 | "<if test=\"password != null\">, password='${password}'</if>" + |
| 22 | "<if test=\"username != null\">, username='${username}'</if>" + | 22 | "<if test=\"username != null\">, username='${username}'</if>" + |
| 23 | "WHERE id=#{id}" + | 23 | "WHERE id=#{id}" + |
| 24 | " </script>"}) | 24 | " </script>"}) |
| 25 | int update(User user); | 25 | int update(User user); |
| 26 | 26 | ||
| 27 | - @Delete("DELETE FROM user WHERE id=#{id}") | 27 | + @Delete("DELETE FROM user WHERE id != 1 and id=#{id}") |
| 28 | int delete(int id); | 28 | int delete(int id); |
| 29 | 29 | ||
| 30 | - @Select("select * FROM user WHERE username=#{username} AND password=#{password}") | 30 | + @Select("select user.*, role.id roleID, role.name roleName, role.authority roleAuthority , role.createTime roleCreateTime , role.updateTime roleUpdateTime FROM user, role WHERE user.roleId=role.id and user.username=#{username} AND user.password=#{password}") |
| 31 | + @Results(id = "roleMap", value = { | ||
| 32 | + @Result(column = "roleID", property = "role.id"), | ||
| 33 | + @Result(column = "roleName", property = "role.name"), | ||
| 34 | + @Result(column = "roleAuthority", property = "role.authority"), | ||
| 35 | + @Result(column = "roleCreateTime", property = "role.createTime"), | ||
| 36 | + @Result(column = "roleUpdateTime", property = "role.updateTime") | ||
| 37 | + }) | ||
| 31 | User select(String username, String password); | 38 | User select(String username, String password); |
| 32 | 39 | ||
| 33 | - @Select("select * FROM user WHERE id=#{id}") | 40 | + @Select("select user.*, role.id roleID, role.name roleName, role.authority roleAuthority, role.createTime roleCreateTime , role.updateTime roleUpdateTime FROM user, role WHERE user.roleId=role.id and user.id=#{id}") |
| 41 | + @ResultMap(value="roleMap") | ||
| 34 | User selectById(int id); | 42 | User selectById(int id); |
| 35 | 43 | ||
| 36 | - @Select("select * FROM user WHERE username=#{username}") | 44 | + @Select("select user.*, role.id roleID, role.name roleName, role.authority roleAuthority, role.createTime roleCreateTime , role.updateTime roleUpdateTime FROM user, role WHERE user.roleId=role.id and username=#{username}") |
| 45 | + @ResultMap(value="roleMap") | ||
| 37 | User getUserByUsername(String username); | 46 | User getUserByUsername(String username); |
| 38 | 47 | ||
| 39 | - @Select("select * FROM user") | 48 | + @Select("select user.*, role.id roleID, role.name roleName, role.authority roleAuthority, role.createTime roleCreateTime , role.updateTime roleUpdateTime FROM user, role WHERE user.roleId=role.id") |
| 49 | + @ResultMap(value="roleMap") | ||
| 40 | List<User> selectAll(); | 50 | List<User> selectAll(); |
| 41 | } | 51 | } |
src/main/java/com/genersoft/iot/vmp/storager/dao/dto/Role.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.storager.dao.dto; | ||
| 2 | + | ||
| 3 | +public class Role { | ||
| 4 | + | ||
| 5 | + private int id; | ||
| 6 | + private String name; | ||
| 7 | + private String authority; | ||
| 8 | + private String createTime; | ||
| 9 | + private String updateTime; | ||
| 10 | + | ||
| 11 | + public int getId() { | ||
| 12 | + return id; | ||
| 13 | + } | ||
| 14 | + | ||
| 15 | + public void setId(int id) { | ||
| 16 | + this.id = id; | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + public String getName() { | ||
| 20 | + return name; | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + public void setName(String name) { | ||
| 24 | + this.name = name; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + public String getAuthority() { | ||
| 28 | + return authority; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public void setAuthority(String authority) { | ||
| 32 | + this.authority = authority; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + public String getCreateTime() { | ||
| 36 | + return createTime; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + public void setCreateTime(String createTime) { | ||
| 40 | + this.createTime = createTime; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + public String getUpdateTime() { | ||
| 44 | + return updateTime; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + public void setUpdateTime(String updateTime) { | ||
| 48 | + this.updateTime = updateTime; | ||
| 49 | + } | ||
| 50 | +} |
src/main/java/com/genersoft/iot/vmp/storager/dao/dto/User.java
| @@ -7,7 +7,7 @@ public class User { | @@ -7,7 +7,7 @@ public class User { | ||
| 7 | private String password; | 7 | private String password; |
| 8 | private String createTime; | 8 | private String createTime; |
| 9 | private String updateTime; | 9 | private String updateTime; |
| 10 | - private int roleId; | 10 | + private Role role; |
| 11 | 11 | ||
| 12 | public int getId() { | 12 | public int getId() { |
| 13 | return id; | 13 | return id; |
| @@ -41,14 +41,6 @@ public class User { | @@ -41,14 +41,6 @@ public class User { | ||
| 41 | this.createTime = createTime; | 41 | this.createTime = createTime; |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | - public int getRoleId() { | ||
| 45 | - return roleId; | ||
| 46 | - } | ||
| 47 | - | ||
| 48 | - public void setRoleId(int roleId) { | ||
| 49 | - this.roleId = roleId; | ||
| 50 | - } | ||
| 51 | - | ||
| 52 | public String getUpdateTime() { | 44 | public String getUpdateTime() { |
| 53 | return updateTime; | 45 | return updateTime; |
| 54 | } | 46 | } |
| @@ -56,4 +48,12 @@ public class User { | @@ -56,4 +48,12 @@ public class User { | ||
| 56 | public void setUpdateTime(String updateTime) { | 48 | public void setUpdateTime(String updateTime) { |
| 57 | this.updateTime = updateTime; | 49 | this.updateTime = updateTime; |
| 58 | } | 50 | } |
| 51 | + | ||
| 52 | + public Role getRole() { | ||
| 53 | + return role; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + public void setRole(Role role) { | ||
| 57 | + this.role = role; | ||
| 58 | + } | ||
| 59 | } | 59 | } |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java
| @@ -52,10 +52,10 @@ public class PlatformController { | @@ -52,10 +52,10 @@ public class PlatformController { | ||
| 52 | @GetMapping("/server_config") | 52 | @GetMapping("/server_config") |
| 53 | public ResponseEntity<JSONObject> serverConfig() { | 53 | public ResponseEntity<JSONObject> serverConfig() { |
| 54 | JSONObject result = new JSONObject(); | 54 | JSONObject result = new JSONObject(); |
| 55 | - result.put("deviceIp", sipConfig.getSipIp()); | ||
| 56 | - result.put("devicePort", sipConfig.getSipPort()); | ||
| 57 | - result.put("username", sipConfig.getSipId()); | ||
| 58 | - result.put("password", sipConfig.getSipPassword()); | 55 | + result.put("deviceIp", sipConfig.getIp()); |
| 56 | + result.put("devicePort", sipConfig.getPort()); | ||
| 57 | + result.put("username", sipConfig.getId()); | ||
| 58 | + result.put("password", sipConfig.getPassword()); | ||
| 59 | return new ResponseEntity<>(result, HttpStatus.OK); | 59 | return new ResponseEntity<>(result, HttpStatus.OK); |
| 60 | } | 60 | } |
| 61 | 61 |
src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java
| 1 | package com.genersoft.iot.vmp.vmanager.log; | 1 | package com.genersoft.iot.vmp.vmanager.log; |
| 2 | 2 | ||
| 3 | +import com.genersoft.iot.vmp.conf.UserSetup; | ||
| 4 | +import com.genersoft.iot.vmp.media.zlm.ZLMRunner; | ||
| 3 | import com.genersoft.iot.vmp.service.ILogService; | 5 | import com.genersoft.iot.vmp.service.ILogService; |
| 4 | import com.genersoft.iot.vmp.storager.dao.dto.LogDto; | 6 | import com.genersoft.iot.vmp.storager.dao.dto.LogDto; |
| 5 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; | 7 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| @@ -8,6 +10,8 @@ import io.swagger.annotations.Api; | @@ -8,6 +10,8 @@ import io.swagger.annotations.Api; | ||
| 8 | import io.swagger.annotations.ApiImplicitParam; | 10 | import io.swagger.annotations.ApiImplicitParam; |
| 9 | import io.swagger.annotations.ApiImplicitParams; | 11 | import io.swagger.annotations.ApiImplicitParams; |
| 10 | import io.swagger.annotations.ApiOperation; | 12 | import io.swagger.annotations.ApiOperation; |
| 13 | +import org.slf4j.Logger; | ||
| 14 | +import org.slf4j.LoggerFactory; | ||
| 11 | import org.springframework.beans.factory.annotation.Autowired; | 15 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | import org.springframework.http.HttpStatus; | 16 | import org.springframework.http.HttpStatus; |
| 13 | import org.springframework.http.ResponseEntity; | 17 | import org.springframework.http.ResponseEntity; |
| @@ -23,9 +27,14 @@ import java.text.SimpleDateFormat; | @@ -23,9 +27,14 @@ import java.text.SimpleDateFormat; | ||
| 23 | @RequestMapping("/api/log") | 27 | @RequestMapping("/api/log") |
| 24 | public class LogController { | 28 | public class LogController { |
| 25 | 29 | ||
| 30 | + private final static Logger logger = LoggerFactory.getLogger(LogController.class); | ||
| 31 | + | ||
| 26 | @Autowired | 32 | @Autowired |
| 27 | private ILogService logService; | 33 | private ILogService logService; |
| 28 | 34 | ||
| 35 | + @Autowired | ||
| 36 | + private UserSetup userSetup; | ||
| 37 | + | ||
| 29 | private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 38 | private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| 30 | 39 | ||
| 31 | /** | 40 | /** |
| @@ -60,7 +69,9 @@ public class LogController { | @@ -60,7 +69,9 @@ public class LogController { | ||
| 60 | if (StringUtils.isEmpty(query)) query = null; | 69 | if (StringUtils.isEmpty(query)) query = null; |
| 61 | if (StringUtils.isEmpty(startTime)) startTime = null; | 70 | if (StringUtils.isEmpty(startTime)) startTime = null; |
| 62 | if (StringUtils.isEmpty(endTime)) endTime = null; | 71 | if (StringUtils.isEmpty(endTime)) endTime = null; |
| 63 | - | 72 | + if (!userSetup.getLogInDatebase()) { |
| 73 | + logger.warn("自动记录日志功能已关闭,查询结果可能不完整。"); | ||
| 74 | + } | ||
| 64 | 75 | ||
| 65 | try { | 76 | try { |
| 66 | if (startTime != null) format.parse(startTime); | 77 | if (startTime != null) format.parse(startTime); |
src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java
| 1 | package com.genersoft.iot.vmp.vmanager.server; | 1 | package com.genersoft.iot.vmp.vmanager.server; |
| 2 | 2 | ||
| 3 | +import com.alibaba.fastjson.JSON; | ||
| 4 | +import com.alibaba.fastjson.JSONObject; | ||
| 3 | import com.genersoft.iot.vmp.VManageBootstrap; | 5 | import com.genersoft.iot.vmp.VManageBootstrap; |
| 4 | import com.genersoft.iot.vmp.common.VersionPo; | 6 | import com.genersoft.iot.vmp.common.VersionPo; |
| 7 | +import com.genersoft.iot.vmp.conf.SipConfig; | ||
| 8 | +import com.genersoft.iot.vmp.conf.UserSetup; | ||
| 5 | import com.genersoft.iot.vmp.conf.VersionInfo; | 9 | import com.genersoft.iot.vmp.conf.VersionInfo; |
| 6 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 10 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 7 | import com.genersoft.iot.vmp.service.IMediaServerService; | 11 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| @@ -9,9 +13,13 @@ import com.genersoft.iot.vmp.utils.SpringBeanFactory; | @@ -9,9 +13,13 @@ import com.genersoft.iot.vmp.utils.SpringBeanFactory; | ||
| 9 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; | 13 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| 10 | import gov.nist.javax.sip.SipStackImpl; | 14 | import gov.nist.javax.sip.SipStackImpl; |
| 11 | import io.swagger.annotations.Api; | 15 | import io.swagger.annotations.Api; |
| 16 | +import io.swagger.annotations.ApiImplicitParam; | ||
| 17 | +import io.swagger.annotations.ApiImplicitParams; | ||
| 12 | import io.swagger.annotations.ApiOperation; | 18 | import io.swagger.annotations.ApiOperation; |
| 13 | import org.springframework.beans.factory.annotation.Autowired; | 19 | import org.springframework.beans.factory.annotation.Autowired; |
| 20 | +import org.springframework.beans.factory.annotation.Value; | ||
| 14 | import org.springframework.context.ConfigurableApplicationContext; | 21 | import org.springframework.context.ConfigurableApplicationContext; |
| 22 | +import org.springframework.util.StringUtils; | ||
| 15 | import org.springframework.web.bind.annotation.*; | 23 | import org.springframework.web.bind.annotation.*; |
| 16 | 24 | ||
| 17 | import javax.sip.ListeningPoint; | 25 | import javax.sip.ListeningPoint; |
| @@ -36,6 +44,15 @@ public class ServerController { | @@ -36,6 +44,15 @@ public class ServerController { | ||
| 36 | @Autowired | 44 | @Autowired |
| 37 | VersionInfo versionInfo; | 45 | VersionInfo versionInfo; |
| 38 | 46 | ||
| 47 | + @Autowired | ||
| 48 | + SipConfig sipConfig; | ||
| 49 | + | ||
| 50 | + @Autowired | ||
| 51 | + UserSetup userSetup; | ||
| 52 | + | ||
| 53 | + @Value("${server.port}") | ||
| 54 | + private int serverPort; | ||
| 55 | + | ||
| 39 | 56 | ||
| 40 | @ApiOperation("流媒体服务列表") | 57 | @ApiOperation("流媒体服务列表") |
| 41 | @GetMapping(value = "/media_server/list") | 58 | @GetMapping(value = "/media_server/list") |
| @@ -113,4 +130,34 @@ public class ServerController { | @@ -113,4 +130,34 @@ public class ServerController { | ||
| 113 | result.setData(versionInfo.getVersion()); | 130 | result.setData(versionInfo.getVersion()); |
| 114 | return result; | 131 | return result; |
| 115 | } | 132 | } |
| 133 | + | ||
| 134 | + @ApiOperation("配置信息") | ||
| 135 | + @GetMapping(value = "/config") | ||
| 136 | + @ApiImplicitParams({ | ||
| 137 | + @ApiImplicitParam(name="type", value = "配置类型(sip, base)", dataTypeClass = String.class), | ||
| 138 | + }) | ||
| 139 | + @ResponseBody | ||
| 140 | + public WVPResult<JSONObject> getVersion(String type){ | ||
| 141 | + WVPResult<JSONObject> result = new WVPResult<>(); | ||
| 142 | + result.setCode(0); | ||
| 143 | + result.setMsg("success"); | ||
| 144 | + | ||
| 145 | + JSONObject jsonObject = new JSONObject(); | ||
| 146 | + jsonObject.put("server.port", serverPort); | ||
| 147 | + if (StringUtils.isEmpty(type)) { | ||
| 148 | + jsonObject.put("sip", JSON.toJSON(sipConfig)); | ||
| 149 | + jsonObject.put("base", JSON.toJSON(userSetup)); | ||
| 150 | + }else { | ||
| 151 | + switch (type){ | ||
| 152 | + case "sip": | ||
| 153 | + jsonObject.put("sip", sipConfig); | ||
| 154 | + break; | ||
| 155 | + case "base": | ||
| 156 | + jsonObject.put("base", userSetup); | ||
| 157 | + break; | ||
| 158 | + } | ||
| 159 | + } | ||
| 160 | + result.setData(jsonObject); | ||
| 161 | + return result; | ||
| 162 | + } | ||
| 116 | } | 163 | } |
src/main/java/com/genersoft/iot/vmp/vmanager/user/RoleController.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.vmanager.user; | ||
| 2 | + | ||
| 3 | +import com.genersoft.iot.vmp.conf.security.SecurityUtils; | ||
| 4 | +import com.genersoft.iot.vmp.service.IRoleService; | ||
| 5 | +import com.genersoft.iot.vmp.service.IUserService; | ||
| 6 | +import com.genersoft.iot.vmp.storager.dao.dto.Role; | ||
| 7 | +import com.genersoft.iot.vmp.storager.dao.dto.User; | ||
| 8 | +import com.genersoft.iot.vmp.vmanager.bean.WVPResult; | ||
| 9 | +import io.swagger.annotations.Api; | ||
| 10 | +import io.swagger.annotations.ApiImplicitParam; | ||
| 11 | +import io.swagger.annotations.ApiImplicitParams; | ||
| 12 | +import io.swagger.annotations.ApiOperation; | ||
| 13 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 14 | +import org.springframework.http.HttpStatus; | ||
| 15 | +import org.springframework.http.ResponseEntity; | ||
| 16 | +import org.springframework.security.authentication.AuthenticationManager; | ||
| 17 | +import org.springframework.util.DigestUtils; | ||
| 18 | +import org.springframework.util.StringUtils; | ||
| 19 | +import org.springframework.web.bind.annotation.*; | ||
| 20 | + | ||
| 21 | +import java.text.SimpleDateFormat; | ||
| 22 | +import java.util.List; | ||
| 23 | + | ||
| 24 | +@Api(tags = "角色管理") | ||
| 25 | +@CrossOrigin | ||
| 26 | +@RestController | ||
| 27 | +@RequestMapping("/api/role") | ||
| 28 | +public class RoleController { | ||
| 29 | + | ||
| 30 | + @Autowired | ||
| 31 | + private IRoleService roleService; | ||
| 32 | + | ||
| 33 | + private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 34 | + | ||
| 35 | + @ApiOperation("添加角色") | ||
| 36 | + @ApiImplicitParams({ | ||
| 37 | + @ApiImplicitParam(name = "name", required = true, value = "角色名", dataTypeClass = String.class), | ||
| 38 | + @ApiImplicitParam(name = "authority", required = true, value = "权限(自行定义内容,目前未使用)", dataTypeClass = String.class), | ||
| 39 | + }) | ||
| 40 | + @PostMapping("/add") | ||
| 41 | + public ResponseEntity<WVPResult<Integer>> add(@RequestParam String name, | ||
| 42 | + @RequestParam(required = false) String authority){ | ||
| 43 | + WVPResult<Integer> result = new WVPResult<>(); | ||
| 44 | + // 获取当前登录用户id | ||
| 45 | + int currenRoleId = SecurityUtils.getUserInfo().getRole().getId(); | ||
| 46 | + if (currenRoleId != 1) { | ||
| 47 | + // 只用角色id为1才可以删除和添加用户 | ||
| 48 | + result.setCode(-1); | ||
| 49 | + result.setMsg("用户无权限"); | ||
| 50 | + return new ResponseEntity<>(result, HttpStatus.FORBIDDEN); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + Role role = new Role(); | ||
| 54 | + role.setName(name); | ||
| 55 | + role.setAuthority(authority); | ||
| 56 | + role.setCreateTime(format.format(System.currentTimeMillis())); | ||
| 57 | + role.setUpdateTime(format.format(System.currentTimeMillis())); | ||
| 58 | + | ||
| 59 | + int addResult = roleService.add(role); | ||
| 60 | + | ||
| 61 | + result.setCode(addResult > 0 ? 0 : -1); | ||
| 62 | + result.setMsg(addResult > 0 ? "success" : "fail"); | ||
| 63 | + result.setData(addResult); | ||
| 64 | + return new ResponseEntity<>(result, HttpStatus.OK); | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + @ApiOperation("删除角色") | ||
| 68 | + @ApiImplicitParams({ | ||
| 69 | + @ApiImplicitParam(name = "id", required = true, value = "用户Id", dataTypeClass = Integer.class), | ||
| 70 | + }) | ||
| 71 | + @DeleteMapping("/delete") | ||
| 72 | + public ResponseEntity<WVPResult<String>> delete(@RequestParam Integer id){ | ||
| 73 | + // 获取当前登录用户id | ||
| 74 | + int currenRoleId = SecurityUtils.getUserInfo().getRole().getId(); | ||
| 75 | + WVPResult<String> result = new WVPResult<>(); | ||
| 76 | + if (currenRoleId != 1) { | ||
| 77 | + // 只用角色id为0才可以删除和添加用户 | ||
| 78 | + result.setCode(-1); | ||
| 79 | + result.setMsg("用户无权限"); | ||
| 80 | + return new ResponseEntity<>(result, HttpStatus.FORBIDDEN); | ||
| 81 | + } | ||
| 82 | + int deleteResult = roleService.delete(id); | ||
| 83 | + | ||
| 84 | + result.setCode(deleteResult>0? 0 : -1); | ||
| 85 | + result.setMsg(deleteResult>0? "success" : "fail"); | ||
| 86 | + return new ResponseEntity<>(result, HttpStatus.OK); | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + @ApiOperation("查询角色") | ||
| 90 | + @ApiImplicitParams({}) | ||
| 91 | + @GetMapping("/all") | ||
| 92 | + public ResponseEntity<WVPResult<List<Role>>> all(){ | ||
| 93 | + // 获取当前登录用户id | ||
| 94 | + List<Role> allRoles = roleService.getAll(); | ||
| 95 | + WVPResult<List<Role>> result = new WVPResult<>(); | ||
| 96 | + result.setCode(0); | ||
| 97 | + result.setMsg("success"); | ||
| 98 | + result.setData(allRoles); | ||
| 99 | + return new ResponseEntity<>(result, HttpStatus.OK); | ||
| 100 | + } | ||
| 101 | +} |
src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java
| @@ -2,7 +2,9 @@ package com.genersoft.iot.vmp.vmanager.user; | @@ -2,7 +2,9 @@ package com.genersoft.iot.vmp.vmanager.user; | ||
| 2 | 2 | ||
| 3 | import com.genersoft.iot.vmp.conf.security.SecurityUtils; | 3 | import com.genersoft.iot.vmp.conf.security.SecurityUtils; |
| 4 | import com.genersoft.iot.vmp.conf.security.dto.LoginUser; | 4 | import com.genersoft.iot.vmp.conf.security.dto.LoginUser; |
| 5 | +import com.genersoft.iot.vmp.service.IRoleService; | ||
| 5 | import com.genersoft.iot.vmp.service.IUserService; | 6 | import com.genersoft.iot.vmp.service.IUserService; |
| 7 | +import com.genersoft.iot.vmp.storager.dao.dto.Role; | ||
| 6 | import com.genersoft.iot.vmp.storager.dao.dto.User; | 8 | import com.genersoft.iot.vmp.storager.dao.dto.User; |
| 7 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; | 9 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| 8 | import io.swagger.annotations.Api; | 10 | import io.swagger.annotations.Api; |
| @@ -14,6 +16,7 @@ import org.springframework.http.HttpStatus; | @@ -14,6 +16,7 @@ import org.springframework.http.HttpStatus; | ||
| 14 | import org.springframework.http.ResponseEntity; | 16 | import org.springframework.http.ResponseEntity; |
| 15 | import org.springframework.security.authentication.AuthenticationManager; | 17 | import org.springframework.security.authentication.AuthenticationManager; |
| 16 | import org.springframework.util.DigestUtils; | 18 | import org.springframework.util.DigestUtils; |
| 19 | +import org.springframework.util.StringUtils; | ||
| 17 | import org.springframework.web.bind.annotation.*; | 20 | import org.springframework.web.bind.annotation.*; |
| 18 | 21 | ||
| 19 | import javax.security.sasl.AuthenticationException; | 22 | import javax.security.sasl.AuthenticationException; |
| @@ -32,6 +35,9 @@ public class UserController { | @@ -32,6 +35,9 @@ public class UserController { | ||
| 32 | @Autowired | 35 | @Autowired |
| 33 | private IUserService userService; | 36 | private IUserService userService; |
| 34 | 37 | ||
| 38 | + @Autowired | ||
| 39 | + private IRoleService roleService; | ||
| 40 | + | ||
| 35 | private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 41 | private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| 36 | 42 | ||
| 37 | @ApiOperation("登录") | 43 | @ApiOperation("登录") |
| @@ -97,21 +103,38 @@ public class UserController { | @@ -97,21 +103,38 @@ public class UserController { | ||
| 97 | @PostMapping("/add") | 103 | @PostMapping("/add") |
| 98 | public ResponseEntity<WVPResult<Integer>> add(@RequestParam String username, | 104 | public ResponseEntity<WVPResult<Integer>> add(@RequestParam String username, |
| 99 | @RequestParam String password, | 105 | @RequestParam String password, |
| 100 | - @RequestParam int roleId){ | 106 | + @RequestParam Integer roleId){ |
| 107 | + WVPResult<Integer> result = new WVPResult<>(); | ||
| 108 | + if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password) || roleId == null) { | ||
| 109 | + result.setCode(-1); | ||
| 110 | + result.setMsg("参数不可为空"); | ||
| 111 | + return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST); | ||
| 112 | + } | ||
| 101 | // 获取当前登录用户id | 113 | // 获取当前登录用户id |
| 102 | - int currenRoleId = SecurityUtils.getUserInfo().getRoleId(); | ||
| 103 | - if (currenRoleId != 0) { | ||
| 104 | - // 只用角色id为0才可以删除和添加用户 | ||
| 105 | - return new ResponseEntity<>(null, HttpStatus.FORBIDDEN); | 114 | + int currenRoleId = SecurityUtils.getUserInfo().getRole().getId(); |
| 115 | + if (currenRoleId != 1) { | ||
| 116 | + // 只用角色id为1才可以删除和添加用户 | ||
| 117 | + result.setCode(-1); | ||
| 118 | + result.setMsg("用户无权限"); | ||
| 119 | + return new ResponseEntity<>(result, HttpStatus.FORBIDDEN); | ||
| 106 | } | 120 | } |
| 107 | User user = new User(); | 121 | User user = new User(); |
| 108 | user.setUsername(username); | 122 | user.setUsername(username); |
| 109 | user.setPassword(DigestUtils.md5DigestAsHex(password.getBytes())); | 123 | user.setPassword(DigestUtils.md5DigestAsHex(password.getBytes())); |
| 110 | - user.setRoleId(roleId); | 124 | + |
| 125 | + Role role = roleService.getRoleById(roleId); | ||
| 126 | + | ||
| 127 | + if (role == null) { | ||
| 128 | + result.setCode(-1); | ||
| 129 | + result.setMsg("roleId is not found"); | ||
| 130 | + // 角色不存在 | ||
| 131 | + return new ResponseEntity<>(result, HttpStatus.OK); | ||
| 132 | + } | ||
| 133 | + user.setRole(role); | ||
| 111 | user.setCreateTime(format.format(System.currentTimeMillis())); | 134 | user.setCreateTime(format.format(System.currentTimeMillis())); |
| 112 | user.setUpdateTime(format.format(System.currentTimeMillis())); | 135 | user.setUpdateTime(format.format(System.currentTimeMillis())); |
| 113 | int addResult = userService.addUser(user); | 136 | int addResult = userService.addUser(user); |
| 114 | - WVPResult<Integer> result = new WVPResult<>(); | 137 | + |
| 115 | result.setCode(addResult > 0 ? 0 : -1); | 138 | result.setCode(addResult > 0 ? 0 : -1); |
| 116 | result.setMsg(addResult > 0 ? "success" : "fail"); | 139 | result.setMsg(addResult > 0 ? "success" : "fail"); |
| 117 | result.setData(addResult); | 140 | result.setData(addResult); |
| @@ -125,13 +148,16 @@ public class UserController { | @@ -125,13 +148,16 @@ public class UserController { | ||
| 125 | @DeleteMapping("/delete") | 148 | @DeleteMapping("/delete") |
| 126 | public ResponseEntity<WVPResult<String>> delete(@RequestParam Integer id){ | 149 | public ResponseEntity<WVPResult<String>> delete(@RequestParam Integer id){ |
| 127 | // 获取当前登录用户id | 150 | // 获取当前登录用户id |
| 128 | - int currenRoleId = SecurityUtils.getUserInfo().getRoleId(); | ||
| 129 | - if (currenRoleId != 0) { | 151 | + int currenRoleId = SecurityUtils.getUserInfo().getRole().getId(); |
| 152 | + WVPResult<String> result = new WVPResult<>(); | ||
| 153 | + if (currenRoleId != 1) { | ||
| 130 | // 只用角色id为0才可以删除和添加用户 | 154 | // 只用角色id为0才可以删除和添加用户 |
| 131 | - return new ResponseEntity<>(null, HttpStatus.FORBIDDEN); | 155 | + result.setCode(-1); |
| 156 | + result.setMsg("用户无权限"); | ||
| 157 | + return new ResponseEntity<>(result, HttpStatus.FORBIDDEN); | ||
| 132 | } | 158 | } |
| 133 | int deleteResult = userService.deleteUser(id); | 159 | int deleteResult = userService.deleteUser(id); |
| 134 | - WVPResult<String> result = new WVPResult<>(); | 160 | + |
| 135 | result.setCode(deleteResult>0? 0 : -1); | 161 | result.setCode(deleteResult>0? 0 : -1); |
| 136 | result.setMsg(deleteResult>0? "success" : "fail"); | 162 | result.setMsg(deleteResult>0? "success" : "fail"); |
| 137 | return new ResponseEntity<>(result, HttpStatus.OK); | 163 | return new ResponseEntity<>(result, HttpStatus.OK); |
src/main/java/com/genersoft/iot/vmp/web/ApiController.java
| @@ -38,10 +38,10 @@ public class ApiController { | @@ -38,10 +38,10 @@ public class ApiController { | ||
| 38 | result.put("ServerTime","2020-09-02 17:11"); | 38 | result.put("ServerTime","2020-09-02 17:11"); |
| 39 | result.put("StartUpTime","2020-09-02 17:11"); | 39 | result.put("StartUpTime","2020-09-02 17:11"); |
| 40 | result.put("Server",""); | 40 | result.put("Server",""); |
| 41 | - result.put("SIPSerial", sipConfig.getSipId()); | ||
| 42 | - result.put("SIPRealm", sipConfig.getSipDomain()); | ||
| 43 | - result.put("SIPHost", sipConfig.getSipIp()); | ||
| 44 | - result.put("SIPPort", sipConfig.getSipPort()); | 41 | + result.put("SIPSerial", sipConfig.getId()); |
| 42 | + result.put("SIPRealm", sipConfig.getDomain()); | ||
| 43 | + result.put("SIPHost", sipConfig.getIp()); | ||
| 44 | + result.put("SIPPort", sipConfig.getPort()); | ||
| 45 | result.put("ChannelCount","1000"); | 45 | result.put("ChannelCount","1000"); |
| 46 | result.put("VersionType",""); | 46 | result.put("VersionType",""); |
| 47 | result.put("LogoMiniText",""); | 47 | result.put("LogoMiniText",""); |
| @@ -65,10 +65,10 @@ public class ApiController { | @@ -65,10 +65,10 @@ public class ApiController { | ||
| 65 | // result.put("ServerTime","2020-09-02 17:11"); | 65 | // result.put("ServerTime","2020-09-02 17:11"); |
| 66 | // result.put("StartUpTime","2020-09-02 17:11"); | 66 | // result.put("StartUpTime","2020-09-02 17:11"); |
| 67 | // result.put("Server",""); | 67 | // result.put("Server",""); |
| 68 | -// result.put("SIPSerial", sipConfig.getSipId()); | ||
| 69 | -// result.put("SIPRealm", sipConfig.getSipDomain()); | ||
| 70 | -// result.put("SIPHost", sipConfig.getSipIp()); | ||
| 71 | -// result.put("SIPPort", sipConfig.getSipPort()); | 68 | +// result.put("SIPSerial", sipConfig.getId()); |
| 69 | +// result.put("SIPRealm", sipConfig.getDomain()); | ||
| 70 | +// result.put("SIPHost", sipConfig.getIp()); | ||
| 71 | +// result.put("SIPPort", sipConfig.getPort()); | ||
| 72 | // result.put("ChannelCount","1000"); | 72 | // result.put("ChannelCount","1000"); |
| 73 | // result.put("VersionType",""); | 73 | // result.put("VersionType",""); |
| 74 | // result.put("LogoMiniText",""); | 74 | // result.put("LogoMiniText",""); |
src/main/resources/all-application.yml
| @@ -76,6 +76,8 @@ sip: | @@ -76,6 +76,8 @@ sip: | ||
| 76 | keepalive-timeout: 180 | 76 | keepalive-timeout: 180 |
| 77 | # [可选] 国标级联注册失败,再次发起注册的时间间隔。 默认60秒 | 77 | # [可选] 国标级联注册失败,再次发起注册的时间间隔。 默认60秒 |
| 78 | register-time-interval: 60 | 78 | register-time-interval: 60 |
| 79 | + # [可选] 云台控制速度 | ||
| 80 | + ptz-speed: 50 | ||
| 79 | # TODO [可选] 收到心跳后自动上线, 重启服务后会将所有设备置为离线,默认false,等待注册后上线。设置为true则收到心跳设置为上线。 | 81 | # TODO [可选] 收到心跳后自动上线, 重启服务后会将所有设备置为离线,默认false,等待注册后上线。设置为true则收到心跳设置为上线。 |
| 80 | # keepalliveToOnline: false | 82 | # keepalliveToOnline: false |
| 81 | 83 | ||
| @@ -155,4 +157,10 @@ user-settings: | @@ -155,4 +157,10 @@ user-settings: | ||
| 155 | 157 | ||
| 156 | # 在线文档: swagger-ui(生产环境建议关闭) | 158 | # 在线文档: swagger-ui(生产环境建议关闭) |
| 157 | swagger-ui: | 159 | swagger-ui: |
| 158 | - enabled: true | ||
| 159 | \ No newline at end of file | 160 | \ No newline at end of file |
| 161 | + enabled: true | ||
| 162 | + | ||
| 163 | +# 版本信息, 不需修改 | ||
| 164 | +version: | ||
| 165 | + version: "@project.version@" | ||
| 166 | + description: "@project.description@" | ||
| 167 | + artifact-id: "@project.artifactId@" | ||
| 160 | \ No newline at end of file | 168 | \ No newline at end of file |
src/main/resources/application-dev.yml
| @@ -85,4 +85,10 @@ user-settings: | @@ -85,4 +85,10 @@ user-settings: | ||
| 85 | 85 | ||
| 86 | # 在线文档: swagger-ui(生产环境建议关闭) | 86 | # 在线文档: swagger-ui(生产环境建议关闭) |
| 87 | swagger-ui: | 87 | swagger-ui: |
| 88 | - enabled: true | ||
| 89 | \ No newline at end of file | 88 | \ No newline at end of file |
| 89 | + enabled: true | ||
| 90 | + | ||
| 91 | +# 版本信息, 不需修改 | ||
| 92 | +version: | ||
| 93 | + version: "@project.version@" | ||
| 94 | + description: "@project.description@" | ||
| 95 | + artifact-id: "@project.artifactId@" | ||
| 90 | \ No newline at end of file | 96 | \ No newline at end of file |
src/main/resources/banner.txt
| @@ -6,3 +6,4 @@ | @@ -6,3 +6,4 @@ | ||
| 6 | \ \____________\ \__/ / \ \__\ \ \__\ \ \__\\ _\\ \_______\ | 6 | \ \____________\ \__/ / \ \__\ \ \__\ \ \__\\ _\\ \_______\ |
| 7 | \|____________|\|__|/ \|__| \|__| \|__|\|__|\|_______| | 7 | \|____________|\|__|/ \|__| \|__| \|__|\|__|\|_______| |
| 8 | 8 | ||
| 9 | +版本:${version.version} | ||
| 9 | \ No newline at end of file | 10 | \ No newline at end of file |
src/main/resources/wvp.sqlite
No preview for this file type
src/test/java/com/genersoft/iot/vmp/service/impl/RoleServiceImplTest.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.service.impl; | ||
| 2 | + | ||
| 3 | +import com.genersoft.iot.vmp.service.IRoleService; | ||
| 4 | +import com.genersoft.iot.vmp.service.IUserService; | ||
| 5 | +import com.genersoft.iot.vmp.storager.dao.dto.Role; | ||
| 6 | +import com.genersoft.iot.vmp.storager.dao.dto.User; | ||
| 7 | +import org.junit.runner.RunWith; | ||
| 8 | +import org.springframework.boot.test.context.SpringBootTest; | ||
| 9 | +import org.springframework.test.context.junit4.SpringRunner; | ||
| 10 | + | ||
| 11 | +import javax.annotation.Resource; | ||
| 12 | +import java.text.SimpleDateFormat; | ||
| 13 | +import java.util.List; | ||
| 14 | + | ||
| 15 | + | ||
| 16 | +@SpringBootTest | ||
| 17 | +@RunWith(SpringRunner.class) | ||
| 18 | +class RoleServiceImplTest { | ||
| 19 | + | ||
| 20 | + @Resource | ||
| 21 | + private IRoleService roleService; | ||
| 22 | + | ||
| 23 | + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 24 | + @org.junit.jupiter.api.Test | ||
| 25 | + void getAllUser() { | ||
| 26 | + List<Role> all = roleService.getAll(); | ||
| 27 | + Role roleById = roleService.getRoleById(1); | ||
| 28 | + System.out.println(); | ||
| 29 | + | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + | ||
| 33 | + @org.junit.jupiter.api.Test | ||
| 34 | + void add() { | ||
| 35 | + for (int i = 0; i < 10; i++) { | ||
| 36 | + Role role = new Role(); | ||
| 37 | + role.setName("test+" + i); | ||
| 38 | + role.setAuthority("adadadda"); | ||
| 39 | + role.setCreateTime(format.format(System.currentTimeMillis())); | ||
| 40 | + role.setUpdateTime(format.format(System.currentTimeMillis())); | ||
| 41 | + roleService.add(role); | ||
| 42 | + } | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + @org.junit.jupiter.api.Test | ||
| 46 | + void delete() { | ||
| 47 | + roleService.delete(20); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + @org.junit.jupiter.api.Test | ||
| 51 | + void update() { | ||
| 52 | + Role role = new Role(); | ||
| 53 | + role.setId(21); | ||
| 54 | + role.setName("TTTTTT"); | ||
| 55 | + role.setAuthority("adadadda"); | ||
| 56 | + roleService.update(role); | ||
| 57 | + } | ||
| 58 | +} | ||
| 0 | \ No newline at end of file | 59 | \ No newline at end of file |
src/test/java/com/genersoft/iot/vmp/service/impl/UserServiceImplTest.java
| @@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.service.impl; | @@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.service.impl; | ||
| 3 | import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; | 3 | import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; |
| 4 | import com.genersoft.iot.vmp.service.IDeviceAlarmService; | 4 | import com.genersoft.iot.vmp.service.IDeviceAlarmService; |
| 5 | import com.genersoft.iot.vmp.service.IUserService; | 5 | import com.genersoft.iot.vmp.service.IUserService; |
| 6 | +import com.genersoft.iot.vmp.storager.dao.dto.Role; | ||
| 6 | import com.genersoft.iot.vmp.storager.dao.dto.User; | 7 | import com.genersoft.iot.vmp.storager.dao.dto.User; |
| 7 | import org.junit.runner.RunWith; | 8 | import org.junit.runner.RunWith; |
| 8 | import org.springframework.boot.test.context.SpringBootTest; | 9 | import org.springframework.boot.test.context.SpringBootTest; |
| @@ -11,6 +12,7 @@ import org.springframework.test.context.junit4.SpringRunner; | @@ -11,6 +12,7 @@ import org.springframework.test.context.junit4.SpringRunner; | ||
| 11 | import javax.annotation.Resource; | 12 | import javax.annotation.Resource; |
| 12 | import java.text.SimpleDateFormat; | 13 | import java.text.SimpleDateFormat; |
| 13 | import java.util.Date; | 14 | import java.util.Date; |
| 15 | +import java.util.List; | ||
| 14 | 16 | ||
| 15 | 17 | ||
| 16 | @SpringBootTest | 18 | @SpringBootTest |
| @@ -24,7 +26,11 @@ class UserServiceImplTest { | @@ -24,7 +26,11 @@ class UserServiceImplTest { | ||
| 24 | 26 | ||
| 25 | @org.junit.jupiter.api.Test | 27 | @org.junit.jupiter.api.Test |
| 26 | void getAllUser() { | 28 | void getAllUser() { |
| 29 | + List<User> allUsers = userService.getAllUsers(); | ||
| 27 | System.out.println(userService.getAllUsers().size()); | 30 | System.out.println(userService.getAllUsers().size()); |
| 31 | + User admin = userService.getUser("admin", "21232f297a57a5a743894a0e4a801fc3"); | ||
| 32 | + User admin1 = userService.getUserByUsername("admin"); | ||
| 33 | + System.out.println(12); | ||
| 28 | } | 34 | } |
| 29 | 35 | ||
| 30 | 36 | ||
| @@ -34,7 +40,10 @@ class UserServiceImplTest { | @@ -34,7 +40,10 @@ class UserServiceImplTest { | ||
| 34 | User user = new User(); | 40 | User user = new User(); |
| 35 | user.setUsername("admin_" + i); | 41 | user.setUsername("admin_" + i); |
| 36 | user.setPassword("admin_password_" + i); | 42 | user.setPassword("admin_password_" + i); |
| 37 | - user.setRoleId((int)(Math.random()*4 + 1)); | 43 | + |
| 44 | + Role role = new Role(); | ||
| 45 | + role.setId(1); | ||
| 46 | + user.setRole(role); | ||
| 38 | user.setCreateTime(format.format(System.currentTimeMillis())); | 47 | user.setCreateTime(format.format(System.currentTimeMillis())); |
| 39 | user.setUpdateTime(format.format(System.currentTimeMillis())); | 48 | user.setUpdateTime(format.format(System.currentTimeMillis())); |
| 40 | userService.addUser(user); | 49 | userService.addUser(user); |
| @@ -49,10 +58,12 @@ class UserServiceImplTest { | @@ -49,10 +58,12 @@ class UserServiceImplTest { | ||
| 49 | @org.junit.jupiter.api.Test | 58 | @org.junit.jupiter.api.Test |
| 50 | void update() { | 59 | void update() { |
| 51 | User user = new User(); | 60 | User user = new User(); |
| 52 | - user.setId(1003); | 61 | + user.setId(11); |
| 53 | user.setUsername("update" ); | 62 | user.setUsername("update" ); |
| 54 | user.setPassword("update"); | 63 | user.setPassword("update"); |
| 55 | - user.setRoleId((int)(Math.random()*4 + 1)); | 64 | + Role role = new Role(); |
| 65 | + role.setId(2); | ||
| 66 | + user.setRole(role); | ||
| 56 | user.setUpdateTime(format.format(System.currentTimeMillis())); | 67 | user.setUpdateTime(format.format(System.currentTimeMillis())); |
| 57 | userService.updateUsers(user); | 68 | userService.updateUsers(user); |
| 58 | } | 69 | } |