完成预订方式接口编写

This commit is contained in:
freeebird
2018-11-15 19:00:19 +08:00
parent 4e51fe2a51
commit c8124bbc70
11 changed files with 160 additions and 19 deletions

View File

@@ -2,6 +2,7 @@ package cn.mafangui.hotel.controller;
import cn.mafangui.hotel.entity.Room;
import cn.mafangui.hotel.entity.RoomType;
import cn.mafangui.hotel.entity.Worker;
import cn.mafangui.hotel.service.RoomService;
import cn.mafangui.hotel.service.RoomTypeService;
import cn.mafangui.hotel.service.WorkerService;
@@ -36,7 +37,13 @@ public class AdminController {
else return 0;
}
// TODO
@RequestMapping(method = RequestMethod.POST,value = "/withUsername")
public Worker getByUsername(String username) {
Worker res = workerService.selectByUsername(username);
res.setPassword(null);
return res;
}

View File

@@ -0,0 +1,45 @@
package cn.mafangui.hotel.controller;
import cn.mafangui.hotel.entity.OrderType;
import cn.mafangui.hotel.service.OrderTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping(value = "/orderType")
public class OrderTypeController {
@Autowired
private OrderTypeService orderTypeService;
@RequestMapping(value = "/add")
public int addOrderType(String type,String remark){
OrderType orderType = new OrderType(type,remark);
return orderTypeService.insertOrderType(orderType);
}
@RequestMapping(value = "/delete")
public int deleteOrderType(int typeId){
return orderTypeService.deleteOrderType(typeId);
}
@RequestMapping(value = "/update")
public int updateOrderType(int typeId,String type,String remark){
OrderType orderType = new OrderType(type,remark);
orderType.setTypeId(typeId);
return orderTypeService.updateOrderType(orderType);
}
@RequestMapping(value = "/withId")
public OrderType getById(int typeId){
return orderTypeService.selectById(typeId);
}
@RequestMapping(value = "all")
public List<OrderType> getAllType(){
return orderTypeService.selectAll();
}
}

View File

@@ -52,4 +52,23 @@ public class OrderType {
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public OrderType() {
}
public OrderType(String type, String remark) {
this.type = type;
this.remark = remark;
}
@Override
public String toString() {
return "OrderType{" +
"typeId=" + typeId +
", type='" + type + '\'' +
", remark='" + remark + '\'' +
", createTime=" + createTime +
", updateTime=" + updateTime +
'}';
}
}

View File

@@ -1,7 +1,12 @@
package cn.mafangui.hotel.mapper;
import cn.mafangui.hotel.entity.OrderType;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public interface OrderTypeMapper {
int deleteByPrimaryKey(Integer typeId);
@@ -14,4 +19,8 @@ public interface OrderTypeMapper {
int updateByPrimaryKeySelective(OrderType record);
int updateByPrimaryKey(OrderType record);
List<OrderType> selectAll();
}

View File

@@ -24,5 +24,7 @@ public interface WorkerMapper {
List<Worker> selectByRole(String role);
Worker selectByUsername(String username);
List<Worker> selectAll();
}

View File

@@ -0,0 +1,18 @@
package cn.mafangui.hotel.service;
import cn.mafangui.hotel.entity.OrderType;
import java.util.List;
public interface OrderTypeService {
int insertOrderType(OrderType orderType);
int deleteOrderType(int typeId);
int updateOrderType(OrderType orderType);
OrderType selectById(int typeId);
List<OrderType> selectAll();
}

View File

@@ -9,6 +9,7 @@ public interface WorkerService {
int delete(int workerId);
int updateById(Worker worker);
Worker selectById(int workerId);
Worker selectByUsername(String username);
List<Worker> findAll();
List<Worker> selectByRole(String role);
Worker login(String username,String password,String role);

View File

@@ -0,0 +1,40 @@
package cn.mafangui.hotel.service.impl;
import cn.mafangui.hotel.entity.OrderType;
import cn.mafangui.hotel.mapper.OrderTypeMapper;
import cn.mafangui.hotel.service.OrderTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class OrderTypeServiceImpl implements OrderTypeService {
@Autowired
private OrderTypeMapper orderTypeMapper;
@Override
public int insertOrderType(OrderType orderType) {
return orderTypeMapper.insertSelective(orderType);
}
@Override
public int deleteOrderType(int typeId) {
return orderTypeMapper.deleteByPrimaryKey(typeId);
}
@Override
public int updateOrderType(OrderType orderType) {
return orderTypeMapper.updateByPrimaryKeySelective(orderType);
}
@Override
public OrderType selectById(int typeId) {
return orderTypeMapper.selectByPrimaryKey(typeId);
}
@Override
public List<OrderType> selectAll() {
return orderTypeMapper.selectAll();
}
}

View File

@@ -34,6 +34,11 @@ public class WorkerServiceImpl implements WorkerService {
return workerMapper.selectByPrimaryKey(workerId);
}
@Override
public Worker selectByUsername(String username) {
return workerMapper.selectByUsername(username);
}
@Override
public List<Worker> findAll() {
return workerMapper.selectAll();