Java实战之在线寄查快递系统的实现

网友投稿 248 2022-08-25


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 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

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 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

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 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 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 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 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

//用统一验证实体方法验证是否合法

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 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 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 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(http://"/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 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 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 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寄查快递系统的资料请关注我们其它相关文章!

//用统一验证实体方法验证是否合法

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 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 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 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(http://"/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 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 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 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寄查快递系统的资料请关注我们其它相关文章!


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:python备份数据库脚本(mysql数据库备份脚本)
下一篇:python pandas库 常用函数及操作一览(python怎么读)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~