场景:
前端需要字段 case_createTime
后端返回的字段为:createTime
需要后端给这个返回字段case_createTime,也就是说我们需要把 createTime 转成 case_createTime。
只需要在实体里面引入注解即可
@JsonProperty
完整的类名如下:
import com.fasterxml.jackson.annotation.JsonProperty;
package com.zhejiangzhengyuan.municipal_common.entity.vo;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotBlank; import java.sql.Timestamp; import java.util.List; /** * 案件返回VO */ @Data public class CaseVo { @ApiModelProperty(value = "部门名称") private String department; @ApiModelProperty(value = "当前这个案件上报人名称") private String name; @ApiModelProperty(value = "自增主键") @TableId(value = "id",type = IdType.AUTO) private Long id; @ApiModelProperty(value = "案件包裹的事件类型,关联字典条目表。注:一则案件只对应一则事件数据") private String type; @ApiModelProperty(value = "案件接收部门|科室,目前只进行单部门|科室的接收,但是存储时考虑多个部门接收情况") private String receiveDepartmentId; @ApiModelProperty(value = "案件的状态,关联字典条目表") private String status; @ApiModelProperty(value = "案件的的处理意见") private String advice; @ApiModelProperty(value = "案件的的等级") private String grade; @ApiModelProperty(value = "案件的的描述") @NotBlank private String caseDescribe; @ApiModelProperty(value = "记录创建时间") @JsonProperty(value = "case_createTime") private Timestamp createTime; @ApiModelProperty(value = "记录更新时间") @JsonProperty(value = "case_updateTime") private Timestamp updateTime; @ApiModelProperty(value = "案件发生位置") private String location; @ApiModelProperty(value = "新建案件的类型,道路或者桥梁") private String caseType; @ApiModelProperty(value = "截止日期") private Timestamp deadLine; @ApiModelProperty(value = "是否启动定时提醒业务:{true:表示启动,false:表示不启动}") private Boolean startReminder; @ApiModelProperty(value = "是否完成了待处理状态下的消息提醒:{true:已完成,false:未完成}") private Boolean pendingReminder; @ApiModelProperty(value = "是否完成待确认状态下的消息提醒:{true:已完成, false:未完成}") private Boolean confirmReminder; /** * 2020.06.01 新增 */ @ApiModelProperty(value = "案件上报人id") private Long reportUserId; @ApiModelProperty(value = "案件派发的上层id") private Long caseReassignParent; @ApiModelProperty(value = "文件地址") private List<String> link; }
完美解决: