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

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mosty.base.manager.mapper.TbJcglAbfcMapper;
import com.mosty.base.manager.service.TbJcglAbfcService;
import com.mosty.base.model.dto.jcgl.TbJcglAbfcDto;
import com.mosty.base.model.entity.jcgl.TbJcglAbfc;
import com.mosty.base.model.query.jcgl.TbJcglAbfcQuery;
import com.mosty.common.token.UserInfo;
import com.mosty.common.token.UserInfoManager;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class TbJcglAbfcServiceImpl extends ServiceImpl<TbJcglAbfcMapper, TbJcglAbfc>
        implements TbJcglAbfcService {

    @Override
    public int addEntity(TbJcglAbfcDto dto) {
        TbJcglAbfc item = new TbJcglAbfc();
        UserInfo user = UserInfoManager.get();
        BeanUtils.copyProperties(dto, item);
        item.setCjrid(String.valueOf(user.getUserId()));
        item.setCjrxm(user.getUserName());
        item.setCjrsfzh(user.getIdEntityCard());
        item.setXtSjly("1");
        item.setTjsj(new Date());
        return this.baseMapper.insert(item);
    }

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

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

    @Override
    public List<TbJcglAbfc> getPageList(TbJcglAbfcQuery dto) {
        return this.baseMapper.getList(dto);
    }

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