Parcourir la source

权限 :人员搜索增加按角色搜索

wangdy il y a 8 ans
Parent
commit
932d1c8071

+ 2 - 2
src/main/java/com/uas/platform/b2c/common/account/controller/UserController.java

@@ -135,9 +135,9 @@ public class UserController {
 	 * @return 完整的企业人员信息
 	 * @return 完整的企业人员信息
 	 */
 	 */
 	@RequestMapping(value = "/enterprise/keywordinfo",method = RequestMethod.GET)
 	@RequestMapping(value = "/enterprise/keywordinfo",method = RequestMethod.GET)
-	public Page<User> getEnterpriseAllUsersInfoByKeyword(PageParams params, Long enuu, String keyword){
+	public Page<User> getEnterpriseAllUsersInfoByKeyword(PageParams params, Long enuu, String keyword , Long roleId){
 		PageInfo pageInfo = new PageInfo(params);
 		PageInfo pageInfo = new PageInfo(params);
-		return userService.findUsersPageByEnUUAndKeyword(pageInfo,enuu,keyword);
+		return userService.findUsersPageByEnUUAndKeyword(pageInfo,enuu,keyword,roleId);
 	}
 	}
 
 
 	/**
 	/**

+ 1 - 1
src/main/java/com/uas/platform/b2c/common/account/service/UserService.java

@@ -50,7 +50,7 @@ public interface UserService {
 	 * @return
 	 * @return
 	 */
 	 */
 	Page<User> findUsersPageByEnUU(PageInfo pageInfo, Long enUU);
 	Page<User> findUsersPageByEnUU(PageInfo pageInfo, Long enUU);
-	Page<User> findUsersPageByEnUUAndKeyword(PageInfo pageInfo , Long enUU , String keyword);
+	Page<User> findUsersPageByEnUUAndKeyword(PageInfo pageInfo , Long enUU , String keyword , Long roleId);
 	/**
 	/**
 	 * 按email取用户信息
 	 * 按email取用户信息
 	 * 
 	 * 

+ 43 - 11
src/main/java/com/uas/platform/b2c/common/account/service/impl/UserServiceImpl.java

@@ -31,6 +31,7 @@ import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
 import javax.persistence.criteria.Root;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
+import java.lang.reflect.Array;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.*;
 
 
@@ -57,8 +58,11 @@ public class UserServiceImpl implements UserService {
 	@Autowired
 	@Autowired
 	private CommonDao commonDao;
 	private CommonDao commonDao;
 
 
+/*
 	@Autowired
 	@Autowired
 	private MailService mailService;
 	private MailService mailService;
+*/
+
 	@Autowired
 	@Autowired
 	private MessageConf messageConf;
 	private MessageConf messageConf;
 
 
@@ -201,19 +205,47 @@ public class UserServiceImpl implements UserService {
 		}
 		}
 	}
 	}
 	@Override
 	@Override
