From 1cf2bc727f5e2de093ec10f50a28f9c3ba7c7ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E8=8B=B1=E6=9D=B0?= <327782001@qq.com> Date: Sat, 7 Oct 2023 18:10:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=88=A0=E6=8E=89=E6=9E=9A=E4=B8=BE?= =?UTF-8?q?=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/DictionaryManagement.java | 28 +++++++ .../enums/AlgorithmicProblemTypeEnum.java | 76 ------------------- .../mapper/DictionaryManagementMapper.java | 15 ++++ .../service/DictionaryManagementService.java | 15 ++++ .../impl/AlgorithmicProblemServiceImpl.java | 23 +++++- .../impl/DictionaryManagementServiceImpl.java | 19 +++++ 6 files changed, 97 insertions(+), 79 deletions(-) create mode 100644 src/main/java/com/kwan/springbootkwan/entity/DictionaryManagement.java delete mode 100644 src/main/java/com/kwan/springbootkwan/enums/AlgorithmicProblemTypeEnum.java create mode 100644 src/main/java/com/kwan/springbootkwan/mapper/DictionaryManagementMapper.java create mode 100644 src/main/java/com/kwan/springbootkwan/service/DictionaryManagementService.java create mode 100644 src/main/java/com/kwan/springbootkwan/service/impl/DictionaryManagementServiceImpl.java diff --git a/src/main/java/com/kwan/springbootkwan/entity/DictionaryManagement.java b/src/main/java/com/kwan/springbootkwan/entity/DictionaryManagement.java new file mode 100644 index 0000000..f2c14b3 --- /dev/null +++ b/src/main/java/com/kwan/springbootkwan/entity/DictionaryManagement.java @@ -0,0 +1,28 @@ +package com.kwan.springbootkwan.entity; + +import com.baomidou.mybatisplus.extension.activerecord.Model; +import lombok.Data; + +import java.util.Date; + +/** + * 字典表(DictionaryManagement)表实体类 + * + * @author makejava + * @since 2023-10-07 17:54:39 + */ +@Data +public class DictionaryManagement extends Model { + //主键id + private Integer id; + //字典类型 + private Integer dictType; + //字典code + private Integer code; + //字典名称 + private String name; + //创建时间 + private Date createTime; + //逻辑删除,0未删除,1已删除 + private Integer isDelete; +} \ No newline at end of file diff --git a/src/main/java/com/kwan/springbootkwan/enums/AlgorithmicProblemTypeEnum.java b/src/main/java/com/kwan/springbootkwan/enums/AlgorithmicProblemTypeEnum.java deleted file mode 100644 index 99fa356..0000000 --- a/src/main/java/com/kwan/springbootkwan/enums/AlgorithmicProblemTypeEnum.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.kwan.springbootkwan.enums; - -import com.kwan.springbootkwan.entity.dto.AlgorithmicQuestionTypeDTO; -import lombok.Getter; -import lombok.ToString; - -import java.util.LinkedList; - -@Getter -@ToString -public enum AlgorithmicProblemTypeEnum { - /** - * 全部 - */ - type_00(0, "全部"), - /** - * 链表 - */ - type_01(1, "链表"), - /** - * 数组 - */ - type_02(2, "数组"), - /** - * 二叉树 - */ - type_03(3, "二叉树"), - /** - * 贪心 - */ - type_04(4, "贪心"), - /** - * 动态规划 - */ - type_05(5, "动态规划"), - /** - * 其他 - */ - type_99(99, "其他"); - private Integer code; - private String name; - - AlgorithmicProblemTypeEnum(Integer code, String name) { - this.code = code; - this.name = name; - } - - /** - * 通过code获取name - * - * @param code - * @return - */ - public static String getNameByCode(Integer code) { - for (AlgorithmicProblemTypeEnum enums : AlgorithmicProblemTypeEnum.values()) { - if (enums.getCode().equals(code)) { - return enums.getName(); - } - } - return null; - } - - /** - * 获取所有枚举 - * - * @return - */ - public static LinkedList getAll() { - LinkedList list = new LinkedList<>(); - for (AlgorithmicProblemTypeEnum enums : AlgorithmicProblemTypeEnum.values()) { - AlgorithmicQuestionTypeDTO algorithmicQuestionTypeDTO = new AlgorithmicQuestionTypeDTO(enums.getCode(), enums.getName(), 0); - list.add(algorithmicQuestionTypeDTO); - } - return list; - } -} diff --git a/src/main/java/com/kwan/springbootkwan/mapper/DictionaryManagementMapper.java b/src/main/java/com/kwan/springbootkwan/mapper/DictionaryManagementMapper.java new file mode 100644 index 0000000..78770bd --- /dev/null +++ b/src/main/java/com/kwan/springbootkwan/mapper/DictionaryManagementMapper.java @@ -0,0 +1,15 @@ +package com.kwan.springbootkwan.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.kwan.springbootkwan.entity.DictionaryManagement; + +/** + * 字典表(DictionaryManagement)表数据库访问层 + * + * @author makejava + * @since 2023-10-07 17:54:37 + */ +public interface DictionaryManagementMapper extends BaseMapper { + +} + diff --git a/src/main/java/com/kwan/springbootkwan/service/DictionaryManagementService.java b/src/main/java/com/kwan/springbootkwan/service/DictionaryManagementService.java new file mode 100644 index 0000000..ef9e84a --- /dev/null +++ b/src/main/java/com/kwan/springbootkwan/service/DictionaryManagementService.java @@ -0,0 +1,15 @@ +package com.kwan.springbootkwan.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.kwan.springbootkwan.entity.DictionaryManagement; + +/** + * 字典表(DictionaryManagement)表服务接口 + * + * @author makejava + * @since 2023-10-07 17:54:39 + */ +public interface DictionaryManagementService extends IService { + +} + diff --git a/src/main/java/com/kwan/springbootkwan/service/impl/AlgorithmicProblemServiceImpl.java b/src/main/java/com/kwan/springbootkwan/service/impl/AlgorithmicProblemServiceImpl.java index 581f46b..5b5c1da 100644 --- a/src/main/java/com/kwan/springbootkwan/service/impl/AlgorithmicProblemServiceImpl.java +++ b/src/main/java/com/kwan/springbootkwan/service/impl/AlgorithmicProblemServiceImpl.java @@ -1,16 +1,19 @@ package com.kwan.springbootkwan.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.kwan.springbootkwan.entity.AlgorithmicProblem; +import com.kwan.springbootkwan.entity.DictionaryManagement; import com.kwan.springbootkwan.entity.dto.AlgorithmicQuestionTypeDTO; -import com.kwan.springbootkwan.enums.AlgorithmicProblemTypeEnum; import com.kwan.springbootkwan.mapper.AlgorithmicProblemMapper; import com.kwan.springbootkwan.service.AlgorithmicProblemService; +import com.kwan.springbootkwan.service.DictionaryManagementService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.LinkedList; import java.util.List; +import java.util.stream.Collectors; /** * 算法题(AlgorithmicProblem)表服务实现类 @@ -23,22 +26,36 @@ public class AlgorithmicProblemServiceImpl extends ServiceImpl questionType() { + final List algorithmicQuestionTypeDTOS = this.allQuestionType(); //获取种类,并按数量排序 LinkedList types = interviewQuestionMapper.questionType(); types.addFirst(new AlgorithmicQuestionTypeDTO(0, "全部", 0)); for (AlgorithmicQuestionTypeDTO algorithmicQuestionTypeDTO : types) { //数据库存的是问题类型的编码 - algorithmicQuestionTypeDTO.setName(AlgorithmicProblemTypeEnum.getNameByCode(algorithmicQuestionTypeDTO.getQuestionType())); + final AlgorithmicQuestionTypeDTO item = algorithmicQuestionTypeDTOS.stream().filter(x -> x.getQuestionType().equals(algorithmicQuestionTypeDTO.getQuestionType())).findFirst().get(); + algorithmicQuestionTypeDTO.setName(item.getName()); } return types; } @Override public List allQuestionType() { - return AlgorithmicProblemTypeEnum.getAll(); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("dict_type", 2); + wrapper.eq("is_delete", 0); + final List list = dictionaryManagementService.list(wrapper); + return list.stream() + .map(item -> { + AlgorithmicQuestionTypeDTO algorithmicQuestionTypeDTO = new AlgorithmicQuestionTypeDTO(); + algorithmicQuestionTypeDTO.setQuestionType(item.getCode()); + algorithmicQuestionTypeDTO.setName(item.getName()); + return algorithmicQuestionTypeDTO; + }).collect(Collectors.toList()); } } diff --git a/src/main/java/com/kwan/springbootkwan/service/impl/DictionaryManagementServiceImpl.java b/src/main/java/com/kwan/springbootkwan/service/impl/DictionaryManagementServiceImpl.java new file mode 100644 index 0000000..62edc77 --- /dev/null +++ b/src/main/java/com/kwan/springbootkwan/service/impl/DictionaryManagementServiceImpl.java @@ -0,0 +1,19 @@ +package com.kwan.springbootkwan.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.kwan.springbootkwan.entity.DictionaryManagement; +import com.kwan.springbootkwan.mapper.DictionaryManagementMapper; +import com.kwan.springbootkwan.service.DictionaryManagementService; +import org.springframework.stereotype.Service; + +/** + * 字典表(DictionaryManagement)表服务实现类 + * + * @author makejava + * @since 2023-10-07 17:54:39 + */ +@Service("dictionaryManagementService") +public class DictionaryManagementServiceImpl extends ServiceImpl implements DictionaryManagementService { + +} + -- GitLab