开发指南测试
This commit is contained in:
parent
22133a83da
commit
80260a9fa0
|
@ -74,7 +74,8 @@ public class CategoryServiceImpl extends CrudServiceImpl<CategoryDao, Category,
|
|||
.eq("del_flag",0)
|
||||
.eq("is_attr", "true")
|
||||
.orderByAsc("xh");
|
||||
return categoryDao.selectList(wrapper);
|
||||
List<Category> categories = categoryDao.selectList(wrapper);
|
||||
return categories;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package io.renren.modules.resource.controller;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.renren.common.annotation.LogOperation;
|
||||
import io.renren.common.constant.Constant;
|
||||
import io.renren.common.controller.FileUploadController;
|
||||
import io.renren.common.page.PageData;
|
||||
import io.renren.common.utils.Result;
|
||||
import io.renren.common.validator.ValidatorUtils;
|
||||
|
@ -14,13 +15,21 @@ import io.swagger.annotations.Api;
|
|||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 资源表
|
||||
|
@ -32,9 +41,14 @@ import java.util.Map;
|
|||
@RequestMapping("/resource")
|
||||
@Api(tags="资源表")
|
||||
public class ResourceController {
|
||||
|
||||
@Value("${resource.devModelFilePath}")
|
||||
private String delModelFilePath;
|
||||
@Autowired
|
||||
private ResourceService resourceService;
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(ResourceController.class);
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("分页查询资源信息")
|
||||
@ApiImplicitParams({
|
||||
|
@ -135,6 +149,38 @@ public class ResourceController {
|
|||
}
|
||||
}
|
||||
|
||||
@PostMapping("/upload")
|
||||
@ApiOperation("开发指南文件上传")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "file", value = "开发指南文件", paramType = "file", dataType = "file", required = true)
|
||||
})
|
||||
public Result upload(@RequestParam("file") MultipartFile uploadFile,
|
||||
HttpServletRequest request) {
|
||||
logger.info("上传文件:" + uploadFile.getOriginalFilename());
|
||||
File folder = new File(delModelFilePath);
|
||||
if (!folder.isDirectory()) {
|
||||
folder.mkdirs();
|
||||
}
|
||||
if (folder.exists()) {
|
||||
if (folder.isFile()) {
|
||||
if (!folder.delete()) {
|
||||
return new Result<>().error("保存开发指南失败!!!");
|
||||
}
|
||||
}
|
||||
}
|
||||
// 对上传的文件重命名,避免文件重名
|
||||
//String oldName = uploadFile.getOriginalFilename();
|
||||
String fileName = "devModelFile.md";
|
||||
try {
|
||||
// 文件保存
|
||||
uploadFile.transferTo(new File(folder, fileName));
|
||||
|
||||
return new Result<>();
|
||||
} catch (IOException e) {
|
||||
return new Result<String>().error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/*@GetMapping("export")
|
||||
@ApiOperation("导出")
|
||||
@LogOperation("导出")
|
||||
|
|
|
@ -20,6 +20,7 @@ import io.renren.modules.security.user.UserDetail;
|
|||
import org.apache.commons.io.IOUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -43,6 +44,9 @@ import java.util.Map;
|
|||
@Service
|
||||
public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEntity, ResourceDTO> implements ResourceService {
|
||||
|
||||
@Value("${resource.devModelFilePath}")
|
||||
private String delModelFilePath;
|
||||
|
||||
@Autowired
|
||||
private ResourceDao resourceDao;
|
||||
|
||||
|
@ -183,7 +187,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
//String type = request.getParameter("type").toString();
|
||||
//Long resourceId = Long.parseLong(request.getParameter("resourceId"));
|
||||
//String url = type + "/devModelFile.txt";
|
||||
String url = "renren-admin/src/main/resources/temp/devModelFile.md";
|
||||
String url = delModelFilePath + "devModelFile.md";
|
||||
File file = new File(url);
|
||||
if (!file.exists()) {
|
||||
Exception e = new Exception("文件不存在");
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
resource:
|
||||
root_url: 15.2.21.238
|
||||
path: /home/yth/files/
|
||||
devModelFilePath: /home/yth/files/resource
|
||||
# Tomcat
|
||||
server:
|
||||
tomcat:
|
||||
|
|
Loading…
Reference in New Issue