IUserinfoServiceImpl.java 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.ruoyi.system.service.impl;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
  4. import com.ruoyi.system.domain.OpenAccount;
  5. import com.ruoyi.system.domain.SysUserRole;
  6. import com.ruoyi.system.domain.vo.OpenAccountVO;
  7. import com.ruoyi.system.mapper.IUserinfoMapper;
  8. import com.ruoyi.system.mapper.SysUserRoleMapper;
  9. import com.ruoyi.system.service.IUserinfoService;
  10. import lombok.RequiredArgsConstructor;
  11. import org.springframework.stereotype.Service;
  12. import org.springframework.transaction.annotation.Transactional;
  13. @Service
  14. @RequiredArgsConstructor
  15. @Transactional
  16. public class IUserinfoServiceImpl implements IUserinfoService {
  17. private final IUserinfoMapper iUserinfoMapper;
  18. private final SysUserRoleMapper userRoleMapper;
  19. @Override
  20. public void createAdmin(OpenAccountVO openAccountVO) {
  21. //注册用户
  22. OpenAccount openAccount = new OpenAccount(openAccountVO);
  23. iUserinfoMapper.insert(openAccount);
  24. //设置权限
  25. for (Integer role : openAccountVO.getRoles()) {
  26. SysUserRole sysUserRole = new SysUserRole();
  27. sysUserRole.setUserId(openAccount.getUserId());
  28. sysUserRole.setRoleId(Long.valueOf(role));
  29. userRoleMapper.insert(sysUserRole);
  30. }
  31. }
  32. @Override
  33. public void createUser(OpenAccountVO openAccountVO) {
  34. OpenAccount openAccount = new OpenAccount(openAccountVO);
  35. iUserinfoMapper.insert(openAccount);
  36. }
  37. @Override
  38. public void disableUser(OpenAccountVO openAccountVO) {
  39. UpdateWrapper<OpenAccount> updateWrapper = new UpdateWrapper<>();
  40. updateWrapper.eq("u_id",openAccountVO.getUId());
  41. updateWrapper.set("delFlag",2);
  42. iUserinfoMapper.update(null,updateWrapper);
  43. }
  44. }