package com.chinaweal.aiccs.aiccs.fraudreg.service.impl;

import com.chinaweal.aiccs.aiccs.fraudreg.entity.TBizFraud;
import com.chinaweal.aiccs.aiccs.fraudreg.entity.TFraudEnt;
import com.chinaweal.aiccs.aiccs.fraudreg.mapper.TFraudEntMapper;
import com.chinaweal.aiccs.aiccs.fraudreg.service.ITFraudEntService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chinaweal.youfool.framework.springboot.mybatis.plus.BaseServiceImpl;
import org.springframework.stereotype.Service;
import com.chinaweal.youfool.framework.springboot.base.query.BaseQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;

/**
 * <p>
 * 涉嫌冒用他人身份取得登记主体信息表 服务实现类
 * </p>
 *
 * @author chinaweal
 * @since 2021-11-11
 */
@Service
public class TFraudEntServiceImpl extends BaseServiceImpl<TFraudEntMapper, TFraudEnt> implements ITFraudEntService {

    @Override
    public TFraudEnt saveTFraudEnt(TFraudEnt tFraudEnt) {
        save(tFraudEnt);
        return tFraudEnt;
    }

    @Override
    public void updateTFraudEnt(TFraudEnt tFraudEnt) {
        updateById(tFraudEnt);
    }

    @Override
    public IPage<TFraudEnt> listTFraudEnt(BaseQuery<TFraudEnt> query) {
        TFraudEnt entity = query.getEntity(TFraudEnt.class);
        Page<TFraudEnt> page = query.getPage();

        LambdaQueryWrapper<TFraudEnt> lambdaQueryWrapper = Wrappers.lambdaQuery();

        return page(page, lambdaQueryWrapper);
    }

    @Override
    public TFraudEnt getByBizSeq(String bizSeq) {
        return this.lambdaQuery().eq(TFraudEnt::getBizSeq, bizSeq).one();
    }

    @Override
    public IPage<TFraudEnt> listTFraudEntByEntName(BaseQuery<TFraudEnt> query) {
        TFraudEnt entity = query.getEntity(TFraudEnt.class);
        Page<TFraudEnt> page = query.getPage();

        LambdaQueryWrapper<TFraudEnt> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(TFraudEnt::getUniScId,entity.getUniScId());
        lambdaQueryWrapper.eq(TFraudEnt::getEntName,entity.getEntName());

        return page(page, lambdaQueryWrapper);
    }
}
