体温上报 历史上报信息
This commit is contained in:
@@ -13,8 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/access/report")
|
||||
@@ -26,12 +25,21 @@ public class ReportController {
|
||||
@Autowired
|
||||
private ReportServiceImpl reportService;
|
||||
|
||||
/**
|
||||
* 体温上报
|
||||
*
|
||||
* @param id
|
||||
* @param address
|
||||
* @param timestamp
|
||||
* @param temperature
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ResponseBody
|
||||
public Res getCodeInfo(@RequestParam("userId") Integer id,
|
||||
@RequestParam("address") String address,
|
||||
@RequestParam("timestamp") Long timestamp,
|
||||
@RequestParam("temperature") Integer temperature) {
|
||||
public Res submit(@RequestParam("userId") Integer id,
|
||||
@RequestParam("address") String address,
|
||||
@RequestParam("timestamp") Long timestamp,
|
||||
@RequestParam("temperature") Integer temperature) {
|
||||
User user = userService.getUserById(id);
|
||||
if (user == null) {
|
||||
return Res.error("用户不存在");
|
||||
@@ -53,4 +61,37 @@ public class ReportController {
|
||||
|
||||
return Res.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户填报信息
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getRecordList")
|
||||
@ResponseBody
|
||||
public Res getRecordList(@RequestParam("userId") Integer userId) {
|
||||
User user = userService.getUserById(userId);
|
||||
if (user == null) {
|
||||
return Res.error("用户不存在");
|
||||
}
|
||||
List<Report> records = reportService.getRecordListByUserId(user.getId());
|
||||
return Res.success(records);
|
||||
}
|
||||
/**
|
||||
* 获取最近一次用户填报信息
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getLatestRecord")
|
||||
@ResponseBody
|
||||
public Res getLatestRecord(@RequestParam("userId") Integer userId) {
|
||||
User user = userService.getUserById(userId);
|
||||
if (user == null) {
|
||||
return Res.error("用户不存在");
|
||||
}
|
||||
Report records = reportService.getLatestRecordByUserId(user.getId());
|
||||
return Res.success(records);
|
||||
}
|
||||
}
|
||||
|
@@ -4,8 +4,14 @@ import com.cxyxiaomo.epp.common.pojo.Report;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface ReportDao {
|
||||
Integer insert(Report report);
|
||||
|
||||
List<Report> getReportListByUserId(Integer userId);
|
||||
|
||||
Report getLatestReportByUserId(Integer userId);
|
||||
}
|
||||
|
@@ -2,6 +2,13 @@ package com.cxyxiaomo.epp.access.service;
|
||||
|
||||
import com.cxyxiaomo.epp.common.pojo.Report;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ReportService {
|
||||
|
||||
void addRecord(Report report);
|
||||
|
||||
List<Report> getRecordListByUserId(Integer userId);
|
||||
|
||||
Report getLatestRecordByUserId(Integer userId);
|
||||
}
|
||||
|
@@ -5,6 +5,8 @@ import com.cxyxiaomo.epp.common.pojo.Report;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ReportServiceImpl implements ReportService {
|
||||
|
||||
@@ -15,4 +17,12 @@ public class ReportServiceImpl implements ReportService {
|
||||
public void addRecord(Report report) {
|
||||
reportDao.insert(report);
|
||||
}
|
||||
|
||||
public List<Report> getRecordListByUserId(Integer userId) {
|
||||
return reportDao.getReportListByUserId(userId);
|
||||
}
|
||||
|
||||
public Report getLatestRecordByUserId(Integer userId) {
|
||||
return reportDao.getLatestReportByUserId(userId);
|
||||
}
|
||||
}
|
||||
|
@@ -7,4 +7,15 @@
|
||||
INSERT INTO report (`user_id`, `name`, `address`, `time`, `temperature`)
|
||||
VALUES (#{userId}, #{name}, #{address}, #{time}, #{temperature})
|
||||
</insert>
|
||||
<select id="getReportListByUserId" parameterType="java.lang.Integer" resultType="com.cxyxiaomo.epp.common.pojo.Report">
|
||||
SELECT * FROM report
|
||||
WHERE `user_id` = #{userId}
|
||||
order by time desc
|
||||
</select>
|
||||
<select id="getLatestReportByUserId" parameterType="java.lang.Integer" resultType="com.cxyxiaomo.epp.common.pojo.Report">
|
||||
SELECT * FROM report
|
||||
WHERE `user_id` = #{userId}
|
||||
order by time desc
|
||||
LIMIT 1
|
||||
</select>
|
||||
</mapper>
|
||||
|
Reference in New Issue
Block a user