初始化 用户新增 用户删除 也删除角色关联
parent
04a64f7cc9
commit
ad76b6fe63
1
pom.xml
1
pom.xml
|
@ -27,6 +27,7 @@
|
|||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||
<version>3.1.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web-services</artifactId>
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.bbyb.operating.examination.controller;
|
||||
|
||||
import com.bbyb.operating.examination.model.po.Role;
|
||||
import com.bbyb.operating.examination.model.po.RoleUser;
|
||||
import com.bbyb.operating.examination.model.po.UserReq;
|
||||
import com.bbyb.operating.examination.service.RoleUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
@ -34,5 +36,9 @@ public class RoleUserController {
|
|||
return roleUserService.updateByPrimaryKey(row);
|
||||
}
|
||||
|
||||
@PostMapping("/findRoleUser")
|
||||
public RoleUser findRoleUser(UserReq userReq) {
|
||||
return roleUserService.findRoleUser(userReq);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -65,6 +65,11 @@ public class UserController {
|
|||
return userService.findUser(userReq);
|
||||
}
|
||||
|
||||
@PostMapping("/deleteUser")
|
||||
public CommonResult<Boolean> deleteUser(@RequestBody UserReq userReq){
|
||||
return new CommonResult<>(userService.deleteUser(userReq));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.bbyb.operating.examination.service;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bbyb.operating.examination.model.po.RoleUser;
|
||||
import com.bbyb.operating.examination.model.po.UserReq;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -15,4 +16,6 @@ public interface RoleUserService extends IService<RoleUser> {
|
|||
List<RoleUser> selectAll();
|
||||
|
||||
int updateByPrimaryKey(RoleUser row);
|
||||
|
||||
RoleUser findRoleUser(UserReq userReq);
|
||||
}
|
||||
|
|
|
@ -14,4 +14,6 @@ public interface UserService extends IService<User>{
|
|||
|
||||
|
||||
User findUser(UserReq userReq);
|
||||
|
||||
Boolean deleteUser(UserReq userReq);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
package com.bbyb.operating.examination.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bbyb.operating.examination.mapper.RoleUserMapper;
|
||||
import com.bbyb.operating.examination.mapper.UserMapper;
|
||||
import com.bbyb.operating.examination.model.po.RoleUser;
|
||||
import com.bbyb.operating.examination.model.po.User;
|
||||
import com.bbyb.operating.examination.model.po.UserReq;
|
||||
import com.bbyb.operating.examination.service.RoleUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -13,6 +17,8 @@ import java.util.List;
|
|||
public class RoleUserServiceImpl extends ServiceImpl<RoleUserMapper, RoleUser> implements RoleUserService {
|
||||
@Autowired
|
||||
private RoleUserMapper roleUserMapper;
|
||||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
|
||||
@Override
|
||||
public int deleteByPrimaryKey(Integer id) {
|
||||
|
@ -54,4 +60,15 @@ public class RoleUserServiceImpl extends ServiceImpl<RoleUserMapper, RoleUser> i
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoleUser findRoleUser(UserReq userReq) {
|
||||
User user = userMapper.selectByPrimaryKey(userReq.getId());
|
||||
if(user != null){
|
||||
LambdaQueryWrapper<RoleUser> roleUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
roleUserLambdaQueryWrapper.eq(RoleUser::getUserId,user.getId());
|
||||
return getOne(roleUserLambdaQueryWrapper);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.bbyb.operating.examination.mapper.UserMapper;
|
|||
import com.bbyb.operating.examination.model.po.RoleUser;
|
||||
import com.bbyb.operating.examination.model.po.User;
|
||||
import com.bbyb.operating.examination.model.po.UserReq;
|
||||
import com.bbyb.operating.examination.service.RoleUserService;
|
||||
import com.bbyb.operating.examination.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -27,6 +28,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|||
private UserMapper userMapper;
|
||||
@Autowired
|
||||
private RoleUserMapper roleUserMapper;
|
||||
@Autowired
|
||||
private RoleUserService roleUserService;
|
||||
|
||||
@Override
|
||||
public String addUser(UserReq userReq) {
|
||||
|
@ -62,5 +65,17 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|||
return getOne(userLambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteUser(UserReq userReq) {
|
||||
if(userReq.getUserCode() != null){
|
||||
User user = findUser(userReq);
|
||||
int i = userMapper.deleteByPrimaryKey(user.getId());
|
||||
if(i > 0){
|
||||
roleUserService.findRoleUser(userReq);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue