| | |
| | | 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 org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | |
| | | @Service(version = "1.0.0") |
| | | @Service |
| | | public class UserInfoExtraServiceImpl implements UserInfoExtraService { |
| | | |
| | | @Resource |
| | |
| | | |
| | | |
| | | @Override |
| | | public void init(Long uid) { |
| | | public void init(Long uid, boolean msgSetting) { |
| | | UserInfoExtra extra = new UserInfoExtra(); |
| | | extra.setUid(uid); |
| | | extra.setCreateTime(new Date()); |
| | | extra.setMsgSetting(new UserMsgSettings().toString()); |
| | | extra.setMsgUnreadCount(0); |
| | | UserMsgSettings userMsgSettings = new UserMsgSettings(); |
| | | userMsgSettings.setDrawnMsg(true); |
| | | userMsgSettings.setAssistSuccessMsg(true); |
| | | userMsgSettings.setJoinActivityMsg(true); |
| | | userMsgSettings.setNotOpenActivityMsg(false); |
| | | userMsgSettings.setNotDrawnMsg(false); |
| | | userMsgSettings.setOpenActivityMsg(false); |
| | | if (msgSetting) { |
| | | extra.setMsgSetting(userMsgSettings.toString()); |
| | | } |
| | | userInfoExtraMapper.insertSelective(extra); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public void setUserMsgSetting(Long uid, UserMsgSettings setting) { |
| | | UserMsgSettings old = getUserMsgSettings(uid); |
| | | //设置已经设置的 |
| | | if (setting.getAssistSuccessMsg() != null) { |
| | | old.setAssistSuccessMsg(setting.getAssistSuccessMsg()); |
| | | } |
| | | |
| | | if (setting.getDrawnMsg() != null) { |
| | | old.setDrawnMsg(setting.getDrawnMsg()); |
| | | } |
| | | |
| | | if (setting.getJoinActivityMsg() != null) { |
| | | old.setJoinActivityMsg(setting.getJoinActivityMsg()); |
| | | } |
| | | |
| | | if (setting.getNotDrawnMsg() != null) { |
| | | old.setNotDrawnMsg(setting.getNotDrawnMsg()); |
| | | } |
| | | |
| | | if (setting.getNotOpenActivityMsg() != null) { |
| | | old.setNotOpenActivityMsg(setting.getNotOpenActivityMsg()); |
| | | } |
| | | |
| | | if (setting.getOpenActivityMsg() != null) { |
| | | old.setOpenActivityMsg(setting.getOpenActivityMsg()); |
| | | } |
| | | |
| | | |
| | | UserInfoExtra extra = new UserInfoExtra(); |
| | | extra.setUid(uid); |
| | | extra.setMsgSetting(setting.toString()); |
| | | extra.setMsgSetting(old.toString()); |
| | | extra.setUpdateTime(new Date()); |
| | | userInfoExtraMapper.updateByPrimaryKeySelective(extra); |
| | | } |
| | |
| | | String msg = userInfoExtra.getMsgSetting(); |
| | | return UserMsgSettings.parse(msg); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public void addMsgUnReadCount(Long uid, int count) { |
| | | UserInfoExtra userInfoExtra = userInfoExtraMapper.selectByPrimaryKeyForUpdate(uid); |
| | | UserInfoExtra update = new UserInfoExtra(); |
| | | update.setUid(uid); |
| | | update.setMsgUnreadCount(userInfoExtra.getMsgUnreadCount() + count); |
| | | update.setUpdateTime(new Date()); |
| | | userInfoExtraMapper.updateByPrimaryKeySelective(update); |
| | | } |
| | | } |