Update修改方法判断该ID的数据是否超过24小时,超过不许修改
@PostMapping("/update") public Result projectUpdate(@RequestBody ProjectVoEntity projectvo) throws ParseException { //获取项目id ProjectEntity project = projectService.selectById(projectvo.getProjectid()); //获取项目分类id ClassesEntity ce = classesService.selectById(projectvo.getClassid()); //判断项目id是否存在 if(project!=null) { //时间转换 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //获取创建时间 Date ss=project.getCretime(); //Date转String String sstr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(ss); //创建时间 Date stt = sdf.parse(sstr); //当前时间 Date sttt = new Date(); //当前时间减去创建时间 long cha = sttt.getTime() - stt.getTime(); boolean flag; if(cha<0){ flag= false; } double result = cha * 1.0 / (1000 * 60 * 60); if(result<=24){ project.setProjectid(projectvo.getProjectid()); project.setPname(projectvo.getPname()); //修改项目分类id project.setClassid(ce.getClassid()); project.setStartday(sdf.parse(projectvo.getStartday())); project.setEndday(sdf.parse(projectvo.getStartday())); project.setProanalysis(projectvo.getProanalysis()); project.setUnderent(projectvo.getUnderent()); project.setBudgetmoney(new BigDecimal(projectvo.getBudgetmoney())); project.setProschedule(projectvo.getProschedule()); project.setProplan(projectvo.getProplan()); project.setYear(projectvo.getYear()); project.setEditstate("true"); projectService.updateById(project); flag= true; }else{ flag= false; project.setEditstate("false"); projectService.updateById(project); return Result.error("false"); } }else { return Result.error("项目ID不存在"); } return Result.ok(); }