Commit edb6c827 by luozhenzhen

新增数据业务上传接口

parent a3f29f4f
<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</groupId>
<artifactId>mongodb</artifactId>
<artifactId>deviceCheat</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
......
......@@ -5,13 +5,20 @@ import org.springframework.data.mongodb.core.mapping.Document;
@Document(collection="BusinData")
public class BusinData {
private String StBusinData;
private String stBusinData;
public String getStBusinData() {
return StBusinData;
return stBusinData;
}
public void setStBusinData(String stBusinData) {
StBusinData = stBusinData;
stBusinData = stBusinData;
}
@Override
public String toString() {
return "BusinData{" +
"stBusinData='" + stBusinData + '\'' +
'}';
}
}
package com.demo.mongodb;
import com.alibaba.fastjson.JSONObject;
import com.demo.constant.ResultStatus;
import com.demo.entity.po.BusinData;
import com.demo.entity.po.ExceptionRecord;
......@@ -9,8 +10,11 @@ import com.demo.entity.vo.SensorVo;
import com.demo.service.DeviceService;
import com.demo.util.FileEncryptor;
import com.demo.util.ResultObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
......@@ -23,6 +27,8 @@ import java.util.Map;
@RequestMapping("/")
public class DevicecheatController {
private final Logger logger = LoggerFactory.getLogger(DevicecheatController.class);
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
......@@ -142,11 +148,17 @@ public class DevicecheatController {
*/
@RequestMapping(value = "/businData", method = RequestMethod.POST)
@ResponseBody
public ResultObject businData(BusinData data) throws Exception {
public ResultObject businData(@RequestBody BusinData data) throws Exception {
logger.info("/businData : {}" , data.toString());
if(data == null || StringUtils.isEmpty(data.getStBusinData())){
return new ResultObject(ResultStatus.FAIL);
}
deviceService.insertBusinData(data);
return new ResultObject(ResultStatus.SUCCESS);
}
}
......@@ -2,7 +2,7 @@ server.port=8081
spring.data.mongodb.host=192.168.168.81
spring.data.mongodb.port=8763
spring.data.mongodb.database=device
server.ssl.key-store=classpath:keystore.p12_win
server.ssl.key-store=classpath:keystore.p12
server.ssl.key-store-password=123456
server.ssl.key-store-type=PKCS12
server.ssl.key-alias= tomcat
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment