package com.seer.teach.admin.convert;

import com.seer.teach.admin.request.QuestionOptionsReq;
import com.seer.teach.admin.response.QuestionOptionsResp;
import com.seer.teach.teacher.module.entity.QuestionOptionsEntity;
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 QuestionOptionsConvert {

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

    /**
     * 将请求参数转换为实体对象
     *
     * @param req 题目选项请求参数
     * @return 题目选项实体对象
     */
    @Mapping(target = "id", ignore = true)
    @Mapping(target = "createTime", ignore = true)
    @Mapping(target = "updateTime", ignore = true)
    @Mapping(target = "deleted", ignore = true)
    QuestionOptionsEntity convertReqToEntity(QuestionOptionsReq req);

    /**
     * 将实体对象转换为响应参数
     *
     * @param entity 题目选项实体对象
     * @return 题目选项响应参数
     */
    QuestionOptionsResp convertEntityToResp(QuestionOptionsEntity entity);

    /**
     * 将实体对象列表转换为响应参数列表
     *
     * @param entities 题目选项实体对象列表
     * @return 题目选项响应参数列表
     */
    List<QuestionOptionsResp> convertEntityListToRespList(List<QuestionOptionsEntity> entities);

    /**
     * 更新实体对象属性
     *
     * @param req    题目选项请求参数
     * @param entity 题目选项实体对象
     */
    void updateEntityFromReq(QuestionOptionsReq req, @MappingTarget QuestionOptionsEntity entity);
}