🔨 Refactor: [后台]:开始头像上传

This commit is contained in:
fanxb 2019-09-08 19:39:29 +08:00
parent 05d07e49a6
commit 4a063ec343
4 changed files with 26 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import com.fanxb.bookmark.common.util.UserContextHolder;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
/**
* 类功能简述
@ -63,6 +64,17 @@ public class UserController {
return Result.success(userService.getUserInfo(UserContextHolder.get().getUserId()));
}
/**
* 修改用户头像
*
* @param file 头像文件
*/
@PostMapping("/icon")
public Result pushIcon(@RequestParam("file") MultipartFile file) {
return Result.success(userService.updateIcon(file));
}
/**
* Description: 用户登录
*

View File

@ -11,6 +11,7 @@ import com.fanxb.bookmark.common.exception.FormDataException;
import com.fanxb.bookmark.common.util.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.util.HashMap;
import java.util.Map;
@ -155,4 +156,13 @@ public class UserService {
public User getUserInfo(int userId) {
return userDao.selectByUserId(userId);
}
/**
* 修改用户头像
* @param file file
* @return 修改后的路径
*/
public String updateIcon(MultipartFile file){
return "asdf";
}
}

View File

@ -1 +1 @@
<?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> <groupId>com.fanxb</groupId> <artifactId>bookMarkService</artifactId> <packaging>pom</packaging> <version>1.0-SNAPSHOT</version> <modules> <module>common</module> <module>business</module> <module>web</module> </modules> <properties> <project.build.sourceEncoding>utf-8</project.build.sourceEncoding> <project.reporting.outputEncoding>utf-8</project.reporting.outputEncoding> <java.version>11</java.version> </properties> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.6.RELEASE</version> <relativePath/> </parent> <dependencyManagement> <dependencies> <!--定义es版本号,因为spring-boot-start-parent中引入了es的依赖会导致es的版本问题无法正常使用high-level-client--> <dependency> <groupId>org.elasticsearch.client</groupId> <artifactId>elasticsearch-rest-high-level-client</artifactId> <version>7.2.0</version> </dependency> <!-- https://mvnrepository.com/artifact/org.elasticsearch/elasticsearch --> <dependency> <groupId>org.elasticsearch</groupId> <artifactId>elasticsearch</artifactId> <version>7.2.0</version> </dependency> <!--&lt;!&ndash; https://mvnrepository.com/artifact/org.elasticsearch.client/elasticsearch-rest-client &ndash;&gt;--> <dependency> <groupId>org.elasticsearch.client</groupId> <artifactId>elasticsearch-rest-client</artifactId> <version>7.2.0</version> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> </project>
<?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> <groupId>com.fanxb</groupId> <artifactId>bookMarkService</artifactId> <packaging>pom</packaging> <version>1.0-SNAPSHOT</version> <modules> <module>common</module> <module>business</module> <module>web</module> </modules> <properties> <project.build.sourceEncoding>utf-8</project.build.sourceEncoding> <project.reporting.outputEncoding>utf-8</project.reporting.outputEncoding> <java.version>8</java.version> </properties> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.6.RELEASE</version> <relativePath/> </parent> <dependencyManagement> <dependencies> <!--定义es版本号,因为spring-boot-start-parent中引入了es的依赖会导致es的版本问题无法正常使用high-level-client--> <dependency> <groupId>org.elasticsearch.client</groupId> <artifactId>elasticsearch-rest-high-level-client</artifactId> <version>7.2.0</version> </dependency> <!-- https://mvnrepository.com/artifact/org.elasticsearch/elasticsearch --> <dependency> <groupId>org.elasticsearch</groupId> <artifactId>elasticsearch</artifactId> <version>7.2.0</version> </dependency> <!--&lt;!&ndash; https://mvnrepository.com/artifact/org.elasticsearch.client/elasticsearch-rest-client &ndash;&gt;--> <dependency> <groupId>org.elasticsearch.client</groupId> <artifactId>elasticsearch-rest-client</artifactId> <version>7.2.0</version> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> </project>

View File

@ -66,3 +66,6 @@ es:
host: localhost
port: 9200
scheme: http
# 默认文件上传基路径
fileSavePath: ./