package com.cool.store.dto.menu;


import com.cool.store.entity.SysMenuDO;
import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.enums.MenuTypeEnum;
import com.cool.store.exception.ServiceException;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;


@Data
public class AddMenuDTO {

    @NotBlank(message = "名称不能为空")
    private String name;

    @JsonProperty("parent_id")
    @NotNull(message = "父Id不能为空")
    private Long parentId;

    @NotBlank(message = "地址不能为空")
    private String path;

    private String component;

    private String target;

    private String icon;

    private String env;

    private String code;

    public static SysMenuDO convertDO(AddMenuDTO param, MenuTypeEnum menuTypeEnum){
        SysMenuDO sysMenuDO = new SysMenuDO();
        sysMenuDO.setParentId(param.getParentId());
        sysMenuDO.setName(param.getName());
        sysMenuDO.setCode(param.getCode());
        sysMenuDO.setPath(param.getPath());
        sysMenuDO.setIcon(param.getIcon());
        sysMenuDO.setMenuType(menuTypeEnum.getCode());
        return sysMenuDO;
    }


}
