admin
2024-06-24 5d3b3b74afd2ac4cf21697fc38367b2f88170e9f
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package com.taoke.autopay.service.impl;
 
import com.taoke.autopay.dao.ClientInfoMapper;
import com.taoke.autopay.entity.ClientInfo;
import com.taoke.autopay.exception.LoginException;
import com.taoke.autopay.service.ClientInfoService;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
 
/**
 * @author hxh
 * @title: ClientInfoServiceImpl
 * @description: TODO
 * @date 2024/6/14 18:43
 */
@Service
public class ClientInfoServiceImpl implements ClientInfoService {
    @Resource
    private ClientInfoMapper clientInfoMapper;
 
    @Override
    public ClientInfo login(String account, String pwd) throws LoginException {
        ClientInfoMapper.DaoQuery query = new ClientInfoMapper.DaoQuery();
        query.start = 0;
        query.count = 1;
        query.account = account;
        List<ClientInfo> list = clientInfoMapper.list(query);
        if (list.size() == 0) {
            throw new LoginException("账号不存在");
        }
        if (!list.get(0).getPwd().equalsIgnoreCase(pwd)) {
            throw new LoginException("密码错误");
        }
 
        return list.get(0);
    }
 
    @Override
    public void logout(Long uid) {
        clientInfoMapper.clearActiveTime(uid);
    }
 
    @Override
    public ClientInfo selectByPrimaryKey(Long id) {
        return clientInfoMapper.selectByPrimaryKey(id);
    }
 
    @Override
    public void setActiveTime(Long id, Date date) {
        ClientInfo info=new ClientInfo();
        info.setId(id);
        info.setActiveTime(date);
        clientInfoMapper.updateByPrimaryKeySelective(info);
    }
}