| | |
| | | import org.modelmapper.ModelMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import java.util.List; |
| | | |
| | | |
| | | public class BaseApiController { |
| | | /** |
| | |
| | | protected User getCurrentUser() { |
| | | return webContext.getCurrentUser(); |
| | | } |
| | | |
| | | protected boolean isDeptAdmin() { |
| | | return webContext.isDeptAdmin(); |
| | | } |
| | | |
| | | protected List<Integer> getAdminDeptIds() { |
| | | return webContext.getAdminDeptIds(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.mindskip.xzs.configuration.spring.security; |
| | | |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | import org.springframework.security.core.GrantedAuthority; |
| | | import org.springframework.security.core.userdetails.User; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author gonghl |
| | | * @since 2024/5/16 上午 10:35 |
| | | */ |
| | | |
| | | @Getter |
| | | @Setter |
| | | public class MyUser extends User { |
| | | |
| | | private Integer role; |
| | | private List<Integer> deptId; |
| | | |
| | | |
| | | public MyUser(String username, String password, Collection<? extends GrantedAuthority> authorities, Integer role, List<Integer> deptId) { |
| | | super(username, password, authorities); |
| | | this.role = role; |
| | | this.deptId = deptId; |
| | | } |
| | | |
| | | public MyUser(String username, String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities, Integer role, List<Integer> deptId) { |
| | | super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities); |
| | | this.role = role; |
| | | this.deptId = deptId; |
| | | } |
| | | } |
| | |
| | | import com.mindskip.xzs.service.AuthenticationService; |
| | | import com.mindskip.xzs.service.UserService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.authentication.AuthenticationProvider; |
| | | import org.springframework.security.authentication.BadCredentialsException; |
| | | import org.springframework.security.authentication.LockedException; |
| | |
| | | import org.springframework.security.core.AuthenticationException; |
| | | import org.springframework.security.core.GrantedAuthority; |
| | | import org.springframework.security.core.authority.SimpleGrantedAuthority; |
| | | import org.springframework.security.core.userdetails.User; |
| | | import org.springframework.security.core.userdetails.UsernameNotFoundException; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | |
| | | throw new LockedException("用户被禁用"); |
| | | } |
| | | |
| | | // // 查询该用户是不是部门管理员 |
| | | // Integer num = departmentMapper.countByAdminId(user.getId()); |
| | | |
| | | ArrayList<GrantedAuthority> grantedAuthorities = new ArrayList<>(); |
| | | // 赋予部门管理员角色 |
| | | if (DeptAdminEnum.YES.getValue().equals(user.getDeptAdmin())) { |
| | | grantedAuthorities.add(new SimpleGrantedAuthority(RoleEnum.DEPT_ADMIN.getRoleName())); |
| | | } |
| | | grantedAuthorities.add(new SimpleGrantedAuthority(RoleEnum.fromCode(user.getRole()).getRoleName())); |
| | | |
| | | User authUser = new User(user.getUserName(), user.getPassword(), grantedAuthorities); |
| | | // 获取该用户管理部门 |
| | | List<Integer> deptAdminIds = userService.getDeptAdminIds(user.getId()); |
| | | MyUser authUser = new MyUser(user.getUserName(), user.getPassword(), grantedAuthorities, user.getRole(), deptAdminIds); |
| | | return new UsernamePasswordAuthenticationToken(authUser, authUser.getPassword(), authUser.getAuthorities()); |
| | | } |
| | | |
| | |
| | | com.mindskip.xzs.domain.User newUser = new com.mindskip.xzs.domain.User(); |
| | | newUser.setUserName(user.getUserName()); |
| | | newUser.setImagePath(user.getImagePath()); |
| | | // 返回是否部门管理员的标识 |
| | | newUser.setDeptAdmin(user.getDeptAdmin()); |
| | | // 返回是否部门管理员的标识 1是部门管理员 |
| | | newUser.setDeptAdmin(user.getRole().equals(-1) ? "1" : "0"); |
| | | RestUtil.response(response, SystemCode.OK.getCode(), SystemCode.OK.getMessage(), newUser); |
| | | } |
| | | } else { |
| | |
| | | package com.mindskip.xzs.context; |
| | | |
| | | import com.mindskip.xzs.configuration.spring.security.MyUser; |
| | | import com.mindskip.xzs.domain.User; |
| | | import com.mindskip.xzs.service.UserService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.context.request.RequestAttributes; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | |
| | | import java.util.List; |
| | | |
| | | |
| | | @Component |
| | |
| | | return user; |
| | | } |
| | | } |
| | | |
| | | public boolean isDeptAdmin() { |
| | | MyUser user = (MyUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); |
| | | return user != null && user.getRole() != null && user.getRole().equals(-1); |
| | | } |
| | | |
| | | public List<Integer> getAdminDeptIds() { |
| | | MyUser user = (MyUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); |
| | | return user.getDeptId(); |
| | | } |
| | | |
| | | } |
| | |
| | | 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)); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.mindskip.xzs.domain.ExamPaperSubject; |
| | | import com.mindskip.xzs.domain.Subject; |
| | | import com.mindskip.xzs.domain.exam.ExamPaperAnswerObject; |
| | | import com.mindskip.xzs.domain.vo.ExamPaperStatisticVO; |
| | | import com.mindskip.xzs.service.ExamPaperAnswerService; |
| | | import com.mindskip.xzs.service.ExamPaperSubjectService; |
| | | import com.mindskip.xzs.service.SubjectService; |
| | |
| | | import com.mindskip.xzs.viewmodel.admin.paper.ExamPaperAnswerPageRequestVM; |
| | | import com.mindskip.xzs.viewmodel.student.exampaper.ExamPaperAnswerPageResponseVM; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.math.BigDecimal; |
| | |
| | | return RestResponse.ok(object); |
| | | } |
| | | |
| | | @RequestMapping(value = "/statistic", method = RequestMethod.GET) |
| | | public RestResponse<Map<String, Object>> statistic(String examPaperId, String departmentId) { |
| | | return RestResponse.ok(examPaperAnswerService.statistic(examPaperId, departmentId)); |
| | | @RequestMapping(value = "/statistic", method = RequestMethod.POST) |
| | | public RestResponse<Map<String, Object>> statistic(@RequestBody ExamPaperStatisticVO examPaperStatisticVO) { |
| | | examPaperStatisticVO.setDepartmentId(isDeptAdmin() ? getAdminDeptIds() : null); |
| | | return RestResponse.ok(examPaperAnswerService.statistic(examPaperStatisticVO)); |
| | | } |
| | | } |
| | |
| | | package com.mindskip.xzs.controller.admin; |
| | | |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.mindskip.xzs.base.BaseApiController; |
| | |
| | | import com.mindskip.xzs.domain.ExamPaperAnswer; |
| | | import com.mindskip.xzs.domain.User; |
| | | import com.mindskip.xzs.domain.UserDepartment; |
| | | import com.mindskip.xzs.domain.vo.ScoreTemplatesCountVO; |
| | | import com.mindskip.xzs.repository.DepartmentMapper; |
| | | import com.mindskip.xzs.repository.ExamPaperAnswerMapper; |
| | | import com.mindskip.xzs.repository.UserDepartmentMapper; |
| | | import com.mindskip.xzs.repository.UserMapper; |
| | | import com.mindskip.xzs.service.*; |
| | | import com.mindskip.xzs.utility.minio.DateUtils; |
| | | import com.mindskip.xzs.viewmodel.admin.paper.ExamPaperGradePageRequestVM; |
| | | import com.mindskip.xzs.viewmodel.admin.paper.ExamPaperGradeQuery; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | @RestController("AdminExamPaperGradeController") |
| | | @RequestMapping(value = "/api/admin/examPaperGrade") |
| | |
| | | |
| | | @RequestMapping(value = "/page", method = RequestMethod.POST) |
| | | public RestResponse<PageInfo<ExamPaperAnswer>> pageJudgeList(@RequestBody ExamPaperGradeQuery query) { |
| | | // 查出用户(并做数据权限) |
| | | User currentUser = webContext.getCurrentUser(); |
| | | if (Objects.nonNull(currentUser)) { |
| | | // 如果是部门管理员,需要做数据权限 |
| | | if ("1".equals(currentUser.getDeptAdmin())) { |
| | | query.setDeptId(departmentMapper.selectByAdminId(currentUser.getId())); |
| | | } |
| | | } |
| | | // 如果是部门管理员,需要做数据权限 |
| | | query.setDeptId(isDeptAdmin() ? getAdminDeptIds() : null); |
| | | query.setFullTime(); |
| | | // 查询 |
| | | PageInfo<ExamPaperAnswer> info = PageHelper.startPage(query.getPageIndex(), query.getPageSize()).doSelectPageInfo(() -> |
| | |
| | | package com.mindskip.xzs.controller.admin; |
| | | |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.mindskip.xzs.base.BaseApiController; |
| | | import com.mindskip.xzs.base.RestResponse; |
| | | import com.mindskip.xzs.context.WebContext; |
| | | import com.mindskip.xzs.domain.ExamPaper; |
| | | import com.mindskip.xzs.domain.ExamTemplates; |
| | | import com.mindskip.xzs.domain.ExamTemplatesSubject; |
| | | import com.mindskip.xzs.domain.User; |
| | | import com.mindskip.xzs.domain.vo.ExamTemplatesVO; |
| | | import com.mindskip.xzs.repository.DepartmentMapper; |
| | | import com.mindskip.xzs.repository.ExamTemplatesSubjectMapper; |
| | | import com.mindskip.xzs.repository.UserDepartmentMapper; |
| | | import com.mindskip.xzs.service.ExamTemplatesService; |
| | | import com.mindskip.xzs.utility.PageInfoHelper; |
| | | import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperEditRequestVM; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | @RestController("AdminExamTemplatesController") |
| | | @RequestMapping(value = "/api/admin/exam/templates") |
| | |
| | | |
| | | @RequestMapping(value = "/edit", method = RequestMethod.POST) |
| | | public RestResponse edit(@RequestBody @Valid ExamPaperEditRequestVM model) { |
| | | User currentUser = webContext.getCurrentUser(); |
| | | if (Objects.nonNull(currentUser)) { |
| | | // 如果是部门管理员,需要做数据权限 |
| | | if ("1".equals(currentUser.getDeptAdmin())) { |
| | | Integer deptId = departmentMapper.selectByAdminId(currentUser.getId()); |
| | | model.setDeptId(deptId); |
| | | } |
| | | } |
| | | examTemplatesService.add(model); |
| | | return RestResponse.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/list", method = RequestMethod.GET) |
| | | public RestResponse<PageInfo<ExamTemplatesVO>> list(ExamTemplatesVO examTemplatesVO) throws Exception { |
| | | User currentUser = webContext.getCurrentUser(); |
| | | if (Objects.nonNull(currentUser)) { |
| | | // 如果是部门管理员,需要做数据权限 |
| | | if ("1".equals(currentUser.getDeptAdmin())) { |
| | | Integer deptId = departmentMapper.selectByAdminId(currentUser.getId()); |
| | | examTemplatesVO.setDeptId(deptId); |
| | | } |
| | | } |
| | | // 如果是部门管理员,需要做数据权限 |
| | | examTemplatesVO.setDeptId(isDeptAdmin() ? getAdminDeptIds() : null); |
| | | PageInfo<ExamTemplates> pageInfo = examTemplatesService.getByadmins(examTemplatesVO); |
| | | PageInfo<ExamTemplatesVO> info = PageInfoHelper.copyMap(pageInfo, e -> { |
| | | ExamTemplatesVO vo = new ExamTemplatesVO(); |
| | |
| | | |
| | | @RequestMapping(value = "/page/list", method = RequestMethod.POST) |
| | | public RestResponse<PageInfo<UserResponseVM>> pageList(@RequestBody UserPageRequestVM model) { |
| | | model.setDepartmentId(isDeptAdmin() ? getAdminDeptIds() : null); |
| | | PageInfo<User> pageInfo = userService.userPage(model); |
| | | PageInfo<UserResponseVM> page = PageInfoHelper.copyMap(pageInfo, d -> |
| | | UserResponseVM.from(d)); |
| | |
| | | |
| | | private String userIds; |
| | | |
| | | private Integer deptId; |
| | | |
| | | public Integer getDeptId() { |
| | | return deptId; |
| | | } |
| | | |
| | | public void setDeptId(Integer deptId) { |
| | | this.deptId = deptId; |
| | | } |
| | | |
| | | public Integer getId() { |
| | | return id; |
New file |
| | |
| | | package com.mindskip.xzs.domain.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author gonghl |
| | | * @since 2024/5/16 上午 11:41 |
| | | */ |
| | | |
| | | @Data |
| | | public class ExamPaperStatisticVO { |
| | | |
| | | private Integer examPaperId; |
| | | |
| | | private List<Integer> departmentId; |
| | | |
| | | } |
| | |
| | | package com.mindskip.xzs.domain.vo; |
| | | |
| | | import com.mindskip.xzs.base.BasePage; |
| | | import com.mindskip.xzs.domain.ExamTemplates; |
| | | import com.mindskip.xzs.domain.ExamTemplatesSubject; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | /** |
| | | * 部门ID |
| | | */ |
| | | private Integer deptId; |
| | | private List<Integer> deptId; |
| | | |
| | | } |
| | |
| | | |
| | | Integer update(Department department); |
| | | |
| | | List<Department> gets(Integer deptId); |
| | | List<Department> gets(List<Integer> deptId); |
| | | |
| | | List<DepartmentResponseVM> page(DepartmentResponseVM departmentResponseVM); |
| | | |
| | |
| | | import com.mindskip.xzs.domain.ExamTemplatesUserCount; |
| | | import com.mindskip.xzs.domain.ScoreTemplatesUserCount; |
| | | import com.mindskip.xzs.domain.other.KeyValue; |
| | | import com.mindskip.xzs.domain.vo.ExamPaperStatisticVO; |
| | | import com.mindskip.xzs.domain.vo.TeamplatesUserExcelVO; |
| | | import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperEditRequestVM; |
| | | import com.mindskip.xzs.viewmodel.admin.paper.ExamPaperGradePageRequestVM; |
| | |
| | | |
| | | void insertDefault(ExamPaperEditRequestVM model); |
| | | |
| | | Map<String, Object> histogram(@Param("examPaperId") String examPaperId, @Param("departmentId") String departmentId); |
| | | Map<String, Object> histogram(ExamPaperStatisticVO examPaperStatisticVO); |
| | | |
| | | Map<String, Object> pieChart(@Param("examPaperId") String examPaperId, @Param("departmentId") String departmentId); |
| | | Map<String, Object> pieChart(ExamPaperStatisticVO examPaperStatisticVO); |
| | | } |
| | |
| | | package com.mindskip.xzs.repository; |
| | | |
| | | import com.mindskip.xzs.domain.Department; |
| | | import com.mindskip.xzs.domain.ExamPaper; |
| | | import com.mindskip.xzs.domain.ExamPaperAnswer; |
| | | import com.mindskip.xzs.domain.User; |
| | |
| | | void updateUserDeptAdmin(UpdateDeptAdminVO form); |
| | | |
| | | void cancelUserDeptAdmin(UpdateDeptAdminVO form); |
| | | |
| | | List<Integer> getDeptAdminIds(Integer id); |
| | | |
| | | List<Department> getDeptAdmins(Integer id); |
| | | } |
| | |
| | | |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.mindskip.xzs.domain.Department; |
| | | import com.mindskip.xzs.domain.Question; |
| | | import com.mindskip.xzs.domain.vo.BaseSelect; |
| | | import com.mindskip.xzs.domain.vo.UpdateDeptAdminVO; |
| | | import com.mindskip.xzs.viewmodel.admin.department.DepartmentResponseVM; |
| | |
| | | |
| | | Department getById(Integer id); |
| | | |
| | | List<Department> gets(Integer deptId); |
| | | List<Department> gets(List<Integer> deptId); |
| | | |
| | | Department getName(String name); |
| | | |
| | |
| | | |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.mindskip.xzs.domain.*; |
| | | import com.mindskip.xzs.domain.vo.ExamPaperStatisticVO; |
| | | import com.mindskip.xzs.viewmodel.admin.paper.ExamPaperGradePageRequestVM; |
| | | import com.mindskip.xzs.viewmodel.admin.paper.ExamPaperGradeQuery; |
| | | import com.mindskip.xzs.viewmodel.student.exam.ExamPaperSubmitVM; |
| | |
| | | |
| | | PageInfo<ExamPaperAnswer> getByCreatUser(ExamPaperGradeQuery query); |
| | | |
| | | Map<String, Object> statistic(String examPaperId, String departmentId); |
| | | Map<String, Object> statistic(ExamPaperStatisticVO examPaperStatisticVO); |
| | | } |
| | |
| | | package com.mindskip.xzs.service; |
| | | |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.mindskip.xzs.domain.Department; |
| | | import com.mindskip.xzs.domain.ExamPaper; |
| | | import com.mindskip.xzs.domain.other.KeyValue; |
| | | import com.mindskip.xzs.domain.User; |
| | | import com.mindskip.xzs.domain.other.KeyValue; |
| | | import com.mindskip.xzs.domain.vo.UserVO; |
| | | import com.mindskip.xzs.viewmodel.admin.user.UserPageRequestVM; |
| | | import com.github.pagehelper.PageInfo; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | void setStatus(UserVO user); |
| | | |
| | | User getUserByExam(ExamPaper examPaper); |
| | | |
| | | List<Integer> getDeptAdminIds(Integer id); |
| | | |
| | | List<Department> getDeptAdmins(Integer id); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Department> gets(Integer deptId) { |
| | | if (deptId == null || deptId == -1) { |
| | | deptId = null; |
| | | } |
| | | public List<Department> gets(List<Integer> deptId) { |
| | | return departmentMapper.gets(deptId); |
| | | } |
| | | |
| | |
| | | import com.mindskip.xzs.domain.other.ExamPaperAnswerUpdate; |
| | | import com.mindskip.xzs.domain.other.KeyValue; |
| | | import com.mindskip.xzs.domain.task.TaskItemAnswerObject; |
| | | import com.mindskip.xzs.domain.vo.ExamPaperStatisticVO; |
| | | import com.mindskip.xzs.repository.ExamPaperAnswerMapper; |
| | | import com.mindskip.xzs.repository.ExamPaperMapper; |
| | | import com.mindskip.xzs.repository.QuestionMapper; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> statistic(String examPaperId, String departmentId) { |
| | | public Map<String, Object> statistic(ExamPaperStatisticVO examPaperStatisticVO) { |
| | | // 获取原始数据 |
| | | Map<String, Object> histogram = examPaperAnswerMapper.histogram(examPaperId, departmentId); |
| | | Map<String, Object> pieChart = examPaperAnswerMapper.pieChart(examPaperId, departmentId); |
| | | Map<String, Object> histogram = examPaperAnswerMapper.histogram(examPaperStatisticVO); |
| | | Map<String, Object> pieChart = examPaperAnswerMapper.pieChart(examPaperStatisticVO); |
| | | // 初始化结果容器 |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | List<Map<String, Object>> score = new ArrayList<>(); |
| | |
| | | package com.mindskip.xzs.service.impl; |
| | | |
| | | import com.mindskip.xzs.domain.Department; |
| | | import com.mindskip.xzs.domain.ExamPaper; |
| | | import com.mindskip.xzs.domain.other.KeyValue; |
| | | import com.mindskip.xzs.domain.vo.UserVO; |
| | |
| | | public User getUserByExam(ExamPaper examPaper) { |
| | | return userMapper.getUserByExam(examPaper); |
| | | } |
| | | |
| | | @Override |
| | | public List<Integer> getDeptAdminIds(Integer id) { |
| | | return userMapper.getDeptAdminIds(id); |
| | | } |
| | | |
| | | @Override |
| | | public List<Department> getDeptAdmins(Integer id) { |
| | | return userMapper.getDeptAdmins(id); |
| | | } |
| | | } |
| | |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 部门ID |
| | | */ |
| | | private Integer deptId; |
| | | private List<Integer> deptId; |
| | | |
| | | /** |
| | | * 参考人 |
| | |
| | | |
| | | import com.mindskip.xzs.base.BasePage; |
| | | |
| | | import java.util.List; |
| | | |
| | | |
| | | public class UserPageRequestVM extends BasePage { |
| | | |
| | | private String userName; |
| | | private Integer role; |
| | | |
| | | private List<Integer> departmentId; |
| | | |
| | | public List<Integer> getDepartmentId() { |
| | | return departmentId; |
| | | } |
| | | |
| | | public void setDepartmentId(List<Integer> departmentId) { |
| | | this.departmentId = departmentId; |
| | | } |
| | | |
| | | public String getUserName() { |
| | | return userName; |
| | | } |
| | |
| | | t_department td |
| | | WHERE |
| | | td.deleted = 0 |
| | | <if test="deptId != null"> |
| | | AND td.id = #{deptId} |
| | | <if test="deptId != null and deptId.size() > 0"> |
| | | AND td.id in <foreach collection="deptId" item="item" index="index" open="(" separator="," close=")"> #{item} </foreach> |
| | | </if> |
| | | </select> |
| | | |
| | |
| | | FROM |
| | | t_exam_paper_answer a |
| | | INNER JOIN (SELECT * FROM t_user_department |
| | | <if test="departmentId != null and departmentId != ''"> |
| | | WHERE department_id = #{departmentId} |
| | | <if test="departmentId != null and departmentId.size() > 0"> |
| | | WHERE department_id IN |
| | | <foreach collection="departmentId" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | GROUP BY user_id) b ON a.create_user = b.user_id |
| | | LEFT JOIN t_user c ON a.create_user = c.id |
| | |
| | | </if> |
| | | LEFT JOIN t_exam_paper_answer c ON a.exam_paper_id = c.exam_paper_id AND a.user_id = c.create_user AND (c.invalid IS NULL OR c.invalid = 0) |
| | | INNER JOIN (SELECT * FROM t_user_department |
| | | <if test="departmentId != null and departmentId != ''"> |
| | | WHERE department_id = #{departmentId} |
| | | <if test="departmentId != null and departmentId.size() > 0"> |
| | | WHERE department_id IN |
| | | <foreach collection="departmentId" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | GROUP BY user_id) d ON a.user_id = d.user_id |
| | | </select> |
| | |
| | | <result column="user_ids" jdbcType="VARCHAR" property="userIds" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | id, name, subject_id, paper_type, grade_level, score, question_count, suggest_time, |
| | | id, dept_id, name, subject_id, paper_type, grade_level, score, question_count, suggest_time, |
| | | limit_start_time, limit_end_time, frame_text_content_id, create_user, create_time, |
| | | deleted, task_exam_id, type, user_ids |
| | | </sql> |
| | |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | id, |
| | | </if> |
| | | <if test="deptId != null"> |
| | | dept_id, |
| | | </if> |
| | | <if test="name != null"> |
| | | name, |
| | |
| | | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | #{id,jdbcType=INTEGER}, |
| | | </if> |
| | | <if test="deptId != null"> |
| | | #{deptId,jdbcType=INTEGER}, |
| | | </if> |
| | | <if test="name != null"> |
| | | #{name,jdbcType=VARCHAR}, |
| | |
| | | <if test="name != null"> |
| | | name = #{name,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="deptId != null"> |
| | | dept_id = #{deptId,jdbcType=INTEGER}, |
| | | </if> |
| | | <if test="subjectId != null"> |
| | | subject_id = #{subjectId,jdbcType=INTEGER}, |
| | | </if> |
| | |
| | | update t_exam_paper |
| | | set name = #{name,jdbcType=VARCHAR}, |
| | | subject_id = #{subjectId,jdbcType=INTEGER}, |
| | | dept_id = #{deptId,jdbcType=INTEGER}, |
| | | paper_type = #{paperType,jdbcType=INTEGER}, |
| | | grade_level = #{gradeLevel,jdbcType=INTEGER}, |
| | | score = #{score,jdbcType=INTEGER}, |
| | |
| | | </sql> |
| | | |
| | | <insert id="add" parameterType="com.mindskip.xzs.domain.ExamTemplates" useGeneratedKeys="true" keyProperty="id"> |
| | | insert into t_exam_templates (name, paper_type, suggest_time, title_name, ctime, status, menu_ids,start_time,end_time) |
| | | values (#{name}, #{paperType}, #{suggestTime}, #{titleName}, #{ctime}, #{status}, #{menuIds},#{startTime},#{endTime}) |
| | | insert into t_exam_templates (name, paper_type, dept_id, suggest_time, title_name, ctime, status, menu_ids,start_time,end_time) |
| | | values (#{name}, #{paperType}, #{deptId}, #{suggestTime}, #{titleName}, #{ctime}, #{status}, #{menuIds},#{startTime},#{endTime}) |
| | | </insert> |
| | | |
| | | <select id="getTime" resultMap="BaseResultMap"> |
| | |
| | | <if test="userId != null"> |
| | | and u.user_id = #{userId} |
| | | </if> |
| | | <if test="deptId != null"> |
| | | and e.dept_id = #{deptId} |
| | | <if test="deptId != null and deptId.size() > 0"> |
| | | and e.dept_id in <foreach collection="deptId" item="item" separator="," open="(" close=")"> #{item} </foreach> |
| | | </if> |
| | | <if test="now !=null"> |
| | | and #{now} between e.start_time and e.end_time |
| | |
| | | <if test="level != null "> |
| | | and q.grade_level= #{level} |
| | | </if> |
| | | <if test="subjectId != null "> |
| | | <if test="subjectId != null and subjectId.length > 0"> |
| | | and qs.subject_id in |
| | | <foreach item="subjectId" collection="subjectId" open="(" separator="," |
| | | close=")"> |
| | |
| | | <select id="userPage" resultMap="BaseResultMap" |
| | | parameterType="com.mindskip.xzs.viewmodel.admin.user.UserPageRequestVM"> |
| | | SELECT |
| | | <include refid="Base_Column_List"/> |
| | | FROM t_user |
| | | <where> |
| | | and deleted=0 |
| | | a.* |
| | | FROM t_user a |
| | | lEFT join |
| | | (select * from t_user_department |
| | | <if test="departmentId != null and departmentId.size() > 0"> |
| | | where department_id in <foreach collection="departmentId" item="item" index="index" open="(" separator="," close=")"> #{item} </foreach> |
| | | </if> |
| | | group by user_id |
| | | ) |
| | | b on a.id = b.user_id |
| | | where |
| | | a.deleted=0 |
| | | <if test="departmentId != null and departmentId.size() > 0"> |
| | | and b.department_id in <foreach collection="departmentId" item="item" index="index" open="(" separator="," close=")"> #{item} </foreach> |
| | | </if> |
| | | <if test="userName != null and userName != ''"> |
| | | and real_name like concat('%',#{userName},'%') |
| | | </if> |
| | | <if test="role != null "> |
| | | and role= #{role} |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | |
| | |
| | | t_user tu INNER JOIN t_user_department tud ON tu.id = tud.user_id AND tu.deleted = 0 |
| | | LEFT JOIN t_exam_paper_answer tepa ON tepa.create_user = tu.id |
| | | <where> |
| | | <if test="query.deptId != null"> |
| | | AND tud.department_id = #{query.deptId} |
| | | <if test="query.deptId != null and query.deptId.size() > 0"> |
| | | AND tud.department_id in <foreach collection="query.deptId" item="deptId" open="(" separator="," close=")"> #{deptId} </foreach> |
| | | </if> |
| | | <if test="query.start != null and query.end != null"> |
| | | AND tepa.create_time between #{query.start} and #{query.end} |
| | |
| | | ))) |
| | | </update> |
| | | |
| | | <select id="getDeptAdminIds" resultType="java.lang.Integer" parameterType="java.lang.Integer"> |
| | | select department_id from t_user_department where dept_admin = 1 and user_id = #{id} |
| | | </select> |
| | | |
| | | <select id="getDeptAdmins" resultType="com.mindskip.xzs.domain.Department" parameterType="java.lang.Integer"> |
| | | <if test="id != null"> |
| | | select a.id, a.name from t_department a inner join t_user_department b on a.id = b.department_id where a.deleted = 0 and b.dept_admin = 1 and b.user_id = #{id} order by a.id desc |
| | | </if> |
| | | <if test="id == null"> |
| | | select a.id, a.name from t_department a where a.deleted = 0 order by a.id desc |
| | | </if> |
| | | </select> |
| | | |
| | | </mapper> |