推送项目重构代码
This commit is contained in:
@@ -55,6 +55,7 @@ public class SysUserController extends BaseController {
|
||||
private final ISysRoleService roleService;
|
||||
private final ISysPostService postService;
|
||||
private final ISysDeptService deptService;
|
||||
private final com.ruoyi.oa.im.ImSendService imSendService;
|
||||
|
||||
/**
|
||||
* 获取用户列表
|
||||
@@ -156,7 +157,12 @@ public class SysUserController extends BaseController {
|
||||
return R.fail("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
}
|
||||
user.setPassword(BCrypt.hashpw(user.getPassword()));
|
||||
return toAjax(userService.insertUser(user));
|
||||
int rows = userService.insertUser(user);
|
||||
if (rows > 0 && StringUtils.isNotEmpty(user.getPhonenumber())) {
|
||||
imSendService.bindOrRegister(user.getUserId(), user.getPhonenumber(),
|
||||
StringUtils.isNotEmpty(user.getNickName()) ? user.getNickName() : user.getUserName());
|
||||
}
|
||||
return toAjax(rows);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckRole;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.system.service.ISysUserDashboardService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户工作台布局
|
||||
*
|
||||
* @author wangyu
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/system/user/dashboard")
|
||||
public class SysUserDashboardController extends BaseController {
|
||||
|
||||
private final ISysUserDashboardService dashboardService;
|
||||
|
||||
/** 获取当前用户的工作台布局 */
|
||||
@GetMapping
|
||||
public R<Map<String, Object>> getLayout() {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
Map<String, Object> data = new HashMap<>(2);
|
||||
data.put("layout", dashboardService.getLayout(userId));
|
||||
return R.ok(data);
|
||||
}
|
||||
|
||||
/** 保存当前用户的工作台布局 */
|
||||
@PutMapping
|
||||
public R<Void> saveLayout(@RequestBody @NotNull LayoutBody body) {
|
||||
dashboardService.saveLayout(LoginHelper.getUserId(), body.getLayout());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/** 重置当前用户的工作台为默认布局 */
|
||||
@PostMapping("/reset")
|
||||
public R<Void> resetLayout() {
|
||||
dashboardService.resetLayout(LoginHelper.getUserId());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/** 管理员:保存系统默认工作台布局(影响所有未自定义的用户) */
|
||||
@SaCheckRole("admin")
|
||||
@PutMapping("/default")
|
||||
public R<Void> saveDefault(@RequestBody @NotNull LayoutBody body) {
|
||||
dashboardService.saveDefaultLayout(body.getLayout());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
public static class LayoutBody {
|
||||
private String layout;
|
||||
public String getLayout() { return layout; }
|
||||
public void setLayout(String layout) { this.layout = layout; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user