package com.red.circle.console.app.convertor;

import com.red.circle.console.app.dto.clienobject.admin.MenuCO;
import com.red.circle.console.app.dto.clienobject.admin.MenuTreeCO;
import com.red.circle.console.app.dto.cmd.admin.MenuCmd;
import com.red.circle.console.infra.database.rds.dto.admin.MenuTreeDTO;
import com.red.circle.console.infra.database.rds.entity.admin.Menu;
import com.red.circle.framework.core.convertor.ConvertorModel;
import java.util.List;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

/**
 * @author pengliang on 2023/5/12
 */
@Mapper(componentModel = ConvertorModel.SPRING)
public interface MenuAppConvertor {

  List<MenuTreeCO> toListMenuTreeCO(List<MenuTreeDTO> menuTrees);

  @Mappings({
      @Mapping(target = "menuType", expression = "java(menu.menuTypeToInt())"),
      @Mapping(target = "status", expression = "java(menu.statusToInt())"),
  })
  MenuCO toMenuCO(Menu menu);

  List<MenuCO> toListMenuCO(List<Menu> menus);

  @Mappings({
      @Mapping(target = "menuType", expression = "java(menu.toMenuType(cmd.getMenuType()))"),
      @Mapping(target = "status", expression = "java(menu.toStatus(cmd.getStatus()))"),
  })
  Menu toMenu(MenuCmd cmd);
}
