mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-22 18:29:51 +08:00
代码优化
This commit is contained in:
@@ -2,6 +2,7 @@ package xyz.playedu.api.service;
|
||||
|
||||
import xyz.playedu.api.domain.User;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import xyz.playedu.api.exception.NotFoundException;
|
||||
import xyz.playedu.api.types.paginate.PaginationResult;
|
||||
import xyz.playedu.api.types.paginate.UserPaginateFilter;
|
||||
|
||||
@@ -20,4 +21,6 @@ public interface UserService extends IService<User> {
|
||||
List<String> existsEmailsByEmails(List<String> emails);
|
||||
|
||||
void removeRelateDepartmentsByUserId(Integer userId);
|
||||
|
||||
User findOrFail(Integer id) throws NotFoundException;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import xyz.playedu.api.domain.User;
|
||||
import xyz.playedu.api.domain.UserDepartment;
|
||||
import xyz.playedu.api.exception.NotFoundException;
|
||||
import xyz.playedu.api.service.internal.UserDepartmentService;
|
||||
import xyz.playedu.api.service.UserService;
|
||||
import xyz.playedu.api.mapper.UserMapper;
|
||||
@@ -105,6 +106,15 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
QueryWrapper<UserDepartment> wrapper = userDepartmentService.query().getWrapper().eq("user_id", userId);
|
||||
userDepartmentService.remove(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User findOrFail(Integer id) throws NotFoundException {
|
||||
User user = getOne(query().getWrapper().eq("id", id));
|
||||
if (user == null) {
|
||||
throw new NotFoundException("学员不存在");
|
||||
}
|
||||
return user;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user