mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-22 18:29:51 +08:00
user_department优化
This commit is contained in:
@@ -31,4 +31,6 @@ public interface DepartmentService extends IService<Department> {
|
||||
|
||||
void create(String name, Integer parentId, Integer sort) throws NotFoundException;
|
||||
|
||||
void remoteRelateUsersByDepId(Integer depId);
|
||||
|
||||
}
|
||||
|
||||
@@ -18,4 +18,6 @@ public interface UserService extends IService<User> {
|
||||
PaginationResult<User> paginate(int page, int size, UserPaginateFilter filter);
|
||||
|
||||
List<String> existsEmailsByEmails(List<String> emails);
|
||||
|
||||
void removeRelateDepartmentsByUserId(Integer userId);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package xyz.playedu.api.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import xyz.playedu.api.domain.Department;
|
||||
import xyz.playedu.api.domain.UserDepartment;
|
||||
import xyz.playedu.api.exception.NotFoundException;
|
||||
import xyz.playedu.api.service.DepartmentService;
|
||||
import xyz.playedu.api.mapper.DepartmentMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import xyz.playedu.api.service.internal.UserDepartmentService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@@ -22,6 +26,9 @@ import java.util.List;
|
||||
@Slf4j
|
||||
public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Department> implements DepartmentService {
|
||||
|
||||
@Autowired
|
||||
private UserDepartmentService userDepartmentService;
|
||||
|
||||
@Override
|
||||
public List<Department> listByParentId(Integer id) {
|
||||
return list(query().getWrapper().eq("parent_id", id).orderByAsc("sort"));
|
||||
@@ -163,6 +170,12 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
||||
|
||||
save(department);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remoteRelateUsersByDepId(Integer depId) {
|
||||
QueryWrapper<UserDepartment> wrapper = userDepartmentService.query().getWrapper().eq("dep_id", depId);
|
||||
userDepartmentService.remove(wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package xyz.playedu.api.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.enums.SqlKeyword;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import xyz.playedu.api.domain.User;
|
||||
import xyz.playedu.api.domain.UserDepartment;
|
||||
import xyz.playedu.api.service.internal.UserDepartmentService;
|
||||
import xyz.playedu.api.service.UserService;
|
||||
import xyz.playedu.api.mapper.UserMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -23,6 +24,10 @@ import java.util.List;
|
||||
*/
|
||||
@Service
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
|
||||
|
||||
@Autowired
|
||||
private UserDepartmentService userDepartmentService;
|
||||
|
||||
@Override
|
||||
public boolean emailIsExists(String email) {
|
||||
User user = getOne(query().getWrapper().eq("email", email));
|
||||
@@ -85,6 +90,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
}
|
||||
return existsEmails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRelateDepartmentsByUserId(Integer userId) {
|
||||
QueryWrapper<UserDepartment> wrapper = userDepartmentService.query().getWrapper().eq("user_id", userId);
|
||||
userDepartmentService.remove(wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package xyz.playedu.api.service.impl;
|
||||
package xyz.playedu.api.service.impl.internal;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import xyz.playedu.api.domain.UserDepartment;
|
||||
import xyz.playedu.api.service.UserDepartmentService;
|
||||
import xyz.playedu.api.service.internal.UserDepartmentService;
|
||||
import xyz.playedu.api.mapper.UserDepartmentMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -14,15 +14,6 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class UserDepartmentServiceImpl extends ServiceImpl<UserDepartmentMapper, UserDepartment>
|
||||
implements UserDepartmentService {
|
||||
@Override
|
||||
public void removeByUserId(Integer userId) {
|
||||
remove(query().getWrapper().eq("user_id", userId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeByDepId(Integer depId) {
|
||||
remove(query().getWrapper().eq("dep_id", depId));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package xyz.playedu.api.service;
|
||||
package xyz.playedu.api.service.internal;
|
||||
|
||||
import xyz.playedu.api.domain.UserDepartment;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
@@ -9,7 +9,4 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
* @createDate 2023-02-23 15:08:38
|
||||
*/
|
||||
public interface UserDepartmentService extends IService<UserDepartment> {
|
||||
|
||||
void removeByUserId(Integer userId);
|
||||
void removeByDepId(Integer depId);
|
||||
}
|
||||
Reference in New Issue
Block a user