package com.yeshi.makemoney.app.service.impl.user;
|
|
import com.yeshi.makemoney.app.dao.user.UserExtraInfoDao;
|
import com.yeshi.makemoney.app.entity.user.UserExtraInfo;
|
import com.yeshi.makemoney.app.service.inter.user.UserExtraInfoService;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.Date;
|
|
@Service
|
public class UserExtraInfoServiceImpl implements UserExtraInfoService {
|
|
@Resource
|
private UserExtraInfoDao userExtraInfoDao;
|
|
|
@Override
|
public UserExtraInfo get(Long uid) {
|
return init(uid);
|
}
|
|
@Override
|
public UserExtraInfo init(Long uid) {
|
UserExtraInfo extraInfo = userExtraInfoDao.get(uid);
|
if (extraInfo != null) {
|
return extraInfo;
|
}
|
|
extraInfo = new UserExtraInfo();
|
extraInfo.setId(uid);
|
extraInfo.setCreateTime(new Date());
|
userExtraInfoDao.save(extraInfo);
|
return extraInfo;
|
}
|
|
@Override
|
public void addUnReadMsgCount(Long uid, int count) {
|
UserExtraInfo extraInfo = init(uid);
|
if (extraInfo.getUnReadMsgCount() == null) {
|
extraInfo.setUnReadMsgCount(count);
|
} else {
|
extraInfo.setUnReadMsgCount(extraInfo.getUnReadMsgCount() + count);
|
}
|
userExtraInfoDao.updateSelective(extraInfo);
|
}
|
|
@Override
|
public void setMsgRead(Long uid) {
|
init(uid);
|
UserExtraInfo update = new UserExtraInfo();
|
update.setId(uid);
|
update.setUnReadMsgCount(0);
|
userExtraInfoDao.updateSelective(update);
|
}
|
|
@Override
|
public void setInviteCode(Long uid, String code) {
|
init(uid);
|
UserExtraInfo update = new UserExtraInfo();
|
update.setId(uid);
|
update.setInviteCode(code);
|
userExtraInfoDao.updateSelective(update);
|
}
|
}
|