/*
*  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.dm.foodCate.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.Data;
import me.zhengjie.base.BaseEntity;
import me.zhengjie.domain.LocalStorage;
import me.zhengjie.modules.system.domain.Menu;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Objects;

/**
* @website https://el-admin.vip
* @description /
* @author sunmz
* @date 2021-09-15
**/
@Entity
@Data
@Table(name="dm_food_cate")
public class DmFoodCate extends BaseEntity implements Serializable {

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


    @Column(name = "cate_id")
    @ApiModelProperty(value = "分类id")
    private Integer cateId;

    @Column(name = "pid")
    @ApiModelProperty(value = "上级菜单ID")
    private Integer pid;

    @Column(name = "cate_name")
    @ApiModelProperty(value = "分类菜品名称")
    private String cateName;

    @Column(name = "picture")
    @ApiModelProperty(value = "分类菜品图片")
    private String picture;

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

    @OneToOne
    @JoinColumn(name = "url",referencedColumnName = "storage_id")
    @ApiModelProperty(value = "url路径")
    private LocalStorage url;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        DmFoodCate dmFoodCate = (DmFoodCate) o;
        return Objects.equals(id, dmFoodCate.id);
    }

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