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

import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.ToStringSerializer;
import io.swagger.annotations.Api;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import me.zhengjie.base.BaseEntity;
import me.zhengjie.modules.dm.dmtsCollection.domain.DmTsCollection;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.math.BigDecimal;
import java.io.Serializable;
import java.util.List;
import java.util.Set;

/**
* @website https://el-admin.vip
* @description /
* @author longda
* @date 2022-03-01
**/
@Entity
@Data
@Table(name="dm_ts_info")
public class DmTsInfo extends BaseEntity implements Serializable {

    @Id
    @Column(name = "ts_id")
    @ApiModelProperty(value = "图书控制号id(数据标识)")
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Long tsId;

    @ApiModelProperty(value = "图书藏信息")
    @NotFound(action = NotFoundAction.IGNORE)
    @OneToMany(fetch = FetchType.LAZY)
    @JoinColumn(name = "ts_id",referencedColumnName = "ts_id")
    private Set<DmTsCollection> dmTsCollections;

    @Column(name = "ts_type_num")
    @ApiModelProperty(value = "图书位置索引(分类号/书此号）")
    private String tsTypeNum;

    @Column(name = "ts_name")
    @ApiModelProperty(value = "图书名称")
    private String tsName;

    @Column(name = "ts_picture")
    @ApiModelProperty(value = "图书名称")
    private String tsPicture;

    @Column(name = "ts_author")
    @ApiModelProperty(value = "图书作者")
    private String tsAuthor;

    @Column(name = "ts_publish_name")
    @ApiModelProperty(value = "图书出版公司或者出版人名称")
    private String tsPublishName;

    @Column(name = "ts_publish_address")
    @ApiModelProperty(value = "图书出版地址")
    private String tsPublishAddress;

    @Column(name = "ts_publish_time")
    @ApiModelProperty(value = "出版日期")
    private String tsPublishTime;

    @Column(name = "ts__num")
    @ApiModelProperty(value = "图书ISBN编号")
    private String tsNum;

    @Column(name = "ts_total_page")
    @ApiModelProperty(value = "图书页数")
    private String tsTotalPage;

    @Column(name = "ts_price")
    @ApiModelProperty(value = "图书单价")
    private BigDecimal tsPrice;

    @Column(name = "ts_acquire_type")
    @ApiModelProperty(value = "图书获得方式")
    private String tsAcquireType;

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