完成预订方式接口编写

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.Room;
import cn.mafangui.hotel.entity.RoomType; import cn.mafangui.hotel.entity.RoomType;
import cn.mafangui.hotel.entity.Worker;
import cn.mafangui.hotel.service.RoomService; import cn.mafangui.hotel.service.RoomService;
import cn.mafangui.hotel.service.RoomTypeService; import cn.mafangui.hotel.service.RoomTypeService;
import cn.mafangui.hotel.service.WorkerService; import cn.mafangui.hotel.service.WorkerService;
@ -36,7 +37,13 @@ public class AdminController {
else return 0; 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) { public void setUpdateTime(Date updateTime) {
this.updateTime = 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; package cn.mafangui.hotel.mapper;
import cn.mafangui.hotel.entity.OrderType; import cn.mafangui.hotel.entity.OrderType;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public interface OrderTypeMapper { public interface OrderTypeMapper {
int deleteByPrimaryKey(Integer typeId); int deleteByPrimaryKey(Integer typeId);
@ -14,4 +19,8 @@ public interface OrderTypeMapper {
int updateByPrimaryKeySelective(OrderType record); int updateByPrimaryKeySelective(OrderType record);
int updateByPrimaryKey(OrderType record); int updateByPrimaryKey(OrderType record);
List<OrderType> selectAll();
} }

View File

@ -24,5 +24,7 @@ public interface WorkerMapper {
List<Worker> selectByRole(String role); List<Worker> selectByRole(String role);
Worker selectByUsername(String username);
List<Worker> selectAll(); 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 delete(int workerId);
int updateById(Worker worker); int updateById(Worker worker);
Worker selectById(int workerId); Worker selectById(int workerId);
Worker selectByUsername(String username);
List<Worker> findAll(); List<Worker> findAll();
List<Worker> selectByRole(String role); List<Worker> selectByRole(String role);
Worker login(String username,String password,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); return workerMapper.selectByPrimaryKey(workerId);
} }
@Override
public Worker selectByUsername(String username) {
return workerMapper.selectByUsername(username);
}
@Override @Override
public List<Worker> findAll() { public List<Worker> findAll() {
return workerMapper.selectAll(); return workerMapper.selectAll();

View File

@ -17,6 +17,9 @@
from order_type from order_type
where type_id = #{typeId,jdbcType=INTEGER} where type_id = #{typeId,jdbcType=INTEGER}
</select> </select>
<select id="selectAll" resultMap="BaseResultMap">
select * from order_type
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from order_type delete from order_type
where type_id = #{typeId,jdbcType=INTEGER} where type_id = #{typeId,jdbcType=INTEGER}
@ -39,12 +42,8 @@
<if test="remark != null"> <if test="remark != null">
remark, remark,
</if> </if>
<if test="createTime != null">
create_time, create_time,
</if>
<if test="updateTime != null">
update_time, update_time,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="typeId != null"> <if test="typeId != null">
@ -56,12 +55,8 @@
<if test="remark != null"> <if test="remark != null">
#{remark,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},
</if> </if>
<if test="createTime != null"> now(),
#{createTime,jdbcType=TIMESTAMP}, now(),
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim> </trim>
</insert> </insert>
<update id="updateByPrimaryKeySelective" parameterType="cn.mafangui.hotel.entity.OrderType"> <update id="updateByPrimaryKeySelective" parameterType="cn.mafangui.hotel.entity.OrderType">
@ -73,12 +68,7 @@
<if test="remark != null"> <if test="remark != null">
remark = #{remark,jdbcType=VARCHAR}, remark = #{remark,jdbcType=VARCHAR},
</if> </if>
<if test="createTime != null"> update_time = now(),
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set> </set>
where type_id = #{typeId,jdbcType=INTEGER} where type_id = #{typeId,jdbcType=INTEGER}
</update> </update>
@ -86,8 +76,7 @@
update order_type update order_type
set type = #{type,jdbcType=VARCHAR}, set type = #{type,jdbcType=VARCHAR},
remark = #{remark,jdbcType=VARCHAR}, remark = #{remark,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP}, update_time = now()
update_time = #{updateTime,jdbcType=TIMESTAMP}
where type_id = #{typeId,jdbcType=INTEGER} where type_id = #{typeId,jdbcType=INTEGER}
</update> </update>
</mapper> </mapper>

View File

@ -25,6 +25,12 @@
from worker_info from worker_info
where worker_id = #{workerId,jdbcType=INTEGER} where worker_id = #{workerId,jdbcType=INTEGER}
</select> </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 id="selectByUsernameAndPassword" parameterType="String" resultMap="BaseResultMap">
select * from worker_info select * from worker_info
where username = #{username,jdbcType=VARCHAR} and password = #{password,jdbcType=VARCHAR} and role = #{role,jdbcType=VARCHAR} where username = #{username,jdbcType=VARCHAR} and password = #{password,jdbcType=VARCHAR} and role = #{role,jdbcType=VARCHAR}