current position:Home>Java project: shared study room reservation management system (java + springboot + thymeleaf + HTML + Maven + MySQL)
Java project: shared study room reservation management system (java + springboot + thymeleaf + HTML + Maven + MySQL)
2022-04-29 05:57:28【OldWinePot】
The source code for : Blog's front page " resources " Download !
Project introduction
The main functions of the project include :
Data analysis : Histogram analysis 、 Line chart analysis 、 Statistics, etc , Every time 10 Seconds auto refresh
User management : User information management 、 User complaint management 、 Complaint feedback information 、 Blacklist management ;
Seat management : Real time seat management 、 Seat use reservation record , The administrator performs the user's seat reservation ;
Password management : Reset password ;
Environmental needs
1. Running environment : It is best to java jdk 1.8, We run on this platform . Other versions can, in theory .
2.IDE Environmental Science :IDEA,Eclipse,Myeclipse Fine . recommend IDEA;
3.tomcat Environmental Science :Tomcat 7.x,8.x,9.x All versions are available
4. Hardware environment :windows 7/8/10 1G Above memory ; perhaps Mac OS;
5. database :MySql 8.0 edition ;
7. whether maven project : yes ;
Technology stack
1. Back end :SpringBoot+Mybatis
2. front end :Thymeleaf+HTML+CSS+LayUI+bootstrap
Instructions
1. Use Navicat Or other tools , stay mysql Create a database with the corresponding name in , And import the sql file ;
2. Use IDEA/Eclipse/MyEclipse Import the project ,Eclipse/MyEclipse Import time , if maven Item, please select maven; if maven project , After importing successfully, please execute maven clean;maven install command , And then run ;
3. In the project application.yml Change the database configuration in the configuration file to your own configuration ;
4. Run the project , Input localhost:8080/index.html Sign in
Administrators :zfx1232 password :123456
User management controller :
/**
* User management controller
*/
@RequestMapping("/user/")
@Controller
public class UserController {
@Autowired
private IUserService userService;
@Autowired
private IRoleService roleService;
@Resource
private ProcessEngineConfiguration configuration;
@Resource
private ProcessEngine engine;
@GetMapping("/index")
@ApiOperation(" Jump to user page interface ")
@PreAuthorize("hasRole(' Administrators ')")
public String index(String menuid,Model model){
List<Role> roles = queryAllRole();
model.addAttribute("roles",roles);
model.addAttribute("menuid",menuid);
// User home page
return "views/user/user_list";
}
@GetMapping("/listpage")
@ApiOperation(" Query user paging data interface ")
@ApiImplicitParams({
@ApiImplicitParam(name = "UserQuery", value = " User query object ", defaultValue = "userQuery object ")
})
@ResponseBody
@PreAuthorize("hasRole(' Administrators ')")
public PageList listpage(UserQuery userQuery){
return userService.listpage(userQuery);
}
// Add users
@PostMapping("/addUser")
@ApiOperation(" Add user interface ")
@ResponseBody
public Map<String,Object> addUser(User user){
Map<String, Object> ret = new HashMap<>();
ret.put("code",-1);
if(StringUtils.isEmpty(user.getUsername())){
ret.put("msg"," Please fill in the user name ");
return ret;
}
if(StringUtils.isEmpty(user.getPassword())){
ret.put("msg"," Please fill in the password ");
return ret;
}
if(StringUtils.isEmpty(user.getEmail())){
ret.put("msg"," Please fill in the email address ");
return ret;
}
if(StringUtils.isEmpty(user.getTel())){
ret.put("msg"," Please fill in the mobile number ");
return ret;
}
if(StringUtils.isEmpty(user.getHeadImg())){
ret.put("msg"," Please upload your avatar ");
return ret;
}
if(userService.addUser(user)<=0) {
ret.put("msg", " Failed to add user ");
return ret;
}
ret.put("code",0);
ret.put("msg"," Add user successfully ");
return ret;
}
/**
* Modify user information
* @param user
* @return
*/
@PostMapping("/editSaveUser")
@ApiOperation(" Modify the user interface ")
@PreAuthorize("hasRole(' Administrators ')")
@ResponseBody
public Message editSaveUser(User user){
if(StringUtils.isEmpty(user.getUsername())){
return Message.error(" Please fill in the user name ");
}
if(StringUtils.isEmpty(user.getEmail())){
return Message.error(" Please fill in the email address ");
}
if(StringUtils.isEmpty(user.getTel())){
return Message.error(" Please fill in the mobile number ");
}
try {
userService.editSaveUser(user);
return Message.success();
} catch (Exception e) {
e.printStackTrace();
return Message.error(" Failed to modify user information ");
}
}
// Add users
@GetMapping("/deleteUser")
@ApiOperation(" Delete user interface ")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = " Such as :88",required = true)
})
@PreAuthorize("hasRole(' Administrators ')")
@ResponseBody
public AjaxResult deleteUser(@RequestParam(required = true) Long id){
AjaxResult ajaxResult = new AjaxResult();
try {
userService.deleteUser(id);
} catch (Exception e) {
e.printStackTrace();
return new AjaxResult(" Delete failed ");
}
return ajaxResult;
}
@PostMapping(value="/deleteBatchUser")
@ApiOperation(" Batch delete user interface ")
@PreAuthorize("hasRole(' Administrators ')")
@ResponseBody
public AjaxResult deleteBatchUser(String ids){
String[] idsArr = ids.split(",");
List list = new ArrayList();
for(int i=0;i<idsArr.length;i++){
list.add(idsArr[i]);
}
try{
userService.batchRemove(list);
return new AjaxResult();
}catch(Exception e){
return new AjaxResult(" Batch deletion failed ");
}
}
// Query all roles
public List<Role> queryAllRole(){
return roleService.queryAll();
}
// Add user's role
@PostMapping("/addUserRole")
@ApiOperation(" Add user role interface ")
@ApiImplicitParams({
@ApiImplicitParam(name = "paramMap", value = " Such as :{userId:1,[1,2,3,4]]}")
})
@ResponseBody
public AjaxResult addUserRole(@RequestBody Map paramMap){
AjaxResult ajaxResult = new AjaxResult();
String userId = (String)paramMap.get("userId");
List roleIds = (List) paramMap.get("roleIds");
try {
// Add the role corresponding to the user
roleService.addUserRole(userId,roleIds);
return ajaxResult;
}catch (Exception e){
e.printStackTrace();
return new AjaxResult(" Failed to save role ");
}
}
// Add users
@RequestMapping("/regSaveUser")
@ResponseBody
public Long addTeacher(User user){
System.out.println(" Save the user ...."+user);
userService.addUser(user);
// Save workflow operation
IdentityService is = engine.getIdentityService();
// Add user group
org.activiti.engine.identity.User userInfo = userService.saveUser(is, user.getUsername());
// Add the group relationship corresponding to the user
Group stuGroup = new GroupEntityImpl();
stuGroup.setId("stuGroup");
Group tGroup = new GroupEntityImpl();
tGroup.setId("tGroup");
if(user.getType() == 2) {
// Save teacher group
userService.saveRel(is, userInfo, tGroup);
}
if(user.getType() == 3) {
// Save student groups
userService.saveRel(is, userInfo, stuGroup);
}
Long userId = user.getId();
return userId;
}
/**
* Change password page
* @return
*/
@RequestMapping(value="/update_pwd",method=RequestMethod.GET)
public String updatePwd(){
return "views/user/update_pwd";
}
/**
* Change password operation
* @param oldPwd
* @param newPwd
* @return
*/
@ResponseBody
@PostMapping("/update_pwd")
public Message updatePassword(@RequestParam(name="oldPwd",required=true)String oldPwd,
@RequestParam(name="newPwd",required=true)String newPwd){
String username = CommonUtils.getLoginUser().getUsername();
User userByUserName = userService.findUserByUserName(username);
if(userByUserName!=null){
String password = userByUserName.getPassword();
BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
boolean matches = bCryptPasswordEncoder.matches(oldPwd, password);
if(!matches){
return Message.error(" The old password is incorrect ");//true
}
userByUserName.setPassword(bCryptPasswordEncoder.encode(newPwd));
if(userService.editUserPassword(userByUserName)<=0){
return Message.error(" Password change failed ");
}
}
return Message.success();
}
/**
* Clear cache
* @param request
* @param response
* @return
*/
@ResponseBody
@PostMapping("/clear_cache")
public Message clearCache(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragrma","no-cache");
response.setDateHeader("Expires",0);
return Message.success();
}
}
System controller :
/**
* System controller
* @author yy
*
*/
@RequestMapping("/system")
@Controller
public class SystemController {
@Autowired
private OperaterLogService operaterLogService;
@Autowired
private UserService userService;
@Autowired
private DatabaseBakService databaseBakService;
@Autowired
private ItemService itemService;
@Autowired
private PeopleService peopleService;
@Autowired
private OrderAuthService orderAuthService;
@Autowired
private StaffService staffService;
/* @Value("${show.tips.text}")
private String showTipsText;
@Value("${show.tips.url.text}")
private String showTipsUrlText;
@Value("${show.tips.btn.text}")
private String showTipsBtnText;
@Value("${show.tips.url}")
private String showTipsUtl;*/
private Logger log = LoggerFactory.getLogger(SystemController.class);
/**
* The login page
* @param model
* @return
*/
@RequestMapping(value="/login",method=RequestMethod.GET)
public String login(Model model){
return "admin/system/login";
}
/**
* User login submission form processing method
* @param request
* @param user
* @param cpacha
* @return
*/
@RequestMapping(value="/login",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> login(HttpServletRequest request,User user,String cpacha){
if(user == null){
return Result.error(CodeMsg.DATA_ERROR);
}
// Use the unified verification entity method to verify whether it is legal
CodeMsg validate = ValidateEntityUtil.validate(user);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
}
// Indicates that the entity information is legal , Start to verify whether the verification code is empty
if(StringUtils.isEmpty(cpacha)){
return Result.error(CodeMsg.CPACHA_EMPTY);
}
// Description verification code is not empty , from session Get verification code from
Object attribute = request.getSession().getAttribute("admin_login");
if(attribute == null){
return Result.error(CodeMsg.SESSION_EXPIRED);
}
// Express session No failure , Further judge whether the verification code filled in by the user is correct
if(!cpacha.equalsIgnoreCase(attribute.toString())){
return Result.error(CodeMsg.CPACHA_ERROR);
}
// Indicates that the verification code is correct , Start querying the database , Verify that the password is correct
User findByUsername = userService.findByUsername(user.getUsername());
// Determine whether it is null
if(findByUsername == null){
return Result.error(CodeMsg.ADMIN_USERNAME_NO_EXIST);
}
// Indicates that the user exists , Further compare whether the password is correct
if(!findByUsername.getPassword().equals(user.getPassword())){
return Result.error(CodeMsg.ADMIN_PASSWORD_ERROR);
}
// Indicates that the password is correct , Next, determine whether the user status is available
if(findByUsername.getStatus() == User.ADMIN_USER_STATUS_UNABLE){
return Result.error(CodeMsg.ADMIN_USER_UNABLE);
}
// Check whether the role status of the user is available
if(findByUsername.getRole() == null || findByUsername.getRole().getStatus() == Role.ADMIN_ROLE_STATUS_UNABLE){
return Result.error(CodeMsg.ADMIN_USER_ROLE_UNABLE);
}
// Check whether the permissions of the user's role exist
if(findByUsername.getRole().getAuthorities() == null || findByUsername.getRole().getAuthorities().size() == 0){
return Result.error(CodeMsg.ADMIN_USER_ROLE_AUTHORITES_EMPTY);
}
// Check that everything conforms to , You can log in. , Store user information in session
request.getSession().setAttribute(SessionConstant.SESSION_USER_LOGIN_KEY, findByUsername);
// The destruction session Verification code in
request.getSession().setAttribute("admin_login", null);
// Write the login record to the log Library
operaterLogService.add(" user 【"+user.getUsername()+"】 On 【" + StringUtil.getFormatterDate(new Date(), "yyyy-MM-dd HH:mm:ss") + "】 Login system !");
log.info(" User successfully logged in ,user = " + findByUsername);
return Result.success(true);
}
/**
* After successful login, the system home page
* @param model
* @return
*/
@RequestMapping(value="/index")
public String index(Model model){
model.addAttribute("operatorLogs", operaterLogService.findLastestLog(10));
model.addAttribute("userTotal", userService.total());
model.addAttribute("operatorLogTotal", operaterLogService.total());
model.addAttribute("databaseBackupTotal", databaseBakService.total());
model.addAttribute("itemCount", itemService.count());
model.addAttribute("peopleCount", peopleService.count());
model.addAttribute("workerCount", staffService.countByType(Staff.WORKER));
model.addAttribute("coachCount", staffService.countByType(Staff.COACH));
model.addAttribute("onlineUserTotal", SessionListener.onlineUserCount);
return "admin/system/index";
}
/**
* Sign out
* @return
*/
@RequestMapping(value="/logout")
public String logout(){
User loginedUser = SessionUtil.getLoginedUser();
if(loginedUser != null){
SessionUtil.set(SessionConstant.SESSION_USER_LOGIN_KEY, null);
}
return "redirect:login";
}
/**
* No permission prompt page
* @return
*/
@RequestMapping(value="/no_right")
public String noRight(){
return "admin/system/no_right";
}
/**
* Modify user's personal information
* @return
*/
@RequestMapping(value="/update_userinfo",method=RequestMethod.GET)
public String updateUserInfo(){
return "admin/system/update_userinfo";
}
/**
* Modify personal information and save
* @param user
* @return
*/
@RequestMapping(value="/update_userinfo",method=RequestMethod.POST)
public String updateUserInfo(User user){
User loginedUser = SessionUtil.getLoginedUser();
loginedUser.setEmail(user.getEmail());
loginedUser.setMobile(user.getMobile());
loginedUser.setHeadPic(user.getHeadPic());
// First save to the database
userService.save(loginedUser);
// to update session In the value of the
SessionUtil.set(SessionConstant.SESSION_USER_LOGIN_KEY, loginedUser);
return "redirect:update_userinfo";
}
/**
* Change password page
* @return
*/
@RequestMapping(value="/update_pwd",method=RequestMethod.GET)
public String updatePwd(){
return "admin/system/update_pwd";
}
/**
* Change password form submission
* @param oldPwd
* @param newPwd
* @return
*/
@RequestMapping(value="/update_pwd",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> updatePwd(@RequestParam(name="oldPwd",required=true)String oldPwd,
@RequestParam(name="newPwd",required=true)String newPwd
){
User loginedUser = SessionUtil.getLoginedUser();
if(!loginedUser.getPassword().equals(oldPwd)){
return Result.error(CodeMsg.ADMIN_USER_UPDATE_PWD_ERROR);
}
if(StringUtils.isEmpty(newPwd)){
return Result.error(CodeMsg.ADMIN_USER_UPDATE_PWD_EMPTY);
}
if (newPwd.length() < 4){
return Result.error(CodeMsg.ADMIN_USER_UPDATE_PWD_LENGTH);
}
loginedUser.setPassword(newPwd);
// Save database
userService.save(loginedUser);
// to update session
SessionUtil.set(SessionConstant.SESSION_USER_LOGIN_KEY, loginedUser);
return Result.success(true);
}
/**
* Log management list
* @param model
* @param operaterLog
* @param pageBean
* @return
*/
@RequestMapping(value="/operator_log_list")
public String operatorLogList(Model model,OperaterLog operaterLog,PageBean<OperaterLog> pageBean){
model.addAttribute("pageBean", operaterLogService.findList(operaterLog, pageBean));
model.addAttribute("operator", operaterLog.getOperator());
model.addAttribute("title", " Log list ");
return "admin/system/operator_log_list";
}
/**
* Delete operation log , You can delete multiple
* @param ids
* @return
*/
@RequestMapping(value="/delete_operator_log",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> delete(String ids){
if(!StringUtils.isEmpty(ids)){
String[] splitIds = ids.split(",");
for(String id : splitIds){
operaterLogService.delete(Long.valueOf(id));
}
}
return Result.success(true);
}
/**
* Empty the entire log
* @return
*/
@RequestMapping(value="/delete_all_operator_log",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> deleteAll(){
operaterLogService.deleteAll();
return Result.success(true);
}
}
Background role management controller :
/**
* Background role management controller
* @author yy
*
*/
@RequestMapping("/admin/role")
@Controller
public class RoleController {
private Logger log = LoggerFactory.getLogger(RoleController.class);
@Autowired
private MenuService menuService;
@Autowired
private OperaterLogService operaterLogService;
@Autowired
private RoleService roleService;
/**
* Paging search role list
* @param model
* @param role
* @param pageBean
* @return
*/
@RequestMapping(value="/list")
public String list(Model model,Role role,PageBean<Role> pageBean){
model.addAttribute("title", " Character list ");
model.addAttribute("name", role.getName());
model.addAttribute("pageBean", roleService.findByName(role, pageBean));
return "admin/role/list";
}
/**
* Role add page
* @param model
* @return
*/
@RequestMapping(value="/add",method=RequestMethod.GET)
public String add(Model model){
List<Menu> findAll = menuService.findAll();
model.addAttribute("topMenus",MenuUtil.getTopMenus(findAll));
model.addAttribute("secondMenus",MenuUtil.getSecondMenus(findAll));
model.addAttribute("thirdMenus",MenuUtil.getThirdMenus(findAll));
return "admin/role/add";
}
/**
* Role add form submission processing
* @param role
* @return
*/
@RequestMapping(value="/add",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> add(Role role){
// Use the unified verification entity method to verify whether it is legal
CodeMsg validate = ValidateEntityUtil.validate(role);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
}
if(roleService.save(role) == null){
return Result.error(CodeMsg.ADMIN_ROLE_ADD_ERROR);
}
log.info(" Adding roles 【"+role+"】");
operaterLogService.add(" Adding roles 【"+role.getName()+"】");
return Result.success(true);
}
/**
* Role edit page
* @param id
* @param model
* @return
*/
@RequestMapping(value="/edit",method=RequestMethod.GET)
public String edit(@RequestParam(name="id",required=true)Long id,Model model){
List<Menu> findAll = menuService.findAll();
model.addAttribute("topMenus",MenuUtil.getTopMenus(findAll));
model.addAttribute("secondMenus",MenuUtil.getSecondMenus(findAll));
model.addAttribute("thirdMenus",MenuUtil.getThirdMenus(findAll));
Role role = roleService.find(id);
model.addAttribute("role", role);
model.addAttribute("authorities",JSONArray.toJSON(role.getAuthorities()).toString());
return "admin/role/edit";
}
/**
* Role modification form submission processing
* @param role
* @return
*/
@RequestMapping(value="/edit",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> edit(Role role){
// Use the unified verification entity method to verify whether it is legal
CodeMsg validate = ValidateEntityUtil.validate(role);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
}
Role existRole = roleService.find(role.getId());
if(existRole == null){
return Result.error(CodeMsg.ADMIN_ROLE_NO_EXIST);
}
existRole.setName(role.getName());
existRole.setRemark(role.getRemark());
existRole.setStatus(role.getStatus());
existRole.setAuthorities(role.getAuthorities());
existRole.setType(role.getType());
if(roleService.save(existRole) == null){
return Result.error(CodeMsg.ADMIN_ROLE_EDIT_ERROR);
}
log.info(" Edit role 【"+role+"】");
operaterLogService.add(" Edit role 【"+role.getName()+"】");
return Result.success(true);
}
/**
* Delete the role
* @param request
* @param id
* @return
*/
@RequestMapping(value="delete",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> delete(@RequestParam(name="id",required=true)Long id){
try {
roleService.delete(id);
} catch (Exception e) {
// TODO: handle exception
return Result.error(CodeMsg.ADMIN_ROLE_DELETE_ERROR);
}
log.info(" Edit role ID【"+id+"】");
operaterLogService.add(" Delete the role ID【"+id+"】");
return Result.success(true);
}
}
The source code for : Blog's front page " resources " Download !
copyright notice
author[OldWinePot],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/116/202204261019147579.html
The sidebar is recommended
- 'interface' declarations can only be used in typescript files in Vue 3.0 + ts resolvent
- leetcode 682. Implementation of JavaScript in baseball game
- JavaScript optional chain
- Source code analysis, Vue global API set, del, nexttick, use, mixin, etc
- Brief introduction of Vue source code directory design
- Docxtemplator + Vue + docxtemplator image module free realize the front-end Word Download Text and free image download
- vue 2. What happens when x source code analyzes new vue()
- Use and principle of Vue keepalive
- Properties and usage of vuex
- Communication mode between Vue components
guess what you like
Front end interview Foundation
Usage scenario and principle of Vue nexttick
Configuration and use of rich text editor ckeditor4 in Vue
How does Java randomly get elements from a list
Study summary of pytext: a search path from NLP research to production
html+css+JavaScript
Tunnel http://bt3xna.natappfree.cc Invalid cannot connect to 172.0.0.1:8080 The web service powered by natapp. Is not available on this port cn
Next JS using react quill
Vue Gaode map can only have one start point and end point. How to realize it
Divide and conquer strategy -- find the k-th smallest element in the array
Random recommended
- Singleton mode - front end design mode
- QT sets that child elements do not inherit the parent style
- Using react to realize comment function
- Front end Vue template
- Front end vuejs set sail
- Front end Vue data binding and MVVM
- Vue data proxy and hijacking in front end
- Vue style of front end
- Front end Vue event handling
- Principle of Vue monitoring data change in front end
- Vue calculation attribute and monitoring attribute of the front end
- Front end Vue conditional rendering and list rendering
- The front-end Vue collects form data
- Vue built-in instruction of front end
- Unknown HttpClient factory netty at org. openqa. selenium. remote...
- Where is the user information obtained by the front end
- What is the gutter principle of Ant Design Vue a-row
- Element form account password
- CSS to add horizontal lines around the text
- Solution to vscode Vue project always reporting space or semicolon warning
- [entry DIARY 7 - ref of react]
- React - higher order functions and controlled components
- Calling setcookie in Ajax fails without any error in the IDE
- Differences, advantages and disadvantages between Ajax and Axios
- Choose Java or front-end for training and learning
- Simple sorting of JavaScript deep copy and shallow copy
- Analysis of event loop mechanism in JavaScript
- Epidemic prevention and control system of front and rear end separation based on Vue + nodejs
- Implementation of enterprise personnel management system by separating the front and back ends of springboot + Vue
- Vue difference between two arrays
- Vue openlayer add wind farm effect
- How to get child nodes of elements in HTML
- The file code with HTML suffix of vscode is not highlighted
- Use the table in Vue element admin in Vue admin template?
- [JavaScript] convert numerical value to numerical value
- Differences, advantages and disadvantages between Ajax and Axios
- Quietly tell you: the wrong place in react18 document
- The new smart spirit 1 starts in Asia! Breaking 100 in 6.7 seconds + frameless door, 190000 pre-sale
- Analysis of event loop mechanism in JavaScript
- Error occurred when installing vant on webstorm