mirror of
https://github.com/FreeeBird/hotel.git
synced 2025-11-02 05:24:46 +08:00
完成RoomTypeService类编写,通过单元测试
This commit is contained in:
@@ -3,7 +3,7 @@ package cn.mafangui.hotel.entity;
|
||||
import java.util.Date;
|
||||
|
||||
public class RoomType {
|
||||
private Long typeId;
|
||||
private Integer typeId;
|
||||
|
||||
private String roomType;
|
||||
|
||||
@@ -25,11 +25,11 @@ public class RoomType {
|
||||
|
||||
private Date updateTime;
|
||||
|
||||
public Long getTypeId() {
|
||||
public Integer getTypeId() {
|
||||
return typeId;
|
||||
}
|
||||
|
||||
public void setTypeId(Long typeId) {
|
||||
public void setTypeId(Integer typeId) {
|
||||
this.typeId = typeId;
|
||||
}
|
||||
|
||||
@@ -112,4 +112,21 @@ public class RoomType {
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RoomType{" +
|
||||
"typeId=" + typeId +
|
||||
", roomType='" + roomType + '\'' +
|
||||
", remark='" + remark + '\'' +
|
||||
", price=" + price +
|
||||
", discount=" + discount +
|
||||
", area=" + area +
|
||||
", bedNum=" + bedNum +
|
||||
", bedSize='" + bedSize + '\'' +
|
||||
", window=" + window +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,25 @@
|
||||
package cn.mafangui.hotel.mapper;
|
||||
|
||||
import cn.mafangui.hotel.entity.RoomType;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public interface RoomTypeMapper {
|
||||
int deleteByPrimaryKey(Long typeId);
|
||||
int deleteByPrimaryKey(Integer typeId);
|
||||
|
||||
int insert(RoomType record);
|
||||
|
||||
int insertSelective(RoomType record);
|
||||
|
||||
RoomType selectByPrimaryKey(Long typeId);
|
||||
RoomType selectByPrimaryKey(Integer typeId);
|
||||
|
||||
int updateByPrimaryKeySelective(RoomType record);
|
||||
|
||||
int updateByPrimaryKey(RoomType record);
|
||||
|
||||
List<RoomType> selectAll();
|
||||
|
||||
RoomType selectByRoomType(String roomType);
|
||||
}
|
||||
@@ -1,20 +1,20 @@
|
||||
package cn.mafangui.hotel.service;
|
||||
|
||||
import cn.mafangui.hotel.entity.RoomType;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public interface RoomTypeService {
|
||||
|
||||
int addRoomType(RoomType roomType);
|
||||
int insert(RoomType roomType);
|
||||
|
||||
int delRoomType(RoomType roomType);
|
||||
int delete(int typeId);
|
||||
|
||||
int delById(int typeId);
|
||||
int update(RoomType roomType);
|
||||
|
||||
int updateRoomType(RoomType roomType);
|
||||
|
||||
RoomType selectByName(RoomType roomType);
|
||||
RoomType selectByName(String roomType);
|
||||
|
||||
RoomType selectById(int typeId);
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package cn.mafangui.hotel.service.impl;
|
||||
|
||||
|
||||
import cn.mafangui.hotel.entity.RoomType;
|
||||
import cn.mafangui.hotel.mapper.RoomTypeMapper;
|
||||
import cn.mafangui.hotel.service.RoomTypeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class RoomTypeServiceImpl implements RoomTypeService {
|
||||
@Autowired
|
||||
private RoomTypeMapper roomTypeMapper;
|
||||
|
||||
@Override
|
||||
public int insert(RoomType roomType) {
|
||||
return roomTypeMapper.insertSelective(roomType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(int typeId) {
|
||||
return roomTypeMapper.deleteByPrimaryKey(typeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(RoomType roomType) {
|
||||
return roomTypeMapper.updateByPrimaryKeySelective(roomType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoomType selectByName(String roomType) {
|
||||
return roomTypeMapper.selectByRoomType(roomType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoomType selectById(int typeId) {
|
||||
return roomTypeMapper.selectByPrimaryKey(typeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoomType> findAllType() {
|
||||
return roomTypeMapper.selectAll();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user