package com.tcm.training.admin.statistics.service; import com.tcm.training.admin.member.entity.AppUser; import com.tcm.training.admin.member.mapper.UserMapper; import com.tcm.training.admin.statistics.entity.AppUserEntryLog; import com.tcm.training.admin.statistics.mapper.AppUserEntryLogMapper; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; @Service public class AppUserEntryLogAppService { private final AppUserEntryLogMapper appUserEntryLogMapper; private final UserMapper userMapper; public AppUserEntryLogAppService(AppUserEntryLogMapper appUserEntryLogMapper, UserMapper userMapper) { this.appUserEntryLogMapper = appUserEntryLogMapper; this.userMapper = userMapper; } @Transactional public void record(Long appUserId) { AppUser user = userMapper.selectById(appUserId); if (user == null || (user.getDeleted() != null && user.getDeleted() == 1)) { throw new IllegalArgumentException("用户不存在"); } AppUserEntryLog entryLog = new AppUserEntryLog(); entryLog.setAppUserId(appUserId); entryLog.setEntryTime(LocalDateTime.now()); entryLog.setDeleted(0); appUserEntryLogMapper.insert(entryLog); } }