package com.mosty.base.manager.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mosty.base.manager.mapper.TbJcglXljlMapper;
import com.mosty.base.manager.service.TbJcglXljlService;
import com.mosty.base.model.dto.jcgl.TbJcglXljlDto;
import com.mosty.base.model.entity.jcgl.TbJcglXljl;
import com.mosty.common.util.UUIDGenerator;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TbJcglXljlServiceImpl extends ServiceImpl<TbJcglXljlMapper, TbJcglXljl>
        implements TbJcglXljlService {

    @Override
    public int addEntity(TbJcglXljlDto dto) {
        TbJcglXljl item = new TbJcglXljl();
        BeanUtils.copyProperties(dto, item);
        item.setId(UUIDGenerator.getUUID());
        return this.baseMapper.insert(item);
    }

    @Override
    public int editEntity(TbJcglXljlDto dto) {
        TbJcglXljl item = new TbJcglXljl();
        BeanUtils.copyProperties(dto, item);
        return this.baseMapper.updateById(item);
    }

    @Override
    public void deleteEntity(List<String> ids) {
        this.baseMapper.deleteBatchIds(ids);
    }

    @Override
    public TbJcglXljl getInfo(String id) {
        return this.baseMapper.selectById(id);
    }

    @Override
    public List<TbJcglXljl> getListByXfid(String xfid) {
        return this.baseMapper.selectList(new LambdaQueryWrapper<TbJcglXljl>().eq(TbJcglXljl::getXfllId,xfid));
    }
}
