From ead4b8891fbe360aa3268492fdaecd22456107db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9C=86=E4=BC=9F?= <1489339700@qq.com> Date: Wed, 17 Aug 2022 16:09:19 +0800 Subject: [PATCH] 11 --- .../controller/EncyclopediaController.java | 19 +++++---- .../irs/mapper/EncyclopediaMapper.java | 12 +++--- .../sixteam/irs/mapper/EncyclopediaMapper.xml | 41 +++++++++++++++++++ ...\345\221\212\351\241\265\351\235\242.html" | 9 ++-- ...\345\221\212\351\241\265\351\235\242.html" | 7 ++-- ...\347\247\221\351\241\265\351\235\242.html" | 14 +++---- 6 files changed, 74 insertions(+), 28 deletions(-) create mode 100644 src/main/resources/com/sixteam/irs/mapper/EncyclopediaMapper.xml diff --git a/src/main/java/com/sixteam/irs/controller/EncyclopediaController.java b/src/main/java/com/sixteam/irs/controller/EncyclopediaController.java index 44701d5..d0db837 100644 --- a/src/main/java/com/sixteam/irs/controller/EncyclopediaController.java +++ b/src/main/java/com/sixteam/irs/controller/EncyclopediaController.java @@ -16,7 +16,7 @@ import javax.servlet.http.HttpServletRequest; import java.util.List; @Controller -@RequestMapping(value = "/ee") +@RequestMapping( "/ee") public class EncyclopediaController { @Autowired private EncyclopediaService encyclopediaService; @@ -24,7 +24,7 @@ public class EncyclopediaController { - @RequestMapping(value = "/list") + @RequestMapping( "/list") public String list(Model model,@RequestParam(defaultValue = "1", required = true, value = "pageNo") Integer pageNo) { Integer pageSize = 4;//每页显示记录数 @@ -36,14 +36,14 @@ public class EncyclopediaController { return "/test/encyclopedia/职场百科页面.html"; } - @RequestMapping(value = "/toAdd") + @RequestMapping( "/toAdd") public String toAdd(Integer encId, HttpServletRequest request) { System.out.println(encId); return "/test/encyclopedia/添加公告页面.html"; } - @RequestMapping(value = "/add") + @RequestMapping( "/add") public ModelAndView add(Encyclopedia encyclopedia) { ModelAndView nav = new ModelAndView(); @@ -61,7 +61,7 @@ public class EncyclopediaController { return nav; } - @RequestMapping(value = "/del") + @RequestMapping( "/del") public String del(Integer encId, HttpServletRequest request) { int res = encyclopediaService.delEncyclopedia(encId); @@ -75,7 +75,7 @@ public class EncyclopediaController { } } - @RequestMapping(value = "/toUpdate") + @RequestMapping( "/toUpdate") public String toUpdate(Integer encId, HttpServletRequest request) { Encyclopedia encyclopedia = encyclopediaService.findById(encId); @@ -84,10 +84,12 @@ public class EncyclopediaController { return "/test/encyclopedia/修改公告页面.html"; } - @RequestMapping(value = "/update") + @RequestMapping( "/update") public String update(Encyclopedia encyclopedia, HttpServletRequest request) { + int res = encyclopediaService.updateEncyclopedia(encyclopedia); + if (res > 0) { return "redirect:/ee/list"; @@ -97,7 +99,7 @@ public class EncyclopediaController { } } - @RequestMapping(value = "/like") + @RequestMapping( "/like") public String like(ModelMap map, @RequestParam(defaultValue = "1", required = true, value = "pageNo") Integer pageNo, String encTitle) { @@ -106,6 +108,7 @@ public class EncyclopediaController { PageHelper.startPage(pageNo, pageSize); List encyclopediaList = encyclopediaService.findEncyclopediaByLike(encTitle);//获取所有用户信息 PageInfo pageInfo = new PageInfo(encyclopediaList); + map.addAttribute("pageInfo", pageInfo); return "/test/encyclopedia/职场百科页面.html"; diff --git a/src/main/java/com/sixteam/irs/mapper/EncyclopediaMapper.java b/src/main/java/com/sixteam/irs/mapper/EncyclopediaMapper.java index 002e862..54cc63b 100644 --- a/src/main/java/com/sixteam/irs/mapper/EncyclopediaMapper.java +++ b/src/main/java/com/sixteam/irs/mapper/EncyclopediaMapper.java @@ -10,16 +10,16 @@ import java.util.List; @Mapper public interface EncyclopediaMapper { - @Insert("INSERT INTO irs_encyclopedia VALUES (NULL, #{encTitle}, #{encContent}, NULL)") + int add(Encyclopedia encyclopedia); - @Delete("delete from irs_encyclopedia where encId = #{encId}") + int del(Integer encId); - @Update("update irs_encyclopedia set encTitle = #{encTitle}, encContext = #{encContext}, time =#{encTime} where encId = #{encId} ") + int update(Encyclopedia encyclopedia); - @Select("select * from irs_encyclopedia where encId = #{encId}") + Encyclopedia getById(Integer encId); - @Select("select * from irs_encyclopedia") + List getAllEncyclopedias(); - @Select("select * from irs_encyclopedia where encTitle like '%' #{encTitle} '%' ") + List getEncyclopediaByLike(String encTitle); } diff --git a/src/main/resources/com/sixteam/irs/mapper/EncyclopediaMapper.xml b/src/main/resources/com/sixteam/irs/mapper/EncyclopediaMapper.xml new file mode 100644 index 0000000..cb92776 --- /dev/null +++ b/src/main/resources/com/sixteam/irs/mapper/EncyclopediaMapper.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + insert into irs_encyclopedia (enc_id,enc_title,enc_context,enc_time) + values (#{encId},#{encTitle},#{encContext},#{encTime}) + + + + delete from irs_encyclopedia where enc_id = #{encId} + + + + update irs_encyclopedia + + enc_title = #{encTitle}, + enc_context = #{encContext}, + enc_time = #{encTime}, + + where enc_id = #{encId} + + \ No newline at end of file diff --git "a/src/main/resources/templates/test/encyclopedia/\344\277\256\346\224\271\345\205\254\345\221\212\351\241\265\351\235\242.html" "b/src/main/resources/templates/test/encyclopedia/\344\277\256\346\224\271\345\205\254\345\221\212\351\241\265\351\235\242.html" index 126b0c2..233b1da 100644 --- "a/src/main/resources/templates/test/encyclopedia/\344\277\256\346\224\271\345\205\254\345\221\212\351\241\265\351\235\242.html" +++ "b/src/main/resources/templates/test/encyclopedia/\344\277\256\346\224\271\345\205\254\345\221\212\351\241\265\351\235\242.html" @@ -1,5 +1,5 @@ - + Title @@ -8,9 +8,10 @@

修改公告页面

- - 标题:
- 内容:
+ + 标题:
+ 内容:
+ 时间:
diff --git "a/src/main/resources/templates/test/encyclopedia/\346\267\273\345\212\240\345\205\254\345\221\212\351\241\265\351\235\242.html" "b/src/main/resources/templates/test/encyclopedia/\346\267\273\345\212\240\345\205\254\345\221\212\351\241\265\351\235\242.html" index f37f810..3d0c57a 100644 --- "a/src/main/resources/templates/test/encyclopedia/\346\267\273\345\212\240\345\205\254\345\221\212\351\241\265\351\235\242.html" +++ "b/src/main/resources/templates/test/encyclopedia/\346\267\273\345\212\240\345\205\254\345\221\212\351\241\265\351\235\242.html" @@ -6,10 +6,11 @@

添加公告

-
+ + Id:
标题:
- 内容:
- 时间:
+ 内容:
+ 时间:
diff --git "a/src/main/resources/templates/test/encyclopedia/\350\201\214\345\234\272\347\231\276\347\247\221\351\241\265\351\235\242.html" "b/src/main/resources/templates/test/encyclopedia/\350\201\214\345\234\272\347\231\276\347\247\221\351\241\265\351\235\242.html" index e9bc0ec..34c3347 100644 --- "a/src/main/resources/templates/test/encyclopedia/\350\201\214\345\234\272\347\231\276\347\247\221\351\241\265\351\235\242.html" +++ "b/src/main/resources/templates/test/encyclopedia/\350\201\214\345\234\272\347\231\276\347\247\221\351\241\265\351\235\242.html" @@ -23,14 +23,14 @@ 时间 操作 - - id(遍历的值) - 标题(遍历的值) - 内容(遍历的值) - 时间(遍历的值) + + id(遍历的值) + 标题(遍历的值) + 内容(遍历的值) + 时间(遍历的值) - 删除 - 修改 + 删除 + 修改 -- Gitee