| | |
| | | package com.project.system.service.impl; |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.project.common.annotation.DataScope; |
| | |
| | | return userMapper.resetPhone(userId, phone); |
| | | } |
| | | |
| | | /** |
| | | * 处理导入数据 |
| | | * @param list 数据 |
| | | * @param deptId 导入部门id |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public SysUserResultVo doImport(List<SysUserVo> list, Long deptId) |
| | | { |
| | |
| | | return this.checkImport(resultVo); |
| | | } |
| | | |
| | | /** |
| | | * 校验导入数据 |
| | | * @param resultVo 数据 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public SysUserResultVo checkImport(SysUserResultVo resultVo) |
| | | { |
| | |
| | | return resultVo; |
| | | } |
| | | |
| | | /** |
| | | * 验证参数 |
| | | * @param entity 数据 |
| | | * @param errorList 错误数据 |
| | | */ |
| | | private void validEntityBeforeImport(SysUserVo entity, List<ImportError> errorList) |
| | | { |
| | | if (StringUtils.isEmpty(entity.getNickName())){ |
| | |
| | | } |
| | | } |
| | | } |
| | | if (StringUtils.isNotEmpty(entity.getEmail())){ |
| | | SysUser check = new SysUser(); |
| | | check.setPhonenumber(entity.getPhonenumber()); |
| | | String s = checkEmailUnique(check); |
| | | if (UserConstants.NOT_UNIQUE.equals(s)) { |
| | | errorList.add(new ImportError(3, "邮箱已存在!")); |
| | | } |
| | | } |
| | | if (StringUtils.isNotEmpty(entity.getImportSex())){ |
| | | switch (entity.getImportSex().trim()){ |
| | | case "男": |
| | | entity.setSex("0"); |
| | | break; |
| | | case "女": |
| | | entity.setSex("1"); |
| | | break; |
| | | case "未知": |
| | | entity.setSex("2"); |
| | | break; |
| | | } |
| | | } else { |
| | | entity.setSex("2"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存导入结果 |
| | | * @param resultVo 数据 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public Boolean saveImport(SysUserResultVo resultVo) { |
| | | return null; |
| | | @Transactional |
| | | public Boolean saveImport(SysUserResultVo resultVo) |
| | | { |
| | | if (resultVo==null || StringUtils.isEmpty(resultVo.getVoList())){ |
| | | throw new BaseException("未获取到导入信息!"); |
| | | } |
| | | resultVo.getVoList().forEach(e-> { |
| | | if (StringUtils.isNotEmpty(e.getErrorList())) { |
| | | throw new BaseException("还有未处理错误信息!"); |
| | | } |
| | | }); |
| | | List<SysUser> users = Convert.toList(SysUser.class, resultVo.getVoList()); |
| | | for (SysUser user : users) { |
| | | this.insertUser(user); |
| | | } |
| | | return true; |
| | | } |
| | | } |