package com.jeequan.jeepay.service.impl;

import cn.hutool.core.util.DesensitizedUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jeequan.jeepay.db.entity.MchStoreTerminal;
import com.jeequan.jeepay.service.mapper.MchStoreTerminalMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 商户辅助终端信息报备表 服务实现类
 * </p>
 *
 * @author [mybatis plus generator]
 * @since 2022-04-26
 */
@Service
public class MchStoreTerminalService extends ServiceImpl<MchStoreTerminalMapper, MchStoreTerminal> {

    @Autowired
    MchStoreTerminalMapper mchStoreTerminalMapper;

    public IPage<MchStoreTerminal> getMchStoreTerminalList(IPage<MchStoreTerminal> page,MchStoreTerminal mchStoreTerminal){
        IPage<MchStoreTerminal> mchStoreTerminalList = mchStoreTerminalMapper.getMchStoreTerminalList(page, mchStoreTerminal);
        //手机号码脱敏
        for (MchStoreTerminal record : mchStoreTerminalList.getRecords()) {
            if (StringUtils.isNotEmpty(record.getContactTel())){
                record.setContactTel(DesensitizedUtil.mobilePhone(record.getContactTel()));
            }
        }
        return mchStoreTerminalList;
    }

}
