package com.xunhong.erp.turbo.api.infra.dto.common;

import com.alibaba.cola.dto.DTO;
import com.alibaba.fastjson2.JSONObject;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.xunhong.erp.turbo.api.infra.dto.enums.SettingKeyEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

@Data
@JsonTypeName("CUSTOM_MENU_CONFIG")
@Schema(title = "自定义菜单配置")
@EqualsAndHashCode(callSuper = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public class CustomMenuConfigValue extends DTO implements SettingValue {

	/**
	 * 自定义菜单是微信小程序底部菜单的配置，配置项为菜单名称、图标、跳转链接，菜单数量不能超过5个。
	 */
	@Schema(title = "菜单列表", requiredMode = Schema.RequiredMode.REQUIRED)
	private List<MenuItem> menuItems;

	@Override
	public SettingKeyEnum getSettingKey() {
		return SettingKeyEnum.CUSTOM_MENU_CONFIG;
	}

	@EqualsAndHashCode(callSuper = true)
	@Data
	@Schema(title = "菜单项")
	@JsonIgnoreProperties(ignoreUnknown = true)
	public static class MenuItem extends DTO {

		@Schema(title = "菜单Id", requiredMode = Schema.RequiredMode.REQUIRED)
		private String menuId;

		@Schema(title = "菜单名称", requiredMode = Schema.RequiredMode.REQUIRED)
		private String menuName;

		@Schema(title = "菜单图标", requiredMode = Schema.RequiredMode.REQUIRED)
		private String menuIcon;

		@Schema(title = "菜单路径", requiredMode = Schema.RequiredMode.REQUIRED)
		private JSONObject menuRedirect;

		@Schema(title = "菜单排序", requiredMode = Schema.RequiredMode.REQUIRED)
		private Integer menuSort;
	}
}
