用户
This commit is contained in:
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
6
.idea/compiler.xml
generated
Normal file
6
.idea/compiler.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<bytecodeTargetLevel target="8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/dictionaries
generated
Normal file
6
.idea/dictionaries
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectDictionaryState">
|
||||||
|
<dictionary name="mima0000" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
37
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
37
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
|
<inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="TOP_LEVEL_CLASS_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||||
|
<option name="REQUIRED_TAGS" value="" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="INNER_CLASS_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||||
|
<option name="REQUIRED_TAGS" value="" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="METHOD_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||||
|
<option name="REQUIRED_TAGS" value="@return@param@throws or @exception" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="FIELD_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||||
|
<option name="REQUIRED_TAGS" value="" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="IGNORE_DEPRECATED" value="false" />
|
||||||
|
<option name="IGNORE_JAVADOC_PERIOD" value="true" />
|
||||||
|
<option name="IGNORE_DUPLICATED_THROWS" value="false" />
|
||||||
|
<option name="IGNORE_POINT_TO_ITSELF" value="false" />
|
||||||
|
<option name="myAdditionalJavadocTags" value="date" />
|
||||||
|
</inspection_tool>
|
||||||
|
</profile>
|
||||||
|
</component>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/nl-sso-server.iml" filepath="$PROJECT_DIR$/.idea/nl-sso-server.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
9
.idea/nl-sso-server.iml
generated
Normal file
9
.idea/nl-sso-server.iml
generated
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.nl.modules.common.base;
|
package org.nl.modules.common.base;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -24,9 +25,11 @@ public class BaseDTO implements Serializable {
|
|||||||
private Long update_optid;
|
private Long update_optid;
|
||||||
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date create_time;
|
private Date create_time;
|
||||||
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date update_time;
|
private Date update_time;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.nl.modules.system.domain;
|
package org.nl.modules.system.domain;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -37,7 +39,7 @@ public class User extends BaseDTO implements Serializable {
|
|||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
private Long user_id;
|
private Long user_id;
|
||||||
|
@JsonFormat
|
||||||
private String roles;
|
private String roles;
|
||||||
|
|
||||||
private String depts;
|
private String depts;
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* 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.modules.system.domain.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.nl.modules.system.domain.Menu;
|
||||||
|
import org.nl.modules.system.domain.User;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色
|
||||||
|
* @author Zheng Jie
|
||||||
|
* @date 2018-11-22
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class RoleVo implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "ID", hidden = true)
|
||||||
|
private Long role_id;
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
@ApiModelProperty(value = "名称", hidden = true)
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "级别,数值越小,级别越大")
|
||||||
|
private Integer level = 3;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "描述")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "描述")
|
||||||
|
private String order_seq;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "描述")
|
||||||
|
private String is_used;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -29,6 +29,7 @@ import org.nl.modules.common.utils.RsaUtils;
|
|||||||
import org.nl.modules.common.utils.SecurityUtils;
|
import org.nl.modules.common.utils.SecurityUtils;
|
||||||
import org.nl.modules.logging.annotation.Log;
|
import org.nl.modules.logging.annotation.Log;
|
||||||
import org.nl.modules.system.domain.User;
|
import org.nl.modules.system.domain.User;
|
||||||
|
import org.nl.modules.system.service.UserRelateService;
|
||||||
import org.nl.modules.system.service.UserService;
|
import org.nl.modules.system.service.UserService;
|
||||||
import org.nl.modules.system.service.dto.UserQueryCriteria;
|
import org.nl.modules.system.service.dto.UserQueryCriteria;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
@@ -54,7 +55,7 @@ public class UserController {
|
|||||||
|
|
||||||
@ApiOperation("查询用户")
|
@ApiOperation("查询用户")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@SaCheckPermission("user:list")
|
// @SaCheckPermission("user:list")
|
||||||
public ResponseEntity<Object> query(UserQueryCriteria criteria, Pageable pageable){
|
public ResponseEntity<Object> query(UserQueryCriteria criteria, Pageable pageable){
|
||||||
return new ResponseEntity<>(userService.queryAll(criteria,pageable),HttpStatus.OK);
|
return new ResponseEntity<>(userService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
@@ -62,7 +63,7 @@ public class UserController {
|
|||||||
@Log("新增用户")
|
@Log("新增用户")
|
||||||
@ApiOperation("新增用户")
|
@ApiOperation("新增用户")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@SaCheckPermission("user:add")
|
// @SaCheckPermission("user:add")
|
||||||
public ResponseEntity<Object> create(@Validated @RequestBody User resources){
|
public ResponseEntity<Object> create(@Validated @RequestBody User resources){
|
||||||
checkLevel(resources);
|
checkLevel(resources);
|
||||||
// 默认密码 123456
|
// 默认密码 123456
|
||||||
@@ -78,7 +79,7 @@ public class UserController {
|
|||||||
@Log("修改用户")
|
@Log("修改用户")
|
||||||
@ApiOperation("修改用户")
|
@ApiOperation("修改用户")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@SaCheckPermission("user:edit")
|
// @SaCheckPermission("user:edit")
|
||||||
public ResponseEntity<Object> update( @RequestBody User resources) throws Exception {
|
public ResponseEntity<Object> update( @RequestBody User resources) throws Exception {
|
||||||
checkLevel(resources);
|
checkLevel(resources);
|
||||||
userService.update(resources);
|
userService.update(resources);
|
||||||
@@ -87,7 +88,7 @@ public class UserController {
|
|||||||
|
|
||||||
@Log("修改用户:个人中心")
|
@Log("修改用户:个人中心")
|
||||||
@ApiOperation("修改用户:个人中心")
|
@ApiOperation("修改用户:个人中心")
|
||||||
@PutMapping(value = "center")
|
// @PutMapping(value = "center")
|
||||||
public ResponseEntity<Object> center(@RequestBody User resources){
|
public ResponseEntity<Object> center(@RequestBody User resources){
|
||||||
if(!resources.getUser_id().equals(StpUtil.getLoginIdAsLong())){
|
if(!resources.getUser_id().equals(StpUtil.getLoginIdAsLong())){
|
||||||
throw new BadRequestException("不能修改他人资料");
|
throw new BadRequestException("不能修改他人资料");
|
||||||
@@ -99,7 +100,7 @@ public class UserController {
|
|||||||
@Log("删除用户")
|
@Log("删除用户")
|
||||||
@ApiOperation("删除用户")
|
@ApiOperation("删除用户")
|
||||||
@DeleteMapping
|
@DeleteMapping
|
||||||
@SaCheckPermission("user:del")
|
// @SaCheckPermission("user:del")
|
||||||
public ResponseEntity<Object> delete(@RequestBody Set<Long> ids) {
|
public ResponseEntity<Object> delete(@RequestBody Set<Long> ids) {
|
||||||
for (Long id : ids) {
|
for (Long id : ids) {
|
||||||
/* Integer currentLevel = Collections.min(roleService.findByUsersId(StpUtil.getLoginIdAsLong()).stream().map(Role::getLevel).collect(Collectors.toList()));
|
/* Integer currentLevel = Collections.min(roleService.findByUsersId(StpUtil.getLoginIdAsLong()).stream().map(Role::getLevel).collect(Collectors.toList()));
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* 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.modules.system.service;
|
||||||
|
|
||||||
|
import org.nl.modules.system.domain.User;
|
||||||
|
import org.nl.modules.system.service.dto.UserQueryCriteria;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Zheng Jie
|
||||||
|
* @date 2018-11-23
|
||||||
|
*/
|
||||||
|
public interface UserRelateService {
|
||||||
|
|
||||||
|
void inserDeptRelate(Long user,Set<Long> deptIds);
|
||||||
|
void inserRoleRelate(Long user,Set<Long> RoleIds);
|
||||||
|
void deleteDeptRelate(Set<Long> deptIds);
|
||||||
|
void deleteRoleRelate(Set<Long> RoleIds);
|
||||||
|
void updateDeptRelate(Long user,Set<Long> deptIds);
|
||||||
|
void updateRoleRelate(Long user,Set<Long> RoleIds);
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package org.nl.modules.system.service.impl;
|
||||||
|
|
||||||
|
import org.nl.modules.system.service.UserRelateService;
|
||||||
|
import org.nl.modules.tools.MapOf;
|
||||||
|
import org.nl.modules.wql.core.bean.WQLObject;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @author ZZQ
|
||||||
|
* @Date 2022/12/2 2:47 下午
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class UserRelateServiceImpl implements UserRelateService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void inserDeptRelate(Long user, Set<Long> deptIds) {
|
||||||
|
if (user !=null && !CollectionUtils.isEmpty(deptIds)){
|
||||||
|
for (Long deptId : deptIds) {
|
||||||
|
WQLObject.getWQLObject("sys_user_dept").insert(MapOf.of("user_id",user,"dept_id",deptId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void inserRoleRelate(Long user, Set<Long> RoleIds) {
|
||||||
|
if (user !=null && !CollectionUtils.isEmpty(RoleIds)){
|
||||||
|
for (Long roleid : RoleIds) {
|
||||||
|
WQLObject.getWQLObject("sys_users_roles").insert(MapOf.of("user_id",user,"role_id",roleid));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteDeptRelate(Set<Long> deptIds) {
|
||||||
|
if (!CollectionUtils.isEmpty(deptIds)){
|
||||||
|
String collect = deptIds.stream().map(a -> String.valueOf(a)).collect(Collectors.joining("','"));
|
||||||
|
String sql="dept_id in ('"+collect+"')";
|
||||||
|
WQLObject.getWQLObject("sys_user_dept").delete(sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteRoleRelate(Set<Long> RoleIds) {
|
||||||
|
if (!CollectionUtils.isEmpty(RoleIds)){
|
||||||
|
String collect = RoleIds.stream().map(a -> String.valueOf(a)).collect(Collectors.joining("','"));
|
||||||
|
String sql="dept_id in ('"+collect+"')";
|
||||||
|
WQLObject.getWQLObject("sys_user_dept").delete(sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void updateDeptRelate(Long user, Set<Long> deptIds) {
|
||||||
|
if (user !=null){
|
||||||
|
this.deleteDeptRelate(deptIds);
|
||||||
|
this.inserDeptRelate(user,deptIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void updateRoleRelate(Long user, Set<Long> RoleIds) {
|
||||||
|
if (user !=null){
|
||||||
|
this.deleteRoleRelate(RoleIds);
|
||||||
|
this.inserRoleRelate(user,RoleIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,11 +34,13 @@ import org.nl.modules.common.utils.dto.CurrentUser;
|
|||||||
import org.nl.modules.security.service.OnlineUserService;
|
import org.nl.modules.security.service.OnlineUserService;
|
||||||
import org.nl.modules.system.domain.User;
|
import org.nl.modules.system.domain.User;
|
||||||
import org.nl.modules.system.service.DeptService;
|
import org.nl.modules.system.service.DeptService;
|
||||||
|
import org.nl.modules.system.service.UserRelateService;
|
||||||
import org.nl.modules.system.service.UserService;
|
import org.nl.modules.system.service.UserService;
|
||||||
|
|
||||||
import org.nl.modules.system.service.dto.UserQueryCriteria;
|
import org.nl.modules.system.service.dto.UserQueryCriteria;
|
||||||
import org.nl.modules.tools.MapOf;
|
import org.nl.modules.tools.MapOf;
|
||||||
import org.nl.modules.wql.WQL;
|
import org.nl.modules.wql.WQL;
|
||||||
|
import org.nl.modules.wql.core.bean.ResultBean;
|
||||||
import org.nl.modules.wql.core.bean.WQLObject;
|
import org.nl.modules.wql.core.bean.WQLObject;
|
||||||
import org.springframework.cache.annotation.CacheConfig;
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
@@ -68,6 +70,8 @@ public class UserServiceImpl implements UserService {
|
|||||||
private final RedisUtils redisUtils;
|
private final RedisUtils redisUtils;
|
||||||
private final OnlineUserService onlineUserService;
|
private final OnlineUserService onlineUserService;
|
||||||
private final DeptService deptService;
|
private final DeptService deptService;
|
||||||
|
private final UserRelateService userRelateService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -135,9 +139,25 @@ public class UserServiceImpl implements UserService {
|
|||||||
throw new EntityExistException(User.class, "username", resources.getUsername());
|
throw new EntityExistException(User.class, "username", resources.getUsername());
|
||||||
}
|
}
|
||||||
CurrentUser user = SecurityUtils.getCurrentUser();
|
CurrentUser user = SecurityUtils.getCurrentUser();
|
||||||
/* resources.setCreate_id(user.getId());
|
resources.setCreate_time(new Date());
|
||||||
resources.setCreate_name(user.getUsername());*/
|
resources.setCreate_id(user.getId());
|
||||||
WQLObject.getWQLObject("sys_user").insert((JSONObject)JSON.toJSON(resources));
|
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();
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -151,10 +171,25 @@ public class UserServiceImpl implements UserService {
|
|||||||
onlineUserService.kickOutForUsername(resources.getUsername());
|
onlineUserService.kickOutForUsername(resources.getUsername());
|
||||||
}
|
}
|
||||||
resources.setPassword(SaSecureUtil.md5BySalt(resources.getPassword(), "salt"));
|
resources.setPassword(SaSecureUtil.md5BySalt(resources.getPassword(), "salt"));
|
||||||
|
resources.setUpdate_time(new Date());
|
||||||
|
resources.setUpdate_optid(user.getId());
|
||||||
|
resources.setUpdate_optname(user.getUsername());
|
||||||
WQLObject.getWQLObject("sys_user").update(JSONObject.parseObject(JSON.toJSONString(resources)),"user_id ='"+resources.getUser_id()+"'");
|
WQLObject.getWQLObject("sys_user").update(JSONObject.parseObject(JSON.toJSONString(resources)),"user_id ='"+resources.getUser_id()+"'");
|
||||||
// 清除缓存
|
// 清除缓存
|
||||||
delCaches(user.getUser_id(), user.getUsername());
|
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);
|
||||||
|
}
|
||||||
// 如果用户的角色改变
|
// 如果用户的角色改变
|
||||||
if (!resources.getRoles().equals(user.getRoles())) {
|
if (!resources.getRoles().equals(user.getRoles())) {
|
||||||
redisUtils.del(CacheKey.DATA_USER + resources.getUser_id());
|
redisUtils.del(CacheKey.DATA_USER + resources.getUser_id());
|
||||||
@@ -186,6 +221,9 @@ public class UserServiceImpl implements UserService {
|
|||||||
}
|
}
|
||||||
String collectSql = ids.stream().map(a -> String.valueOf(a)).collect(Collectors.joining("','"));
|
String collectSql = ids.stream().map(a -> String.valueOf(a)).collect(Collectors.joining("','"));
|
||||||
WQLObject.getWQLObject("sys_user").delete("user_id in ('"+collectSql+"'");
|
WQLObject.getWQLObject("sys_user").delete("user_id in ('"+collectSql+"'");
|
||||||
|
//删除用户部门,角色关系表
|
||||||
|
userRelateService.deleteDeptRelate(ids);
|
||||||
|
userRelateService.deleteRoleRelate(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -229,7 +229,6 @@ public class Syntax {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行完整指令,包含嵌套
|
* 执行完整指令,包含嵌套
|
||||||
* @param list
|
|
||||||
*/
|
*/
|
||||||
private boolean exec(String endCmd){
|
private boolean exec(String endCmd){
|
||||||
boolean isSuccess = false;
|
boolean isSuccess = false;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export function getDepts(params) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDeptTreee(params) {
|
export function getDeptTree(params) {
|
||||||
return request({
|
return request({
|
||||||
url: '/api/dept/allTree',
|
url: '/api/dept/allTree',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
@@ -57,4 +57,4 @@ export function edit(data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default { add, edit, del, getDepts, getDeptSuperior, getDeptvo }
|
export default { add, edit, del, getDepts, getDeptSuperior, getDeptvo, getDeptTree }
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
<el-radio label="0">否</el-radio>
|
<el-radio label="0">否</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="enabled">
|
<el-form-item label="状态" prop="is_uesd">
|
||||||
<el-switch
|
<el-switch
|
||||||
v-model="form.is_used"
|
v-model="form.is_used"
|
||||||
active-color="#409EFF"
|
active-color="#409EFF"
|
||||||
|
|||||||
@@ -55,7 +55,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<crudOperation show="" :permission="permission" />
|
<crudOperation show="" :permission="permission" />
|
||||||
</div>
|
</div>
|
||||||
<!--表单渲染-->
|
<!--新增跟修改表单渲染-->
|
||||||
<el-dialog
|
<el-dialog
|
||||||
append-to-body
|
append-to-body
|
||||||
:close-on-click-modal="false"
|
:close-on-click-modal="false"
|
||||||
@@ -77,12 +77,16 @@
|
|||||||
<el-form-item label="邮箱" prop="email">
|
<el-form-item label="邮箱" prop="email">
|
||||||
<el-input v-model="form.email" style="width: 200px;" />
|
<el-input v-model="form.email" style="width: 200px;" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="部门" prop="dept.id" :rules="[{ required: true, message: '请选择部门', trigger: 'change' }]">
|
<el-form-item label="部门" prop="depts" :rules="[{ required: true, message: '请选择部门', trigger: 'change' }]">
|
||||||
<el-tree-select
|
<treeselect
|
||||||
v-model="form.dept.id"
|
v-model="form.depts"
|
||||||
:data="deptDatas"
|
:load-options="loadDepts"
|
||||||
style="width: 200px"
|
:options="deptDatas"
|
||||||
placeholder="选择部门"
|
style="width: 370px;"
|
||||||
|
:multiple="true"
|
||||||
|
:flat="true"
|
||||||
|
:normalizer="normalizer"
|
||||||
|
placeholder="选择部门类目"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<br v-if="!crud.status.add">
|
<br v-if="!crud.status.add">
|
||||||
@@ -95,15 +99,14 @@
|
|||||||
<el-radio label="女">女</el-radio>
|
<el-radio label="女">女</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态">
|
<el-form-item label="状态" prop="is_uesd">
|
||||||
<el-radio-group v-model="form.is_used" :disabled="form.id === user.id">
|
<el-switch
|
||||||
<el-radio
|
v-model="form.is_used"
|
||||||
v-for="item in dict.user_status"
|
active-color="#409EFF"
|
||||||
:key="item.id"
|
inactive-color="#F56C6C"
|
||||||
:label="item.value"
|
active-value="1"
|
||||||
>{{ item.label }}
|
inactive-value="0"
|
||||||
</el-radio>
|
/>
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item style="margin-bottom: 0;" label="角色" prop="roles">
|
<el-form-item style="margin-bottom: 0;" label="角色" prop="roles">
|
||||||
<el-select
|
<el-select
|
||||||
@@ -116,12 +119,12 @@
|
|||||||
@remove-tag="deleteTag"
|
@remove-tag="deleteTag"
|
||||||
@change="changeRole"
|
@change="changeRole"
|
||||||
>
|
>
|
||||||
|
<!--:disabled="level !== 1 && item.level <= level"-->
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in roles"
|
v-for="item in roles"
|
||||||
:key="item.name"
|
:key="item.role_id"
|
||||||
:disabled="level !== 1 && item.level <= level"
|
|
||||||
:label="item.name"
|
:label="item.name"
|
||||||
:value="item.id"
|
:value="item.role_id"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -150,7 +153,7 @@
|
|||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-switch
|
<el-switch
|
||||||
v-model="scope.row.is_used"
|
v-model="scope.row.is_used"
|
||||||
:disabled="user.id === scope.row.id"
|
:disabled="scope.row.id === 1"
|
||||||
active-color="#409EFF"
|
active-color="#409EFF"
|
||||||
inactive-color="#F56C6C"
|
inactive-color="#F56C6C"
|
||||||
active-value="1"
|
active-value="1"
|
||||||
@@ -198,34 +201,33 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import crudUser from '@/api/system/user'
|
import crudUser from '@/api/system/user'
|
||||||
import { getDepts, getDeptSuperior, getDeptTreee } from '@/api/system/dept'
|
import crudDept from '@/api/system/dept'
|
||||||
import { getAll, getLevel } from '@/api/system/role'
|
import { getAll, getLevel } from '@/api/system/role'
|
||||||
import CRUD, { crud, form, header, presenter } from '@crud/crud'
|
import CRUD, { crud, form, header, presenter } from '@crud/crud'
|
||||||
import rrOperation from '@crud/RR.operation'
|
import rrOperation from '@crud/RR.operation'
|
||||||
import crudOperation from '@crud/CRUD.operation'
|
import crudOperation from '@crud/CRUD.operation'
|
||||||
import udOperation from '@crud/UD.operation'
|
import udOperation from '@crud/UD.operation'
|
||||||
import pagination from '@crud/Pagination'
|
import pagination from '@crud/Pagination'
|
||||||
import DateRangePicker from '@/components/DateRangePicker'
|
|
||||||
import Treeselect, { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect'
|
import Treeselect, { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect'
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||||
|
|
||||||
let userRoles = []
|
let userRoles = []
|
||||||
const defaultForm = {
|
const defaultForm = {
|
||||||
id: null,
|
dept_id: null,
|
||||||
|
depts: [],
|
||||||
username: null,
|
username: null,
|
||||||
person_name: null,
|
person_name: null,
|
||||||
gender: '男',
|
gender: '男',
|
||||||
email: null,
|
email: null,
|
||||||
enabled: 'true',
|
enabled: 'true',
|
||||||
roles: [],
|
roles: [],
|
||||||
dept: { id: 2 },
|
|
||||||
phone: null,
|
phone: null,
|
||||||
password: null
|
password: null
|
||||||
}
|
}
|
||||||
export default {
|
export default {
|
||||||
name: 'User',
|
name: 'User',
|
||||||
components: { Treeselect, crudOperation, rrOperation, udOperation, pagination, DateRangePicker },
|
components: { Treeselect, crudOperation, rrOperation, udOperation, pagination },
|
||||||
cruds() {
|
cruds() {
|
||||||
return CRUD({ title: '用户', url: 'api/users', crudMethod: { ...crudUser }})
|
return CRUD({ title: '用户', url: 'api/users', crudMethod: { ...crudUser }})
|
||||||
},
|
},
|
||||||
@@ -265,7 +267,7 @@ export default {
|
|||||||
])
|
])
|
||||||
},
|
},
|
||||||
beforeMount() {
|
beforeMount() {
|
||||||
this.getDeptTree()
|
this.deptTree()
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.crud.msg.add = '新增成功'
|
this.crud.msg.add = '新增成功'
|
||||||
@@ -278,7 +280,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
changeRole(value) {
|
changeRole(value) {
|
||||||
userRoles = []
|
userRoles = [],
|
||||||
value.forEach(function(data, index) {
|
value.forEach(function(data, index) {
|
||||||
const role = { id: data }
|
const role = { id: data }
|
||||||
userRoles.push(role)
|
userRoles.push(role)
|
||||||
@@ -294,13 +296,13 @@ export default {
|
|||||||
// 新增与编辑前做的操作
|
// 新增与编辑前做的操作
|
||||||
[CRUD.HOOK.afterToCU](crud, form) {
|
[CRUD.HOOK.afterToCU](crud, form) {
|
||||||
this.getRoles()
|
this.getRoles()
|
||||||
if (form.id == null) {
|
if (form.dept_id == null) {
|
||||||
this.getDepts()
|
crudDept.getDepts()
|
||||||
} else {
|
} else {
|
||||||
this.getSupDepts(form.dept.id)
|
this.getSupDepts(form.dept_id)
|
||||||
}
|
}
|
||||||
this.getRoleLevel()
|
this.getRoleLevel()
|
||||||
form.enabled = form.enabled.toString()
|
form.is_used = form.enabled.toString()
|
||||||
},
|
},
|
||||||
// 新增前将多选的值设置为空
|
// 新增前将多选的值设置为空
|
||||||
[CRUD.HOOK.beforeToAdd]() {
|
[CRUD.HOOK.beforeToAdd]() {
|
||||||
@@ -321,7 +323,7 @@ export default {
|
|||||||
},
|
},
|
||||||
// 提交前做的操作
|
// 提交前做的操作
|
||||||
[CRUD.HOOK.afterValidateCU](crud) {
|
[CRUD.HOOK.afterValidateCU](crud) {
|
||||||
if (!crud.form.dept.id) {
|
if (!crud.form.depts) {
|
||||||
this.$message({
|
this.$message({
|
||||||
message: '部门不能为空',
|
message: '部门不能为空',
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
@@ -334,14 +336,18 @@ export default {
|
|||||||
})
|
})
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
crud.form.roles = userRoles
|
const roles = []
|
||||||
|
userRoles.forEach(function(data, index) {
|
||||||
|
roles.push(data.id)
|
||||||
|
})
|
||||||
|
crud.form.roles = roles.toString()
|
||||||
|
crud.form.depts = crud.form.depts.toString()
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
// 获取左侧部门数据
|
// 获取左侧部门数据
|
||||||
getDeptDatas(node, resolve) {
|
getDeptDatas(node, resolve) {
|
||||||
debugger
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
getDeptTreee({ name: node }).then(res => {
|
crudDept.getDeptTree({ name: node }).then(res => {
|
||||||
console.log('res', res)
|
console.log('res', res)
|
||||||
if (resolve) {
|
if (resolve) {
|
||||||
resolve(res.content)
|
resolve(res.content)
|
||||||
@@ -352,16 +358,16 @@ export default {
|
|||||||
}, 100)
|
}, 100)
|
||||||
},
|
},
|
||||||
|
|
||||||
getDeptTree() {
|
deptTree() {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
getDeptTreee().then(res => {
|
crudDept.getDeptTree().then(res => {
|
||||||
this.deptDatas = res.content
|
this.deptDatas = res.content
|
||||||
})
|
})
|
||||||
}, 100)
|
}, 100)
|
||||||
},
|
},
|
||||||
getDepts() {
|
getDepts() {
|
||||||
console.log('获取部门')
|
console.log('获取部门')
|
||||||
getDepts({ is_used: 1 }).then(res => {
|
crudDept.getDepts({ is_used: 1 }).then(res => {
|
||||||
console.log('获取的部门信息', res)
|
console.log('获取的部门信息', res)
|
||||||
|
|
||||||
this.depts = res.content.map(function(obj) {
|
this.depts = res.content.map(function(obj) {
|
||||||
@@ -373,7 +379,7 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
getSupDepts(deptId) {
|
getSupDepts(deptId) {
|
||||||
getDeptSuperior(deptId).then(res => {
|
crudDept.getDeptSuperior(deptId).then(res => {
|
||||||
console.log('父部门', res)
|
console.log('父部门', res)
|
||||||
const date = res.content
|
const date = res.content
|
||||||
this.buildDepts(date)
|
this.buildDepts(date)
|
||||||
@@ -392,21 +398,25 @@ export default {
|
|||||||
},
|
},
|
||||||
// 获取弹窗内部门数据
|
// 获取弹窗内部门数据
|
||||||
loadDepts({ action, parentNode, callback }) {
|
loadDepts({ action, parentNode, callback }) {
|
||||||
debugger
|
|
||||||
if (action === LOAD_CHILDREN_OPTIONS) {
|
if (action === LOAD_CHILDREN_OPTIONS) {
|
||||||
getDepts({ is_used: 1, pid: parentNode.id }).then(res => {
|
crudDept.getDeptvo({ is_used: '1', pid: parentNode.dept_id }).then(res => {
|
||||||
parentNode.children = res.content.map(function(obj) {
|
parentNode.children = res.content.map(function(obj) {
|
||||||
if (obj.hasChildren) {
|
|
||||||
obj.children = null
|
obj.children = null
|
||||||
}
|
|
||||||
return obj
|
return obj
|
||||||
})
|
})
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
callback()
|
callback()
|
||||||
}, 200)
|
}, 100)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
normalizer(node) {
|
||||||
|
return {
|
||||||
|
id: node.dept_id,
|
||||||
|
label: node.name,
|
||||||
|
children: node.children
|
||||||
|
}
|
||||||
|
},
|
||||||
// 切换部门
|
// 切换部门
|
||||||
handleNodeClick(data) {
|
handleNodeClick(data) {
|
||||||
this.query.deptId = data.dept_id
|
this.query.deptId = data.dept_id
|
||||||
|
|||||||
Reference in New Issue
Block a user