| | |
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.msg.MsgDeviceReadStateMapper;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgDeviceReadState;
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public void addUnreadDeviceMsg(String type, String device, int platform, int msgCount, String msg) {
|
| | | public void addUnreadDeviceMsg(String type, String device, int platform, int msgCount, String msg, Date msgTime) {
|
| | | MsgDeviceReadState state = msgDeviceReadStateMapper.selectByDeviceAndPlatformAndType(device, platform, type);
|
| | | if (state != null) {
|
| | | MsgDeviceReadState update = new MsgDeviceReadState();
|
| | |
| | | update.setUnReadCount(state.getUnReadCount() + msgCount);
|
| | | update.setUpdateTime(new Date());
|
| | | update.setLatestContent(msg);
|
| | | update.setLatestContentTime(msgTime);
|
| | | msgDeviceReadStateMapper.updateByPrimaryKeySelective(update);
|
| | | } else {
|
| | | state = new MsgDeviceReadState();
|
| | |
| | | state.setUnReadCount(msgCount);
|
| | | state.setUpdateTime(new Date());
|
| | | state.setLatestContent(msg);
|
| | | state.setLatestContentTime(msgTime);
|
| | | msgDeviceReadStateMapper.insertSelective(state);
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public MsgDeviceReadState getByDeviceAndPlatformAndType(String type, String device, int platform) {
|
| | | MsgDeviceReadState state = msgDeviceReadStateMapper.selectByDeviceAndPlatformAndType(device, platform, type);
|
| | | MsgDeviceReadState state = msgDeviceReadStateMapper.selectByDeviceAndPlatformAndTypeForUpdate(device, platform,
|
| | | type);
|
| | | if (state == null) {
|
| | | state = new MsgDeviceReadState();
|
| | | state.setCreateTime(new Date());
|