mirror of
https://gitee.com/likeadmin/likeadmin_java.git
synced 2026-09-07 07:07:57 +08:00
调整用户管理接口
This commit is contained in:
@@ -17,6 +17,7 @@ public class FrontConfig {
|
||||
"/api/search",
|
||||
"/api/decorate",
|
||||
"/api/sms/send",
|
||||
"/api/upload/image",
|
||||
|
||||
"/api/login/check",
|
||||
"/api/login/register",
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.mdd.common.config.GlobalConfig;
|
||||
import com.mdd.common.utils.YmlUtil;
|
||||
import com.mdd.front.LikeFrontInterceptor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
@@ -41,7 +42,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
||||
* 资源目录映射
|
||||
*/
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
public void addResourceHandlers(@NonNull ResourceHandlerRegistry registry) {
|
||||
String directory = YmlUtil.get("like.upload-directory");
|
||||
if (directory == null || directory.equals("")) {
|
||||
directory = GlobalConfig.uploadDirectory;
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.mdd.front.controller;
|
||||
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.enums.AlbumEnum;
|
||||
import com.mdd.common.plugin.storage.StorageDriver;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 上传管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/upload")
|
||||
public class UploadController {
|
||||
|
||||
/**
|
||||
* 上传图片
|
||||
*
|
||||
* @author fzr
|
||||
* @param request 请求对象
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/image")
|
||||
public Object image(HttpServletRequest request) {
|
||||
MultipartFile multipartFile;
|
||||
try {
|
||||
multipartFile = ((MultipartRequest) request).getFile("file");
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.failed("请正确选择上传图片");
|
||||
}
|
||||
|
||||
if (multipartFile == null) {
|
||||
return AjaxResult.failed("请选择上传图片");
|
||||
}
|
||||
|
||||
StorageDriver storageDriver = new StorageDriver();
|
||||
Map<String, Object> map = storageDriver.upload(multipartFile, "image", AlbumEnum.IMAGE.getCode());
|
||||
return AjaxResult.success(map);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mdd.front.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 上传服务接口类
|
||||
*/
|
||||
public interface IUploadService {
|
||||
|
||||
/**
|
||||
* 上传图片
|
||||
*
|
||||
* @author fzr
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> image();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.mdd.front.service.impl;
|
||||
|
||||
import com.mdd.front.service.IUploadService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 上传服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class UploadServiceImpl implements IUploadService {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> image() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user