-	public Page<User> findUsersPageByEnUUAndKeyword(final PageInfo pageInfo , Long enUU , String keyword) {
+	public Page<User> findUsersPageByEnUUAndKeyword(final PageInfo pageInfo , Long enUU , String keyword, Long roleId) {
 		List<Long> usersId = new ArrayList<>();
 		List<Long> usersId = new ArrayList<>();
-		if (keyword.contains("@")) { // 按邮箱查找
-			usersId = userDao.findUserByUserEmailAndEnUU(keyword, enUU);
-		} else if (keyword.matches(TEL_REGEXP)) { // 按手机号查找
-			usersId = userDao.findUserByUserTelAndEnUU(keyword, enUU);
-		} else if (keyword.matches(UU_REGEXP)) { // 按UU号查找
-			usersId = userDao.findUserByEnUUAndUserUU(enUU, Long.parseLong(keyword));
-		} else if (!keyword.contains("@") && (keyword.matches(CHINESE_REGEXP) || keyword.matches(ENGLISH_REGEXP))) {// 按名字查找
-			usersId = userDao.findUserByUserNameAndEnUU(keyword, enUU);
-		} else{
-			usersId = userDao.findUserByUserNameAndEnUU(keyword, enUU);
+		if(keyword == null){
+			usersId = userDao.findIdByEnUU(enUU);
+		}else {
+			if (keyword.contains("@")) { // 按邮箱查找
+				usersId = userDao.findUserByUserEmailAndEnUU(keyword, enUU);
+			} else if (keyword.matches(TEL_REGEXP)) { // 按手机号查找
+				usersId = userDao.findUserByUserTelAndEnUU(keyword, enUU);
+			} else if (keyword.matches(UU_REGEXP)) { // 按UU号查找
+				usersId = userDao.findUserByEnUUAndUserUU(enUU, Long.parseLong(keyword));
+			} else if (!keyword.contains("@") && (keyword.matches(CHINESE_REGEXP) || keyword.matches(ENGLISH_REGEXP))) {// 按名字查找
+				usersId = userDao.findUserByUserNameAndEnUU(keyword, enUU);
+			} else{
+				usersId = userDao.findUserByUserNameAndEnUU(keyword, enUU);
+			}
+		}
+		if (roleId != null){
+			//过滤 角色信息
+			List<Long> usersId2 = new ArrayList(Arrays.asList(new Object[usersId.size()]));
+			Collections.copy(usersId2,usersId);
+			for (Long id : usersId){
+				User user = userDao.findOne(id);
+				int status = 0;
+				for (Role role : user.getRoles()){
+					if (role.getId().equals(roleId)){
+						status++;
+					}
+				}
+				if (status == 0){
+					for(Long x:usersId2){
+						if(x.equals(id)) {
+							usersId2.remove(x);
+							break;
+						}
+					}
+				}
+			}
+			usersId = usersId2;
 		}
 		}
+
 		final List<Long> users = usersId;
 		final List<Long> users = usersId;
 		if (users.size()>0) {
 		if (users.size()>0) {
 			Page<User> pUser = userDao.findAll(new Specification<User>() {
 			Page<User> pUser = userDao.findAll(new Specification<User>() {

+ 7 - 3
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_account_management_ctrl.js

@@ -51,6 +51,9 @@ define(['app/app'], function(app) {
 				}
 				}
 				else {
 				else {
 					param.keyword = $scope.keyword;
 					param.keyword = $scope.keyword;
+					if ($scope.filterRole !=='all'){
+					    param.roleId = $scope.filterRole;
+                    }
 					Enterprise.findUsersByKeyword(param,function (page) {
 					Enterprise.findUsersByKeyword(param,function (page) {
 						if (page) {
 						if (page) {
 							$scope.pageParam.start = (page.number-1)*page.size+1;
 							$scope.pageParam.start = (page.number-1)*page.size+1;
@@ -64,11 +67,12 @@ define(['app/app'], function(app) {
 				}
 				}
 			}
 			}
 		});
 		});
-
-		$scope.onSearch = function(keyword) {
-			if(keyword != null && keyword != '') {
+        $scope.filterRole = 'all';
+		$scope.onSearch = function(keyword,filterRole) {
+            if((keyword != null && keyword != '') || filterRole !=='all') {
 				$scope.searchMthod = true;
 				$scope.searchMthod = true;
 				$scope.keyword = keyword;
 				$scope.keyword = keyword;
+				$scope.filterRole = filterRole;
 			} else {
 			} else {
 				$scope.searchMthod = false;
 				$scope.searchMthod = false;
 			}
 			}

+ 13 - 11
src/main/webapp/resources/view/vendor/forstore/vendor_account_management.html

@@ -617,17 +617,17 @@
                         </ul>
                         </ul>
                     </div>
                     </div>
                 </div>
                 </div>
-                <div class="user-list">
+               <!-- <div class="user-list">
                     <div class="user-list-head count_basic">
                     <div class="user-list-head count_basic">
                         <div class="basic_title">
                         <div class="basic_title">
-                            <span>企业成员信息</span><!--<span class="fr"><a href="#">修改</a><a href="#">提交</a><a href="#">删除</a></span>-->
+                            <span>企业成员信息</span>&lt;!&ndash;<span class="fr"><a href="#">修改</a><a href="#">提交</a><a href="#">删除</a></span>&ndash;&gt;
                             <span class="pull-right" ng-show="userInfo.sys">
                             <span class="pull-right" ng-show="userInfo.sys">
                                 <a title="新增用户默认密码为111111" ng-show="adding == true" class="btn btn-success btn-sm" ng-disabled="newUserForm.$invalid" ng-click="addUser(newUser)" class="text-simple" style="color: #fff;">
                                 <a title="新增用户默认密码为111111" ng-show="adding == true" class="btn btn-success btn-sm" ng-disabled="newUserForm.$invalid" ng-click="addUser(newUser)" class="text-simple" style="color: #fff;">
                                     <i class="fa fa-user-plus fa-fw"></i>确定添加</a>
                                     <i class="fa fa-user-plus fa-fw"></i>确定添加</a>
                                 <a ng-click="adding = false" ng-show="adding == true" class="text-simple"><i class="fa fa-user-plus fa-fw"></i>
                                 <a ng-click="adding = false" ng-show="adding == true" class="text-simple"><i class="fa fa-user-plus fa-fw"></i>
                                     取消
                                     取消
                                 </a>
                                 </a>
-                                <!-- 添加用户 start -->
+                                &lt;!&ndash; 添加用户 start &ndash;&gt;
                                 <div class="row-operator2">
                                 <div class="row-operator2">
                                     <a ng-show="adding != true" class="text-simple operator-trigger" href="javascript:void(0);">
                                     <a ng-show="adding != true" class="text-simple operator-trigger" href="javascript:void(0);">
                                         <i class="fa fa-user-plus fa-fw"></i>
                                         <i class="fa fa-user-plus fa-fw"></i>
@@ -638,7 +638,7 @@
                                         <li><a ng-click="addExistUser()">添加已注册用户</a></li>
                                         <li><a ng-click="addExistUser()">添加已注册用户</a></li>
                                     </ul>
                                     </ul>
                                 </div>
                                 </div>
-                                <!-- 添加用户 end -->
+                                &lt;!&ndash; 添加用户 end &ndash;&gt;
                         </span>
                         </span>
                         </div>
                         </div>
                     </div>
                     </div>
@@ -660,7 +660,7 @@
                                     <th width="140">邮箱</th>
                                     <th width="140">邮箱</th>
                                     <th width="100">角色</th>
                                     <th width="100">角色</th>
                                     <th width="80">&nbsp;</th>
                                     <th width="80">&nbsp;</th>
-                                    <!--<th width="50" ng-show="active=='chargeapply'">操作</th>-->
+                                    &lt;!&ndash;<th width="50" ng-show="active=='chargeapply'">操作</th>&ndash;&gt;
                                 </tr>
                                 </tr>
                             </thead>
                             </thead>
                             <tbody>
                             <tbody>
@@ -709,9 +709,9 @@
                                         </div>
                                         </div>
                                     </td>
                                     </td>
                                     <td>
                                     <td>
-                                        <!--<a class="operator-trigger" href="javascript:void(0);"><i class="fa fa-pencil fa-lg" ng-show="(userInfo.sys && enterprise.enAdminuu != user.userUU) || users.length == 1"></i></a>-->
+                                        &lt;!&ndash;<a class="operator-trigger" href="javascript:void(0);"><i class="fa fa-pencil fa-lg" ng-show="(userInfo.sys && enterprise.enAdminuu != user.userUU) || users.length == 1"></i></a>&ndash;&gt;
                                         <ul class="list-unstyle list-inline operator-menu" ng-show="(userInfo.sys && enterprise.enAdminuu != user.userUU) || users.length == 1">
                                         <ul class="list-unstyle list-inline operator-menu" ng-show="(userInfo.sys && enterprise.enAdminuu != user.userUU) || users.length == 1">
-                                            <!--<li><a ng-click="editUserRole(u)"><i class="fa fa-fw fa-pencil-square-o" style="color: #fff"></i>编辑</a></li>-->
+                                            &lt;!&ndash;<li><a ng-click="editUserRole(u)"><i class="fa fa-fw fa-pencil-square-o" style="color: #fff"></i>编辑</a></li>&ndash;&gt;
                                             <li><a ng-click="removeUser(user)" ng-if="user.userUU != userInfo.userUU" title="删除"><i class="fa fa-fw fa-trash-o" style="color: #fff"></i>删除</a></li>
                                             <li><a ng-click="removeUser(user)" ng-if="user.userUU != userInfo.userUU" title="删除"><i class="fa fa-fw fa-trash-o" style="color: #fff"></i>删除</a></li>
                                         </ul>
                                         </ul>
                                     </td>
                                     </td>
@@ -719,7 +719,7 @@
                             </tbody>
                             </tbody>
                         </table>
                         </table>
                     </form>
                     </form>
-                </div>
+                </div>-->
             </div>
             </div>
             </div>
             </div>
             <!--安全设置-->
             <!--安全设置-->
@@ -788,14 +788,16 @@
                         </div>
                         </div>
                     </div>
                     </div>
                     <div class="searchUser-group">
                     <div class="searchUser-group">
-                        <span ng-click="onSearch(keyword)">搜索</span>
+                        <span ng-click="onSearch(keyword,filterRole)">搜索</span>
 
 
                         <input type="text"  ng-model="keyword"
                         <input type="text"  ng-model="keyword"
                                ng-search="onSearch(keyword)" placeholder="输入人员姓名、电话号码、邮箱或UU号进行搜索"/>
                                ng-search="onSearch(keyword)" placeholder="输入人员姓名、电话号码、邮箱或UU号进行搜索"/>
                         <!--<input type="text">-->
                         <!--<input type="text">-->
                         <div>
                         <div>
-                            <select>
-                                <option value="all">全部角色</option>
+                            <select ng-model="filterRole" >
+                                <option value="all" selected="selected">全部角色</option>
+                                <option ng-repeat="role1 in roles.defaults" value="{{role1.id}}" >{{role1.desc}}</option>
+                                <option ng-repeat="role2 in roles.custom" value="{{role2.id}}" >{{role2.desc}}</option>
                             </select>
                             </select>
                         </div>
                         </div>
                     </div>
                     </div>