This commit is contained in:
LitterDryFish
2019-09-08 11:57:31 +08:00
16 changed files with 614 additions and 381 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -22,4 +22,5 @@ public interface RoomDao {
int updateRoom(Room room);
}

View File

@@ -52,6 +52,9 @@ public class Child {
public void setChildLongId(String childLongId) {
this.childLongId = childLongId;
}
public void mySetChildLongId(String childLongId) {
this.childLongId = childLongId;
}
public String getChildName() {
return childName;
@@ -60,6 +63,9 @@ public class Child {
public void setChildName(String childName) {
this.childName = childName;
}
public void mySetChildName(String childName) {
this.childName = childName;
}
public String getChildSex() {
return childSex;
@@ -68,6 +74,9 @@ public class Child {
public void setChildSex(String childSex) {
this.childSex = childSex;
}
public void mySetChildSex(String childSex) {
this.childSex = childSex;
}
public String getChildAccount() {
return childAccount;
@@ -76,6 +85,9 @@ public class Child {
public void setChildAccount(String childAccount) {
this.childAccount = childAccount;
}
public void mySetChildAccount(String childAccount) {
this.childAccount = childAccount;
}
public String getChildPassword() {
return childPassword;
@@ -84,6 +96,9 @@ public class Child {
public void setChildPassword(String childPassword) {
this.childPassword = childPassword;
}
public void mySetChildPassword(String childPassword) {
this.childPassword = childPassword;
}
public String getChildPhone() {
return childPhone;
@@ -92,6 +107,9 @@ public class Child {
public void setChildPhone(String childPhone) {
this.childPhone = childPhone;
}
public void mySetChildPhone(String childPhone) {
this.childPhone = childPhone;
}
@Override
public String toString() {

View File

@@ -49,6 +49,7 @@ public class Parent {
this.parentBirth = parentBirth;
this.parentPhone = parentPhone;
}
public Parent(Long parentId, String parentLongId, String parentName, String parentSex, String parentAccount, String parentPassword, Double parentHeight, Double parentWeight, Date parentBirth, String parentPhone) {
this.parentId = parentId;
this.parentLongId = parentLongId;
@@ -70,6 +71,10 @@ public class Parent {
this.parentId = parentId;
}
public void mySetParentId(String parentId) {
this.parentId = Long.valueOf(parentId);
}
public String getParentLongId() {
return parentLongId;
}
@@ -78,6 +83,10 @@ public class Parent {
this.parentLongId = parentLongId;
}
public void mySetParentLongId(String parentLongId) {
this.parentLongId = parentLongId;
}
public String getParentName() {
return parentName;
}
@@ -86,6 +95,10 @@ public class Parent {
this.parentName = parentName;
}
public void mySetParentName(String parentName) {
this.parentName = parentName;
}
public String getParentSex() {
return parentSex;
}
@@ -94,6 +107,10 @@ public class Parent {
this.parentSex = parentSex;
}
public void mySetParentSex(String parentSex) {
this.parentSex = parentSex;
}
public String getParentAccount() {
return parentAccount;
}
@@ -102,6 +119,10 @@ public class Parent {
this.parentAccount = parentAccount;
}
public void mySetParentAccount(String parentAccount) {
this.parentAccount = parentAccount;
}
public String getParentPassword() {
return parentPassword;
}
@@ -110,6 +131,10 @@ public class Parent {
this.parentPassword = parentPassword;
}
public void mySetParentPassword(String parentPassword) {
this.parentPassword = parentPassword;
}
public double getParentHeight() {
return parentHeight;
}
@@ -118,6 +143,10 @@ public class Parent {
this.parentHeight = parentHeight;
}
public void mySetParentHeight(String parentHeight) {
this.parentHeight = Double.valueOf(parentHeight);
}
public double getParentWeight() {
return parentWeight;
}
@@ -126,6 +155,11 @@ public class Parent {
this.parentWeight = parentWeight;
}
public void mySetParentWeight(String parentWeight) {
this.parentWeight = Double.valueOf(parentWeight);
}
public Date getParentBirth() {
return parentBirth;
}
@@ -133,7 +167,8 @@ public class Parent {
public void setParentBirth(Date parentBirth) {
this.parentBirth = parentBirth;
}
public void setParentBirth(String parentBirth) {
public void mySetParentBirth(String parentBirth) {
this.parentBirth = Date.valueOf(parentBirth);
}
@@ -145,6 +180,10 @@ public class Parent {
this.parentPhone = parentPhone;
}
public void mySetParentPhone(String parentPhone) {
this.parentPhone = parentPhone;
}
public int getParentRoomId() {
return parentRoomId;
}
@@ -153,6 +192,11 @@ public class Parent {
this.parentRoomId = parentRoomId;
}
public void mySetParentRoomId(String parentRoomId) {
this.parentRoomId = Integer.valueOf(parentRoomId);
}
public Room getParentRoom() {
return parentRoom;
}

View File

@@ -11,6 +11,7 @@ public class Room {
private String roomName;
private long parentId;
private Parent parent;
private float temp;
public Room() {
}
@@ -18,19 +19,27 @@ public class Room {
public Room(String roomLocation, String roomName) {
this.roomLocation = roomLocation;
this.roomName = roomName;
}
public Room(String roomLocation, String roomName, float temp) {
this.roomLocation = roomLocation;
this.roomName = roomName;
this.temp = temp;
}
public Room(String roomLocation, String roomName, Long parentId) {
public Room(String roomLocation, String roomName, Long parentId, float temp) {
this.roomLocation = roomLocation;
this.roomName = roomName;
this.parentId = parentId;
this.temp = temp;
}
public Room(Integer roomId, String roomLocation, String roomName, Long parentId) {
public Room(Integer roomId, String roomLocation, String roomName, Long parentId, float temp) {
this.roomId = roomId;
this.roomName = roomName;
this.roomLocation = roomLocation;
this.parentId = parentId;
this.temp = temp;
}
public int getRoomId() {
@@ -65,6 +74,28 @@ public class Room {
this.parentId = parentId;
}
public float getTemp() {
return temp;
}
public void setTemp(float temp) {
this.temp = temp;
}
public void mySetTemp(String temp) {
this.temp = Float.valueOf(temp);
}
public void mySetRoomName(String roomName){
this.roomName = roomName;
}
public void mySetRoomLocation(String roomLocation) {
this.roomLocation = roomLocation;
}
public void mySetParentId(String parentId) {
this.parentId = Long.valueOf(parentId);
}
@Override
public String toString() {
return "Room{" +
@@ -73,6 +104,7 @@ public class Room {
", roomName='" + roomName + '\'' +
", parentId=" + parentId +
", parent=" + parent +
", temp=" + temp +
'}';
}
}

View File

@@ -21,4 +21,5 @@ public interface RoomService {
int delete(int roomId);
}

View File

@@ -48,4 +48,5 @@ public class RoomServiceImpl implements RoomService {
public int delete(int roomId) {
return roomDao.deleteRoom(roomId);
}
}

View File

@@ -13,7 +13,7 @@ public class MethodUtil {
public static void updateFields(Object obj, Map<String, Object> params)throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
Class<?> pClass = obj.getClass();
for (Map.Entry<String, Object> entry: params.entrySet()){
Method method = pClass.getMethod("set" + StringUtil.capital(entry.getKey()), entry.getValue().getClass());
Method method = pClass.getMethod("mySet" + StringUtil.capital(entry.getKey()), entry.getValue().getClass());
method.invoke(obj, entry.getValue());
}
}

View File

@@ -56,7 +56,7 @@ public class ParentController {
parent.setParentPassword(String.valueOf(params.get("parentPassword")));
parent.setParentAccount(String.valueOf(params.get("parentAccount")));
parent.setParentName(String.valueOf(params.get("parentName")));
parent.setParentBirth(String.valueOf(params.get("parentBirth")));
parent.mySetParentBirth(String.valueOf(params.get("parentBirth")));
parent.setParentLongId(String.valueOf(params.get("parentLongId")));
parentService.insert(parent);
return parentService.findByLongId(parent.getParentLongId());

View File

@@ -1,4 +1,4 @@
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/ssmtest?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
jdbc.username=root
jdbc.password=root
jdbc.password=

View File

@@ -9,6 +9,7 @@
<result column="location" property="roomLocation" jdbcType="VARCHAR"/>
<result column="name" property="roomName" jdbcType="VARCHAR"/>
<result column="pid" property="parentId" jdbcType="BIGINT"/>
<result column="temp" property="temp" jdbcType="FLOAT"/>
</resultMap>
<select id="findById" resultMap="BaseResultMap" parameterType="int">
@@ -35,7 +36,9 @@
update room
set location = #{roomLocation},
name = #{roomName},
pid = #{parentId}
pid = #{parentId},
temp = #{temp}
where id =#{roomId}
</update>
</mapper>

View File

@@ -31,7 +31,8 @@ CREATE TABLE `room` (
UNIQUE KEY `index` (`pid`) USING BTREE,
CONSTRAINT `room_fk_1` FOREIGN KEY (`pid`) REFERENCES `parent` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC;
ALTER TABLE `room`
ADD COLUMN `temp` float NULL COMMENT '房间温度阈值' AFTER `pid`;
CREATE TABLE `child` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`longid` char(18) NOT NULL COMMENT '身份证',

View File

@@ -50,8 +50,8 @@ public class ParentDaoTest extends BaseTest {
parent.setParentBirth(Date.valueOf("1927-4-5"));
parent.setParentName("当当娃");
parent.setParentAccount("dang");
parent.setParentHeight(12.1);
parent.setParentWeight(3112.1);
parent.setParentHeight(123.2);
parent.setParentWeight(1123.2);
parent.setParentPassword("123");
parent.setParentSex("");
parent.setParentPhone("12312312312");

View File

@@ -26,7 +26,7 @@ public class ParentServiceTest extends BaseTest {
parent.setParentPassword("a");
parent.setParentAccount("a");
parent.setParentName("a");
parent.setParentBirth("2011-2-2");
parent.mySetParentBirth("2011-2-2");
parent.setParentLongId("a");
parentService.insert(parent);
System.out.println(parentService.findByLongId("a"));

View File

@@ -0,0 +1,24 @@
package com.oldpeoplehome.service;
import com.oldpeoplehome.BaseTest;
import com.oldpeoplehome.entity.Room;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
/**
* Created By Jiangyuwei on 2019/9/7 11:10
* Description:
*/
public class RoomServiceTest extends BaseTest {
@Autowired
private RoomService roomService;
@Test
public void test(){
Room room = roomService.findById(1);
room.setTemp(22.2f);
roomService.update(room);
}
}

View File

@@ -24,15 +24,15 @@
* 房间表 room
| id | location | name | pid |
| :--: | :------: | :------: | :----: |
| 主键 | 房间位置 | 房间名称 | 老人id |
| id | location | name | pid | temp |
| :--: | :------: | :------: | :----: | :----------: |
| 主键 | 房间位置 | 房间名称 | 老人id | 房间温度阈值 |
* 运动表 motion
| pid | date | count | distance | time |
| :-------------: | :--: | :---: | :------: | :--: |
| parent id(外键) | 日期 | 步数 | 距离 | 时长 |
| pid | date | count | distance | energy | time |
| :-------------: | :--: | :---: | :------: | :--------: | :--: |
| parent id(外键) | 日期 | 步数 | 距离 | 消耗卡路里 | 时长 |
* 睡眠表 sleep
@@ -48,9 +48,9 @@
* 老人心率表 heartrate
| pid | time | rate |
| :--: | :------: | :--: |
| 老人 | 测量时间 | 心率 |
| pid | time | rate | rate1 | rate2 | oxy |
| :--: | :------: | :--: | :----: | :----: | :------: |
| 老人 | 测量时间 | 心率 | 收缩压 | 舒张压 | 血氧浓度 |
@@ -68,7 +68,7 @@
| Room | /room/list/empty | GET | 查询所有空置room信息(web端给老人分配房间) | |
| Room | /room/add | POST | 添加room | location:地点name:房间名 |
| Room | /room/delete/1 | DELETE | 删除id=1的room信息 | |
| Room | /room/update/1 | POST | 更新id=1的room信息 | **要更新的字段严格按照命名格式传参**比如name就传入roomName |
| Room | /room/update/1 | POST | 更新id=1的room信息 | **要更新的字段严格按照命名格式传参**比如name就传入roomName住房老人id parentId*设置温度阈值属性名为temp* |
| Parent | /parent/get/1 | GET | 查询id=1的parent的详细信息 | |
| Parent | /parent/get_longid/111 | GET | 查询身份证=111的parent的详细信息 | |
| Parent | /parent/get_name/老王 | GET | 查询姓名=老王的parent的详细信息 | |