package me.zhengjie.modules.store.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import me.zhengjie.base.BaseEntity;

@Entity
@Getter
@Setter
@Table(name = "sys_store")
public class Store extends BaseEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`store_id`")
    @ApiModelProperty(value = "ID")
    private Integer id;

    @Column(name = "`code`")
    @ApiModelProperty(value = "门店编码")
    private String code;

    @Column(name = "`name`")
    @ApiModelProperty(value = "门店名称")
    private String name;

    @ApiModelProperty(value = "上级门店")
    private Integer pid;

    @ApiModelProperty(value = "子节点数目", hidden = true)
    private Integer subCount = 0;

    public void copy(Store source) {
        BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
