Merge branch 'feature/sso_function_v1205' of http://121.40.234.130:8899/root/lanzhouhailiang_one into feature/sso_function_v1205

This commit is contained in:
2022-12-07 15:56:27 +08:00
17 changed files with 257 additions and 52 deletions

View File

@@ -1,7 +1,7 @@
1.数据库数据同步
sys_dept,sys_dict,sys_dict_detail,sys_param,
sys_role,sys_users_roles,sys_menus,sys_role_menus,
sys_user,sys_user_dept
sys_user(自增),sys_user_dept,
代码移动至sso包下
2.前端移动模块包括:用户,角色,菜单,部门,字典 paramgrid ,登入页面

View File

@@ -19,11 +19,14 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.nl.sso.base.BaseDto;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* @author Zheng Jie
@@ -38,15 +41,12 @@ public class User extends BaseDto implements Serializable {
private Long id;
private Long user_id;
@JsonFormat
private String roles;
private String depts;
private String username;
private List<Long> roles;
private List<Long> depts;
private String person_name;

View File

@@ -0,0 +1,100 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.nl.sso.system.domain.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.nl.sso.base.BaseDto;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author Zheng Jie
* @date 2018-11-22
*/
@Getter
@Setter
public class UserVo extends BaseDto implements Serializable {
@ApiModelProperty(value = "ID", hidden = true)
private Long id;
private Long user_id;
private List<Long> roles;
private List<Long> depts;
private String deptnames;
private String username;
private String person_name;
@ApiModelProperty(value = "邮箱")
private String email;
@ApiModelProperty(value = "电话号码")
private String phone;
@ApiModelProperty(value = "用户性别")
private String gender;
@ApiModelProperty(value = "头像真实名称",hidden = true)
private String avatarName;
@ApiModelProperty(value = "头像存储的路径", hidden = true)
private String avatarPath;
@ApiModelProperty(value = "密码")
private String password;
@NotNull
@ApiModelProperty(value = "是否启用")
private String is_used;
@ApiModelProperty(value = "是否为admin账号", hidden = true)
private Boolean isAdmin = false;
@ApiModelProperty(value = "最后修改密码的时间", hidden = true)
private Date pwdResetTime;
public void setRoles(String roles) {
if (StringUtils.isNotEmpty(roles)){
String[] split = roles.split(",");
this.roles = Arrays.stream(split).map(a->Long.valueOf(a)).collect(Collectors.toList());
}
}
public void setDepts(String depts) {
if (StringUtils.isNotEmpty(depts)){
String[] split = depts.split(",");
this.depts = Arrays.stream(split).map(a->Long.valueOf(a)).collect(Collectors.toList());
}
}
}

View File

@@ -38,6 +38,12 @@ public class RoleController {
return new ResponseEntity<>(roleService.queryAll(criteria, pageable), HttpStatus.OK);
}
@ApiOperation("查询所有角色")
@GetMapping("/all")
public ResponseEntity<Object> query() {
return new ResponseEntity<>(roleService.queryAll(), HttpStatus.OK);
}
@Log("新增角色")
@ApiOperation("新增角色")

View File

@@ -15,8 +15,10 @@
*/
package org.nl.sso.system.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.nl.sso.system.domain.vo.RoleVo;
import org.springframework.data.domain.Pageable;
import java.util.List;
@@ -37,6 +39,8 @@ public interface RoleService {
*/
JSONObject queryAll(Map whereJson, Pageable page);
List<RoleVo> queryAll();
/**
* 创建
* @param form /

View File

@@ -16,6 +16,7 @@
package org.nl.sso.system.service;
import org.nl.sso.system.domain.User;
import org.nl.sso.system.domain.vo.UserVo;
import org.nl.sso.system.service.dto.UserQueryCriteria;
import org.springframework.data.domain.Pageable;
import org.springframework.web.multipart.MultipartFile;
@@ -96,7 +97,7 @@ public interface UserService {
* @param criteria 条件
* @return /
*/
List<User> queryAll(UserQueryCriteria criteria);
List<UserVo> queryAll(UserQueryCriteria criteria);
/**

View File

@@ -23,6 +23,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.sso.system.domain.vo.RoleVo;
import org.nl.sso.system.service.RoleService;
import org.nl.sso.tools.IdUtil;
import org.nl.sso.tools.SecurityUtils;
@@ -44,6 +45,13 @@ import java.util.*;
@RequiredArgsConstructor
public class RoleServiceImpl implements RoleService {
@Override
public List<RoleVo> queryAll() {
JSONArray sysRoles = WQLObject.getWQLObject("sys_role").query("is_used =1 and is_delete = 0").getResultJSONArray(0);
List<RoleVo> roleVos = sysRoles.toJavaList(RoleVo.class);
return roleVos;
}
@Override
public JSONObject queryAll(Map whereJson, Pageable page) {
WQLObject wo = WQLObject.getWQLObject("sys_role");

View File

@@ -34,6 +34,7 @@ import org.nl.modules.common.utils.RedisUtils;
import org.nl.sso.security.dto.CurrentUser;
import org.nl.sso.security.service.OnlineUserService;
import org.nl.sso.system.domain.User;
import org.nl.sso.system.domain.vo.UserVo;
import org.nl.sso.system.service.DeptService;
import org.nl.sso.system.service.UserRelateService;
import org.nl.sso.system.service.UserService;
@@ -95,11 +96,14 @@ public class UserServiceImpl implements UserService {
}
map.put("flag","1");
JSONObject jsonObject = WQL.getWO("SYS_USER").addParamMap(map).pageQuery(WqlUtil.getHttpContext(pageable),"user_id desc");
JSONArray array = (JSONArray) jsonObject.get("content");
List<UserVo> users = array.toJavaList(UserVo.class);
jsonObject.put("content",users);
return jsonObject;
}
@Override
public List<User> queryAll(UserQueryCriteria criteria) {
public List<UserVo> queryAll(UserQueryCriteria criteria) {
JSONObject o = (JSONObject)JSON.toJSON(criteria);
HashMap map = MapOf.of("user_id", MapUtil.getStr(o, "user_id")
, "blurry", MapUtil.getStr(o, "blurry")
@@ -114,7 +118,7 @@ public class UserServiceImpl implements UserService {
}
map.put("flag","1");
JSONArray array = WQL.getWO("SYS_USER").addParamMap(map).process().getResultJSONArray(0);
List<User> users = array.toJavaList(User.class);
List<UserVo> users = array.toJavaList(UserVo.class);
return users;
}
@@ -139,20 +143,13 @@ public class UserServiceImpl implements UserService {
resources.setCreate_name(user.getUsername());
ResultBean sys_user = WQLObject.getWQLObject("sys_user").insert(JSONObject.parseObject(JSON.toJSONString(resources)));
//更新用户部门表,更新用户角色表
String depts = resources.getDepts();
String roles = resources.getRoles();
List<Long> depts = resources.getDepts();
List<Long> roles = resources.getRoles();
JSONObject currentUser = WQLObject.getWQLObject("sys_user").query("username = '" + resources.getUsername() + "'").uniqueResult(0);
if (StringUtils.isNotEmpty(depts)){
String[] split = depts.split(",");
Set<Long> collect = Arrays.stream(split).map(a -> Long.valueOf(a)).collect(Collectors.toSet());
userRelateService.inserDeptRelate(currentUser.getLong("user_id"),collect);
}
if (StringUtils.isNotEmpty(roles)){
String[] split = roles.split(",");
Set<Long> collect = Arrays.stream(split).map(a -> Long.valueOf(a)).collect(Collectors.toSet());
userRelateService.inserRoleRelate(currentUser.getLong("user_id"),collect);
}
userRelateService.inserDeptRelate(currentUser.getLong("user_id"),new HashSet(depts));
userRelateService.inserRoleRelate(currentUser.getLong("user_id"),new HashSet(roles));
}
@Override
@@ -173,18 +170,12 @@ public class UserServiceImpl implements UserService {
// 清除缓存
delCaches(user.getUser_id(), user.getUsername());
//更新部门用户
String depts = resources.getDepts();
String roles = resources.getRoles();
if (StringUtils.isNotEmpty(depts)){
String[] split = depts.split(",");
Set<Long> collect = Arrays.stream(split).map(a -> Long.valueOf(a)).collect(Collectors.toSet());
userRelateService.updateDeptRelate(resources.getUser_id(),collect);
}
if (StringUtils.isNotEmpty(roles)){
String[] split = roles.split(",");
Set<Long> collect = Arrays.stream(split).map(a -> Long.valueOf(a)).collect(Collectors.toSet());
userRelateService.updateRoleRelate(resources.getUser_id(),collect);
}
List<Long> depts = resources.getDepts();
List<Long> roles = resources.getRoles();
userRelateService.updateDeptRelate(resources.getUser_id(),new HashSet(depts));
userRelateService.updateRoleRelate(resources.getUser_id(),new HashSet(roles));
// 如果用户的角色改变
if (!resources.getRoles().equals(user.getRoles())) {
redisUtils.del(CacheKey.DATA_USER + resources.getUser_id());

View File

@@ -85,7 +85,7 @@ public class WorkteamServiceImpl implements WorkteamService {
String nickName = SecurityUtils.getCurrentNickName();
String now = DateUtil.now();
CurrentUser currentUser = SecurityUtils.getCurrentUser();
String depts = currentUser.getUser().getDepts();
List<Long> depts = currentUser.getUser().getDepts();
//编码唯一性校验
String team_code = dto.getTeam_code();
@@ -99,8 +99,8 @@ public class WorkteamServiceImpl implements WorkteamService {
dto.setUpdate_optname(nickName);
dto.setUpdate_time(now);
dto.setCreate_time(now);
dto.setSyscompanyid(Long.valueOf(depts));
dto.setSysdeptid(Long.valueOf(depts));
dto.setSyscompanyid(Long.valueOf(depts.get(0)));
dto.setSysdeptid(Long.valueOf(depts.get(0)));
WQLObject wo = WQLObject.getWQLObject("pdm_bi_workteam");
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));

View File

@@ -77,7 +77,8 @@
<el-form-item label="邮箱" prop="email">
<el-input v-model="form.email" style="width: 200px;" />
</el-form-item>
<el-form-item label="部门" prop="depts" :rules="[{ required: true, message: '请选择部门', trigger: 'change' }]">
<br v-if="!crud.status.edit">
<el-form-item v-if="crud.status.add" label="部门" prop="depts" :rules="[{ required: true, message: '请选择部门', trigger: 'change' }]">
<treeselect
v-model="form.depts"
:load-options="loadDepts"
@@ -108,7 +109,8 @@
inactive-value="0"
/>
</el-form-item>
<el-form-item style="margin-bottom: 0;" label="角色" prop="roles">
<br v-if="!crud.status.edit">
<el-form-item v-if="crud.status.add" style="margin-bottom: 0;" label="角色" prop="roles">
<el-select
v-model="roleDatas"
style="width: 512px"
@@ -168,8 +170,8 @@
width="200"
>
<template v-if="scope.row.userId !== 1" slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="crud.toEdit(scope.row)(scope.row)">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handdeleted(scope.row)">删除</el-button>
<el-dropdown v-hasPermi="['system:user:resetPwd', 'system:user:edit']" size="mini" @command="(command) => handleCommand(command, scope.row)">
<el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button>
<el-dropdown-menu slot="dropdown">
@@ -241,7 +243,7 @@ const defaultForm = {
person_name: null,
gender: '男',
email: null,
enabled: 'true',
is_used: '1',
roles: [],
phone: null,
password: null
@@ -316,6 +318,17 @@ export default {
}
})
},
handdeleted(datas) {
this.$confirm(`确认删除选中的1条数据?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.crud.delAllLoading = true
this.crud.doDelete(datas)
}).catch(() => {
})
},
// 新增与编辑前做的操作
[CRUD.HOOK.afterToCU](crud, form) {
this.getRoles()
@@ -324,7 +337,7 @@ export default {
} else {
this.getSupDepts(form.dept_id)
}
this.getRoleLevel()
// this.getRoleLevel() 暂时不用
form.is_used = form.enabled.toString()
},
// 新增前将多选的值设置为空
@@ -334,15 +347,17 @@ export default {
},
// 初始化编辑时候的角色与岗位
[CRUD.HOOK.beforeToEdit](crud, form) {
crud.status.edit
this.roleDatas = []
userRoles = []
const _this = this
const arr = form.roles.split(',')
arr.forEach(function(role, index) {
_this.roleDatas.push(role.id)
const rol = { id: role.id }
userRoles.push(rol)
})
if (form.roles !== null && form.roles.length > 0) {
form.roles.forEach(function(role, index) {
_this.roleDatas.push(role)
const rol = { id: role }
userRoles.push(rol)
})
}
},
// 提交前做的操作
[CRUD.HOOK.afterValidateCU](crud) {
@@ -363,8 +378,7 @@ export default {
userRoles.forEach(function(data, index) {
roles.push(data.id)
})
crud.form.roles = roles.toString()
crud.form.depts = crud.form.depts.toString()
crud.form.roles = roles
return true
},
// 获取左侧部门数据
@@ -477,7 +491,8 @@ export default {
})
},
checkboxT(row, rowIndex) {
return row.id !== this.user.id
// return row.id !== this.user.id
return true
},
resetPassword(row) {
row.password = null