| | |
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dao.mybatis.msg.MsgAccountDetailMapper;
|
| | | import com.yeshi.fanli.dto.msg.MsgAccountVipDTO;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgAccountDetail;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgAccountDetail.MsgTypeAccountTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgExtra;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.exception.msg.MsgAccountDetailException;
|
| | | import com.yeshi.fanli.service.inter.msg.MsgExtraService;
|
| | | import com.yeshi.fanli.service.inter.msg.UserMsgReadStateService;
|
| | | import com.yeshi.fanli.service.inter.user.msg.MsgAccountDetailService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserMsgReadStateService userMsgReadStateService;
|
| | | |
| | | @Resource
|
| | | private MsgExtraService msgExtraService;
|
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void addMsgAccountDetail(MsgAccountDetail detail) throws MsgAccountDetailException {
|
| | | if (detail == null)
|
| | | throw new MsgAccountDetailException(1, "消息为空");
|
| | | if (StringUtil.isNullOrEmpty(detail.getTitle()) || StringUtil.isNullOrEmpty(detail.getContent())
|
| | | || detail.getType() == null || detail.getUser() == null)
|
| | | throw new MsgAccountDetailException(2, "消息内容不完整");
|
| | | if (detail == null || detail.getUser() == null || detail.getType() == null
|
| | | || StringUtil.isNullOrEmpty(detail.getExtraInfo()))
|
| | | throw new MsgAccountDetailException(1, "消息信息不全");
|
| | | // 持久化到数据库
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setUpdateTime(new Date());
|
| | | detail.setRead(false);
|
| | | msgAccountDetailMapper.insertSelective(detail);
|
| | | // 消息内容
|
| | | msgExtraService.addMsgExtra(detail.getId(), detail.getExtraInfo(), MsgExtra.MSG_TYPE_ACCOUNT);
|
| | | // 红点
|
| | | userMsgReadStateService.addAccountMsgUnReadCount(detail.getUser().getId(), 1);
|
| | | }
|
| | |
|
| | |
| | | msgAccountDetailMapper.setMsgReadByUid(uid);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public void addMsgVIP(Long uid, String title, String beiZhu, MsgAccountVipDTO dto) {
|
| | | MsgAccountDetail detail = new MsgAccountDetail();
|
| | | detail.setTitle(title);
|
| | | detail.setBeiZhu(beiZhu);
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setUpdateTime(new Date());
|
| | | detail.setRead(false);
|
| | | detail.setUser(new UserInfo(uid));
|
| | | detail.setContent(new Gson().toJson(dto));
|
| | | detail.setType(MsgTypeAccountTypeEnum.vipPgrade);
|
| | | msgAccountDetailMapper.insertSelective(detail);
|
| | | |
| | | userMsgReadStateService.addAccountMsgUnReadCount(detail.getUser().getId(), 1);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public MsgAccountDetail selectByPrimaryKey(Long id) {
|
| | | return msgAccountDetailMapper.selectByPrimaryKey(id);
|
| | | }
|
| | | |
| | | @Override
|
| | | public void deleteByPrimaryKey(Long id) {
|
| | | msgAccountDetailMapper.deleteByPrimaryKey(id);
|
| | | msgExtraService.deleteByPidAndType(id, MsgExtra.MSG_TYPE_ACCOUNT);
|
| | | }
|
| | | |
| | | }
|