hejianhao
2026-09-01 f4e8dfd7f8f11966f4b5dc8c6661cbc3feccc4cf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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);
    }
}