package com.fjhx.common.service.documentary.impl;

import com.fjhx.common.entity.documentary.po.Documentary;
import com.fjhx.common.mapper.documentary.DocumentaryMapper;
import com.fjhx.common.service.documentary.DocumentaryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.common.entity.documentary.vo.DocumentaryVo;
import com.fjhx.common.entity.documentary.dto.DocumentarySelectDto;
import com.ruoyi.common.utils.wrapper.IWrapper;
import com.fjhx.common.entity.documentary.dto.DocumentaryDto;
import cn.hutool.core.bean.BeanUtil;


/**
 * <p>
 * 跟单配置 服务实现类
 * </p>
 *
 * @author 
 * @since 2023-04-19
 */
@Service
public class DocumentaryServiceImpl extends ServiceImpl<DocumentaryMapper, Documentary> implements DocumentaryService {

    @Override
    public Page<DocumentaryVo> getPage(DocumentarySelectDto dto) {
        IWrapper<Documentary> wrapper = getWrapper();
        wrapper.orderByDesc("d", Documentary::getId);
        Page<DocumentaryVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

    @Override
    public DocumentaryVo detail(Long id) {
        Documentary Documentary = this.getById(id);
        DocumentaryVo result = BeanUtil.toBean(Documentary, DocumentaryVo.class);
        return result;
    }

    @Override
    public void add(DocumentaryDto documentaryDto) {
        this.save(documentaryDto);
    }

    @Override
    public void edit(DocumentaryDto documentaryDto) {
        this.updateById(documentaryDto);
    }

    @Override
    public void delete(Long id) {
        this.removeById(id);
    }

}
