开发指南测试

This commit is contained in:
dinggang 2022-04-21 10:29:35 +08:00
parent 22133a83da
commit 80260a9fa0
5 changed files with 55 additions and 3 deletions

View File

@ -74,7 +74,8 @@ public class CategoryServiceImpl extends CrudServiceImpl<CategoryDao, Category,
.eq("del_flag",0) .eq("del_flag",0)
.eq("is_attr", "true") .eq("is_attr", "true")
.orderByAsc("xh"); .orderByAsc("xh");
return categoryDao.selectList(wrapper); List<Category> categories = categoryDao.selectList(wrapper);
return categories;
} }
@Override @Override

View File

@ -3,6 +3,7 @@ package io.renren.modules.resource.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import io.renren.common.annotation.LogOperation; import io.renren.common.annotation.LogOperation;
import io.renren.common.constant.Constant; import io.renren.common.constant.Constant;
import io.renren.common.controller.FileUploadController;
import io.renren.common.page.PageData; import io.renren.common.page.PageData;
import io.renren.common.utils.Result; import io.renren.common.utils.Result;
import io.renren.common.validator.ValidatorUtils; import io.renren.common.validator.ValidatorUtils;
@ -14,13 +15,21 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; 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.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.UUID;
/** /**
* 资源表 * 资源表
@ -32,9 +41,14 @@ import java.util.Map;
@RequestMapping("/resource") @RequestMapping("/resource")
@Api(tags="资源表") @Api(tags="资源表")
public class ResourceController { public class ResourceController {
@Value("${resource.devModelFilePath}")
private String delModelFilePath;
@Autowired @Autowired
private ResourceService resourceService; private ResourceService resourceService;
private static Logger logger = LoggerFactory.getLogger(ResourceController.class);
@GetMapping("/page") @GetMapping("/page")
@ApiOperation("分页查询资源信息") @ApiOperation("分页查询资源信息")
@ApiImplicitParams({ @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") /*@GetMapping("export")
@ApiOperation("导出") @ApiOperation("导出")
@LogOperation("导出") @LogOperation("导出")

View File

@ -20,6 +20,7 @@ import io.renren.modules.security.user.UserDetail;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -43,6 +44,9 @@ import java.util.Map;
@Service @Service
public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEntity, ResourceDTO> implements ResourceService { public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEntity, ResourceDTO> implements ResourceService {
@Value("${resource.devModelFilePath}")
private String delModelFilePath;
@Autowired @Autowired
private ResourceDao resourceDao; private ResourceDao resourceDao;
@ -183,7 +187,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
//String type = request.getParameter("type").toString(); //String type = request.getParameter("type").toString();
//Long resourceId = Long.parseLong(request.getParameter("resourceId")); //Long resourceId = Long.parseLong(request.getParameter("resourceId"));
//String url = type + "/devModelFile.txt"; //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); File file = new File(url);
if (!file.exists()) { if (!file.exists()) {
Exception e = new Exception("文件不存在"); Exception e = new Exception("文件不存在");

View File

@ -2,6 +2,7 @@
resource: resource:
root_url: 15.2.21.238 root_url: 15.2.21.238
path: /home/yth/files/ path: /home/yth/files/
devModelFilePath: /home/yth/files/resource
# Tomcat # Tomcat
server: server:
tomcat: tomcat: