mirror of
				https://github.com/FreeeBird/hotel.git
				synced 2025-10-31 12:34:54 +08:00 
			
		
		
		
	完成预订方式接口编写
This commit is contained in:
		| @@ -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; | ||||
|     } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -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(); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -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 + | ||||
|                 '}'; | ||||
|     } | ||||
| } | ||||
| @@ -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(); | ||||
|  | ||||
|  | ||||
| } | ||||
| @@ -24,5 +24,7 @@ public interface WorkerMapper { | ||||
|  | ||||
|     List<Worker> selectByRole(String role); | ||||
|  | ||||
|     Worker selectByUsername(String username); | ||||
|  | ||||
|     List<Worker> selectAll(); | ||||
| } | ||||
| @@ -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(); | ||||
| } | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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(); | ||||
|     } | ||||
| } | ||||
| @@ -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(); | ||||
|   | ||||
| @@ -17,6 +17,9 @@ | ||||
|     from order_type | ||||
|     where type_id = #{typeId,jdbcType=INTEGER} | ||||
|   </select> | ||||
|   <select id="selectAll" resultMap="BaseResultMap"> | ||||
|     select * from order_type | ||||
|   </select> | ||||
|   <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> | ||||
|     delete from order_type | ||||
|     where type_id = #{typeId,jdbcType=INTEGER} | ||||
| @@ -39,12 +42,8 @@ | ||||
|       <if test="remark != null"> | ||||
|         remark, | ||||
|       </if> | ||||
|       <if test="createTime != null"> | ||||
|         create_time, | ||||
|       </if> | ||||
|       <if test="updateTime != null"> | ||||
|         update_time, | ||||
|       </if> | ||||
|     </trim> | ||||
|     <trim prefix="values (" suffix=")" suffixOverrides=","> | ||||
|       <if test="typeId != null"> | ||||
| @@ -56,12 +55,8 @@ | ||||
|       <if test="remark != null"> | ||||
|         #{remark,jdbcType=VARCHAR}, | ||||
|       </if> | ||||
|       <if test="createTime != null"> | ||||
|         #{createTime,jdbcType=TIMESTAMP}, | ||||
|       </if> | ||||
|       <if test="updateTime != null"> | ||||
|         #{updateTime,jdbcType=TIMESTAMP}, | ||||
|       </if> | ||||
|       now(), | ||||
|       now(), | ||||
|     </trim> | ||||
|   </insert> | ||||
|   <update id="updateByPrimaryKeySelective" parameterType="cn.mafangui.hotel.entity.OrderType"> | ||||
| @@ -73,12 +68,7 @@ | ||||
|       <if test="remark != null"> | ||||
|         remark = #{remark,jdbcType=VARCHAR}, | ||||
|       </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> | ||||
| @@ -86,8 +76,7 @@ | ||||
|     update order_type | ||||
|     set type = #{type,jdbcType=VARCHAR}, | ||||
|       remark = #{remark,jdbcType=VARCHAR}, | ||||
|       create_time = #{createTime,jdbcType=TIMESTAMP}, | ||||
|       update_time = #{updateTime,jdbcType=TIMESTAMP} | ||||
|       update_time = now() | ||||
|     where type_id = #{typeId,jdbcType=INTEGER} | ||||
|   </update> | ||||
| </mapper> | ||||
| @@ -25,6 +25,12 @@ | ||||
|     from worker_info | ||||
|     where worker_id = #{workerId,jdbcType=INTEGER} | ||||
|   </select> | ||||
|   <select id="selectByUsername" parameterType="String" resultMap="BaseResultMap"> | ||||
|     select | ||||
|     <include refid="Base_Column_List" /> | ||||
|     from worker_info | ||||
|     where username = #{username,jdbcType=VARCHAR} | ||||
|   </select> | ||||
|   <select id="selectByUsernameAndPassword" parameterType="String" resultMap="BaseResultMap"> | ||||
|     select * from worker_info | ||||
|     where username = #{username,jdbcType=VARCHAR} and password = #{password,jdbcType=VARCHAR} and role = #{role,jdbcType=VARCHAR} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user