package com.xunhong.erp.turbo.rbac.infrastructure.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.xunhong.erp.turbo.api.rbac.dto.enums.MenuTypeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @author shenyifei
 */
@Data
@TableName(value = "menu")
@EqualsAndHashCode(callSuper = true)
public class MenuDO extends Model<MenuDO> {

	/**
	 * 菜单id
	 */
	@TableId(value = "menu_id", type = IdType.ASSIGN_ID)
	private Long menuId;
	/**
	 * 平台id
	 */
	@TableField(value = "platform_id")
	private Long platformId;
	/**
	 * 名称
	 */
	@TableField(value = "name")
	private String name;
	/**
	 * 路径
	 */
	@TableField(value = "path")
	private String path;
	/**
	 * 组件
	 */
	@TableField(value = "component")
	private String component;
	/**
	 * 上级菜单id
	 */
	@TableField(value = "pid")
	private Long pid;
	/**
	 * 菜单类型：1：菜单，2：页面，3：按钮
	 */
	@TableField(value = "type")
	private MenuTypeEnum type;
	/**
	 * 菜单排序
	 */
	@TableField(value = "sort")
	private BigDecimal sort;
	/**
	 * display
	 */
	@TableField(value = "hide_in_menu")
	private Boolean hideInMenu;
	/**
	 * 权限id
	 */
	@TableField(value = "permission_id", updateStrategy = FieldStrategy.ALWAYS)
	private Long permissionId;
	/**
	 * 创建时间
	 */
	@TableField(value = "created_at", fill = FieldFill.INSERT, updateStrategy = FieldStrategy.NEVER)
	private LocalDateTime createdAt;
	/**
	 * 更新时间
	 */
	@TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
	private LocalDateTime updatedAt;
	/**
	 * 逻辑删除时间
	 */
	@TableLogic(value = "0", delval = "1")
	@TableField(value = "is_delete", fill = FieldFill.INSERT)
	private Integer isDelete;
	/**
	 * 数据版本号(乐观锁)
	 */
	@Version
	@TableField(value = "version", fill = FieldFill.INSERT)
	private Integer version;

	@TableField(exist = false)
	private PermissionDO permissionDO;
}
