用户、角色问题修改
This commit is contained in:
parent
b95d1a4750
commit
2c7d8b680f
|
|
@ -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<Role> list = userService.getRoleAll();
|
||||
return ServerResponse.createSuccess(list);
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return ServerResponse.createErroe("操作失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Org> getOrg();
|
||||
|
||||
/**
|
||||
* 根据手机号查询用户
|
||||
* @param phone
|
||||
* @return
|
||||
*/
|
||||
SysUser getPhone(String phone);
|
||||
|
||||
|
||||
|
|
@ -98,4 +118,10 @@ public interface UserDao {
|
|||
* @return
|
||||
*/
|
||||
int updateEnableState(UserDto data);
|
||||
|
||||
/**
|
||||
* 查询所有角色--不包含关闭状态角色
|
||||
* @return
|
||||
*/
|
||||
List<Role> getRoleAll();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Org> getOrg();
|
||||
|
||||
/**
|
||||
* 根据手机号查询用户
|
||||
* @param phone
|
||||
* @return
|
||||
*/
|
||||
SysUser getPhone(String phone);
|
||||
|
||||
List<SysUser> getLockUser(String state,String type);
|
||||
|
|
@ -78,4 +98,10 @@ public interface UserService {
|
|||
* @return
|
||||
*/
|
||||
ServerResponse updateEnableState(UserDto data);
|
||||
|
||||
/**
|
||||
* 查询角色--不包含关闭状态角色
|
||||
* @return
|
||||
*/
|
||||
List<Role> getRoleAll();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Role> getRoleAll() {
|
||||
return userDao.getRoleAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -42,13 +42,21 @@
|
|||
</select>
|
||||
<!--新增用户-->
|
||||
<insert id="saveUser" parameterType="com.bonus.aqgqj.model.SysUser" >
|
||||
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,
|
||||
<if test="userCode != null and userCode != ''">
|
||||
user_code,
|
||||
</if>
|
||||
sex, org_id,login_type, role_id, phone, user_type, state,
|
||||
password,
|
||||
<if test="teamId != null and teamId != ''">
|
||||
team_id,
|
||||
</if>
|
||||
create_time)
|
||||
values (#{loginName}, #{username}, #{userCode}, #{sex}, #{orgId},#{loginType}, #{roleId}, #{phone}, #{userType},
|
||||
values (#{loginName}, #{username},
|
||||
<if test="userCode != null and userCode != ''">
|
||||
#{userCode},
|
||||
</if>
|
||||
#{sex}, #{orgId},#{loginType}, #{roleId}, #{phone}, #{userType},
|
||||
#{state},
|
||||
#{password},
|
||||
<if test="teamId != null and teamId != ''">
|
||||
|
|
@ -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
|
||||
</select>
|
||||
|
||||
<select id="getUserCode" parameterType="String" resultType="com.bonus.aqgqj.model.SysUser">
|
||||
select t.id,t.user_name as username,t.login_name as loginName,
|
||||
t.password,t.state,t.role_id as roleId,t.login_type loginType,t.new_user newUser,
|
||||
sr.role_code AS roleCode,sr.role_name AS roleName,t.team_id AS teamId
|
||||
select t.id,
|
||||
t.user_name as username,
|
||||
t.login_name as loginName,
|
||||
t.password,
|
||||
t.state,
|
||||
t.role_id as roleId,
|
||||
t.login_type loginType,
|
||||
t.new_user newUser,
|
||||
sr.role_code AS roleCode,
|
||||
sr.role_name AS roleName,
|
||||
t.team_id AS teamId
|
||||
from sys_user t
|
||||
LEFT JOIN sys_role sr ON t.role_id = sr.role_id AND sr.del_flag = 0
|
||||
where t.user_code = #{userCode} limit 1
|
||||
where t.user_code = #{userCode}
|
||||
and t.del_flag = 0 limit 1
|
||||
</select>
|
||||
|
||||
<sql id="where">
|
||||
|
|
@ -177,6 +195,7 @@
|
|||
select id,phone
|
||||
from sys_user
|
||||
where phone = #{phone}
|
||||
and del_flag = 0
|
||||
</select>
|
||||
<select id="getOrgTree" resultType="com.bonus.aqgqj.base.entity.DtreeVo">
|
||||
SELECT so.org_id AS id,
|
||||
|
|
@ -186,6 +205,13 @@
|
|||
WHERE so.del_flag = 0
|
||||
and so.state=1
|
||||
</select>
|
||||
<select id="getRoleAll" resultType="com.bonus.aqgqj.model.Role">
|
||||
select t.role_id as id,
|
||||
t.role_name as name
|
||||
from sys_role t
|
||||
where t.del_flag = 0
|
||||
and t.state = 1
|
||||
</select>
|
||||
|
||||
<insert id="saveUserRoles">
|
||||
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},
|
||||
<if test="teamId != null and teamId != ''">
|
||||
t.team_id = #{teamId},
|
||||
</if>
|
||||
t.state = #{state},
|
||||
t.update_time = now()
|
||||
where t.id = #{id}
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ function initTable(dataList, limit, page) {
|
|||
if (d.teamName == null) {
|
||||
view = "<a style='cursor:pointer; background: #F2F3FF;'>未派工</a>";
|
||||
} else {
|
||||
view = `<a class="ellipsis" title="${d.teamName}">${d.teamName}</a>`;
|
||||
view = `<a style='color: black;' class="ellipsis" title="${d.teamName}">${d.teamName}</a>`;
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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={
|
||||
|
|
|
|||
|
|
@ -59,13 +59,13 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" style="margin-top: 2%;">
|
||||
<label class="layui-form-label"><i style="padding: 0 10px;">*</i>工号</label>
|
||||
<div class="layui-input-inline">
|
||||
<input class="layui-input" id="UserCode" name="UserCode" autocomplete="off"
|
||||
lay-verify="required" maxlength="20">
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="layui-form-item" style="margin-top: 2%;">-->
|
||||
<!-- <label class="layui-form-label"><i style="padding: 0 10px;">*</i>工号</label>-->
|
||||
<!-- <div class="layui-input-inline">-->
|
||||
<!-- <input class="layui-input" id="userCode" name="userCode" autocomplete="off"-->
|
||||
<!-- lay-verify="required" maxlength="20">-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">班组</label>
|
||||
|
|
@ -114,7 +114,7 @@
|
|||
<label class="layui-form-label"><i style="padding: 0 10px;">*</i>密码</label>
|
||||
<div class="layui-input-inline password" >
|
||||
<input class="layui-input secret1" type="password" id="password" name="password" autocomplete="off"
|
||||
lay-verify="required" maxlength="50">
|
||||
lay-verify="required" maxlength="15">
|
||||
<span class="eyes1">
|
||||
<img class="secreteyes1 fa" src="../../../img/by.gif"> <!-- 闭眼 -->
|
||||
<img class="secreteyesk1 none fa" src="../../../img/ky.gif">
|
||||
|
|
|
|||
Loading…
Reference in New Issue