package com.gitee.sop.website.service.help;

import com.gitee.fastmybatis.core.support.LambdaService;
import com.gitee.sop.website.common.util.CopyUtil;
import com.gitee.sop.website.dao.entity.HelpDoc;
import com.gitee.sop.website.dao.mapper.HelpDocMapper;
import com.gitee.sop.website.service.common.StatusEnum;
import com.gitee.sop.website.service.help.dto.HelpDocDTO;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 六如
 */
@Service
public class HelpDocService implements LambdaService<HelpDoc, HelpDocMapper> {

    public List<HelpDocDTO> listTree() {

        return this.query()
                .select(HelpDoc::getId, HelpDoc::getLabel, HelpDoc::getParentId,
                        HelpDoc::getAddTime,
                        HelpDoc::getUpdateTime)
                .eq(HelpDoc::getStatus, StatusEnum.ENABLE.getValue())
                .orderByAsc(HelpDoc::getSort)
                .list(data -> CopyUtil.copyBean(data, HelpDocDTO::new));
    }

}
