|
@@ -1,25 +1,29 @@
|
|
|
package com.ruoyi.sim.service.impl;
|
|
|
|
|
|
+import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
-import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
import com.ruoyi.common.utils.PageUtils;
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.sim.constant.Consts;
|
|
|
import com.ruoyi.sim.domain.AddOnDept;
|
|
|
import com.ruoyi.sim.domain.Major;
|
|
|
import com.ruoyi.sim.domain.Student;
|
|
|
import com.ruoyi.system.mapper.*;
|
|
|
+import com.ruoyi.system.service.ISysPostService;
|
|
|
+import com.ruoyi.system.service.ISysRoleService;
|
|
|
import com.ruoyi.system.service.ISysUserService;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
|
-import javax.validation.Validator;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class StudentService {
|
|
@@ -28,21 +32,18 @@ public class StudentService {
|
|
|
|
|
|
@Autowired
|
|
|
private SysUserMapper userMapper;
|
|
|
-
|
|
|
@Autowired
|
|
|
private SysRoleMapper roleMapper;
|
|
|
-
|
|
|
@Autowired
|
|
|
private AddOnDeptService addOnDeptService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private MajorService majorService;
|
|
|
-
|
|
|
@Autowired
|
|
|
- protected Validator validator;
|
|
|
-
|
|
|
+ private ISysUserService userService;
|
|
|
+ @Autowired
|
|
|
+ private ISysRoleService roleService;
|
|
|
@Autowired
|
|
|
- private ISysUserService sysUserService;
|
|
|
+ private ISysPostService postService;
|
|
|
|
|
|
// @DataScope(deptAlias = "d", userAlias = "u")
|
|
|
public List<Student> selectStudentListOld() {
|
|
@@ -80,11 +81,10 @@ public class StudentService {
|
|
|
// 分页
|
|
|
PageUtils.startPage();
|
|
|
suQ.setRoleId(Consts.ROLE_ID_STUDENT);
|
|
|
- List<SysUser> listSu = sysUserService.selectAllocatedListV2(suQ);
|
|
|
+ List<SysUser> listSu = userService.selectAllocatedListV2(suQ);
|
|
|
List<Student> listSt = new ArrayList<>(listSu.size());
|
|
|
listSu.forEach(su -> {
|
|
|
Student st = new Student();
|
|
|
- su.setPassword("~~~~");
|
|
|
BeanUtils.copyProperties(su, st);
|
|
|
listSt.add(st);
|
|
|
});
|
|
@@ -106,16 +106,16 @@ public class StudentService {
|
|
|
}
|
|
|
break;
|
|
|
case 3: {
|
|
|
- list = sysUserService.selectUserList(new SysUser());
|
|
|
+ list = userService.selectUserList(new SysUser());
|
|
|
}
|
|
|
break;
|
|
|
case 4: {
|
|
|
PageUtils.startPage();
|
|
|
- list = sysUserService.selectUserList(new SysUser());
|
|
|
+ list = userService.selectUserList(new SysUser());
|
|
|
}
|
|
|
break;
|
|
|
case 5: {
|
|
|
- list = sysUserService.selectAllocatedList(new SysUser());
|
|
|
+ list = userService.selectAllocatedList(new SysUser());
|
|
|
}
|
|
|
break;
|
|
|
case 6: {
|
|
@@ -123,16 +123,16 @@ public class StudentService {
|
|
|
PageUtils.startPage();
|
|
|
SysUser su = new SysUser();
|
|
|
su.setRoleId(Consts.ROLE_ID_STUDENT);
|
|
|
- list = sysUserService.selectAllocatedList(su);
|
|
|
+ list = userService.selectAllocatedList(su);
|
|
|
}
|
|
|
break;
|
|
|
case 7: {
|
|
|
- list = sysUserService.selectUnallocatedList(new SysUser());
|
|
|
+ list = userService.selectUnallocatedList(new SysUser());
|
|
|
}
|
|
|
break;
|
|
|
case 8: {
|
|
|
PageUtils.startPage();
|
|
|
- list = sysUserService.selectUnallocatedList(new SysUser());
|
|
|
+ list = userService.selectUnallocatedList(new SysUser());
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
@@ -141,14 +141,12 @@ public class StudentService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
public Student selectStudentByUserId(Long userId) {
|
|
|
SysUser sysUser = userMapper.selectUserById(userId);
|
|
|
Student student = new Student();
|
|
|
// todo:用户角色判断。
|
|
|
// 屏蔽密码
|
|
|
if (Objects.nonNull(sysUser)) {
|
|
|
- sysUser.setPassword("");
|
|
|
BeanUtils.copyProperties(sysUser, student);
|
|
|
Major m = getMajorByDeptId(sysUser.getDeptId());
|
|
|
if (Objects.nonNull(m)) {
|
|
@@ -159,6 +157,27 @@ public class StudentService {
|
|
|
return student;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据用户编号获取详细信息
|
|
|
+ */
|
|
|
+ @GetMapping(value = {"/", "/{userId}"})
|
|
|
+ public AjaxResult getInfo(Long userId) {
|
|
|
+ // 不校验数据权限
|
|
|
+ // userService.checkUserDataScope(userId);
|
|
|
+
|
|
|
+ AjaxResult ajax = AjaxResult.success();
|
|
|
+ List<SysRole> roles = roleService.selectRoleAll();
|
|
|
+ ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
|
|
+ ajax.put("posts", postService.selectPostAll());
|
|
|
+ if (StringUtils.isNotNull(userId)) {
|
|
|
+ SysUser sysUser = userService.selectUserById(userId);
|
|
|
+ ajax.put(AjaxResult.DATA_TAG, sysUser);
|
|
|
+ ajax.put("postIds", postService.selectPostListByUserId(userId));
|
|
|
+ ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ return ajax;
|
|
|
+ }
|
|
|
+
|
|
|
public Major getMajorByDeptId(Long deptId) {
|
|
|
AddOnDept a = addOnDeptService.selectAddOnDeptByDeptId(deptId);
|
|
|
Major m = null;
|