From d4054e37c9652239a8b183f288a441da930cad18 Mon Sep 17 00:00:00 2001 From: youahng <2998465706@qq.com> Date: Wed, 24 Jul 2024 10:52:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=8E=86=E5=8F=B2=E7=9F=A5?= =?UTF-8?q?=E8=AF=86=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 11 ++ .../controller/know/KnowController.java | 40 ----- .../know/KnowRelationshipController.java | 42 ----- .../backend/mapper/know/KnowMapper.java | 10 -- .../mapper/know/KnowRelationshipMapper.java | 18 -- .../model/dto/know/KnowQueryRequest.java | 19 -- .../backend/model/dto/know/KnowRequest.java | 48 ----- .../model/dto/know/KnowupdateRequest.java | 54 ------ .../backend/model/entity/courses/Main.java | 168 ++++++++++++++++++ .../backend/model/entity/know/Know.java | 66 ------- .../model/entity/know/KnowRelationship.java | 46 ----- .../impl/courses/CoursesServiceImpl.java | 20 +-- .../ObjectiveContentKnowServiceImpl.java | 32 ++-- .../know/KnowRelationshipServiceImpl.java | 21 --- .../service/impl/know/KnowServiceimpl.java | 50 ------ .../records/LearningRecordsServiceImpl.java | 7 +- .../know/IKnowRelationshipService.java | 16 -- .../backend/service/know/KnowService.java | 23 --- .../backend/utils/ParamOutAspect.java | 38 ++-- .../utils/getNullPropertyNamesUtil.java | 38 ++++ src/main/resources/application.yml | 5 + 21 files changed, 266 insertions(+), 506 deletions(-) delete mode 100644 src/main/java/com/teaching/backend/controller/know/KnowController.java delete mode 100644 src/main/java/com/teaching/backend/controller/know/KnowRelationshipController.java delete mode 100644 src/main/java/com/teaching/backend/mapper/know/KnowMapper.java delete mode 100644 src/main/java/com/teaching/backend/mapper/know/KnowRelationshipMapper.java delete mode 100644 src/main/java/com/teaching/backend/model/dto/know/KnowQueryRequest.java delete mode 100644 src/main/java/com/teaching/backend/model/dto/know/KnowRequest.java delete mode 100644 src/main/java/com/teaching/backend/model/dto/know/KnowupdateRequest.java create mode 100644 src/main/java/com/teaching/backend/model/entity/courses/Main.java delete mode 100644 src/main/java/com/teaching/backend/model/entity/know/Know.java delete mode 100644 src/main/java/com/teaching/backend/model/entity/know/KnowRelationship.java delete mode 100644 src/main/java/com/teaching/backend/service/impl/know/KnowRelationshipServiceImpl.java delete mode 100644 src/main/java/com/teaching/backend/service/impl/know/KnowServiceimpl.java delete mode 100644 src/main/java/com/teaching/backend/service/know/IKnowRelationshipService.java delete mode 100644 src/main/java/com/teaching/backend/service/know/KnowService.java create mode 100644 src/main/java/com/teaching/backend/utils/getNullPropertyNamesUtil.java diff --git a/pom.xml b/pom.xml index 4f5717c..c37861b 100644 --- a/pom.xml +++ b/pom.xml @@ -24,6 +24,17 @@ org.springframework.boot spring-boot-starter-web + + + org.neo4j.driver + neo4j-java-driver-spring-boot-starter + 4.3.6.0 + + + + org.springframework.boot + spring-boot-starter-data-neo4j + org.springframework.boot spring-boot-starter-aop diff --git a/src/main/java/com/teaching/backend/controller/know/KnowController.java b/src/main/java/com/teaching/backend/controller/know/KnowController.java deleted file mode 100644 index 2bb3859..0000000 --- a/src/main/java/com/teaching/backend/controller/know/KnowController.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.teaching.backend.controller.know; - -import com.teaching.backend.model.dto.know.KnowQueryRequest; -import com.teaching.backend.model.dto.know.KnowRequest; -import com.teaching.backend.model.dto.know.KnowupdateRequest; -import com.teaching.backend.model.entity.know.Know; -import com.teaching.backend.service.know.KnowService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * @Author:youhang - * @Date:2024-06-21-10:26 - * @Description: - */ -@RestController -@RequestMapping("/api/know") -public class KnowController { - - @Autowired - private KnowService knowService; - @PostMapping("/add") - public Boolean add(@RequestBody KnowRequest knowAddRequest) { - return knowService.add(knowAddRequest); - } - @PostMapping("/update") - public Boolean update(@RequestBody KnowupdateRequest knowAddRequest){ - return knowService.update(knowAddRequest); - } - @PostMapping("/delete") - public Integer deleteKnow(@RequestBody List ids){ - return knowService.deleteKnow(ids); - } - @PostMapping("/query") - public List query(@RequestBody KnowQueryRequest knowQueryRequest){ - return knowService.query(knowQueryRequest); - } -} diff --git a/src/main/java/com/teaching/backend/controller/know/KnowRelationshipController.java b/src/main/java/com/teaching/backend/controller/know/KnowRelationshipController.java deleted file mode 100644 index bf7ee78..0000000 --- a/src/main/java/com/teaching/backend/controller/know/KnowRelationshipController.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.teaching.backend.controller.know; - - -import com.teaching.backend.common.BaseResponse; -import com.teaching.backend.common.ResultUtils; -import com.teaching.backend.model.entity.know.Know; -import com.teaching.backend.model.entity.know.KnowRelationship; -import com.teaching.backend.service.know.IKnowRelationshipService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - *

