日考14
commit
6335f498cb
|
@ -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
|
|
@ -0,0 +1,67 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.bwie</groupId>
|
||||
<artifactId>bwie-modules</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>bwie-question</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- 系统公共 依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.bwie</groupId>
|
||||
<artifactId>bwie-common</artifactId>
|
||||
</dependency>
|
||||
<!-- SpringBoot Web-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<!-- Druid -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>1.2.8</version>
|
||||
</dependency>
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<!-- Mybatis 依赖配置 -->
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.2.2</version>
|
||||
</dependency>
|
||||
<!-- Pagehelper -->
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.4.1</version>
|
||||
</dependency>
|
||||
<!-- test -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.tobato</groupId>
|
||||
<artifactId>fastdfs-client</artifactId>
|
||||
<version>1.26.5</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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());
|
||||
}
|
||||
}
|
|
@ -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<Question> findlist();
|
||||
}
|
|
@ -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<Question> findlist();
|
||||
}
|
|
@ -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<Question> findlist() {
|
||||
return questionMapper.findlist();
|
||||
|
||||
}
|
||||
}
|
|
@ -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 "删除成功";
|
||||
}
|
||||
|
||||
}
|
|
@ -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}
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.bwie.question.mapper.QuestionMapper">
|
||||
|
||||
<select id="findlist" resultType="com.bwie.common.domain.Question">
|
||||
select * from question order by public_time desc
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue