基于javaweb+springboot的酒店管理系统(java+Springboot+Mybatis+Beetl+Layui)
此系统用的是springboot框架,前端框架主要用的是layui,表格用的bootstrap 表格,都是一些主流的框架,前端模板引擎用的是beetl,操作简单,通俗易懂,用的都是简单的技术很适合做毕业设计。
项目的主要功能:
1、信息维护:主要维护一些房间的信息,包括房间增加、房间维修等;
2、登记管理:主要是入住登记、退租以及房间的历史使用情况;
3、工作文件:发布一些公告、附件以及附件的下载;
4、申请管理:主要是员工请假申请、调休申请;
5、考勤打卡:员工考勤用的,上班下班打卡,若当天(非周末)23点55分没有打上班卡且没有请假、调休,会自动记为旷工(定时器)
6、账号管理:创建用户以及给用户分配菜单资源权限,若不想用哪个模块或者哪个菜单,可直接隐藏,方便简单;
7、菜单维护:对菜单的增删改查,配置菜单图标、访问路径等
运行环境:jdk1.8、eclipse/idea、Mysql5.7、Navicat/Sqlyog、Maven3.5/3.6
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
if(user!=null){
request.getSession().setAttribute("user",user);
Map map=new HashMap();
return new Result(true,StatusCode.OK,"登陆成功");
}else{
return new Result(false,StatusCode.LOGINERROR,"用户名或密码错误");
}
}else {
User user = userService.findByNameAndPassword(loginMap.get("login"),loginMap.get("password"));
if(user!=null){
request.getSession().setAttribute("user",user);
Map map=new HashMap();
map.put("name",user.getName());//姓名
return new Result(true,StatusCode.OK,"登陆成功",map);
}else{
return new Result(false,StatusCode.LOGINERROR,"用户名或密码错误");
}
}
}
@RestController
@CrossOrigin
@RequestMapping("/user")
public class UserController {
@Autowired
private UserService userService;
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private HttpServletRequest request;
@Autowired
BCryptPasswordEncoder encoder;
/**
* 查询全部数据
*
* @return
User user = userService.findByMobileAndPassword(loginMap.get("login"),loginMap.get("password"));
if(user!=null){
request.getSession().setAttribute("user",user);
Map map=new HashMap();
return new Result(true,StatusCode.OK,"登陆成功");
}else{
return new Result(false,StatusCode.LOGINERROR,"用户名或密码错误");
}
}else {
User user = userService.findByNameAndPassword(loginMap.get("login"),loginMap.get("password"));
if(user!=null){
request.getSession().setAttribute("user",user);
Map map=new HashMap();
map.put("name",user.getName());//姓名
return new Result(true,StatusCode.OK,"登陆成功",map);
model.addAttribute("orders",ordersService.findOrders(user.getId().toString()));
return "index_header::table_refresh";
}
/**
* 查询全部订单
* @return
*/
@ResponseBody
@RequestMapping(value = "/allorder",method = RequestMethod.POST)
public List<Orders> findAllOrder(HttpSession session) throws ParseException {
User user= (User) session.getAttribute("user");
return ordersService.findOrders(user.getId().toString());
}
/**
* 查询全部订单
request.getSession().setAttribute("user",user);
Map map=new HashMap();
return new Result(true,StatusCode.OK,"登陆成功");
}else{
return new Result(false,StatusCode.LOGINERROR,"用户名或密码错误");
}
}else {
User user = userService.findByNameAndPassword(loginMap.get("login"),loginMap.get("password"));
if(user!=null){
request.getSession().setAttribute("user",user);
Map map=new HashMap();
map.put("name",user.getName());//姓名
return new Result(true,StatusCode.OK,"登陆成功",map);
}else{
public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) {
List<Predicate> scenics=new ArrayList<>();
if (StringUtils.isNotBlank(search_key)){
scenics.add( criteriaBuilder.like(root.get("name"),"%"+search_key+"%"));
}
return criteriaBuilder.and(scenics.toArray(new Predicate[scenics.size()]));
}
};
Page<Scenic> page=scenicDao.findAll(specification,pageable);
model.addAttribute("name",search_key);
model.addAttribute("attrs",page);
private ScenicService scenicService;
@Autowired
private ScenicDao scenicDao;
@Autowired
private HotelService hotelService;
@Autowired
private HotelDao hotelDao;
/**
*查询星级
* @return
*/
@ResponseBody
@RequestMapping(value = "/star",method = RequestMethod.POST)
public Result judgeStar(String id,String start){
System.out.println(id+"===="+start);
Optional<Scenic> s = scenicDao.findById(id);
if (s.isPresent()){
Scenic scenic = s.get();
int valuestar = (Integer.valueOf(start)+Integer.valueOf(scenic.getStart()))/2;
scenic.setStart(valuestar);
scenicDao.save(scenic);
System.out.println("数据不为空!");
userService.update(user);
return new Result(true,StatusCode.OK,"修改成功");
}
/**
* 删除
* @param id
*/
@RequestMapping(value="/{id}",method= RequestMethod.DELETE)
public Result delete(@PathVariable String id ){
userService.deleteById(id);
return new Result(true,StatusCode.OK,"删除成功");
}
/**
* 用户注册
* @param code
* @param user
* @return
*/
@ResponseBody
@RequestMapping(value = "/register/",method = RequestMethod.POST)
public Result regist(@RequestParam(name = "code") String code,User user,HttpServletRequest request){
String sCode = (String) request.getSession().getAttribute("user_register_email_code");
if(!sCode.equalsIgnoreCase(code)){
return new Result(false,StatusCode.ERROR,"验证码错误!");
@RequestMapping(value="/{id}",method= RequestMethod.GET)
public Result findById(@PathVariable Long id){
return new Result(true,StatusCode.OK,"查询成功",ordersService.findById(id));
}
/**
* 分页+多条件查询
* @param searchMap 查询条件封装
* @param page 页码
* @param size 页大小
* @return 分页结果
*/
@ResponseBody
@RequestMapping(value="/search/{page}/{size}",method=RequestMethod.POST)
@ResponseBody
@RequestMapping(value="/{id}",method= RequestMethod.PUT)
public Result update(@PathVariable Long id){
ordersService.updateStatus(id);
return new Result(true,StatusCode.OK,"修改成功");
}
/**
* 删除
* @param id
*/
@ResponseBody
@RequestMapping(value="/{id}",method= RequestMethod.DELETE)
public Result delete(@PathVariable Long id ){
ordersService.deleteById(id);
return new Result(true,StatusCode.OK,"删除成功");
}
@RequestMapping(value = "/ordersList")
public String ordersList(){
return "admin/ordersmanage/orderslist";
}
}else {
User user = userService.findByNameAndPassword(loginMap.get("login"),loginMap.get("password"));
if(user!=null){
request.getSession().setAttribute("user",user);
Map map=new HashMap();
map.put("name",user.getName());//姓名
return new Result(true,StatusCode.OK,"登陆成功",map);
}else{
return new Result(false,StatusCode.LOGINERROR,"用户名或密码错误");
}
}
}
/**
* 用户注销
* @param request
* @param response
* @throws IOException
Scenic scenic = s.get();
int valuestar = (Integer.valueOf(start)+Integer.valueOf(scenic.getStart()))/2;
scenic.setStart(valuestar);
scenicDao.save(scenic);
System.out.println("数据不为空!");
return new Result(true,1,"","");
}else {
System.out.println("数据为空!");
return new Result(false,0,"","");
}
}
/**
*查询星级
* @return
*/
/**
* 增加
* @param user
*/
@RequestMapping(method=RequestMethod.POST)
public Result add(@RequestBody User user ){
userService.add(user);
return new Result(true,StatusCode.OK,"增加成功");
}
/**
* 修改
* @param user
*/
@ResponseBody
@RequestMapping(value="/search",method = RequestMethod.POST)
public Result findSearch( @RequestBody Map searchMap){
return new Result(true,StatusCode.OK,"查询成功",ordersService.findSearch(searchMap));
}
/**
* 订单添加操作
* @param orders
*/
@ResponseBody
@RequestMapping(value ="/add",method=RequestMethod.POST)
public Result add(Orders orders, HttpSession session){
//获取数量
User user = (User) session.getAttribute("user");
if (user == null){
return new Result(false,StatusCode.ACCESSERROR,"请登录");
}
return ordersService.add(orders,user.getId(),orders.getId(),orders.getQty());
ordersService.updateStarStatus(orderId);
if(scenic1==null){
return new Result(false,StatusCode.ERROR,"评分更新失败!");
}
return new Result(true,StatusCode.OK,"评价成功!");
}
}
景点管理控制层:
/**
* @Author: yy
* @Date: 景点管理控制层
*/
@Controller
@CrossOrigin
@RequestMapping("/travel")
public class RecomTravelController {
@Autowired
private ScenicService scenicService;
@Autowired
private ScenicDao scenicDao;
@Autowired
private HotelService hotelService;
@Autowired
commentCount=commentCount+1;
totalStar=currentStar+totalStar;
int avgStar = totalStar / commentCount;
hotel.setCommentCount(commentCount);
hotel.setStar(avgStar);
Integer hotel1 = hotelService.updateStar(hotel);
hotel_ordersService.updateStarStatus(orderId);
if(hotel1==null){
return new Result(false,StatusCode.ERROR,"评分更新失败!");
}
return new Result(true,StatusCode.OK,"评价成功!");
@RequestMapping(value = "/allorder",method = RequestMethod.POST)
public List<Orders> findAllOrder(HttpSession session) throws ParseException {
User user= (User) session.getAttribute("user");
return ordersService.findOrders(user.getId().toString());
}
/**
* 查询全部订单
* @return
*/
@ResponseBody
@RequestMapping(value = "/allorderhotel",method = RequestMethod.POST)
public List<HotelOrders> findAllOrderHotel(HttpSession session){
User user= (User) session.getAttribute("user");
List<HotelOrders> hotel_orders=hotel_ordersService.hotel_orders(user.getId());
return hotel_orders;
}
/**
* 根据ID查询
* @param id ID
* @return
*/
@ResponseBody
@RequestMapping(value="/{id}",method= RequestMethod.GET)
public Result findById(@PathVariable Long id){
*/
@ResponseBody
@RequestMapping(value="/login",method=RequestMethod.POST)
public Result login(@RequestParam Map<String,String> loginMap,HttpServletRequest request){
String mobile = loginMap.get("login");
if (StringUtil.isMobile(mobile)){
User user = userService.findByMobileAndPassword(loginMap.get("login"),loginMap.get("password"));
if(user!=null){
request.getSession().setAttribute("user",user);
Map map=new HashMap();
return new Result(true,StatusCode.OK,"登陆成功");
}else{
return new Result(false,StatusCode.LOGINERROR,"用户名或密码错误");
}
}else {
User user = userService.findByNameAndPassword(loginMap.get("login"),loginMap.get("password"));
if(user!=null){
request.getSession().setAttribute("user",user);
Map map=new HashMap();
map.put("name",user.getName());//姓名
return new Result(true,StatusCode.OK,"登陆成功",map);
}else{
* 根据ID查询
* @param id ID
* @return
*/
@ResponseBody
@RequestMapping(value="/{id}",method= RequestMethod.GET)
public Result findById(@PathVariable Long id){
return new Result(true,StatusCode.OK,"查询成功",ordersService.findById(id));
}
/**
* 分页+多条件查询
* @param searchMap 查询条件封装
* @param page 页码
*/
@ResponseBody
@RequestMapping(value="/{id}",method= RequestMethod.PUT)
public Result update(User user, @PathVariable Long id ){
User oldUser=userService.findById(id);
user.setId(id);
user.setPassword(oldUser.getPassword());
userService.update(user);
return new Result(true,StatusCode.OK,"修改成功");
}
/**
* 修改
* @param user
*/
@RequestMapping(value="/change",method= RequestMethod.POST,consumes = "application/json")
public Result update(@RequestBody User user, HttpSession session){
User us= (User) session.getAttribute("user");
user.setId(us.getId());
user.setPassword(us.getPassword());
userService.update(user);
return new Result(true,StatusCode.OK,"修改成功");
*/
@Controller
@CrossOrigin
@RequestMapping("/orders")
public class OrdersController {
@Autowired
private OrdersService ordersService;
@Autowired
private HotelOrdersService hotel_ordersService;
@Autowired
Integer commentCount = newHotel.getCommentCount();
commentCount=commentCount+1;
totalStar=currentStar+totalStar;
int avgStar = totalStar / commentCount;
hotel.setCommentCount(commentCount);
hotel.setStar(avgStar);
Integer hotel1 = hotelService.updateStar(hotel);
hotel_ordersService.updateStarStatus(orderId);
if(hotel1==null){
return new Result(false,StatusCode.ERROR,"评分更新失败!");
}
return new Result(true,StatusCode.OK,"评价成功!");
}
/**
* 景点评分
* @param scenic
* @return
*/
@ResponseBody
@PostMapping("/travelOrderStar")
*/
@RequestMapping(value = "/email",method = RequestMethod.POST)
@ResponseBody
public Result findemail(User user){
String email = user.getEmail();
if(!StringUtil.emailFormat(email)){
return new Result(true,StatusCode.ERROR,"请填写正确的邮箱格式");
}
User useremail= userService.findByEmail(email);
if (useremail == null){
return new Result(true,StatusCode.OK,"该邮箱可以注册");
}
return new Result(false,StatusCode.ERROR,"该邮箱已经被注册");
}
/**
* 用户登录
* @param loginMap
User userphone= userService.findByMobile(phone);
if (userphone == null){
return new Result(true,StatusCode.OK,"该手机号可以注册");
}
return new Result(false,StatusCode.ERROR,"该手机号已经被注册");
}
/**
* 邮箱验证
* @param user
* @return
*/
@RequestMapping(value = "/email",method = RequestMethod.POST)
@ResponseBody
public Result findemail(User user){
String email = user.getEmail();
if(!StringUtil.emailFormat(email)){
return new Result(true,StatusCode.ERROR,"请填写正确的邮箱格式");
}
User useremail= userService.findByEmail(email);
private HotelOrdersService hotel_ordersService;
@Autowired
private HotelService hotelService;
@Autowired
private ScenicService scenicService;
/**
* 查询全部数据
* @return
*/
@ResponseBody
@RequestMapping(value = "/list",method= RequestMethod.GET)
public Result findAll(){
List<Orders> all = ordersService.findAll();
return new Result(true, StatusCode.OK,"查询成功",all,all.size());
@ResponseBody
@RequestMapping(value = "/allorder",method = RequestMethod.POST)
public List<Orders> findAllOrder(HttpSession session) throws ParseException {
User user= (User) session.getAttribute("user");
return ordersService.findOrders(user.getId().toString());
}
/**
* 查询全部订单
* @return
*/
@ResponseBody
@RequestMapping(value = "/allorderhotel",method = RequestMethod.POST)
public List<HotelOrders> findAllOrderHotel(HttpSession session){
Page<Orders> pageList = ordersService.findSearch(searchMap, page, size);
return new Result(true,StatusCode.OK,"查询成功", new PageResult<Orders>(pageList.getTotalElements(), pageList.getContent()) );
}
/**
* 根据条件查询
* @param searchMap
* @return
*/
@ResponseBody
@RequestMapping(value="/search",method = RequestMethod.POST)
public Result findSearch( @RequestBody Map searchMap){
return new Result(true,StatusCode.OK,"查询成功",ordersService.findSearch(searchMap));
}
/**
* 订单添加操作