wangqifan пре 3 година
родитељ
комит
9cdd7ef30a

+ 26 - 7
src/main/java/com/izouma/nineth/service/UserService.java

@@ -126,7 +126,8 @@ public class UserService {
                 if (roleName.equals("ROLE_MINTER")) {
                     and.add(criteriaBuilder.equal(root.get("minter"), true));
                 } else {
-                    and.add(criteriaBuilder.isMember(Authority.get(AuthorityName.valueOf(roleName)), root.get("authorities")));
+                    and.add(criteriaBuilder
+                            .isMember(Authority.get(AuthorityName.valueOf(roleName)), root.get("authorities")));
                 }
             }
 
@@ -463,6 +464,20 @@ public class UserService {
         return new PageImpl<>(userDTOS, users.getPageable(), users.getTotalElements());
     }
 
+    public Page<Minter> toMinterDTO(Page<User> users) {
+        List<User> origins = users.getContent();
+        List<Minter> minters = new ArrayList<>();
+        origins.forEach(user -> {
+            Minter minter = Minter.builder()
+                    .id(user.getId())
+                    .name(user.getNickname())
+                    .avatar(user.getAvatar())
+                    .build();
+            minters.add(minter);
+        });
+        return new PageImpl<>(minters, users.getPageable(), users.getTotalElements());
+    }
+
     @CacheEvict(value = "user", allEntries = true)
     public void setTradeCode(Long userId, String token, String tradeCode) {
         String phone = smsService.verifyToken(token);
@@ -490,7 +505,7 @@ public class UserService {
             throw new BusinessException("用户不存在或未认证");
         }
         String realName = identityAuthRepo.findFirstByUserIdAndStatusAndDelFalseOrderByCreatedAtDesc(
-                        user.getId(), AuthStatus.SUCCESS)
+                user.getId(), AuthStatus.SUCCESS)
                 .map(IdentityAuth::getRealName).orElse("").replaceAll(".*(?=.)", "**");
         Map<String, Object> map = new HashMap<>();
         map.put("id", user.getId());
@@ -503,8 +518,8 @@ public class UserService {
 
     public Map<String, Object> searchByPhoneAdmin(String phoneStr) {
         List<String> phone = Arrays.stream(phoneStr.replaceAll("\n", " ")
-                        .replaceAll("\r\n", " ")
-                        .split(" "))
+                .replaceAll("\r\n", " ")
+                .split(" "))
                 .map(String::trim)
                 .filter(s -> !StringUtils.isEmpty(s))
                 .collect(Collectors.toList());
@@ -519,7 +534,8 @@ public class UserService {
 
     public void addBankCard(Long userId, String bankNo, String phone, String code) throws BaseAdaPayException {
         User user = userRepo.findById(userId).orElseThrow(new BusinessException("用户不存在"));
-        IdentityAuth identityAuth = identityAuthRepo.findFirstByUserIdAndStatusAndDelFalseOrderByCreatedAtDesc(userId, AuthStatus.SUCCESS)
+        IdentityAuth identityAuth = identityAuthRepo
+                .findFirstByUserIdAndStatusAndDelFalseOrderByCreatedAtDesc(userId, AuthStatus.SUCCESS)
                 .orElseThrow(new BusinessException("用户未认证"));
         if (identityAuth.isOrg()) {
             //throw new BusinessException("企业认证用户请绑定对公账户");
@@ -533,7 +549,9 @@ public class UserService {
         }
         smsService.verify(phone, code);
 
-        adapayMerchantService.createMemberForAll(userId.toString(), user.getPhone(), identityAuth.getRealName(), identityAuth.getIdNo());
+        adapayMerchantService
+                .createMemberForAll(userId.toString(), user.getPhone(), identityAuth.getRealName(), identityAuth
+                        .getIdNo());
         user.setMemberId(user.getId().toString());
         save(user);
 
@@ -653,7 +671,8 @@ public class UserService {
         list.forEach(user -> {
             try {
                 Thread.sleep(500);
-                IdentityAuth identityAuth = identityAuthRepo.findFirstByUserIdAndStatusAndDelFalseOrderByCreatedAtDesc(user.getId(), AuthStatus.SUCCESS)
+                IdentityAuth identityAuth = identityAuthRepo
+                        .findFirstByUserIdAndStatusAndDelFalseOrderByCreatedAtDesc(user.getId(), AuthStatus.SUCCESS)
                         .orElseThrow(new BusinessException("用户未认证"));
                 UserBankCard userBankCard = userBankCardRepo.findByUserId(user.getId()).stream().findAny()
                         .orElseThrow(new BusinessException("未绑卡"));

+ 5 - 0
src/main/java/com/izouma/nineth/web/CompanyCollectionController.java

@@ -75,5 +75,10 @@ public class CompanyCollectionController extends BaseController {
     public void deny(@RequestParam Long id, String reason) {
         companyCollectionService.audit(id, CollectionStatus.FAIL, reason);
     }
+
+//    @PostMapping("/createDistrict")
+//    public void deny(@RequestParam Long id, String reason) {
+//        companyCollectionService.audit(id, CollectionStatus.FAIL, reason);
+//    }
 }
 

+ 6 - 0
src/main/java/com/izouma/nineth/web/UserController.java

@@ -87,6 +87,12 @@ public class UserController extends BaseController {
         return userService.toDTO(userService.all(pageQuery).toPage());
     }
 
+    @PostMapping("/minterList")
+    public Page<Minter> getMinter(@RequestBody PageQuery pageQuery) {
+        pageQuery.getQuery().put("minter", true);
+        return userService.toMinterDTO(userService.all(pageQuery).toPage());
+    }
+
     //    @PreAuthorize("hasRole('ADMIN')")
     @GetMapping("/get/{id}")
     public UserDTO get(@PathVariable Long id) {