• 序列化后成对象转map,再添加到dataList


    吐槽一句,这个bos平台真的垃圾;

    package com.gree.osf.port.write.grentry.model.bo;

    import java.io.Serializable;

    import com.alibaba.fastjson.annotation.JSONField;

    import com.alibaba.fastjson.serializer.SerializerFeature;

    public class EmpBO implements Serializable,Cloneable{

    private static final long serialVersionUID = 1L;

    private static final int default_ResultFlag=1;

    private static final int default_ResultFlag_error=0;

    private static final String  default_Message="OK";

    private static final String  default_Message_Error="ERROR";

    @JSONField(name="ResultFlag",serialzeFeatures=SerializerFeature.WriteMapNullValue)

    private int resultFlag;

    @JSONField(name="Message",serialzeFeatures=SerializerFeature.WriteNullStringAsEmpty)

    private String message;

    @JSONField(name="id",serialzeFeatures=SerializerFeature.WriteNullStringAsEmpty)

    private String empPk;

    @JSONField(name="员工姓名",serialzeFeatures=SerializerFeature.WriteNullStringAsEmpty)

    private String empName;

    @JSONField(name="员工编号",serialzeFeatures=SerializerFeature.WriteNullStringAsEmpty)

    private String empNumber;

    public int getResultFlag() {

    if(this.resultFlag==1) return this.default_ResultFlag;

    else return this.default_ResultFlag_error;

    }

    public void setResultFlag(int resultFlag) {

    this.resultFlag = resultFlag;

    }

    public String getMessage() {

    if(this.message.equals("OK")) return this.default_Message;

    return this.default_Message_Error;

    }

    public void setMessage(String message) {

    this.message = message;

    }

    public String getEmpPk() {

    return empPk;

    }

    public void setEmpPk(String empPk) {

    this.empPk = empPk;

    }

    public String getEmpName() {

    return empName;

    }

    public void setEmpName(String empName) {

    this.empName = empName;

    }

    public String getEmpNumber() {

    return empNumber;

    }

    public void setEmpNumber(String empNumber) {

    this.empNumber = empNumber;

    }

    //处理全部或者部分的异常数据返回

    EmpBO empBO=new EmpBO();

    empBO.setEmpName(pInfo.getName().toString());

    empBO.setEmpNumber(pInfo.getNumber().toString());

    empBO.setEmpPk(personPk.toString());

    empBO.setResultFlag(1);

    empBO.setMessage(CNConsts.OK);

    //序列化后成对象转map,再添加到dataList

    System.out.println(">>"+JSON.parseObject(JSON.toJSONString(empBO),new TypeReference<LinkedHashMap<String,Object>>(){},Feature.OrderedField));

    什么垃圾,这个很难编译?

    于是我用这个.

  • 相关阅读:
    Linux学习之查看是否安装软件
    Linux学习之nfs实例
    Linux学习之nfs安装配置
    Linux 学习之防火墙配置
    Linux学习之系统时间同步
    Linux学习之守护进程详解
    Linux学习之Center os网络配置
    Linux学习之挂载操作
    Linux学习之挂载
    Linux学习之开机启动
  • 原文地址:https://www.cnblogs.com/luojiabao/p/11243035.html
Copyright © 2020-2023  润新知