¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.smartearth.poiexcel.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.metadata.OrderItem; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.smartearth.poiexcel.entity.DkEntity; |
| | | import com.smartearth.poiexcel.entity.ResponseMsg; |
| | | import com.smartearth.poiexcel.mapper.DkMapper; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å°åæ§å¶å¨ |
| | | * @author WWW |
| | | * @date 2023-10-07 |
| | | */ |
| | | @Api(tags = "å°åæ§å¶å¨") |
| | | @RestController |
| | | @RequestMapping("/dk") |
| | | @SuppressWarnings("ALL") |
| | | public class DkController extends BaseController { |
| | | @Resource |
| | | DkMapper dkMapper; |
| | | |
| | | @ApiOperation(value = "å页æ¥è¯¢å°å") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "pageSize", value = "æ¯é¡µæ¡æ°", dataType = "Integer", paramType = "query", example = "10"), |
| | | @ApiImplicitParam(name = "pageIndex", value = "å页æ°ï¼ä»1å¼å§ï¼", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectByPage") |
| | | public ResponseMsg<Object> selectByPage(Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (null == pageSize || pageSize < 1) { |
| | | pageSize = 10; |
| | | } |
| | | if (null == pageIndex || pageIndex < 1) { |
| | | pageIndex = 1; |
| | | } |
| | | |
| | | QueryWrapper<DkEntity> wrapper = new QueryWrapper<>(); |
| | | // wrapper.ge("age",20); |
| | | |
| | | Page<DkEntity> page = new Page<>(pageIndex, pageSize); |
| | | page.addOrder(OrderItem.desc("id")); |
| | | |
| | | IPage<DkEntity> iPage = dkMapper.selectPage(page, wrapper); |
| | | List<DkEntity> list = iPage.getRecords(); |
| | | |
| | | return success(iPage.getTotal(), list); |
| | | } catch (Exception ex) { |
| | | return fail(ex, -1); |
| | | } |
| | | } |
| | | } |