33 lines
1.0 KiB
Java
33 lines
1.0 KiB
Java
package com.example.prapro2spring.service;
|
|
|
|
import com.example.prapro2spring.dto.AllPeopleValues;
|
|
import com.example.prapro2spring.dto.PersonValue;
|
|
import com.example.prapro2spring.repository.PersonValueRepository;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
@Service
|
|
public class PersonValueService {
|
|
@Autowired
|
|
PersonValueRepository personValueRepository;
|
|
|
|
public AllPeopleValues getAllPersonValues(Integer lastIndex) {
|
|
List<Object[]> results = personValueRepository.queryAllPersonValues(lastIndex);
|
|
List<PersonValue> personValues = new ArrayList<>();
|
|
|
|
for (Object[] result : results) {
|
|
PersonValue personValue = new PersonValue((Integer) result[0], (Integer) result[1]);
|
|
personValues.add(personValue);
|
|
}
|
|
|
|
return new AllPeopleValues(personValues, personValues.size());
|
|
}
|
|
|
|
public Integer getPersonValuesById(Integer id) {
|
|
return personValueRepository.queryPersonValuesById(id);
|
|
}
|
|
}
|