查询返回类型优化

This commit is contained in:
myh 2023-10-26 11:33:56 +08:00
parent 251f379035
commit 298a2eaf87
6 changed files with 10 additions and 13 deletions

View File

@ -16,7 +16,7 @@ public class MerchantsController {
@PostMapping("/add")
public Merchants saveMerchants(@RequestBody Merchants merchants) {
return merchantsService.insetMerchants(merchants);
return merchantsService.addMerchants(merchants);
}
@DeleteMapping("/delete/{id}")
@ -30,7 +30,7 @@ public class MerchantsController {
}
@GetMapping("/find")
public List<Merchants> getMerchants() {
public Iterable<Merchants> getMerchants() {
return merchantsService.findAllMerchants();
}

View File

@ -16,7 +16,7 @@ public class UsersController {
@PostMapping("/add")
public Users saveUsers(@RequestBody Users users) {
return usersService.insetUsers(users);
return usersService.addUsers(users);
}
@DeleteMapping("/delete/{id}")

View File

@ -2,17 +2,16 @@ package com.example.springdemo.service;
import com.example.springdemo.entities.Merchants;
import java.util.List;
import java.util.Optional;
public interface MerchantsService {
Merchants insetMerchants(Merchants merchant);
Merchants addMerchants(Merchants merchant);
void deleteMerchantsById(Long id);
Merchants updateMerchants(Merchants merchant);
List<Merchants> findAllMerchants();
Iterable<Merchants> findAllMerchants();
Optional<Merchants> findById(Long id);

View File

@ -14,7 +14,7 @@ public class MerchantsServiceImpl implements MerchantsService {
private MerchantsRepository merchantsRepository;
@Override
public Merchants insetMerchants(Merchants merchant) {
public Merchants addMerchants(Merchants merchant) {
return merchantsRepository.save(merchant);
}

View File

@ -2,18 +2,17 @@ package com.example.springdemo.service;
import com.example.springdemo.entities.Users;
import java.util.List;
import java.util.Optional;
public interface UsersService {
Users insetUsers(Users user);
Users addUsers(Users user);
void deleteUsersById(Long id);
Users updateUsers(Users user);
List<Users> findAllUsers();
Iterable<Users> findAllUsers();
Optional<Users> findById(Long id);

View File

@ -5,7 +5,6 @@ import com.example.springdemo.entities.Users;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
@Service
@ -14,7 +13,7 @@ public class UsersServiceImpl implements UsersService {
private UsersRepository usersRepository;
@Override
public Users insetUsers(Users user) {
public Users addUsers(Users user) {
return usersRepository.save(user);
}
@ -29,7 +28,7 @@ public class UsersServiceImpl implements UsersService {
}
@Override
public List<Users> findAllUsers() {
public Iterable<Users> findAllUsers() {
return usersRepository.findAll();
}