🐛 修复了一些已知 Bug
🐛 修复了一些已知 Bug
This commit is contained in:
commit
5b53760d4c
@ -51,4 +51,11 @@ public interface NotificationMapper extends Mapper<Notification> {
|
||||
* @return
|
||||
*/
|
||||
Integer readNotification(@Param("id") Integer id);
|
||||
|
||||
/**
|
||||
* 标记所有消息已读
|
||||
* @param idUser
|
||||
* @return
|
||||
*/
|
||||
Integer readAllNotification(@Param("idUser") Integer idUser);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.rymcu.forest.service;
|
||||
import com.rymcu.forest.core.service.Service;
|
||||
import com.rymcu.forest.dto.NotificationDTO;
|
||||
import com.rymcu.forest.entity.Notification;
|
||||
import com.rymcu.forest.web.api.exception.BaseApiException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -47,6 +48,14 @@ public interface NotificationService extends Service<Notification> {
|
||||
/**
|
||||
* 标记消息已读
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Integer readNotification(Integer id);
|
||||
|
||||
/**
|
||||
* 标记所有消息已读
|
||||
* @return
|
||||
* @throws BaseApiException
|
||||
*/
|
||||
Integer readAllNotification() throws BaseApiException;
|
||||
}
|
||||
|
@ -274,10 +274,8 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
||||
if (Objects.isNull(user)) {
|
||||
throw new BaseApiException(ErrorCode.INVALID_TOKEN);
|
||||
}
|
||||
StringBuilder shareUrl = new StringBuilder(article.getArticlePermalink());
|
||||
shareUrl.append("?s=").append(user.getAccount());
|
||||
Map map = new HashMap(1);
|
||||
map.put("shareUrl", shareUrl);
|
||||
Map map = new HashMap(2);
|
||||
map.put("shareUrl", article.getArticlePermalink() + "?s=" + user.getAccount());
|
||||
return map;
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,8 @@ import com.rymcu.forest.mapper.NotificationMapper;
|
||||
import com.rymcu.forest.service.NotificationService;
|
||||
import com.rymcu.forest.util.BeanCopierUtil;
|
||||
import com.rymcu.forest.util.NotificationUtils;
|
||||
import com.rymcu.forest.util.UserUtils;
|
||||
import com.rymcu.forest.web.api.exception.BaseApiException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@ -70,4 +72,9 @@ public class NotificationServiceImpl extends AbstractService<Notification> imple
|
||||
public Integer readNotification(Integer id) {
|
||||
return notificationMapper.readNotification(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer readAllNotification() throws BaseApiException {
|
||||
return notificationMapper.readAllNotification(Objects.requireNonNull(UserUtils.getCurrentUserByToken()).getIdUser());
|
||||
}
|
||||
}
|
||||
|
@ -65,4 +65,13 @@ public class NotificationController {
|
||||
return GlobalResultGenerator.genSuccessResult("标记已读成功");
|
||||
}
|
||||
|
||||
@PutMapping("/read-all")
|
||||
public GlobalResult readAll() throws BaseApiException {
|
||||
Integer result = notificationService.readAllNotification();
|
||||
if (result == 0) {
|
||||
return GlobalResultGenerator.genErrorResult("标记已读失败");
|
||||
}
|
||||
return GlobalResultGenerator.genSuccessResult("标记已读成功");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,6 +25,9 @@
|
||||
<update id="readNotification">
|
||||
update forest_notification set has_read = '1' where id = #{id}
|
||||
</update>
|
||||
<update id="readAllNotification">
|
||||
update forest_notification set has_read = '1' where id_user = #{idUser} and has_read = '0'
|
||||
</update>
|
||||
<select id="selectUnreadNotifications" resultMap="BaseResultMapper">
|
||||
select * from forest_notification where has_read = '0' and id_user = #{idUser} order by created_time desc
|
||||
</select>
|
||||
|
@ -339,7 +339,7 @@ values (4, '普通用户', 'user', '0', '2019-12-05 03:10:59', '2020-03-12 15:13
|
||||
|
||||
insert into forest.forest_user (id, account, password, nickname, real_name, sex, avatar_type, avatar_url, email, phone,
|
||||
status, created_time, updated_time, last_login_time, signature)
|
||||
values (1, 'admin', '8ce2dd866238958ac4f07870766813cdaa39a9b83a8c75e26aa50f23', 'admin', 'admin', '0', '0', null, null,
|
||||
values (1, 'admin', '8ce2dd866238958ac4f07870766813cdaa39a9b83a8c75e26aa50f23', 'admin', 'admin', '0', '0', null, 'admin@rymcu.com',
|
||||
null, '0', '2021-01-25 18:21:51', '2021-01-25 18:21:54', null, null);
|
||||
|
||||
insert into forest.forest_user_role (id_user, id_role, created_time)
|
||||
|
Loading…
Reference in New Issue
Block a user