🎨 代码优化
🎨 代码优化
This commit is contained in:
commit
d34bf02561
6
pom.xml
6
pom.xml
@ -101,7 +101,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
<version>2.0.3</version>
|
<version>1.2.83</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- shiro权限控制框架 -->
|
<!-- shiro权限控制框架 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -241,10 +241,6 @@
|
|||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
<exclusion>
|
|
||||||
<groupId>org.json</groupId>
|
|
||||||
<artifactId>json</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -75,11 +75,21 @@ public class AuthorshipAspect {
|
|||||||
isArticle = false;
|
isArticle = false;
|
||||||
}
|
}
|
||||||
HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
|
HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
|
||||||
String idArticle = "";
|
String idArticle;
|
||||||
Integer idAuthor = 0;
|
Integer idAuthor = 0;
|
||||||
if (isAjax(request)) {
|
if (isAjax(request)) {
|
||||||
Object[] objects = joinPoint.getArgs();
|
Object[] objects = joinPoint.getArgs();
|
||||||
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(objects[0]));
|
JSONObject jsonObject;
|
||||||
|
if (objects[0] instanceof Integer) {
|
||||||
|
jsonObject = new JSONObject();
|
||||||
|
if (isArticle) {
|
||||||
|
jsonObject.put("idArticle", objects[0].toString());
|
||||||
|
} else {
|
||||||
|
jsonObject.put("idPortfolio", objects[0].toString());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
jsonObject = JSONObject.parseObject(JSON.toJSONString(objects[0]));
|
||||||
|
}
|
||||||
if (Objects.nonNull(jsonObject)) {
|
if (Objects.nonNull(jsonObject)) {
|
||||||
if (isArticle) {
|
if (isArticle) {
|
||||||
idArticle = jsonObject.getString("idArticle");
|
idArticle = jsonObject.getString("idArticle");
|
||||||
|
@ -54,9 +54,14 @@ public class SecurityAspect {
|
|||||||
String idUser = "";
|
String idUser = "";
|
||||||
if (isAjax(request)) {
|
if (isAjax(request)) {
|
||||||
Object[] objects = joinPoint.getArgs();
|
Object[] objects = joinPoint.getArgs();
|
||||||
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(objects[0]));
|
JSONObject jsonObject;
|
||||||
if (Objects.nonNull(jsonObject)) {
|
if (objects[0] instanceof Integer) {
|
||||||
idUser = jsonObject.getString("idUser");
|
idUser = objects[0].toString();
|
||||||
|
} else {
|
||||||
|
jsonObject = JSONObject.parseObject(JSON.toJSONString(objects[0]));
|
||||||
|
if (Objects.nonNull(jsonObject)) {
|
||||||
|
idUser = jsonObject.getString("idUser");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Map params = getParams(request);
|
Map params = getParams(request);
|
||||||
|
@ -24,7 +24,7 @@ public class Sponsor implements Serializable, Cloneable {
|
|||||||
/**
|
/**
|
||||||
* 数据类型
|
* 数据类型
|
||||||
*/
|
*/
|
||||||
private String dataType;
|
private Integer dataType;
|
||||||
/**
|
/**
|
||||||
* 数据主键
|
* 数据主键
|
||||||
*/
|
*/
|
||||||
|
@ -7,29 +7,22 @@ import java.util.Arrays;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public enum TransactionEnum {
|
public enum TransactionEnum {
|
||||||
ArticleSponsor("0", 20, "文章赞赏"),
|
ArticleSponsor(20, "文章赞赏"),
|
||||||
Answer("1", 30, "答题奖励"),
|
Answer(30, "答题奖励"),
|
||||||
CorrectAnswer("2", 50, "答题奖励"),
|
CorrectAnswer(50, "答题奖励"),
|
||||||
NewbieRewards("3", 200, "新手奖励");
|
NewbieRewards(200, "新手奖励");
|
||||||
|
|
||||||
private String dataType;
|
|
||||||
|
|
||||||
private Integer money;
|
private Integer money;
|
||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
TransactionEnum(String dataType, Integer money, String description) {
|
TransactionEnum(Integer money, String description) {
|
||||||
this.dataType = dataType;
|
|
||||||
this.money = money;
|
this.money = money;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TransactionEnum findTransactionEnum(String dataType) {
|
public static TransactionEnum findTransactionEnum(int dataType) {
|
||||||
return Arrays.stream(TransactionEnum.values()).filter(transactionEnum -> transactionEnum.getDataType().equals(dataType)).findFirst().orElse(TransactionEnum.ArticleSponsor);
|
return Arrays.stream(TransactionEnum.values()).filter(transactionEnum -> transactionEnum.ordinal() == dataType).findFirst().orElse(TransactionEnum.ArticleSponsor);
|
||||||
}
|
|
||||||
|
|
||||||
public String getDataType() {
|
|
||||||
return this.dataType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getMoney() {
|
public Integer getMoney() {
|
||||||
|
@ -58,4 +58,12 @@ public interface NotificationMapper extends Mapper<Notification> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Integer readAllNotification(@Param("idUser") Integer idUser);
|
Integer readAllNotification(@Param("idUser") Integer idUser);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除相关未读消息
|
||||||
|
* @param dataId
|
||||||
|
* @param dataType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Integer deleteUnreadNotification(@Param("dataId") Integer dataId, @Param("dataType") String dataType);
|
||||||
}
|
}
|
||||||
|
@ -58,4 +58,12 @@ public interface NotificationService extends Service<Notification> {
|
|||||||
* @throws BaseApiException
|
* @throws BaseApiException
|
||||||
*/
|
*/
|
||||||
Integer readAllNotification() throws BaseApiException;
|
Integer readAllNotification() throws BaseApiException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除相关未读消息
|
||||||
|
* @param dataId
|
||||||
|
* @param dataType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Integer deleteUnreadNotification(Integer dataId, String dataType);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import com.rymcu.forest.entity.User;
|
|||||||
import com.rymcu.forest.lucene.service.LuceneService;
|
import com.rymcu.forest.lucene.service.LuceneService;
|
||||||
import com.rymcu.forest.mapper.ArticleMapper;
|
import com.rymcu.forest.mapper.ArticleMapper;
|
||||||
import com.rymcu.forest.service.ArticleService;
|
import com.rymcu.forest.service.ArticleService;
|
||||||
|
import com.rymcu.forest.service.NotificationService;
|
||||||
import com.rymcu.forest.service.TagService;
|
import com.rymcu.forest.service.TagService;
|
||||||
import com.rymcu.forest.service.UserService;
|
import com.rymcu.forest.service.UserService;
|
||||||
import com.rymcu.forest.util.*;
|
import com.rymcu.forest.util.*;
|
||||||
@ -43,6 +44,8 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
|||||||
private UserService userService;
|
private UserService userService;
|
||||||
@Resource
|
@Resource
|
||||||
private LuceneService luceneService;
|
private LuceneService luceneService;
|
||||||
|
@Resource
|
||||||
|
private NotificationService notificationService;
|
||||||
|
|
||||||
@Value("${resource.domain}")
|
@Value("${resource.domain}")
|
||||||
private String domain;
|
private String domain;
|
||||||
@ -257,6 +260,8 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
|||||||
articleMapper.deleteTagArticle(id);
|
articleMapper.deleteTagArticle(id);
|
||||||
// 删除文章内容表
|
// 删除文章内容表
|
||||||
articleMapper.deleteArticleContent(id);
|
articleMapper.deleteArticleContent(id);
|
||||||
|
// 删除相关未读消息
|
||||||
|
notificationService.deleteUnreadNotification(id, NotificationConstant.PostArticle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -77,4 +77,9 @@ public class NotificationServiceImpl extends AbstractService<Notification> imple
|
|||||||
public Integer readAllNotification() throws BaseApiException {
|
public Integer readAllNotification() throws BaseApiException {
|
||||||
return notificationMapper.readAllNotification(Objects.requireNonNull(UserUtils.getCurrentUserByToken()).getIdUser());
|
return notificationMapper.readAllNotification(Objects.requireNonNull(UserUtils.getCurrentUserByToken()).getIdUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer deleteUnreadNotification(Integer dataId, String dataType) {
|
||||||
|
return notificationMapper.deleteUnreadNotification(dataId, dataType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ public class TransactionRecordServiceImpl extends AbstractService<TransactionRec
|
|||||||
@Override
|
@Override
|
||||||
public List<TransactionRecordDTO> findTransactionRecords(String bankAccount, String startDate, String endDate) {
|
public List<TransactionRecordDTO> findTransactionRecords(String bankAccount, String startDate, String endDate) {
|
||||||
List<TransactionRecordDTO> list = transactionRecordMapper.selectTransactionRecords(bankAccount, startDate, endDate);
|
List<TransactionRecordDTO> list = transactionRecordMapper.selectTransactionRecords(bankAccount, startDate, endDate);
|
||||||
list.forEach(transactionRecordDTO -> genTransactionRecord(transactionRecordDTO));
|
list.forEach(this::genTransactionRecord);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,9 @@
|
|||||||
<update id="readAllNotification">
|
<update id="readAllNotification">
|
||||||
update forest_notification set has_read = '1' where id_user = #{idUser} and has_read = '0'
|
update forest_notification set has_read = '1' where id_user = #{idUser} and has_read = '0'
|
||||||
</update>
|
</update>
|
||||||
|
<delete id="deleteUnreadNotification">
|
||||||
|
delete from forest_notification where has_read = '0' and data_id = #{dataId} and data_type = #{dataType}
|
||||||
|
</delete>
|
||||||
<select id="selectUnreadNotifications" resultMap="BaseResultMapper">
|
<select id="selectUnreadNotifications" resultMap="BaseResultMapper">
|
||||||
select * from forest_notification where has_read = '0' and id_user = #{idUser} order by created_time desc
|
select * from forest_notification where has_read = '0' and id_user = #{idUser} order by created_time desc
|
||||||
</select>
|
</select>
|
||||||
|
Loading…
Reference in New Issue
Block a user