package com.seer.teach.user.admin.convert;

import com.seer.teach.common.auth.dto.PermissionDTO;
import com.seer.teach.user.admin.request.AddAuthority;
import com.seer.teach.user.admin.request.AuthorityBatchUpdate;
import com.seer.teach.user.admin.request.UpdateAuthority;
import com.seer.teach.user.admin.response.AuthorityRespData;
import com.seer.teach.user.entity.AuthorityEntity;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface AdminAuthorityConvert {

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

    @Mapping(source = "module", target = "module")
    AuthorityEntity toEntity(AddAuthority params);

    AuthorityEntity toEntity(UpdateAuthority params);

    AuthorityEntity permissionDTO2Entity(PermissionDTO permissionDTO);

    List<AuthorityEntity> permissionDTOtoEntityList(List<PermissionDTO.ApiItem> apiItems);

    AuthorityRespData toAuthorityRespData(AuthorityEntity authorityEntity);

    List<AuthorityRespData> toAuthorityRespData(List<AuthorityEntity> authorityEntities);

    @Mapping(source = "id", target = "id")
    AuthorityEntity toEntity(AuthorityBatchUpdate batchUpdateParams, Integer id);
}
