Commit d700ffe93a2357aaa6f0c1ad2fe1379860d50567
1 parent
c312a77b
fix: 使用了AutoDict注解的字段需要指定JsonSerialize 序列化为LocalDateTimeSerializer
Showing
7 changed files
with
16 additions
and
15 deletions
@@ -37,7 +37,7 @@ public class SysDictAspect { | @@ -37,7 +37,7 @@ public class SysDictAspect { | ||
37 | private static final String DICT_TEXT_SUFFIX = "DictText"; | 37 | private static final String DICT_TEXT_SUFFIX = "DictText"; |
38 | 38 | ||
39 | /** 定义切入点 */ | 39 | /** 定义切入点 */ |
40 | - @Pointcut("execution(* com.codeez..*.*Controller.*(..))") | 40 | + @Pointcut("execution(* org.thingsboard..*.yunteng.*Controller.*(..))") |
41 | public void exudeService() {} | 41 | public void exudeService() {} |
42 | 42 | ||
43 | /** | 43 | /** |
@@ -120,20 +120,13 @@ public class SysDictAspect { | @@ -120,20 +120,13 @@ public class SysDictAspect { | ||
120 | Object codeText = field.get(object); | 120 | Object codeText = field.get(object); |
121 | if (null != codeText) { | 121 | if (null != codeText) { |
122 | String textValue = getDictText(dictCode, codeText); | 122 | String textValue = getDictText(dictCode, codeText); |
123 | - JsonNode jsonNode = JacksonUtil.toJsonNode(JacksonUtil.toString(sourceObject)); | ||
124 | if(null == objectNode){ | 123 | if(null == objectNode){ |
124 | + JsonNode jsonNode = JacksonUtil.toJsonNode(JacksonUtil.toString(sourceObject)); | ||
125 | objectNode = (ObjectNode) jsonNode; | 125 | objectNode = (ObjectNode) jsonNode; |
126 | } | 126 | } |
127 | objectNode.put(field.getName() + DICT_TEXT_SUFFIX, textValue); | 127 | objectNode.put(field.getName() + DICT_TEXT_SUFFIX, textValue); |
128 | } | 128 | } |
129 | } | 129 | } |
130 | - if(field.getType().getName().equals("java.time.LocalDateTime")){ | ||
131 | - Object content = field.get(object); | ||
132 | - if(null != content && null !=objectNode){ | ||
133 | - DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); | ||
134 | - objectNode.put(field.getName(),fmt.format((LocalDateTime)content)); | ||
135 | - } | ||
136 | - } | ||
137 | } | 130 | } |
138 | return objectNode; | 131 | return objectNode; |
139 | } | 132 | } |
@@ -4,6 +4,8 @@ package org.thingsboard.server.common.data.yunteng.dto; | @@ -4,6 +4,8 @@ package org.thingsboard.server.common.data.yunteng.dto; | ||
4 | import com.fasterxml.jackson.annotation.JsonFormat; | 4 | import com.fasterxml.jackson.annotation.JsonFormat; |
5 | import com.fasterxml.jackson.annotation.JsonIgnore; | 5 | import com.fasterxml.jackson.annotation.JsonIgnore; |
6 | import com.fasterxml.jackson.annotation.JsonInclude; | 6 | import com.fasterxml.jackson.annotation.JsonInclude; |
7 | +import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
8 | +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; | ||
7 | import io.swagger.annotations.ApiModelProperty; | 9 | import io.swagger.annotations.ApiModelProperty; |
8 | import lombok.Data; | 10 | import lombok.Data; |
9 | import org.springframework.beans.BeanUtils; | 11 | import org.springframework.beans.BeanUtils; |
@@ -29,6 +31,7 @@ public class BaseDTO { | @@ -29,6 +31,7 @@ public class BaseDTO { | ||
29 | /**创建时间*/ | 31 | /**创建时间*/ |
30 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | 32 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
31 | @ApiModelProperty(value = "创建时间") | 33 | @ApiModelProperty(value = "创建时间") |
34 | + @JsonSerialize(using = LocalDateTimeSerializer.class) | ||
32 | private LocalDateTime createTime; | 35 | private LocalDateTime createTime; |
33 | /**更新用户*/ | 36 | /**更新用户*/ |
34 | @ApiModelProperty(value = "更新用户") | 37 | @ApiModelProperty(value = "更新用户") |
@@ -36,6 +39,7 @@ public class BaseDTO { | @@ -36,6 +39,7 @@ public class BaseDTO { | ||
36 | /**更新时间*/ | 39 | /**更新时间*/ |
37 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | 40 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
38 | @ApiModelProperty(value = "更新时间") | 41 | @ApiModelProperty(value = "更新时间") |
42 | + @JsonSerialize(using = LocalDateTimeSerializer.class) | ||
39 | private LocalDateTime updateTime; | 43 | private LocalDateTime updateTime; |
40 | @JsonIgnore | 44 | @JsonIgnore |
41 | public <E> void copyToEntity(E entity, String... ignoreProperties) { | 45 | public <E> void copyToEntity(E entity, String... ignoreProperties) { |
@@ -2,6 +2,8 @@ package org.thingsboard.server.common.data.yunteng.dto; | @@ -2,6 +2,8 @@ package org.thingsboard.server.common.data.yunteng.dto; | ||
2 | 2 | ||
3 | import com.fasterxml.jackson.annotation.JsonFormat; | 3 | import com.fasterxml.jackson.annotation.JsonFormat; |
4 | import com.fasterxml.jackson.databind.JsonNode; | 4 | import com.fasterxml.jackson.databind.JsonNode; |
5 | +import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
6 | +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; | ||
5 | import lombok.Data; | 7 | import lombok.Data; |
6 | import org.thingsboard.server.common.data.yunteng.common.aspect.annotation.AutoDict; | 8 | import org.thingsboard.server.common.data.yunteng.common.aspect.annotation.AutoDict; |
7 | 9 | ||
@@ -32,6 +34,7 @@ public class MailLogDTO extends BaseDTO{ | @@ -32,6 +34,7 @@ public class MailLogDTO extends BaseDTO{ | ||
32 | 34 | ||
33 | /** 发送时间 */ | 35 | /** 发送时间 */ |
34 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | 36 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
37 | + @JsonSerialize(using = LocalDateTimeSerializer.class) | ||
35 | private LocalDateTime sendTime; | 38 | private LocalDateTime sendTime; |
36 | 39 | ||
37 | /** 租户Code */ | 40 | /** 租户Code */ |
@@ -23,6 +23,7 @@ public class MessageTemplateDTO extends TenantDTO { | @@ -23,6 +23,7 @@ public class MessageTemplateDTO extends TenantDTO { | ||
23 | private MessageConfigDTO messageConfig; | 23 | private MessageConfigDTO messageConfig; |
24 | 24 | ||
25 | /**消息类型*/ | 25 | /**消息类型*/ |
26 | + @AutoDict(dictCode = "message_type") | ||
26 | private String messageType; | 27 | private String messageType; |
27 | 28 | ||
28 | /** 模板用途 */ | 29 | /** 模板用途 */ |
@@ -3,9 +3,10 @@ package org.thingsboard.server.common.data.yunteng.dto; | @@ -3,9 +3,10 @@ package org.thingsboard.server.common.data.yunteng.dto; | ||
3 | 3 | ||
4 | import com.fasterxml.jackson.annotation.JsonFormat; | 4 | import com.fasterxml.jackson.annotation.JsonFormat; |
5 | import com.fasterxml.jackson.annotation.JsonInclude; | 5 | import com.fasterxml.jackson.annotation.JsonInclude; |
6 | +import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
7 | +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; | ||
6 | import lombok.Data; | 8 | import lombok.Data; |
7 | import lombok.EqualsAndHashCode; | 9 | import lombok.EqualsAndHashCode; |
8 | -import org.thingsboard.server.common.data.yunteng.common.AddGroup; | ||
9 | import org.thingsboard.server.common.data.yunteng.common.UpdateGroup; | 10 | import org.thingsboard.server.common.data.yunteng.common.UpdateGroup; |
10 | import org.thingsboard.server.common.data.yunteng.enums.TenantStatusEnum; | 11 | import org.thingsboard.server.common.data.yunteng.enums.TenantStatusEnum; |
11 | 12 | ||
@@ -32,5 +33,6 @@ public class TenantDTO extends BaseDTO { | @@ -32,5 +33,6 @@ public class TenantDTO extends BaseDTO { | ||
32 | private TenantStatusEnum tenantStatus; | 33 | private TenantStatusEnum tenantStatus; |
33 | 34 | ||
34 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | 35 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
36 | + @JsonSerialize(using = LocalDateTimeSerializer.class) | ||
35 | private LocalDateTime tenantExpireTime; | 37 | private LocalDateTime tenantExpireTime; |
36 | } | 38 | } |
@@ -58,18 +58,17 @@ public class YtMessageTemplateServiceImpl | @@ -58,18 +58,17 @@ public class YtMessageTemplateServiceImpl | ||
58 | MessageTemplateDTO queryTemplate = new MessageTemplateDTO(); | 58 | MessageTemplateDTO queryTemplate = new MessageTemplateDTO(); |
59 | queryTemplate.setTemplatePurpose(templateDTO.getTemplatePurpose()); | 59 | queryTemplate.setTemplatePurpose(templateDTO.getTemplatePurpose()); |
60 | queryTemplate.setMessageType(templateDTO.getMessageType()); | 60 | queryTemplate.setMessageType(templateDTO.getMessageType()); |
61 | - //queryTemplate.setTemplateCode(tenantCode); | 61 | + queryTemplate.setTenantId(templateDTO.getTenantId()); |
62 | + queryTemplate.setStatus(FastIotConstants.MagicNumber.ONE); | ||
62 | if(StringUtils.isEmpty(templateDTO.getTemplatePurpose()) || StringUtils.isEmpty(templateDTO.getMessageType())){ | 63 | if(StringUtils.isEmpty(templateDTO.getTemplatePurpose()) || StringUtils.isEmpty(templateDTO.getMessageType())){ |
63 | throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); | 64 | throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); |
64 | } | 65 | } |
65 | List<MessageTemplateDTO> messageTemplateDTOList = baseMapper.findMessageTemplate(queryTemplate); | 66 | List<MessageTemplateDTO> messageTemplateDTOList = baseMapper.findMessageTemplate(queryTemplate); |
66 | if(null!=messageTemplateDTOList && messageTemplateDTOList.size()>0){ | 67 | if(null!=messageTemplateDTOList && messageTemplateDTOList.size()>0){ |
67 | - throw new YtDataValidationException(ErrorMessage.NOT_SET_PASSWORD_TEMPLATE.getMessage()); | 68 | + throw new YtDataValidationException(ErrorMessage.EXIST_ENABLE_TEMPLATE.getMessage()); |
68 | } | 69 | } |
69 | MessageTemplate messageTemplate = baseMapper.selectById(templateDTO.getId()); | 70 | MessageTemplate messageTemplate = baseMapper.selectById(templateDTO.getId()); |
70 | - templateDTO.setTenantId(templateDTO.getTenantId()); | ||
71 | templateDTO.copyToEntity(messageTemplate); | 71 | templateDTO.copyToEntity(messageTemplate); |
72 | - | ||
73 | baseMapper.updateById(messageTemplate); | 72 | baseMapper.updateById(messageTemplate); |
74 | messageTemplate.copyToDTO(templateDTO); | 73 | messageTemplate.copyToDTO(templateDTO); |
75 | return templateDTO; | 74 | return templateDTO; |
@@ -31,7 +31,6 @@ | @@ -31,7 +31,6 @@ | ||
31 | LEFT JOIN sys_dict sd ON sd.ID = sdi.dict_id | 31 | LEFT JOIN sys_dict sd ON sd.ID = sdi.dict_id |
32 | <where> | 32 | <where> |
33 | sdi.status = 1 | 33 | sdi.status = 1 |
34 | - <if test="tenantId !=null and tenantId!=''">AND sd.tenant_id=#{tenantId}</if> | ||
35 | <if test="dictCode !=null and dictCode!=''">AND sd.dict_code = #{dictCode}</if> | 34 | <if test="dictCode !=null and dictCode!=''">AND sd.dict_code = #{dictCode}</if> |
36 | <if test="itemValue !=null and itemValue!=''">AND sdi.item_value = #{itemValue}</if> | 35 | <if test="itemValue !=null and itemValue!=''">AND sdi.item_value = #{itemValue}</if> |
37 | </where> | 36 | </where> |