Код: Выделить всё
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dtTkcDailyController': Unsatisfied dependency expressed through field 'dtTkcService': Error creating bean with name 'dtTkcService': Unsatisfied dependency expressed through field 'dtTkcDailyBranchRepo': Error creating bean with name 'dtTkcDailyBranchRepo' defined in com.oracleConnect.authapi.repositories.dtTkcDailyBranchRepo defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Could not create query for public abstract java.util.List com.oracleConnect.authapi.repositories.dtTkcDailyBranchRepo.findBranchSumDate(java.time.LocalDate); Reason: Failed to create query for method public abstract java.util.List com.oracleConnect.authapi.repositories.dtTkcDailyBranchRepo.findBranchSumDate(java.time.LocalDate); No property 'findBranchSumDate' found for type 'dtTkcDailyByBranch'
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:788) ~[spring-beans-6.1.13.jar:6.1.13]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:768) ~[spring-beans-6.1.13.jar:6.1.13]
Код: Выделить всё
package com.oracleConnect.authapi.services;
import com.oracleConnect.authapi.entities.dtTkcDailyByBranch;
import com.oracleConnect.authapi.entities.dtTkcDailybyDistrict;
import com.oracleConnect.authapi.repositories.DtTkcDailyBranchCustom;
import com.oracleConnect.authapi.repositories.dtTkcDailyBranchRepo;
import com.oracleConnect.authapi.repositories.dtTkcDailyRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.List;
@Service
public class dtTkcService {
@Autowired
private dtTkcDailyRepository dtTkcDailyRepository;
@Autowired
private dtTkcDailyBranchRepo dtTkcDailyBranchRepo;
public List\ getDtTkcBySumDate(LocalDate sumDate){
return dtTkcDailyRepository.findBySumDate(sumDate);
}
public List\ getBranchBySumDate(LocalDate sumDate){
return dtTkcDailyBranchRepo.findBranchSumDate(sumDate);
}
public List findDtTkcDailyBranchData(String sumDate, String networkId, String branchName, String linhVuc, String[] cap2Sum, int center) {
return dtTkcDailyBranchRepo.findDtTkcDailyBranchDataByParams(sumDate, networkId, branchName, linhVuc, cap2Sum, center);
}
}
Код: Выделить всё
package com.oracleConnect.authapi.controllers;import com.oracleConnect.authapi.entities.dtTkcDailyByBranch;import com.oracleConnect.authapi.entities.dtTkcDailybyDistrict;import com.oracleConnect.authapi.services.dtTkcService;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.http.HttpStatus;import org.springframework.http.ResponseEntity;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestParam;import org.springframework.web.bind.annotation.RestController;import java.time.LocalDate;import java.time.format.DateTimeFormatter;import java.time.format.DateTimeParseException;import java.util.List;
@RestController@RequestMapping(path = "/record")public class dtTkcDailyController {
@Autowired
private dtTkcService dtTkcService;
@GetMapping("/dt-tkc/date-by-branch")
public ResponseEntity
findDtTkcDailyBranchData(@RequestParam String date,
@RequestParam(required = false) String networkId,
@RequestParam(required = false) String branchName,
@RequestParam(required = false) String linhVuc,
@RequestParam(required = false) String[] cap2Sum,
@RequestParam(required = false) int center) {
//List dateRecords = dtTkcService.getDtTkcBySumDate(sumDate);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");
try {
// Kiểm tra xem date có đúng định dạng hay không
LocalDate sumDate = LocalDate.parse(date, formatter);
// Gọi service để lấy dữ liệu
List dateRecords = dtTkcService.getBranchBySumDate(sumDate);
return new ResponseEntity(dateRecords, HttpStatus.OK);
} catch (DateTimeParseException e) {
// Trả về lỗi nếu ngày không đúng định dạng
String errorMessage = "Ngày nhập không đúng định dạng dd/MM/yyyy. Vui lòng thử lại.";
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(errorMessage);
}
}}
Код: Выделить всё
package com.oracleConnect.authapi.repositories;
import java.util.List
public interface DtTkcDailyBranchCustom {
List findDtTkcDailyBranchDataByParams(String sumDate, String networkId, String branchName, String linhVuc, String[] cap2Sum, int center);
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... ressed-thr