| | |
| | | import com.mindskip.xzs.domain.vo.BaseSelect; |
| | | import com.mindskip.xzs.domain.vo.DepartmentVO; |
| | | import com.mindskip.xzs.domain.vo.UpdateDeptAdminVO; |
| | | import com.mindskip.xzs.domain.vo.UserVO; |
| | | import com.mindskip.xzs.repository.DepartmentMapper; |
| | | import com.mindskip.xzs.repository.UserDepartmentMapper; |
| | | import com.mindskip.xzs.service.DepartmentService; |
| | | import com.mindskip.xzs.service.UserService; |
| | | import com.mindskip.xzs.utility.PageInfoHelper; |
| | | import com.mindskip.xzs.viewmodel.admin.department.DepartmentResponseVM; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | |
| | | |
| | | @RequestMapping(value = "/list", method = RequestMethod.POST) |
| | | public RestResponse<List<Department>> getAll(){ |
| | | List<Department> res = departmentService.gets(-1); |
| | | List<Department> res = departmentService.gets(new ArrayList<>()); |
| | | return RestResponse.ok(res); |
| | | } |
| | | |
| | |
| | | |
| | | @RequestMapping(value = "/getDepartmentUser", method = RequestMethod.POST) |
| | | public RestResponse<List<DepartmentVO>> getUserDepartment(Integer examPaperId){ |
| | | User currentUser = webContext.getCurrentUser(); |
| | | Integer deptId = null; |
| | | if (Objects.nonNull(currentUser)) { |
| | | // 如果是部门管理员,需要做数据权限 |
| | | if ("1".equals(currentUser.getDeptAdmin())) { |
| | | deptId = departmentMapper.selectByAdminId(currentUser.getId()); |
| | | } |
| | | } |
| | | List<DepartmentVO> res = departmentService.gets(deptId) |
| | | List<DepartmentVO> res = departmentService.gets(isDeptAdmin() ? getAdminDeptIds() : null) |
| | | .stream().map(e->{ |
| | | DepartmentVO departmentVO = new DepartmentVO(); |
| | | List<UserDepartment> userDepartments = userDepartmentMapper.selectByDepartmentId(e.getId()); |
| | |
| | | }).collect(Collectors.toList()); |
| | | return RestResponse.ok(res); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getDeptAdmins", method = RequestMethod.GET) |
| | | public RestResponse<List<Department>> getDeptAdmins(){ |
| | | return RestResponse.ok(userService.getDeptAdmins(isDeptAdmin() ? getCurrentUser().getId() : null)); |
| | | } |
| | | |
| | | } |