Commit 84c1d09dd8562678c3a40091f5ec2c0671f419f8

Authored by xp.Huang
2 parents 25210b0f 8da35d8f

Merge branch '20200305' into 'master'

refactor: 密码找回

See merge request huang/thingsboard3.3.2!57
@@ -43,6 +43,7 @@ public enum ErrorMessage { @@ -43,6 +43,7 @@ public enum ErrorMessage {
43 CONVERT_JS_IS_ALONE(400024,"转换脚本只能启用一个"), 43 CONVERT_JS_IS_ALONE(400024,"转换脚本只能启用一个"),
44 PHONE_OR_EMAIL_HAS_REGISTER(400025,"手机或邮箱已被使用"), 44 PHONE_OR_EMAIL_HAS_REGISTER(400025,"手机或邮箱已被使用"),
45 CONTACT_ALREADY_ASSOCIATED(400026,"当前联系人已被设备配置关联"), 45 CONTACT_ALREADY_ASSOCIATED(400026,"当前联系人已被设备配置关联"),
  46 + MSG_CODE_NOT_MATCHED(400027,"验证码不正确"),
46 HAVE_NO_PERMISSION(500002,"没有修改权限"); 47 HAVE_NO_PERMISSION(500002,"没有修改权限");
47 private final int code; 48 private final int code;
48 private String message; 49 private String message;
@@ -14,6 +14,7 @@ import javax.validation.Valid; @@ -14,6 +14,7 @@ import javax.validation.Valid;
14 import javax.validation.constraints.NotEmpty; 14 import javax.validation.constraints.NotEmpty;
15 import java.time.Instant; 15 import java.time.Instant;
16 import java.time.LocalDateTime; 16 import java.time.LocalDateTime;
  17 +import java.time.ZoneId;
17 import java.time.ZoneOffset; 18 import java.time.ZoneOffset;
18 import java.util.Optional; 19 import java.util.Optional;
19 import java.util.UUID; 20 import java.util.UUID;
@@ -64,7 +65,7 @@ public class DeviceProfileDTO extends TenantDTO { @@ -64,7 +65,7 @@ public class DeviceProfileDTO extends TenantDTO {
64 65
65 public DeviceProfileDTO(UUID id, String name, Long time, String description, DeviceTransportType transportType, UUID defaultRuleChainId,boolean isDefault,String image,DeviceProfileType type,Object profileData) { 66 public DeviceProfileDTO(UUID id, String name, Long time, String description, DeviceTransportType transportType, UUID defaultRuleChainId,boolean isDefault,String image,DeviceProfileType type,Object profileData) {
66 setId(id.toString()); 67 setId(id.toString());
67 - setCreateTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneOffset.UTC)); 68 + setCreateTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneOffset.of("+8")));
68 this.name = name; 69 this.name = name;
69 this.isDefault = isDefault; 70 this.isDefault = isDefault;
70 this.image = image; 71 this.image = image;
@@ -78,7 +79,7 @@ public class DeviceProfileDTO extends TenantDTO { @@ -78,7 +79,7 @@ public class DeviceProfileDTO extends TenantDTO {
78 79
79 public DeviceProfileDTO(UUID id, String name, Long time, String description, DeviceTransportType transportType, String defaultRuleChainId,boolean isDefault,String image,DeviceProfileType type, String convertJs) { 80 public DeviceProfileDTO(UUID id, String name, Long time, String description, DeviceTransportType transportType, String defaultRuleChainId,boolean isDefault,String image,DeviceProfileType type, String convertJs) {
80 setId(id.toString()); 81 setId(id.toString());
81 - setCreateTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneOffset.UTC)); 82 + setCreateTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneOffset.of("+8")));
82 this.name = name; 83 this.name = name;
83 this.isDefault = isDefault; 84 this.isDefault = isDefault;
84 this.image = image; 85 this.image = image;
@@ -59,6 +59,7 @@ public class SceneLinkageServiceImpl extends AbstractBaseService<SceneLinkageMap @@ -59,6 +59,7 @@ public class SceneLinkageServiceImpl extends AbstractBaseService<SceneLinkageMap
59 sceneLinkageDTO.setTenantId(tenantId); 59 sceneLinkageDTO.setTenantId(tenantId);
60 // 第一步保存场景,获取场景ID 60 // 第一步保存场景,获取场景ID
61 // 场景对象 61 // 场景对象
  62 + sceneLinkageDTO.setStatus(0);
62 SceneLinkage sceneLinkage = sceneLinkageDTO.getEntity(SceneLinkage.class); 63 SceneLinkage sceneLinkage = sceneLinkageDTO.getEntity(SceneLinkage.class);
63 // 新增 64 // 新增
64 int insert = sceneLinkageMapper.insert(sceneLinkage); 65 int insert = sceneLinkageMapper.insert(sceneLinkage);
@@ -143,6 +143,7 @@ public class YtNoticeServiceImpl implements YtNoticeService { @@ -143,6 +143,7 @@ public class YtNoticeServiceImpl implements YtNoticeService {
143 private void sms4Alarm(AlarmInfoDTO alarmInfo,String templateId, Organization organization,List<AlarmContact> contacts){ 143 private void sms4Alarm(AlarmInfoDTO alarmInfo,String templateId, Organization organization,List<AlarmContact> contacts){
144 SmsReqDTO info = new SmsReqDTO(); 144 SmsReqDTO info = new SmsReqDTO();
145 info.setId(templateId); 145 info.setId(templateId);
  146 + info.setTemplatePurpose(MsgTemplatePurposeEnum.FOR_ALARM_NOTICE.name());
146 LinkedHashMap<String, String> params = new LinkedHashMap<>(); 147 LinkedHashMap<String, String> params = new LinkedHashMap<>();
147 //name-其他;device_name-其他;level-其他;location-其他;alarm_value-其他; 148 //name-其他;device_name-其他;level-其他;location-其他;alarm_value-其他;
148 params.put("type", alarmInfo.getType()); 149 params.put("type", alarmInfo.getType());
@@ -186,6 +187,7 @@ public class YtNoticeServiceImpl implements YtNoticeService { @@ -186,6 +187,7 @@ public class YtNoticeServiceImpl implements YtNoticeService {
186 info.setBody(body); 187 info.setBody(body);
187 info.setEmailFormatEnum(EmailFormatEnum.TEXT.name()); 188 info.setEmailFormatEnum(EmailFormatEnum.TEXT.name());
188 info.setId(templateId); 189 info.setId(templateId);
  190 + info.setTemplatePurpose(MsgTemplatePurposeEnum.FOR_ALARM_NOTICE.name());
189 191
190 mailService.sendEmail(info); 192 mailService.sendEmail(info);
191 } 193 }
@@ -461,13 +461,10 @@ public class YtUserServiceImpl extends AbstractBaseService<UserMapper, User> @@ -461,13 +461,10 @@ public class YtUserServiceImpl extends AbstractBaseService<UserMapper, User>
461 }) 461 })
462 .orElse(false); 462 .orElse(false);
463 if (!correct) { 463 if (!correct) {
464 - throw new BadCredentialsException("验证码不正确"); 464 + throw new YtDataValidationException(ErrorMessage.MSG_CODE_NOT_MATCHED.getMessage());
465 } 465 }
466 String pwd = forget.getPassword(); 466 String pwd = forget.getPassword();
467 - if (StringUtils.isEmpty(pwd)  
468 -// || StringUtils.isEmpty(forget.getResetPassword())  
469 -// || !pwd.equals(forget.getResetPassword())  
470 - ) { 467 + if (StringUtils.isEmpty(pwd)) {
471 throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); 468 throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
472 } 469 }
473 470