|
@@ -47,6 +47,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
@@ -60,13 +61,12 @@ import java.util.stream.Collectors;
|
|
|
@RequestMapping("${app-config.url.tenant:}/student")
|
|
|
@Api(value = "学生表", tags = "学生表")
|
|
|
public class StudentController extends BaseController {
|
|
|
+
|
|
|
@Autowired
|
|
|
private StudentService studentService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private TeacherService teacherService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private SysUserFeignService sysUserFeignService;
|
|
|
@Autowired
|
|
|
private ImUserFriendService imUserFriendService;
|
|
@@ -104,17 +104,18 @@ public class StudentController extends BaseController {
|
|
|
});
|
|
|
|
|
|
|
|
|
- Map<Long, List<TenantActivationCode>> groupByUserId = new HashMap<>();
|
|
|
+ Map<String, List<TenantActivationCode>> groupByPhone = new HashMap<>();
|
|
|
if (!rows.isEmpty() && query.getTenantAlbumPurchaseId() != null) {
|
|
|
- List<String> studentPhones = rows.stream().map(StudentVo::getPhone).collect(Collectors.toList());
|
|
|
- groupByUserId = tenantActivationCodeService.lambdaQuery()
|
|
|
+ List<String> studentPhones =
|
|
|
+ rows.stream().map(StudentVo::getPhone).filter(StringUtils::isNotEmpty).collect(Collectors.toList());
|
|
|
+ groupByPhone = tenantActivationCodeService.lambdaQuery()
|
|
|
.eq(TenantActivationCode::getId, query.getTenantAlbumPurchaseId())
|
|
|
.in(TenantActivationCode::getActivationPhone, studentPhones)
|
|
|
- .list().stream().collect(Collectors.groupingBy(TenantActivationCode::getActivationUserId));
|
|
|
+ .list().stream().collect(Collectors.groupingBy(TenantActivationCode::getActivationPhone));
|
|
|
}
|
|
|
|
|
|
for (StudentVo vo : rows) {
|
|
|
- vo.setSendActiveCodeNum(groupByUserId.getOrDefault(vo.getUserId(), new ArrayList<>()).size());
|
|
|
+ vo.setSendActiveCodeNum(groupByPhone.getOrDefault(vo.getPhone(), new ArrayList<>()).size());
|
|
|
if (StringUtils.isNotEmpty(vo.getPhone())) {
|
|
|
vo.setPhone(vo.getPhone().replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2"));
|
|
|
}
|
|
@@ -165,11 +166,12 @@ public class StudentController extends BaseController {
|
|
|
studentService.save(studentInfo);
|
|
|
|
|
|
// 加好友
|
|
|
- if (studentInfo.getId() == null) {
|
|
|
- SysUser sysUser = sysUserFeignService.queryUserByMobile(student.getPhone());
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserByMobile(student.getPhone());
|
|
|
+ Student newStudent = studentService.getById(sysUser.getId());
|
|
|
+ if (newStudent.getTenantId()!= null && newStudent.getTenantId()!=-1L) {
|
|
|
// 自动与机构老师成为好友
|
|
|
List<Teacher> teacherList = teacherService.lambdaQuery()
|
|
|
- .eq(Teacher::getTenantId, studentInfo.getTenantId()).list();
|
|
|
+ .eq(Teacher::getTenantId, newStudent.getTenantId()).list();
|
|
|
teacherList.forEach(next -> imUserFriendService.saveUserFriend(next.getUserId(),
|
|
|
new HashSet<>(ImmutableList.of(sysUser.getId()))));
|
|
|
}
|