package cn.estsh.i3plus.pojo.form.bean;

import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.util.List;

/**
 * @Description : 表单菜单目录
 * @Reference :
 * @Author : yunhao
 * @CreateDate : 2019-03-21 15:33
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="BF_MENU",indexes = {
        @Index(name="index_bf_menu_parent_id",columnList = "PARENT_ID"),
})
@Api(value="表单菜单目录",description = "表单菜单目录")
public class BfMenu extends BaseBean {

    private static final long serialVersionUID = 6559248298739431579L;
    @Column(name="MENU_NAME")
    @ApiParam(value ="菜单名称")
    private String menuName;

    @Column(name="MENU_CODE")
    @ApiParam(value ="功能代码(唯一校验，路径跳转使用)")
    private String menuCode;

    @Column(name="PARENT_ID")
    @ApiParam(value ="父级菜单id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long parentId;

    public long getParentIdVal(){
        if(parentId == null){
            return CommonEnumUtil.PARENT.DEFAULT.getValue().longValue();
        } else {
          return parentId.longValue();
        }
    }

    @Column(name="PARENT_NAME_RDD")
    @ApiParam(value ="父级菜单名称")
    private String parentNameRdd;

    @Column(name="MENU_SORT")
    @ApiParam(value ="菜单排序")
    private Integer menuSort;

    @Column(name="MENU_ICON")
    @ApiParam(value ="菜单图标")
    private String menuIcon;

    @Lob
    @Column(name="MENU_STYLE")
    @ApiParam(value ="菜单样式")
    private String menuStyle;

    //
    @Column(name="MENU_TYPE")
    @ApiParam(value ="菜单类型")
    private Integer menuType;

    @Column(name="MENU_URL")
    @ApiParam(value ="菜单url")
    private String menuUrl;

    @Column(name="METHOD_ID")
    @ApiParam(value ="功能id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long methodId;

    @Column(name="METHOD_NAME_RDD")
    @ApiParam(value ="功能名称")
    private String methodNameRdd;

    @Column(name="SOFT_TYPE")
    @ApiParam(value ="所属模块")
    private Integer softType;

    @Column(name = "MENU_STATUS")
    @ApiParam(value = "菜单状态")
    private Integer menuStatus;

    @Transient
    @ApiParam(value = "菜单子集")
    private List<BfMenu> bfMenuList;
}
