7.3.2 服务层
接口
package com.atguigu.gmall0225publisher2.service;
import java.util.Map;
public interface PublisherService {
long getDauTotal(String date);
Map getDauHour(String date);
}
实现
package com.atguigu.gmall0225publisher2.service;
import com.atguigu.gmall0225publisher2.mapper.DauMapper;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
@Service
public class PublisherServiceImpl implements PublisherService {
@Autowired
DauMapper dauMapper;
@Override
public long getDauTotal(String date) {
return dauMapper.getDauTotal(date);
}
@Override
public Map getDauHour(String date) {
List<Map> dauHourList = dauMapper.getDauHour(date);
Map dauHourMap = new HashedMap();
for (Map map : dauHourList) {
String hour = (String)map.get("LOGHOUR");
Long count = (Long) map.get("COUNT");
dauHourMap.put(hour, count);
}
return dauHourMap;
}
}