package com.seer.teach.admin.convert;

import com.seer.teach.admin.request.ExampleQuestionsReq;
import com.seer.teach.admin.response.ExampleQuestionsResp;
import com.seer.teach.teacher.module.entity.ExampleQuestionsEntity;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * <p>
 * 例题转换器
 * </p>
 *
 * @author ZS
 * @since 2025-10-24
 */
@Mapper
public interface ExampleQuestionsConvert {

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

    /**
     * 将请求参数转换为实体对象
     *
     * @param req 例题请求参数
     * @return 例题实体对象
     */
    @Mapping(target = "id", ignore = true)
    @Mapping(target = "createTime", ignore = true)
    @Mapping(target = "updateTime", ignore = true)
    @Mapping(target = "deleted", ignore = true)
    @Mapping(target = "isChecked", ignore = true)
    @Mapping(target = "score", ignore = true)
    ExampleQuestionsEntity toEntity(ExampleQuestionsReq req);

    /**
     * 将实体对象转换为响应参数
     *
     * @param entity 例题实体对象
     * @return 例题响应参数
     */
    ExampleQuestionsResp toResp(ExampleQuestionsEntity entity);

    /**
     * 将实体对象列表转换为响应参数列表
     *
     * @param entities 例题实体对象列表
     * @return 例题响应参数列表
     */
    List<ExampleQuestionsResp> toRespList(List<ExampleQuestionsEntity> entities);

    /**
     * 更新实体对象属性
     *
     * @param req    例题请求参数
     * @param entity 例题实体对象
     */
    void updateEntityFromReq(ExampleQuestionsReq req, @MappingTarget ExampleQuestionsEntity entity);
}