package com.seer.teach.teacher.convert;


import com.seer.teach.common.dto.mq.WordItem;
import com.seer.teach.teacher.common.resp.*;
import com.seer.teach.teacher.module.entity.*;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @Author: Captain
 * @Description:
 * @Date: 2025-06-24 17:28
 */
@Mapper
public interface BookConvert {

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

    BookListTvResp toBookTvResp(BooksEntity param);

    List<BookListTvResp> toBookListTvResp(List<BooksEntity> records);

    @Mapping(target = "id",source = "id")
    @Mapping(target = "title",source = "title")
    @Mapping(target = "author",source = "author")
    @Mapping(target = "introduction",source = "introduction")
    @Mapping(target = "isFree",source = "isFree")
    BookTvDetail toBookTvDetail(BooksEntity book);

    @Mapping(target = "id",source = "id")
    @Mapping(target = "title",source = "title")
    BookChapterListTvResp toBookChapterTvResp(BookChaptersEntity params);

    @Mapping(target = "userId",source = "userId")
    @Mapping(target = "bookId",source = "bookId")
    @Mapping(target = "chapterId",source = "chapterId")
    @Mapping(target = "lastReadTime",source = "lastReadTime")
    @Mapping(target = "model",source = "model")
    @Mapping(target = "aiHumanId",source = "aiHumanId")
    ReadingRecordsEntity toReadingRecordsEntity(Integer userId, Integer bookId,Integer chapterId, LocalDateTime lastReadTime,Integer model,Integer aiHumanId);

    BookChapterAudioResp toBookChapterAudioResp(BookChapterAudiosEntity bookChapterAudiosEntity);

    List<BookChapterAudioResp> toBookChapterAudioList(List<BookChapterAudiosEntity> list);

    AudioData toSmartAudioData(String audioUrl, List<WordItem> wordItems);

    SmartReadResp toSmartReadResp(Integer id, String title, Integer model, List<AudioData> audioData,Integer type);

    @Mapping(target = "hasChapter", constant = "true")
    AppBookInfoResp toBookInfo(BooksEntity booksEntity);

    List<AppBookInfoResp> toBookInfoList(List<BooksEntity> booksEntity);

    ChapterInfoResp toChapterInfo(BookChaptersEntity bookChaptersEntity);

    List<ChapterInfoResp> toChapterInfoList( List<BookChaptersEntity> bookChaptersEntity);

    @Mapping(target = "title", source = "book.title")
    @Mapping(target = "coverImageUrl", source = "book.coverImageUrl")
    @Mapping(target = "author", source = "book.author")
    @Mapping(target = "introduction", source = "book.introduction")
    @Mapping(target = "chapters", source = "result")
    AppChapterInfoResp toAppChapterInfoResp(BooksEntity book, List<ChapterInfoResp> result);
}
