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 | 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 | 41 | public void exudeService() {} |
42 | 42 | |
43 | 43 | /** |
... | ... | @@ -120,20 +120,13 @@ public class SysDictAspect { |
120 | 120 | Object codeText = field.get(object); |
121 | 121 | if (null != codeText) { |
122 | 122 | String textValue = getDictText(dictCode, codeText); |
123 | - JsonNode jsonNode = JacksonUtil.toJsonNode(JacksonUtil.toString(sourceObject)); | |
124 | 123 | if(null == objectNode){ |
124 | + JsonNode jsonNode = JacksonUtil.toJsonNode(JacksonUtil.toString(sourceObject)); | |
125 | 125 | objectNode = (ObjectNode) jsonNode; |
126 | 126 | } |
127 | 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 | 131 | return objectNode; |
139 | 132 | } | ... | ... |
... | ... | @@ -4,6 +4,8 @@ package org.thingsboard.server.common.data.yunteng.dto; |
4 | 4 | import com.fasterxml.jackson.annotation.JsonFormat; |
5 | 5 | import com.fasterxml.jackson.annotation.JsonIgnore; |
6 | 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 | 9 | import io.swagger.annotations.ApiModelProperty; |
8 | 10 | import lombok.Data; |
9 | 11 | import org.springframework.beans.BeanUtils; |
... | ... | @@ -29,6 +31,7 @@ public class BaseDTO { |
29 | 31 | /**创建时间*/ |
30 | 32 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
31 | 33 | @ApiModelProperty(value = "创建时间") |
34 | + @JsonSerialize(using = LocalDateTimeSerializer.class) | |
32 | 35 | private LocalDateTime createTime; |
33 | 36 | /**更新用户*/ |
34 | 37 | @ApiModelProperty(value = "更新用户") |
... | ... | @@ -36,6 +39,7 @@ public class BaseDTO { |
36 | 39 | /**更新时间*/ |
37 | 40 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
38 | 41 | @ApiModelProperty(value = "更新时间") |
42 | + @JsonSerialize(using = LocalDateTimeSerializer.class) | |
39 | 43 | private LocalDateTime updateTime; |
40 | 44 | @JsonIgnore |
41 | 45 | public <E> void copyToEntity(E entity, String... ignoreProperties) { | ... | ... |
... | ... | @@ -2,6 +2,8 @@ package org.thingsboard.server.common.data.yunteng.dto; |
2 | 2 | |
3 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; |
4 | 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 | 7 | import lombok.Data; |
6 | 8 | import org.thingsboard.server.common.data.yunteng.common.aspect.annotation.AutoDict; |
7 | 9 | |
... | ... | @@ -32,6 +34,7 @@ public class MailLogDTO extends BaseDTO{ |
32 | 34 | |
33 | 35 | /** 发送时间 */ |
34 | 36 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
37 | + @JsonSerialize(using = LocalDateTimeSerializer.class) | |
35 | 38 | private LocalDateTime sendTime; |
36 | 39 | |
37 | 40 | /** 租户Code */ | ... | ... |
... | ... | @@ -3,9 +3,10 @@ package org.thingsboard.server.common.data.yunteng.dto; |
3 | 3 | |
4 | 4 | import com.fasterxml.jackson.annotation.JsonFormat; |
5 | 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 | 8 | import lombok.Data; |
7 | 9 | import lombok.EqualsAndHashCode; |
8 | -import org.thingsboard.server.common.data.yunteng.common.AddGroup; | |
9 | 10 | import org.thingsboard.server.common.data.yunteng.common.UpdateGroup; |
10 | 11 | import org.thingsboard.server.common.data.yunteng.enums.TenantStatusEnum; |
11 | 12 | |
... | ... | @@ -32,5 +33,6 @@ public class TenantDTO extends BaseDTO { |
32 | 33 | private TenantStatusEnum tenantStatus; |
33 | 34 | |
34 | 35 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
36 | + @JsonSerialize(using = LocalDateTimeSerializer.class) | |
35 | 37 | private LocalDateTime tenantExpireTime; |
36 | 38 | } | ... | ... |
... | ... | @@ -58,18 +58,17 @@ public class YtMessageTemplateServiceImpl |
58 | 58 | MessageTemplateDTO queryTemplate = new MessageTemplateDTO(); |
59 | 59 | queryTemplate.setTemplatePurpose(templateDTO.getTemplatePurpose()); |
60 | 60 | queryTemplate.setMessageType(templateDTO.getMessageType()); |
61 | - //queryTemplate.setTemplateCode(tenantCode); | |
61 | + queryTemplate.setTenantId(templateDTO.getTenantId()); | |
62 | + queryTemplate.setStatus(FastIotConstants.MagicNumber.ONE); | |
62 | 63 | if(StringUtils.isEmpty(templateDTO.getTemplatePurpose()) || StringUtils.isEmpty(templateDTO.getMessageType())){ |
63 | 64 | throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); |
64 | 65 | } |
65 | 66 | List<MessageTemplateDTO> messageTemplateDTOList = baseMapper.findMessageTemplate(queryTemplate); |
66 | 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 | 70 | MessageTemplate messageTemplate = baseMapper.selectById(templateDTO.getId()); |
70 | - templateDTO.setTenantId(templateDTO.getTenantId()); | |
71 | 71 | templateDTO.copyToEntity(messageTemplate); |
72 | - | |
73 | 72 | baseMapper.updateById(messageTemplate); |
74 | 73 | messageTemplate.copyToDTO(templateDTO); |
75 | 74 | return templateDTO; | ... | ... |
... | ... | @@ -31,7 +31,6 @@ |
31 | 31 | LEFT JOIN sys_dict sd ON sd.ID = sdi.dict_id |
32 | 32 | <where> |
33 | 33 | sdi.status = 1 |
34 | - <if test="tenantId !=null and tenantId!=''">AND sd.tenant_id=#{tenantId}</if> | |
35 | 34 | <if test="dictCode !=null and dictCode!=''">AND sd.dict_code = #{dictCode}</if> |
36 | 35 | <if test="itemValue !=null and itemValue!=''">AND sdi.item_value = #{itemValue}</if> |
37 | 36 | </where> | ... | ... |