| | |
| | | package com.lf.server.controller.sys; |
| | | |
| | | 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.lf.server.annotation.SysLog; |
| | | import com.lf.server.controller.all.BaseController; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.sys.BlacklistEntity; |
| | | import com.lf.server.entity.sys.DownlogEntity; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.mapper.sys.DownlogMapper; |
| | | import com.lf.server.service.sys.DepService; |
| | | import com.lf.server.service.sys.DownlogService; |
| | | import com.lf.server.service.sys.TokenService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @RequestMapping("/downlog") |
| | | public class DownlogController extends BaseController { |
| | | @Autowired |
| | | DownlogMapper downlogMapper; |
| | | DownlogService downlogService; |
| | | |
| | | @Autowired |
| | | TokenService tokenService; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "分页查询并返回记录数") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = ""), |
| | | @ApiImplicitParam(name = "uname", value = "用户名", dataType = "String", paramType = "query", example = "员"), |
| | | @ApiImplicitParam(name = "type", value = "类型", dataType = "Integer", paramType = "query", example = "3"), |
| | | @ApiImplicitParam(name = "start", value = "开始时间", dataType = "Timestamp", paramType = "query", example = "2022-12-09 09:00:00"), |
| | | @ApiImplicitParam(name = "end", value = "结束时间", dataType = "Timestamp", paramType = "query", example = "2022-12-25 17:00:00"), |
| | | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"), |
| | | @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectByPageAndCount") |
| | | public ResponseMsg<List<DownlogEntity>> selectByPageAndCount(String name, Integer pageSize, Integer pageIndex) { |
| | | public ResponseMsg<Object> selectByPageAndCount(String uname, Integer type, Timestamp start, Timestamp end, Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | |
| | | QueryWrapper wrapper = new QueryWrapper(); |
| | | if (!StringHelper.isEmpty(name)) { |
| | | wrapper.like("name", name); |
| | | int count = downlogService.selectCount(uname, type, start, end); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | | } |
| | | |
| | | Page<DownlogEntity> page = new Page<>(pageIndex, pageSize); |
| | | page.addOrder(OrderItem.asc("id")); |
| | | IPage<DownlogEntity> paged = downlogMapper.selectPage(page, wrapper); |
| | | List<DownlogEntity> rs = downlogService.selectByPage(uname, type, start, end, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(paged.getTotal(), paged.getRecords()); |
| | | return success(count, rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | } |