You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
2.0 KiB
54 lines
2.0 KiB
package com.zh.project0512.serviceImpl;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.zh.project0512.mapper.RankMapper;
|
|
import com.zh.project0512.model.Rank;
|
|
import com.zh.project0512.model.dto.RankListDTO;
|
|
import com.zh.project0512.model.vo.RankListVo;
|
|
import com.zh.project0512.service.IRankService;
|
|
import com.zh.project0512.utils.PropertyUtils;
|
|
import com.zh.project0512.utils.page.PageInfo;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.ArrayList;
|
|
import java.util.Calendar;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
|
|
@Service
|
|
public class RankServiceImpl implements IRankService {
|
|
@Resource
|
|
RankMapper rankMapper;
|
|
|
|
@Override
|
|
public PageInfo<RankListVo> rankList(RankListDTO rankListDTO) {
|
|
ArrayList<RankListVo> rankListVoList = new ArrayList<>();
|
|
Calendar cal = Calendar.getInstance();
|
|
cal.setTime(new Date());
|
|
cal.add(Calendar.DAY_OF_MONTH,-1);
|
|
cal.set(Calendar.DAY_OF_MONTH,1);
|
|
cal.set(Calendar.HOUR_OF_DAY, 0);
|
|
cal.set(Calendar.MINUTE, 0);
|
|
cal.set(Calendar.SECOND, 0);
|
|
Date time = cal.getTime();
|
|
|
|
QueryWrapper<Rank> queryWrapper = new QueryWrapper<>();
|
|
queryWrapper.eq("type",rankListDTO.getType());
|
|
queryWrapper.eq("dateStart",time);
|
|
Page<Rank> page = new Page<>(rankListDTO.getPageNum(), rankListDTO.getSize());
|
|
IPage<Rank> rankIPage = rankMapper.selectPage(page, queryWrapper);
|
|
List<Rank> records = rankIPage.getRecords();
|
|
if (records != null && records.size()>0){
|
|
for (Rank record : records) {
|
|
RankListVo rankListVo = new RankListVo();
|
|
PropertyUtils.copyProperties(record,rankListVo);
|
|
rankListVoList.add(rankListVo);
|
|
}
|
|
}
|
|
return new PageInfo<>(rankIPage.getPages(), rankListVoList, rankIPage.getTotal());
|
|
}
|
|
}
|