use of com.cas.sim.tis.mapper.ElecCompMapper in project TeachingInSimulation by ScOrPiOzzy.
the class ElecCompServiceImpl method findElecCompGroupByType.
@Override
public Map<Integer, List<ElecComp>> findElecCompGroupByType() {
ElecCompMapper dao = (ElecCompMapper) mapper;
List<ElecComp> all = dao.selectAll();
if (all == null) {
return new HashMap<>();
}
return all.stream().collect(Collectors.groupingBy(ElecComp::getType));
}
use of com.cas.sim.tis.mapper.ElecCompMapper in project TeachingInSimulation by ScOrPiOzzy.
the class ElecCompServiceImpl method findElecCompByModel.
@Override
public ElecComp findElecCompByModel(String model) {
ElecCompMapper dao = (ElecCompMapper) mapper;
Condition condition = new Condition(ElecComp.class);
Criteria criteria = condition.createCriteria();
criteria.andEqualTo("model", model);
List<ElecComp> compList = dao.selectByCondition(condition);
if (compList.size() == 0) {
return null;
} else if (compList.size() > 1) {
throw new TooManyResultsException();
}
return compList.get(0);
}
Aggregations