feat:用户绑定

new-rd20250506
wangxy 1 month ago
parent 99b1fefcd5
commit 055bc7d942

@ -5,11 +5,7 @@ import java.util.stream.Collectors;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.extra.pinyin.PinyinUtil;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.system.domain.UserCheckDTO;
import com.ruoyi.system.service.*;
import com.ruoyi.web.controller.manager.UserRecordManager;
import lombok.val;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
@ -35,6 +31,10 @@ import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.shiro.service.SysPasswordService;
import com.ruoyi.framework.shiro.util.AuthorizationUtils;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.ISysPostService;
import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService;
/**
*
@ -65,9 +65,6 @@ public class SysUserController extends BaseController {
@Autowired
private UserRecordManager userRecordManager;
@Autowired
private ISysDictDataService dictDataService;
@RequiresPermissions("system:user:view")
@GetMapping()
public String user() {
@ -137,15 +134,6 @@ public class SysUserController extends BaseController {
} else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) {
return error("新增用户'" + user.getLoginName() + "'失败,邮箱账号已存在");
}
List<SysDictData> smType = dictDataService.selectDictDataByType("sys_role_key");
UserCheckDTO userCheckDTO = new UserCheckDTO();
userCheckDTO.setDeptId(user.getDeptId());
userCheckDTO.setRoleId(user.getRoleIds()[0]);
userCheckDTO.setRoleKey(smType.get(0).getDictValue());
int total = userService.checkUser(userCheckDTO);
if(total>=1){
return error("新增用户'" + user.getLoginName() + "'在当前部门该角色下账号已存在,不能重复新增");
}
user.setSalt(ShiroUtils.randomSalt());
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
user.setCreateBy(getLoginName());
@ -215,6 +203,38 @@ public class SysUserController extends BaseController {
return error();
}
/**
* resetUeky
* @param userId
* @param mmap
* @return
*/
//@RequiresPermissions("system:user:resetUeky")
@GetMapping("/resetUeky/{userId}")
public String resetUeky(@PathVariable("userId") Long userId, ModelMap mmap) {
mmap.put("user", userService.selectUserById(userId));
return prefix + "/resetUeky";
}
/**
* resetUeky
* @param user
* @return
*/
//@RequiresPermissions("system:user:resetUeky")
@Log(title = "UKey绑定", businessType = BusinessType.RESET)
@PostMapping("/resetUekySave")
@ResponseBody
public AjaxResult resetUekySave(SysUser user) {
boolean update = userService.lambdaUpdate()
.eq(SysUser::getUserId, user.getUserId())
.set(SysUser::getUkeyId, user.getUkeyId())
.update();
if (update) {
return success();
}
return error();
}
/**
*
*/
@ -372,11 +392,4 @@ public class SysUserController extends BaseController {
}
@PostMapping("/checkUser")
@ResponseBody
public AjaxResult checkUser(UserCheckDTO userCheckDTO) {
return success(userService.checkUser(userCheckDTO));
}
}

