package cn.com.tenlion.systembase.pojo.dtos.bigdta;

import com.google.gson.Gson;
import ink.wgink.exceptions.ParamsException;
import org.apache.commons.lang3.StringUtils;

/**
 * {tableNumber: '表单编号', uid:'主键', action'delete或update或save', data: {需要保存或修改的数据}, keyId:'批量删除自定义字段名(可为空)', keyValue:'批量删除自定义字段值(可为空)'}
 * 编号:C0033
 * 表名:comprehensive_person
 * 名称:综治成员信息表
 */
public class ComprehensivePerson {

    // 区域编码
    private String area_code;
    // 网格名称
    private String grid_name;
    // 网格编码
    private String grid_code;
    // 区域全名称(/隔开)
    private String area_name_all;
    // 区域旗县区名称
    private String area_name;
    // 姓名
    private String name;
    // 所在队伍名称
    private String department;
    // 性别
    private String sex;
    // 手机号
    private String phone;

    public String getarea_code() {
        return area_code;
    }
    
    public void setarea_code(String area_code) {
        this.area_code = area_code;
    }
    
    public String getgrid_name() {
        return grid_name;
    }
    
    public void setgrid_name(String grid_name) {
        this.grid_name = grid_name;
    }
    
    public String getgrid_code() {
        return grid_code;
    }
    
    public void setgrid_code(String grid_code) {
        this.grid_code = grid_code;
    }
    
    public String getarea_name_all() {
        return area_name_all;
    }
    
    public void setarea_name_all(String area_name_all) {
        this.area_name_all = area_name_all;
    }
    
    public String getarea_name() {
        return area_name;
    }
    
    public void setarea_name(String area_name) {
        this.area_name = area_name;
    }
    
    public String getname() {
        return name;
    }
    
    public void setname(String name) {
        this.name = name;
    }
    
    public String getdepartment() {
        return department;
    }
    
    public void setdepartment(String department) {
        this.department = department;
    }
    
    public String getsex() {
        return sex;
    }
    
    public void setsex(String sex) {
        this.sex = sex;
    }
    
    public String getphone() {
        return phone;
    }
    
    public void setphone(String phone) {
        this.phone = phone;
    }
    

    // 保存校验并转Json
    public String saveCheckToJson() {
        if(area_code != null && area_code.length() > 20 ) {
            throw new ParamsException("区域编码超出长度");
        }
        if(grid_name != null && grid_name.length() > 100 ) {
            throw new ParamsException("网格名称超出长度");
        }
        if(grid_code != null && grid_code.length() > 100 ) {
            throw new ParamsException("网格编码超出长度");
        }
        if(area_name_all != null && area_name_all.length() > 255 ) {
            throw new ParamsException("区域全名称(/隔开)超出长度");
        }
        if(area_name != null && area_name.length() > 100 ) {
            throw new ParamsException("区域旗县区名称超出长度");
        }
        if(StringUtils.isEmpty(name)) {
            throw new ParamsException("姓名名不能为空");
        }
        if(name != null && name.length() > 100 ) {
            throw new ParamsException("姓名超出长度");
        }
        if(StringUtils.isEmpty(department)) {
            throw new ParamsException("所在队伍名称名不能为空");
        }
        if(department != null && department.length() > 100 ) {
            throw new ParamsException("所在队伍名称超出长度");
        }
        if(StringUtils.isEmpty(sex)) {
            throw new ParamsException("性别名不能为空");
        }
        if(sex != null && sex.length() > 100 ) {
            throw new ParamsException("性别超出长度");
        }
        if(phone != null && phone.length() > 100 ) {
            throw new ParamsException("手机号超出长度");
        }
        return new Gson().toJson(this);
    }

    // 修改转Json
    public String updateToJson() {
        return new Gson().toJson(this);
    }
    
}
