diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -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/ diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..38d573b --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/dictionaries b/.idea/dictionaries new file mode 100644 index 0000000..dee037e --- /dev/null +++ b/.idea/dictionaries @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..9b6c85f --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,37 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..731bc8e --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/nl-sso-server.iml b/.idea/nl-sso-server.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/nl-sso-server.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/common/base/BaseDTO.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/common/base/BaseDTO.java index 644d8b1..1cab58a 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/common/base/BaseDTO.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/common/base/BaseDTO.java @@ -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; } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/User.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/User.java index a7f34d1..2da09c5 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/User.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/User.java @@ -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; diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/vo/RoleVo.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/vo/RoleVo.java new file mode 100644 index 0000000..4d464c7 --- /dev/null +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/domain/vo/RoleVo.java @@ -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; + +} diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/rest/UserController.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/rest/UserController.java index db6ec6d..a200b1f 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/rest/UserController.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/rest/UserController.java @@ -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 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 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 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 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 delete(@RequestBody Set ids) { for (Long id : ids) { /* Integer currentLevel = Collections.min(roleService.findByUsersId(StpUtil.getLoginIdAsLong()).stream().map(Role::getLevel).collect(Collectors.toList())); diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/UserRelateService.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/UserRelateService.java new file mode 100644 index 0000000..6bfbe2f --- /dev/null +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/UserRelateService.java @@ -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 deptIds); + void inserRoleRelate(Long user,Set RoleIds); + void deleteDeptRelate(Set deptIds); + void deleteRoleRelate(Set RoleIds); + void updateDeptRelate(Long user,Set deptIds); + void updateRoleRelate(Long user,Set RoleIds); +} diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/UserRelateServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/UserRelateServiceImpl.java new file mode 100644 index 0000000..c701a20 --- /dev/null +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/UserRelateServiceImpl.java @@ -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 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 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 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 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 deptIds) { + if (user !=null){ + this.deleteDeptRelate(deptIds); + this.inserDeptRelate(user,deptIds); + } + } + + @Override + @Transactional + public void updateRoleRelate(Long user, Set RoleIds) { + if (user !=null){ + this.deleteRoleRelate(RoleIds); + this.inserRoleRelate(user,RoleIds); + } + } +} diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/UserServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/UserServiceImpl.java index 8314100..c6b26bc 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/UserServiceImpl.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/system/service/impl/UserServiceImpl.java @@ -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 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 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 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 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 diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/wql/core/engine/Syntax.java b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/wql/core/engine/Syntax.java index adff484..b0e4e8c 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/wql/core/engine/Syntax.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/modules/wql/core/engine/Syntax.java @@ -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 cmdstack = new Stack(); //指令作用域栈 - + 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; } - - - -} \ No newline at end of file + + + +} diff --git a/nladmin-ui/src/api/system/dept.js b/nladmin-ui/src/api/system/dept.js index 13ee310..145887a 100644 --- a/nladmin-ui/src/api/system/dept.js +++ b/nladmin-ui/src/api/system/dept.js @@ -8,7 +8,7 @@ export function getDepts(params) { }) } -export function getDeptTreee(params) { +export function getDeptTree(params) { return request({ url: '/api/dept/allTree', 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 } diff --git a/nladmin-ui/src/views/system/dept/index.vue b/nladmin-ui/src/views/system/dept/index.vue index f9c02af..17409c6 100644 --- a/nladmin-ui/src/views/system/dept/index.vue +++ b/nladmin-ui/src/views/system/dept/index.vue @@ -61,7 +61,7 @@ - + - + - - +
@@ -95,15 +99,14 @@
- - - {{ item.label }} - - + + + @@ -150,7 +153,7 @@