体温上报功能完成;小程序更新npm依赖版本
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
package com.cxyxiaomo.epp.access.controller;
|
||||
|
||||
import com.cxyxiaomo.epp.access.rpc.UserServiceFeign;
|
||||
import com.cxyxiaomo.epp.access.service.ReportServiceImpl;
|
||||
import com.cxyxiaomo.epp.common.pojo.Report;
|
||||
import com.cxyxiaomo.epp.common.pojo.User;
|
||||
import com.cxyxiaomo.epp.common.response.Res;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
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;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/access/report")
|
||||
public class ReportController {
|
||||
|
||||
@Autowired
|
||||
private UserServiceFeign userService;
|
||||
|
||||
@Autowired
|
||||
private ReportServiceImpl reportService;
|
||||
|
||||
@PostMapping("/submit")
|
||||
@ResponseBody
|
||||
public Res getCodeInfo(@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("用户不存在");
|
||||
}
|
||||
|
||||
// 查询数据库,判断当天是否已经填报过
|
||||
|
||||
Calendar instance = Calendar.getInstance();
|
||||
instance.setTimeInMillis(timestamp);
|
||||
|
||||
Report report = new Report();
|
||||
report.setAddress(address);
|
||||
report.setName(user.getRealname());
|
||||
report.setTime(instance.getTime());
|
||||
report.setUserId(user.getId());
|
||||
report.setTemperature(temperature);
|
||||
|
||||
reportService.addRecord(report);
|
||||
|
||||
return Res.success();
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
package com.cxyxiaomo.epp.access.dao;
|
||||
|
||||
import com.cxyxiaomo.epp.common.pojo.Report;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface ReportDao {
|
||||
Integer insert(Report report);
|
||||
}
|
@@ -6,7 +6,7 @@ import org.springframework.stereotype.Repository;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface AccessDao {
|
||||
public interface SettingDao {
|
||||
Integer updateSetting(Setting setting);
|
||||
|
||||
Setting getValueByKey(String key);
|
@@ -1,7 +1,6 @@
|
||||
package com.cxyxiaomo.epp.access.service;
|
||||
|
||||
import com.cxyxiaomo.epp.common.pojo.User;
|
||||
import com.cxyxiaomo.epp.access.dao.AccessDao;
|
||||
import com.cxyxiaomo.epp.access.dao.SettingDao;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -9,6 +8,6 @@ import org.springframework.stereotype.Service;
|
||||
public class AccessServiceImpl implements AccessService {
|
||||
|
||||
@Autowired
|
||||
private AccessDao accessDao;
|
||||
private SettingDao accessDao;
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,7 @@
|
||||
package com.cxyxiaomo.epp.access.service;
|
||||
|
||||
import com.cxyxiaomo.epp.common.pojo.Report;
|
||||
|
||||
public interface ReportService {
|
||||
void addRecord(Report report);
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
package com.cxyxiaomo.epp.access.service;
|
||||
|
||||
import com.cxyxiaomo.epp.access.dao.ReportDao;
|
||||
import com.cxyxiaomo.epp.common.pojo.Report;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ReportServiceImpl implements ReportService {
|
||||
|
||||
@Autowired
|
||||
ReportDao reportDao;
|
||||
|
||||
@Override
|
||||
public void addRecord(Report report) {
|
||||
reportDao.insert(report);
|
||||
}
|
||||
}
|
@@ -2,7 +2,7 @@ package com.cxyxiaomo.epp.access.service;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.cxyxiaomo.epp.access.dao.AccessDao;
|
||||
import com.cxyxiaomo.epp.access.dao.SettingDao;
|
||||
import com.cxyxiaomo.epp.access.pojo.UnlimitedQRCodeParam;
|
||||
import com.cxyxiaomo.epp.access.utils.RestUtil;
|
||||
import com.cxyxiaomo.epp.common.pojo.Setting;
|
||||
@@ -20,7 +20,7 @@ import java.util.Map;
|
||||
public class WeChatTokenServiceImpl implements WeChatTokenService {
|
||||
|
||||
@Autowired
|
||||
AccessDao accessDao;
|
||||
SettingDao accessDao;
|
||||
|
||||
// 数据库中该 key 保存的 time 是失效时间
|
||||
final String SETTING_KEY = "wechat_access_token";
|
||||
|
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.cxyxiaomo.epp.access.dao.ReportDao">
|
||||
<insert id="insert" parameterType="com.cxyxiaomo.epp.common.pojo.Report">
|
||||
INSERT INTO report (`user_id`, `name`, `address`, `time`, `temperature`)
|
||||
VALUES (#{userId}, #{name}, #{address}, #{time}, #{temperature})
|
||||
</insert>
|
||||
</mapper>
|
@@ -2,7 +2,7 @@
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.cxyxiaomo.epp.access.dao.AccessDao">
|
||||
<mapper namespace="com.cxyxiaomo.epp.access.dao.SettingDao">
|
||||
<insert id="updateSetting" parameterType="com.cxyxiaomo.epp.common.pojo.Setting">
|
||||
INSERT INTO setting (`key`, `value`, `time`)
|
||||
VALUES (#{key}, #{value}, #{time})
|
Reference in New Issue
Block a user