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.
63 lines
2.4 KiB
63 lines
2.4 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.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
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.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);
|
|
cal.set(Calendar.MILLISECOND,0);
|
|
Date time = cal.getTime();
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
|
|
try {
|
|
time = simpleDateFormat.parse(simpleDateFormat.format(time));
|
|
} catch (ParseException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
QueryWrapper<Rank> queryWrapper = new QueryWrapper<>();
|
|
queryWrapper.eq("type",rankListDTO.getType());
|
|
queryWrapper.eq("dateStart",time);
|
|
Page<Rank> page = new Page<>(rankListDTO.getPageNum(), rankListDTO.getPageSize());
|
|
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());
|
|
}
|
|
}
|