Commit c4676ff4 authored by renjie's avatar renjie

用户消费

parent 6870651d
...@@ -112,8 +112,8 @@ public class AdministratorController { ...@@ -112,8 +112,8 @@ public class AdministratorController {
//根据用户名查询用户账单tested //根据用户名查询用户账单tested
@PreAuthorize("hasRole('ADMIN')") @PreAuthorize("hasRole('ADMIN')")
@RequestMapping(path ="/0xadministrator/searchuserbill/{name}",method = RequestMethod.GET) @RequestMapping(path ="/0xadministrator/searchuserbill/{name}",method = RequestMethod.GET)
public BillQueryResultDto getUserBillByName(@PathVariable String name){ public BillQueryResultDto getUserBillByName(@PathVariable String name, @RequestParam("page") int page, @RequestParam("size") int size){
return administratorService.getUserBillingByName(name); return administratorService.getUserBillingByName(name, page, size);
} }
......
package com.edgec.browserbackend.account.dto; package com.edgec.browserbackend.account.dto;
import com.edgec.browserbackend.account.domain.UserPrePaidBilling; import com.edgec.browserbackend.account.domain.UserPrePaidBilling;
import org.springframework.data.domain.Page;
import java.util.List; import java.util.List;
public class BillQueryResultDto { public class BillQueryResultDto {
List<UserPrePaidBilling> userPrePaidBillingList; Page<UserPrePaidBilling> userPrePaidBillingList;
double totalExpense; double totalExpense;
double totalEarn; double totalEarn;
...@@ -25,11 +26,11 @@ public class BillQueryResultDto { ...@@ -25,11 +26,11 @@ public class BillQueryResultDto {
this.totalExpense = totalExpense; this.totalExpense = totalExpense;
} }
public List<UserPrePaidBilling> getUserPrePaidBillingList() { public Page<UserPrePaidBilling> getUserPrePaidBillingList() {
return userPrePaidBillingList; return userPrePaidBillingList;
} }
public void setUserPrePaidBillingList(List<UserPrePaidBilling> userPrePaidBillingList) { public void setUserPrePaidBillingList(Page<UserPrePaidBilling> userPrePaidBillingList) {
this.userPrePaidBillingList = userPrePaidBillingList; this.userPrePaidBillingList = userPrePaidBillingList;
} }
} }
...@@ -18,6 +18,8 @@ public interface UserPrePaidBillingRepository extends MongoRepository<UserPrePai ...@@ -18,6 +18,8 @@ public interface UserPrePaidBillingRepository extends MongoRepository<UserPrePai
List<UserPrePaidBilling> findByUsername(String username); List<UserPrePaidBilling> findByUsername(String username);
Page<UserPrePaidBilling> findAllByUsername(String username, Pageable pageable);
Page<UserPrePaidBilling> findAllByYearBetweenAndMonthBetween(Pageable pageable, int year1, int year2, int month1, int month2); Page<UserPrePaidBilling> findAllByYearBetweenAndMonthBetween(Pageable pageable, int year1, int year2, int month1, int month2);
List<UserPrePaidBilling> findByUsernameAndYearAndMonthAndPayMethodIsNot(String username, int year, int month, int payMethod); List<UserPrePaidBilling> findByUsernameAndYearAndMonthAndPayMethodIsNot(String username, int year, int month, int payMethod);
......
...@@ -23,7 +23,7 @@ public interface AdministratorService { ...@@ -23,7 +23,7 @@ public interface AdministratorService {
Account getAccountByEmail(String target); Account getAccountByEmail(String target);
BillQueryResultDto getUserBillingByName(String name); BillQueryResultDto getUserBillingByName(String name, int page, int size);
Account unLockLockedAccount(String name, Account account); Account unLockLockedAccount(String name, Account account);
......
...@@ -105,8 +105,11 @@ public class AdministratorServiceImpl implements AdministratorService { ...@@ -105,8 +105,11 @@ public class AdministratorServiceImpl implements AdministratorService {
@Override @Override
public BillQueryResultDto getUserBillingByName(String name) { public BillQueryResultDto getUserBillingByName(String name, int page, int size) {
List<UserPrePaidBilling> userBillingList = userPrePaidBillingRepository.findByUsername(name); if (size > 100)
size = 100;
Pageable pageable = PageRequest.of(page, size);
Page<UserPrePaidBilling> userBillingList = userPrePaidBillingRepository.findAllByUsername(name, pageable);
if (userBillingList == null) if (userBillingList == null)
throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST, "Username does not exist: " + name); throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST, "Username does not exist: " + name);
List<UserPrePaidBilling> userPrePaidBillings = userPrePaidBillingRepository.findByUsernameAndPayMethodIsNot(name, 0); List<UserPrePaidBilling> userPrePaidBillings = userPrePaidBillingRepository.findByUsernameAndPayMethodIsNot(name, 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment