用户
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package org.nl.modules.common.base;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@@ -24,9 +25,11 @@ public class BaseDTO implements Serializable {
|
||||
private Long update_optid;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date create_time;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date update_time;
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.nl.modules.system.domain;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -37,7 +39,7 @@ public class User extends BaseDTO implements Serializable {
|
||||
private Long id;
|
||||
|
||||
private Long user_id;
|
||||
|
||||
@JsonFormat
|
||||
private String roles;
|
||||
|
||||
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.logging.annotation.Log;
|
||||
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.dto.UserQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -54,7 +55,7 @@ public class UserController {
|
||||
|
||||
@ApiOperation("查询用户")
|
||||
@GetMapping
|
||||
@SaCheckPermission("user:list")
|
||||
// @SaCheckPermission("user:list")
|
||||
public ResponseEntity<Object> query(UserQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(userService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
@@ -62,7 +63,7 @@ public class UserController {
|
||||
@Log("新增用户")
|
||||
@ApiOperation("新增用户")
|
||||
@PostMapping
|
||||
@SaCheckPermission("user:add")
|
||||
// @SaCheckPermission("user:add")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody User resources){
|
||||
checkLevel(resources);
|
||||
// 默认密码 123456
|
||||
@@ -78,7 +79,7 @@ public class UserController {
|
||||
@Log("修改用户")
|
||||
@ApiOperation("修改用户")
|
||||
@PutMapping
|
||||
@SaCheckPermission("user:edit")
|
||||
// @SaCheckPermission("user:edit")
|
||||
public ResponseEntity<Object> update( @RequestBody User resources) throws Exception {
|
||||
checkLevel(resources);
|
||||
userService.update(resources);
|
||||
@@ -87,7 +88,7 @@ public class UserController {
|
||||
|
||||
@Log("修改用户:个人中心")
|
||||
@ApiOperation("修改用户:个人中心")
|
||||
@PutMapping(value = "center")
|
||||
// @PutMapping(value = "center")
|
||||
public ResponseEntity<Object> center(@RequestBody User resources){
|
||||
if(!resources.getUser_id().equals(StpUtil.getLoginIdAsLong())){
|
||||
throw new BadRequestException("不能修改他人资料");
|
||||
@@ -99,7 +100,7 @@ public class UserController {
|
||||
@Log("删除用户")
|
||||
@ApiOperation("删除用户")
|
||||
@DeleteMapping
|
||||
@SaCheckPermission("user:del")
|
||||
// @SaCheckPermission("user:del")
|
||||
public ResponseEntity<Object> delete(@RequestBody Set<Long> ids) {
|
||||
for (Long id : ids) {
|
||||
/* 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.system.domain.User;
|
||||
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.dto.UserQueryCriteria;
|
||||
import org.nl.modules.tools.MapOf;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.ResultBean;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
@@ -68,6 +70,8 @@ public class UserServiceImpl implements UserService {
|
||||
private final RedisUtils redisUtils;
|
||||
private final OnlineUserService onlineUserService;
|
||||
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());
|
||||
}
|
||||
CurrentUser user = SecurityUtils.getCurrentUser();
|
||||
/* resources.setCreate_id(user.getId());
|
||||
resources.setCreate_name(user.getUsername());*/
|
||||
WQLObject.getWQLObject("sys_user").insert((JSONObject)JSON.toJSON(resources));
|
||||
resources.setCreate_time(new Date());
|
||||
resources.setCreate_id(user.getId());
|
||||
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
|
||||
@@ -151,10 +171,25 @@ public class UserServiceImpl implements UserService {
|
||||
onlineUserService.kickOutForUsername(resources.getUsername());
|
||||
}
|
||||
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()+"'");
|
||||
// 清除缓存
|
||||
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())) {
|
||||
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("','"));
|
||||
WQLObject.getWQLObject("sys_user").delete("user_id in ('"+collectSql+"'");
|
||||
//删除用户部门,角色关系表
|
||||
userRelateService.deleteDeptRelate(ids);
|
||||
userRelateService.deleteRoleRelate(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* 创 建 者 :yumeng
|
||||
* 创建时间:2014-06-25 14:25:35
|
||||
* 文件版本:v1.0
|
||||
* 文件版本:v1.0
|
||||
*
|
||||
*******************************************************/
|
||||
package org.nl.modules.wql.core.engine;
|
||||
@@ -34,11 +34,11 @@ public class Syntax {
|
||||
private WO wo;
|
||||
Stack stack = new Stack(); //指令栈
|
||||
Stack<String> cmdstack = new Stack<String>(); //指令作用域栈
|
||||
|
||||
|
||||
public static ArrayList KEYWORD = new ArrayList(); //关键运算符
|
||||
public static ArrayList SINGWORD = new ArrayList(); //单个运算符
|
||||
|
||||
|
||||
|
||||
|
||||
public static final String UNIONSTR = "UNIONSTR"; //关键字:unionstr
|
||||
static{
|
||||
/***********************************
|
||||
@@ -50,57 +50,57 @@ public class Syntax {
|
||||
*********************************/
|
||||
KEYWORD.add("SELECT"); //查询
|
||||
KEYWORD.add("ENDSELECT"); //查询结束
|
||||
|
||||
|
||||
KEYWORD.add("INSERT"); //插入
|
||||
KEYWORD.add("ENDINSERT"); //插入结束
|
||||
|
||||
|
||||
KEYWORD.add("UPDATE"); //更新
|
||||
KEYWORD.add("ENDUPDATE"); //更新结束
|
||||
|
||||
|
||||
KEYWORD.add("DELETE"); //删除
|
||||
KEYWORD.add("ENDDELETE"); //删除结束
|
||||
|
||||
|
||||
KEYWORD.add("EXECSQL"); //执行
|
||||
KEYWORD.add("ENDEXECSQL"); //执行结束
|
||||
|
||||
|
||||
/***********************************
|
||||
* 逻辑运算符
|
||||
*********************************/
|
||||
KEYWORD.add("IF"); //判断
|
||||
KEYWORD.add("ENDIF"); //判断结束
|
||||
|
||||
|
||||
KEYWORD.add("CALLWQL"); //调用其他WQL
|
||||
KEYWORD.add("ENDCALLWQL"); //调用其他WQL结束
|
||||
|
||||
|
||||
KEYWORD.add("CALLJAVA"); //调用JAVA
|
||||
KEYWORD.add("ENDCALLJAVA"); //调用JAVA结束
|
||||
|
||||
KEYWORD.add("CALLPROC"); //调用存储过程
|
||||
KEYWORD.add("ENDCALLPROC"); //调用存储过程结束
|
||||
|
||||
|
||||
KEYWORD.add("QUERY"); //普通查询
|
||||
KEYWORD.add("ENDQUERY"); //普通查询结束
|
||||
|
||||
|
||||
KEYWORD.add("PAGEQUERY"); //分页查询
|
||||
KEYWORD.add("ENDPAGEQUERY"); //分页查询结束
|
||||
|
||||
|
||||
KEYWORD.add("LOOP"); //按次数循环
|
||||
KEYWORD.add("ENDLOOP"); //按次数循环结束
|
||||
|
||||
|
||||
KEYWORD.add("WHILE"); //按条件循环
|
||||
KEYWORD.add("ENDWHILE"); //按条件循环结束
|
||||
|
||||
|
||||
// KEYWORD.add("OPTION"); //条件过滤
|
||||
// KEYWORD.add("ENDOPTION"); //条件过滤结束
|
||||
|
||||
|
||||
/***********************************
|
||||
* 特殊指令 单独在指令中判断
|
||||
*********************************/
|
||||
|
||||
|
||||
SINGWORD.add("DUMP"); //输出提示信息
|
||||
SINGWORD.add("ERROR"); //输出错误信息
|
||||
}
|
||||
|
||||
|
||||
/////////////////////考虑运算符的对象化
|
||||
public boolean exec(WO wo, ArrayList list){
|
||||
boolean isSuccess = false;
|
||||
@@ -123,17 +123,17 @@ public class Syntax {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//如果是结尾符,则出栈该任务域并交付执行
|
||||
if(cmdname.startsWith("END")){
|
||||
stack.push(wql);
|
||||
|
||||
|
||||
//如果命令栈中还存在前一个命令域
|
||||
if(cmdstack.size()>0){
|
||||
//将当前作用域构建为运行对象
|
||||
IWQL iwql = getWQLObject(wql);
|
||||
stack.push(iwql);
|
||||
|
||||
|
||||
//则用前一命令域替换当前命令域
|
||||
cmd = cmdstack.pop();
|
||||
}else{
|
||||
@@ -154,7 +154,7 @@ public class Syntax {
|
||||
stack.push(wql);
|
||||
}
|
||||
}else if(SINGWORD.contains(cmdname)){ //2、如果遇到单个运算符
|
||||
|
||||
|
||||
ArrayList ls = new ArrayList();
|
||||
ls.add(wql);
|
||||
IWQL iwql = null;
|
||||
@@ -172,7 +172,7 @@ public class Syntax {
|
||||
IWQL iwql = new wqlAssign();
|
||||
iwql.setWQL(wo, wql, null);
|
||||
iwql.exec(-1);
|
||||
|
||||
|
||||
}else if("IF".equals(cmd)
|
||||
||"LOOP".equals(cmd)
|
||||
||"WHILE".equals(cmd)){
|
||||
@@ -189,7 +189,7 @@ public class Syntax {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
log.debug("cmdstack size:"+cmdstack.size());
|
||||
log.debug("stack size:"+stack.size());
|
||||
if(stack.size()>0){
|
||||
@@ -200,7 +200,7 @@ public class Syntax {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 按命令域执行指令
|
||||
* @param endCmd
|
||||
@@ -226,10 +226,9 @@ public class Syntax {
|
||||
iwql.setWQL(this.wo,cmdLine, ls);
|
||||
return iwql;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 执行完整指令,包含嵌套
|
||||
* @param list
|
||||
*/
|
||||
private boolean exec(String endCmd){
|
||||
boolean isSuccess = false;
|
||||
@@ -248,14 +247,14 @@ public class Syntax {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IWQL iwql = IWQL.newInstance(startCmd);
|
||||
//赋值
|
||||
iwql.setWQL(this.wo,cmdLine, ls);
|
||||
isSuccess = iwql.exec(-1);
|
||||
return isSuccess;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user