/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.goods.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 javax.validation.constraints.NotBlank;

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

/**
 * @website https://eladmin.vip
 * @description /
 * @author Bu
 * @date 2023-09-14
 **/
@Entity
@Data
@EqualsAndHashCode(callSuper = false)
@Table(name = "sys_goods")
public class Goods extends BaseEntity {

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

    @Column(name = "`code`", nullable = false)
    @NotBlank
    @ApiModelProperty(value = "货品编码")
    private String code;

    @Column(name = "`name`")
    @ApiModelProperty(value = "货品名称")
    private String name;

    @Column(name = "`common_name`")
    @ApiModelProperty(value = "通用名")
    private String commonName;

    @Column(name = "`barcode`")
    @ApiModelProperty(value = "条形码")
    private String barcode;

    @Column(name = "`ac`")
    @ApiModelProperty(value = "批准文号")
    private String ac;

    @Column(name = "`spec`")
    @ApiModelProperty(value = "商品规格")
    private String spec;

    @Column(name = "`unit`")
    @ApiModelProperty(value = "单位")
    private String unit;

    @Column(name = "`manufacturer`")
    @ApiModelProperty(value = "生产厂家")
    private String manufacturer;

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