@ -72,7 +72,7 @@
</ul>
</li>
<li th:if="${demoEnabled}">
<!-- <a href="#"><i class="fa fa-desktop"></i><span class="nav-label">实例演示</span><span class="fa arrow"></span></a>-->
<!-- <a href="#"><i class="fa fa-desktop"></i><span class="nav-label">实例演示</span><span class="fa arrow"></span></a>-->
<ul class="nav nav-second-level collapse">
<li> <a>表单<span class="fa arrow"></span></a>
<ul class="nav nav-third-level">
@ -193,7 +193,7 @@
</a>
</div>
<ul class="nav navbar-top-links navbar-right welcome-message">
<!-- <li><a data-toggle="tooltip" data-trigger="hover" data-placement="bottom" title="开发文档" href="http://doc.ruoyi.vip/ruoyi" target="_blank"><i class="fa fa-question-circle"></i> 文档</a></li>-->
<!-- <li><a data-toggle="tooltip" data-trigger="hover" data-placement="bottom" title="开发文档" href="http://doc.ruoyi.vip/ruoyi" target="_blank"><i class="fa fa-question-circle"></i> 文档</a></li>-->
<li><a data-toggle="tooltip" data-trigger="hover" data-placement="bottom" title="锁定屏幕" href="#" id="lockScreen"><i class="fa fa-lock"></i> 锁屏</a></li>
<li><a data-toggle="tooltip" data-trigger="hover" data-placement="bottom" title="全屏显示" href="#" id="fullScreen"><i class="fa fa-arrows-alt"></i> 全屏</a></li>
<li class="dropdown user-menu">
@ -210,6 +210,10 @@
<a onclick="resetPwd()">
<i class="fa fa-key"></i> 修改密码</a>
</li>
<li>
<a onclick="resetUeky()">
<i class="fa fa-key"></i> UKey绑定</a>
</li>
<li>
<a onclick="switchSkin()">
<i class="fa fa-dashboard"></i> 切换主题</a>
@ -269,36 +273,44 @@
<script th:src="@{/ruoyi/index.js?v=20201208}"></script>
<script th:src="@{/ajax/libs/fullscreen/jquery.fullscreen.js}"></script>
<script th:inline="javascript">
window.history.forward(1);
var ctx = [[@{/}]];
var lockscreen = [[${session.lockscreen}]];
if(lockscreen){window.top.location=ctx+"lockscreen";}
// 皮肤缓存
var skin = storage.get("skin");
// history表示去掉地址的#)否则地址以"#"形式展示
var mode = "history";
// 历史访问路径缓存
var historyPath = storage.get("historyPath");
// 是否页签与菜单联动
var isLinkage = true;
window.history.forward(1);
var ctx = [[@{/}]];
var lockscreen = [[${session.lockscreen}]];
if(lockscreen){window.top.location=ctx+"lockscreen";}
// 皮肤缓存
var skin = storage.get("skin");
// history表示去掉地址的#)否则地址以"#"形式展示
var mode = "history";
// 历史访问路径缓存
var historyPath = storage.get("historyPath");
// 是否页签与菜单联动
var isLinkage = true;
// 本地主题优先,未设置取系统配置
if($.common.isNotEmpty(skin)){
// 本地主题优先,未设置取系统配置
if($.common.isNotEmpty(skin)){
$("body").addClass(skin.split('|')[0]);
$("body").addClass(skin.split('|')[1]);
} else {
} else {
$("body").addClass([[${sideTheme}]]);
$("body").addClass([[${skinName}]]);
}
}
/* 用户管理-重置密码 */
function resetPwd() {
/* 用户管理-重置密码 */
function resetPwd() {
var url = ctx + 'system/user/profile/resetPwd';
$.modal.open("重置密码", url, '770', '380');
}
}
/* 切换主题 */
function switchSkin() {
/* 用户管理-UKey绑定 */
function resetUeky() {
var prefix = ctx + "system/user";
var userId = [[${user.userId}]];
var url = prefix + '/resetUeky/' + userId;
$.modal.open("UKey绑定", url, '770', '380');
}
/* 切换主题 */
function switchSkin() {
layer.open({
type : 2,
shadeClose : true,
@ -306,26 +318,26 @@ function switchSkin() {
area : ["530px", "386px"],
content : [ctx + "system/switchSkin", 'no']
})
}
}
/* 切换菜单 */
function toggleMenu() {
/* 切换菜单 */
function toggleMenu() {
$.modal.confirm("确认要切换成横向菜单吗?", function() {
$.get(ctx + 'system/menuStyle/topnav', function(result) {
window.location.reload();
});
})
}
}
/** 刷新时访问路径页签 */
function applyPath(url) {
/** 刷新时访问路径页签 */
function applyPath(url) {
$('a[href$="' + decodeURI(url) + '"]').click();
if (!$('a[href$="' + url + '"]').hasClass("noactive")) {
$('a[href$="' + url + '"]').parent("li").addClass("selected").parents("li").addClass("active").end().parents("ul").addClass("in");
}
}
}
$(function() {
$(function() {
var lockPath = storage.get('lockPath');
if($.common.equals("history", mode) && window.performance.navigation.type == 1) {
var url = storage.get('publicPath');
@ -373,7 +385,7 @@ $(function() {
});
}
$("[data-toggle='tooltip']").tooltip();
});
});
</script>
</body>
</html>

@ -0,0 +1,98 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('UKey绑定')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-user-ukey">
<input name="userId" type="hidden" th:value="${user.userId}" />
<div class="form-group">
<label class="col-sm-3 control-label is-required">请选择证书:</label>
<div class="col-sm-8">
<select class="form-control" id="id_cert_list" required onchange="select_cert(this.value)">
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">选择设备序列号:</label>
<div class="col-sm-8">
<select class="form-control" id="id_device_list" required onchange="select_device(this.value)">
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">设备序列号:</label>
<div class="col-sm-8">
<input class="form-control" type="text" required readonly id="id_selected_device_sn">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">选择的证书ID</label>
<div class="col-sm-8">
<input class="form-control" type="text" required readonly id="id_selected_cert_id" name="ukeyId" th:value="${user.ukeyId}">
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<script th:src="@{/ruoyi/xtxasyn.js}"></script>
<script type="text/javascript">
function customFireEvent(objId, eventName) {
var obj = document.getElementById(objId);
if (obj == undefined) {
return;
}
if (obj.fireEvent) {
obj.fireEvent("on" + eventName);
} else if (obj.dispatchEvent) {
var e = document.createEvent('HTMLEvents');
e.initEvent(eventName, false, false);
obj.dispatchEvent(e);
}
}
function FillDeviceList() {
GetAllDeviceSN(function (retObj) {
var obj = document.getElementById("id_device_list");
if (obj == undefined) {
return;
}
var i, n = obj.length;
for (i = 0; i < n; i++) {
obj.remove(0);
}
var strDeviceList = retObj.retVal;
while (true) {
var pos = strDeviceList.indexOf(";");
if (pos <= 0) {
break;
}
var strOneDevice = strDeviceList.substring(0, pos);
var objItem = new Option(strOneDevice, strOneDevice);
obj.options.add(objItem);
var len = strDeviceList.length;
strDeviceList = strDeviceList.substring(pos + 1, len);
}
customFireEvent('id_cert_list', 'change');
customFireEvent('id_device_list', 'change');
});
}
function select_cert(value) {
$("#id_selected_cert_id").val(value);
}
function select_device(value) {
$("#id_selected_device_sn").val(value);
}
SetUserCertList("id_cert_list");
FillDeviceList();
SetOnUsbKeyChangeCallBack(FillDeviceList);
function submitHandler() {
if ($.validate.form()) {
$.operate.save(ctx + "system/user/resetUekySave", $('#form-user-ukey').serialize());
}
}
</script>
</body>
</html>
Loading…
Cancel
Save