package com.sckw.system.model.vo.res;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * App 菜单/按钮权限项：字段与菜单表对齐，序列化时对空值统一为默认非 null，便于前端直接使用。
 */
@Data
public class AppMenuPermItemResVo implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "菜单主键")
    private Long id;

    @Schema(description = "父级菜单 id，无父级时为 0")
    private Long parentId;

    @Schema(description = "终端类型：1运营端、2企业PC、3企业APP、4司机端")
    private Integer clientType;

    @Schema(description = "权限标识")
    private String perms;

    @Schema(description = "名称")
    private String name;

    @Schema(description = "类型：0目录/1菜单/2按钮")
    private Integer type;

    @Schema(description = "前端路由或页面路径")
    private String url;

    @Schema(description = "按钮对应后端接口地址")
    private String links;

    @Schema(description = "菜单图标")
    private String icon;

    @Schema(description = "排序")
    private Integer sort;

    @Schema(description = "层级")
    private Integer level;

    @Schema(description = "是否定制：0否 1是")
    private Integer custom;

    @Schema(description = "是否默认展示")
    private Integer isDisplay;

    @Schema(description = "菜单开放类型：0普通 1超管 2非普通用户")
    private Integer isMain;

    @Schema(description = "适用企业类型（多值拼接）")
    private String usingRoles;

    @Schema(description = "备注")
    private String remark;

    @Schema(description = "状态：0正常 1锁定")
    private Integer status;

    @Schema(description = "创建人")
    private Long createBy;

    @Schema(description = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @Schema(description = "更新人")
    private Long updateBy;

    @Schema(description = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @Schema(description = "删除标识：0正常")
    private Integer delFlag;

    /**
     * 菜单+按钮查询时为下属按钮列表；仅菜单/仅按钮查询时为无元素的列表，避免 null。
     */
    @Schema(description = "下属按钮权限；非菜单+按钮模式为空列表")
    private List<AppMenuPermItemResVo> buttons = new ArrayList<>();
}