- * 前端控制器 - *

- * - * @author author - * @since 2024-06-20 - */ -@Api(tags = "知识点章节关系") -@RestController -@RequestMapping("/know-relationship") -public class KnowRelationshipController { - - @Autowired - private IKnowRelationshipService knowRelationshipService; - @ApiOperation("添加课程知识点关系") - @PostMapping() - public BaseResponse add(@RequestBody KnowRelationship knowRelationship){ - boolean save = knowRelationshipService.save(knowRelationship); - return ResultUtils.success(save); - } - @GetMapping() - public BaseResponse> getAll(){ - List list = knowRelationshipService.list(); - return ResultUtils.success(list); - } -} diff --git a/src/main/java/com/teaching/backend/mapper/know/KnowMapper.java b/src/main/java/com/teaching/backend/mapper/know/KnowMapper.java deleted file mode 100644 index d6c2237..0000000 --- a/src/main/java/com/teaching/backend/mapper/know/KnowMapper.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.teaching.backend.mapper.know; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.teaching.backend.model.entity.know.Know; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface KnowMapper extends BaseMapper { - -} diff --git a/src/main/java/com/teaching/backend/mapper/know/KnowRelationshipMapper.java b/src/main/java/com/teaching/backend/mapper/know/KnowRelationshipMapper.java deleted file mode 100644 index 5756236..0000000 --- a/src/main/java/com/teaching/backend/mapper/know/KnowRelationshipMapper.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.teaching.backend.mapper.know; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.teaching.backend.model.entity.know.KnowRelationship; -import org.apache.ibatis.annotations.Mapper; - -/** - *

- * Mapper 接口 - *

- * - * @author author - * @since 2024-06-20 - */ -@Mapper -public interface KnowRelationshipMapper extends BaseMapper { - -} diff --git a/src/main/java/com/teaching/backend/model/dto/know/KnowQueryRequest.java b/src/main/java/com/teaching/backend/model/dto/know/KnowQueryRequest.java deleted file mode 100644 index fb42742..0000000 --- a/src/main/java/com/teaching/backend/model/dto/know/KnowQueryRequest.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.teaching.backend.model.dto.know; - -import lombok.Data; - -import java.io.Serializable; -import java.math.BigDecimal; - -/** - * 知识点请求 - */ -@Data -public class KnowQueryRequest implements Serializable { - - /** - * 知识点名称 - */ - private String name; - -} diff --git a/src/main/java/com/teaching/backend/model/dto/know/KnowRequest.java b/src/main/java/com/teaching/backend/model/dto/know/KnowRequest.java deleted file mode 100644 index 2da09bb..0000000 --- a/src/main/java/com/teaching/backend/model/dto/know/KnowRequest.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.teaching.backend.model.dto.know; - -import lombok.Data; - -import java.io.Serializable; -import java.math.BigDecimal; - -/** - * 知识点请求 - */ -@Data -public class KnowRequest implements Serializable { - - - /** - * 知识点名称 - */ - private String name; - - /** - * 简介 - */ - private String info; - - /** - * 知识点内容 - */ - private String content; - - /** - * 知识点图片 - */ - private String img; - - /** - * 知识点学时 - */ - private BigDecimal hour; - - - - /** - * 资源id 运用json - */ - private String resourceid; - - -} diff --git a/src/main/java/com/teaching/backend/model/dto/know/KnowupdateRequest.java b/src/main/java/com/teaching/backend/model/dto/know/KnowupdateRequest.java deleted file mode 100644 index bc339ea..0000000 --- a/src/main/java/com/teaching/backend/model/dto/know/KnowupdateRequest.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.teaching.backend.model.dto.know; - -import lombok.Data; - -import java.io.Serializable; -import java.math.BigDecimal; - -/** - * 知识点请求 - */ -@Data -public class KnowupdateRequest implements Serializable { - - - /** - * 知识点id - */ - private Integer id; - - - /** - * 知识点名称 - */ - private String name; - - /** - * 简介 - */ - private String info; - - /** - * 知识点内容 - */ - private String content; - - /** - * 知识点图片 - */ - private String img; - - /** - * 知识点学时 - */ - private BigDecimal hour; - - - - /** - * 资源id 运用json - */ - private String resourceid; - - -} diff --git a/src/main/java/com/teaching/backend/model/entity/courses/Main.java b/src/main/java/com/teaching/backend/model/entity/courses/Main.java new file mode 100644 index 0000000..539ef74 --- /dev/null +++ b/src/main/java/com/teaching/backend/model/entity/courses/Main.java @@ -0,0 +1,168 @@ +package com.teaching.backend.model.entity.courses; + +/** + * @Author:youhang + * @Date:2024-07-07-21:21 + * @Description: + */ + +import java.util.Scanner; + +class Num { + public int Zero = 0; + + public int One = 0; + + public int getZero() { + return Zero; + } + + public void setZero(int zero) { + Zero = zero; + } + + public int getOne() { + return One; + } + + public void setOne(int one) { + One = one; + } +} + +// 注意类名必须为 Main, 不要有任何 package xxx 信息 +public class Main { + public static void main(String[] args) { + Scanner in = new Scanner(System.in); + int n = in.nextInt(); + String[] arr = new String[n]; + int counts = 0; + Num num = new Num(); + for (int i = 0; i < n; i++) { + arr[i] = in.next(); + } + + int p = 1, q = 1; + while (p < n) { + if (arr[0].charAt(0) == '1') { + num.One += 1; + } else { + num.Zero += 1; + } + for (int i = 0; i <= p; i++) { + if (arr[i].charAt(p) == '1') { + num.One += 1; + } else { + num.Zero += 1; + } + if (arr[p].charAt(i) == '1') { + num.One += 1; + } else { + num.Zero += 1; + } + } + if (arr[p].charAt(p) == '1') { + num.One -= 1; + } else { + num.Zero -= 1; + } + if(num.Zero == num.One){ + counts++; + } + num.One = 0; + num.Zero = 0; + + if (arr[0].charAt(n-1) == '1') { + num.One += 1; + } else { + num.Zero += 1; + } + for (int i = 0; i <= p; i++) { + if (arr[i].charAt(n-1-p) == '1') { + num.One += 1; + } else { + num.Zero += 1; + } + if (arr[p].charAt(n-i-1) == '1') { + num.One += 1; + } else { + num.Zero += 1; + } + } + if (arr[p].charAt(n-p-1) == '1') { + num.One -= 1; + } else { + num.Zero -= 1; + } + if(num.Zero == num.One){ + counts++; + } + //左下 + num.One = 0; + num.Zero = 0; + + if (arr[n-1].charAt(0) == '1') { + num.One += 1; + } else { + num.Zero += 1; + } + for (int i = 0; i <= p; i++) { + if (arr[n-1-i].charAt(p) == '1') { + num.One += 1; + } else { + num.Zero += 1; + } + if (arr[n-p-1].charAt(i) == '1') { + num.One += 1; + } else { + num.Zero += 1; + } + } + if (arr[n-p-1].charAt(p) == '1') { + num.One -= 1; + } else { + num.Zero -= 1; + } + if(num.Zero == num.One){ + counts++; + } + + //右下 + num.One = 0; + num.Zero = 0; + + if (arr[n-1].charAt(n-1) == '1') { + num.One += 1; + } else { + num.Zero += 1; + } + for (int i = 0; i <= p; i++) { + if (arr[n-1-i].charAt(n-p-1) == '1') { + num.One += 1; + } else { + num.Zero += 1; + } + if (arr[n-p-1].charAt(n-1-i) == '1') { + num.One += 1; + } else { + num.Zero += 1; + } + } + if (arr[n-p-1].charAt(n-1-p) == '1') { + num.One -= 1; + } else { + num.Zero -= 1; + } + if(num.Zero == num.One){ + counts++; + } + + p++; + } + + + } + + +} + diff --git a/src/main/java/com/teaching/backend/model/entity/know/Know.java b/src/main/java/com/teaching/backend/model/entity/know/Know.java deleted file mode 100644 index 02199c4..0000000 --- a/src/main/java/com/teaching/backend/model/entity/know/Know.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.teaching.backend.model.entity.know; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.Api; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - - -import java.io.Serializable; -import java.math.BigDecimal; -import java.time.LocalDateTime; - -@Data -@EqualsAndHashCode(callSuper = false) -@Accessors(chain = true) -@TableName("know") -public class Know implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * id - */ - @TableId(value = "id", type = IdType.AUTO) - private Long id; - - /** - * 知识点名称 - */ - private String name; - - /** - * 简介 - */ - private String info; - - /** - * 知识点内容 - */ - private String content; - - /** - * 知识点图片 - */ - private String img; - - /** - * 知识点学时 - */ - private BigDecimal hour; - - - - /** - * 资源id 运用json - */ - private String resourceid; - - -} - diff --git a/src/main/java/com/teaching/backend/model/entity/know/KnowRelationship.java b/src/main/java/com/teaching/backend/model/entity/know/KnowRelationship.java deleted file mode 100644 index 2c073b3..0000000 --- a/src/main/java/com/teaching/backend/model/entity/know/KnowRelationship.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.teaching.backend.model.entity.know; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -import java.io.Serializable; - -/** - *

