当前位置:   article > 正文

基于javaweb+SpringBoot的校园物流快递管理系统(java+maven+JSP+SpringBoot+layui+mysql)_jsp+layui+springboot

jsp+layui+springboot

一、项目运行

环境配置
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)

项目技术:
JSP +SpringBoot + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等。请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

            UserExample.Criteria criteriaUserName = userExample.createCriteria();
            criteriaUserName.andUsernameLike("%" + keyWord + "%");
            //真实名字条件
            UserExample.Criteria criteriaRealName = userExample.createCriteria();
            criteriaRealName.andRealnameLike("%" + keyWord + "%");
            //将两个条件用 or 组合
            userExample.or(criteriaRealName);
        }
        List<User> users = userService.selectByExample(userExample);
        //获得分页对象
        PageInfo<User> pageInfo = new PageInfo<>(users);
        return pageInfo;
    }
    @ResponseBody
    @RequestMapping("/delete")
    @RequiresPermissions("admin:delete")
    public Map<String, String> delete(Long[] userIds) {
        HashMap<String, String> map = new HashMap<>();
        if (userIds.length == 1) {
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
    public String list() {
        return "order/list";
    }
    @ResponseBody
    @RequestMapping("/getOrders")
    @RequiresPermissions("order:list")
    public PageInfo<OrderView> getOrders(String keyWord,
                                        @RequestParam(defaultValue = "1") Integer pageNum,
                                        @RequestParam(defaultValue = "10") Integer pageSize) {
        return getOrdersUtil(keyWord, pageNum, pageSize);
    }
    @ResponseBody
    @RequestMapping("/delete")
    @RequiresPermissions("order:delete")
    public Map<String, String> delete(Long[] orderIds) {
        HashMap<String, String> map = new HashMap<>();
        //单个删除
        if (orderIds.length == 1) {
            int res = orderService.deleteByPrimaryKey(orderIds[0]);
            if (res == 1) {
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
    public String addAdmin(Model m) {
        RoleExample roleExample = new RoleExample();
        List<Role> roles = roleService.selectByExample(roleExample);
        m.addAttribute("roles", roles);
        return "admin/add";
    }
    @ResponseBody
    @RequestMapping("/checkUsername")
    @RequiresPermissions("admin:list")
    public Boolean checkUsername(String username) {
        UserExample userExample = new UserExample();
        UserExample.Criteria criteria = userExample.createCriteria();
        criteria.andUsernameEqualTo(username);
        System.out.println(userService.selectByExample(userExample));
        if (userService.selectByExample(userExample).size() != 0) {
            return false;
        }
        return true;
    }
    @ResponseBody
    @RequestMapping("/insert")
    @RequiresPermissions("admin:insert")
    public Boolean insert(User user){
        String salt = UUID.randomUUID().toString().substring(0, 4);
        String hashedPassword = new SimpleHash("md5", user.getPassword(), salt,3).toString();
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
            return true;
        }
        return false;
    }
    @RequestMapping("/edit")
    @RequiresPermissions("order:update")
    public String edit(Long orderId, Model m) {
        //获取常规数据
        getOrderGeneralData(m);
        //添加选中的订单
        Order selectedOrder = orderService.selectByPrimaryKey(orderId);
        m.addAttribute("selectedOrder", selectedOrder);
        //添加订单详情
        OrderDetailExample orderDetailExample = new OrderDetailExample();
        orderDetailExample.createCriteria().andOrderIdEqualTo(orderId);
        List<OrderDetail> orderDetails = orderDetailService.selectByExample(orderDetailExample);
        m.addAttribute("orderDetails", orderDetails);
        return "order/edit";
    }
    @RequiresPermissions("order:update")
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
        }
        //批量删除
        int success = 0;
        int total = customerIds.length;
        for(Long customerId : customerIds) {
            success += customerService.deleteByPrimaryKey(customerId);
        }
        map.put("status", "true");
        map.put("info", "成功删除选中 " + total + " 个客户中的 " + success + " 个客户");
        return map;
    }
    @RequestMapping("/add")
    @RequiresPermissions("customer:insert")
    public String add(Model m) {
        //查出地区列表
        BasicDataExample basicDataExample = new BasicDataExample();
        basicDataExample.createCriteria().andParentIdEqualTo(ConstantDataField.AREA_BASICDATA_ID);
        List<BasicData> basicDatas= basicDataService.selectByExample(basicDataExample);
        m.addAttribute("areas",basicDatas);
        //获取当前登录用户
        Subject subject = SecurityUtils.getSubject();
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
    private CustomerViewService customerViewService;
    @Autowired
    private CustomerService customerService;
    @Autowired
    private BasicDataService basicDataService;
    @Autowired
    private UserService userService;
    @RequestMapping("/list")
    @RequiresPermissions("customer:list")
    public String list() {
        return "customer/list";
    }
    @ResponseBody
    @RequestMapping("/getCustomers")
    @RequiresPermissions("customer:list")
    public PageInfo<CustomerView> getCustomers(String keyWord,
                                                 @RequestParam(defaultValue = "1") Integer pageNum,
                                                 @RequestParam(defaultValue = "10") Integer pageSize) {
        //开始分页,这里启动并设置页码,和每页结果数量后,后续结果会自动为分页后结果
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
        //循环比较表单新数据和数据库数据,若存在则修改,不存在则新增
        formOrderDetails.forEach(formOrderDetail -> {
            if (dbOrderDetails.contains(formOrderDetail)) {
                orderDetailService.updateByPrimaryKeySelective(formOrderDetail);
            } else {
                formOrderDetail.setOrderId(order.getOrderId());
                orderDetailService.insert(formOrderDetail);
            }
        });
        //修改Order
        int res = orderService.updateByPrimaryKey(order);
        if (res == 1){
            return true;
        }
        return false;
    }
    //抽取的工具方法
    private void getOrderGeneralData(Model m){
        User user = (User)SecurityUtils.getSubject().getPrincipal(); //获取当前用户
        Long userRoleId = user.getRoleId(); //当前用户角色ID
        Long userId = user.getUserId(); //当前用户ID
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
    @RequiresPermissions("customer:list")
    public String list() {
        return "customer/list";
    }
    @ResponseBody
    @RequestMapping("/getCustomers")
    @RequiresPermissions("customer:list")
    public PageInfo<CustomerView> getCustomers(String keyWord,
                                                 @RequestParam(defaultValue = "1") Integer pageNum,
                                                 @RequestParam(defaultValue = "10") Integer pageSize) {
        //开始分页,这里启动并设置页码,和每页结果数量后,后续结果会自动为分页后结果
        PageHelper.startPage(pageNum, pageSize);
        CustomerViewExample customerViewExample = new CustomerViewExample();
        CustomerViewExample.Criteria criteria = customerViewExample.createCriteria();
        /**
         * StringUtils.isNotBlank 可以判断 ""/" "/null 为 false
         */
        if (StringUtils.isNotBlank(keyWord)) {
            //权限名条件
            criteria.andCustomerNameLike("%" + keyWord + "%");
        }
        //判断当前登录用户是否为业务员,业务员只能查看自己的客户
        Subject subject = SecurityUtils.getSubject();
        User user = (User) subject.getPrincipal();
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
    @RequestMapping("/getOrders")
    @RequiresPermissions("order:list")
    public PageInfo<OrderView> getOrders(String keyWord,
                                        @RequestParam(defaultValue = "1") Integer pageNum,
                                        @RequestParam(defaultValue = "10") Integer pageSize) {
        return getOrdersUtil(keyWord, pageNum, pageSize);
    }
    @ResponseBody
    @RequestMapping("/delete")
    @RequiresPermissions("order:delete")
    public Map<String, String> delete(Long[] orderIds) {
        HashMap<String, String> map = new HashMap<>();
        //单个删除
        if (orderIds.length == 1) {
            int res = orderService.deleteByPrimaryKey(orderIds[0]);
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
        }
        //判断当前登录用户是否为业务员,业务员只能查看自己的客户
        Subject subject = SecurityUtils.getSubject();
        User user = (User) subject.getPrincipal();
        if (user.getRoleId() == ConstantDataField.SALESMAN_ROLE_ID) {
            //客户的业务员id等于登录用户的id
            criteria.andUserIdEqualTo(user.getUserId());
        }
        List<CustomerView> customers = customerViewService.selectByExample(customerViewExample);
        //获得分页对象
        PageInfo<CustomerView> pageInfo = new PageInfo<>(customers);
        return pageInfo;
    }
    @ResponseBody
    @RequestMapping("/delete")
    @RequiresPermissions("customer:delete")
    public Map<String, String> delete(Long[] customerIds) {
        HashMap<String, String> map = new HashMap<>();
        if (customerIds.length == 1) {
            int res = customerService.deleteByPrimaryKey(customerIds[0]);
            if (res == 1) {
                map.put("status", "true");
                map.put("info", "删除成功!");
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/155623
推荐阅读
相关标签
  

闽ICP备14008679号