package {{packageName}}.core.{{entity.module}}.domain;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.math.BigInteger;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.springframework.util.ObjectUtils;
import org.springframework.util.DigestUtils;
import cn.ibizlab.util.domain.EntityBase;
import cn.ibizlab.util.annotation.DEField;
import cn.ibizlab.util.enums.DEPredefinedFieldType;
import cn.ibizlab.util.enums.DEFieldDefaultValueType;
import cn.ibizlab.util.helper.DataObject;
import cn.ibizlab.util.annotation.Audit;
import cn.ibizlab.util.enums.DupCheck;
import cn.ibizlab.util.domain.EntityClient;
import java.io.Serializable;
import lombok.*;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Transient;
import org.springframework.data.annotation.Id;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
{{#entity.relEntities}}
import {{packageName}}.core.{{module}}.domain.{{codeName}};
{{/entity.relEntities}}

@Getter
@Setter
@NoArgsConstructor
@JsonIgnoreProperties(value = "handler")
@ApiModel(value = "{{entity.name}}", description = "{{entity.logicName}}")
public class {{entity.codeName}} extends EntityBase implements Serializable
{

    {{#each entity.fields}}
        {{#unless deepStructure}}
    /**
     * {{logicName}}
     */
        {{#if keyDEField}}
    @Id
        {{/if}}
            {{#enableAudit}}
    @Audit
            {{/enableAudit}}
    @DEField({{annotation}})
    @JsonProperty("{{jsonName}}")
            {{#timeType}}
    @JsonFormat(pattern = "{{format}}", locale = "zh", timezone = "GMT+8")
            {{/timeType}}
    @JSONField(name = "{{jsonName}}"{{#timeType}} , format = "{{format}}"{{/timeType}})
            {{#eq type.java "Long"}}
    @JsonSerialize(using = ToStringSerializer.class)
            {{/eq}}
    @ApiModelProperty(value = "{{columnName}}", notes = "{{logicName}}")
    private {{type.java}} {{camelCase codeName}};

        {{/unless}}
    {{/each}}

    {{#each entity.references}}
    /**
     * {{entityLogicName}}
     */
    @JSONField(name = "{{lowerCase codeName}}")
    @JsonProperty("{{lowerCase codeName}}")
    @ApiModelProperty(value = "{{lowerCase codeName}}", notes = "{{logicName}}")
    private {{entityCodeName}} {{camelCase codeName}};
    {{/each}}

    {{#each entity.nesteds}}
    /**
     * {{entityLogicName}}
     */
        {{#if listCode}}
    @JSONField(name = "{{listCode}}")
    @JsonProperty("{{listCode}}")
    @ApiModelProperty(value = "{{lowerCase listCode}}", notes = "{{logicName}}")
    {{else}}
    @JsonIgnore
    @JSONField(serialize = false)
    @ApiModelProperty(value = "{{lowerCase codeName}}", notes = "{{logicName}}")
    {{/if}}
    private List<{{entityCodeName}}> {{camelCase codeName}};
    {{/each}}

    {{#each entity.fields}}
        {{#unless deepStructure}}
            {{#unless keyDEField}}
                {{#unless predefinedType}}
    /**
     * 设置 [{{logicName}}]
     */
    public void set{{pascalCase codeName}}({{type.java}} {{camelCase codeName}}) {
        this.{{camelCase codeName}} = {{camelCase codeName}};
        this.modify("{{jsonName}}", {{camelCase codeName}});
    }
                {{/unless}}
            {{/unless}}

        {{/unless}}
    {{/each}}

    {{#entity.nesteds}}
        {{#if listCode}}
    /**
     * 设置 [{{entityLogicName}}]
     */
    public void set{{pascalCase codeName}}(List<{{entityCodeName}}> {{camelCase codeName}}) {
        this.{{camelCase codeName}} = {{camelCase codeName}};
        this.modify("{{listCode}}", ({{camelCase codeName}}!=null)?{{camelCase codeName}}:(new ArrayList()));
    }
        {{/if}}

    {{/entity.nesteds}}
}