- * - *

- * - * @author author - * @since 2024-06-20 - */ -@Data -@EqualsAndHashCode(callSuper = false) -@Accessors(chain = true) -@TableName("know_relationship") -@ApiModel(value="KnowRelationship对象", description="") -public class KnowRelationship implements Serializable { - - private static final long serialVersionUID = 1L; - - - @ApiModelProperty(value = "章节id") - @TableField("chapterId") - private String chapterId; - - @ApiModelProperty(value = "课程id") - @TableField("courseId") - private String courseId; - - @ApiModelProperty(value = "知识点id") - @TableField("knowId") - private int knowId; - - -} diff --git a/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java index 1efe8c2..a104d6d 100644 --- a/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java @@ -12,7 +12,6 @@ import com.teaching.backend.common.ErrorCode; import com.teaching.backend.exception.BusinessException; import com.teaching.backend.mapper.chapter.ChapterMapper; import com.teaching.backend.mapper.courses.*; -import com.teaching.backend.mapper.know.KnowRelationshipMapper; import com.teaching.backend.mapper.records.LearningRecordsMapper; import com.teaching.backend.mapper.umsAdmin.UmsTeacherMapper; import com.teaching.backend.mapper.umsAdmin.UmsUserMapper; @@ -20,7 +19,6 @@ import com.teaching.backend.model.dto.courses.CoursesDTO; import com.teaching.backend.model.dto.courses.PageDTO; import com.teaching.backend.model.entity.chapter.Chapter; import com.teaching.backend.model.entity.courses.*; -import com.teaching.backend.model.entity.know.KnowRelationship; import com.teaching.backend.model.entity.records.LearningRecords; import com.teaching.backend.model.entity.umsAdmin.UmsTeacher; import com.teaching.backend.model.entity.umsAdmin.UmsUser; @@ -43,7 +41,6 @@ import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; -import java.util.stream.Stream; /** *

@@ -65,8 +62,6 @@ public class CoursesServiceImpl extends ServiceImpl impl @Autowired CoursesMapper coursesMapper; - @Autowired - KnowRelationshipMapper knowRelationshipMapper; @Autowired CourseObjectivesMapper courseObjectivesMapper; @@ -307,7 +302,7 @@ public class CoursesServiceImpl extends ServiceImpl impl coursesVO.setTotalHours(countHours(courseid)); coursesVO.setTotalAssignHours(countChaptersHours(courseid)); coursesVO.setTotalNotAssignHours(coursesVO.getTotalHours()-coursesVO.getTotalAssignHours()); - coursesVO.setTotalKnow(countKnow(courseid)); +// coursesVO.setTotalKnow(countKnow(courseid)); System.out.println(coursesVO); return coursesVO; } @@ -322,20 +317,17 @@ public class CoursesServiceImpl extends ServiceImpl impl item.setTotalHours(countHours(item.getId())); item.setTotalchapter(countChapters(item.getId())); - item.setTotalKnow(countKnow(item.getId())); +// item.setTotalKnow(countKnow(item.getId())); return item; }).collect(Collectors.toList()); return coursesVo; } // 计算课程知识点个数 - public int countKnow(String courseid){ - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(KnowRelationship::getCourseId,courseid); - List list = knowRelationshipMapper.selectList(wrapper); - int total=list.size(); - return total; - } +// public Integer countKnow(String courseid){ +// // 已修改 yh +// return knowRepository.findCountsByCourseId(courseid); +// } // 计算课程已分配的学时 计算章的学时(即已包含了小节的学时) public int countChaptersHours(String courseid){ LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); diff --git a/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentKnowServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentKnowServiceImpl.java index 3f1f99f..f62b99a 100644 --- a/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentKnowServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentKnowServiceImpl.java @@ -9,12 +9,10 @@ import com.teaching.backend.mapper.courses.CourseObjectivesMapper; import com.teaching.backend.mapper.courses.CoursesMapper; import com.teaching.backend.mapper.courses.ObjectiveContentKnowMapper; import com.teaching.backend.mapper.courses.ObjectiveContentsMapper; -import com.teaching.backend.mapper.know.KnowMapper; import com.teaching.backend.model.dto.courses.ObjectiveContentKnowDTO; import com.teaching.backend.model.entity.courses.CourseObjectives; import com.teaching.backend.model.entity.courses.ObjectiveContentKnow; import com.teaching.backend.model.entity.courses.ObjectiveContents; -import com.teaching.backend.model.entity.know.Know; import com.teaching.backend.model.vo.courses.ObjectiveContentKnowVO; import com.teaching.backend.service.courses.IObjectiveContentKnowService; import org.springframework.beans.factory.annotation.Autowired; @@ -23,11 +21,9 @@ import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.math.RoundingMode; -import java.sql.SQLIntegrityConstraintViolationException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.UUID; import java.util.stream.Collectors; /** @@ -43,8 +39,8 @@ public class ObjectiveContentKnowServiceImpl extends ServiceImpl { - Know know = knowMapper.selectOne(new LambdaQueryWrapper() - .eq(Know::getId, contentKnow.getKnow())); - if (know == null) { - throw new BusinessException(ErrorCode.KNOW_NOT_EXIT); - } - return know.getHour(); - }) - .reduce(BigDecimal.ZERO, BigDecimal::add); - - vo.setKnowsTime(knowsTime); +// BigDecimal knowsTime = objectiveContentKnows.stream() +// .map(contentKnow -> { +// Know know = knowMapper.selectOne(new LambdaQueryWrapper() +// .eq(Know::getId, contentKnow.getKnow())); +// if (know == null) { +// throw new BusinessException(ErrorCode.KNOW_NOT_EXIT); +// } +// return know.getHour(); +// }) +// .reduce(BigDecimal.ZERO, BigDecimal::add); + +// vo.setKnowsTime(knowsTime); return vo; } diff --git a/src/main/java/com/teaching/backend/service/impl/know/KnowRelationshipServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/know/KnowRelationshipServiceImpl.java deleted file mode 100644 index 9de0420..0000000 --- a/src/main/java/com/teaching/backend/service/impl/know/KnowRelationshipServiceImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.teaching.backend.service.impl.know; - - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.teaching.backend.mapper.know.KnowRelationshipMapper; -import com.teaching.backend.model.entity.know.KnowRelationship; -import com.teaching.backend.service.know.IKnowRelationshipService; -import org.springframework.stereotype.Service; - -/** - *

- * 服务实现类 - *

- * - * @author author - * @since 2024-06-20 - */ -@Service -public class KnowRelationshipServiceImpl extends ServiceImpl implements IKnowRelationshipService { - -} diff --git a/src/main/java/com/teaching/backend/service/impl/know/KnowServiceimpl.java b/src/main/java/com/teaching/backend/service/impl/know/KnowServiceimpl.java deleted file mode 100644 index f2f924b..0000000 --- a/src/main/java/com/teaching/backend/service/impl/know/KnowServiceimpl.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.teaching.backend.service.impl.know; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.teaching.backend.mapper.know.KnowMapper; -import com.teaching.backend.model.dto.know.KnowQueryRequest; -import com.teaching.backend.model.dto.know.KnowRequest; -import com.teaching.backend.model.dto.know.KnowupdateRequest; -import com.teaching.backend.model.entity.know.Know; -import com.teaching.backend.service.know.KnowService; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.List; - -@Service -public class KnowServiceimpl extends ServiceImpl implements KnowService { - @Autowired - private KnowMapper knowMapper; - @Override - public Boolean add(KnowRequest knowAddRequest) { - Know know = new Know(); - BeanUtils.copyProperties(knowAddRequest,know); - return save(know); - } - - @Override - public Boolean update(KnowupdateRequest knowAddRequest) { - Know know = new Know(); - BeanUtils.copyProperties(knowAddRequest,know); - return (updateById(know)); - } - - @Override - public Integer deleteKnow(List ids) { - Integer result = knowMapper.deleteBatchIds(ids); - return result; - } - - @Override - public List query(KnowQueryRequest knowQueryRequest) { - String name = knowQueryRequest.getName(); - QueryWrapper knowQueryWrapper = new QueryWrapper<>(); - knowQueryWrapper.eq("name",name); - List knows = knowMapper.selectList(knowQueryWrapper); - return knows; - } - -} diff --git a/src/main/java/com/teaching/backend/service/impl/records/LearningRecordsServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/records/LearningRecordsServiceImpl.java index 248feba..562a697 100644 --- a/src/main/java/com/teaching/backend/service/impl/records/LearningRecordsServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/records/LearningRecordsServiceImpl.java @@ -14,7 +14,6 @@ import com.teaching.backend.model.vo.records.LearningRecordsVo; import com.teaching.backend.service.impl.CourseResourcesServiceImpl; import com.teaching.backend.service.impl.chapter.ChapterServiceImpl; import com.teaching.backend.service.impl.courses.CoursesServiceImpl; -import com.teaching.backend.service.impl.know.KnowServiceimpl; import com.teaching.backend.service.records.LearningRecordsService; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -36,8 +35,8 @@ public class LearningRecordsServiceImpl extends ServiceImpl - * 服务类 - *

