package com.fjhx.service.contract.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.utils.WrapperUtil;
import com.fjhx.entity.contract.ContractDetails;
import com.fjhx.params.contract.ContractDetailsVo;
import com.fjhx.mapper.contract.ContractDetailsMapper;
import com.fjhx.service.contract.ContractDetailsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 * 合同明细 服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2022-10-25
 */
@Service
public class ContractDetailsServiceImpl extends ServiceImpl<ContractDetailsMapper, ContractDetails> implements ContractDetailsService {

    @Override
    public Page<ContractDetails> getPage(Map<String, String> condition) {

        QueryWrapper<ContractDetails> wrapper = Wrappers.query();

        WrapperUtil.init(condition, wrapper)
                .createTimeDesc();

        Page<ContractDetails> page = page(condition, wrapper);
        return page;
    }

    @Override
    public void add(ContractDetailsVo contractDetailsVo) {
        save(contractDetailsVo);
    }

    @Override
    public void edit(ContractDetailsVo contractDetailsVo) {
        updateById(contractDetailsVo);
    }

    @Override
    public void delete(ContractDetailsVo contractDetailsVo) {
        removeById(contractDetailsVo.getId());
    }

}
