Java project: JSP online book lending management system

Author homepage: Source Space Station 2022

Introduction: High-quality creators in the Java field, Java projects, learning materials, technical mutual assistance

Get the source code at the end of the article

Project Introduction

The administrator role includes the following functions:
Administrator information modification, administrator login, user information management, book information management, check book borrowing information, administrator information management and other functions.

User roles include the following capabilities:
User login, modify personal information, book borrowing and other functions.

Library staff roles include the following functions:
Employee login, employee information modification, user information management, book information management, check book borrowing information and other functions.

Due to the small scale of this program, it can be used for course design and graduation design learning demonstration

environmental needs

1. Operating environment: preferably java jdk 1.8, we run on this platform. Other versions are also theoretically possible.
2.IDE environment: IDEA, Eclipse,Myeclipse are all available. Recommend IDEA;
3.tomcat environment: Tomcat 7.x,8.x,9.x versions are available
4. Hardware environment: Windows 7/8/10 with 1G memory or more; or Mac OS;
5. Database: MySql 5.7 version;

6. Whether it is a Maven project: Yes; check whether pom.xml is included in the source code directory; if it is included, it is a maven project, otherwise it is a non-maven project

technology stack

1. Backend: servlet s

2. Front end: JSP+bootstrap+jQuery

Instructions for use

1. Use Navicat or other tools to create a database with the corresponding name in mysql, and import the sql file of the project;
2. Use IDEA/Eclipse/MyEclipse to import the project. When importing Eclipse/MyEclipse, if it is a maven project, please select maven; if it is a maven project, please execute the maven clean;maven install command after the import is successful, and then run;
3. Change the database configuration in the db.properties and spring-mybatis.xml configuration files in the project to your own configuration;
Note: Modified without synchronizing the data of db.properties in spring-mybatis.xml;

4. Run the project, enter localhost:8080/chaoshi to log in Note: The configuration project path in tomcat must be /chaoshi, and the front-end code has been hard-coded, otherwise an error will be reported;

run screenshot

related code

role management control

@RestController
@RequestMapping("/sys/role")
public class SysRoleController extends AbstractController {
	@Autowired
	private SysRoleService sysRoleService;
	@Autowired
	private SysRoleMenuService sysRoleMenuService;
	
	/**
	 * role list
	 */
	@RequestMapping("/list")
	public R list(@RequestParam Map<String, Object> params){
		//If you are not a super administrator, only query the list of roles you created
//		if(getUserId() != Constant.SUPER_ADMIN){
//			params.put("createUserId", getUserId());
//		}
		
		//query list data
		Query query = new Query(params);
		List<SysRoleEntity> list = sysRoleService.queryList(query);
		int total = sysRoleService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(list, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	/**
	 * role list
	 */
	@RequestMapping("/select")
	public R select(){
		Map<String, Object> map = new HashMap<>();
		
		//If you are not a super administrator, only query the list of roles you own
//		if(getUserId() != Constant.SUPER_ADMIN){
//			map.put("createUserId", getUserId());
//		}
		List<SysRoleEntity> list = sysRoleService.queryList(map);
		
		return R.ok().put("list", list);
	}
	
	/**
	 * role information
	 */
	@RequestMapping("/info/{roleId}")
	public R info(@PathVariable("roleId") Long roleId){
		SysRoleEntity role = sysRoleService.queryObject(roleId);
		
		//Query the menu corresponding to the role
		List<Long> menuIdList = sysRoleMenuService.queryMenuIdList(roleId);
		role.setMenuIdList(menuIdList);
		
		return R.ok().put("role", role);
	}
	
	/**
	 * save role
	 */
	@RequestMapping("/save")
	public R save(@RequestBody SysRoleEntity role){

		role.setCreateUserId(getUserId());
		sysRoleService.save(role);
		
		return R.ok();
	}
	
	/**
	 * modify role
	 */
	@RequestMapping("/update")
	public R update(@RequestBody SysRoleEntity role){

		role.setCreateUserId(getUserId());
		sysRoleService.update(role);
		
		return R.ok();
	}
	
	/**
	 * delete role
	 */
	@RequestMapping("/delete")
	public R delete(@RequestBody Long[] roleIds){
		sysRoleService.deleteBatch(roleIds);
		
		return R.ok();
	}
}

user controller

@WebServlet(name = "admin_user_delete",urlPatterns = "/admin/user_delete")
public class AdminUserDeleteServlet extends HttpServlet {
    private UserService uService = new UserService();
    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int id = Integer.parseInt(request.getParameter("id"));
        boolean isSuccess = uService.delete(id);
        if(isSuccess) {
            request.setAttribute("msg", "Customer deleted successfully");
        }else {
            request.setAttribute("failMsg", "The customer has placed an order, please delete the customer's order first, and then delete the customer!");
        }
        request.getRequestDispatcher("/admin/user_list").forward(request, response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doGet(request, response);
    }
}

If you also want to learn this system, get it below. Follow and reply: 113jsp

Tags: Java JSP servlet programming language

Posted by steved on Wed, 18 Jan 2023 00:22:34 +1030