Commit 9bdad03a authored by zhuangzhuang's avatar zhuangzhuang

3.9--修改实体类和vo层以及controller的数据类型以及判断

parent b169ed88
......@@ -45,6 +45,31 @@ dependencies {
compile('org.apache.commons:commons-compress:1.9')
compile('org.springframework.boot:spring-boot-starter-data-redis')
}
jar {
String someString = ''
configurations.runtime.each {someString = someString + " lib\\"+it.name} //遍历项目的所有依赖的jar包赋值给变量someString
manifest {
attributes 'Main-Class': 'com.example.tdl'
attributes 'Class-Path': someString
}
}
//清除上次的编译过的文件
task clearPj(type:Delete){
delete 'build','target'
}
task copyJar(type:Copy){
from configurations.runtime
into ('build/libs/lib')
}
task release(type: Copy,dependsOn: [build,copyJar]) {
// from 'conf'
// into ('build/libs/core/conf')
}
This diff is collapsed.
package com.example.tdl.config;
import com.example.tdl.interceptor.LoginInterceptor;
import com.example.tdl.interceptor.PermissionInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
......@@ -14,10 +15,16 @@ public class MyWebMvcConfigurer extends WebMvcConfigurerAdapter {
return new LoginInterceptor();
}
@Bean
public PermissionInterceptor permissionInterceptor(){
return new PermissionInterceptor();
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(loginInterceptor())
.excludePathPatterns("/login/**");
registry.addInterceptor(permissionInterceptor()).excludePathPatterns("/login/**");
super.addInterceptors(registry);
}
}
......@@ -6,15 +6,15 @@ public class AddAlarmVo {
private String alarmScene;
private float temMax;//温度上限
private Float temMax;//温度上限
private float temMin;//温度下限
private Float temMin;//温度下限
private float humidityMax;//湿度上限
private Float humidityMax;//湿度上限
private float humidityMin;//湿度下限
private Float humidityMin;//湿度下限
private float tilt;//倾斜度
private Float tilt;//倾斜度
private String shock;//震度
......@@ -36,43 +36,43 @@ public class AddAlarmVo {
this.alarmScene = alarmScene;
}
public float getTemMax() {
public Float getTemMax() {
return temMax;
}
public void setTemMax(float temMax) {
public void setTemMax(Float temMax) {
this.temMax = temMax;
}
public float getTemMin() {
public Float getTemMin() {
return temMin;
}
public void setTemMin(float temMin) {
public void setTemMin(Float temMin) {
this.temMin = temMin;
}
public float getHumidityMax() {
public Float getHumidityMax() {
return humidityMax;
}
public void setHumidityMax(float humidityMax) {
public void setHumidityMax(Float humidityMax) {
this.humidityMax = humidityMax;
}
public float getHumidityMin() {
public Float getHumidityMin() {
return humidityMin;
}
public void setHumidityMin(float humidityMin) {
public void setHumidityMin(Float humidityMin) {
this.humidityMin = humidityMin;
}
public float getTilt() {
public Float getTilt() {
return tilt;
}
public void setTilt(float tilt) {
public void setTilt(Float tilt) {
this.tilt = tilt;
}
......
......@@ -3,7 +3,7 @@ package com.example.tdl.domain.vo;
public class AddProbesModelInfoVo {
private String probesModelName;
private int port;
private Integer port;
private String unit;
......@@ -13,9 +13,9 @@ public class AddProbesModelInfoVo {
private String type;
private int alarmUp;
private Integer alarmUp;
private int alarmDown;
private Integer alarmDown;
public String getProbesModelName() {
return probesModelName;
......@@ -25,11 +25,11 @@ public class AddProbesModelInfoVo {
this.probesModelName = probesModelName;
}
public int getPort() {
public Integer getPort() {
return port;
}
public void setPort(int port) {
public void setPort(Integer port) {
this.port = port;
}
......@@ -65,19 +65,19 @@ public class AddProbesModelInfoVo {
this.type = type;
}
public int getAlarmUp() {
public Integer getAlarmUp() {
return alarmUp;
}
public void setAlarmUp(int alarmUp) {
public void setAlarmUp(Integer alarmUp) {
this.alarmUp = alarmUp;
}
public int getAlarmDown() {
public Integer getAlarmDown() {
return alarmDown;
}
public void setAlarmDown(int alarmDown) {
public void setAlarmDown(Integer alarmDown) {
this.alarmDown = alarmDown;
}
}
package com.example.tdl.domain.vo;
public class AddProbesModelVo {
private String probesModelName;
private int countNum;
private Integer countNum;
public String getProbesModelName() {
return probesModelName;
......@@ -13,11 +14,11 @@ public class AddProbesModelVo {
this.probesModelName = probesModelName;
}
public int getCountNum() {
public Integer getCountNum() {
return countNum;
}
public void setCountNum(int countNum) {
public void setCountNum(Integer countNum) {
this.countNum = countNum;
}
}
......@@ -5,11 +5,11 @@ public class AddTopicModelInfoVo {
private String topicName;
private int type;
private Integer type;
private int intervalTime;
private Integer intervalTime;
private int frequency;
private Integer frequency;
public String getTopicModelName() {
return topicModelName;
......@@ -27,27 +27,27 @@ public class AddTopicModelInfoVo {
this.topicName = topicName;
}
public int getType() {
public Integer getType() {
return type;
}
public void setType(int type) {
public void setType(Integer type) {
this.type = type;
}
public int getIntervalTime() {
public Integer getIntervalTime() {
return intervalTime;
}
public void setIntervalTime(int intervalTime) {
public void setIntervalTime(Integer intervalTime) {
this.intervalTime = intervalTime;
}
public int getFrequency() {
public Integer getFrequency() {
return frequency;
}
public void setFrequency(int frequency) {
public void setFrequency(Integer frequency) {
this.frequency = frequency;
}
}
......@@ -30,17 +30,17 @@ public class AddWarehouseVo {
private String hardwareLevel;//硬件等级
private double areaIndoor;//室内平面面积
private Double areaIndoor;//室内平面面积
private double areaRack;//货架面积
private Double areaRack;//货架面积
private double areaOutdoor;//实际室内总面积
private Double areaOutdoor;//实际室内总面积
private double areaPlanIndoor;//实际室内总面积
private Double areaPlanIndoor;//实际室内总面积
private String office;//办事处
private int timeZone;//时区
private Integer timeZone;//时区
private String weatherInfo;//区域气象信息
......@@ -160,35 +160,35 @@ public class AddWarehouseVo {
this.hardwareLevel = hardwareLevel;
}
public double getAreaIndoor() {
public Double getAreaIndoor() {
return areaIndoor;
}
public void setAreaIndoor(double areaIndoor) {
public void setAreaIndoor(Double areaIndoor) {
this.areaIndoor = areaIndoor;
}
public double getAreaRack() {
public Double getAreaRack() {
return areaRack;
}
public void setAreaRack(double areaRack) {
public void setAreaRack(Double areaRack) {
this.areaRack = areaRack;
}
public double getAreaOutdoor() {
public Double getAreaOutdoor() {
return areaOutdoor;
}
public void setAreaOutdoor(double areaOutdoor) {
public void setAreaOutdoor(Double areaOutdoor) {
this.areaOutdoor = areaOutdoor;
}
public double getAreaPlanIndoor() {
public Double getAreaPlanIndoor() {
return areaPlanIndoor;
}
public void setAreaPlanIndoor(double areaPlanIndoor) {
public void setAreaPlanIndoor(Double areaPlanIndoor) {
this.areaPlanIndoor = areaPlanIndoor;
}
......@@ -200,11 +200,11 @@ public class AddWarehouseVo {
this.office = office;
}
public int getTimeZone() {
public Integer getTimeZone() {
return timeZone;
}
public void setTimeZone(int timeZone) {
public void setTimeZone(Integer timeZone) {
this.timeZone = timeZone;
}
......
......@@ -6,15 +6,15 @@ public class ResultAlarmVo{
private String alarmScene;
private float temMax;//温度上限
private Float temMax;//温度上限
private float temMin;//温度下限
private Float temMin;//温度下限
private float humidityMax;//湿度上限
private Float humidityMax;//湿度上限
private float humidityMin;//湿度下限
private Float humidityMin;//湿度下限
private float tilt;//倾斜度
private Float tilt;//倾斜度
private String shock;//震度
......@@ -36,43 +36,43 @@ public class ResultAlarmVo{
this.alarmScene = alarmScene;
}
public float getTemMax() {
public Float getTemMax() {
return temMax;
}
public void setTemMax(float temMax) {
public void setTemMax(Float temMax) {
this.temMax = temMax;
}
public float getTemMin() {
public Float getTemMin() {
return temMin;
}
public void setTemMin(float temMin) {
public void setTemMin(Float temMin) {
this.temMin = temMin;
}
public float getHumidityMax() {
public Float getHumidityMax() {
return humidityMax;
}
public void setHumidityMax(float humidityMax) {
public void setHumidityMax(Float humidityMax) {
this.humidityMax = humidityMax;
}
public float getHumidityMin() {
public Float getHumidityMin() {
return humidityMin;
}
public void setHumidityMin(float humidityMin) {
public void setHumidityMin(Float humidityMin) {
this.humidityMin = humidityMin;
}
public float getTilt() {
public Float getTilt() {
return tilt;
}
public void setTilt(float tilt) {
public void setTilt(Float tilt) {
this.tilt = tilt;
}
......
......@@ -7,19 +7,11 @@ public class ResultGatewayVo {
private String type;
private boolean state;
private Boolean state;
private boolean bConfig;
private Boolean bConfig;
private int useScene;
public int getUseScene() {
return useScene;
}
public void setUseScene(int useScene) {
this.useScene = useScene;
}
private Integer useScene;
public String getSN() {
return SN;
......@@ -45,19 +37,27 @@ public class ResultGatewayVo {
this.type = type;
}
public boolean isState() {
public Boolean getState() {
return state;
}
public void setState(boolean state) {
public void setState(Boolean state) {
this.state = state;
}
public boolean isbConfig() {
public Boolean getbConfig() {
return bConfig;
}
public void setbConfig(boolean bConfig) {
public void setbConfig(Boolean bConfig) {
this.bConfig = bConfig;
}
public Integer getUseScene() {
return useScene;
}
public void setUseScene(Integer useScene) {
this.useScene = useScene;
}
}
......@@ -3,7 +3,7 @@ package com.example.tdl.domain.vo;
public class ResultProbesModelInfoVo {
private String probesModelName;
private int port;
private Integer port;
private String unit;
......@@ -13,9 +13,9 @@ public class ResultProbesModelInfoVo {
private String type;
private int alarmUp;
private Integer alarmUp;
private int alarmDown;
private Integer alarmDown;
public String getProbesModelName() {
return probesModelName;
......@@ -25,11 +25,11 @@ public class ResultProbesModelInfoVo {
this.probesModelName = probesModelName;
}
public int getPort() {
public Integer getPort() {
return port;
}
public void setPort(int port) {
public void setPort(Integer port) {
this.port = port;
}
......@@ -65,19 +65,19 @@ public class ResultProbesModelInfoVo {
this.type = type;
}
public int getAlarmUp() {
public Integer getAlarmUp() {
return alarmUp;
}
public void setAlarmUp(int alarmUp) {
public void setAlarmUp(Integer alarmUp) {
this.alarmUp = alarmUp;
}
public int getAlarmDown() {
public Integer getAlarmDown() {
return alarmDown;
}
public void setAlarmDown(int alarmDown) {
public void setAlarmDown(Integer alarmDown) {
this.alarmDown = alarmDown;
}
}
......@@ -3,7 +3,7 @@ package com.example.tdl.domain.vo;
public class ResultProbesModelVo {
private String probesModelName;
private int countNum;
private Integer countNum;
private String createTime;
......@@ -17,11 +17,11 @@ public class ResultProbesModelVo {
this.probesModelName = probesModelName;
}
public int getCountNum() {
public Integer getCountNum() {
return countNum;
}
public void setCountNum(int countNum) {
public void setCountNum(Integer countNum) {
this.countNum = countNum;
}
......
......@@ -9,7 +9,7 @@ public class ResultTDLDeviceVo {
private String lastTime;
private int useScene;
private Integer useScene;
private String warehouseName;
......@@ -19,20 +19,12 @@ public class ResultTDLDeviceVo {
private String gatewayType;
public String getGatewaySN() {
return gatewaySN;
}
public void setGatewaySN(String gatewaySN) {
this.gatewaySN = gatewaySN;
}
public String getGatewayType() {
return gatewayType;
public String getTDLName() {
return TDLName;
}
public void setGatewayType(String gatewayType) {
this.gatewayType = gatewayType;
public void setTDLName(String TDLName) {
this.TDLName = TDLName;
}
public String getTDLSN() {
......@@ -59,19 +51,11 @@ public class ResultTDLDeviceVo {
this.lastTime = lastTime;
}
public String getTDLName() {
return TDLName;
}
public void setTDLName(String TDLName) {
this.TDLName = TDLName;
}
public int getUseScene() {
public Integer getUseScene() {
return useScene;
}
public void setUseScene(int useScene) {
public void setUseScene(Integer useScene) {
this.useScene = useScene;
}
......@@ -90,4 +74,20 @@ public class ResultTDLDeviceVo {
public void setTransportationNo(String transportationNo) {
this.transportationNo = transportationNo;
}
public String getGatewaySN() {
return gatewaySN;
}
public void setGatewaySN(String gatewaySN) {
this.gatewaySN = gatewaySN;
}
public String getGatewayType() {
return gatewayType;
}
public void setGatewayType(String gatewayType) {
this.gatewayType = gatewayType;
}
}
......@@ -5,11 +5,11 @@ public class ResultTopicModelInfoVo {
private String topicName;
private int type;
private Integer type;
private int intervalTime;
private Integer intervalTime;
private int frequency;
private Integer frequency;
public String getTopicModelName() {
return topicModelName;
......@@ -27,27 +27,27 @@ public class ResultTopicModelInfoVo {
this.topicName = topicName;
}
public int getType() {
public Integer getType() {
return type;
}
public void setType(int type) {
public void setType(Integer type) {
this.type = type;
}
public int getIntervalTime() {
public Integer getIntervalTime() {
return intervalTime;
}
public void setIntervalTime(int intervalTime) {
public void setIntervalTime(Integer intervalTime) {
this.intervalTime = intervalTime;
}
public int getFrequency() {
public Integer getFrequency() {
return frequency;
}
public void setFrequency(int frequency) {
public void setFrequency(Integer frequency) {
this.frequency = frequency;
}
}
......@@ -34,17 +34,17 @@ public class ResultWarehouseVo {
private String hardwareLevel;//硬件等级
private double areaIndoor;//室内平面面积
private Double areaIndoor;//室内平面面积
private double areaRack;//货架面积
private Double areaRack;//货架面积
private double areaOutdoor;//实际室内总面积
private Double areaOutdoor;//实际室内总面积
private double areaPlanIndoor;//实际室内总面积
private Double areaPlanIndoor;//实际室内总面积
private String office;//办事处
private int timeZone;//时区
private Integer timeZone;//时区
private String weatherInfo;//区域气象信息
......@@ -180,35 +180,35 @@ public class ResultWarehouseVo {
this.hardwareLevel = hardwareLevel;
}
public double getAreaIndoor() {
public Double getAreaIndoor() {
return areaIndoor;
}
public void setAreaIndoor(double areaIndoor) {
public void setAreaIndoor(Double areaIndoor) {
this.areaIndoor = areaIndoor;
}
public double getAreaRack() {
public Double getAreaRack() {
return areaRack;
}
public void setAreaRack(double areaRack) {
public void setAreaRack(Double areaRack) {
this.areaRack = areaRack;
}
public double getAreaOutdoor() {
public Double getAreaOutdoor() {
return areaOutdoor;
}
public void setAreaOutdoor(double areaOutdoor) {
public void setAreaOutdoor(Double areaOutdoor) {
this.areaOutdoor = areaOutdoor;
}
public double getAreaPlanIndoor() {
public Double getAreaPlanIndoor() {
return areaPlanIndoor;
}
public void setAreaPlanIndoor(double areaPlanIndoor) {
public void setAreaPlanIndoor(Double areaPlanIndoor) {
this.areaPlanIndoor = areaPlanIndoor;
}
......@@ -220,11 +220,11 @@ public class ResultWarehouseVo {
this.office = office;
}
public int getTimeZone() {
public Integer getTimeZone() {
return timeZone;
}
public void setTimeZone(int timeZone) {
public void setTimeZone(Integer timeZone) {
this.timeZone = timeZone;
}
......
......@@ -5,7 +5,7 @@ public class TDLDeviceTermVo {
private String TDLSN;
private int useScene;
private Integer useScene;
public String getTDLName() {
return TDLName;
......@@ -23,11 +23,11 @@ public class TDLDeviceTermVo {
this.TDLSN = TDLSN;
}
public int getUseScene() {
public Integer getUseScene() {
return useScene;
}
public void setUseScene(int useScene) {
public void setUseScene(Integer useScene) {
this.useScene = useScene;
}
}
......@@ -6,15 +6,15 @@ public class UpdateAlarmVo {
private String alarmScene;
private float temMax;//温度上限
private Float temMax;//温度上限
private float temMin;//温度下限
private Float temMin;//温度下限
private float humidityMax;//湿度上限
private Float humidityMax;//湿度上限
private float humidityMin;//湿度下限
private Float humidityMin;//湿度下限
private float tilt;//倾斜度
private Float tilt;//倾斜度
private String shock;//震度
......@@ -24,22 +24,6 @@ public class UpdateAlarmVo {
private String oldAlarmScene;
public String getOldAlarmType() {
return oldAlarmType;
}
public void setOldAlarmType(String oldAlarmType) {
this.oldAlarmType = oldAlarmType;
}
public String getOldAlarmScene() {
return oldAlarmScene;
}
public void setOldAlarmScene(String oldAlarmScene) {
this.oldAlarmScene = oldAlarmScene;
}
public String getAlarmType() {
return alarmType;
}
......@@ -56,43 +40,43 @@ public class UpdateAlarmVo {
this.alarmScene = alarmScene;
}
public float getTemMax() {
public Float getTemMax() {
return temMax;
}
public void setTemMax(float temMax) {
public void setTemMax(Float temMax) {
this.temMax = temMax;
}
public float getTemMin() {
public Float getTemMin() {
return temMin;
}
public void setTemMin(float temMin) {
public void setTemMin(Float temMin) {
this.temMin = temMin;
}
public float getHumidityMax() {
public Float getHumidityMax() {
return humidityMax;
}
public void setHumidityMax(float humidityMax) {
public void setHumidityMax(Float humidityMax) {
this.humidityMax = humidityMax;
}
public float getHumidityMin() {
public Float getHumidityMin() {
return humidityMin;
}
public void setHumidityMin(float humidityMin) {
public void setHumidityMin(Float humidityMin) {
this.humidityMin = humidityMin;
}
public float getTilt() {
public Float getTilt() {
return tilt;
}
public void setTilt(float tilt) {
public void setTilt(Float tilt) {
this.tilt = tilt;
}
......@@ -111,4 +95,20 @@ public class UpdateAlarmVo {
public void setRemark(String remark) {
this.remark = remark;
}
public String getOldAlarmType() {
return oldAlarmType;
}
public void setOldAlarmType(String oldAlarmType) {
this.oldAlarmType = oldAlarmType;
}
public String getOldAlarmScene() {
return oldAlarmScene;
}
public void setOldAlarmScene(String oldAlarmScene) {
this.oldAlarmScene = oldAlarmScene;
}
}
......@@ -5,22 +5,14 @@ public class UpdateTopicModelInfoVo {
private String topicName;
private int type;
private Integer type;
private int intervalTime;
private Integer intervalTime;
private int frequency;
private Integer frequency;
private String oldTopicName;
public String getOldTopicName() {
return oldTopicName;
}
public void setOldTopicName(String oldTopicName) {
this.oldTopicName = oldTopicName;
}
public String getTopicModelName() {
return topicModelName;
}
......@@ -37,27 +29,35 @@ public class UpdateTopicModelInfoVo {
this.topicName = topicName;
}
public int getType() {
public Integer getType() {
return type;
}
public void setType(int type) {
public void setType(Integer type) {
this.type = type;
}
public int getIntervalTime() {
public Integer getIntervalTime() {
return intervalTime;
}
public void setIntervalTime(int intervalTime) {
public void setIntervalTime(Integer intervalTime) {
this.intervalTime = intervalTime;
}
public int getFrequency() {
public Integer getFrequency() {
return frequency;
}
public void setFrequency(int frequency) {
public void setFrequency(Integer frequency) {
this.frequency = frequency;
}
public String getOldTopicName() {
return oldTopicName;
}
public void setOldTopicName(String oldTopicName) {
this.oldTopicName = oldTopicName;
}
}
......@@ -31,17 +31,17 @@ public class UpdateWarehouseVo {
private String hardwareLevel;//硬件等级
private double areaIndoor;//室内平面面积
private Double areaIndoor;//室内平面面积
private double areaRack;//货架面积
private Double areaRack;//货架面积
private double areaOutdoor;//实际室内总面积
private Double areaOutdoor;//实际室内总面积
private double areaPlanIndoor;//实际室内总面积
private Double areaPlanIndoor;//实际室内总面积
private String office;//办事处
private int timeZone;//时区
private Integer timeZone;//时区
private String weatherInfo;//区域气象信息
......@@ -171,35 +171,35 @@ public class UpdateWarehouseVo {
this.hardwareLevel = hardwareLevel;
}
public double getAreaIndoor() {
public Double getAreaIndoor() {
return areaIndoor;
}
public void setAreaIndoor(double areaIndoor) {
public void setAreaIndoor(Double areaIndoor) {
this.areaIndoor = areaIndoor;
}
public double getAreaRack() {
public Double getAreaRack() {
return areaRack;
}
public void setAreaRack(double areaRack) {
public void setAreaRack(Double areaRack) {
this.areaRack = areaRack;
}
public double getAreaOutdoor() {
public Double getAreaOutdoor() {
return areaOutdoor;
}
public void setAreaOutdoor(double areaOutdoor) {
public void setAreaOutdoor(Double areaOutdoor) {
this.areaOutdoor = areaOutdoor;
}
public double getAreaPlanIndoor() {
public Double getAreaPlanIndoor() {
return areaPlanIndoor;
}
public void setAreaPlanIndoor(double areaPlanIndoor) {
public void setAreaPlanIndoor(Double areaPlanIndoor) {
this.areaPlanIndoor = areaPlanIndoor;
}
......@@ -211,11 +211,11 @@ public class UpdateWarehouseVo {
this.office = office;
}
public int getTimeZone() {
public Integer getTimeZone() {
return timeZone;
}
public void setTimeZone(int timeZone) {
public void setTimeZone(Integer timeZone) {
this.timeZone = timeZone;
}
......
......@@ -17,15 +17,15 @@ public class Alarm implements Serializable{
private String alarmScene;
private float temMax;//温度上限
private Float temMax;//温度上限
private float temMin;//温度下限
private Float temMin;//温度下限
private float humidityMax;//湿度上限
private Float humidityMax;//湿度上限
private float humidityMin;//湿度下限
private Float humidityMin;//湿度下限
private float tilt;//倾斜度
private Float tilt;//倾斜度
private String shock;//震度
......@@ -55,43 +55,43 @@ public class Alarm implements Serializable{
this.alarmScene = alarmScene;
}
public float getTemMax() {
public Float getTemMax() {
return temMax;
}
public void setTemMax(float temMax) {
public void setTemMax(Float temMax) {
this.temMax = temMax;
}
public float getTemMin() {
public Float getTemMin() {
return temMin;
}
public void setTemMin(float temMin) {
public void setTemMin(Float temMin) {
this.temMin = temMin;
}
public float getHumidityMax() {
public Float getHumidityMax() {
return humidityMax;
}
public void setHumidityMax(float humidityMax) {
public void setHumidityMax(Float humidityMax) {
this.humidityMax = humidityMax;
}
public float getHumidityMin() {
public Float getHumidityMin() {
return humidityMin;
}
public void setHumidityMin(float humidityMin) {
public void setHumidityMin(Float humidityMin) {
this.humidityMin = humidityMin;
}
public float getTilt() {
public Float getTilt() {
return tilt;
}
public void setTilt(float tilt) {
public void setTilt(Float tilt) {
this.tilt = tilt;
}
......
......@@ -3,7 +3,7 @@ package com.example.tdl.entity;
public class Probes {
private int id;
private int port;
private Integer port;
private String unit;
......@@ -13,9 +13,9 @@ public class Probes {
private String type;
private int alarmUp;
private Integer alarmUp;
private int alarmDown;
private Integer alarmDown;
private Gateway gateway;
......@@ -27,11 +27,11 @@ public class Probes {
this.id = id;
}
public int getPort() {
public Integer getPort() {
return port;
}
public void setPort(int port) {
public void setPort(Integer port) {
this.port = port;
}
......@@ -67,19 +67,19 @@ public class Probes {
this.type = type;
}
public int getAlarmUp() {
public Integer getAlarmUp() {
return alarmUp;
}
public void setAlarmUp(int alarmUp) {
public void setAlarmUp(Integer alarmUp) {
this.alarmUp = alarmUp;
}
public int getAlarmDown() {
public Integer getAlarmDown() {
return alarmDown;
}
public void setAlarmDown(int alarmDown) {
public void setAlarmDown(Integer alarmDown) {
this.alarmDown = alarmDown;
}
......
......@@ -5,7 +5,7 @@ public class ProbesModel {
private String probesModelName;
private int countNum;
private Integer countNum;
private Long createTime;
......@@ -27,11 +27,11 @@ public class ProbesModel {
this.probesModelName = probesModelName;
}
public int getCountNum() {
public Integer getCountNum() {
return countNum;
}
public void setCountNum(int countNum) {
public void setCountNum(Integer countNum) {
this.countNum = countNum;
}
......
......@@ -5,7 +5,7 @@ public class ProbesModelInfo {
private ProbesModel probesModel;
private int port;
private Integer port;
private String unit;
......@@ -15,9 +15,9 @@ public class ProbesModelInfo {
private String type;
private int alarmUp;
private Integer alarmUp;
private int alarmDown;
private Integer alarmDown;
public int getId() {
return id;
......@@ -35,11 +35,11 @@ public class ProbesModelInfo {
this.probesModel = probesModel;
}
public int getPort() {
public Integer getPort() {
return port;
}
public void setPort(int port) {
public void setPort(Integer port) {
this.port = port;
}
......@@ -75,19 +75,19 @@ public class ProbesModelInfo {
this.type = type;
}
public int getAlarmUp() {
public Integer getAlarmUp() {
return alarmUp;
}
public void setAlarmUp(int alarmUp) {
public void setAlarmUp(Integer alarmUp) {
this.alarmUp = alarmUp;
}
public int getAlarmDown() {
public Integer getAlarmDown() {
return alarmDown;
}
public void setAlarmDown(int alarmDown) {
public void setAlarmDown(Integer alarmDown) {
this.alarmDown = alarmDown;
}
}
......@@ -16,20 +16,12 @@ public class TDLDevice implements Serializable{
private Long lastTime;
private int useScene;
private Integer useScene;
private String warehouseName;
private String transportationNo;
public String getWarehouseName() {
return warehouseName;
}
public void setWarehouseName(String warehouseName) {
this.warehouseName = warehouseName;
}
public int getId() {
return id;
}
......@@ -38,14 +30,6 @@ public class TDLDevice implements Serializable{
this.id = id;
}
public String getTDLSN() {
return TDLSN;
}
public void setTDLSN(String TDLSN) {
this.TDLSN = TDLSN;
}
public String getTDLName() {
return TDLName;
}
......@@ -54,6 +38,14 @@ public class TDLDevice implements Serializable{
this.TDLName = TDLName;
}
public String getTDLSN() {
return TDLSN;
}
public void setTDLSN(String TDLSN) {
this.TDLSN = TDLSN;
}
public String getCounts() {
return counts;
}
......@@ -70,14 +62,22 @@ public class TDLDevice implements Serializable{
this.lastTime = lastTime;
}
public int getUseScene() {
public Integer getUseScene() {
return useScene;
}
public void setUseScene(int useScene) {
public void setUseScene(Integer useScene) {
this.useScene = useScene;
}
public String getWarehouseName() {
return warehouseName;
}
public void setWarehouseName(String warehouseName) {
this.warehouseName = warehouseName;
}
public String getTransportationNo() {
return transportationNo;
}
......
......@@ -5,11 +5,11 @@ public class Topic {
private String topicName;
private int type;
private Integer type;
private int intervalTime;
private Integer intervalTime;
private int frequency;
private Integer frequency;
private Gateway gateway;
......@@ -29,27 +29,27 @@ public class Topic {
this.topicName = topicName;
}
public int getType() {
public Integer getType() {
return type;
}
public void setType(int type) {
public void setType(Integer type) {
this.type = type;
}
public int getIntervalTime() {
public Integer getIntervalTime() {
return intervalTime;
}
public void setIntervalTime(int intervalTime) {
public void setIntervalTime(Integer intervalTime) {
this.intervalTime = intervalTime;
}
public int getFrequency() {
public Integer getFrequency() {
return frequency;
}
public void setFrequency(int frequency) {
public void setFrequency(Integer frequency) {
this.frequency = frequency;
}
......
......@@ -7,11 +7,11 @@ public class TopicModelInfo {
private String topicName;
private int type;
private Integer type;
private int intervalTime;
private Integer intervalTime;
private int frequency;
private Integer frequency;
public int getId() {
return id;
......@@ -37,27 +37,27 @@ public class TopicModelInfo {
this.topicName = topicName;
}
public int getType() {
public Integer getType() {
return type;
}
public void setType(int type) {
public void setType(Integer type) {
this.type = type;
}
public int getIntervalTime() {
public Integer getIntervalTime() {
return intervalTime;
}
public void setIntervalTime(int intervalTime) {
public void setIntervalTime(Integer intervalTime) {
this.intervalTime = intervalTime;
}
public int getFrequency() {
public Integer getFrequency() {
return frequency;
}
public void setFrequency(int frequency) {
public void setFrequency(Integer frequency) {
this.frequency = frequency;
}
}
......@@ -42,17 +42,17 @@ public class Warehouse implements Serializable {
private String hardwareLevel;//硬件等级
private double areaIndoor;//室内平面面积
private Double areaIndoor;//室内平面面积
private double areaRack;//货架面积
private Double areaRack;//货架面积
private double areaOutdoor;//实际室内总面积
private Double areaOutdoor;//实际室内总面积
private double areaPlanIndoor;//实际室内总面积
private Double areaPlanIndoor;//实际室内总面积
private String office;//办事处
private int timeZone;//时区
private Integer timeZone;//时区
private String weatherInfo;//区域气象信息
......@@ -64,6 +64,38 @@ public class Warehouse implements Serializable {
private String remark;
public Warehouse() {
}
public Warehouse( String warehouseName, String warehouseNo, String country, String province, String city, String district, String address, String regionCN, String regionEN, String longitude, String latitude, String property, String type, String alarmType, String hardwareLevel, Double areaIndoor, Double areaRack, Double areaOutdoor, Double areaPlanIndoor, String office, Integer timeZone, String weatherInfo, String warehouseInfo, Long createTime, Long updateTime, String remark) {
this.warehouseName = warehouseName;
this.warehouseNo = warehouseNo;
this.country = country;
this.province = province;
this.city = city;
this.district = district;
this.address = address;
this.regionCN = regionCN;
this.regionEN = regionEN;
this.longitude = longitude;
this.latitude = latitude;
this.property = property;
this.type = type;
this.alarmType = alarmType;
this.hardwareLevel = hardwareLevel;
this.areaIndoor = areaIndoor;
this.areaRack = areaRack;
this.areaOutdoor = areaOutdoor;
this.areaPlanIndoor = areaPlanIndoor;
this.office = office;
this.timeZone = timeZone;
this.weatherInfo = weatherInfo;
this.warehouseInfo = warehouseInfo;
this.createTime = createTime;
this.updateTime = updateTime;
this.remark = remark;
}
public Integer getId() {
return id;
}
......@@ -80,6 +112,14 @@ public class Warehouse implements Serializable {
this.warehouseName = warehouseName;
}
public String getWarehouseNo() {
return warehouseNo;
}
public void setWarehouseNo(String warehouseNo) {
this.warehouseNo = warehouseNo;
}
public String getCountry() {
return country;
}
......@@ -168,14 +208,6 @@ public class Warehouse implements Serializable {
this.type = type;
}
public Serializable getSerializable() {
return serializable;
}
public void setSerializable(Serializable serializable) {
this.serializable = serializable;
}
public String getAlarmType() {
return alarmType;
}
......@@ -192,35 +224,35 @@ public class Warehouse implements Serializable {
this.hardwareLevel = hardwareLevel;
}
public double getAreaIndoor() {
public Double getAreaIndoor() {
return areaIndoor;
}
public void setAreaIndoor(double areaIndoor) {
public void setAreaIndoor(Double areaIndoor) {
this.areaIndoor = areaIndoor;
}
public double getAreaRack() {
public Double getAreaRack() {
return areaRack;
}
public void setAreaRack(double areaRack) {
public void setAreaRack(Double areaRack) {
this.areaRack = areaRack;
}
public double getAreaOutdoor() {
public Double getAreaOutdoor() {
return areaOutdoor;
}
public void setAreaOutdoor(double areaOutdoor) {
public void setAreaOutdoor(Double areaOutdoor) {
this.areaOutdoor = areaOutdoor;
}
public double getAreaPlanIndoor() {
public Double getAreaPlanIndoor() {
return areaPlanIndoor;
}
public void setAreaPlanIndoor(double areaPlanIndoor) {
public void setAreaPlanIndoor(Double areaPlanIndoor) {
this.areaPlanIndoor = areaPlanIndoor;
}
......@@ -232,11 +264,11 @@ public class Warehouse implements Serializable {
this.office = office;
}
public int getTimeZone() {
public Integer getTimeZone() {
return timeZone;
}
public void setTimeZone(int timeZone) {
public void setTimeZone(Integer timeZone) {
this.timeZone = timeZone;
}
......@@ -256,14 +288,6 @@ public class Warehouse implements Serializable {
this.warehouseInfo = warehouseInfo;
}
public String getWarehouseNo() {
return warehouseNo;
}
public void setWarehouseNo(String warehouseNo) {
this.warehouseNo = warehouseNo;
}
public Long getCreateTime() {
return createTime;
}
......@@ -287,36 +311,4 @@ public class Warehouse implements Serializable {
public void setRemark(String remark) {
this.remark = remark;
}
public Warehouse() {
}
public Warehouse(String warehouseName, String warehouseNo, String country, String province, String city, String district, String address, String regionCN, String regionEN, String longitude, String latitude, String property, String type, String alarmType, String hardwareLevel, double areaIndoor, double areaRack, double areaOutdoor, double areaPlanIndoor, String office, int timeZone, String weatherInfo, String warehouseInfo, Long createTime, Long updateTime, String remark) {
this.warehouseName = warehouseName;
this.warehouseNo = warehouseNo;
this.country = country;
this.province = province;
this.city = city;
this.district = district;
this.address = address;
this.regionCN = regionCN;
this.regionEN = regionEN;
this.longitude = longitude;
this.latitude = latitude;
this.property = property;
this.type = type;
this.alarmType = alarmType;
this.hardwareLevel = hardwareLevel;
this.areaIndoor = areaIndoor;
this.areaRack = areaRack;
this.areaOutdoor = areaOutdoor;
this.areaPlanIndoor = areaPlanIndoor;
this.office = office;
this.timeZone = timeZone;
this.weatherInfo = weatherInfo;
this.warehouseInfo = warehouseInfo;
this.createTime = createTime;
this.updateTime = updateTime;
this.remark = remark;
}
}
......@@ -26,7 +26,7 @@ public class LoginInterceptor implements HandlerInterceptor {
String token = request.getHeader("Account_token");
if(token == null){
response.setContentType("application/json");
response.setStatus(401);
response.setStatus(200);
response.setHeader("Content-type", "text/html;charset=UTF-8");
OutputStream ps = response.getOutputStream();
ps.write("{\"code\":0,\"message\":\"用户未登录,请先登录\"}".getBytes("UTF-8"));
......@@ -35,10 +35,10 @@ public class LoginInterceptor implements HandlerInterceptor {
String data = redisService.get("TOKEN_" +token);
if(data == null){
response.setContentType("application/json");
response.setStatus(401);
response.setStatus(200);
response.setHeader("Content-type", "text/html;charset=UTF-8");
OutputStream ps = response.getOutputStream();
ps.write("{\"code\":0,\"message\":\"用户登录过期,请重新登录\"}".getBytes("UTF-8"));
ps.write("{\"code\":2,\"message\":\"用户登录过期,请重新登录\"}".getBytes("UTF-8"));
return false;
}
redisService.expire("TOKEN_" +token,60 * 30);
......
package com.example.tdl.interceptor;
import com.example.tdl.domain.vo.UserVo;
import com.example.tdl.service.RoleService;
import com.example.tdl.service.TokenRedisService;
import com.google.gson.Gson;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class PermissionInterceptor implements HandlerInterceptor {
private static Logger logger = LoggerFactory.getLogger(PermissionInterceptor.class);
@Autowired
private TokenRedisService redisService;
@Autowired
private RoleService roleService;
Gson gson = new Gson();
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
logger.info("==============执行顺序: 1、preHandle================");
String requestUri = request.getRequestURI();
String contextPath = request.getContextPath();
String url = requestUri.substring(contextPath.length());
logger.info("requestUri:"+requestUri);
logger.info("contextPath:"+contextPath);
logger.info("url:"+url);
//获取用户信息以及对应的权限信息
UserVo user = gson.fromJson(redisService.get("TOKEN_" +request.getHeader("Account_token")),UserVo.class);
//根据用户名获取对应的权限
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
}
}
package com.example.tdl.mqtt;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
@ConfigurationProperties(prefix = "tdl.mqtt")
public class MqttConfig {
private String url;
private String port;
private String username;
private String password;
private String qos;
private String clientPubId;
private String clientSubId;
private String clientSubTopic;
private Boolean useCredential;
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getPort() {
return port;
}
public void setPort(String port) {
this.port = port;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getQos() {
return qos;
}
public void setQos(String qos) {
this.qos = qos;
}
public String getClientPubId() {
return clientPubId;
}
public void setClientPubId(String clientPubId) {
this.clientPubId = clientPubId;
}
public String getClientSubId() {
return clientSubId;
}
public void setClientSubId(String clientSubId) {
this.clientSubId = clientSubId;
}
public String getClientSubTopic() {
return clientSubTopic;
}
public void setClientSubTopic(String clientSubTopic) {
this.clientSubTopic = clientSubTopic;
}
public Boolean getUseCredential() {
return useCredential;
}
public void setUseCredential(Boolean useCredential) {
this.useCredential = useCredential;
}
/* @Bean
public MqttTemplate mqttTemplate() throws MqttException {
MqttTemplate mqttTemplate =null;
try {
mqttTemplate = new MqttTemplate(this.url+":"+this.port,"witiumcloud");
mqttTemplate.connect(MqttTemplate.setOptions(this.username,this.password));
System.out.println("Mqtt connected with mqtt broker at url : 120.27.235.39:1883");
}catch (MqttException e)
{
e.printStackTrace();
}
return mqttTemplate;
}*/
}
......@@ -2,6 +2,9 @@ package com.example.tdl.service;
import com.example.tdl.domain.vo.*;
import com.example.tdl.mapper.UserMapper;
import com.google.gson.Gson;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -9,9 +12,15 @@ import java.util.List;
@Service
public class UserService {
Gson gson = new Gson();
@Autowired
private UserMapper userMapper;
@Autowired
private TokenRedisService redisService;
public int login(LoginUserVo loginUserVo){
return userMapper.login(loginUserVo);
}
......@@ -55,4 +64,23 @@ public class UserService {
public int resetPassword(String userNumber,String password){
return userMapper.resetPassword(userNumber,password);
}
//登录
public String getUser(LoginUserVo loginUserVo) {
//获取用户信息
UserVo userVo = userMapper.getByUserName(loginUserVo.getUserName());
if(userVo == null){
return null;
}
//匹配密码
if(!userVo.getPassword().equals(DigestUtils.sha256Hex(loginUserVo.getPassword()))){
return null;
}
String token = DigestUtils.md5Hex(System.currentTimeMillis() + userVo.getUserName());
UserRedisVo redisVo = new UserRedisVo(userVo.getUserName(),userVo.getUserNumber(),userVo.getNickName(),userVo.getEmail(),userVo.getPhone(),userVo.getRoleName());
//将用户数据保存到redis中
redisService.set("TOKEN_" + token, gson.toJson(redisVo), 60 * 30);
return token;
}
}
package com.example.tdl.shiro;
import com.example.tdl.domain.vo.UserVo;
import com.example.tdl.service.UserService;
import org.apache.shiro.authc.*;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.springframework.beans.factory.annotation.Autowired;
public class AuthRealm extends AuthorizingRealm{
@Autowired
private UserService userService;
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
System.out.println("....认证....");
//1 强转token
UsernamePasswordToken upToken = (UsernamePasswordToken) token;
//2 根据用户名查找用户信息
UserVo user = userService.getByUserName(upToken.getUsername());
if(user==null){
return null;
}
SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(user, user.getPassword(),this.getName());
return info;
}
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
// 授权
//1 获取当前登录用户
UserVo user = (UserVo) principals.fromRealm(this.getName()).iterator().next();
//2 获取用户的角色
//Set<Role> roles = user.getRoles();
//定义接收module的结果集
// List<String> list = new ArrayList<String>();
//3 遍历角色,获取每个角色对应的访问权限
//for(Role r:roles){
//}
// 4返回AuthorizationInfo信息
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
//添加list信息
//info.addStringPermissions(list);
//return info;
return null;
}
}
......@@ -64,9 +64,6 @@ public class ShiroRealm extends AuthorizingRealm {
Set<String> r = new HashSet<String>();
r.add("role1");
info.setRoles(r);
//设置登录次数、时间
// userService.updateUserLogin(user);
return info;
}
......@@ -75,8 +72,6 @@ public class ShiroRealm extends AuthorizingRealm {
//认证
logger.info("doGetAuthenticationInfo +" + authenticationToken.toString());
UsernamePasswordToken token = (UsernamePasswordToken) authenticationToken;
//String userName=token.getUsername();
//logger.info(userName+token.getPassword());
UserVo user = userService.getByUserName(token.getUsername());
if(user == null){
......
package com.example.tdl.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
/**
*
* Cookie 工具类
*
*/
public final class CookieUtils {
protected static final Logger logger = LoggerFactory.getLogger(CookieUtils.class);
/**
* 得到Cookie的值, 不编码
*
* @param request
* @param cookieName
* @return
*/
public static String getCookieValue(HttpServletRequest request, String cookieName) {
return getCookieValue(request, cookieName, false);
}
/**
* 得到Cookie的值,
*
* @param request
* @param cookieName
* @return
*/
public static String getCookieValue(HttpServletRequest request, String cookieName, boolean isDecoder) {
Cookie[] cookieList = request.getCookies();
if (cookieList == null || cookieName == null){
return null;
}
String retValue = null;
try {
for (int i = 0; i < cookieList.length; i++) {
if (cookieList[i].getName().equals(cookieName)) {
if (isDecoder) {
retValue = URLDecoder.decode(cookieList[i].getValue(), "UTF-8");
} else {
retValue = cookieList[i].getValue();
}
break;
}
}
} catch (UnsupportedEncodingException e) {
logger.error("Cookie Decode Error.", e);
}
return retValue;
}
/**
* 得到Cookie的值,
*
* @param request
* @param cookieName
* @return
*/
public static String getCookieValue(HttpServletRequest request, String cookieName, String encodeString) {
Cookie[] cookieList = request.getCookies();
if (cookieList == null || cookieName == null){
return null;
}
String retValue = null;
try {
for (int i = 0; i < cookieList.length; i++) {
if (cookieList[i].getName().equals(cookieName)) {
retValue = URLDecoder.decode(cookieList[i].getValue(), encodeString);
break;
}
}
} catch (UnsupportedEncodingException e) {
logger.error("Cookie Decode Error.", e);
}
return retValue;
}
/**
* 设置Cookie的值 不设置生效时间默认浏览器关闭即失效,也不编码
*/
public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue) {
setCookie(request, response, cookieName, cookieValue, -1);
}
/**
* 设置Cookie的值 在指定时间内生效,但不编码
*/
public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue, int cookieMaxage) {
setCookie(request, response, cookieName, cookieValue, cookieMaxage, false);
}
/**
* 设置Cookie的值 不设置生效时间,但编码
*/
public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue, boolean isEncode) {
setCookie(request, response, cookieName, cookieValue, -1, isEncode);
}
/**
* 设置Cookie的值 在指定时间内生效, 编码参数
*/
public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue, int cookieMaxage, boolean isEncode) {
doSetCookie(request, response, cookieName, cookieValue, cookieMaxage, isEncode);
}
/**
* 设置Cookie的值 在指定时间内生效, 编码参数(指定编码)
*/
public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue, int cookieMaxage, String encodeString) {
doSetCookie(request, response, cookieName, cookieValue, cookieMaxage, encodeString);
}
/**
* 删除Cookie带cookie域名
*/
public static void deleteCookie(HttpServletRequest request, HttpServletResponse response, String cookieName) {
doSetCookie(request, response, cookieName, "", -1, false);
}
/**
* 设置Cookie的值,并使其在指定时间内生效
*
* @param cookieMaxage
* cookie生效的最大秒数
*/
private static final void doSetCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue, int cookieMaxage, boolean isEncode) {
try {
if (cookieValue == null) {
cookieValue = "";
} else if (isEncode) {
cookieValue = URLEncoder.encode(cookieValue, "utf-8");
}
Cookie cookie = new Cookie(cookieName, cookieValue);
if (cookieMaxage > 0)
cookie.setMaxAge(cookieMaxage);
if (null != request) {// 设置域名的cookie
if (request.getRemoteHost().equals("localhost") || request.getRemoteHost().equals("127.0.0.1") || request.getRemoteHost().equals("192.168.1.52")) {
cookie.setDomain("");
} else {
cookie.setDomain(getDomainName(request));
}
}
cookie.setPath("/");
response.addCookie(cookie);
} catch (Exception e) {
logger.error("Cookie Encode Error.", e);
}
}
/**
* 设置Cookie的值,并使其在指定时间内生效
*
* @param cookieMaxage
* cookie生效的最大秒数
*/
private static final void doSetCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue, int cookieMaxage, String encodeString) {
try {
if (cookieValue == null) {
cookieValue = "";
} else {
cookieValue = URLEncoder.encode(cookieValue, encodeString);
}
Cookie cookie = new Cookie(cookieName, cookieValue);
if (cookieMaxage > 0)
cookie.setMaxAge(cookieMaxage);
if (null != request)// 设置域名的cookie
cookie.setDomain(getDomainName(request));
cookie.setPath("/");
response.addCookie(cookie);
} catch (Exception e) {
logger.error("Cookie Encode Error.", e);
}
}
/**
* 得到cookie的域名
*/
private static final String getDomainName(HttpServletRequest request) {
String domainName = null;
String serverName = request.getRequestURL().toString();
if (serverName == null || serverName.equals("")) {
domainName = "";
} else {
serverName = serverName.toLowerCase();
serverName = serverName.substring(7);
final int end = serverName.indexOf("/");
serverName = serverName.substring(0, end);
final String[] domains = serverName.split("\\.");
int len = domains.length;
if (len > 3) {
// www.xxx.com.cn
domainName = "." + domains[len - 3] + "." + domains[len - 2] + "." + domains[len - 1];
} else if (len <= 3 && len > 1) {
// xxx.com or xxx.cn
domainName = "." + domains[len - 2] + "." + domains[len - 1];
} else {
domainName = serverName;
}
}
if (domainName != null && domainName.indexOf(":") > 0) {
String[] ary = domainName.split("\\:");
domainName = ary[0];
}
return domainName;
}
}
......@@ -113,32 +113,32 @@ public class AlarmController {
fb.setMessage("请选择正确的预警场景");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addAlarmVo.getTemMax()+"")){
if (addAlarmVo.getTemMax()== null){
fb.setCode(0);
fb.setMessage("温度上限不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addAlarmVo.getTemMin()+"")){
if (addAlarmVo.getTemMin()== null){
fb.setCode(0);
fb.setMessage("温度下限不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addAlarmVo.getHumidityMax()+"")){
if (addAlarmVo.getHumidityMax()==null){
fb.setCode(0);
fb.setMessage("湿度上限不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addAlarmVo.getHumidityMin()+"")){
if (addAlarmVo.getHumidityMin()==null){
fb.setCode(0);
fb.setMessage("湿度下限不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addAlarmVo.getTilt()+"")){
if (addAlarmVo.getTilt()==null){
fb.setCode(0);
fb.setMessage("倾斜度不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addAlarmVo.getShock()+"")){
if (addAlarmVo.getShock()==null){
fb.setCode(0);
fb.setMessage("震度不能为空");
return gson.toJson(fb);
......@@ -206,32 +206,32 @@ public class AlarmController {
fb.setMessage("请选择正确的预警场景");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateAlarmVo.getTemMax()+"")){
if (updateAlarmVo.getTemMax()==null){
fb.setCode(0);
fb.setMessage("温度上限不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateAlarmVo.getTemMin()+"")){
if (updateAlarmVo.getTemMin()==null){
fb.setCode(0);
fb.setMessage("温度下限不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateAlarmVo.getHumidityMax()+"")){
if (updateAlarmVo.getHumidityMax()==null){
fb.setCode(0);
fb.setMessage("湿度上限不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateAlarmVo.getHumidityMin()+"")){
if (updateAlarmVo.getHumidityMin()==null){
fb.setCode(0);
fb.setMessage("湿度下限不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateAlarmVo.getTilt()+"")){
if (updateAlarmVo.getTilt()==null){
fb.setCode(0);
fb.setMessage("倾斜度不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateAlarmVo.getShock()+"")){
if (updateAlarmVo.getShock()==null){
fb.setCode(0);
fb.setMessage("震度不能为空");
return gson.toJson(fb);
......
......@@ -8,6 +8,7 @@ import com.example.tdl.entity.LoginLog;
import com.example.tdl.service.LoginLogService;
import com.example.tdl.service.TokenRedisService;
import com.example.tdl.service.UserService;
import com.example.tdl.util.CookieUtils;
import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
......@@ -50,7 +51,6 @@ public class LoginController {
" userName: 用户名," +
" password: 密码")
@RequestMapping(value = "/loginForToken", method = RequestMethod.POST)
@ResponseBody
public String loginForToken(@RequestBody LoginUserVo loginUserVo, HttpServletRequest request, HttpServletResponse response) {
if(StringUtils.isEmpty(loginUserVo.getUserName())){
fb.setCode(0);
......@@ -62,11 +62,6 @@ public class LoginController {
fb.setMessage("密码不能为空");
return gson.toJson(fb);
}
if(userService.getByUserName(loginUserVo.getUserName()) == null){
fb.setCode(0);
fb.setMessage("该用户不存在");
return gson.toJson(fb);
}
try {
UserVo userVo=userService.getByUserName(loginUserVo.getUserName());
//将封装好的用户名和密码交给shiro安全框架并实现登陆
......@@ -100,7 +95,6 @@ public class LoginController {
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@RequestMapping(value = "/logout", method = RequestMethod.GET)
@ResponseBody
public String logout(HttpServletRequest request){
String token=request.getHeader("Account_token");
tokenRedisService.delKey("TOKEN_"+token);
......@@ -110,13 +104,38 @@ public class LoginController {
}
@ApiOperation(value="登录",notes = "登录")
@RequestMapping(value = "/login", method = RequestMethod.POST)
public String login(@RequestBody LoginUserVo loginUserVo,HttpServletRequest request,HttpServletResponse response){
if(StringUtils.isEmpty(loginUserVo.getUserName())){
fb.setCode(0);
fb.setMessage("用户名不能为空");
return gson.toJson(fb);
}
if(StringUtils.isEmpty(loginUserVo.getPassword())){
fb.setCode(0);
fb.setMessage("密码不能为空");
return gson.toJson(fb);
}
String token = userService.getUser(loginUserVo);
if(token == null){
fb.setCode(0);
fb.setMessage("账号或者密码错误");
}else{
CookieUtils.setCookie(request,response,"Account_token",token);
fb.setCode(1);
fb.setMessage(token);
}
return gson.toJson(fb);
}
//登录功能
// @ApiOperation(value = "登录功能",notes = "登录功能:" +
// " userName: 用户名," +
// " password: 密码")
// @RequestMapping(value = "/doLogin", method = RequestMethod.POST)
// @ResponseBody
// public String login(@RequestBody LoginUserVo loginUserVo) {
// if(StringUtils.isEmpty(loginUserVo.getUserName())){
// fb.setCode(0);
......
......@@ -38,7 +38,6 @@ public class LoginLogController {
@Autowired
private TokenRedisService tokenRedisService;
//查询登录日志
@ApiOperation(value = "查询登录日志",notes = "查询登录日志,返回值说明:" +
" userName:用户名," +
......@@ -65,12 +64,12 @@ public class LoginLogController {
})
@RequestMapping(value="/getByTime",method = RequestMethod.POST)
public Object getByTime(@RequestBody LoginLogTermVo loginLogTermVo){
if (StringUtils.isEmpty(loginLogTermVo.getStartTime()+"")){
if (loginLogTermVo.getStartTime() == null){
fb.setCode(0);
fb.setMessage("查询开始时间不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(loginLogTermVo.getStopTime()+"")){
if (loginLogTermVo.getStopTime() == null){
fb.setCode(0);
fb.setMessage("查询结束时间不能为空");
return gson.toJson(fb);
......
......@@ -69,7 +69,7 @@ public class ProbesModelController {
fb.setMessage("模板名不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addProbesModelVo.getCountNum()+"")){
if (addProbesModelVo.getCountNum()==null){
fb.setCode(0);
fb.setMessage("新增的模板通道数量不能为空");
return gson.toJson(fb);
......
......@@ -90,12 +90,12 @@ public class TopicModelInfoController {
fb.setMessage("添加的主题名不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(topicModelInfoVo.getType()+"")){
if (topicModelInfoVo.getType() == null){
fb.setCode(0);
fb.setMessage("添加的主题类型不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(topicModelInfoVo.getIntervalTime()+"")){
if (topicModelInfoVo.getIntervalTime() == null){
fb.setCode(0);
fb.setMessage("添加的间隔时间不能为空");
return gson.toJson(fb);
......@@ -148,12 +148,12 @@ public class TopicModelInfoController {
fb.setMessage("修改的主题名不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateTopicModelInfoVo.getType()+"")){
if (updateTopicModelInfoVo.getType()== null){
fb.setCode(0);
fb.setMessage("修改的主题类型不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateTopicModelInfoVo.getIntervalTime()+"")){
if (updateTopicModelInfoVo.getIntervalTime()== null){
fb.setCode(0);
fb.setMessage("修改的间隔时间不能为空");
return gson.toJson(fb);
......
......@@ -266,22 +266,22 @@ public class WarehouseController {
fb.setMessage("请选择正确的硬件等级");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addWarehouseVo.getAreaIndoor()+"")){
if (addWarehouseVo.getAreaIndoor()==null){
fb.setCode(0);
fb.setMessage("室内平面面积不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addWarehouseVo.getAreaRack()+"")){
if (addWarehouseVo.getAreaRack()==null){
fb.setCode(0);
fb.setMessage("货架面积不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addWarehouseVo.getAreaOutdoor()+"")){
if (addWarehouseVo.getAreaOutdoor()==null){
fb.setCode(0);
fb.setMessage("室外面积不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addWarehouseVo.getAreaPlanIndoor()+"")){
if (addWarehouseVo.getAreaPlanIndoor() == null){
fb.setCode(0);
fb.setMessage("实际室内总面积不能为空");
return gson.toJson(fb);
......@@ -291,7 +291,7 @@ public class WarehouseController {
fb.setMessage("办事处不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addWarehouseVo.getTimeZone()+"")){
if (addWarehouseVo.getTimeZone()==null){
fb.setCode(0);
fb.setMessage("时区不能为空");
return gson.toJson(fb);
......@@ -465,22 +465,22 @@ public class WarehouseController {
fb.setMessage("请选择正确的硬件等级");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateWarehouseVo.getAreaIndoor()+"")){
if (updateWarehouseVo.getAreaIndoor() == null){
fb.setCode(0);
fb.setMessage("室内平面面积不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateWarehouseVo.getAreaRack()+"")){
if (updateWarehouseVo.getAreaRack()== null){
fb.setCode(0);
fb.setMessage("货架面积不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateWarehouseVo.getAreaOutdoor()+"")){
if (updateWarehouseVo.getAreaOutdoor()== null){
fb.setCode(0);
fb.setMessage("室外面积不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateWarehouseVo.getAreaPlanIndoor()+"")){
if (updateWarehouseVo.getAreaPlanIndoor()== null){
fb.setCode(0);
fb.setMessage("实际室内总面积不能为空");
return gson.toJson(fb);
......@@ -490,7 +490,7 @@ public class WarehouseController {
fb.setMessage("办事处不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateWarehouseVo.getTimeZone()+"")){
if (updateWarehouseVo.getTimeZone()== null){
fb.setCode(0);
fb.setMessage("时区不能为空");
return gson.toJson(fb);
......
spring.datasource.url=jdbc:mysql://192.168.1.200:3306/tdlcloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.redis.host=192.168.1.200
tdl.influxdb.host=http://192.168.1.200:8086
spring.datasource.url=jdbc:mysql://HostTest-mysql:3306/cy?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.username=root
spring.datasource.password=37774020
# Redisַ
spring.redis.host=HostTest-redis
spring.redis.port=6379
tdl.influxdb.host=http://HostTest-influxdb:8086
# Logging
logging.config=classpath:logback.xml
......@@ -35,3 +35,16 @@ spring.redis.timeout=0
# Logging
logging.config=classpath:logback.xml
tdl.mqtt.url = tcp://192.168.1.87
tdl.mqtt.port = 1883
tdl.mqtt.username = test
tdl.mqtt.password = witium
tdl.mqtt.qos = 0
tdl.mqtt.timeout = 20;
tdl.mqtt.clientPubId = witiumcloud
tdl.mqtt.useCredential = true
tdl.mqtt.clientSubId = witiumcloud
tdl.mqtt.clientSubTopic = witium/#
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment