From ec30014e3aac9c6b8ff5afe8f9bed28c36b2c738 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=A3=95?= <1798488403@qq.com> Date: Sun, 27 Nov 2022 14:16:52 +0800 Subject: [PATCH] finally --- src/demo/pom.xml | 12 +++++++++ .../com/example/demo/config/MyMvcConfig.java | 11 ++++++-- .../demo/controller/TaskuploadController.java | 13 ++++++---- .../demo/controller/UserController.java | 5 +--- .../demo/controller/Webcontroller.java | 24 ++++++++++++++++-- .../com/example/demo/controller/Webneed.java | 18 ++++++++----- .../com/example/demo/domain/Dragonson.java | 3 ++- .../java/com/example/demo/domain/Rcode.java | 9 +++++++ .../src/main/resources/templates/list.html | 2 +- .../resources/templates/task/groupdetail.html | 10 +++++--- .../templates/task/groupnoteeditlist.html | 2 +- .../templates/task/groupnotelist.html | 2 +- .../templates/task/groupnoteupdate.html | 4 +-- .../resources/templates/task/taskdetail.html | 6 +++-- .../templates/task/taskeditlist.html | 4 +-- .../resources/templates/task/tasklist.html | 6 ++--- .../resources/templates/task/taskupdate.html | 4 +-- .../main/resources/templates/user/update.html | 4 +-- .../demo/controller/Webcontroller.class | Bin 11174 -> 11477 bytes src/demo/target/classes/templates/list.html | 2 +- src/demo/班级通1.0 | 1 - 21 files changed, 99 insertions(+), 43 deletions(-) delete mode 160000 src/demo/班级通1.0 diff --git a/src/demo/pom.xml b/src/demo/pom.xml index 57e8046..b5e78aa 100644 --- a/src/demo/pom.xml +++ b/src/demo/pom.xml @@ -2,6 +2,18 @@ 4.0.0 + + + sonar + + true + + + http://127.0.0.1:9000 + + + + org.springframework.boot spring-boot-starter-parent diff --git a/src/demo/src/main/java/com/example/demo/config/MyMvcConfig.java b/src/demo/src/main/java/com/example/demo/config/MyMvcConfig.java index e7bf9fc..d62662d 100644 --- a/src/demo/src/main/java/com/example/demo/config/MyMvcConfig.java +++ b/src/demo/src/main/java/com/example/demo/config/MyMvcConfig.java @@ -1,6 +1,7 @@ package com.example.demo.config; import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @@ -8,7 +9,13 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; public class MyMvcConfig implements WebMvcConfigurer { @Override public void addViewControllers(ViewControllerRegistry registry) { - registry.addViewController("/").setViewName("index"); - registry.addViewController("/index.html").setViewName("index"); + registry.addViewController("/").setViewName("index"); + registry.addViewController("/index.html").setViewName("index"); + } + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(new LoginHandleInterceptor()).addPathPatterns("/resource").excludePathPatterns("/index.html","dashboard","/","/login","/css/**","/js/**","/img/**"); + } } diff --git a/src/demo/src/main/java/com/example/demo/controller/TaskuploadController.java b/src/demo/src/main/java/com/example/demo/controller/TaskuploadController.java index 4203300..d51ac48 100644 --- a/src/demo/src/main/java/com/example/demo/controller/TaskuploadController.java +++ b/src/demo/src/main/java/com/example/demo/controller/TaskuploadController.java @@ -42,7 +42,7 @@ public class TaskuploadController { @RequestParam(name = "skey", required = true) String skey, @RequestParam(name = "Task_id", required = true) Integer Taskid) { //skey 查表 - + System.out.println(skey); QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.like("skey", skey); User user = this.userMapper.selectOne(queryWrapper); @@ -103,9 +103,10 @@ public class TaskuploadController { } - @RequestMapping("/uploadDragon") - public String uploaddragon(@RequestParam(name = "skey", required = true) String skey, - @RequestParam(name = "dragonid", required = true) int dragonid, + @RequestMapping(value = "/uploadDragon",method = RequestMethod.POST) + public String uploaddragon(HttpServletRequest request, + @RequestParam(name = "skey", required = true) String skey, + @RequestParam(name = "dragonid", required = true) Integer dragonid, @RequestParam(name = "text", required = true) String text) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.like("skey", skey); @@ -120,8 +121,10 @@ public class TaskuploadController { dragonson.setStudentnumber(user.getStudentNumber()); this.dragonsonMapper.insert(dragonson); } - dragonson.setText(text); + System.out.println(text); + dragonson = this.dragonsonMapper.selectOne(queryWrapper1); dragonson.setFinishtime(new Date()); + dragonson.setText(text); this.dragonsonMapper.updateById(dragonson); return "success"; diff --git a/src/demo/src/main/java/com/example/demo/controller/UserController.java b/src/demo/src/main/java/com/example/demo/controller/UserController.java index dd8bfd5..0897ac8 100644 --- a/src/demo/src/main/java/com/example/demo/controller/UserController.java +++ b/src/demo/src/main/java/com/example/demo/controller/UserController.java @@ -21,10 +21,6 @@ import java.util.*; @Tag(name = "真·用户接口", description = "用户登录,") @RestController public class UserController { - @RequestMapping("/index") - public String first() { - return "index"; - } @Autowired private UserMapper userMapper; @@ -131,6 +127,7 @@ public class UserController { @Operation(summary = "获取验证码") public String getrcode(@RequestParam(value = "skey", required = true) String skey) { Rcode rcode = this.rcodeMapper.selectById(skey); + System.out.println(rcode); String code = ""; if (rcode == null) { rcode = new Rcode(); diff --git a/src/demo/src/main/java/com/example/demo/controller/Webcontroller.java b/src/demo/src/main/java/com/example/demo/controller/Webcontroller.java index f320d04..21eb091 100644 --- a/src/demo/src/main/java/com/example/demo/controller/Webcontroller.java +++ b/src/demo/src/main/java/com/example/demo/controller/Webcontroller.java @@ -184,6 +184,16 @@ public class Webcontroller { List taskson=this.tasksonMapper.selectList(queryWrapper); // System.out.println(taskson); + /* + 完成人数 + */ + int stunum_complete=taskson.size(); + model.addAttribute("stunum_com",stunum_complete); + QueryWrapperqueryWrapper1 = new QueryWrapper<>(); + queryWrapper1.select(); + List users=this.userMapper.selectList(queryWrapper1); + int stunum= users.size(); + model.addAttribute("stunum",stunum); model.addAttribute("taskdetail",taskson); return "task/taskdetail"; @@ -203,10 +213,20 @@ public class Webcontroller { 并根据子表获取详细信息 */ QueryWrapperqueryWrapper = new QueryWrapper<>(); - queryWrapper.select("task_id","studentnumber","finishtime","filepath").like("task_id", id); + queryWrapper.select("dragon_id","studentnumber","finishtime","text").like("dragon_id", id); List groupson=this.dragonsonMapper.selectList(queryWrapper); - System.out.println(groupson); + /* + 完成人数 + */ + int stunum_complete=groupson.size(); + model.addAttribute("stunum_com",stunum_complete); + QueryWrapperqueryWrapper1 = new QueryWrapper<>(); + queryWrapper1.select(); + List users=this.userMapper.selectList(queryWrapper1); + int stunum= users.size(); + model.addAttribute("stunum",stunum); +// System.out.println(groupson); model.addAttribute("groupdetail",groupson); return "task/groupdetail"; diff --git a/src/demo/src/main/java/com/example/demo/controller/Webneed.java b/src/demo/src/main/java/com/example/demo/controller/Webneed.java index ed028ad..1d9889d 100644 --- a/src/demo/src/main/java/com/example/demo/controller/Webneed.java +++ b/src/demo/src/main/java/com/example/demo/controller/Webneed.java @@ -2,6 +2,7 @@ package com.example.demo.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.example.demo.common.ZipUtils; import com.example.demo.domain.Dragonson; import com.example.demo.domain.User; import com.example.demo.mapper.DragonsonMapper; @@ -10,6 +11,7 @@ import org.apache.poi.hssf.usermodel.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; 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.RequestParam; @@ -24,8 +26,8 @@ public class Webneed { @Autowired DragonsonMapper dragonsonMapper; - @GetMapping("/exceldownload") - public void download(HttpServletResponse response, @RequestParam(value = "dragonid", required = false) String dragonid) throws IOException { + @GetMapping("/exceldownload/{id}") + public void download(HttpServletResponse response, @PathVariable("id") String dragonid) throws IOException { HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("接龙情况"); QueryWrapper queryWrapper = new QueryWrapper<>(); @@ -64,9 +66,11 @@ public class Webneed { return "daochu"; } - @RequestMapping("/filedownload") - public String downloadfile(@RequestParam(value = "taskid", required = true) String taskid, - HttpServletResponse response) throws UnsupportedEncodingException { + @RequestMapping("/filedownload/{id}") + public String downloadfile(@PathVariable("id") String taskid, + HttpServletResponse response) throws UnsupportedEncodingException, FileNotFoundException { + FileOutputStream fos1 = new FileOutputStream(new File( taskid+".zip")); + ZipUtils.toZip("E:\\git\\project\\src\\demo\\target\\"+taskid, fos1, true); File scFileDir = new File("./"); String fileName = taskid + ".zip"; File fileDir = new File(scFileDir, fileName); @@ -90,9 +94,9 @@ public class Webneed { os.write(buffer, 0, i); i = bis.read(buffer); } - System.out.println("Download the song successfully!"); + System.out.println("Download successfully!"); } catch (Exception e) { - System.out.println("Download the song failed!"); + System.out.println("Download failed!"); } finally { if (bis != null) { try { diff --git a/src/demo/src/main/java/com/example/demo/domain/Dragonson.java b/src/demo/src/main/java/com/example/demo/domain/Dragonson.java index 1fe88e2..d071276 100644 --- a/src/demo/src/main/java/com/example/demo/domain/Dragonson.java +++ b/src/demo/src/main/java/com/example/demo/domain/Dragonson.java @@ -1,6 +1,7 @@ package com.example.demo.domain; import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.segments.MergeSegments; @@ -15,7 +16,7 @@ public class Dragonson extends Wrapper { /** * id */ - @TableField("id") + @TableId("id") private int id; /** * dragon_id diff --git a/src/demo/src/main/java/com/example/demo/domain/Rcode.java b/src/demo/src/main/java/com/example/demo/domain/Rcode.java index 76e467e..ed05862 100644 --- a/src/demo/src/main/java/com/example/demo/domain/Rcode.java +++ b/src/demo/src/main/java/com/example/demo/domain/Rcode.java @@ -1,9 +1,18 @@ package com.example.demo.domain; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + import java.util.Random; +@Data +@TableName("rcode") public class Rcode { + @TableField("code") private String code; + @TableId private String skey; public Rcode() { diff --git a/src/demo/src/main/resources/templates/list.html b/src/demo/src/main/resources/templates/list.html index 9415f6b..e46e412 100644 --- a/src/demo/src/main/resources/templates/list.html +++ b/src/demo/src/main/resources/templates/list.html @@ -48,7 +48,7 @@ diff --git a/src/demo/src/main/resources/templates/task/groupdetail.html b/src/demo/src/main/resources/templates/task/groupdetail.html index e95391d..bfdcea6 100644 --- a/src/demo/src/main/resources/templates/task/groupdetail.html +++ b/src/demo/src/main/resources/templates/task/groupdetail.html @@ -44,7 +44,7 @@