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:'批量删除自定义字段值(可为空)'}
 * 编号:C0019
 * 表名:key_area_check_renovation_patrol
 * 名称:重点区域巡查记录
 */
public class KeyAreaCheckRenovationPatrol {

    // 重点区域名称
    private String key_area_name;
    // 区域全名称(/隔开)
    private String location_all;
    // 区域编码
    private String location_code;
    // 区域旗县区名称
    private String location_area;
    // 巡查时间
    private String patrol_time;
    // 巡查人
    private String creator_name;

    public String getkey_area_name() {
        return key_area_name;
    }
    
    public void setkey_area_name(String key_area_name) {
        this.key_area_name = key_area_name;
    }
    
    public String getlocation_all() {
        return location_all;
    }
    
    public void setlocation_all(String location_all) {
        this.location_all = location_all;
    }
    
    public String getlocation_code() {
        return location_code;
    }
    
    public void setlocation_code(String location_code) {
        this.location_code = location_code;
    }
    
    public String getlocation_area() {
        return location_area;
    }
    
    public void setlocation_area(String location_area) {
        this.location_area = location_area;
    }
    
    public String getpatrol_time() {
        return patrol_time;
    }
    
    public void setpatrol_time(String patrol_time) {
        this.patrol_time = patrol_time;
    }
    
    public String getcreator_name() {
        return creator_name;
    }
    
    public void setcreator_name(String creator_name) {
        this.creator_name = creator_name;
    }
    

    // 保存校验并转Json
    public String saveCheckToJson() {
        if(StringUtils.isEmpty(key_area_name)) {
            throw new ParamsException("重点区域名称名不能为空");
        }
        if(key_area_name != null && key_area_name.length() > 255 ) {
            throw new ParamsException("重点区域名称超出长度");
        }
        if(StringUtils.isEmpty(location_all)) {
            throw new ParamsException("区域全名称(/隔开)名不能为空");
        }
        if(location_all != null && location_all.length() > 255 ) {
            throw new ParamsException("区域全名称(/隔开)超出长度");
        }
        if(StringUtils.isEmpty(location_code)) {
            throw new ParamsException("区域编码名不能为空");
        }
        if(location_code != null && location_code.length() > 100 ) {
            throw new ParamsException("区域编码超出长度");
        }
        if(StringUtils.isEmpty(location_area)) {
            throw new ParamsException("区域旗县区名称名不能为空");
        }
        if(location_area != null && location_area.length() > 100 ) {
            throw new ParamsException("区域旗县区名称超出长度");
        }
        if(StringUtils.isEmpty(patrol_time)) {
            throw new ParamsException("巡查时间名不能为空");
        }
        if(patrol_time != null && patrol_time.length() > 20 ) {
            throw new ParamsException("巡查时间超出长度");
        }
        if(StringUtils.isEmpty(creator_name)) {
            throw new ParamsException("巡查人名不能为空");
        }
        if(creator_name != null && creator_name.length() > 20 ) {
            throw new ParamsException("巡查人超出长度");
        }
        return new Gson().toJson(this);
    }

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