From 2c7d8b680f331496ded31050bb9350061e9af424 Mon Sep 17 00:00:00 2001 From: hayu <1604366271@qq.com> Date: Mon, 29 Jul 2024 15:12:35 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E3=80=81=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/controller/UserController.java | 18 ++++++-- .../com/bonus/aqgqj/system/dao/UserDao.java | 26 ++++++++++++ .../aqgqj/system/service/UserService.java | 26 ++++++++++++ .../system/service/impl/UserServiceImpl.java | 6 +++ .../resources/mappers/system/UserMapper.xml | 42 +++++++++++++++---- .../resources/static/js/samples/samplesMge.js | 2 +- .../static/js/system/child/userForm.js | 2 +- .../static/js/system/child/userFormTemp.js | 33 ++++++++++++--- .../resources/static/pages/role/addRole.html | 17 ++++---- .../static/pages/user/child/userFormTemp.html | 16 +++---- 10 files changed, 151 insertions(+), 37 deletions(-) diff --git a/src/main/java/com/bonus/aqgqj/system/controller/UserController.java b/src/main/java/com/bonus/aqgqj/system/controller/UserController.java index 14cc7b3..3136dbc 100644 --- a/src/main/java/com/bonus/aqgqj/system/controller/UserController.java +++ b/src/main/java/com/bonus/aqgqj/system/controller/UserController.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Objects; import com.bonus.aqgqj.annotation.DecryptAndVerify; +import com.bonus.aqgqj.model.Role; import com.bonus.aqgqj.system.dao.UserDao; import com.bonus.aqgqj.system.vo.EncryptedReq; import com.bonus.aqgqj.system.vo.Org; @@ -96,10 +97,6 @@ public class UserController { if (u != null) { return ServerResponse.createErroe("登录名"+data.getData().getLoginName() + "已存在"); } - SysUser u3 = userService.getUserCode(data.getData().getUserCode()); - if(u3 != null){ - return ServerResponse.createErroe("工号"+data.getData().getUserCode() + "已存在"); - } if(StringHelper.isNotEmpty(data.getData().getPhone())){ SysUser u2 = userService.getPhone(data.getData().getPhone()); if (u2 != null) { @@ -305,4 +302,17 @@ public class UserController { return userService.getOrgTree(); } + @PostMapping(value = "getRoleAll") + @LogAnnotation(operModul = "用户管理", operation = "查询所有角色", operDesc = "系统级事件",operType="查询") + @PreAuthorize("@pms.hasPermission('sys:role:query')" ) + public ServerResponse getAll() { + try { + List list = userService.getRoleAll(); + return ServerResponse.createSuccess(list); + }catch (Exception e){ + log.error(e.toString(),e); + } + return ServerResponse.createErroe("操作失败"); + } + } diff --git a/src/main/java/com/bonus/aqgqj/system/dao/UserDao.java b/src/main/java/com/bonus/aqgqj/system/dao/UserDao.java index 278cbbc..dcd1f40 100644 --- a/src/main/java/com/bonus/aqgqj/system/dao/UserDao.java +++ b/src/main/java/com/bonus/aqgqj/system/dao/UserDao.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Map; import com.bonus.aqgqj.base.entity.DtreeVo; +import com.bonus.aqgqj.model.Role; import com.bonus.aqgqj.system.vo.LoginUser; import com.bonus.aqgqj.system.vo.Org; import com.bonus.aqgqj.system.vo.UserDto; @@ -32,8 +33,18 @@ public interface UserDao { */ UserDto getById(Long id); + /** + * 根据用户名查询用户 + * @param username + * @return + */ SysUser getUser(String username); + /** + * 根据工号查询用户 + * @param userCode + * @return + */ SysUser getUserCode(String userCode); @Update("update sys_user t set t.password = #{password} where t.id = #{id}") @@ -66,8 +77,17 @@ public interface UserDao { int delUser(Long id); + /** + * 查询组织机构 + * @return + */ List getOrg(); + /** + * 根据手机号查询用户 + * @param phone + * @return + */ SysUser getPhone(String phone); @@ -98,4 +118,10 @@ public interface UserDao { * @return */ int updateEnableState(UserDto data); + + /** + * 查询所有角色--不包含关闭状态角色 + * @return + */ + List getRoleAll(); } diff --git a/src/main/java/com/bonus/aqgqj/system/service/UserService.java b/src/main/java/com/bonus/aqgqj/system/service/UserService.java index c143180..250e99d 100644 --- a/src/main/java/com/bonus/aqgqj/system/service/UserService.java +++ b/src/main/java/com/bonus/aqgqj/system/service/UserService.java @@ -1,5 +1,6 @@ package com.bonus.aqgqj.system.service; +import com.bonus.aqgqj.model.Role; import com.bonus.aqgqj.system.vo.Org; import com.bonus.aqgqj.system.vo.UserDto; import com.bonus.aqgqj.model.PasswordConfig; @@ -25,8 +26,18 @@ public interface UserService { */ SysUser updateUser(UserDto userDto); + /** + * 根据用户名查询用户 + * @param loginName + * @return + */ SysUser getUser(String loginName); + /** + * 根据工号查询用户 + * @param userCode + * @return + */ SysUser getUserCode(String userCode); ServerResponse changePassword(SysUser user); @@ -53,8 +64,17 @@ public interface UserService { PasswordConfig getPasswordConfigById(); + /** + * 查询组织机构 + * @return + */ List getOrg(); + /** + * 根据手机号查询用户 + * @param phone + * @return + */ SysUser getPhone(String phone); List getLockUser(String state,String type); @@ -78,4 +98,10 @@ public interface UserService { * @return */ ServerResponse updateEnableState(UserDto data); + + /** + * 查询角色--不包含关闭状态角色 + * @return + */ + List getRoleAll(); } diff --git a/src/main/java/com/bonus/aqgqj/system/service/impl/UserServiceImpl.java b/src/main/java/com/bonus/aqgqj/system/service/impl/UserServiceImpl.java index 1cd60a8..7a5c280 100644 --- a/src/main/java/com/bonus/aqgqj/system/service/impl/UserServiceImpl.java +++ b/src/main/java/com/bonus/aqgqj/system/service/impl/UserServiceImpl.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Map; import com.bonus.aqgqj.base.entity.DtreeVo; +import com.bonus.aqgqj.model.Role; import com.bonus.aqgqj.system.vo.Org; import com.bonus.aqgqj.model.PasswordConfig; import com.bonus.aqgqj.utils.ServerResponse; @@ -213,6 +214,11 @@ public class UserServiceImpl implements UserService { return ServerResponse.createErroe("参数异常,请联系管理员"); } + @Override + public List getRoleAll() { + return userDao.getRoleAll(); + } + /** * 修改用户 */ diff --git a/src/main/resources/mappers/system/UserMapper.xml b/src/main/resources/mappers/system/UserMapper.xml index bac8297..d3640cb 100644 --- a/src/main/resources/mappers/system/UserMapper.xml +++ b/src/main/resources/mappers/system/UserMapper.xml @@ -42,13 +42,21 @@ - insert into sys_user(login_name, user_name, user_code, sex, org_id,login_type, role_id, phone, user_type, state, + insert into sys_user(login_name, user_name, + + user_code, + + sex, org_id,login_type, role_id, phone, user_type, state, password, team_id, create_time) - values (#{loginName}, #{username}, #{userCode}, #{sex}, #{orgId},#{loginType}, #{roleId}, #{phone}, #{userType}, + values (#{loginName}, #{username}, + + #{userCode}, + + #{sex}, #{orgId},#{loginType}, #{roleId}, #{phone}, #{userType}, #{state}, #{password}, @@ -64,15 +72,25 @@ from sys_user t LEFT JOIN sys_role sr ON t.role_id = sr.role_id AND sr.del_flag = 0 where t.login_name = #{username} + and t.del_flag = 0 @@ -177,6 +195,7 @@ select id,phone from sys_user where phone = #{phone} + and del_flag = 0 + insert into sys_role_user(roleId, userId) values @@ -205,7 +231,9 @@ t.phone = #{phone}, t.user_type = #{userType}, t.login_type = #{loginType}, - t.team_id = #{teamId}, + + t.team_id = #{teamId}, + t.state = #{state}, t.update_time = now() where t.id = #{id} diff --git a/src/main/resources/static/js/samples/samplesMge.js b/src/main/resources/static/js/samples/samplesMge.js index 11a1d5e..3f60dac 100644 --- a/src/main/resources/static/js/samples/samplesMge.js +++ b/src/main/resources/static/js/samples/samplesMge.js @@ -121,7 +121,7 @@ function initTable(dataList, limit, page) { if (d.teamName == null) { view = "未派工"; } else { - view = `${d.teamName}`; + view = `${d.teamName}`; } return view; } diff --git a/src/main/resources/static/js/system/child/userForm.js b/src/main/resources/static/js/system/child/userForm.js index 83dc2ff..d120c39 100644 --- a/src/main/resources/static/js/system/child/userForm.js +++ b/src/main/resources/static/js/system/child/userForm.js @@ -67,7 +67,7 @@ function setParams(params) { * 获取角色数据 */ function getRoleSelected() { - let url = dataUrl + '/roles/all'; + let url = dataUrl + '/users/getRoleAll'; ajaxRequest(url, "POST", null, false, function () { }, function (result) { if (result.code === 200) { diff --git a/src/main/resources/static/js/system/child/userFormTemp.js b/src/main/resources/static/js/system/child/userFormTemp.js index 7871db5..6b8889b 100644 --- a/src/main/resources/static/js/system/child/userFormTemp.js +++ b/src/main/resources/static/js/system/child/userFormTemp.js @@ -6,10 +6,6 @@ let data = [], appResList = []; let roleList; let orgData; let teamList; -// showDictSelect("orgId", "org_id"); -// showDictSelect("sex", "sex"); -// showDictSelect("unit", "unit"); -// showDictSelect("dept", "dept"); function setParams(params) { console.log(params) idParam = JSON.parse(params).id; @@ -44,6 +40,9 @@ function setParams(params) { return layer.alert("请输入正确的手机号", {icon: 2}) } } + if (!validatePassword(data.field.password)){ + return layer.alert("密码必须包含大、小写字母 、数字、 特殊字符四种里至少三种,且密码长度不低于8位", {icon: 2}) + } saveData(data); }); @@ -67,11 +66,33 @@ function setParams(params) { } +/** + * 校验密码 + */ +function validatePassword(password) { + console.log("password:",password) + // 定义正则表达式来检测不同的字符类型 + const hasUpperCase = /[A-Z]/.test(password); + const hasLowerCase = /[a-z]/.test(password); + const hasDigit = /\d/.test(password); + const hasSpecialChar = /[!@#$%^&*(),.?":{}|<>]/.test(password); + + // 检查密码长度 + const isLengthValid = password.length >= 8; + + // 计算符合要求的字符类型数量 + const typesCount = [hasUpperCase, hasLowerCase, hasDigit, hasSpecialChar].filter(Boolean).length; + console.log("typesCount:",typesCount) + + // 验证密码:长度合法且包含至少三种字符类型 + return isLengthValid && typesCount >= 3; +} + /** * 获取角色数据 */ function getRoleSelected() { - let url = dataUrl + '/roles/all'; + let url = dataUrl + '/users/getRoleAll'; ajaxRequest(url, "POST", null, true, function () { }, function (result) { if (result.code === 200) { @@ -88,7 +109,7 @@ function getRoleSelected() { * 获取班组数据 */ function getTeamSelected() { - let url = dataUrl + '/samples/getTeamSelected'; + let url = dataUrl + '/testReport/getTeamSelected'; ajaxRequest(url, "POST", null, true, function () { }, function (result) { if (result.code === 200) { diff --git a/src/main/resources/static/pages/role/addRole.html b/src/main/resources/static/pages/role/addRole.html index 446788b..28cfa50 100644 --- a/src/main/resources/static/pages/role/addRole.html +++ b/src/main/resources/static/pages/role/addRole.html @@ -102,7 +102,7 @@ form.render(); form.verify(); form.on('submit(formData)', function (data) { - saveData(); + saveData(data); }); }); $.fn.zTree.init($("#treeDemo"), getSettting(), getMenuTree()); @@ -152,16 +152,13 @@ function save() { $('#formSubmit').trigger('click') } - $('#form').bootstrapValidator(); - - function saveData() { - var bootstrapValidator = $("#form").data('bootstrapValidator'); - bootstrapValidator.validate(); - if(!bootstrapValidator.isValid()){ - return; - } - var formdata = $("#form").serializeObject(); + + function saveData(data) { + var formdata = data.field; formdata.permissionIds = getCheckedMenuIds(); + if (!formdata.orgId_select_nodeId){ + return layer.alert("请选择上级组织!", {icon: 2}) + } formdata.orgId=formdata.orgId_select_nodeId; console.log(formdata) var params={ diff --git a/src/main/resources/static/pages/user/child/userFormTemp.html b/src/main/resources/static/pages/user/child/userFormTemp.html index fbb584c..d6251b1 100644 --- a/src/main/resources/static/pages/user/child/userFormTemp.html +++ b/src/main/resources/static/pages/user/child/userFormTemp.html @@ -59,13 +59,13 @@ -
- -
- -
-
+ + + + + + +
@@ -114,7 +114,7 @@
+ lay-verify="required" maxlength="15">