|
|
@@ -1,11 +1,14 @@
|
|
|
package com.railway.web.controller.system;
|
|
|
|
|
|
import com.railway.common.annotation.Log;
|
|
|
+import com.railway.common.constant.Constants;
|
|
|
import com.railway.common.core.controller.BaseController;
|
|
|
import com.railway.common.core.domain.AjaxResult;
|
|
|
import com.railway.common.core.domain.entity.SysRole;
|
|
|
import com.railway.common.core.domain.entity.SysUser;
|
|
|
import com.railway.common.core.domain.model.LoginUser;
|
|
|
+import com.railway.common.core.page.TableDataInfo;
|
|
|
+import com.railway.common.core.redis.RedisCache;
|
|
|
import com.railway.common.enums.BusinessType;
|
|
|
import com.railway.common.utils.SecurityUtils;
|
|
|
import com.railway.common.utils.StringUtils;
|
|
|
@@ -15,8 +18,11 @@ import com.railway.system.service.ISysRoleService;
|
|
|
import com.railway.system.service.ISysUserService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
@@ -39,14 +45,16 @@ public class SysProfileController extends BaseController {
|
|
|
private final ISysRoleService roleService;
|
|
|
private final TokenService tokenService;
|
|
|
private final ISysFileService sysFileService;
|
|
|
+ private final RedisCache redisCache;
|
|
|
|
|
|
public SysProfileController(ISysUserService userService,
|
|
|
ISysRoleService roleService, TokenService tokenService,
|
|
|
- ISysFileService sysFileService) {
|
|
|
+ ISysFileService sysFileService, RedisCache redisCache) {
|
|
|
this.userService = userService;
|
|
|
this.roleService = roleService;
|
|
|
this.tokenService = tokenService;
|
|
|
this.sysFileService = sysFileService;
|
|
|
+ this.redisCache = redisCache;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -67,6 +75,43 @@ public class SysProfileController extends BaseController {
|
|
|
return ajax;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取用户所选要查看数据的车间
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "获取用户所选要查看数据的车间", response = TableDataInfo.class)
|
|
|
+ @GetMapping("/getSelectedDept")
|
|
|
+ public AjaxResult getSelectedDept() {
|
|
|
+ LoginUser loginUser = getLoginUser();
|
|
|
+ List<Long> deptIds = redisCache.getCacheList(getCacheKey(loginUser.getUserId()));
|
|
|
+ AjaxResult ajax = AjaxResult.success();
|
|
|
+ if(CollectionUtils.isNotEmpty(deptIds)) {
|
|
|
+ ajax.put("selectedDeptIds", deptIds);
|
|
|
+ }
|
|
|
+ return ajax;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新用户所选要查看数据的车间
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "更新用户所选要查看数据的车间", response = AjaxResult.class)
|
|
|
+ @Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
|
|
+ @PutMapping("/putSelectedDept/{userIds}")
|
|
|
+ public AjaxResult putSelectedDept(@PathVariable Long[] userIds) {
|
|
|
+ LoginUser loginUser = getLoginUser();
|
|
|
+ redisCache.setCacheList(getCacheKey(loginUser.getUserId()), Arrays.asList(userIds));
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置cache key
|
|
|
+ *
|
|
|
+ * @param configKey 参数键
|
|
|
+ * @return 缓存键key
|
|
|
+ */
|
|
|
+ private String getCacheKey(Long configKey) {
|
|
|
+ return Constants.LEADER_VIEW_DEPT_KEY + configKey;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 修改用户
|
|
|
*/
|