commit 6335f498cb4e27ca24d75c3da51a6b3fee00ebe5
Author: WeiRan <2392355487@qq.com>
Date: Wed Aug 7 19:02:59 2024 +0800
日考14
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5ff6309
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,38 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..8d41935
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,67 @@
+
+
+ 4.0.0
+
+ com.bwie
+ bwie-modules
+ 1.0-SNAPSHOT
+
+
+ bwie-question
+
+
+ 8
+ 8
+ UTF-8
+
+
+
+
+
+ com.bwie
+ bwie-common
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ com.alibaba
+ druid-spring-boot-starter
+ 1.2.8
+
+
+
+ mysql
+ mysql-connector-java
+
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-starter
+ 2.2.2
+
+
+
+ com.github.pagehelper
+ pagehelper-spring-boot-starter
+ 1.4.1
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ com.github.tobato
+ fastdfs-client
+ 1.26.5
+
+
+
+
diff --git a/src/main/java/com/bwie/question/QuestionApplication.java b/src/main/java/com/bwie/question/QuestionApplication.java
new file mode 100644
index 0000000..197e011
--- /dev/null
+++ b/src/main/java/com/bwie/question/QuestionApplication.java
@@ -0,0 +1,18 @@
+package com.bwie.question;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * @Author:weiran
+ * @Package:com.bwie.question
+ * @Project:week3
+ * @name:QuestionApplication
+ * @Date:2024/8/7 18:44
+ */
+@SpringBootApplication
+public class QuestionApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(QuestionApplication.class, args);
+ }
+}
diff --git a/src/main/java/com/bwie/question/controller/QuestionController.java b/src/main/java/com/bwie/question/controller/QuestionController.java
new file mode 100644
index 0000000..cd80082
--- /dev/null
+++ b/src/main/java/com/bwie/question/controller/QuestionController.java
@@ -0,0 +1,34 @@
+package com.bwie.question.controller;
+
+import com.bwie.common.domain.Question;
+import com.bwie.question.service.QuestionService;
+import com.bwie.common.result.Result;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Author:weiran
+ * @Package:com.bwie.question.controller
+ * @Project:week3
+ * @name:QuestionController
+ * @Date:2024/8/7 18:39
+ */
+
+@RequestMapping("/question")
+@RestController
+public class QuestionController {
+ @Autowired
+ private QuestionService questionService;
+
+
+ /**
+ * 查询列表
+ */
+ @PostMapping("/list")
+ public Result findlist(){
+ return Result.success(questionService.findlist());
+ }
+}
diff --git a/src/main/java/com/bwie/question/mapper/QuestionMapper.java b/src/main/java/com/bwie/question/mapper/QuestionMapper.java
new file mode 100644
index 0000000..a35540c
--- /dev/null
+++ b/src/main/java/com/bwie/question/mapper/QuestionMapper.java
@@ -0,0 +1,18 @@
+package com.bwie.question.mapper;
+
+import com.bwie.common.domain.Question;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ * @Author:weiran
+ * @Package:com.bwie.question.mapper
+ * @Project:week3
+ * @name:QuestionMapper
+ * @Date:2024/8/7 18:39
+ */
+@Mapper
+public interface QuestionMapper {
+ List findlist();
+}
diff --git a/src/main/java/com/bwie/question/service/QuestionService.java b/src/main/java/com/bwie/question/service/QuestionService.java
new file mode 100644
index 0000000..c102957
--- /dev/null
+++ b/src/main/java/com/bwie/question/service/QuestionService.java
@@ -0,0 +1,16 @@
+package com.bwie.question.service;
+
+import com.bwie.common.domain.Question;
+
+import java.util.List;
+
+/**
+ * @Author:weiran
+ * @Package:com.bwie.question.service
+ * @Project:week3
+ * @name:QuestionService
+ * @Date:2024/8/7 18:40
+ */
+public interface QuestionService {
+ List findlist();
+}
diff --git a/src/main/java/com/bwie/question/service/impl/QuestionServiceImpl.java b/src/main/java/com/bwie/question/service/impl/QuestionServiceImpl.java
new file mode 100644
index 0000000..eca445d
--- /dev/null
+++ b/src/main/java/com/bwie/question/service/impl/QuestionServiceImpl.java
@@ -0,0 +1,29 @@
+package com.bwie.question.service.impl;
+
+import com.bwie.common.domain.Question;
+import com.bwie.question.mapper.QuestionMapper;
+import com.bwie.question.service.QuestionService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @Author:weiran
+ * @Package:com.bwie.question.service.impl
+ * @Project:week3
+ * @name:QuestionServiceImpl
+ * @Date:2024/8/7 18:40
+ */
+@Service
+public class QuestionServiceImpl implements QuestionService {
+ @Autowired
+ private QuestionMapper questionMapper;
+
+
+ @Override
+ public List findlist() {
+ return questionMapper.findlist();
+
+ }
+}
diff --git a/src/main/java/com/bwie/question/utils/FastUtil.java b/src/main/java/com/bwie/question/utils/FastUtil.java
new file mode 100644
index 0000000..806fb2b
--- /dev/null
+++ b/src/main/java/com/bwie/question/utils/FastUtil.java
@@ -0,0 +1,55 @@
+package com.bwie.question.utils;
+
+import org.springframework.stereotype.Component;
+import com.github.tobato.fastdfs.domain.fdfs.StorePath;
+import com.github.tobato.fastdfs.service.FastFileStorageClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.util.StringUtils;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+
+/**
+ * @BelongsProject: 0107day02
+ * @BelongsPackage: com.bw.config
+ * @Author: zhupengfei
+ * @CreateTime: 2023-02-01 08:52
+ */
+@Component
+public class FastUtil {
+ private static final Logger log = LoggerFactory.getLogger(FastUtil.class);
+
+ @Resource
+ private FastFileStorageClient storageClient ;
+
+ /**
+ * 上传文件
+ */
+ public String upload(MultipartFile multipartFile) throws Exception{
+ String originalFilename = multipartFile.getOriginalFilename().
+ substring(multipartFile.getOriginalFilename().
+ lastIndexOf(".") + 1);
+ StorePath storePath = this.storageClient.uploadImageAndCrtThumbImage(
+ multipartFile.getInputStream(),
+ multipartFile.getSize(),originalFilename , null);
+ return storePath.getFullPath() ;
+ }
+ /**
+ * 删除文件
+ */
+ public String deleteFile(String fileUrl) {
+ if (StringUtils.isEmpty(fileUrl)) {
+ log.info("fileUrl == >>文件路径为空...");
+ return "文件路径不能为空";
+ }
+ try {
+ StorePath storePath = StorePath.parseFromUrl(fileUrl);
+ storageClient.deleteFile(storePath.getGroup(), storePath.getPath());
+ } catch (Exception e) {
+ log.error(e.getMessage());
+ }
+ return "删除成功";
+ }
+
+}
diff --git a/src/main/resources/bootstrap.yml b/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..4f62969
--- /dev/null
+++ b/src/main/resources/bootstrap.yml
@@ -0,0 +1,31 @@
+# Tomcat
+server:
+ port: 9003
+# Spring
+spring:
+ main:
+ allow-circular-references: true
+ jackson:
+ date-format: yyyy-MM-dd HH:mm:ss
+ time-zone: GMT+8
+ application:
+ # 应用名称
+ name: bwie-question
+ profiles:
+ # 环境配置
+ active: dev
+ cloud:
+ nacos:
+ discovery:
+ # 服务注册地址
+ server-addr: 122.51.12.81:8848
+ namespace: nacos
+ config:
+ # 配置中心地址
+ server-addr: 122.51.12.81:8848
+ namespace: nacos
+ # 配置文件格式
+ file-extension: yml
+ # 共享配置
+ shared-configs:
+ - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
diff --git a/src/main/resources/mapper/QuestionMapper.xml b/src/main/resources/mapper/QuestionMapper.xml
new file mode 100644
index 0000000..0eee321
--- /dev/null
+++ b/src/main/resources/mapper/QuestionMapper.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+