This commit is contained in:
ScorpioMiku
2019-08-21 14:41:09 +08:00
98 changed files with 2136 additions and 251 deletions

124
server/OldPeopleHome/.idea/uiDesigner.xml generated Normal file
View File

@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,23 @@
package com.oldpeoplehome.dao;
import com.oldpeoplehome.entity.Parent;
import java.awt.print.PrinterAbortException;
import java.util.List;
/**
* Created By Jiangyuwei on 2019/8/20 13:27
* Description:
*/
public interface ParentDao {
Parent findByID(long id);
Parent findByLongId(String longId);
Parent findByRoomId(int roomId);
Parent findByName(String name);
List<Parent> findAll();
void insert(Parent parent);
void update(Parent parent);
void delete(long id);
}

View File

@@ -14,8 +14,11 @@ public interface RoomDao {
//查所有房间
List<Room> findAll();
//添加房间
Room insertRoom(Room room);
int insertRoom(Room room);
//删除房间
int deleteRoom(int roomId);
//更新
int updateRoom(Room room);
}

View File

@@ -9,7 +9,7 @@ import java.sql.Date;
public class Parent {
private long parentId;
private long parentLongId;
private String parentLongId;
private String parentName;
private String parentSex;
private String parentAccount;
@@ -17,13 +17,27 @@ public class Parent {
private double parentHeight;
private double parentWeight;
private Date parentBirth;
private long parentPhone;
private String parentPhone;
private int parentRoomId;
private Room parentRoom;
public Parent() {
}
public Parent(long parentId, long parentLongId, String parentName, String parentSex, String parentAccount, String parentPassword, double parentHeight, double parentWeight, Date parentBirth, long parentPhone, int parentRoomId) {
public Parent(String parentLongId, String parentName, String parentSex, String parentAccount, String parentPassword, Double parentHeight, Double parentWeight, Date parentBirth, String parentPhone, Integer parentRoomId, Room parentRoom) {
this.parentLongId = parentLongId;
this.parentName = parentName;
this.parentSex = parentSex;
this.parentAccount = parentAccount;
this.parentPassword = parentPassword;
this.parentHeight = parentHeight;
this.parentWeight = parentWeight;
this.parentBirth = parentBirth;
this.parentPhone = parentPhone;
this.parentRoomId = parentRoomId;
this.parentRoom = parentRoom;
}
public Parent(Long parentId, String parentLongId, String parentName, String parentSex, String parentAccount, String parentPassword, Double parentHeight, Double parentWeight, Date parentBirth, String parentPhone, Integer parentRoomId, Room parentRoom) {
this.parentId = parentId;
this.parentLongId = parentLongId;
this.parentName = parentName;
@@ -35,21 +49,22 @@ public class Parent {
this.parentBirth = parentBirth;
this.parentPhone = parentPhone;
this.parentRoomId = parentRoomId;
this.parentRoom = parentRoom;
}
public long getParentId() {
return parentId;
}
public void setParentId(long parentId) {
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public long getParentLongId() {
public String getParentLongId() {
return parentLongId;
}
public void setParentLongId(long parentLongId) {
public void setParentLongId(String parentLongId) {
this.parentLongId = parentLongId;
}
@@ -89,7 +104,7 @@ public class Parent {
return parentHeight;
}
public void setParentHeight(double parentHeight) {
public void setParentHeight(Double parentHeight) {
this.parentHeight = parentHeight;
}
@@ -97,7 +112,7 @@ public class Parent {
return parentWeight;
}
public void setParentWeight(double parentWeight) {
public void setParentWeight(Double parentWeight) {
this.parentWeight = parentWeight;
}
@@ -108,12 +123,15 @@ public class Parent {
public void setParentBirth(Date parentBirth) {
this.parentBirth = parentBirth;
}
public void setParentBirth(String parentBirth) {
this.parentBirth = Date.valueOf(parentBirth);
}
public long getParentPhone() {
public String getParentPhone() {
return parentPhone;
}
public void setParentPhone(long parentPhone) {
public void setParentPhone(String parentPhone) {
this.parentPhone = parentPhone;
}
@@ -121,10 +139,18 @@ public class Parent {
return parentRoomId;
}
public void setParentRoomId(int parentRoomId) {
public void setParentRoomId(Integer parentRoomId) {
this.parentRoomId = parentRoomId;
}
public Room getParentRoom() {
return parentRoom;
}
public void setParentRoom(Room parentRoom) {
this.parentRoom = parentRoom;
}
@Override
public String toString() {
return "Parent{" +
@@ -139,6 +165,7 @@ public class Parent {
", parentBirth=" + parentBirth +
", parentPhone=" + parentPhone +
", parentRoomId=" + parentRoomId +
", parentRoom=" + parentRoom +
'}';
}
}

View File

@@ -13,7 +13,12 @@ public class Room {
public Room() {
}
public Room(int roomId, String roomLocation, String roomName) {
public Room(String roomLocation, String roomName) {
this.roomLocation = roomLocation;
this.roomName = roomName;
}
public Room(Integer roomId, String roomLocation, String roomName) {
this.roomId = roomId;
this.roomName = roomName;
this.roomLocation = roomLocation;
@@ -23,7 +28,7 @@ public class Room {
return roomId;
}
public void setRoomId(int roomId) {
public void setRoomId(Integer roomId) {
this.roomId = roomId;
}

View File

@@ -0,0 +1,20 @@
package com.oldpeoplehome.service;
import com.oldpeoplehome.entity.Parent;
import java.util.List;
/**
* Created By Jiangyuwei on 2019/8/20 18:07
* Description:
*/
public interface ParentService {
Parent findByID(long id);
Parent findByLongId(String longId);
Parent findByRoomId(int roomId);
Parent findByName(String name);
List<Parent> findAll();
void insert(Parent parent);
void update(Parent parent);
void delete(long id);
}

View File

@@ -0,0 +1,23 @@
package com.oldpeoplehome.service;
import com.oldpeoplehome.entity.Room;
import java.util.List;
/**
* Created By Jiangyuwei on 2019/8/19 21:26
* Description:
*/
public interface RoomService {
Room findById(int roomId);
List<Room> findAll();
int insert(Room room);
int update(Room room);
int delete(int roomId);
}

View File

@@ -0,0 +1,60 @@
package com.oldpeoplehome.service.impl;
import com.oldpeoplehome.dao.ParentDao;
import com.oldpeoplehome.entity.Parent;
import com.oldpeoplehome.service.ParentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Created By Jiangyuwei on 2019/8/20 18:08
* Description:
*/
@Service
public class ParentServiceImpl implements ParentService {
@Autowired
private ParentDao parentDao;
@Override
public Parent findByID(long id) {
return parentDao.findByID(id);
}
@Override
public Parent findByLongId(String longId) {
return parentDao.findByLongId(longId);
}
@Override
public Parent findByRoomId(int roomId) {
return parentDao.findByRoomId(roomId);
}
@Override
public Parent findByName(String name) {
return parentDao.findByName(name);
}
@Override
public List<Parent> findAll() {
return parentDao.findAll();
}
@Override
public void insert(Parent parent) {
parentDao.insert(parent);
}
@Override
public void update(Parent parent) {
parentDao.insert(parent);
}
@Override
public void delete(long id) {
parentDao.delete(id);
}
}

View File

@@ -0,0 +1,46 @@
package com.oldpeoplehome.service.impl;
import com.oldpeoplehome.dao.RoomDao;
import com.oldpeoplehome.entity.Room;
import com.oldpeoplehome.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.awt.print.Book;
import java.util.List;
/**
* Created By Jiangyuwei on 2019/8/19 21:27
* Description:
*/
@Service
public class RoomServiceImpl implements RoomService {
@Autowired
private RoomDao roomDao;
@Override
public Room findById(int roomId) {
return roomDao.findById(roomId);
}
@Override
public List<Room> findAll() {
return roomDao.findAll();
}
@Override
public int insert(Room room) {
return roomDao.insertRoom(room);
}
@Override
public int update(Room room) {
return roomDao.updateRoom(room);
}
@Override
public int delete(int roomId) {
return roomDao.deleteRoom(roomId);
}
}

View File

@@ -0,0 +1,22 @@
package com.oldpeoplehome.utils;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;
/**
* Created By Jiangyuwei on 2019/8/20 20:59
* Description:
*/
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.invoke(obj, entry.getValue());
}
}
}

View File

@@ -0,0 +1,35 @@
package com.oldpeoplehome.utils;
/**
* Created By Jiangyuwei on 2019/8/20 10:53
* Description:
*/
public class Result<T> {
private static String NULL = "[]";
private boolean success;
private T data;
private String error;
public Result(){}
public Result(boolean success, T data) {
this.success = success;
this.data = data;
this.error = NULL;
}
public Result(boolean success, String error) {
this.success = success;
this.error = error;
}
@Override
public String toString() {
return "{" +
"success=" + success +
", data=" + data +
", error='" + error + '\'' +
'}';
}
}

View File

@@ -0,0 +1,14 @@
package com.oldpeoplehome.utils;
/**
* Created By Jiangyuwei on 2019/8/20 16:31
* Description:
*/
public class StringUtil {
public static String capital(String s){
s = s.substring(0, 1).toUpperCase() + s.substring(1);
return s;
}
}

View File

@@ -0,0 +1,78 @@
package com.oldpeoplehome.web;
import com.oldpeoplehome.entity.Parent;
import com.oldpeoplehome.service.ParentService;
import com.oldpeoplehome.utils.MethodUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;
/**
* Created By Jiangyuwei on 2019/8/20 20:04
* Description:
*/
@RestController
@RequestMapping("/parent")
public class ParentController {
@Autowired
private ParentService parentService;
@RequestMapping("/get/{id}")
@ResponseBody
public Parent get(@PathVariable("id") String id){
return parentService.findByID(Long.valueOf(id));
}
@RequestMapping("/get_longid/{longid}")
@ResponseBody
public Parent getLong(@PathVariable("longid") String id){
return parentService.findByLongId(id);
}
@RequestMapping("/get_name/{name}")
@ResponseBody
public Parent getName(@PathVariable("name") String name){
return parentService.findByName(name);
}
@RequestMapping("/get_room/{room}")
@ResponseBody
public Parent getRoom(@PathVariable("room") String room){
return parentService.findByID(Integer.valueOf(room));
}
@RequestMapping("/list")
@ResponseBody
public List list() {
return parentService.findAll();
}
@RequestMapping(value = "/add", method = RequestMethod.POST)
@ResponseBody
public Parent add(Map<String, Object> params){
Parent parent = new Parent();
parent.setParentSex(String.valueOf(params.get("parentSex")));
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.setParentRoomId(Integer.valueOf(String.valueOf(params.get("parentRoomId"))));
parent.setParentLongId(String.valueOf(params.get("parentLongId")));
parentService.insert(parent);
return parentService.findByLongId(parent.getParentLongId());
}
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
public Parent update(Map<String, Object> params, @PathVariable("id") String id) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
Parent parent = parentService.findByID(Long.valueOf(id));
MethodUtil.updateFields(parent, params);
parentService.update(parent);
return parent;
}
@RequestMapping(value = "/delete/{id}", method = RequestMethod.DELETE)
@ResponseBody
public List<Parent> delete(@PathVariable("id") String id){
parentService.delete(Long.valueOf(id));
return parentService.findAll();
}
}

View File

@@ -0,0 +1,71 @@
package com.oldpeoplehome.web;
import com.oldpeoplehome.entity.Room;
import com.oldpeoplehome.service.RoomService;
import com.oldpeoplehome.utils.MethodUtil;
import com.oldpeoplehome.utils.Result;
import com.oldpeoplehome.utils.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
/**
* Created By Jiangyuwei on 2019/8/19 21:46
* Description:
*/
@RestController
@RequestMapping("/room")
public class RoomController {
@Autowired
private RoomService roomService;
@RequestMapping("/get/{id}")
@ResponseBody
public Room get(@PathVariable("id") String id) {
Room room = roomService.findById(Integer.valueOf(id));
System.out.println(room);
return room;
}
@RequestMapping("/list")
@ResponseBody
public List list() {
List<Room> list = roomService.findAll();
System.out.println(list);
return list;
}
@RequestMapping(value = "/add", method = RequestMethod.POST)
@ResponseBody
public Room add(@RequestParam Map<String, Object> param) {
Room room = new Room(String.valueOf(param.get("location")), String.valueOf(param.get("name")));
roomService.insert(room);
return room;
}
@RequestMapping(value = "/delete/{id}", method = RequestMethod.DELETE)
@ResponseBody
public List delete(@PathVariable("id") String id) {
roomService.delete(Integer.valueOf(id));
List<Room> list = roomService.findAll();
System.out.println(list);
return list;
}
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
public Room update(@RequestParam Map<String, Object> params, @PathVariable("id") String id) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
Room room = roomService.findById(Integer.valueOf(id));
MethodUtil.updateFields(room, params);
roomService.update(room);
return room;
}
}

View File

@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.oldpeoplehome.dao.ParentDao">
<resultMap id="BaseResultMap" type="com.oldpeoplehome.entity.Parent">
<id column="id" property="parentId" jdbcType="BIGINT"/>
<result column="longid" property="parentLongId" jdbcType="CHAR"/>
<result column="name" property="parentName" jdbcType="VARCHAR"/>
<result column="sex" property="parentSex" jdbcType="VARCHAR"/>
<result column="account" property="parentAccount" jdbcType="VARCHAR"/>
<result column="password" property="parentPassword" jdbcType="VARCHAR"/>
<result column="height" property="parentHeight" jdbcType="DOUBLE"/>
<result column="weight" property="parentWeight" jdbcType="DOUBLE"/>
<result column="birth" property="parentBirth" jdbcType="DATE"/>
<result column="phone" property="parentPhone" jdbcType="CHAR"/>
<result column="room" property="parentRoomId" jdbcType="INTEGER"/>
<association property="parentRoom" column="room" javaType="Room">
<id column="rid" property="roomId" jdbcType="INTEGER"/>
<result column="rlocation" property="roomLocation" jdbcType="VARCHAR"/>
<result column="rname" property="roomName" jdbcType="VARCHAR"/>
</association>
</resultMap>
<select id="findByID" parameterType="long" resultMap="BaseResultMap">
select p.*,r.id rid,r.name rname, r.location rlocation from parent p left join room r on p.id=r.id where p.id=#{parentId}
</select>
<select id="findByLongId" parameterType="String" resultMap="BaseResultMap">
select p.*,r.id rid,r.name rname, r.location rlocation from parent p left join room r on p.id=r.id where p.longid=#{parentLongId}
</select>
<select id="findByRoomId" parameterType="int" resultMap="BaseResultMap">
select p.*,r.id rid,r.name rname, r.location rlocation from parent p left join room r on p.id=r.id where p.room=#{p.parentRoomId}
</select>
<select id="findByName" parameterType="String" resultMap="BaseResultMap">
select p.*,r.id rid,r.name rname, r.location rlocation from parent p left join room r on p.id=r.id where p.name=#{p.parentName}
</select>
<select id="findAll" resultMap="BaseResultMap">
select p.*,r.id rid,r.name rname, r.location rlocation from parent p left join room r on p.id=r.id
</select>
<insert id="insert" parameterType="Parent" useGeneratedKeys="true" keyColumn="id" keyProperty="roomId">
insert into parent(longid,name,sex,account,password,height,weight,birth,phone,room)
values (#{parentLongId}, #{parentName}, #{parentSex}, #{parentAccount}, #{parentPassword}, #{parentHeight}, #{parentWeight}, #{parentBirth}, #{parentPhone}, #{parentRoomId})
</insert>
<update id="update" keyColumn="id">
update parent
set longid=#{parentLongId}, name=#{parentName}, sex=#{parentSex}, account=#{parentAccount}, password=#{parentPassword}, height=#{parentHeight}, weight=#{parentWeight}, birth=#{parentBirth}, phone=#{parentPhone}, room=#{parentRoomId}
where id=#{parentId}
</update>
<delete id="delete" parameterType="long">
delete from parent where id=#{parentId}
</delete>
</mapper>

View File

@@ -18,8 +18,18 @@
select * from room
</select>
<insert id="insertRoom">
<insert id="insertRoom" useGeneratedKeys="true" keyColumn="id" keyProperty="roomId" parameterType="Room">
insert into room(location, name) values (#{roomLocation}, #{roomName})
</insert>
<delete id="deleteRoom" parameterType="int">
delete from room where id = #{roomId}
</delete>
<update id="updateRoom" parameterType="Room">
update room
set location = #{roomLocation},
name = #{roomName}
where id =#{roomId}
</update>
</mapper>

View File

@@ -1,7 +1,41 @@
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1" metadata-complete="true">
<!-- 如果是用mvn命令生成的xml需要修改servlet版本为3.1 -->
<!-- 配置DispatcherServlet -->
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 配置springMVC需要加载的配置文件
spring-dao.xml,spring-service.xml,spring-web.xml
Mybatis - > spring -> springmvc
-->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/spring-*.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<!-- 默认匹配所有的请求 -->
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- Spring字符集过滤器 -->
<filter>
<filter-name>SpringEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>SpringEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

View File

@@ -0,0 +1,76 @@
package com.oldpeoplehome.dao;
import com.oldpeoplehome.BaseTest;
import com.oldpeoplehome.entity.Parent;
import com.oldpeoplehome.utils.StringUtil;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.sql.Date;
import java.util.HashMap;
import java.util.Map;
/**
* Created By Jiangyuwei on 2019/8/20 13:53
* Description:
*/
public class ParentDaoTest extends BaseTest {
@Autowired
private ParentDao parentDao;
@Test
public void testFindById(){
System.out.println( parentDao.findByID(1) );
}
@Test
public void testFindByName(){
System.out.println( parentDao.findByName("jiang") );
}
@Test
public void testFindByLong(){
System.out.println( parentDao.findByLongId("510703199706330018") );
}
@Test
public void testFindByRoom(){
System.out.println( parentDao.findByRoomId(1) );
}
@Test
public void testFindAll(){
System.out.println( parentDao.findAll() );
}
@Test
public void testInsert(){
Parent parent = new Parent();
parent.setParentLongId("510703199701230019");
parent.setParentBirth(Date.valueOf("1993-4-5"));
parent.setParentName("丁丁娃");
parent.setParentAccount("ding");
parent.setParentHeight(1232.1);
parent.setParentWeight(1312.1);
parent.setParentPassword("123");
parent.setParentRoomId(17);
parent.setParentSex("");
parent.setParentPhone("12312312312");
parentDao.insert(parent);
System.out.println(parent);
}
@Test
public void testUpdate()throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
Map<String, Object> params = new HashMap<>();
params.put("parentName", "咪咪娃");
params.put("parentBirth", "2017-2-23");
Parent parent = parentDao.findByID(6);
Class<?> pClass = parent.getClass();
for (Map.Entry<String, Object> entry: params.entrySet()){
Method method = pClass.getMethod("set"+ StringUtil.capital(entry.getKey()), entry.getValue().getClass());
System.out.println("***" + method);
method.invoke(parent, entry.getValue());
}
System.out.println(parent);
parentDao.update(parent);
}
}

View File

@@ -1,11 +1,15 @@
package com.oldpeoplehome.dao;
import com.oldpeoplehome.BaseTest;
import com.oldpeoplehome.entity.Parent;
import com.oldpeoplehome.entity.Room;
import com.oldpeoplehome.utils.StringUtil;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
/**
* Created By Jiangyuwei on 2019/8/19 15:01
@@ -29,4 +33,42 @@ public class RoomDaoTest extends BaseTest {
System.out.println(s);
}
@Test
public void testInsert(){
Room room = new Room("惠子楼", "241");
int s = roomDao.insertRoom(room);
System.out.println("*******" + s);
}
@Test
public void testDelete(){
int id = 3;
int s = roomDao.deleteRoom(id);
System.out.println("*******" + s);
}
@Test
public void testUpdate() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
int roomId = 4;
Map<String, Object> params = new HashMap<>();
params.put("roomLocation", "钉子楼");
params.put("roomName", "9128");
Room room = roomDao.findById(roomId);
Class<?> pClass = room.getClass();
for(Map.Entry<String, Object> entry: params.entrySet()){
Method method = pClass.getMethod("set"+StringUtil.capital(entry.getKey()), entry.getValue().getClass());
System.out.println("***" + method);
method.invoke(room, entry.getValue());
}
System.out.println(room);
roomDao.updateRoom(room);
}
@Test
public void testA(){
Parent parent = new Parent();
System.out.println(parent.getClass());
Object obj = parent;
System.out.println(obj.getClass());
}
}

Binary file not shown.

View File

@@ -0,0 +1,5 @@
Manifest-Version: 1.0
Built-By: Jiangyuwei
Created-By: IntelliJ IDEA
Build-Jdk: 1.8.0_161

View File

@@ -0,0 +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

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are by default assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="debug">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.oldpeoplehome.dao.ParentDao">
<resultMap id="BaseResultMap" type="com.oldpeoplehome.entity.Parent">
<id column="id" property="parentId" jdbcType="BIGINT"/>
<result column="longid" property="parentLongId" jdbcType="CHAR"/>
<result column="name" property="parentName" jdbcType="VARCHAR"/>
<result column="sex" property="parentSex" jdbcType="VARCHAR"/>
<result column="account" property="parentAccount" jdbcType="VARCHAR"/>
<result column="password" property="parentPassword" jdbcType="VARCHAR"/>
<result column="height" property="parentHeight" jdbcType="DOUBLE"/>
<result column="weight" property="parentWeight" jdbcType="DOUBLE"/>
<result column="birth" property="parentBirth" jdbcType="DATE"/>
<result column="phone" property="parentPhone" jdbcType="CHAR"/>
<result column="room" property="parentRoomId" jdbcType="INTEGER"/>
<association property="parentRoom" column="room" javaType="Room">
<id column="rid" property="roomId" jdbcType="INTEGER"/>
<result column="rlocation" property="roomLocation" jdbcType="VARCHAR"/>
<result column="rname" property="roomName" jdbcType="VARCHAR"/>
</association>
</resultMap>
<select id="findByID" parameterType="long" resultMap="BaseResultMap">
select p.*,r.id rid,r.name rname, r.location rlocation from parent p left join room r on p.id=r.id where p.id=#{parentId}
</select>
<select id="findByLongId" parameterType="String" resultMap="BaseResultMap">
select p.*,r.id rid,r.name rname, r.location rlocation from parent p left join room r on p.id=r.id where p.longid=#{parentLongId}
</select>
<select id="findByRoomId" parameterType="int" resultMap="BaseResultMap">
select p.*,r.id rid,r.name rname, r.location rlocation from parent p left join room r on p.id=r.id where p.room=#{p.parentRoomId}
</select>
<select id="findByName" parameterType="String" resultMap="BaseResultMap">
select p.*,r.id rid,r.name rname, r.location rlocation from parent p left join room r on p.id=r.id where p.name=#{p.parentName}
</select>
<select id="findAll" resultMap="BaseResultMap">
select p.*,r.id rid,r.name rname, r.location rlocation from parent p left join room r on p.id=r.id
</select>
<insert id="insert" parameterType="Parent" useGeneratedKeys="true" keyColumn="id" keyProperty="roomId">
insert into parent(longid,name,sex,account,password,height,weight,birth,phone,room)
values (#{parentLongId}, #{parentName}, #{parentSex}, #{parentAccount}, #{parentPassword}, #{parentHeight}, #{parentWeight}, #{parentBirth}, #{parentPhone}, #{parentRoomId})
</insert>
<update id="update" keyColumn="id">
update parent
set longid=#{parentLongId}, name=#{parentName}, sex=#{parentSex}, account=#{parentAccount}, password=#{parentPassword}, height=#{parentHeight}, weight=#{parentWeight}, birth=#{parentBirth}, phone=#{parentPhone}, room=#{parentRoomId}
where id=#{parentId}
</update>
<delete id="delete" parameterType="long">
delete from parent where id=#{parentId}
</delete>
</mapper>

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.oldpeoplehome.dao.RoomDao">
<resultMap id="BaseResultMap" type="com.oldpeoplehome.entity.Room">
<id column="id" property="roomId" jdbcType="INTEGER"/>
<result column="location" property="roomLocation" jdbcType="VARCHAR"/>
<result column="name" property="roomName" jdbcType="VARCHAR"/>
</resultMap>
<select id="findById" resultMap="BaseResultMap" parameterType="int">
select * from room where id = #{roomId}
</select>
<select id="findAll" resultMap="BaseResultMap">
select * from room
</select>
<insert id="insertRoom" useGeneratedKeys="true" keyColumn="id" keyProperty="roomId" parameterType="Room">
insert into room(location, name) values (#{roomLocation}, #{roomName})
</insert>
<delete id="deleteRoom" parameterType="int">
delete from room where id = #{roomId}
</delete>
<update id="updateRoom" parameterType="Room">
update room
set location = #{roomLocation},
name = #{roomName}
where id =#{roomId}
</update>
</mapper>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!-- 配置全局属性 -->
<settings>
<!-- 使用jdbc的getGeneratedKeys获取数据库自增主键值 -->
<setting name="useGeneratedKeys" value="true" />
<!-- 使用列别名替换列名 默认:true -->
<setting name="useColumnLabel" value="true" />
<!-- 开启驼峰命名转换:Table{create_time} -> Entity{createTime} -->
<setting name="mapUnderscoreToCamelCase" value="true" />
</settings>
</configuration>

View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!--配置数据库相关参数 -->
<context:property-placeholder location="classpath:jdbc.properties"/>
<!-- 2.数据库连接池 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<!-- 配置连接池属性 -->
<property name="driverClass" value="${jdbc.driver}"/>
<property name="jdbcUrl" value="${jdbc.url}"/>
<property name="user" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<!-- c3p0连接池的私有属性 -->
<property name="maxPoolSize" value="30"/>
<property name="minPoolSize" value="10"/>
<!-- 关闭连接后不自动commit -->
<property name="autoCommitOnClose" value="false"/>
<!-- 获取连接超时时间 -->
<property name="checkoutTimeout" value="10000"/>
<!-- 当获取连接失败重试次数 -->
<property name="acquireRetryAttempts" value="2"/>
</bean>
<!-- 3.配置SqlSessionFactory对象 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 注入数据库连接池 -->
<property name="dataSource" ref="dataSource"/>
<!-- 配置MyBaties全局配置文件:mybatis-config.xml -->
<property name="configLocation" value="classpath:mybatis-config.xml"/>
<!-- 扫描entity包 使用别名 -->
<property name="typeAliasesPackage" value="com.oldpeoplehome.entity"/>
<!-- 扫描sql配置文件:mapper需要的xml文件 -->
<property name="mapperLocations" value="classpath:mapper/*.xml"/>
</bean>
<!-- 4.配置扫描Dao接口包动态实现Dao接口注入到spring容器中 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!-- 注入sqlSessionFactory -->
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
<!-- 给出需要扫描Dao接口包 -->
<property name="basePackage" value="com.oldpeoplehome.dao"/>
</bean>
</beans>

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<!-- 扫描service包下所有使用注解的类型 -->
<context:component-scan base-package="com.oldpeoplehome.service" />
<!-- 配置事务管理器 -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<!-- 注入数据库连接池 -->
<property name="dataSource" ref="dataSource" />
</bean>
<!-- 配置基于注解的声明式事务 -->
<tx:annotation-driven transaction-manager="transactionManager" />
</beans>

View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- 配置SpringMVC -->
<!-- 1.开启SpringMVC注解模式 -->
<!-- 简化配置:
(1)自动注册DefaultAnootationHandlerMapping,AnotationMethodHandlerAdapter
(2)提供一些列数据绑定数字和日期的format @NumberFormat, @DateTimeFormat, xml,json默认读写支持
-->
<mvc:annotation-driven />
<!-- 2.静态资源默认servlet配置
(1)加入对静态资源的处理js,gif,png
(2)允许使用"/"做整体映射
-->
<mvc:default-servlet-handler/>
<!-- 3.配置jsp 显示ViewResolver -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<!-- 4.扫描web相关的bean -->
<context:component-scan base-package="com.oldpeoplehome.web" />
<context:component-scan base-package="com.oldpeoplehome">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
</beans>

View File

@@ -0,0 +1,41 @@
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1" metadata-complete="true">
<!-- 如果是用mvn命令生成的xml需要修改servlet版本为3.1 -->
<!-- 配置DispatcherServlet -->
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 配置springMVC需要加载的配置文件
spring-dao.xml,spring-service.xml,spring-web.xml
Mybatis - > spring -> springmvc
-->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/spring-*.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<!-- 默认匹配所有的请求 -->
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- Spring字符集过滤器 -->
<filter>
<filter-name>SpringEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>SpringEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

View File

@@ -0,0 +1,5 @@
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>

View File

@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.oldpeoplehome.dao.ParentDao">
<resultMap id="BaseResultMap" type="com.oldpeoplehome.entity.Parent">
<id column="id" property="parentId" jdbcType="BIGINT"/>
<result column="longid" property="parentLongId" jdbcType="CHAR"/>
<result column="name" property="parentName" jdbcType="VARCHAR"/>
<result column="sex" property="parentSex" jdbcType="VARCHAR"/>
<result column="account" property="parentAccount" jdbcType="VARCHAR"/>
<result column="password" property="parentPassword" jdbcType="VARCHAR"/>
<result column="height" property="parentHeight" jdbcType="DOUBLE"/>
<result column="weight" property="parentWeight" jdbcType="DOUBLE"/>
<result column="birth" property="parentBirth" jdbcType="DATE"/>
<result column="phone" property="parentPhone" jdbcType="CHAR"/>
<result column="room" property="parentRoomId" jdbcType="INTEGER"/>
<association property="parentRoom" column="room" javaType="Room">
<id column="rid" property="roomId" jdbcType="INTEGER"/>
<result column="rlocation" property="roomLocation" jdbcType="VARCHAR"/>
<result column="rname" property="roomName" jdbcType="VARCHAR"/>
</association>
</resultMap>
<select id="findByID" parameterType="long" resultMap="BaseResultMap">
select p.*,r.id rid,r.name rname, r.location rlocation from parent p left join room r on p.id=r.id where p.id=#{parentId}
</select>
<select id="findByLongId" parameterType="String" resultMap="BaseResultMap">
select p.*,r.id rid,r.name rname, r.location rlocation from parent p left join room r on p.id=r.id where p.longid=#{parentLongId}
</select>
<select id="findByRoomId" parameterType="int" resultMap="BaseResultMap">
select p.*,r.id rid,r.name rname, r.location rlocation from parent p left join room r on p.id=r.id where p.room=#{p.parentRoomId}
</select>
<select id="findByName" parameterType="String" resultMap="BaseResultMap">
select p.*,r.id rid,r.name rname, r.location rlocation from parent p left join room r on p.id=r.id where p.name=#{p.parentName}
</select>
<select id="findAll" resultMap="BaseResultMap">
select p.*,r.id rid,r.name rname, r.location rlocation from parent p left join room r on p.id=r.id
</select>
<insert id="insert" parameterType="Parent" useGeneratedKeys="true" keyColumn="id" keyProperty="roomId">
insert into parent(longid,name,sex,account,password,height,weight,birth,phone,room)
values (#{parentLongId}, #{parentName}, #{parentSex}, #{parentAccount}, #{parentPassword}, #{parentHeight}, #{parentWeight}, #{parentBirth}, #{parentPhone}, #{parentRoomId})
</insert>
<update id="update" keyColumn="id">
update parent
set longid=#{parentLongId}, name=#{parentName}, sex=#{parentSex}, account=#{parentAccount}, password=#{parentPassword}, height=#{parentHeight}, weight=#{parentWeight}, birth=#{parentBirth}, phone=#{parentPhone}, room=#{parentRoomId}
where id=#{parentId}
</update>
<delete id="delete" parameterType="long">
delete from parent where id=#{parentId}
</delete>
</mapper>

View File

@@ -18,5 +18,18 @@
select * from room
</select>
<insert id="insertRoom" useGeneratedKeys="true" keyColumn="id" keyProperty="roomId" parameterType="Room">
insert into room(location, name) values (#{roomLocation}, #{roomName})
</insert>
<delete id="deleteRoom" parameterType="int">
delete from room where id = #{roomId}
</delete>
<update id="updateRoom" parameterType="Room">
update room
set location = #{roomLocation},
name = #{roomName}
where id =#{roomId}
</update>
</mapper>

View File

@@ -1079,4 +1079,388 @@ body.xml #x {background: transparent url("/ui2019/bg-retina.png") -730px -48
body.webbuilding #w {background: transparent url("/ui2019/bg-retina.png") -843px -48px no-repeat; background-size: auto 900px;}
body.reference #r {background: transparent url("/ui2019/bg-retina.png") -1040px -48px no-repeat; background-size: auto 900px;}
}
}
*
{
margin:0;
padding:0;
border:0;
}
body
{
font-family:PingFangSC-Regular, Verdana, Arial, '微软雅黑','宋体';
font-size:15px;
}
div#maincontent div#intro {
padding-top: 45px;
padding-bottom: 45px;
font-size:24px;
font-family:'微软雅黑';
color:#3f3f3f;
font-weight:400;
}
span.parameter {
font-style: italic;
color: #000;
}
div#maincontent h2
{
font-size: 30px;
font-weight: 400;
color:#3f3f3f;
}
body#homefirst div#maincontent, div#maincontent h1, div#maincontent h2, div#sidebar div#ad h2
{
font-family:'微软雅黑';
}
pre, pre code, div#maincontent input, div#maincontent select, div#maincontent textarea
{
font-family:Consolas, "Courier New", Courier, monospace;
}
h2, h3, h4, h5, h6, em
{
font-weight: bold;
}
p.note span, p.important span, p.tip span, p.inherited, p.inherited span, p.gototop, .html5_new_note span
{
font-weight: bold;
}
p.tip span {
color:#ff9955;
}
p.tip2 {
background: #BBEDB8 url(/ui2017/tip.png) top left no-repeat;
display:block;
padding:15px 15px 15px 50px;
color:#000;
border-radius:5px;
background-position:15px 15px;
}
body#homesecond div#navsecond li
{
font-weight:bold;
}
div#sidebar div#ad h2, body#homefirst div#maincontent h3
{
font-size: 14px;
}
div#maincontent h3
{
font-size: 16px;
}
div#maincontent h4
{
font-size: 14px;
}
div#maincontent button, div#maincontent input, div#maincontent select, div#maincontent textarea
{
font-size:12px;
}
body#homefirst div#maincontent div#w3 h2
{
font-size:20px;
}
em
{
font-style:normal;
}
pre code
{
color:#0000dd;
}
.html5_new_note
{
background: #ffffff url(/i/html5_new_note.png) top left no-repeat;
padding-left:20px;
}
.html5_new_note span
{
color:blue;
}
p.gototop
{
text-align:right;
}
div#maincontent button
{
margin-top:15px;
}
/* ----------------------------------- layout ----------------------------------- */
html {
min-width: 1210px;
background-color: #fdfcf8;
overflow:scroll;
overflow-x:hidden;
}
body
{
text-align: center;
margin: 0;
padding: 0;
border: 0;
background: #fdfcf8;
}
div#wrapper
{
margin: 0 auto;
padding: 0;
border: 0;
width: 1239px;
text-align: left;
background: transparent url(/ui2017/wrapper.png) top left repeat-y;
}
div#navsecond
{
float: left;
margin: 0 0 0 6px;
padding: 0;
border: 0;
width: 180px;
background : transparent;
}
html>body div#navsecond
{
margin-left: 12px;
}
div#maincontent
{
float: left;
margin: 0;
padding: 30px 0 0 0;
border: 0;
width: 850px;
background: transparent;
}
div#maincontent div{
width: 810px;
margin: 0 0 0 25px;
padding: 30px 0 35px 0;
border:0;
border-bottom: 1px solid #aaa;
}
div#sidebar
{
float: left;
margin: 0;
padding: 0;
border: 0;
width: 180px;
background: transparent;
}
div#footer
{
clear: both;
margin: 0;
padding-top: 16px;
margin-left: 12px;
width: 1210px;
line-height:24px;
background: #f0f0f0;
border-top: 0px solid #fff;
background: #fdfcf8 url(/ui2017/footer.png) top left repeat-x;
font-family:PingFangSC-Regular, '微软雅黑', Verdana, Arial, '宋体';
*
{
margin:0;
padding:0;
border:0;
}
body
{
font-family:PingFangSC-Regular, Verdana, Arial, '微软雅黑','宋体';
font-size:15px;
}
div#maincontent div#intro {
padding-top: 45px;
padding-bottom: 45px;
font-size:24px;
font-family:'微软雅黑';
color:#3f3f3f;
font-weight:400;
}
span.parameter {
font-style: italic;
color: #000;
}
div#maincontent h2
{
font-size: 30px;
font-weight: 400;
color:#3f3f3f;
}
body#homefirst div#maincontent, div#maincontent h1, div#maincontent h2, div#sidebar div#ad h2
{
font-family:'微软雅黑';
}
*
{
margin:0;
padding:0;
border:0;
}
body
{
font-family:PingFangSC-Regular, Verdana, Arial, '微软雅黑','宋体';
font-size:15px;
}
div#maincontent div#intro {
padding-top: 45px;
padding-bottom: 45px;
font-size:24px;
font-family:'微软雅黑';
color:#3f3f3f;
font-weight:400;
}
span.parameter {
font-style: italic;
color: #000;
}
div#maincontent h2
{
font-size: 30px;
font-weight: 400;
color:#3f3f3f;
}
body#homefirst div#maincontent, div#maincontent h1, div#maincontent h2, div#sidebar div#ad h2
{
font-family:'微软雅黑';
}
pre, pre code, div#maincontent input, div#maincontent select, div#maincontent textarea
{
font-family:Consolas, "Courier New", Courier, monospace;
}
h2, h3, h4, h5, h6, em
{
font-weight: bold;
}
p.note span, p.important span, p.tip span, p.inherited, p.inherited span, p.gototop, .html5_new_note span
{
font-weight: bold;
}
p.tip span {
color:#ff9955;
}
p.tip2 {
background: #BBEDB8 url(/ui2017/tip.png) top left no-repeat;
display:block;
padding:15px 15px 15px 50px;
color:#000;
border-radius:5px;
background-position:15px 15px;
}
body#homesecond div#navsecond li
{
font-weight:bold;
}
div#sidebar div#ad h2, body#homefirst div#maincontent h3
{
font-size: 14px;
}
div#maincontent h3
{
font-size: 16px;
}
div#maincontent h4
{
font-size: 14px;
}
div#maincontent button, div#maincontent input, div#maincontent select, div#maincontent textarea
{
font-size:12px;
}
body#homefirst div#maincontent div#w3 h2
{
font-size:20px;
}
em
{
font-style:normal;
}
pre code
{
color:#0000dd;
}
.html5_new_note
{
background: #ffffff url(/i/html5_new_note.png) top left no-repeat;
padding-left:20px;
}
.html5_new_note span
{
color:blue;
}
p.gototop
{
text-align:right;
}
div#maincontent button
{
margin-top:15px;
}
/* ----------------------------------- layout ----------------------------------- */