mirror of
https://github.com/FreeeBird/hotel.git
synced 2025-05-06 19:49:26 +08:00
更新房间类型的接口
This commit is contained in:
parent
6063878687
commit
4680160c2f
@ -8,10 +8,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.awt.print.PrinterException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "room")
|
||||
@RequestMapping(value = "roomInfo")
|
||||
public class RoomController {
|
||||
|
||||
@Autowired
|
||||
@ -91,12 +92,11 @@ public class RoomController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/all")
|
||||
public List<Room> allRoom(){
|
||||
try {
|
||||
return roomService.findAll();
|
||||
}catch (Exception e){
|
||||
return null;
|
||||
}
|
||||
public HashMap allRoom(){
|
||||
HashMap result = new HashMap();
|
||||
result.put("data",roomService.findAll());
|
||||
result.put("code",20000);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -7,11 +7,13 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/roomType")
|
||||
public class RoomTypeController {
|
||||
private final String CODE = "code";
|
||||
private final String DATA = "data";
|
||||
|
||||
@Autowired
|
||||
private RoomTypeService roomTypeService;
|
||||
@ -22,26 +24,36 @@ public class RoomTypeController {
|
||||
* @param typeName
|
||||
* @param bookingPrice
|
||||
* @param bookingDiscount
|
||||
* @param remark
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.POST,value = "/add")
|
||||
public int addNewType(int roomType,String typeName,double bookingPrice,double bookingDiscount){
|
||||
RoomType rt = new RoomType(roomType,typeName,bookingPrice,bookingDiscount);
|
||||
return roomTypeService.addRoomType(rt);
|
||||
public HashMap addNewType(int roomType,String typeName,double bookingPrice,double bookingDiscount,String remark){
|
||||
HashMap result = new HashMap();
|
||||
result.put(CODE,20000);
|
||||
RoomType rt = new RoomType(roomType,typeName,bookingPrice,bookingDiscount,remark);
|
||||
result.put(DATA,roomTypeService.addRoomType(rt));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id
|
||||
* 删除房间类型
|
||||
* @param roomType
|
||||
* @param typeName
|
||||
* @param typeId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.POST,value = "/del")
|
||||
public int delType(int roomType,String typeName){
|
||||
RoomType rt = new RoomType();
|
||||
rt.setRoomType(roomType);
|
||||
rt.setTypeName(typeName);
|
||||
return roomTypeService.delRoomType(rt);
|
||||
public HashMap delType(int typeId){
|
||||
HashMap result = new HashMap();
|
||||
result.put(CODE,20000);
|
||||
result.put(DATA,roomTypeService.delById(typeId));
|
||||
return result;
|
||||
}
|
||||
|
||||
public HashMap massDeletion(int[] typeId){
|
||||
HashMap result = new HashMap();
|
||||
result.put(CODE,20000);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,21 +65,26 @@ public class RoomTypeController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.POST,value = "/update")
|
||||
public int updateType(int roomType,String typeName,double bookingPrice,double bookingDiscount){
|
||||
RoomType rt = new RoomType(roomType,typeName,bookingPrice,bookingDiscount);
|
||||
return roomTypeService.updateRoomType(rt);
|
||||
public HashMap updateType(int typeId,int roomType,String typeName,double bookingPrice,double bookingDiscount,String remark){
|
||||
HashMap result = new HashMap();
|
||||
result.put(CODE,20000);
|
||||
RoomType rt = new RoomType(roomType,typeName,bookingPrice,bookingDiscount,remark);
|
||||
rt.setTypeId(typeId);
|
||||
result.put(DATA,roomTypeService.updateRoomType(rt));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询房间类型
|
||||
* @param roomType
|
||||
* @param typeId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/query")
|
||||
public RoomType findByRoomType(int roomType){
|
||||
RoomType rt = new RoomType();
|
||||
rt.setRoomType(roomType);
|
||||
return roomTypeService.selectByName(rt);
|
||||
@RequestMapping(value = "/withId")
|
||||
public HashMap findByRoomType(int typeId){
|
||||
HashMap result = new HashMap();
|
||||
result.put(CODE,20000);
|
||||
result.put(DATA, roomTypeService.selectById(typeId));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,7 +92,10 @@ public class RoomTypeController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/all")
|
||||
public List<RoomType> findAllRoomType(){
|
||||
return roomTypeService.findAllType();
|
||||
public HashMap findAllRoomType(){
|
||||
HashMap result = new HashMap();
|
||||
result.put("code",20000);
|
||||
result.put("data",roomTypeService.findAllType());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,15 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/worker")
|
||||
public class WorkerController {
|
||||
private final String CODE = "code";
|
||||
private final String DATA = "data";
|
||||
@Autowired
|
||||
private WorkerService workerService;
|
||||
|
||||
@ -87,8 +91,11 @@ public class WorkerController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/all")
|
||||
public List<Worker> findAllWorkers(){
|
||||
return workerService.findAllWorker();
|
||||
public HashMap findAllWorkers(){
|
||||
HashMap result = new HashMap();
|
||||
result.put(CODE,20000);
|
||||
result.put(DATA,workerService.findAllWorker());
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,10 @@
|
||||
package cn.mafangui.hotel.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import cn.mafangui.hotel.utils.MyDateTimeFormat;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class RoomType {
|
||||
@ -14,10 +18,13 @@ public class RoomType {
|
||||
|
||||
private Double bookingDiscount;
|
||||
|
||||
private String remark;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
public Integer getTypeId() {
|
||||
return typeId;
|
||||
}
|
||||
@ -71,14 +78,23 @@ public class RoomType {
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public RoomType(Integer roomType, String typeName, Double bookingPrice, Double bookingDiscount) {
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public RoomType(Integer roomType, String typeName, Double bookingPrice, Double bookingDiscount,String remark) {
|
||||
this.roomType = roomType;
|
||||
this.typeName = typeName;
|
||||
this.bookingPrice = bookingPrice;
|
||||
this.bookingDiscount = bookingDiscount;
|
||||
this.remark = remark;
|
||||
}
|
||||
public RoomType(){}
|
||||
|
||||
@ -90,6 +106,7 @@ public class RoomType {
|
||||
", typeName='" + typeName + '\'' +
|
||||
", bookingPrice=" + bookingPrice +
|
||||
", bookingDiscount=" + bookingDiscount +
|
||||
", remark='" + remark + '\'' +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
'}';
|
||||
|
@ -10,9 +10,13 @@ public interface RoomTypeService {
|
||||
|
||||
int delRoomType(RoomType roomType);
|
||||
|
||||
int delById(int typeId);
|
||||
|
||||
int updateRoomType(RoomType roomType);
|
||||
|
||||
RoomType selectByName(RoomType roomType);
|
||||
|
||||
RoomType selectById(int typeId);
|
||||
|
||||
List<RoomType> findAllType();
|
||||
}
|
||||
|
@ -23,9 +23,14 @@ public class RoomTypeServiceImpl implements RoomTypeService {
|
||||
return roomTypeMapper.deleteByRoomType(roomType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delById(int typeId) {
|
||||
return roomTypeMapper.deleteByPrimaryKey(typeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateRoomType(RoomType roomType) {
|
||||
return roomTypeMapper.updateByRoomTypeSelective(roomType);
|
||||
return roomTypeMapper.updateByPrimaryKeySelective(roomType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -33,6 +38,11 @@ public class RoomTypeServiceImpl implements RoomTypeService {
|
||||
return roomTypeMapper.selectByRoomType(roomType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoomType selectById(int typeId) {
|
||||
return roomTypeMapper.selectByPrimaryKey(typeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoomType> findAllType() {
|
||||
return roomTypeMapper.findAll();
|
||||
|
6
src/main/java/cn/mafangui/hotel/utils/finalString.java
Normal file
6
src/main/java/cn/mafangui/hotel/utils/finalString.java
Normal file
@ -0,0 +1,6 @@
|
||||
package cn.mafangui.hotel.utils;
|
||||
|
||||
public class finalString {
|
||||
private final String CODE = "code";
|
||||
private final String DATA = "data";
|
||||
}
|
@ -8,7 +8,7 @@
|
||||
<result column="booking_price" jdbcType="DOUBLE" property="bookingPrice" />
|
||||
<result column="booking_discount" jdbcType="DOUBLE" property="bookingDiscount" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||
<result column="update_time" jdbcType="DATE" property="updateTime" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
type_id, room_type, type_name, booking_price, booking_discount, create_time, update_time
|
||||
@ -90,12 +90,7 @@
|
||||
<if test="bookingDiscount != null">
|
||||
booking_discount = #{bookingDiscount,jdbcType=REAL},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
update_time = now(),
|
||||
</set>
|
||||
where type_id = #{typeId,jdbcType=INTEGER}
|
||||
</update>
|
||||
|
Loading…
x
Reference in New Issue
Block a user