- * - * @author author - * @since 2024-06-20 - */ -public interface IKnowRelationshipService extends IService { -} diff --git a/src/main/java/com/teaching/backend/service/know/KnowService.java b/src/main/java/com/teaching/backend/service/know/KnowService.java deleted file mode 100644 index c40a743..0000000 --- a/src/main/java/com/teaching/backend/service/know/KnowService.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.teaching.backend.service.know; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.teaching.backend.model.dto.favour.knowFavour.KnowFavourAddRequest; - -import com.teaching.backend.model.dto.know.KnowQueryRequest; -import com.teaching.backend.model.dto.know.KnowRequest; -import com.teaching.backend.model.dto.know.KnowupdateRequest; -import com.teaching.backend.model.entity.know.Know; - -import java.util.List; - - -public interface KnowService extends IService { - public Boolean add(KnowRequest knowAddRequest); - - public Boolean update(KnowupdateRequest knowAddRequest); - - public Integer deleteKnow(List ids); - - public List query(KnowQueryRequest knowQueryRequest); -} - diff --git a/src/main/java/com/teaching/backend/utils/ParamOutAspect.java b/src/main/java/com/teaching/backend/utils/ParamOutAspect.java index 383ce64..b6b3eee 100644 --- a/src/main/java/com/teaching/backend/utils/ParamOutAspect.java +++ b/src/main/java/com/teaching/backend/utils/ParamOutAspect.java @@ -21,6 +21,7 @@ // //import javax.servlet.http.HttpServletRequest; //import javax.servlet.http.HttpServletResponse; +//import java.lang.reflect.Field; //import java.lang.reflect.Method; //import java.util.Arrays; //import java.util.List; @@ -36,7 +37,7 @@ // private final String executeExpr = "execution(public * com.teaching.backend.controller..*.*(..))"; // // @Before(executeExpr) -// public void processLog(JoinPoint joinPoint) { +// public void processLog(JoinPoint joinPoint) throws IllegalAccessException { // Method method = ((MethodSignature) joinPoint.getSignature()).getMethod(); // //获取方法名称 // String methodName = method.getName(); @@ -53,22 +54,25 @@ // final Object[] array = filteredArgs.stream().toArray(); // // for (int i = 0; i < array.length; i++) { -// String jsonStr = JSONUtil.toJsonStr(array[i]); -//// Class myClass = array[i].getClass(); // 获取类的 Class 对象 -// JSONObject entries = JSONUtil.parseObj(jsonStr); -// System.out.println(entries); -// // 遍历JSONObject的属性 -// entries.forEach((key, value) -> { -// if(value == null || "".equals(value)){ -// //可以设置为空的字段 -// if(key.equals( "sortField")||key.equals( "sortOrder")){ -// }else{ -// throw new BusinessException(ErrorCode.PARAMS_NULL); -// } -// -// } -//// System.out.println(key + ": " + value); -// }); +// Class clazz = array[i].getClass(); +// // 获取所有字段(包括私有字段) +// Field[] fields = clazz.getDeclaredFields(); +// for (Field field : fields) { +// // 设置字段为可访问(如果需要访问私有字段) +// field.setAccessible(true); +// +// // 获取字段的值 +// Object value = field.get(array[i]); +// +// // 检查值是否为空 +// if (value == null) { +// // 这里可以抛出异常或记录日志,具体取决于你的需求 +// String fieldName = field.getName(); +// throw new IllegalArgumentException(fieldName + " @@@@@is null"); +// } +// } +// +// // } // } // } diff --git a/src/main/java/com/teaching/backend/utils/getNullPropertyNamesUtil.java b/src/main/java/com/teaching/backend/utils/getNullPropertyNamesUtil.java new file mode 100644 index 0000000..4131209 --- /dev/null +++ b/src/main/java/com/teaching/backend/utils/getNullPropertyNamesUtil.java @@ -0,0 +1,38 @@ +package com.teaching.backend.utils; + +import org.springframework.beans.BeanWrapper; +import org.springframework.beans.BeanWrapperImpl; + +import java.math.BigDecimal; +import java.util.HashSet; +import java.util.Set; + +/** + * @Author:youhang + * @Date:2024-06-23-12:45 + * @Description: + */ +public class getNullPropertyNamesUtil { + + public static String[] getNullPropertyNames (Object source) { + final BeanWrapper src = new BeanWrapperImpl(source); + java.beans.PropertyDescriptor[] pds = src.getPropertyDescriptors(); + + Set emptyNames = new HashSet(); + for(java.beans.PropertyDescriptor pd : pds) { + Class propertyType = src.getPropertyType(pd.getName()); + Object srcValue = src.getPropertyValue(pd.getName()); +// if ("Integer".equals(propertyType.getName()) || "Long".equals(propertyType.getName())){ +// Integer value = (Integer) srcValue; +// if (value == 0) emptyNames.add(pd.getName()); +// } + if ("BigDecimal".equals(propertyType.getName())){ + BigDecimal value =(BigDecimal)srcValue; + if (value == null || (BigDecimal.ZERO).equals(0)) emptyNames.add(pd.getName()); + } + if (srcValue == null || srcValue == "") emptyNames.add(pd.getName()); + } + String[] result = new String[emptyNames.size()]; + return emptyNames.toArray(result); + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 8dcd1f6..6002750 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -7,6 +7,11 @@ spring: multipart: max-file-size: 10MB max-request-size: 10MB + neo4j: + uri: bolt://39.106.16.162:7687 + authentication: + username: neo4j # 连接Neo4j数据P库的用户名 + password: 123456 # 连接Neo4j数据库的密码 mvc: pathmatch: matching-strategy: ant_path_matcher