From d45e39b06c2daf3ec956679dac72adf70ee31959 Mon Sep 17 00:00:00 2001 From: zy <3308399775@qq.com> Date: Tue, 21 May 2024 23:43:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=8F=91=E8=AF=BE=E7=A8=8B=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=EF=BC=8C=E7=BC=96=E8=BE=91=EF=BC=8C=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/controller/CourseController.java | 36 ++++++-- .../java/com/example/mapper/CourseMapper.java | 10 +++ .../com/example/service/CourseService.java | 12 +++ .../example/controller/CourseController.class | Bin 1611 -> 2598 bytes .../com/example/mapper/CourseMapper.class | Bin 583 -> 1169 bytes .../com/example/service/CourseService.class | Bin 1498 -> 1908 bytes vue/src/views/manager/Course.vue | 78 +++++++++++++++++- 7 files changed, 126 insertions(+), 10 deletions(-) diff --git a/springboot/src/main/java/com/example/controller/CourseController.java b/springboot/src/main/java/com/example/controller/CourseController.java index 96fc022..de5e84e 100644 --- a/springboot/src/main/java/com/example/controller/CourseController.java +++ b/springboot/src/main/java/com/example/controller/CourseController.java @@ -4,10 +4,7 @@ import com.example.common.Result; import com.example.entity.Course; import com.example.service.CourseService; import com.github.pagehelper.PageInfo; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -17,12 +14,39 @@ public class CourseController { @Resource private CourseService courseService; - - @GetMapping("/selectPage") + /** + * 分页条件查询课程 + */ + @GetMapping("/selectPage") public Result selectPage(@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "5") Integer pageSize, Course course){ PageInfo pageInfo = courseService.selectPage(pageNum, pageSize,course); return Result.success(pageInfo); } + /** + * 新增课程 + */ + @PostMapping("/add") + public Result add(@RequestBody Course course){ + courseService.add(course); + return Result.success(); + } + /** + * 更新课程 + */ + @PutMapping("/update") + public Result update(@RequestBody Course course){ + courseService.updateById(course); + return Result.success(); + } + + /** + * 删除课程 + */ + @DeleteMapping("/delete/{id}") + public Result delete(@PathVariable Integer id){ + courseService.deleteById(id); + return Result.success(); + } } diff --git a/springboot/src/main/java/com/example/mapper/CourseMapper.java b/springboot/src/main/java/com/example/mapper/CourseMapper.java index 747d961..c856804 100644 --- a/springboot/src/main/java/com/example/mapper/CourseMapper.java +++ b/springboot/src/main/java/com/example/mapper/CourseMapper.java @@ -1,11 +1,21 @@ package com.example.mapper; import com.example.entity.Course; +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; import java.util.List; public interface CourseMapper { @Select("select * from course where name like concat('%',#{name},'%') and no like concat('%',#{no},'%') and teacher like concat('%',#{teacher},'%') order by id desc") List selectAll(Course course); + @Insert("insert into course (name, no, descr, times, teacher) values(#{name},#{no},#{descr},#{times},#{teacher})") + void insert(Course course); + @Update("update course set name=#{name},no=#{no},descr=#{descr},times=#{times},teacher=#{teacher} where id=#{id}") + void updateById(Course course); + + @Delete("delete from course where id=#{id}") + void deleteById(Integer id); } diff --git a/springboot/src/main/java/com/example/service/CourseService.java b/springboot/src/main/java/com/example/service/CourseService.java index 65b3425..fdd3b7e 100644 --- a/springboot/src/main/java/com/example/service/CourseService.java +++ b/springboot/src/main/java/com/example/service/CourseService.java @@ -21,4 +21,16 @@ public class CourseService { List coursesList = courseMapper.selectAll(course); return PageInfo.of(coursesList); } + //新增数据 + public void add(Course course) { + courseMapper.insert(course); + } + + public void updateById(Course course) { + courseMapper.updateById(course); + } + + public void deleteById(Integer id) { + courseMapper.deleteById(id); + } } diff --git a/springboot/target/classes/com/example/controller/CourseController.class b/springboot/target/classes/com/example/controller/CourseController.class index 94503c77670fdd0f7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W1|ChBJ^kgYHR;CN4aH-oZ1t(TxeQ zrXg|BfAwEoReyIsHa?>E`{eZv$QXq9bSijsLwcNq^f?VU3pgJSCU)`bKD4St5dm`n z7ZEX8z-7c0*A~g>D=B`w?;*QN@Rev`mr`Lxoi7Z9wooamHFbTVCG^r4tg$(+tCnI| zU|zM9N}z60Xld#at})*WJ#lgRgx%@(o^fv6;xniY%ZyN?U|s&E$;qbLS&m#ZST@-) zE83Onm{rzr&799 diff --git a/springboot/target/classes/com/example/mapper/CourseMapper.class b/springboot/target/classes/com/example/mapper/CourseMapper.class index 22cafae8f7f78b5d8eb7c5750b7ad43f380a00fe..823ca9cf8f500cfa4eee1fd0c46b4b705d58be5e 100644 GIT binary patch delta 518 zcmZ`$yG{c!5L}<~P=W~I6`lbHnw&T(4P8WoXilOf4V4uy;ZWj3=SvVmQNH1no-d%G zrJzOPAK+6EYu_b6L1FKBcRVw)-*QQ*`u_Fu3INAYFTzd{cAu+{tXv3`#wcd6m+aSB zC;2#-__ot#&`W1LP;tn+;V{z3n@SAO<0|yHMBR-%9tQ)|R8VxUF>?7x^oOXMhYyB1 z_Naztw`>C}--7hU*kw>2-bxYU>Af#m^4XYN*rSP%4rcBeV{T+mX6h<5kPNIm;mpRG z&@nU1!kI>9%I_#F@<38AkYkDzog4c33uYQNMr=Cn;hTQqTC`x}Ifh}8f9 delta 46 zcmbQpd7MSy)W2Q(7#J8#7zEiF_}Li*HVVvRoZQSD&&W9WF|$4w10w@3P@0K>4*({Z B3DN)n diff --git a/springboot/target/classes/com/example/service/CourseService.class b/springboot/target/classes/com/example/service/CourseService.class index 039fad0be8d1e0d8929116d7c13cbec5ea1d45e1..3548b73042ffff591a64c5820f4c90c13304da87 100644 GIT binary patch delta 731 zcma)($xZ@65QhI5z|ol&cSOO#9mECq1@~Qy#+&y^WSez!h@%dcP0F94>oZ^FWui4?|7OklDOCZ;SFW=zat zPDb<6EJ%|!uxMcEe(YAS^*OGq!A=zKv`BjBSc7?W?mBsI<0iwr>3U~gWfMvqoI2M| z>deVyQ<+@e%X$}!vPC~}i*NeTTqBwcEDNk))xes-IyM9Z>J4lPY+>8Lj=(PV1Tq*D zh)a{e(8HlGt4(RBImumm7kTt>c8j+nSa#C~xvQaXpbyaVAll~Qhd&f=Dc3+{D`UZm zRJ9>Qub~}b_^6EpQU$3EatA5}6=7;*&ouRbUG9-l2RaqUMud^Bs!?>YH_S^PF@S<90r O)s=^p9r^j=QQ#ZdBSLTh delta 344 zcmX|+Ia0$w6hz;Q5MxW@1S32vbikdnCws3PD1&PX{2F-1$J z2!8kfJ^g#?f7id_!Q|)t1IQRgRM?H!V?UzDK@~?o=8&U^V+M}YaWWph*!&@Q?A53{ zPCaLwJ2KA&m!2w-+9J!iJ_)Y{X&z z4KpsEo5I43Y;!_CH84+0lVO2H0vh>qn3`t(8MdAZS4JpI{#-@3#B#Zr&{k*5*A6S% nZ7YA3HD*|sTI5faL`qjmEzmL&p`+SRSzTq>D!c9fdv@R#_J106 diff --git a/vue/src/views/manager/Course.vue b/vue/src/views/manager/Course.vue index d754e77..6d612d2 100644 --- a/vue/src/views/manager/Course.vue +++ b/vue/src/views/manager/Course.vue @@ -8,7 +8,7 @@
- 新 增 + 新 增
@@ -20,8 +20,8 @@ @@ -31,12 +31,39 @@ @current-change = "handleCurrentChange" background layout="prev, pager, next" :total="data.total" />
+ + + + + + + + + + + + + + + + + + + / + +
\ No newline at end of file