package com.sqx.modules.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sqx.modules.app.entity.UserInfo;
import com.sqx.modules.app.mapper.UserInfoMapper;
import com.sqx.modules.app.service.UserInfoService;
import org.springframework.stereotype.Service;

/**
* @author Administrator
* @description 针对表【user_info】的数据库操作Service实现
* @createDate 2025-01-02 14:15:08
*/
@Service
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
    implements UserInfoService{

    @Override
    public UserInfo getByUserId(long userId) {
        UserInfo userInfo = getOne(new LambdaQueryWrapper<UserInfo>()
                .eq(UserInfo::getUserId, userId));
        if (userInfo == null) {
            userInfo = new UserInfo();
            userInfo.setUserId(userId);
            save(userInfo);
        }
        return userInfo;
    }

    @Override
    public Integer countCertCount(String name, String idNum) {
        return count(new LambdaQueryWrapper<UserInfo>()
                .eq(UserInfo::getCertName, name)
                .eq(UserInfo::getCertNo, idNum));
    }
}




