package com.sptg.estate.biz.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.estate.api.entity.ContractImg;
import com.sptg.estate.biz.mapper.ContractImgMapper;
import com.sptg.estate.biz.service.ContractImgServiceInterface;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * title: ProjectServiceImpl
 * package: com.sptg.estate.biz.security
 * description: 实施项目合同图片-服务层实现层
 *
 *               
 *                     
 */
@Service
public class ContractImgServiceImpl extends ServiceImpl<ContractImgMapper, ContractImg> implements ContractImgServiceInterface {
    @Override
    @Transactional(rollbackFor = Throwable.class)
    public ResultBean<Boolean> addList(List<ContractImg> list) {
        return new ResultBean<>(ResultEnum.SUCCESS,this.insertBatch(list));
    }

    @Override
    public ResultBean<Boolean> deleteByContractId(Long contractId) {
        Wrapper<ContractImg> wrapper = new EntityWrapper<>();
        wrapper.eq("l_contract_id",contractId);
        return new ResultBean<>(ResultEnum.SUCCESS,this.delete(wrapper));
    }

    @Override
    public List<ContractImg> getListContractId(Long contractId) {
        Wrapper<ContractImg> wrapper = new EntityWrapper<>();
        wrapper.eq("l_contract_id",contractId);
        return this.selectList(wrapper);
    }
}
