🐛 消息标记为已读问题修复
This commit is contained in:
parent
1774637e28
commit
22979810e5
@ -48,5 +48,5 @@ public interface NotificationService extends Service<Notification> {
|
|||||||
* 标记消息已读
|
* 标记消息已读
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
void readNotification(Integer id);
|
Integer readNotification(Integer id);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.rymcu.vertical.entity.Notification;
|
|||||||
import com.rymcu.vertical.mapper.NotificationMapper;
|
import com.rymcu.vertical.mapper.NotificationMapper;
|
||||||
import com.rymcu.vertical.service.NotificationService;
|
import com.rymcu.vertical.service.NotificationService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -36,12 +37,14 @@ public class NotificationServiceImpl extends AbstractService<Notification> imple
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Integer save(Integer idUser, Integer dataId, String dataType, String dataSummary) {
|
public Integer save(Integer idUser, Integer dataId, String dataType, String dataSummary) {
|
||||||
return notificationMapper.insertNotification(idUser,dataId,dataType,dataSummary);
|
return notificationMapper.insertNotification(idUser,dataId,dataType,dataSummary);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readNotification(Integer id) {
|
@Transactional(rollbackFor = Exception.class)
|
||||||
notificationMapper.readNotification(id);
|
public Integer readNotification(Integer id) {
|
||||||
|
return notificationMapper.readNotification(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,12 @@ public class NotificationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/read/{id}")
|
@PutMapping("/read/{id}")
|
||||||
public void read(@PathVariable Integer id) {
|
public GlobalResult read(@PathVariable Integer id) {
|
||||||
notificationService.readNotification(id);
|
Integer result = notificationService.readNotification(id);
|
||||||
|
if (result == 0) {
|
||||||
|
return GlobalResultGenerator.genErrorResult("标记已读失败");
|
||||||
|
}
|
||||||
|
return GlobalResultGenerator.genSuccessResult("标记已读成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user