1、修改申请培训改为通过手机号查询userId
parent
c7d4fafd1e
commit
e0b278cc25
|
|
@ -1,6 +1,7 @@
|
|||
package com.zcloud.edu.gatewayimpl.training;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||
import com.zcloud.edu.domain.gateway.training.TrainingApplyUserGateway;
|
||||
import com.zcloud.edu.domain.model.training.TrainingApplyUserE;
|
||||
import com.zcloud.edu.persistence.dataobject.TrainingApplyUserDO;
|
||||
|
|
@ -14,6 +15,7 @@ import org.springframework.stereotype.Service;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -37,11 +39,21 @@ public class TrainingApplyUserGatewayImpl implements TrainingApplyUserGateway {
|
|||
|
||||
@Override
|
||||
public Boolean addBatch(List<TrainingApplyUserE> trainingApplyUserEList) {
|
||||
// 使用 Stream 流进行转换
|
||||
if (CollectionUtils.isEmpty(trainingApplyUserEList)) return true;
|
||||
List<String> phones = trainingApplyUserEList.stream().map(TrainingApplyUserE::getPhone).collect(Collectors.toList());
|
||||
List<TrainingApplyUserDO> userDOS = trainingApplyUserRepository.getIdByPhones(phones);
|
||||
Map<String, Long> userMap = userDOS.stream()
|
||||
.collect(Collectors.toMap(
|
||||
TrainingApplyUserDO::getPhone,
|
||||
TrainingApplyUserDO::getUserId,
|
||||
(v1, v2) -> v1
|
||||
));
|
||||
List<TrainingApplyUserDO> doList = trainingApplyUserEList.stream()
|
||||
.map(e -> {
|
||||
Long userId = userMap.get(e.getPhone());
|
||||
TrainingApplyUserDO d = new TrainingApplyUserDO(Tools.get32UUID());
|
||||
BeanUtils.copyProperties(e, d, "trainingApplyUserId");
|
||||
d.setUserId(userId);
|
||||
return d;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
|
|
|||
|
|
@ -21,5 +21,10 @@ public interface TrainingApplyUserMapper extends BaseMapper<TrainingApplyUserDO>
|
|||
*/
|
||||
List<TrainingApplyUserDO> selectByRecordId(@Param("trainingApplyRecordId") String trainingApplyRecordId);
|
||||
|
||||
/**
|
||||
* 根据手机号集合查询用户信息
|
||||
*/
|
||||
List<TrainingApplyUserDO> selectByPhoneList(@Param("phones") List<String> phone, @Param("corpinfoId") Long corpinfoId);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.zcloud.edu.persistence.repository.impl;
|
||||
|
||||
import com.jjb.saas.framework.auth.model.SSOUser;
|
||||
import com.jjb.saas.framework.auth.utils.AuthContext;
|
||||
import com.jjb.saas.framework.repository.common.PageHelper;
|
||||
import com.zcloud.edu.persistence.dataobject.TrainingApplyUserDO;
|
||||
import com.zcloud.edu.persistence.mapper.TrainingApplyUserMapper;
|
||||
|
|
@ -41,5 +43,10 @@ public class TrainingApplyUserRepositoryImpl extends BaseRepositoryImpl<Training
|
|||
public List<TrainingApplyUserDO> getByRecordId(String trainingApplyRecordId) {
|
||||
return trainingApplyUserMapper.selectByRecordId(trainingApplyRecordId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TrainingApplyUserDO> getIdByPhones(List<String> phones) {
|
||||
return trainingApplyUserMapper.selectByPhoneList(phones, AuthContext.getTenantId());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,5 +20,10 @@ public interface TrainingApplyUserRepository extends BaseRepository<TrainingAppl
|
|||
* 根据申请记录ID查询申请人员(含姓名、身份证等)
|
||||
*/
|
||||
List<TrainingApplyUserDO> getByRecordId(String trainingApplyRecordId);
|
||||
|
||||
/**
|
||||
* 根据批量手机号查询用户ID
|
||||
*/
|
||||
List<TrainingApplyUserDO> getIdByPhones(List<String> phones);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,27 @@
|
|||
tau.create_time ASC
|
||||
</select>
|
||||
|
||||
<select id="selectByPhoneList" resultType="com.zcloud.edu.persistence.dataobject.TrainingApplyUserDO">
|
||||
SELECT
|
||||
u.id as userId,
|
||||
u.phone
|
||||
FROM
|
||||
`user` u
|
||||
WHERE
|
||||
u.corpinfo_id = #{corpinfoId}
|
||||
<if test="phones != null and phones.size() > 0">
|
||||
AND u.phone IN
|
||||
<foreach collection="phones" item="phone" open="(" separator="," close=")">
|
||||
#{phone}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
<if test="phones == null or phones.size() == 0">
|
||||
AND 1 = 0
|
||||
</if>
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue