|
@@ -8,6 +8,7 @@ import com.microsvc.toolkit.common.response.paging.QueryInfo;
|
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
import com.ym.mec.auth.api.enums.SysUserType;
|
|
|
import com.ym.mec.auth.api.enums.YesOrNoEnum;
|
|
|
+import com.ym.mec.biz.dal.dao.CooperationOrganDao;
|
|
|
import com.ym.mec.biz.dal.dao.TeacherDao;
|
|
|
import com.ym.mec.biz.dal.entity.CooperationOrgan;
|
|
|
import com.ym.mec.biz.dal.entity.SchoolStaff;
|
|
@@ -15,8 +16,10 @@ import com.ym.mec.biz.dal.entity.SysConfig;
|
|
|
import com.ym.mec.biz.dal.enums.school.ESchoolStaffType;
|
|
|
import com.ym.mec.biz.dal.mapper.SchoolStaffMapper;
|
|
|
import com.ym.mec.biz.dal.wrapper.SchoolStaffWrapper;
|
|
|
+import com.ym.mec.biz.dal.wrapper.StatGroupWrapper;
|
|
|
import com.ym.mec.biz.service.CooperationOrganService;
|
|
|
import com.ym.mec.biz.service.SchoolStaffService;
|
|
|
+import com.ym.mec.biz.service.SmsCodeService;
|
|
|
import com.ym.mec.biz.service.SysConfigService;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -26,6 +29,7 @@ import org.joda.time.DateTime;
|
|
|
import org.redisson.api.RBucket;
|
|
|
import org.redisson.api.RedissonClient;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -56,6 +60,14 @@ public class SchoolStaffServiceImpl extends ServiceImpl<SchoolStaffMapper, Schoo
|
|
|
private TeacherDao teacherDao;
|
|
|
@Autowired
|
|
|
private SysConfigService sysConfigService;
|
|
|
+ @Autowired
|
|
|
+ private CooperationOrganDao cooperationOrganDao;
|
|
|
+ @Autowired
|
|
|
+ private SmsCodeService smsCodeService;
|
|
|
+
|
|
|
+
|
|
|
+ @Value("${message.debugMode:false}")
|
|
|
+ private boolean debugMode;
|
|
|
|
|
|
/**
|
|
|
* 查询详情
|
|
@@ -96,6 +108,13 @@ public class SchoolStaffServiceImpl extends ServiceImpl<SchoolStaffMapper, Schoo
|
|
|
throw new BizException("请勿重复提交");
|
|
|
}
|
|
|
|
|
|
+ // 验证码合法性校验
|
|
|
+ if(smsCodeService.verifyValidCode(schoolStaff.getMobile(), schoolStaff.getSmsCode())
|
|
|
+ && !debugMode) {
|
|
|
+
|
|
|
+ throw new BizException("验证码错误");
|
|
|
+ }
|
|
|
+
|
|
|
// 合作单位编号
|
|
|
CooperationOrgan cooperation = cooperationOrganService.get(schoolStaff.getSchoolId().intValue());
|
|
|
if (Objects.isNull(cooperation)) {
|
|
@@ -181,7 +200,7 @@ public class SchoolStaffServiceImpl extends ServiceImpl<SchoolStaffMapper, Schoo
|
|
|
if (Objects.nonNull(user)) {
|
|
|
// 学校员工帐号平台惟一,不能与其他帐号共存
|
|
|
if (StringUtils.isNotBlank(user.getUserType())) {
|
|
|
- throw new BizException("帐号已存在");
|
|
|
+ throw new BizException(999, "帐号已存在");
|
|
|
}
|
|
|
|
|
|
// 后续流程暂时忽略,用户允许存在多个身份时才走以下创建账号流程
|
|
@@ -327,4 +346,39 @@ public class SchoolStaffServiceImpl extends ServiceImpl<SchoolStaffMapper, Schoo
|
|
|
return sorted;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据用户ID获取学校所有员工身份
|
|
|
+ *
|
|
|
+ * @param schoolId 学校ID
|
|
|
+ * @return SchoolStaffWrapper.SchoolStaffStat
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public SchoolStaffWrapper.SchoolStaffStat getUserTypeStatByCooperationId(Integer schoolId) {
|
|
|
+
|
|
|
+ Map<String, Integer> collect = baseMapper.selectUserTypeNumsStat(schoolId).stream()
|
|
|
+ .collect(Collectors.toMap(StatGroupWrapper::getGid, StatGroupWrapper::getTotal, (o, n) -> n));
|
|
|
+
|
|
|
+ // 统计学校员工身份
|
|
|
+ return SchoolStaffWrapper.SchoolStaffStat.builder()
|
|
|
+ .schoolmasterNums(collect.getOrDefault(ESchoolStaffType.SCHOOLMASTER.getCode(), 0))
|
|
|
+ .schoolLeaderNums(collect.getOrDefault(ESchoolStaffType.SCHOOL_LEADER.getCode(), 0))
|
|
|
+ .orchestraNums(collect.getOrDefault(ESchoolStaffType.ORCHESTRA_LEADER.getCode(), 0))
|
|
|
+ .teacherNums(collect.getOrDefault(ESchoolStaffType.TEACHER.getCode(), 0))
|
|
|
+ .orchestraNums(0)
|
|
|
+ .studentNums(0)
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+
|
|
|
+ /***
|
|
|
+ * 更新合作单位信息
|
|
|
+ * @param info SchoolStaffWrapper.Cooperation
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void updateCooperation(SchoolStaffWrapper.Cooperation info) {
|
|
|
+
|
|
|
+ // 合作单位信息
|
|
|
+ cooperationOrganDao.update(JSON.parseObject(info.jsonString(), CooperationOrgan.class));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|