diff --git a/ruoyi-cms/src/main/java/com/ruoyi/cms/controller/CmsUserController.java b/ruoyi-cms/src/main/java/com/ruoyi/cms/controller/CmsUserController.java index a8cffac27..3e8eb886b 100644 --- a/ruoyi-cms/src/main/java/com/ruoyi/cms/controller/CmsUserController.java +++ b/ruoyi-cms/src/main/java/com/ruoyi/cms/controller/CmsUserController.java @@ -31,10 +31,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; import sun.awt.image.IntegerComponentRaster; @@ -49,6 +46,7 @@ import java.util.List; */ @Controller @RequestMapping("/web") +@SessionAttributes("user") public class CmsUserController { private static final Logger log = LoggerFactory.getLogger( CmsUserController.class ); @@ -110,6 +108,7 @@ public class CmsUserController { @RequestMapping("/user/index.html") public String webUserIndex(ModelMap map) { map.put( "user", ShiroUtils.getSysUser() ); + map.addAttribute("user", ShiroUtils.getSysUser()); return prefix + "/user/set"; } @RequestMapping("/user/home.html") @@ -168,8 +167,11 @@ public class CmsUserController { @ResponseBody public AjaxResult addCollectionquestion(String questionId) { SysUser sysUser = ShiroUtils.getSysUser(); - examUserCollectionQuestionService.insertSelectiveBySelf(Integer.parseInt(questionId),sysUser); - AjaxResult success = AjaxResult.success("插入成功"); + int i = examUserCollectionQuestionService.insertSelectiveBySelf(Integer.parseInt(questionId), sysUser); + AjaxResult success = AjaxResult.success("收藏成功"); + if(i==0){ + success = AjaxResult.success("已收藏,无法重复收藏"); + } return success; } diff --git a/ruoyi-cms/src/main/resources/templates/web/index.html b/ruoyi-cms/src/main/resources/templates/web/index.html index b478938e1..0018e7cdb 100644 --- a/ruoyi-cms/src/main/resources/templates/web/index.html +++ b/ruoyi-cms/src/main/resources/templates/web/index.html @@ -173,19 +173,19 @@
diff --git a/ruoyi-cms/src/main/resources/templates/web/practice/detail.html b/ruoyi-cms/src/main/resources/templates/web/practice/detail.html
index f12914a12..05b056342 100644
--- a/ruoyi-cms/src/main/resources/templates/web/practice/detail.html
+++ b/ruoyi-cms/src/main/resources/templates/web/practice/detail.html
@@ -105,6 +105,8 @@ document.write(unescape("%3Cspan id='cnzz_stat_icon_30088308'%3E%3C/span%3E%3Csc
success: function (result) {
if (result.code != web_status.SUCCESS) {
layer.msg(result.msg, {icon: 2});
+ }else{
+ layer.msg(result.msg, {icon: 1});
}
}
});
diff --git a/ruoyi-exam/src/main/java/com/ruoyi/exam/service/impl/ExamUserCollectionQuestionServiceImpl.java b/ruoyi-exam/src/main/java/com/ruoyi/exam/service/impl/ExamUserCollectionQuestionServiceImpl.java
index f798d7b89..787dc69b8 100644
--- a/ruoyi-exam/src/main/java/com/ruoyi/exam/service/impl/ExamUserCollectionQuestionServiceImpl.java
+++ b/ruoyi-exam/src/main/java/com/ruoyi/exam/service/impl/ExamUserCollectionQuestionServiceImpl.java
@@ -52,6 +52,10 @@ public class ExamUserCollectionQuestionServiceImpl extends AbstractBaseServiceIm
ExamUserCollectionQuestion examUserCollectionQuestion = new ExamUserCollectionQuestion();
examUserCollectionQuestion.setExamQuestionId( questionId );
examUserCollectionQuestion.setVipUserId( sysUser.getUserId().intValue() );
+ List