package com.yeejoin.amos.boot.module.jg.biz.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.module.jg.api.entity.JgRegistrationHistory;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgRegistrationHistoryMapper;
import com.yeejoin.amos.boot.module.jg.api.service.IJgRegistrationHistoryService;
import com.yeejoin.amos.boot.module.jg.api.dto.JgRegistrationHistoryDto;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;

/**
 * 数据登记变更历史表服务实现类
 *
 * @author system_generator
 * @date 2023-12-20
 */
@Service
public class JgRegistrationHistoryServiceImpl extends BaseService<JgRegistrationHistoryDto,JgRegistrationHistory,JgRegistrationHistoryMapper> implements IJgRegistrationHistoryService {
    /**
     * 分页查询
     */
    public Page<JgRegistrationHistoryDto> queryForJgRegistrationHistoryPage(Page<JgRegistrationHistoryDto> page)   {
        return this.queryForPage(page, null, false);
    }

    /**
     * 列表查询 示例
     */
    public List<JgRegistrationHistoryDto> queryForJgRegistrationHistoryList()   {
        return this.queryForList("" , false);
    }

    /**
     * 新增或移装变更历史数据
     * @param history
     */
    public boolean saveOrUpdateHistoryData(JgRegistrationHistory history) {
        return this.saveOrUpdate(history);
    }

    /**
     * 根据指定参数查询历史数据详情
     * @param currentDocumentId
     * @return
     */
    public JgRegistrationHistory getDteailByRecord(String record, String currentDocumentId) {
        return this.getOne(new QueryWrapper<JgRegistrationHistory>().eq("equ_id", record).eq("current_document_id", currentDocumentId));
    }

    /**
     * 修改历史数据
     * @param history
     * @param historyWapper
     * @return
     */
    public boolean updateDate(JgRegistrationHistory history, LambdaQueryWrapper<JgRegistrationHistory> historyWapper) {
        return this.update(history, historyWapper);
    }

    public JgRegistrationHistory queryLatestRegistrationHistory(Long projectContraptionSeq) {
        return this.baseMapper.queryLatestRegistrationHistory(projectContraptionSeq);
    }
}