package cn.ey.biz.module.system.convert.permission;

import cn.ey.biz.module.system.api.permission.dto.CodeBlockConfigDataRespDTO;
import cn.ey.biz.module.system.api.permission.dto.CodeBlockDataRespDTO;
import cn.ey.biz.module.system.api.permission.dto.DataRoleDTO;
import cn.ey.biz.module.system.api.permission.dto.DataRoleRespDTO;
import cn.ey.biz.module.system.dal.dataobject.permission.DataRoleDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface DataRoleDTOConvert {

    DataRoleDTOConvert INSTANCE = Mappers.getMapper(DataRoleDTOConvert.class);

    @Mappings({
            @Mapping(expression = "java(DataRoleConverter.stringToAreaObject(dto.getArea()))", target = "area"),
            @Mapping(expression = "java(DataRoleConverter.stringToServiceLineObject(dto.getServiceLine()))", target = "serviceLine"),
    })
    CodeBlockConfigDataRespDTO configConvert(CodeBlockDataRespDTO dto);

    DataRoleDTO convert(DataRoleDO dataRoleDO);

    List<DataRoleRespDTO> convertDtoList(List<DataRoleDO> dataRoleDO);
}
