Commit bdd64e12 authored by frank.xa.zhang's avatar frank.xa.zhang

add user and role module -- frank

parent 4403bb37
......@@ -4,26 +4,14 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import pwc.taxtech.atms.dpo.UserRoleInfo;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.dimension.DimensionValueUpdateDto;
import pwc.taxtech.atms.dto.navtree.NavTreeDto;
import pwc.taxtech.atms.dto.role.RoleDisplayDto;
import pwc.taxtech.atms.dto.role.RoleDto;
import pwc.taxtech.atms.dto.role.RoleDtoTree;
import pwc.taxtech.atms.dto.role.RolePermissionDto;
import pwc.taxtech.atms.dto.role.UpdateRoleInfo;
import pwc.taxtech.atms.dto.user.DimensionRole;
import pwc.taxtech.atms.dto.user.DimensionUser;
import pwc.taxtech.atms.dto.user.UserRoleDimensionValueDto;
import pwc.taxtech.atms.dto.user.UserRoleDto;
import pwc.taxtech.atms.dto.user.UserRoleUpdateDto;
import pwc.taxtech.atms.dto.role.*;
import pwc.taxtech.atms.dto.user.*;
import pwc.taxtech.atms.organization.dpo.UserRoleHKInfo;
import pwc.taxtech.atms.service.impl.RoleServiceImpl;
import java.util.HashMap;
......@@ -53,7 +41,7 @@ public class RoleController {
// @ApiOperation(value = "获取所有用户角色", notes = "返回所有用户的角色")
@RequestMapping(value = "getAllOwnUserRoleList", method = RequestMethod.GET)
public @ResponseBody
List<UserRoleInfo> getAllOwnUserRoleList() {
List<UserRoleHKInfo> getAllOwnUserRoleList() {
logger.debug("RoleController getAllOwnUserRoleList");
return roleService.getAllOwnUserRoleList();
}
......
......@@ -294,7 +294,7 @@ public class OrganizationHKServiceImpl {
return parentOrg;
}
private List<OrganizationHK> findAllOrganizations() {
public List<OrganizationHK> findAllOrganizations() {
OrganizationHKExample organizationExample = new OrganizationHKExample();
return organizationHKMapper.selectByExample(organizationExample);
}
......
......@@ -19,6 +19,8 @@ import pwc.taxtech.atms.dto.role.*;
import pwc.taxtech.atms.dto.user.*;
import pwc.taxtech.atms.entity.*;
import pwc.taxtech.atms.entity.UserRoleExample.Criteria;
import pwc.taxtech.atms.organization.dpo.UserRoleHKInfo;
import pwc.taxtech.atms.organization.entity.OrganizationHK;
import pwc.taxtech.atms.security.JwtAuthenticationService;
import java.util.*;
......@@ -510,74 +512,58 @@ public class RoleServiceImpl extends AbstractService {
return retList;
}
public List<UserRoleInfo> getAllOwnUserRoleList() {
// logger.debug("Start to get all own user roles");
// List<User> userList = userService.findAllUsers();
// // 角色列表
// List<Role> roleList = findAll();
// // 原始维度
// List<UserRole> userRoleList = userRoleService.findAllUserRoles();
// List<OrganizationHK> organizationList = organizationService.findAllOrganizations();
// List<UserRoleInfo> retList = new ArrayList<>();
//
// for (User userItem : userList) {
// List<UserRole> sameList = userRoleList.stream().filter(sa -> userItem.getId().equals(sa.getUserId()))
// .collect(Collectors.toList());
// List<OrganizationHK> orgList = organizationList.stream()
// .filter(sa -> sa.getId().equals(userItem.getOrganizationId())).collect(Collectors.toList());
// if (orgList.isEmpty()) {
// continue;
// }
// OrganizationHK org = orgList.get(0);
// UserRoleInfo userRoleInfo = new UserRoleInfo();
// userRoleInfo.setUserName(userItem.getUserName());
// userRoleInfo.setStatus(userItem.getStatus());
// userRoleInfo.setServiceTypeId("");
// userRoleInfo.setRoleInfoList(new ArrayList<>());
// userRoleInfo.setOrganizationName(org.getName());
// userRoleInfo.setOrganizationId(org.getId());
// userRoleInfo.setIsAccessible(true);
// userRoleInfo.setEmail(userItem.getEmail());
// userRoleInfo.setBusinessUnitId(org.getBusinessUnitId());
// userRoleInfo.setAreaId(org.getAreaId());
// userRoleInfo.setId(userItem.getId());
//
// List<RoleInfo> roleInfoList = new ArrayList<>();
// for (UserRole userRole : sameList) {
// for (Role role : roleList) {
// if (role.getId().equals(userRole.getRoleId())) {
// RoleInfo roleInfo = new RoleInfo();
// roleInfo.setDimensionId("");
// roleInfo.setDimensionValue("");
// roleInfo.setDimensionValueId("");
// roleInfo.setId(role.getId());
// roleInfo.setIsAccessible(true);
// roleInfo.setIsHeritable(true);
// roleInfo.setName(role.getName());
// roleInfo.setRoleSource(RoleSourceEnum.OriginalLevel.value());
// roleInfoList.add(roleInfo);
// }
// }
// }
// userRoleInfo.setRoleInfoList(roleInfoList);
// retList.add(userRoleInfo);
// }
// // 这里可以一次查出来再合并
// retList.forEach(l->{
// if(null!=l.getBusinessUnitId()){
// BusinessUnit bu = businessUnitMapper.selectByPrimaryKey(l.getBusinessUnitId());
// if(bu!=null){
// l.setBusinessUnitName(bu.getName());
// }
// }
// if (null!=l.getAreaId()){
// Area area = areaMapper.selectByPrimaryKey(l.getAreaId());
// if(area!=null){
// l.setAreaName(area.getName());
// }
// }
// });
return java.util.Collections.emptyList();
public List<UserRoleHKInfo> getAllOwnUserRoleList() {
logger.debug("Start to get all own user roles");
List<User> userList = userService.findAllUsers();
// 角色列表
List<Role> roleList = findAll();
// 原始维度
List<UserRole> userRoleList = userRoleService.findAllUserRoles();
List<OrganizationHK> organizationList = organizationService.findAllOrganizations();
List<UserRoleHKInfo> retList = new ArrayList<>();
for (User userItem : userList) {
List<UserRole> sameList = userRoleList.stream().filter(sa -> userItem.getId().equals(sa.getUserId()))
.collect(Collectors.toList());
List<OrganizationHK> orgList = organizationList.stream()
.filter(sa -> sa.getId().toString().equals(userItem.getOrganizationId())).collect(Collectors.toList());
if (orgList.isEmpty()) {
continue;
}
OrganizationHK org = orgList.get(0);
UserRoleHKInfo userRoleInfo = new UserRoleHKInfo();
userRoleInfo.setUserName(userItem.getUserName());
userRoleInfo.setStatus(userItem.getStatus());
userRoleInfo.setServiceTypeId("");
userRoleInfo.setOrganizationName(org.getName());
userRoleInfo.setOrganizationId(org.getId());
userRoleInfo.setIsAccessible(true);
userRoleInfo.setEmail(userItem.getEmail());
userRoleInfo.setBusinessUnitId(org.getBusinessUnitId());
userRoleInfo.setAreaId(org.getAreaId());
userRoleInfo.setId(userItem.getId());
List<RoleInfo> roleInfoList = new ArrayList<>();
for (UserRole userRole : sameList) {
for (Role role : roleList) {
if (role.getId().equals(userRole.getRoleId())) {
RoleInfo roleInfo = new RoleInfo();
roleInfo.setDimensionId("");
roleInfo.setDimensionValue("");
roleInfo.setDimensionValueId("");
roleInfo.setId(role.getId());
roleInfo.setIsAccessible(true);
roleInfo.setIsHeritable(true);
roleInfo.setName(role.getName());
roleInfo.setRoleSource(RoleSourceEnum.OriginalLevel.value());
roleInfoList.add(roleInfo);
}
}
}
userRoleInfo.setRoleInfoList(roleInfoList);
retList.add(userRoleInfo);
}
return retList;
}
public List<UserRoleInfo> getAllUserRoleList() {
......
package pwc.taxtech.atms.organization.dpo;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
import pwc.taxtech.atms.dpo.RoleInfo;
import java.util.List;
import java.util.stream.Collectors;
@Getter
@Setter
public class UserRoleHKInfo {
/// 用户Id
/// The identifier.
// @JsonProperty("ID")
private String id;
/// 用户名
/// The name of the user.
private String userName;
private String email;
/// 1:激活
/// -1:未激活
/// 0:禁用
/// 2:锁定
/// The status.
public Integer status;
/// 机构Id
/// The organization identifier.
@JsonProperty("organizationID")
private Long organizationId;
@JsonProperty("serviceTypeID")
private String serviceTypeId;
/// 机构名
/// The name of the organization.
private String organizationName;
/// 事业部
@JsonProperty("businessUnitID")
private String businessUnitId;
private String businessUnitName;
/// 区域Id
@JsonProperty("areaID")
private String areaId;
private String areaName;
public Boolean isAccessible;
/// 角色列表
/// The role information list.
public List<RoleInfo> roleInfoList;
public String roleList;
public String statusStr;
public String getRoleList() {
if(!this.roleInfoList.isEmpty()){
List<String> rList = this.roleInfoList.stream().map(RoleInfo::getName).collect(Collectors.toList());
return JSON.toJSONString(rList);
}
return roleList;
}
public void setRoleList(String roleList) {
this.roleList = roleList;
}
}
infrastructureModule
.controller('UserManageListController', ['$state','$filter', '$scope', '$log', 'userService', 'orgService', 'SweetAlert', 'projectService', 'roleService', '$translate', 'enums', 'businessUnitService', 'areaService', '$timeout', 'loginContext',
function ($state,$filter, $scope, $log, userService, orgService, SweetAlert, projectService, roleService, $translate, enums, businessUnitService, areaService, $timeout, loginContext) {
.controller('UserManageListController', ['$state','$filter', '$scope', '$log', 'userService', 'orgHKService', 'SweetAlert', 'projectService', 'roleService', '$translate', 'enums', 'businessUnitService', 'areaService', '$timeout', 'loginContext',
function ($state,$filter, $scope, $log, userService, orgHKService, SweetAlert, projectService, roleService, $translate, enums, businessUnitService, areaService, $timeout, loginContext) {
'use strict';
/***********************************************************new code start*********************************************************/
......@@ -12,19 +12,8 @@
$scope.getOrgListToJson = function () {
$scope.doing_async = true;
orgService.getOrgListToJson(0).success(function (data) {
var filterData = [];
if (loginContext.userName && loginContext.userName.toLowerCase() === "simon") {
data.forEach(function (row) {
if (row && row.data.industryID === '10') {
filterData.push(row);
}
});
} else {
filterData = data;
}
orgHKService.getOrgListToJson(0).success(function (data) {
var filterData = data;
$scope.orgTreeData = filterData;
$scope.doing_async = false;
......@@ -351,12 +340,6 @@
return row.userName && row.userName.toLowerCase() !== "admin";
});
if (loginContext.userName.toLowerCase() === "simon") {
data = _.filter(data, function (row) {
return row.userName !== "aaa" && row.userName !== "bbb";
});
}
// 先排序
data = sortByUserName(data);
$scope.originalUserRoleList = data;
......@@ -373,16 +356,9 @@
roleService.getAllOwnUserRoleList().success(function (data) {
data = _.filter(data, function (row) {
return row.userName && row.userName.toLowerCase() !== "admin";
});
if (loginContext.userName.toLowerCase() === "simon") {
data = _.filter(data, function (row) {
return row.userName !== "aaa" && row.userName !== "bbb";
});
}
// 先排序
data = sortByUserName(data);
$scope.originalUserRoleList = data;
......@@ -608,7 +584,7 @@
}
// 只显示禁用的用户
if (!$scope.showActiveUser && user.status != enums.userStatus.disabled) {
if (!$scope.showActiveUser && user.status !== enums.userStatus.disabled) {
continue;
}
......@@ -620,13 +596,13 @@
}*/
// 只显示禁用的用户
if (!$scope.showActiveUser && user.status != enums.userStatus.disabled) {
if (!$scope.showActiveUser && user.status !== enums.userStatus.disabled) {
continue;
}
}
// 根据机构做筛选
if ($scope.selectOrgBranch && user.organizationID != $scope.selectOrgBranch.data.id) {
if ($scope.selectOrgBranch && user.organizationID !== $scope.selectOrgBranch.data.id) {
continue;
}
......@@ -636,32 +612,32 @@
return row.data.id === user.organizationID;
});
if (!query || query.length == 0) {
if (!query || query.length === 0) {
continue;
}
}
// 事业部筛选
if ($scope.selectBusinessUnitList && $scope.selectBusinessUnitList.length > 0) {
var query = _.filter($scope.selectBusinessUnitList, function (row) {
return row.ID === user.businessUnitID;
});
if (!query || query.length == 0) {
continue;
}
}
// if ($scope.selectBusinessUnitList && $scope.selectBusinessUnitList.length > 0) {
// var query = _.filter($scope.selectBusinessUnitList, function (row) {
// return row.ID === user.businessUnitID;
// });
//
// if (!query || query.length === 0) {
// continue;
// }
// }
// 区域
if ($scope.selectAreaList && $scope.selectAreaList.length > 0) {
var query = _.filter($scope.selectAreaList, function (row) {
return row.ID === user.areaID;
});
if (!query || query.length == 0) {
continue;
}
}
// if ($scope.selectAreaList && $scope.selectAreaList.length > 0) {
// var query = _.filter($scope.selectAreaList, function (row) {
// return row.ID === user.areaID;
// });
//
// if (!query || query.length === 0) {
// continue;
// }
// }
// 角色筛选
if ($scope.selectRoleList && $scope.selectRoleList.length > 0) {
......@@ -671,7 +647,7 @@
return roleIdList.indexOf(row.data.id) > -1;
});
if (!query || query.length == 0) {
if (!query || query.length === 0) {
continue;
}
}
......@@ -734,7 +710,7 @@
if ($scope.userRoleList && $scope.userRoleList.length > 0) {
$scope.queryResult.pageInfo.totalCount = $scope.userRoleList.length;
var totalPage = parseInt($scope.queryResult.pageInfo.totalCount / $scope.queryResult.pageInfo.pageSize);
totalPage = $scope.queryResult.pageInfo.totalCount % $scope.queryResult.pageInfo.pageSize == 0 ? totalPage : totalPage + 1;
totalPage = $scope.queryResult.pageInfo.totalCount % $scope.queryResult.pageInfo.pageSize === 0 ? totalPage : totalPage + 1;
$scope.queryResult.pageInfo.totalPage = totalPage;
$scope.creatPage = $("#userManagePager").createPage({
......
......@@ -3,7 +3,8 @@
<div class="menu-title">{{'UserManagement' | translate}}</div>
<div class="user-list-container">
<div class="search-container">
<input class="search-input" type="text" value="" placeholder="{{'Search' | translate}}" ng-model="queryUser" ng-change="queryUserEvent()" /><span class="glyphicon glyphicon-search input-group-addon search-icon"></span>
<input class="search-input" type="text" value="" placeholder="{{'Search' | translate}}" ng-model="queryUser" ng-change="queryUserEvent()"/><span
class="glyphicon glyphicon-search input-group-addon search-icon"></span>
</div>
<button class=" btn btn-in-grid " ng-class="{false:'no-permission'}[hasAddPermission]" ng-disabled="!hasAddPermission" ng-click="addUser()">
<i class=" material-icons middle ">
......@@ -48,37 +49,37 @@
</div>
</div>
<!--事业部-->
<div class="dimension-block">
<div class="text-location" ng-click="showMoreBusinessUnitClick()">
<span class="text-title" translate="FieldbusinessUnitName"></span>
<span class="show-more">
<i class="fa fa-angle-down" aria-hidden="true" ng-show="!showMoreBusinessUnit"></i>
<i class="fa fa-angle-up" aria-hidden="true" ng-show="showMoreBusinessUnit"></i>
</span>
</div>
<div class="list-container" ng-class="{false:'show-less',true:''}[showMoreBusinessUnit]">
<div ng-repeat="x in businessUnitList" class="business-item" ng-class="{true:'active',false:''}[x.selected]" ng-click="singleClickBusinessUnit(x)">
<span title="{{x.name}}">{{x.name | limitString:20}}</span>
<span ng-if="x.isShowCount" class="label-count">{{x.count}}</span>
</div>
</div>
</div>
<!--<div class="dimension-block">-->
<!--<div class="text-location" ng-click="showMoreBusinessUnitClick()">-->
<!--<span class="text-title" translate="FieldbusinessUnitName"></span>-->
<!--<span class="show-more">-->
<!--<i class="fa fa-angle-down" aria-hidden="true" ng-show="!showMoreBusinessUnit"></i>-->
<!--<i class="fa fa-angle-up" aria-hidden="true" ng-show="showMoreBusinessUnit"></i>-->
<!--</span>-->
<!--</div>-->
<!--<div class="list-container" ng-class="{false:'show-less',true:''}[showMoreBusinessUnit]">-->
<!--<div ng-repeat="x in businessUnitList" class="business-item" ng-class="{true:'active',false:''}[x.selected]" ng-click="singleClickBusinessUnit(x)">-->
<!--<span title="{{x.name}}">{{x.name | limitString:20}}</span>-->
<!--<span ng-if="x.isShowCount" class="label-count">{{x.count}}</span>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
<!-- 区域 -->
<div class="dimension-block">
<div class="text-location" ng-click="showMoreAreaToggle()">
<span class="text-title" translate="OrgArea"></span>
<span class="show-more">
<i class="fa fa-angle-down" aria-hidden="true" ng-show="!showMoreArea"></i>
<i class="fa fa-angle-up" aria-hidden="true" ng-show="showMoreArea"></i>
</span>
</div>
<div class="list-container" ng-class="{false:'show-less',true:''}[showMoreArea]">
<div ng-repeat="x in areaList" class="business-item" class="business-item" ng-class="{true:'active',false:''}[x.selected]" ng-click="singleClickArea(x)">
<span title="{{x.name}}">{{x.name | limitString:20}}</span>
<span ng-if="x.isShowCount" class="label-count">{{x.count}}</span>
</div>
</div>
</div>
<!--<div class="dimension-block">-->
<!--<div class="text-location" ng-click="showMoreAreaToggle()">-->
<!--<span class="text-title" translate="OrgArea"></span>-->
<!--<span class="show-more">-->
<!--<i class="fa fa-angle-down" aria-hidden="true" ng-show="!showMoreArea"></i>-->
<!--<i class="fa fa-angle-up" aria-hidden="true" ng-show="showMoreArea"></i>-->
<!--</span>-->
<!--</div>-->
<!--<div class="list-container" ng-class="{false:'show-less',true:''}[showMoreArea]">-->
<!--<div ng-repeat="x in areaList" class="business-item" class="business-item" ng-class="{true:'active',false:''}[x.selected]" ng-click="singleClickArea(x)">-->
<!--<span title="{{x.name}}">{{x.name | limitString:20}}</span>-->
<!--<span ng-if="x.isShowCount" class="label-count">{{x.count}}</span>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
<!--角色-->
<div class="dimension-block">
<div class="text-location" ng-click="showMoreRoleToggle()">
......@@ -119,15 +120,15 @@
<span ng-click="singleClickOrg(x)">×</span>
</div>
<!-- 选择事业部 -->
<div class="query-item" ng-repeat="x in selectBusinessUnitList ">
{{'FieldbusinessUnitName'|translate}}:{{x.name}}
<span ng-click="singleClickBusinessUnit(x)">×</span>
</div>
<!--<div class="query-item" ng-repeat="x in selectBusinessUnitList ">-->
<!--{{'FieldbusinessUnitName'|translate}}:{{x.name}}-->
<!--<span ng-click="singleClickBusinessUnit(x)">×</span>-->
<!--</div>-->
<!-- 选择区域 -->
<div class="query-item" ng-repeat="x in selectAreaList ">
{{'OrgArea'|translate}}:{{x.name}}
<span ng-click="singleClickArea(x)">×</span>
</div>
<!--<div class="query-item" ng-repeat="x in selectAreaList ">-->
<!--{{'OrgArea'|translate}}:{{x.name}}-->
<!--<span ng-click="singleClickArea(x)">×</span>-->
<!--</div>-->
<!-- 选择角色 -->
<div class="query-item" ng-repeat="x in selectRoleList ">
{{'RoleDesc'|translate}}:{{x.label}}
......
......@@ -22,22 +22,24 @@
<div class="form-group">
<label class="control-label col-sm-3" for="inputUserName"><span class="red-color">*</span><span translate="UserNameColon"></span></label>
<div class="col-sm-9">
<input id="inputUserName" type="text" name="inputUserName" class="form-control" maxlength="50" style="width: 300px;" placeholder="{{'PUserName'|translate}}" ng-model="editUserModel.UserName" required>
<input id="inputUserName" type="text" name="inputUserName" class="form-control" maxlength="50" style="width: 300px;" placeholder="{{'PUserName'|translate}}"
ng-model="editUserModel.UserName" required>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-3" for="inputUserEmail"><span class="red-color">*</span><span translate="E-mailColon"></label>
<div class="col-sm-9">
<input id="inputUserEmail" type="email" name="inputUserEmail" maxlength="100" class="form-control" style="width: 300px;" placeholder="{{'PE-mail'|translate}}" ng-model="editUserModel.Email" required>
<input id="inputUserEmail" type="email" name="inputUserEmail" maxlength="100" class="form-control" style="width: 300px;" placeholder="{{'PE-mail'|translate}}"
ng-model="editUserModel.Email" required>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-3"><span class="red-color">*</span><span translate="Company"></label>
<div class="col-sm-9">
<input id="orgName" type="text" name="orgName" maxlength="100" class="form-control" style="width: 300px;" ng-model="editUserModel.orgName" readonly="readonly" required>
<!--<org-selector selected-org-name="editUserModel.OrgName" selected-org-id="editUserModel.OrganizationID" component-selected-org="" is-show-all="false" is-require="true"
<!--<input id="orgName" type="text" name="orgName" maxlength="100" class="form-control" style="width: 300px;" ng-model="editUserModel.orgName" readonly="readonly" required>-->
<org-selector selected-org-name="editUserModel.OrgName" selected-org-id="editUserModel.OrganizationID" component-selected-org="" is-show-all="false" is-require="true"
style="width: 300px;"></org-selector>
<label class="error-label" style="font-size:12px;" ng-show="editUserModel.organizationIDError">{{editUserModel.organizationIDError}}</label>-->
<label class="error-label" style="font-size:12px;" ng-show="editUserModel.organizationIDError">{{editUserModel.organizationIDError}}</label>
</div>
</div>
<div class="form-group">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment