/*
*  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 com.youchain.basicdata.domain;

import com.youchain.base.BaseEntity;
import com.youchain.modules.system.domain.Dept;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.io.Serializable;

/**
* @website https://eladmin.vip
* @description /
* @author liuxue
* @date 2023-07-28
**/
@Entity
@Data
@Table(name="base_stock_type")
public class StockType extends BaseEntity implements Serializable {

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

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

    @Column(name = "`code`")
    @ApiModelProperty(value = "代码")
    private String code;

    @Column(name = "`enabled`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "状态：1启用、0禁用")
    private Boolean enabled=true;

    @Column(name = "`length`")
    @ApiModelProperty(value = "长")
    private Double length=0d;

    @Column(name = "`width`")
    @ApiModelProperty(value = "宽")
    private Double width=0d;

    @Column(name = "`height`")
    @ApiModelProperty(value = "高")
    private Double height=0d;

    @Column(name = "`weight`")
    @ApiModelProperty(value = "重量")
    private Double weight=0d;

    @Column(name = "`size`")
    @ApiModelProperty(value = "体积")
    private Double size=0d;

    @OneToOne
    @JoinColumn(name = "dept_id")
    @ApiModelProperty(value = "仓库")
    private Dept dept;

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