用删除优化

main
cheney 11 months ago
parent 30bdb3eb49
commit 741e4a55b7
  1. 5
      users/src/main/java/com/huoran/users/controller/HrUserAccountController.java
  2. 6
      users/src/main/java/com/huoran/users/controller/UserLoginController.java
  3. 4
      users/src/main/java/com/huoran/users/service/IHrUserAccountService.java
  4. 35
      users/src/main/java/com/huoran/users/service/impl/HrUserAccountServiceImpl.java

@ -93,9 +93,8 @@ public class HrUserAccountController {
*/
@PostMapping("/delUserAccounts")
@ApiOperation(value = "批量删除用户以及账号")
public R delUserAccounts(@RequestBody List<Integer> ids) {
int result = iHrUserAccountService.delUserAccounts(ids);
return result > 0 ? R.ok("删除成功!") : R.error();
public R delUserAccounts(@RequestBody List<String> ids) {
return iHrUserAccountService.delUserAccounts(ids);
}
/**

@ -245,8 +245,10 @@ public class UserLoginController {
@ApiParam(name = "openId", value = "微信id", required = true)
@RequestParam String openId,
@ApiParam(name = "userName", value = "用户名称")
@RequestParam String userName){
return userAccountService.updateAvatars(openId,url,userName);
@RequestParam String userName,
@ApiParam(name = "platformId", value = "平台id")
@RequestParam String platformId){
return userAccountService.updateAvatars(openId,url,userName,platformId);
}
/**

@ -54,7 +54,7 @@ public interface IHrUserAccountService extends IService<HrUserAccount> {
R examinePassword(ResetPwdReq resetPwdReq);
int delUserAccounts(List<Integer> ids);
R delUserAccounts(List<String> ids);
Integer getUserIdByAccountId(String accountId);
@ -87,5 +87,5 @@ public interface IHrUserAccountService extends IService<HrUserAccount> {
UserInfoDetailsRes viewUserDetails(String openId);
R updateAvatars(String openId, String url, String userName);
R updateAvatars(String openId, String url, String userName,String platformId);
}

@ -24,8 +24,7 @@ import com.huoran.users.entity.req.*;
import com.huoran.users.entity.res.*;
import com.huoran.users.entity.vo.CheckVo;
import com.huoran.users.mapper.*;
import com.huoran.users.service.IHrUserAccountService;
import com.huoran.users.service.PlatformLoginService;
import com.huoran.users.service.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.BeanFactory;
@ -59,9 +58,8 @@ public class HrUserAccountServiceImpl extends ServiceImpl<HrUserAccountMapper, H
@Autowired
private UserAuthenticationInformationMapper userAuthenticationInformationMapper;
@Autowired
private EnterpriseCertificationMapper enterpriseCertificationMapper;
public EnterpriseCertificationService enterpriseCertificationService;
@Autowired
private HrPersonalFileMapper hrPersonalFileMapper;
@Autowired
@ -127,13 +125,24 @@ public class HrUserAccountServiceImpl extends ServiceImpl<HrUserAccountMapper, H
}
@Override
public int delUserAccounts(List<Integer> ids) {
//删除用户表
boolean i = hrUserInfoMapper.delUserInfos(ids);
public R delUserAccounts(List<String> ids) {
List<HrUserAccount> accountList = hrUserAccountMapper.selectList(new QueryWrapper<HrUserAccount>().in("app_open_id", ids));
List<Integer> userIds = accountList.stream().map(HrUserAccount::getUserId).collect(Collectors.toList());
//删除用户信息
hrUserInfoMapper.deleteBatchIds(userIds);
//删除账号表
boolean n = hrUserAccountMapper.delUserAccounts(ids);
return i & n == true ? 1 : 0;
int delete = hrUserAccountMapper.delete(new QueryWrapper<HrUserAccount>().in("app_open_id", ids));
//删除平台全部认证信息
ids.forEach(openId -> {
QueryWrapper<UserAuthenticationInformation> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("open_id", openId);
userAuthenticationInformationMapper.delete(queryWrapper);
QueryWrapper<EnterpriseCertification> queryWrapper1 = new QueryWrapper<>();
queryWrapper1.eq("open_id", openId);
enterpriseCertificationService.remove(queryWrapper1);
});
return delete > 0 ? R.ok("删除成功!") : R.error();
}
@Override
@ -439,10 +448,10 @@ public class HrUserAccountServiceImpl extends ServiceImpl<HrUserAccountMapper, H
}
@Override
public R updateAvatars(String openId, String url, String userName) {
public R updateAvatars(String openId, String url, String userName,String platformId) {
//查询账号详情
HrUserAccount hrUserAccount = hrUserAccountMapper.selectOne(new QueryWrapper<HrUserAccount>()
.eq("app_open_id", openId).eq("platform_id", 7));
.eq("app_open_id", openId).eq("platform_id", platformId));
//查询用户信息
HrUserInfo hrUserInfo = hrUserInfoMapper.selectByUserId(hrUserAccount.getUserId());
@ -451,6 +460,8 @@ public class HrUserAccountServiceImpl extends ServiceImpl<HrUserAccountMapper, H
}
if (StringUtils.isNotBlank(userName)){
hrUserInfo.setUserName(userName);
hrUserAccount.setAccount(userName);
hrUserAccountMapper.updateById(hrUserAccount);
}
int update = hrUserInfoMapper.updateById(hrUserInfo);
return update>0 ? R.ok():R.error();

Loading…
Cancel
Save