current position:Home>Java project: tourism hotel management system (java + Maven + springboot + MySQL)

Java project: tourism hotel management system (java + Maven + springboot + MySQL)

2022-01-27 05:07:19 qq_ one billion three hundred and thirty-four million six hundr

This project is based on SpringBoot Tourism hotel management system , It is divided into foreground and background client. Users can register independently 、 Background administrator role . Front desk functions : Scenic spot 、 The hotel 、 strategy 、 Orders, etc . Background administrator function : User management 、 Scenic spot management 、 Album management 、 Message management 、 hotel management 、 Order management, etc . !

Running environment :jdk1.8 mysql5.7 idea/eclipse navicat/sqlyog maven3.5/3.6

 

 

 

 

Hotel order control layer :

/**
 *  Hotel order control layer 
 */
@Controller
@CrossOrigin
@RequestMapping("/hotelorders")
public class Hotel_OrdersController {


    @Autowired
    private HotelOrdersService hotel_ordersService;


    /**
     *  Add operation 
     * @param orders
     */
    @ResponseBody
    @RequestMapping(value ="/add",method=RequestMethod.POST)
    public Result add(HotelOrders orders, HttpSession session){
        User user = (User) session.getAttribute("user");
        if (user == null){
            return new Result(false,StatusCode.ACCESSERROR," Please log in ");
        }
        return hotel_ordersService.add(orders,user,orders.getId(),orders.getQty(),orders.getBegin(),orders.getEnd());
    }
}

Background administrator controller layer :

/**
 *  Background administrator controller layer 
 *
 */
@Controller
@CrossOrigin
@RequestMapping("/admin")
public class AdminController {

	@Autowired
	private AdminService adminService;
	
	@Autowired
	BCryptPasswordEncoder encoder;

	/**
	 *  Query all data 
	 * @return
	 */
	@ResponseBody
	@RequestMapping(method= RequestMethod.GET)
	public Result findAll(){
		return new Result(true, StatusCode.OK," The query is successful ",adminService.findAll());
	}
	
	/**
	 *  according to ID Inquire about 
	 * @param id ID
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="/{id}",method= RequestMethod.GET)
	public Result findById(@PathVariable Long id){
		return new Result(true,StatusCode.OK," The query is successful ",adminService.findById(id));
	}


	/**
	 *  Pagination + Multiconditional query 
	 * @param searchMap  Query condition encapsulation 
	 * @param page  Page number 
	 * @param size  Page size 
	 * @return  Paging results 
	 */
	@ResponseBody
	@RequestMapping(value="/search/{page}/{size}",method=RequestMethod.POST)
	public Result findSearch(@RequestBody Map searchMap , @PathVariable int page, @PathVariable int size){
		Page<Admin> pageList = adminService.findSearch(searchMap, page, size);
		return  new Result(true,StatusCode.OK," The query is successful ",  new PageResult<Admin>(pageList.getTotalElements(), pageList.getContent()) );
	}

	/**
     *  Query... According to the conditions 
     * @param searchMap
     * @return
     */
	@ResponseBody
    @RequestMapping(value="/search",method = RequestMethod.POST)
    public Result findSearch( @RequestBody Map searchMap){
        return new Result(true,StatusCode.OK," The query is successful ",adminService.findSearch(searchMap));
    }
	
	/**
	 *  increase 
	 * @param admin
	 */
	@ResponseBody
	@RequestMapping(method=RequestMethod.POST)
	public Result add(@RequestBody Admin admin  ){
		adminService.add(admin);
		return new Result(true,StatusCode.OK," Increase success ");
	}
	
	/**
	 *  modify 
	 * @param admin
	 */
	@ResponseBody
	@RequestMapping(value="/{id}",method= RequestMethod.PUT)
	public Result update(@RequestBody Admin admin, @PathVariable Long id ){
		admin.setId(id);
		adminService.update(admin);		
		return new Result(true,StatusCode.OK," Modification successful ");
	}
	
	/**
	 *  Delete 
	 * @param id
	 */
	@ResponseBody
	@RequestMapping(value="/{id}",method= RequestMethod.DELETE)
	public Result delete(@PathVariable String id ){
		adminService.deleteById(id);
		return new Result(true,StatusCode.OK," Delete successful ");
	}

	/**
	 *  Administrator jump 
	 * @return
	 */
	@RequestMapping(value = "/adminlogin")
	public String adminlogin()
	{
		return "admin/login/login";
	}


	/**
	 *  admin Sign in 
	 * @param loginMap
	 * @param request
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="/login",method= RequestMethod.POST)
	public Result login(@RequestParam Map<String,String> loginMap,HttpServletRequest request){
		Admin admin = adminService.finbyNameAndPassword(loginMap.get("name"),loginMap.get("password"));
		if (admin!=null){

			request.getSession().setAttribute("admin",admin);
			Map map=new HashMap();
			map.put("name",admin.getName());
			return new Result(true,StatusCode.OK," Login successful ");
		}else {
			return new Result(false,StatusCode.ERROR," Wrong account password ");
		}
	}

	/**
	 *  Administrator login succeeded 
	 * @return
	 */
	@RequestMapping(value = "/index")
	public String success(){
		return "admin/index";
	}


	/**
	 *  User list 
	 * @return
	 */
	@RequestMapping(value = "/userList")
	public String user(){
		return "admin/usermanage/userList";
	}

	@RequestMapping(value = "/echars")
	public String analysis(){
		return "admin/echars/console";
	}


	/**
	 *  The administrator logs out 
	 * @return
	 */
	@RequestMapping(value = "/logout")
	public String logout(HttpSession session){
		session.removeAttribute("admin");
		return "admin/login/login";
	}


