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 cn.ibizlab.util.domain.EntityClient;
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.EntityMP;
import java.io.Serializable;
import lombok.*;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Transient;
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
@Accessors(chain = true)
@JsonIgnoreProperties(value = "handler")
@ApiModel("{{entity.logicName}}")
public class {{entity.codeName}} extends EntityClient implements Serializable
{

{{#each entity.fields}}
    {{#unless deepStructure}}
        /**
        * {{logicName}}
        */
        {{#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("{{logicName}}")
        private {{type.java}} {{camelCase codeName}};

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

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

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

{{#each entity.fields}}
    {{#unless deepStructure}}
        {{#timeType}}
            /**
            * 格式化日期 [{{logicName}}]
            */
            public String format{{pascalCase codeName}}() {
            if (this.{{camelCase codeName}} == null) {
            return null;
            }
            SimpleDateFormat sdf = new SimpleDateFormat("{{format}}");
            return sdf.format({{camelCase codeName}});
            }
        {{/timeType}}

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

}