1:添加spring-data-redis1.7.1相关jar及测试代码

2:添加fastdfs的相关jar及测试代码
3:修改某些系统文件中项目名称为maat_service(有些系统配置文件里面的项目名称没有改过来)
This commit is contained in:
RenKaiGe-Office
2018-05-17 14:53:57 +08:00
parent 7732a5b895
commit 286ede4df9
21 changed files with 739 additions and 127 deletions

View File

@@ -26,6 +26,7 @@ import com.nis.util.StringUtils;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.TestRedisService;
import com.nis.web.service.restful.ConfigSourcesService;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
@@ -48,6 +49,22 @@ public class ConfigSourcesController extends BaseRestController {
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
@Autowired
TestRedisService testRedisServiceimpl;
@RequestMapping(value = "/save", method = RequestMethod.GET)
@ApiOperation(value = "test redis", httpMethod = "GET", response = Map.class, notes = "测试redis事务的crontroller")
@ApiParam(value = "test redis", name = "测试redis事务的crontroller", required = true)
public String testRedis() {
try {
testRedisServiceimpl.saveConfigCompile();
return "ok";
} catch (Exception e) {
e.printStackTrace();
}
return "false";
}
@RequestMapping(value = "/cfg/v1/configSources", method = RequestMethod.POST)
@ApiOperation(value = "业务配置存储", httpMethod = "POST", response = Map.class, notes = "对有效的配置(封堵|监测|白名单)存储")
@ApiParam(value = "业务配置数据源", name = "configSource", required = true)
@@ -123,14 +140,16 @@ public class ConfigSourcesController extends BaseRestController {
checkOpAction(thread, System.currentTimeMillis() - start, opAction, 2);
String msg = "";
ConfigCompile compile = configSource.getConfigCompileList().get(0);
if(StringUtil.isEmpty(compile.getGroupRelationList())&&StringUtil.isEmpty(compile.getIpRegionList())&&StringUtil.isEmpty(compile.getStrRegionList())&&StringUtil.isEmpty(compile.getNumRegionList())){
if (StringUtil.isEmpty(compile.getGroupRelationList()) && StringUtil.isEmpty(compile.getIpRegionList())
&& StringUtil.isEmpty(compile.getStrRegionList())
&& StringUtil.isEmpty(compile.getNumRegionList())) {
msg = configSourcesService.updateByJDBCThread3(thread, start, configSource.getConfigCompileList(),
configSource.getOpTime(), sb);
}else{
configSource.getOpTime(), sb);
} else {
msg = configSourcesService.updateByJDBCThread12(thread, start, configSource.getConfigCompileList(),
configSource.getOpTime(), sb);
configSource.getOpTime(), sb);
}
if (msg.equals("error")) {
String errorCode = "";
Exception exception = ConfigSourcesService.getMsgList().get(0);
@@ -240,7 +259,8 @@ public class ConfigSourcesController extends BaseRestController {
}
}
Map<Integer, String> throwExceptionInfo = OracleErrorCodeUtil.throwExceptionInfo(errorCode);
Map<Integer, String> throwExceptionInfo = OracleErrorCodeUtil
.throwExceptionInfo(errorCode);
for (int errorNum : throwExceptionInfo.keySet()) {
if (errorNum == 998) {
thread.setExceptionInfo(e.toString());

View File

@@ -0,0 +1,110 @@
package com.nis.web.controller.restful;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.csource.common.MyException;
import org.csource.common.NameValuePair;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.nis.web.service.fdfs.FastDFSFile;
import com.nis.web.service.fdfs.FileManager;
/**
* <p>Title: FastDFSController.java</p>
* <p>Description: fastdfs测试controller</p>
* <p>Company: IIE</p>
* @author rkg
* @date 2018年5月16日
*
*/
@Controller
public class FastDFSController {
public static void main(String[] args) {
String path = new FastDFSController().testAdd();
//String path = "M00/00/01/CgAGwFr786aAegOQAADz3NN2rlY283.jpg";
new FastDFSController().testDelete(path);
}
public void testDelete(String filePath) {
filePath = filePath.substring(filePath.indexOf("group"));
String groupName=filePath.substring(0,filePath.indexOf("/"));
filePath=filePath.substring(filePath.indexOf("/")+1);
Integer a = FileManager.delete_file(groupName, filePath);
System.out.println(a);
}
public String testAdd() {
String filePath = "d:/1.jpg";
File file = new File(filePath);
String fileName = file.getName();
String ext = fileName.substring(fileName.lastIndexOf(".") + 1);
NameValuePair[] meta_list = new NameValuePair[4];
meta_list[0] = new NameValuePair("fileName", fileName);
meta_list[1] = new NameValuePair("fileLength", String.valueOf(file.length()));
meta_list[2] = new NameValuePair("fileExt", ext);
meta_list[3] = new NameValuePair("fileAuthor", "rkg");
String successFilePath = FileManager.upload(new FastDFSFile(getByte(file), ext), null);
System.out.println("上传成功返回的路径是" + successFilePath);
return successFilePath;
}
private byte[] getByte(File file) {
byte[] bf = null;
try {
InputStream fis = new FileInputStream(file);
bf = new byte[fis.available()];
fis.read(bf);
} catch (Exception e) {
e.printStackTrace();
}
return bf;
}
@ResponseBody
@RequestMapping(value = "/add", method = RequestMethod.POST)
// public String add(@Validated User user, MultipartFile attach,
// HttpServletRequest request)
public String add(MultipartFile attach, HttpServletRequest request) throws IOException, MyException {
// 获取文件后缀名
String ext = attach.getOriginalFilename().substring(attach.getOriginalFilename().lastIndexOf(".") + 1);
FastDFSFile file = new FastDFSFile(attach.getBytes(), ext);
NameValuePair[] meta_list = new NameValuePair[4];
meta_list[0] = new NameValuePair("fileName", attach.getOriginalFilename());
meta_list[1] = new NameValuePair("fileLength", String.valueOf(attach.getSize()));
meta_list[2] = new NameValuePair("fileExt", ext);
meta_list[3] = new NameValuePair("fileAuthor", "rkg");
String filePath = FileManager.upload(file, meta_list);
// user.setFilePath(filePath);
// users.put(user.getUsername(), user);
return filePath;
}
// public ResponseEntity<byte[]> download(@PathVariable String filePath,
// HttpServletResponse response)
@RequestMapping(value = "/download", method = RequestMethod.GET)
public ResponseEntity<byte[]> download(@RequestParam("filePath") String filePath, HttpServletResponse response)
throws IOException, MyException {
// User u = users.get(username);
// String filePath = u.getFilePath();
// String filePath = "";
String substr = filePath.substring(filePath.indexOf("group"));
String group = substr.split("/")[0];
String remoteFileName = substr.substring(substr.indexOf("/") + 1);
// 重命名文件
String specFileName = "rkg" + substr.substring(substr.indexOf("."));
return FileManager.download(group, remoteFileName, specFileName);
}
}