diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 000000000..73f69e095 --- /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 000000000..38d573bd0 --- /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 000000000..dee037ee1 --- /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 000000000..9b6c85f8f --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,37 @@ + + + + \ No newline at end of file diff --git a/.idea/lanzhouhailiang_one.iml b/.idea/lanzhouhailiang_one.iml new file mode 100644 index 000000000..d6ebd4805 --- /dev/null +++ b/.idea/lanzhouhailiang_one.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 000000000..68ad8de93 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 000000000..35eb1ddfb --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/featuretodo.md b/lms/nladmin-system/src/main/java/org/nl/sso/featuretodo.md index 27a15f8df..7e8b33cb6 100644 --- a/lms/nladmin-system/src/main/java/org/nl/sso/featuretodo.md +++ b/lms/nladmin-system/src/main/java/org/nl/sso/featuretodo.md @@ -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.前端移动模块包括:用户,角色,菜单,部门,字典 param,grid ,登入页面 diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/system/domain/User.java b/lms/nladmin-system/src/main/java/org/nl/sso/system/domain/User.java index ac297078c..6b969f17f 100644 --- a/lms/nladmin-system/src/main/java/org/nl/sso/system/domain/User.java +++ b/lms/nladmin-system/src/main/java/org/nl/sso/system/domain/User.java @@ -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 roles; + + private List depts; private String person_name; diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/system/domain/vo/UserVo.java b/lms/nladmin-system/src/main/java/org/nl/sso/system/domain/vo/UserVo.java new file mode 100644 index 000000000..f3de74044 --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/sso/system/domain/vo/UserVo.java @@ -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 roles; + + private List 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()); + } + } +} diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/system/rest/RoleController.java b/lms/nladmin-system/src/main/java/org/nl/sso/system/rest/RoleController.java index d11fc8181..212866ea8 100644 --- a/lms/nladmin-system/src/main/java/org/nl/sso/system/rest/RoleController.java +++ b/lms/nladmin-system/src/main/java/org/nl/sso/system/rest/RoleController.java @@ -38,6 +38,12 @@ public class RoleController { return new ResponseEntity<>(roleService.queryAll(criteria, pageable), HttpStatus.OK); } + @ApiOperation("查询所有角色") + @GetMapping("/all") + public ResponseEntity query() { + return new ResponseEntity<>(roleService.queryAll(), HttpStatus.OK); + } + @Log("新增角色") @ApiOperation("新增角色") diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/RoleService.java b/lms/nladmin-system/src/main/java/org/nl/sso/system/service/RoleService.java index 5cefe6582..20f53605e 100644 --- a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/RoleService.java +++ b/lms/nladmin-system/src/main/java/org/nl/sso/system/service/RoleService.java @@ -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 queryAll(); + /** * 创建 * @param form / diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/UserService.java b/lms/nladmin-system/src/main/java/org/nl/sso/system/service/UserService.java index 51a332368..09a2aceb6 100644 --- a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/UserService.java +++ b/lms/nladmin-system/src/main/java/org/nl/sso/system/service/UserService.java @@ -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 queryAll(UserQueryCriteria criteria); + List queryAll(UserQueryCriteria criteria); /** diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/RoleServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/RoleServiceImpl.java index 8ea319ab6..2d0f6417b 100644 --- a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/RoleServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/RoleServiceImpl.java @@ -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 queryAll() { + JSONArray sysRoles = WQLObject.getWQLObject("sys_role").query("is_used =1 and is_delete = 0").getResultJSONArray(0); + List roleVos = sysRoles.toJavaList(RoleVo.class); + return roleVos; + } + @Override public JSONObject queryAll(Map whereJson, Pageable page) { WQLObject wo = WQLObject.getWQLObject("sys_role"); diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/UserServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/UserServiceImpl.java index beb7a484c..ce8ba39f7 100644 --- a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/UserServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/UserServiceImpl.java @@ -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 users = array.toJavaList(UserVo.class); + jsonObject.put("content",users); return jsonObject; } @Override - public List queryAll(UserQueryCriteria criteria) { + public List 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 users = array.toJavaList(User.class); + List 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 depts = resources.getDepts(); + List 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); - } + 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 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); - } + List depts = resources.getDepts(); + List 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()); diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/mps/service/impl/WorkteamServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/mps/service/impl/WorkteamServiceImpl.java index ff5bd726c..b94e11740 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/mps/service/impl/WorkteamServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/mps/service/impl/WorkteamServiceImpl.java @@ -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 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)); diff --git a/lms/nladmin-ui/src/views/system/user/index.vue b/lms/nladmin-ui/src/views/system/user/index.vue index 906f955eb..9f28ec97e 100644 --- a/lms/nladmin-ui/src/views/system/user/index.vue +++ b/lms/nladmin-ui/src/views/system/user/index.vue @@ -77,7 +77,8 @@ - +
+ - +
+