首页>代码>基于SpringBoot的快递之家管理系统的设计与实现>/logistics/logistics/src/main/java/com/ev/logistics/controller/PickUpController.java
package com.ev.logistics.controller;

import com.ev.logistics.entity.Orders;
import com.ev.logistics.entity.Position;
import com.ev.logistics.entity.Post;
import com.ev.logistics.entity.User;
import com.ev.logistics.service.OrdersService;
import com.ev.logistics.service.PositionService;
import com.ev.logistics.service.PostService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.servlet.http.HttpSession;
import java.util.Date;
import java.util.List;

/**
 * @author EV
 * @date 2021/5/5 1:39
 */
@Controller
public class PickUpController {

    @Autowired
    OrdersService ordersService;

    @Autowired
    PositionService positionService;

    @Autowired
    PostService postService;

    @GetMapping("/toPickUp")
    public String toPickUp(@RequestParam(required = false, defaultValue = "1", value = "pageNum") int pageNum, Model model, HttpSession session, RedirectAttributes attributes) {
        User userInfo = (User) session.getAttribute("user");
        if (userInfo != null) {
            PageHelper.startPage(pageNum, 6);
            List<Orders> ordersList = ordersService.findByUserId(userInfo.getId());
            PageInfo<Orders> pageInfo = new PageInfo<>(ordersList);
            model.addAttribute("ordersList",ordersList);
            model.addAttribute("pageInfo",pageInfo);
            return "pickUp";
        } else {
            attributes.addFlashAttribute("message", "权限不足,请先登录");
            return "redirect:/toLogin";
        }
    }

    @GetMapping("/pickUpOrders/{id}")
    public String pickUpOrders(@PathVariable Integer id){
        ordersService.updateOrdersStatusTo1(id,new Date());
        Orders orders = ordersService.findById(id);
        //柜子状态变为0
        Position position = positionService.getById(orders.getPositionId());
        position.setStatus(0);
        positionService.updateById(position);
        //post状态变为3
        Post post = postService.findByNum(orders.getNum());
        postService.updatePostStatusTo3(post.getId(), new Date());

        return "redirect:/toPickUp";
    }

    @GetMapping("/pickUpOrders2/{id}")
    public String pickUpOrders2(@PathVariable Integer id){
        ordersService.updateOrdersStatusTo1(id,new Date());
        //柜子状态变为0
        Orders orders = ordersService.findById(id);
        Position position = positionService.getById(orders.getPositionId());
        position.setStatus(0);
        positionService.updateById(position);
        return "redirect:/toUserPickUp";
    }

}
最近下载更多
陈金龙  LV6 4月8日
zolscy  LV12 3月24日
floweyws  LV6 3月20日
2010160433  LV3 3月9日
可是不知道么  LV23 1月30日
root111snkdnc  LV3 1月26日
admin_z  LV22 2023年12月28日
zyzyhh  LV2 2023年11月18日
拜托你仔细听  LV3 2023年9月21日
最近浏览更多
12364qq 5月1日
暂无贡献等级
kenhomeliu  LV29 4月30日
whb5566  LV10 4月24日
sudowoodo 4月20日
暂无贡献等级
860421  LV3 4月18日
akittyboy  LV9 4月16日
一个小学码  LV4 4月16日
陈金龙  LV6 4月8日
玖零定制问题修复  LV34 4月4日
wanglinddad  LV54 4月2日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友