Quellcode durchsuchen

1.接口同步修改

yuanliang vor 1 Jahr
Ursprung
Commit
07917f0e30

+ 19 - 16
cooleshow-app/src/main/java/com/yonge/cooleshow/tenant/controller/StudentController.java

@@ -33,6 +33,7 @@ import com.yonge.toolset.utils.easyexcel.ExcelException;
 import com.yonge.toolset.utils.easyexcel.ExcelUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
@@ -46,6 +47,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -53,6 +55,7 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.stream.Collectors;
 
+@Slf4j
 @RestController
 @RequestMapping("${app-config.url.tenant:}/student")
 @Api(value = "学生表", tags = "学生表")
@@ -61,19 +64,18 @@ public class StudentController extends BaseController {
     private StudentService studentService;
 
     @Autowired
-    private SysUserFeignService sysUserFeignService;
+    private TeacherService teacherService;
 
     @Autowired
+    private SysUserFeignService sysUserFeignService;
+    @Autowired
+    private ImUserFriendService imUserFriendService;
+    @Autowired
     private TenantInfoService tenantInfoService;
 
     @Autowired
     private TenantActivationCodeService tenantActivationCodeService;
 
-    @Autowired
-    private TeacherService teacherService;
-    @Autowired
-    private ImUserFriendService imUserFriendService;
-
     @GetMapping("/detail/{id}")
     @ApiOperation(value = "详情", notes = "传入id")
     public HttpResponseResult<StudentVo> detail(@PathVariable("id") Long id) {
@@ -100,18 +102,18 @@ public class StudentController extends BaseController {
             }
         });
 
-        
-        Map<String, List<TenantActivationCode>> groupByUserId = new HashMap<>();
+
+        Map<Long, List<TenantActivationCode>> groupByUserId = new HashMap<>();
         if (!rows.isEmpty() && query.getTenantAlbumPurchaseId() != null) {
-            List<String> studentIdList = rows.stream().map(StudentVo::getPhone).collect(Collectors.toList());
-             groupByUserId = tenantActivationCodeService.lambdaQuery()
-                    .eq(TenantActivationCode::getTenantAlbumPurchaseId, query.getTenantAlbumPurchaseId())
-                    .in(TenantActivationCode::getActivationPhone, studentIdList)
-                    .list().stream().collect(Collectors.groupingBy(TenantActivationCode::getActivationPhone));
+            List<String> studentPhones = rows.stream().map(StudentVo::getPhone).collect(Collectors.toList());
+            groupByUserId = tenantActivationCodeService.lambdaQuery()
+                    .eq(TenantActivationCode::getId, query.getTenantAlbumPurchaseId())
+                    .in(TenantActivationCode::getActivationPhone, studentPhones)
+                    .list().stream().collect(Collectors.groupingBy(TenantActivationCode::getActivationUserId));
         }
 
         for (StudentVo vo : rows) {
-            vo.setSendActiveCodeNum(groupByUserId.getOrDefault(Optional.ofNullable(vo.getPhone()).orElse(""), Lists.newArrayList()).size());
+            vo.setSendActiveCodeNum(groupByUserId.getOrDefault(vo.getUserId(), new ArrayList<>()).size());
             if (StringUtils.isNotEmpty(vo.getPhone())) {
                 vo.setPhone(vo.getPhone().replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2"));
             }
@@ -170,6 +172,7 @@ public class StudentController extends BaseController {
             teacherList.forEach(next -> imUserFriendService.saveUserFriend(next.getUserId(),
                     new HashSet<>(ImmutableList.of(sysUser.getId()))));
         }
+
         return succeed();
     }
 
@@ -189,8 +192,8 @@ public class StudentController extends BaseController {
             studentService.importStudentExcel(reader.getDataList(), user.getTenantId(), user.getId());
             return HttpResponseResult.succeed();
         } catch (ExcelException e) {
-            return HttpResponseResult.failed(BizHttpStatus.IMPORT.getCode(), e.getErrMsgList(),
-                    BizHttpStatus.IMPORT.getMsg());
+            log.error("导入学生失败:" + JSON.toJSONString(e.getErrMsgList()));
+            return HttpResponseResult.failed("文件解析失败");
         }
     }
 

+ 2 - 2
cooleshow-app/src/main/java/com/yonge/cooleshow/tenant/controller/TenantActivationCodeController.java

@@ -281,8 +281,8 @@ public class TenantActivationCodeController extends BaseController {
                     tenantAlbumPurchaseId);
             return HttpResponseResult.succeed();
         } catch (ExcelException e) {
-            return HttpResponseResult.failed(BizHttpStatus.IMPORT.getCode(), e.getErrMsgList(),
-                    BizHttpStatus.IMPORT.getMsg());
+            log.error("导入激活码失败:"+JSON.toJSONString(e.getErrMsgList()));
+            return HttpResponseResult.failed("文件解析错误");
         }
     }