package com.sa.ibiz.demo.demoapp.controller.demo.vo;

import java.sql.Timestamp;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty.Access;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import lombok.Data;
import org.springframework.util.StringUtils;
import com.sa.ibiz.demo.demo.domain.UserRoleDetail;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.Map;
import java.util.Date;
import org.springframework.cglib.beans.BeanCopier;
import javax.validation.constraints.Size;
import java.util.UUID;
import org.springframework.cglib.beans.BeanCopier;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.sa.ibiz.demo.ibizutil.security.AuthenticationUser;
import java.math.BigInteger;
import com.alibaba.fastjson.JSONObject;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class UserRoleDetail_EditForm_Main{

    @JsonProperty(access=Access.WRITE_ONLY)
    private Map<String,String> srfparentdata;
    @JsonIgnore
    private Timestamp updatedate;
    @JsonProperty(access=Access.WRITE_ONLY)
    private String srforikey;
    @JsonIgnore
    private String userroledetailid;
    @JsonIgnore
    private String userroledetailname;
    @JsonIgnore
    private String srftempmode;
    @JsonProperty
    private String srfuf;
    @JsonProperty
    private String srfdeid;
    @JsonProperty(access=Access.WRITE_ONLY)
    private String srfsourcekey;
    @JsonIgnore
    private String userrolename;
    @JsonIgnore
    private String userobjectname;
    @JsonIgnore
    private String usertag;
    @JsonIgnore
    private String userobjectid;
    @JsonIgnore
    private String userroleid;

    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
    @JsonProperty(value = "srfupdatedate")
    public Timestamp getSrfupdatedate(){
        return updatedate;
    }
    @JsonProperty(value = "srfupdatedate")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
    public void setSrfupdatedate(Timestamp updatedate){
        this.updatedate = updatedate;
    }

    @JsonProperty(value = "srforikey")
    public String getSrforikey(){
        return srforikey;
    }
    @JsonProperty(value = "srforikey")
    public void setSrforikey(String srforikey){
        this.srforikey = srforikey;
    }

    @Size(min = 0, max = 100, message = "[用户角色成员标识]长度必须在[100]以内!")
    @JsonProperty(value = "srfkey")
    public String getSrfkey(){
        return userroledetailid;
    }
    @JsonProperty(value = "srfkey")
    public void setSrfkey(String userroledetailid){
        this.userroledetailid = userroledetailid;
    }

    @Size(min = 0, max = 200, message = "[用户角色成员名称]长度必须在[200]以内!")
    @JsonProperty(value = "srfmajortext")
    public String getSrfmajortext(){
        return userroledetailname;
    }

    @JsonProperty(value = "srftempmode")
    public String getSrftempmode(){
        return srftempmode;
    }
    @JsonProperty(value = "srftempmode")
    public void setSrftempmode(String srftempmode){
        this.srftempmode = srftempmode;
    }

    @JsonProperty(value = "srfdeid")
    public String getSrfdeid(){
        return srfdeid;
    }
    @JsonProperty(value = "srfdeid")
    public void setSrfdeid(String srfdeid){
        this.srfdeid = srfdeid;
    }

    @NotBlank(message = "[用户角色]不允许为空!")
    @Size(min = 0, max = 200, message = "[用户角色]长度必须在[200]以内!")
    @JsonProperty(value = "uesrrolename")
    public String getUesrrolename(){
        return userrolename;
    }
    @JsonProperty(value = "uesrrolename")
    public void setUesrrolename(String userrolename){
        this.userrolename = userrolename;
    }

    @NotBlank(message = "[用户对象]不允许为空!")
    @Size(min = 0, max = 200, message = "[用户对象]长度必须在[200]以内!")
    @JsonProperty(value = "userobjectname")
    public String getUserobjectname(){
        return userobjectname;
    }
    @JsonProperty(value = "userobjectname")
    public void setUserobjectname(String userobjectname){
        this.userobjectname = userobjectname;
    }

    @Size(min = 0, max = 200, message = "[用户自定义]长度必须在[200]以内!")
    @JsonProperty(value = "usertag")
    public String getUsertag(){
        return usertag;
    }
    @JsonProperty(value = "usertag")
    public void setUsertag(String usertag){
        this.usertag = usertag;
    }

    @Size(min = 0, max = 100, message = "[用户对象]长度必须在[100]以内!")
    @JsonProperty(value = "userobjectid")
    public String getUserobjectid(){
        //输出获取外键值方法-用于通过parentdata关系填充外键值id
        if(StringUtils.isEmpty(userobjectid) && this.getSrfparentdata() != null)
        {
            if(this.getSrfparentdata().containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_USERROLEDETAIL_USEROBJECT_USEROBJECTID"))
                this.userobjectid=this.getSrfparentdata().get("srfparentkey");
        }
        return userobjectid;
    }
    @JsonProperty(value = "userobjectid")
    public void setUserobjectid(String userobjectid){
        this.userobjectid = userobjectid;
    }

    @Size(min = 0, max = 100, message = "[用户角色成员标识]长度必须在[100]以内!")
    @JsonProperty(value = "userroledetailid")
    public String getUserroledetailid(){
        return userroledetailid;
    }
    @JsonProperty(value = "userroledetailid")
    public void setUserroledetailid(String userroledetailid){
        this.userroledetailid = userroledetailid;
    }

    @Size(min = 0, max = 100, message = "[用户角色]长度必须在[100]以内!")
    @JsonProperty(value = "userroleid")
    public String getUserroleid(){
        //输出获取外键值方法-用于通过parentdata关系填充外键值id
        if(StringUtils.isEmpty(userroleid) && this.getSrfparentdata() != null)
        {
            if(this.getSrfparentdata().containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_USERROLEDETAIL_USERROLE_USERROLEID"))
                this.userroleid=this.getSrfparentdata().get("srfparentkey");
        }
        return userroleid;
    }
    @JsonProperty(value = "userroleid")
    public void setUserroleid(String userroleid){
        this.userroleid = userroleid;
    }

    public  void fromUserRoleDetail(UserRoleDetail sourceEntity)  {
        this.fromUserRoleDetail(sourceEntity,true);
    }

     /**
	 * do转换为vo
	 * @param sourceEntity do数据对象
	 * @return
	 */
    public  void fromUserRoleDetail(UserRoleDetail sourceEntity,boolean reset)  {
      BeanCopier copier=BeanCopier.create(UserRoleDetail.class, UserRoleDetail_EditForm_Main.class, false);
      copier.copy(sourceEntity,this,  null);
      this.toString();
	}

    /**
	 * vo转换为do
	 * @param
	 * @return
	 */
    public  UserRoleDetail toUserRoleDetail()  {
        UserRoleDetail targetEntity =new UserRoleDetail();
        BeanCopier copier=BeanCopier.create(UserRoleDetail_EditForm_Main.class, UserRoleDetail.class, false);
        copier.copy(this, targetEntity, null);
        return targetEntity;
	}

     /**
	 * 新建
	 * @param
	 * @return
	 */
    private boolean isCreate()
    {
    	if((StringUtils.isEmpty(this.srfuf))||this.srfuf.equals("0"))
	    	return true;
    	else
    	    return false;
    }
     /**
	 * 更新
	 * @param
	 * @return
	 */
    private boolean isUpdate()
    {
    	if((!StringUtils.isEmpty(this.srfuf))&&this.srfuf.equals("1"))
	    	return true;
    	else
    	    return false;
    }

}
