1.更改字符串常量

2.添加数据库创建sql
This commit is contained in:
freeebird
2018-11-08 19:55:47 +08:00
parent 2d4657f00f
commit 643ef18f0a
6 changed files with 221 additions and 58 deletions

View File

@@ -3,7 +3,7 @@ package cn.mafangui.hotel.controller;
import cn.mafangui.hotel.entity.Room;
import cn.mafangui.hotel.service.RoomService;
import cn.mafangui.hotel.utils.finalString;
import cn.mafangui.hotel.utils.StaticString;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -20,25 +20,26 @@ public class RoomController {
* 增加房间
* @param roomNumber
* @param roomFloor
* @param roomType
* @param typeName
* @param roomPrice
* @param roomDiscount
* @param roomStatus
* @param remark
* @return
*/
@RequestMapping(value = "/add")
public HashMap addRoom(String roomNumber, int roomFloor, int roomType, String typeName, double roomPrice,double roomDiscount,String roomStatus){
public HashMap addRoom(String roomNumber, int roomFloor, String typeName,
double roomPrice,double roomDiscount,String roomStatus,String remark){
HashMap result = new HashMap();
int data = 0;
Room room = new Room(roomNumber,roomFloor,roomType,typeName,roomPrice,roomDiscount,roomStatus);
Room room = new Room(roomNumber,roomFloor,typeName,roomPrice,roomDiscount,roomStatus,remark);
try {
data = roomService.addRoom(room);
}catch (Exception e){
data = -1;
}
result.put(finalString.CODE,20000);
result.put(finalString.DATA,data);
result.put(StaticString.CODE,20000);
result.put(StaticString.DATA,data);
return result;
}
@@ -61,8 +62,8 @@ public class RoomController {
}catch (Exception e){
data = -1;
}
result.put(finalString.CODE,20000);
result.put(finalString.DATA,data);
result.put(StaticString.CODE,20000);
result.put(StaticString.DATA,data);
return result;
}
@@ -71,26 +72,27 @@ public class RoomController {
* @param roomId
* @param roomNumber
* @param roomFloor
* @param roomType
* @param typeName
* @param roomPrice
* @param roomDiscount
* @param roomStatus
* @param remark
* @return
*/
@RequestMapping(value = "/update")
public HashMap updateRoom(int roomId,String roomNumber, int roomFloor, int roomType, String typeName, double roomPrice,double roomDiscount,String roomStatus){
public HashMap updateRoom(int roomId,String roomNumber, int roomFloor, String typeName,
double roomPrice,double roomDiscount,String roomStatus,String remark){
HashMap result = new HashMap();
int data = 0;
Room room = new Room(roomNumber,roomFloor,roomType,typeName,roomPrice,roomDiscount,roomStatus);
Room room = new Room(roomNumber,roomFloor,typeName,roomPrice,roomDiscount,roomStatus,remark);
room.setRoomId(roomId);
try {
data = roomService.updateRoom(room);
}catch (Exception e){
data = -1;
}
result.put(finalString.CODE,20000);
result.put(finalString.DATA,data);
result.put(StaticString.CODE,20000);
result.put(StaticString.DATA,data);
return result;
}
@@ -101,8 +103,8 @@ public class RoomController {
@RequestMapping(value = "/all")
public HashMap allRoom(){
HashMap result = new HashMap();
result.put(finalString.DATA,roomService.findAll());
result.put(finalString.CODE,20000);
result.put(StaticString.DATA,roomService.findAll());
result.put(StaticString.CODE,20000);
return result;
}
@@ -115,11 +117,11 @@ public class RoomController {
@RequestMapping(value = "/withId")
public HashMap findRoomById(int roomId){
HashMap result = new HashMap();
result.put(finalString.CODE,20000);
result.put(StaticString.CODE,20000);
try{
result.put(finalString.DATA,roomService.findById(roomId));
result.put(StaticString.DATA,roomService.findById(roomId));
}catch (Exception e){
result.put(finalString.DATA,-1);
result.put(StaticString.DATA,-1);
}
return result;
}
@@ -132,11 +134,11 @@ public class RoomController {
@RequestMapping(value = "/withRoomNumber")
public HashMap findRoomByNumber(String roomNumber){
HashMap result = new HashMap();
result.put(finalString.CODE,20000);
result.put(StaticString.CODE,20000);
try{
result.put(finalString.DATA,roomService.findByNumber(roomNumber));
result.put(StaticString.DATA,roomService.findByNumber(roomNumber));
}catch (Exception e){
result.put(finalString.DATA,-1);
result.put(StaticString.DATA,-1);
}
return result;
}
@@ -149,11 +151,11 @@ public class RoomController {
@RequestMapping(value = "/withStatus")
public HashMap findRoomByStatus(String roomStatus){
HashMap result = new HashMap();
result.put(finalString.CODE,20000);
result.put(StaticString.CODE,20000);
try{
result.put(finalString.DATA,roomService.findByStatus(roomStatus));
result.put(StaticString.DATA,roomService.findByStatus(roomStatus));
}catch (Exception e){
result.put(finalString.DATA,-1);
result.put(StaticString.DATA,-1);
}
return result;
}
@@ -166,11 +168,11 @@ public class RoomController {
@RequestMapping(value = "/withType")
public HashMap findRoomByType(String typeName){
HashMap result = new HashMap();
result.put(finalString.CODE,20000);
result.put(StaticString.CODE,20000);
try{
result.put(finalString.DATA,roomService.findByType(typeName));
result.put(StaticString.DATA,roomService.findByType(typeName));
}catch (Exception e){
result.put(finalString.DATA,-1);
result.put(StaticString.DATA,-1);
}
return result;
}

View File

@@ -1,6 +1,6 @@
package cn.mafangui.hotel.entity;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;
public class Room {
@@ -10,9 +10,7 @@ public class Room {
private Integer roomFloor;
private Integer roomType;
private String typeName;
private String roomType;
private Double roomPrice;
@@ -20,6 +18,8 @@ public class Room {
private String roomStatus;
private String remark;
private Date createTime;
private Date updateTime;
@@ -48,22 +48,14 @@ public class Room {
this.roomFloor = roomFloor;
}
public Integer getRoomType() {
public String getRoomType() {
return roomType;
}
public void setRoomType(Integer roomType) {
public void setRoomType(String roomType) {
this.roomType = roomType;
}
public String getTypeName() {
return typeName;
}
public void setTypeName(String typeName) {
this.typeName = typeName;
}
public Double getRoomPrice() {
return roomPrice;
}
@@ -88,6 +80,14 @@ public class Room {
this.roomStatus = roomStatus == null ? null : roomStatus.trim();
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public Date getCreateTime() {
return createTime;
}
@@ -107,14 +107,14 @@ public class Room {
public Room() {
}
public Room(String roomNumber, Integer roomFloor, Integer roomType, String typeName, Double roomPrice, Double roomDiscount, String roomStatus) {
public Room(String roomNumber, Integer roomFloor, String roomType, Double roomPrice, Double roomDiscount, String roomStatus,String remark) {
this.roomNumber = roomNumber;
this.roomFloor = roomFloor;
this.roomType = roomType;
this.typeName = typeName;
this.roomPrice = roomPrice;
this.roomDiscount = roomDiscount;
this.roomStatus = roomStatus;
this.remark = remark;
}
@Override
@@ -123,8 +123,7 @@ public class Room {
"roomId=" + roomId +
", roomNumber='" + roomNumber + '\'' +
", roomFloor=" + roomFloor +
", roomType=" + roomType +
", typeName='" + typeName + '\'' +
", roomType='" + roomType + '\'' +
", roomPrice=" + roomPrice +
", roomDiscount=" + roomDiscount +
", roomStatus='" + roomStatus + '\'' +

View File

@@ -1,7 +1,8 @@
package cn.mafangui.hotel.utils;
public class finalString {
public class StaticString {
public static final String CODE = "code";
public static final String STATUS = "status";
public static final String DATA = "data";
}