欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

SSM案例-企业权限系统(7)- 查询所有订单

程序员文章站 2022-04-08 13:00:01
...

1 查询所有订单

SSM案例-企业权限系统(7)- 查询所有订单

1.1 DAO

SSM案例-企业权限系统(7)- 查询所有订单

package com.tzb.dao;

import com.tzb.domain.Orders;
import com.tzb.domain.Product;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface IOrdersDao {

    @Select("select * from orders")
    @Results({
            @Result(id=true,property = "id",column = "id"),
            @Result(property = "orderNum",column = "orderNum"),
            @Result(property = "orderTime",column = "orderTime"),
            @Result(property = "orderStatus",column = "orderStatus"),
            @Result(property = "peopleCount",column = "peopleCount"),
            @Result(property = "peopleCount",column = "peopleCount"),
            @Result(property = "payType",column = "payType"),
            @Result(property = "orderDesc",column = "orderDesc"),
            @Result(property = "product",column = "productId",
                    javaType = Product.class,one = @One(select = "com.tzb.dao.IProductDao.findById")),
    })
    public List<Orders> findAll() throws Exception;
}

1.2 Service

package com.tzb.service;

import com.tzb.domain.Orders;

import java.util.List;

public interface IOrdersService {
    List<Orders> findAll() throws Exception;
}

package com.tzb.service.impl;

import com.tzb.dao.IOrdersDao;
import com.tzb.domain.Orders;
import com.tzb.service.IOrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("ordersService")
@Transactional
public class OrdersServiceImpl implements IOrdersService {

    @Autowired
    private IOrdersDao ordersDao;

    @Override
    public List<Orders> findAll() throws Exception{
        return ordersDao.findAll();
    }
}

1.4 Controller

@Controller
@RequestMapping("/orders")
public class OrdersController {

    @Autowired
    private IOrdersService ordersService;

    @RequestMapping("/findAll.do")
    public ModelAndView findAll() throws Exception {
        ModelAndView mv = new ModelAndView();
        List<Orders> ordersList = ordersService.findAll();
        mv.addObject("ordersList",ordersList);
        mv.setViewName("orders-list");
        return mv;
    }

}

SSM案例-企业权限系统(7)- 查询所有订单


SSM案例-企业权限系统(7)- 查询所有订单