src/main/java/com/byh/biyesheji/controller/ProductController.java

(开头部分) 5KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

package com.byh.biyesheji.controller;

import com.byh.biyesheji.pojo.Category;
import com.byh.biyesheji.pojo.Product;
import com.byh.biyesheji.pojo.ProductVO;
import com.byh.biyesheji.pojo.User;
import com.byh.biyesheji.service.CategoryService;
import com.byh.biyesheji.service.ProductService;
import com.byh.biyesheji.service.UserService;
import com.byh.biyesheji.util.Page;
import com.byh.biyesheji.util.UploadUtil;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.IOException;
import java.util.List;

/**
 * 商品模块controller
 */
@Controller
@RequestMapping("/product")
public class ProductController {

    @Autowired
    private ProductService productService;
    @Autowired
    private UserService userService;
    @Autowired
    private CategoryService categoryService;

    @RequestMapping("/list")
    public String list(Model model, Page page){
        PageHelper.offsetPage(page.getStart(),page.getCount());//分页查询
        List<Product> list= productService.list();
        int total = (int) new PageInfo<>(list).getTotal();//总条数
        page.setTotal(total);

        model.addAttribute("list",list);
        model.addAttribute("total",total);
        model.addAttribute("page", page);

        return "productmodule/product-list";
    }


    @RequestMapping("/enableStatus")
    @ResponseBody
    public String enableStatus(@RequestParam(value = "name") String name){
        return productService.enableStatus(name);
    }

后面还有 102 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。