| | |
| | | package com.yeshi.fanli.service.impl.user.invite;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.msg.MsgInviteDetailMapper;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgExtra;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgInviteDetail;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.exception.msg.MsgInviteDetailException;
|
| | | import com.yeshi.fanli.service.inter.msg.MsgExtraService;
|
| | | import com.yeshi.fanli.service.inter.msg.UserMsgReadStateService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.MsgInviteDetailService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | @Service
|
| | | public class MsgInviteDetailServiceImpl implements MsgInviteDetailService {
|
| | |
|
| | | @Resource
|
| | | private MsgInviteDetailMapper msgInviteDetailMapper;
|
| | |
|
| | | @Resource
|
| | | private UserMsgReadStateService userMsgReadStateService;
|
| | |
|
| | | @Resource
|
| | | private MsgExtraService msgExtraService;
|
| | | |
| | | |
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void addMsgInviteDetail(MsgInviteDetail detail) throws MsgInviteDetailException {
|
| | | if (detail == null)
|
| | | throw new MsgInviteDetailException(1, "消息为空");
|
| | |
|
| | | if (detail.getMsgType() == null || detail.getUser() == null || StringUtil.isNullOrEmpty(detail.getExtraInfo()))
|
| | | throw new MsgInviteDetailException(2, "消息内容不完整");
|
| | |
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setUpdateTime(new Date());
|
| | | detail.setRead(false);
|
| | | msgInviteDetailMapper.insertSelective(detail);
|
| | | msgExtraService.addMsgExtra(detail.getId(), detail.getExtraInfo(), MsgExtra.MSG_TYPE_INVITE);
|
| | | userMsgReadStateService.addInviteMsgUnReadCount(detail.getUser().getId(), 1);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<MsgInviteDetail> listMsgInviteDetail(Long uid, int page) {
|
| | | return msgInviteDetailMapper.listByUid(uid, (page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countMsgInviteDetail(Long uid) {
|
| | | return msgInviteDetailMapper.countByUid(uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void readMsgByUid(Long uid) {
|
| | | msgInviteDetailMapper.setMsgReadByUid(uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void deleteByThreeSale(ThreeSale sale) {
|
| | | if (sale == null)
|
| | | return;
|
| | | msgInviteDetailMapper.deleteByThreeSaleId(sale.getId());
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void insertSelective(MsgInviteDetail detail) {
|
| | | msgInviteDetailMapper.insertSelective(detail);
|
| | | userMsgReadStateService.addInviteMsgUnReadCount(detail.getUser().getId(), 1);
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.service.impl.user.invite; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import com.yeshi.fanli.dao.mybatis.msg.MsgInviteDetailMapper; |
| | | import com.yeshi.fanli.entity.bus.msg.MsgExtra; |
| | | import com.yeshi.fanli.entity.bus.msg.MsgInviteDetail; |
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale; |
| | | import com.yeshi.fanli.exception.msg.MsgInviteDetailException; |
| | | import com.yeshi.fanli.service.inter.msg.MsgExtraService; |
| | | import com.yeshi.fanli.service.inter.msg.UserMsgReadStateService; |
| | | import com.yeshi.fanli.service.inter.user.invite.MsgInviteDetailService; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | |
| | | @Service |
| | | public class MsgInviteDetailServiceImpl implements MsgInviteDetailService { |
| | | |
| | | @Resource |
| | | private MsgInviteDetailMapper msgInviteDetailMapper; |
| | | |
| | | @Resource |
| | | private UserMsgReadStateService userMsgReadStateService; |
| | | |
| | | @Resource |
| | | private MsgExtraService msgExtraService; |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void addMsgInviteDetail(MsgInviteDetail detail) throws MsgInviteDetailException { |
| | | if (detail == null) |
| | | throw new MsgInviteDetailException(1, "消息为空"); |
| | | |
| | | if (detail.getMsgType() == null || detail.getUser() == null || StringUtil.isNullOrEmpty(detail.getExtraInfo())) |
| | | throw new MsgInviteDetailException(2, "消息内容不完整"); |
| | | |
| | | detail.setCreateTime(new Date()); |
| | | detail.setUpdateTime(new Date()); |
| | | detail.setRead(false); |
| | | msgInviteDetailMapper.insertSelective(detail); |
| | | msgExtraService.addMsgExtra(detail.getId(), detail.getExtraInfo(), MsgExtra.MSG_TYPE_INVITE); |
| | | userMsgReadStateService.addInviteMsgUnReadCount(detail.getUser().getId(), 1); |
| | | } |
| | | |
| | | @Override |
| | | public List<MsgInviteDetail> listMsgInviteDetail(Long uid, int page) { |
| | | return msgInviteDetailMapper.listByUid(uid, (page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE); |
| | | } |
| | | |
| | | @Override |
| | | public List<MsgInviteDetail> listDetail(List<Long> ids) { |
| | | return msgInviteDetailMapper.listByPrimaryKeys(ids); |
| | | } |
| | | |
| | | @Override |
| | | public long countMsgInviteDetail(Long uid) { |
| | | return msgInviteDetailMapper.countByUid(uid); |
| | | } |
| | | |
| | | @Override |
| | | public void readMsgByUid(Long uid) { |
| | | msgInviteDetailMapper.setMsgReadByUid(uid); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteByThreeSale(ThreeSale sale) { |
| | | if (sale == null) |
| | | return; |
| | | msgInviteDetailMapper.deleteByThreeSaleId(sale.getId()); |
| | | } |
| | | |
| | | @Override |
| | | public void insertSelective(MsgInviteDetail detail) { |
| | | msgInviteDetailMapper.insertSelective(detail); |
| | | userMsgReadStateService.addInviteMsgUnReadCount(detail.getUser().getId(), 1); |
| | | } |
| | | |
| | | @Override |
| | | public MsgInviteDetail selectByPrimaryKey(Long id) { |
| | | return msgInviteDetailMapper.selectByPrimaryKey(id); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteByPrimaryKey(Long id) { |
| | | msgInviteDetailMapper.deleteByPrimaryKey(id); |
| | | msgExtraService.deleteByPidAndType(id, MsgExtra.MSG_TYPE_INVITE); |
| | | } |
| | | |
| | | } |