current position:Home>Java project: logistics express management system (java + SSM + jsp + MySQL)
Java project: logistics express management system (java + SSM + jsp + MySQL)
2022-01-27 05:07:25 【qq_ one billion three hundred and thirty-four million six hundr】
The main functions of this system are :
Front end company home page 、 policy 、 News Consulting 、 Contact address 、 Leave a message online 、 Place an order online , Query express logistics information, etc ,
The main functions of the background are : Menu management 、 Role management 、 User management 、 News management 、 Log management 、 message management 、 Order management, etc .
Front desk login registration control layer :
/**
* Front desk login registration control layer
*/
@Controller
@RequestMapping("/home/index")
public class HomeLoginController {
@Autowired
private HomeUserService homeUserService;
/**
* Go to the login page
* @return
*/
@RequestMapping(value="/login",method= RequestMethod.GET)
public String login(){
return "home/login";
}
/**
* The user login
* @param mobile
* @param password
* @return
*/
@RequestMapping(value="/login",method= RequestMethod.POST)
@ResponseBody
public Result<Boolean> login(@RequestParam("mobile")String mobile,@RequestParam("password")String password) {
// Verify whether the entered mobile phone number is legal
String checkPhone = "^1[3|4|5|7|8]\\d{9}$";
Pattern r = Pattern.compile(checkPhone);
Matcher m = r.matcher(mobile);
if (!m.matches()) {
return Result.error(CodeMsg.HOMEUSER_MOBILE_ERROR);
}
HomeUser byMobile = homeUserService.findByMobile(mobile);
if (byMobile == null){
return Result.error(CodeMsg.HOMEUSER_NO_EXIST);
}
if (byMobile.getStatus() == 0){
return Result.error(CodeMsg.HOMEUSER_STATUS_ERROR);
}
if (!byMobile.getPassword().equals(password)){
return Result.error(CodeMsg.HOMEUSER_PASSWORD_ERROR);
}
SessionUtil.set(SessionConstant.SESSION_HOME_USER_LOGIN_KEY, byMobile);
return Result.success(true);
}
/**
* Go to the registration page
* @return
*/
@RequestMapping(value="/register",method= RequestMethod.GET)
public String register(){
return "home/register";
}
/**
* User registration
* @param homeUser
* @param code
* @return
*/
@RequestMapping(value="/register",method= RequestMethod.POST)
@ResponseBody
public Result<Boolean> register(HomeUser homeUser, @RequestParam("reCode") String code) {
// Verify whether the entered mobile phone number is legal
String checkPhone = "^1[3|4|5|7|8]\\d{9}$";
Pattern r = Pattern.compile(checkPhone);
Matcher m = r.matcher(homeUser.getMobile());
if (!m.matches()) {
return Result.error(CodeMsg.HOMEUSER_MOBILE_ERROR);
}
if (!StringUtil.emailFormat(homeUser.getEmail())) {
return Result.error(CodeMsg.COMMON_EMAIL_FORMAET_ERROR);
}
if (code == null) {
return Result.error(CodeMsg.HOMEUSER_CODE_ERROR);
}
if (code.length() != 4) {
return Result.error(CodeMsg.HOMEUSER_CODE_LENGTH_ERROR);
}
Object attr = SessionUtil.get(SessionConstant.HOME_USER_REGISTER_CODE);
if (attr == null) {
return Result.error(CodeMsg.CODE_NOT_EMPTY);
}
if (!code.equalsIgnoreCase(attr.toString())) {
return Result.error(CodeMsg.CPACHA_ERROR);
}
// Judge whether the mobile phone number is registered
if(homeUserService.isExistMobile(homeUser.getMobile(),0L)){
return Result.error(CodeMsg.HOMEUSER_MOBILE_EXIST);
}
if (homeUserService.save(homeUser) == null) {
return Result.error(CodeMsg.HOMEUSER_ADD_ERROR);
}
SessionUtil.set(SessionConstant.HOME_USER_REGISTER_CODE, null);
return Result.success(true);
}
/**
* Jump to forgot password
* @return
*/
@RequestMapping(value="/forget",method= RequestMethod.GET)
public String forget(){
return "home/forget_password";
}
/**
* Change Password
* @param homeUser
* @param code
* @return
*/
@RequestMapping(value="/forget",method= RequestMethod.POST)
@ResponseBody
public Result<Boolean> forget(HomeUser homeUser, @RequestParam("reCode") String code) {
// Verify whether the entered mobile phone number is legal
String checkPhone = "^1[3|4|5|7|8]\\d{9}$";
Pattern r = Pattern.compile(checkPhone);
Matcher m = r.matcher(homeUser.getMobile());
if (!m.matches()) {
return Result.error(CodeMsg.HOMEUSER_MOBILE_ERROR);
}
if (!StringUtil.emailFormat(homeUser.getEmail())) {
return Result.error(CodeMsg.COMMON_EMAIL_FORMAET_ERROR);
}
if (code == null) {
return Result.error(CodeMsg.HOMEUSER_CODE_ERROR);
}
if (code.length() != 4) {
return Result.error(CodeMsg.HOMEUSER_CODE_LENGTH_ERROR);
}
Object attr = SessionUtil.get(SessionConstant.HOME_USER_FORGET_PASSWORD_CODE);
if (attr == null) {
return Result.error(CodeMsg.CODE_NOT_EMPTY);
}
if (!code.equalsIgnoreCase(attr.toString())) {
return Result.error(CodeMsg.CPACHA_ERROR);
}
// Judge whether the mobile phone number is registered
HomeUser byMobile = homeUserService.findByMobile(homeUser.getMobile());
if (byMobile == null) {
return Result.error(CodeMsg.HOMEUSER_NO_EXIST);
}
if (!byMobile.getEmail().equals(homeUser.getEmail())){
return Result.error(CodeMsg.CODE_NOT_ERROR);
}
byMobile.setPassword(homeUser.getPassword());
if (homeUserService.save(byMobile) == null) {
return Result.error(CodeMsg.HOMEUSER_FORGET_ERROR);
}
SessionUtil.set(SessionConstant.HOME_USER_FORGET_PASSWORD_CODE, null);
return Result.success(true);
}
/**
* sign out
* @return
*/
@RequestMapping(value = "logout", method = RequestMethod.POST)
@ResponseBody
public Result<Boolean> logout() {
HttpSession session = SessionUtil.getSession();
HomeUser homeUser = SessionUtil.getHomeUser();
if (homeUser != null) {
session.removeAttribute(SessionConstant.SESSION_HOME_USER_LOGIN_KEY);
}
return Result.success(true);
}
}
The background administrator manages the controller :
/**
* The background administrator manages the controller
* @author yy
*
*/
@RequestMapping("/admin/user")
@Controller
public class UserController {
@Autowired
private UserService userService;
@Autowired
private RoleService roleService;
@Autowired
private OperaterLogService operaterLogService;
/**
* Administrator list page
* @param model
* @param user
* @param pageBean
* @return
*/
@RequestMapping(value="/list")
public String list(Model model,User user,PageBean<User> pageBean){
model.addAttribute("title", " Admin list ");
model.addAttribute("username", user.getUsername());
model.addAttribute("pageBean", userService.findList(pageBean,user.getUsername(), UserRoleTypeEnum.ADMIN));
return "admin/user/list";
}
/**
* New administrator page
* @param model
* @return
*/
@RequestMapping(value="/add",method=RequestMethod.GET)
public String add(Model model){
model.addAttribute("roles", roleService.findAllByRoleType(UserRoleTypeEnum.ADMIN));
return "admin/user/add";
}
/**
* Administrator adds form submission processing
* @param user
* @return
*/
@RequestMapping(value="/add",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> add(User user){
// 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);
}
if(user.getRole() == null || user.getRole().getId() == null){
return Result.error(CodeMsg.ADMIN_USER_ROLE_EMPTY);
}
// Determine whether the administrator name exists
if(userService.isExistUsername(user.getUsername(), 0L)){
return Result.error(CodeMsg.ADMIN_USERNAME_EXIST);
}
user.setUserType(UserRoleTypeEnum.ADMIN);
// This means that everything is qualified , Add database
if(userService.save(user) == null){
return Result.error(CodeMsg.ADMIN_USE_ADD_ERROR);
}
operaterLogService.add(" Add Administrator , Administrator name :" + user.getUsername());
return Result.success(true);
}
/**
* Administrator edit page
* @param model
* @return
*/
@RequestMapping(value="/edit",method=RequestMethod.GET)
public String edit(Model model,@RequestParam(name="id",required=true)Long id){
model.addAttribute("roles", roleService.findAllByRoleType(UserRoleTypeEnum.ADMIN));
model.addAttribute("user", userService.find(id));
return "admin/user/edit";
}
/**
* Edit administrator information form submission processing
* @param user
* @return
*/
@RequestMapping(value="/edit",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> edit(User user){
// 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);
}
if(user.getRole() == null || user.getRole().getId() == null){
return Result.error(CodeMsg.ADMIN_USER_ROLE_EMPTY);
}
if(user.getId() == null || user.getId().longValue() <= 0){
return Result.error(CodeMsg.ADMIN_USE_NO_EXIST);
}
if(userService.isExistUsername(user.getUsername(), user.getId())){
return Result.error(CodeMsg.ADMIN_USERNAME_EXIST);
}
// This means that everything is qualified , Save the database
User findById = userService.find(user.getId());
// The specified fields of the submitted administrator information are copied to the existing user In the object , This method overwrites the contents of the new field
BeanUtils.copyProperties(user, findById, "id","createTime","updateTime","userType");
if(userService.save(findById) == null){
return Result.error(CodeMsg.ADMIN_USE_EDIT_ERROR);
}
operaterLogService.add(" Editor administrator , Administrator name :" + user.getUsername());
return Result.success(true);
}
/**
* Delete Administrator
* @param id
* @return
*/
@RequestMapping(value="/delete",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> delete(@RequestParam(name="id",required=true)Long id){
try {
userService.delete(id);
} catch (Exception e) {
return Result.error(CodeMsg.ADMIN_USE_DELETE_ERROR);
}
operaterLogService.add(" Delete Administrator , Administrators ID:" + id);
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("roleTypes", UserRoleTypeEnum.values());
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){
Role top1ByRoleType = roleService.findTop1ByRoleTypeAndRoleTypeNot(role.getRoleType());
if (top1ByRoleType != null){
return Result.error(CodeMsg.ADMIN_ROLE_EXIST);
}
// 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());
model.addAttribute("roleTypes", UserRoleTypeEnum.values());
return "admin/role/edit";
}
/**
* Role modification form submission processing
* @param request
* @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());
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);
}
}
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/202201270507243946.html
The sidebar is recommended
- Spring IOC container loading process
- [thinking] the difference between singleton mode and static method - object-oriented programming
- Hadoop environment setup (MySQL environment configuration)
- 10 minutes, using node JS creates a real-time early warning system for bad weather!
- Git tool
- Force deduction algorithm - 92 Reverse linked list II
- What is the sub problem of dynamic programming?
- C / C + +: static keyword summary
- Idea does not have the artifacts option when configuring Tomcat
- Anaconda can't open it
guess what you like
-
I don't know how to start this
-
Matlab simulation of transportation optimization algorithm based on PSO
-
MySQL slow log optimization
-
[Vue] as the window is stretched (larger, smaller, wider and higher), the text will not be displayed
-
Popular Linux distributions for embedded computing
-
Suzhou computer research
-
After installing SSL Certificate in Windows + tomcat, the domain name request is not successful. Please answer!!
-
Implementation time output and greetings of jQuery instance
-
The 72 year old uncle became popular. Wu Jing and Guo fan made his story into a film, which made countless dreamers blush
-
How to save computer research
Random recommended
- Springboot implements excel import and export, which is easy to use, and poi can be thrown away
- The final examination subjects of a class are mathematical programming, and the scores are sorted and output from high to low
- Two pronged approach, Tsinghua Professor Pro code JDK and hotspot source code notes, one-time learning to understand
- C + + recursive knapsack problem
- The use of GIT and GitHub and the latest git tutorial are easy to understand -- Video notes of crazy God speaking
- PostgreSQL statement query
- Ignition database test
- Context didn't understand why he got a high salary?, Nginxfair principle
- Bootstrap switch switch control user's guide, springcloud actual combat video
- A list that contains only strings. What other search methods can be used except sequential search
- [matlab path planning] multi ant colony algorithm grid map path planning [including GUI source code 650]
- [matlab path planning] improved genetic algorithm grid map path planning [including source code phase 525]
- Iinternet network path management system
- Appium settings app is not running after 5000ms
- Reactnative foundation - 07 (background image, status bar, statusbar)
- Reactnative foundation - 04 (custom rpx)
- If you want an embedded database (H2, hsql or Derby), please put it on the classpath
- When using stm32g070 Hal library, if you want to write to flash, you must perform an erase. If you don't let it, you can't write continuously.
- Linux checks where the software is installed and what files are installed
- SQL statement fuzzy query and time interval filtering
- 69. Sqrt (x) (c + + problem solving version with vs runnable source program)
- Fresh students are about to graduate. Do you choose Java development or big data?
- Java project: OA management system (java + SSM + bootstrap + MySQL + JSP)
- Titanic passenger survival prediction
- Vectorization of deep learning formula
- Configuration and use of private image warehouse of microservice architect docker
- Relearn JavaScript events
- For someone, delete return 1 and return 0
- How does Java dynamically obtain what type of data is passed? It is used to judge whether the data is the same, dynamic data type
- How does the database cow optimize SQL?
- [data structure] chain structure of binary tree (pre order traversal) (middle order traversal) (post order traversal) (sequence traversal)
- Webpack packaging optimization solution
- 5. Operation element
- Detailed explanation of red and black trees
- redhat7. 9 install database 19C
- Blue Bridge Cup notes: (the given elements are not repeated) complete arrangement (arrangement cannot be repeated, arrangement can be repeated)
- Detailed explanation of springboot default package scanning mechanism and @ componentscan specified scanning path
- How to solve the run-time exception of test times
- Detailed explanation of k8s management tool kubectl
- Android system view memory command