admin
2020-12-03 55f808742eb4117dbb840955cb11bb9b9ae4f04c
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.ks.daylucky.service.impl.remote;
 
import com.ks.daylucky.exception.UserInfoExtraException;
import com.ks.daylucky.mapper.UserInfoExtraMapper;
import com.ks.daylucky.pojo.DO.UserInfoExtra;
import com.ks.daylucky.pojo.DTO.UserMsgSettings;
import com.ks.daylucky.service.UserInfoExtraService;
import org.apache.dubbo.config.annotation.Service;
 
import javax.annotation.Resource;
import java.util.Date;
 
@Service(version = "1.0.0")
public class UserInfoExtraServiceImpl implements UserInfoExtraService {
 
    @Resource
    private UserInfoExtraMapper userInfoExtraMapper;
 
 
    @Override
    public void init(Long uid) {
        UserInfoExtra extra = new UserInfoExtra();
        extra.setCreateTime(new Date());
        extra.setMsgSetting(new UserMsgSettings().toString());
        extra.setMsgUnreadCount(0);
        userInfoExtraMapper.insertSelective(extra);
    }
 
    @Override
    public UserInfoExtra getUserInfoExtra(Long uid) {
        return userInfoExtraMapper.selectByPrimaryKey(uid);
    }
 
    @Override
    public void setMsgRead(Long uid) throws UserInfoExtraException {
        UserInfoExtra extra = new UserInfoExtra();
        extra.setUid(uid);
        extra.setMsgUnreadCount(0);
        extra.setUpdateTime(new Date());
        userInfoExtraMapper.updateByPrimaryKeySelective(extra);
    }
 
    @Override
    public void setUserMsgSetting(Long uid, UserMsgSettings setting) {
        UserInfoExtra extra = new UserInfoExtra();
        extra.setUid(uid);
        extra.setMsgSetting(setting.toString());
        extra.setUpdateTime(new Date());
        userInfoExtraMapper.updateByPrimaryKeySelective(extra);
    }
 
    @Override
    public UserMsgSettings getUserMsgSettings(Long uid) {
        UserInfoExtra userInfoExtra = userInfoExtraMapper.selectByPrimaryKeyForUpdate(uid);
        String msg = userInfoExtra.getMsgSetting();
        return UserMsgSettings.parse(msg);
    }
}