	/**
	 *  The administrator changes the password 
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/passwd")
	public Result passwd(HttpSession session,String passwd,String oldpad){

		Admin admindmin= (Admin) session.getAttribute("admin");
		Admin admins=adminService.findById(admindmin.getId());
		boolean old=encoder.matches(oldpad,admins.getPassword());
		if (old){
			String newPassd=encoder.encode(passwd);
			admins.setPassword(newPassd);
			adminService.update(admins);
			return new Result(true,StatusCode.OK," success ");
		}else {
			return new Result(false,StatusCode.ERROR," Update failed ");
		}
	}

}

Attraction controller layer :

/**
 *  Attraction controller layer 
 * @author yy
 *
 */
@Controller
@CrossOrigin
@RequestMapping("/scenic")
public class ScenicController {

	@Autowired
	private ScenicService scenicService;


	/**
	 *  Query all data 
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "list",method= RequestMethod.GET)
	public Result findAll(){
		List<Scenic> all = scenicService.findAll();
		return new Result(true, StatusCode.OK," The query is successful ",all,all.size());
	}
	
	/**
	 *  according to ID Inquire about 
	 * @param id ID
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="/{id}",method= RequestMethod.GET)
	public Result findById(@PathVariable Long id){
		return new Result(true,StatusCode.OK," The query is successful ",scenicService.findById(id));
	}


	/**
	 *  Pagination + Multiconditional query 
	 * @param searchMap  Query condition encapsulation 
	 * @param page  Page number 
	 * @param size  Page size 
	 * @return  Paging results 
	 */
	@ResponseBody
	@RequestMapping(value="/search/{page}/{size}",method=RequestMethod.POST)
	public Result findSearch(@RequestBody Map searchMap , @PathVariable int page, @PathVariable int size){
		Page<Scenic> pageList = scenicService.findSearch(searchMap, page, size);
		return  new Result(true,StatusCode.OK," The query is successful ",  new PageResult<Scenic>(pageList.getTotalElements(), pageList.getContent()) );
	}


	/**
     *  Query... According to the conditions 
     * @param searchMap
     * @return
     */
	@ResponseBody
    @RequestMapping(value="/search",method = RequestMethod.POST)
    public Result findSearch( @RequestBody Map searchMap){
        return new Result(true,StatusCode.OK," The query is successful ",scenicService.findSearch(searchMap));
    }
	
	/**
	 *  Add scenic spots 
	 * @param scenic
	 */
	@ResponseBody
	@RequestMapping(method=RequestMethod.POST)
	public Result add(@RequestBody Scenic scenic){
		if(StringUtils.isEmpty(scenic.getName())){
			return new Result(false,StatusCode.ERROR," Please fill in the name of the scenic spot ");
		}
		if(StringUtils.isEmpty(scenic.getContry())){
			return new Result(false,StatusCode.ERROR," Please fill in the location of the scenic spot ");
		}
		if(StringUtils.isEmpty(scenic.getComment())){
			return new Result(false,StatusCode.ERROR," Please fill in the scenic spot Overview ");
		}
		if(StringUtils.isEmpty(scenic.getMiaoshu())){
			return new Result(false,StatusCode.ERROR," Please fill in a detailed description ");
		}
		scenic.setCommentCount(0);
		scenic.setStart(0);
		if(scenicService.add(scenic)==null){
			return new Result(false,StatusCode.ERROR," Failed to add scenic spot ");
		}
		return new Result(true,StatusCode.OK," Attractions added successfully ");
	}
	
	/**
	 *  Scenic spot modification 
	 * @param scenic
	 */
	@ResponseBody
	@RequestMapping(value="/{id}",method= RequestMethod.PUT)
	public Result update(@RequestBody Scenic scenic, @PathVariable Long id ){
		if(StringUtils.isEmpty(scenic.getName())){
			return new Result(false,StatusCode.ERROR," Please fill in the name of the scenic spot ");
		}
		if(StringUtils.isEmpty(scenic.getContry())){
			return new Result(false,StatusCode.ERROR," Please fill in the location of the scenic spot ");
		}
		if(StringUtils.isEmpty(scenic.getComment())){
			return new Result(false,StatusCode.ERROR," Please fill in the scenic spot Overview ");
		}
		if(StringUtils.isEmpty(scenic.getMiaoshu())){
			return new Result(false,StatusCode.ERROR," Please fill in a detailed description ");
		}
		Scenic scenic1ById = scenicService.findById(id);
		if(scenic1ById==null){
			return new Result(false,StatusCode.ERROR," The attraction does not exist ");
		}
		BeanUtils.copyProperties(scenic,scenic1ById,"id","startdate","img","commentCount");
		if(scenicService.update(scenic1ById)==null){
			return new Result(false,StatusCode.ERROR," Failed to modify the scenic spot ");
		}
		return new Result(true,StatusCode.OK," Modification successful ");
	}
	
	/**
	 *  Delete 
	 * @param id
	 */
	@ResponseBody
	@RequestMapping(value="/{id}",method= RequestMethod.DELETE)
	public Result delete(@PathVariable String id ){
		scenicService.deleteById(id);
		return new Result(true,StatusCode.OK," Delete successful ");
	}

	@RequestMapping(value = "/scenicList")
	public String scenicList(){
		return "admin/scenicmanage/scenicList";
	}

	@RequestMapping(value = "/scenicAdd")
	public String scenicAdd(){
		return "admin/scenicmanage/scenicAdd";
	}

}

copyright notice
author[qq_ one billion three hundred and thirty-four million six hundr],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270507148063.html

Random recommended