Java實戰之在線寄查快遞系統的實現
介紹
超級管理員:系統管理、用戶管理、網點管理、運輸點管理、快遞員管理、網點申請管理(審核)、報價管理(時效報價)等。
普通用戶:註冊登錄、個人信息管理(個人資料、密碼修改等)、地址管理、實名認證、在線寄件(單件寄件、批量導入寄件)、訂單查詢(物流信息查詢)、在線申請網點、投訴建議等。
網點管理員:攬收負責區域的快遞,進行快遞快遞運輸,確認到達快遞,快遞到達後指派網點下快遞員進行派送。
運輸點管理員:負責運輸至該運輸點的快遞再次運輸。
運行環境:windows/Linux均可、jdk1.8、mysql5.7、idea/eclipse均可。
效果圖
核心代碼
後臺角色管理控制器
/** * 後臺角色管理控制器 * @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; /** * 分頁搜索角色列表 * @param model * @param role * @param pageBean * @return */ @RequestMapping(value="/list") public String list(Model model,Role role,PageBean<Role> pageBean){ model.addAttribute("title", "角色列表"); model.addAttribute("name", role.getName()); model.addAttribute("pageBean", roleService.findByName(role, pageBean)); return "admin/role/list"; } /** * 角色添加頁面 * @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"; } /** * 角色添加表單提交處理 * @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); } //用統一驗證實體方法驗證是否合法 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("添加角色【"+role+"】"); operaterLogService.add("添加角色【"+role.getName()+"】"); return Result.success(true); } /** * 角色編輯頁面 * @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"; } /** * 角色修改表單提交處理 * @param request * @param role * @return */ @RequestMapping(value="/edit",method=RequestMethod.POST) @ResponseBody public Result<Boolean> edit(Role role){ //用統一驗證實體方法驗證是否合法 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("編輯角色【"+role+"】"); operaterLogService.add("編輯角色【"+role.getName()+"】"); return Result.success(true); } /** * 刪除角色 * @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("編輯角色ID【"+id+"】"); operaterLogService.add("刪除角色ID【"+id+"】"); return Result.success(true); } }
後臺管理員管理控制器
/** * 後臺管理員管理控制器 * @author yy * */ @RequestMapping("/admin/user") @Controller public class UserController { @Autowired private UserService userService; @Autowired private RoleService roleService; @Autowired private OperaterLogService operaterLogService; /** * 管理員列表頁面 * @param model * @param user * @param pageBean * @return */ @RequestMapping(value="/list") public String list(Model model,User user,PageBean<User> pageBean){ model.addAttribute("title", "管理員列表"); model.addAttribute("username", user.getUsername()); model.addAttribute("pageBean", userService.findList(pageBean,user.getUsername(), UserRoleTypeEnum.ADMIN)); return "admin/user/list"; } /** * 新增管理員頁面 * @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"; } /** * 管理員添加表單提交處理 * @param user * @return */ @RequestMapping(value="/add",method=RequestMethod.POST) @ResponseBody public Result<Boolean> add(User user){ //用統一驗證實體方法驗證是否合法 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(userService.isExistUsername(user.getUsername(), 0L)){ return Result.error(CodeMsg.ADMIN_USERNAME_EXIST); } user.setUserType(UserRoleTypeEnum.ADMIN); //到這說明一切符合條件,進行數據庫新增 if(userService.save(user) == null){ return Result.error(CodeMsg.ADMIN_USE_ADD_ERROR); } operaterLogService.add("添加管理員,管理員名:" + user.getUsername()); return Result.success(true); } /** * 管理員編輯頁面 * @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"; } /** * 編輯管理員信息表單提交處理 * @param user * @return */ @RequestMapping(value="/edit",method=RequestMethod.POST) @ResponseBody public Result<Boolean> edit(User user){ //用統一驗證實體方法驗證是否合法 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); } //到這說明一切符合條件,進行數據庫保存 User findById = userService.find(user.getId()); //講提交的管理員信息指定字段復制到已存在的user對象中,該方法會覆蓋新字段內容 BeanUtils.copyProperties(user, findById, "id","createTime","updateTime","userType"); if(userService.save(findById) == null){ return Result.error(CodeMsg.ADMIN_USE_EDIT_ERROR); } operaterLogService.add("編輯管理員,管理員名:" + user.getUsername()); return Result.success(true); } /** * 刪除管理員 * @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("刪除管理員,管理員ID:" + id); return Result.success(true); } }
投訴控制層
/** * @info : 投訴控制層 * @author: yy */ @RequestMapping("/admin/complaint") @Controller public class ComplaintController { @Autowired private ComplaintService complaintService; /** * 分頁搜索投訴列表 * @param model * @param complaint * @param pageBean * @return */ @RequestMapping(value="/list") public String list(Model model, Complaint complaint, PageBean<Complaint> pageBean){ model.addAttribute("title", "投訴列表"); model.addAttribute("waybillNumber", complaint.getWaybillNumber()); model.addAttribute("pageBean", complaintService.findList(complaint, pageBean)); return "admin/complaint/list"; } @RequestMapping(value="/accepted",method= RequestMethod.POST) @ResponseBody public Result<Boolean> accepted(@RequestParam(name="id")Long id){ Complaint complaint = complaintService.find(id); complaint.setStatus(Complaint.ACCEPTED); if (complaintService.save(complaint) == null){ return Result.error(CodeMsg.COMPLAINT_ACCEPTED_ERROR); } return Result.success(true); } }
前臺申請地點申請控制層
/** * @info : 前臺網點申請網點申請控制層 * @author: yy */ @RequestMapping("/admin/branchApplyFor") @Controller public class BranchApplyForController { @Autowired private BranchApplyForService branchApplyForService; @Autowired private UserService userService; @Autowired private RoleService roleService; /** * 網點申請列表頁面 * @param model * @param branchApplyFor * @param pageBean * @return */ @RequestMapping(value="/list") public String list(Model model, BranchApplyFor branchApplyFor, PageBean<BranchApplyFor> pageBean){ model.addAttribute("title", "網點申請列表"); model.addAttribute("branchName", branchApplyFor.getBranchName()); model.addAttribute("pageBean", branchApplyForService.findList(pageBean,branchApplyFor.getBranchName(), null)); return "admin/branch_apply_for/list"; } /** * 通過申請 * @param id * @return */ @RequestMapping(value="/agree",method=RequestMethod.POST) @ResponseBody public Result<Boolean> agree(@RequestParam(name="id")Long id){ Role role = roleService.findTop1ByRoleType(UserRoleTypeEnum.BRANCHES); if (role == null){ return Result.error(CodeMsg.BRANCHAPPLYFOR_ROLE_NO_EXIST); } Integer integer = branchApplyForService.agreeBranchApplyFor(id, role); if (1 == integer){ return Result.error(CodeMsg.BRANCHAPPLYFOR_THROUGH_ERROR); } return Result.success(true); } /** * 駁回申請 * @param id * @return */ @RequestMapping(value="/rejected",method=RequestMethod.POST) @ResponseBody public Result<Boolean> rejected(@RequestParam(name="id")Long id,@RequestParam(name = "rejectReason")String rejectReason){ BranchApplyFor branchApplyFor = branchApplyForService.find(id); branchApplyFor.setBranchApplyForStatus(BranchApplyForStatusEnum.NOTTHROUGH); if (StringUtils.isEmpty(rejectReason)){ return Result.error(CodeMsg.BRANCHAPPLYFOR_NOTTHROUGH_NULL); } if (rejectReason.length() >= 188){ return Result.error(CodeMsg.BRANCHAPPLYFOR_NOTTHROUGH_LENGTH); } branchApplyFor.setRejectReason(rejectReason); if (branchApplyForService.save(branchApplyFor) == null){ return Result.error(CodeMsg.BRANCHAPPLYFOR_NOTTHROUGH_ERROR); } return Result.success(true); } }
以上就是Java實戰之在線寄查快遞系統的實現的詳細內容,更多關於Java寄查快遞系統的資料請關註WalkonNet其它相關文章!
推薦閱讀:
- Java實戰之實現物流配送系統示例詳解
- Java實戰員工績效管理系統的實現流程
- Java實戰權限管理系統的實現流程
- Java 實戰項目之精品養老院管理系統的實現流程
- Java實戰角色權限後臺腳手架系統的實現流程