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

import cn.estsh.i3plus.pojo.base.annotation.AnnoOutputColumn;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
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.ArrayList;
import java.util.List;

/**
 * @Description : 系统功能
 * @Reference   :
 * @Author      : wei.peng
 * @Date        : 2018-10-22 16:58:43.641
 * @Modify      :
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="SYS_MENU",indexes = {
        @Index(name="index_sys_menu_parent_id",columnList = "PARENT_ID"),
})
@Api(value="系统功能",description = "系统功能")
public class SysMenu extends BaseBean {

    private static final long serialVersionUID = 6892387964234712323L;
    @Column(name="NAME")
    @ApiParam(value ="功能名称")
    private String name;

    @Column(name="NAME_ZH_SHORTENING")
    @ApiParam(value ="功能名称中文简写")
    private String nameZhShortening;

    @Column(name="MENU_CODE")
    @ApiParam(value ="功能代码")
    private String menuCode;

    /**
     * 产品类型暂时不能填写, 产品以上线调整影响范围太大.
     */
    @Column(name="SOFT_TYPE")
    @ApiParam(value ="产品类型", example = "0",access = "softTyp DOC: http://doc.estsh.com/docs/i3plus_api/i3plus_api-impp")
    @AnnoOutputColumn
    private Integer softType;

    @Column(name="MENU_TYPE")
    @ApiParam(value ="功能类型" , example ="-1" ,access = "枚举：1.模块，2.菜单，3.按钮")
    private Integer menuType;

    // 根节点-1
    @Column(name="PARENT_ID")
    @ApiParam(value ="父级功能ID" , example = "-1")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long parentId;

    @Column(name="PARENT_NAME_RDD")
    @ApiParam(value ="父级功能名称" , access ="父级功能名称")
    @AnnoOutputColumn(required = false)
    private String parentNameRdd;

    @Column(name="MENU_CLASS_PATH")
    @ApiParam(value ="资源class path" , access ="资源class path")
    @AnnoOutputColumn(required = false)
    private String menuClassPath;

    @Column(name="MENU_GRADE")
    @ApiParam(value ="资源等级", example = "1")
    @AnnoOutputColumn(required = false)
    private String menuGrade;

    @Column(name="MENU_SORT")
    @ApiParam(value ="资源排序", example = "0")
    @AnnoOutputColumn(required = false)
    private Integer menuSort = 0;

    @Column(name="MENU_URL")
    @ApiParam(value ="资源 url" , access ="资源 url")
    @AnnoOutputColumn(required = false)
    private String menuUrl;

    @Column(name="MENU_CSS")
    @ApiParam(value ="资源css" , access ="资源css")
    @AnnoOutputColumn(required = false)
    private String menuCss;

    @Column(name="MENU_ICON")
    @ApiParam(value ="资源icon" , access ="资源icon")
    @AnnoOutputColumn(required = false)
    private String menuIcon;

    @Column(name="MENU_DESCRIPTION")
    @ApiParam(value ="资源描述" , access ="配置描述")
    @AnnoOutputColumn(required = false)
    private String menuDescription;

    @Column(name="MENU_STATUS")
    @ApiParam(value ="功能状态" , example ="1" , access ="功能状态（1.正常，2.禁用）",defaultValue="1")
    @AnnoOutputColumn(required = false)
    private Integer menuStatus;

    @Transient
    @ApiParam(value ="子集列表")
    private List<SysMenu> childList = new ArrayList<>();

    public SysMenu() {
    }

    public SysMenu(String menuCode) {
        this.menuCode = menuCode;
    }
}
