package com.fu.service.impl; import com.fu.config.qiniu.QiNiuUrlConfig; import com.fu.dao.FuNewInfoMapper; import com.fu.entity.FuNewInfo; import com.fu.model.FuNewInfoModel; import com.fu.service.NewsService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.text.SimpleDateFormat; import java.util.*; /** * @author fish * @Package com.zjs.service.impl * @Description: ${todo} * @date 2020/12/1514:41 */ @Service @Slf4j public class NewsServiceImpl implements NewsService { @Autowired private FuNewInfoMapper fuNewInfoMapper; @Override public List indexNewList(Integer num) { List list = fuNewInfoMapper.indexNewList(num); if(list!=null && list.size()>0){ for(FuNewInfoModel model : list){ Calendar calendar = Calendar.getInstance(); calendar.setTime(model.getCreateTime()); model.setMonth((calendar.get(Calendar.MONTH)+1)+"?); model.setDay(calendar.get(Calendar.DATE)+""); model.setPicUrl(QiNiuUrlConfig.PICURL + "/" + model.getKeyValue()); } } return list; } @Override public Map getNewsList(Integer page,String key) { int start = 0; int row = 9; int upPage = 0; int nextPage = 0; if(page==null) { page = 1; } start = (page-1)*row; int newTotal = getNewsTotal(key); List list = new ArrayList<>(); if(newTotal>0){ list = fuNewInfoMapper.getNewsList(start, row,key); if(list!=null && list.size()>0){ for(FuNewInfoModel model : list){ Calendar calendar = Calendar.getInstance(); calendar.setTime(model.getCreateTime()); model.setYear(calendar.get(Calendar.YEAR)+"q?); model.setMonth((calendar.get(Calendar.MONTH)+1)+"?); model.setDay(calendar.get(Calendar.DATE)+""); model.setPicUrl(QiNiuUrlConfig.PICURL + "/" + model.getKeyValue()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyqMM月dd?); model.setShowTime(simpleDateFormat.format(model.getCreateTime())); } } } Map map = new HashMap(); if(start==0){ upPage = 0; }else{ upPage = page -1; } if(newTotal-page*9<0){ nextPage = 0; }else{ nextPage = page +1; } map.put("upPage",upPage); map.put("nextPage",nextPage); map.put("newList",list); map.put("newTotal",newTotal); return map; } @Override public Map getUpNextId(Integer id) { FuNewInfo upInfo = new FuNewInfo(); FuNewInfo nextInfo = new FuNewInfo(); FuNewInfo nowinfo = fuNewInfoMapper.selectByPrimaryKey(id-1); if(nowinfo!=null){ upInfo.setId(nowinfo.getId()); upInfo.setTitle(nowinfo.getTitle()); } FuNewInfo nowinfo1 = fuNewInfoMapper.selectByPrimaryKey(id+1); if(nowinfo1!=null){ nextInfo.setId(nowinfo1.getId()); nextInfo.setTitle(nowinfo1.getTitle()); } Map map = new HashMap(); map.put("upInfo",upInfo); map.put("nextInfo",nextInfo); return map; } @Override public FuNewInfo getNewsInfo(Integer id) { FuNewInfo info = fuNewInfoMapper.selectByPrimaryKey(id); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); info.setShowTime(simpleDateFormat.format(info.getCreateTime())); try { info.setContentStr(new String(info.getContent(), "utf-8")); } catch (Exception e) { } //更新点击ơ数 FuNewInfo info1 = new FuNewInfo(); info1.setId(info.getId()); info1.setCheckNum(info.getCheckNum() + 1); fuNewInfoMapper.updateByPrimaryKeySelective(info1); return info; } public int getNewsTotal(String key) { return fuNewInfoMapper.getNewsTotal(key); } } 香蕉人人超人人超碰超国产_中文字幕人妻伦伦在线播放_丰满少妇av无码区_a特级猛片 你敢看吗