Ver código fonte

员工权限添加

wuxw 7 anos atrás
pai
commit
15ad9a0ab7

+ 19 - 0
OrderService/src/main/java/com/java110/order/api/PrivilegeApi.java

@@ -139,6 +139,25 @@ public class PrivilegeApi extends BaseController {
     }
 
 
+    @RequestMapping(path = "/addStaffPrivilegeOrPrivilegeGroup",method= RequestMethod.POST)
+    @ApiOperation(value="用户添加权限或权限组", notes="test: 返回 200 表示服务受理成功,其他表示失败")
+    @ApiImplicitParam(paramType="query", name = "privilegeInfo", value = "权限信息", required = true, dataType = "String")
+    public ResponseEntity<String> addStaffPrivilegeOrPrivilegeGroup(@RequestBody String privilegeInfo,HttpServletRequest request){
+        ResponseEntity<String> responseEntity = null;
+
+        try {
+            responseEntity = privilegeSMOImpl.addStaffPrivilegeOrPrivilegeGroup(privilegeInfo);
+        }catch (Exception e){
+            logger.error("请求订单异常",e);
+            responseEntity =  new ResponseEntity<String>("请求中心服务发生异常,"+e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
+        }finally {
+            logger.debug("订单服务返回报文为: {}",responseEntity);
+            return responseEntity;
+        }
+    }
+
+
+
     public IPrivilegeSMO getPrivilegeSMOImpl() {
         return privilegeSMOImpl;
     }

+ 21 - 0
OrderService/src/main/java/com/java110/order/dao/IPrivilegeDAO.java

@@ -53,4 +53,25 @@ public interface IPrivilegeDAO {
     public List<Map> queryPrivilegeGroup(Map info);
 
     public boolean addPrivilegeRel(Map info);
+
+    /**
+     * 查询权限
+     * @param info
+     * @return
+     */
+    public List<Map> queryPrivilege(Map info);
+
+    /**
+     * 查询用户权限
+     * @param info
+     * @return
+     */
+    public List<Map> queryUserPrivilege(Map info);
+
+    /**
+     * 添加用户权限
+     * @param info
+     * @return
+     */
+    public boolean addUserPrivilege(Map info);
 }

+ 37 - 0
OrderService/src/main/java/com/java110/order/dao/impl/PrivilegeDAOImpl.java

@@ -121,5 +121,42 @@ public class PrivilegeDAOImpl extends BaseServiceDao implements IPrivilegeDAO {
         return true;
     }
 
+    /**
+     * 查询权限
+     * @param info
+     * @return
+     */
+    @Override
+    public List<Map> queryPrivilege(Map info) {
+        logger.debug("查询权限信息入参:{}",info);
+        return sqlSessionTemplate.selectList("privilegeDAOImpl.queryPrivilege",info);
+    }
+
+    /**
+     * 查询用户默认权限
+     * @param info
+     * @return
+     */
+    @Override
+    public List<Map> queryUserPrivilege(Map info) {
+        logger.debug("查询用户权限信息入参:{}",info);
+        return sqlSessionTemplate.selectList("privilegeDAOImpl.queryUserPrivilege",info);
+    }
+
+    /**
+     * 添加用户权限
+     * @param info
+     * @return
+     */
+    @Override
+    public boolean addUserPrivilege(Map info) {
+        logger.debug("添加用户权限信息入参:{}",info);
+        int saveFlag = sqlSessionTemplate.insert("privilegeDAOImpl.addUserPrivilege",info);
+        if(saveFlag < 1){
+            throw new DAOException(ResponseConstant.RESULT_CODE_INNER_ERROR,"添加用户权限信息失败:"+ JSONObject.toJSONString(info));
+        }
+        return true;
+    }
+
 
 }

+ 7 - 0
OrderService/src/main/java/com/java110/order/smo/IPrivilegeSMO.java

@@ -54,4 +54,11 @@ public interface IPrivilegeSMO {
      */
     public ResponseEntity<String> deletePrivilegeToPrivilegeGroup(String privilegeInfo);
 
+    /**
+     * 员工添加权限
+     * @param privilegeInfo
+     * @return
+     */
+    public ResponseEntity<String> addStaffPrivilegeOrPrivilegeGroup(String privilegeInfo);
+
 }

+ 74 - 0
OrderService/src/main/java/com/java110/order/smo/impl/PrivilegeSMOImpl.java

@@ -3,6 +3,7 @@ package com.java110.order.smo.impl;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.common.cache.MappingCache;
 import com.java110.common.constant.MappingConstant;
+import com.java110.common.exception.SMOException;
 import com.java110.common.util.Assert;
 import com.java110.core.factory.GenerateCodeFactory;
 import com.java110.order.dao.IPrivilegeDAO;
@@ -180,6 +181,79 @@ public class PrivilegeSMOImpl implements IPrivilegeSMO {
         return new ResponseEntity<String>("成功", HttpStatus.OK);
     }
 
+    /**
+     * 员工添加权限或权限组
+     * @param privilegeInfo
+     * @return
+     */
+    @Override
+    public ResponseEntity<String> addStaffPrivilegeOrPrivilegeGroup(String privilegeInfo) {
+
+        JSONObject privilegeObj = validateData(privilegeInfo);
+        //根据权限组ID和商户ID查询是否有数据
+        String pFlag = privilegeObj.getString("pFlag");//权限组
+        privilegeObj.put("privilegeFlag","1".equals(pFlag)?"1":"0");
+        List<Map> privilegeGroups = privilegeDAOImpl.queryUserPrivilege(privilegeObj);
+        Assert.isNotNull(privilegeGroups, "当前没有权限操作权限组" + privilegeInfo);
+
+        if (!privilegeDAOImpl.addUserPrivilege(privilegeObj)) {
+            return new ResponseEntity<String>("添加权限失败", HttpStatus.INTERNAL_SERVER_ERROR);
+        }
+
+        return new ResponseEntity<String>("成功", HttpStatus.OK);
+    }
+
+    private JSONObject validateData(String privilegeInfo) {
+
+        Assert.isJsonObject(privilegeInfo, "请求报文不是有效的json格式");
+
+        Assert.jsonObjectHaveKey(privilegeInfo, "pId", "请求报文中未包含pId节点");
+
+        Assert.jsonObjectHaveKey(privilegeInfo, "pFlag", "请求报文中未包含pFlag节点");
+
+        Assert.jsonObjectHaveKey(privilegeInfo, "userId", "请求报文中未包含userId节点");
+
+        Assert.jsonObjectHaveKey(privilegeInfo, "storeId", "请求报文中未包含storeId节点");
+
+        Assert.jsonObjectHaveKey(privilegeInfo, "storeTypeCd", "请求报文中未包含storeTypeCd节点");
+
+        JSONObject privilegeObj = JSONObject.parseObject(privilegeInfo);
+        String pFlag = privilegeObj.getString("pFlag");//权限组
+        if("1".equals(pFlag)){
+            validatePrivilegeGroup(privilegeObj);
+            return privilegeObj;
+        }
+        validatePrivilege(privilegeObj);
+        return privilegeObj;
+    }
+
+    /**
+     * 权限组数据校验
+     * @param privilegeObj
+     */
+    private void validatePrivilegeGroup(JSONObject privilegeObj){
+
+        //判断当前权限组是否隶属于 当前商户
+        privilegeObj.put("pgId",privilegeObj.getString("pId"));
+        List<Map> privilegeGroups = privilegeDAOImpl.queryPrivilegeGroup(privilegeObj);
+        if(privilegeGroups == null || privilegeGroups.size() == 0){
+            throw new SMOException(1999,"当前没有权限操作该权限组"+privilegeGroups.toString());
+        }
+    }
+
+    /**
+     * 权限数据校验
+     * @param privilegeObj
+     */
+    private void validatePrivilege(JSONObject privilegeObj){
+
+        privilegeObj.put("domain",privilegeObj.getString("storeTypeCd"));
+        List<Map> privileges = privilegeDAOImpl.queryPrivilege(privilegeObj);
+        if(privileges == null || privileges.size() == 0){
+            throw new SMOException(1999,"当前没有权限操作该权限"+privileges.toString());
+        }
+    }
+
 
     public IPrivilegeDAO getPrivilegeDAOImpl() {
         return privilegeDAOImpl;

+ 76 - 0
WebService/src/main/java/com/java110/web/components/staff/AddStaffPrivilegeComponent.java

@@ -0,0 +1,76 @@
+package com.java110.web.components.staff;
+
+
+import com.java110.core.context.IPageData;
+import com.java110.web.smo.IStaffServiceSMO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+
+/**
+ * 员工添加权限
+ */
+@Component("addStaffPrivilege")
+public class AddStaffPrivilegeComponent {
+
+
+
+    @Autowired
+    private IStaffServiceSMO staffServiceSMOImpl;
+
+    /**
+     * 查询员工还没有添加的权限组
+     */
+    public ResponseEntity<String> listNoAddPrivilegeGroup(IPageData pd){
+        ResponseEntity<String> responseEntity = null;
+        try{
+            responseEntity =  staffServiceSMOImpl.listNoAddPrivilegeGroup(pd);
+        }catch (Exception e){
+            responseEntity = new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
+        }finally {
+            return responseEntity;
+        }
+    }
+
+    /**
+     * 查询员工还没有添加的权限
+     * @param pd
+     * @return
+     */
+    public ResponseEntity<String> listNoAddPrivilege(IPageData pd){
+        ResponseEntity<String> responseEntity = null;
+        try{
+            responseEntity =  staffServiceSMOImpl.listNoAddPrivilege(pd);
+        }catch (Exception e){
+            responseEntity = new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
+        }finally {
+            return responseEntity;
+        }
+    }
+
+    /**
+     * 添加权限和权限组
+     * @param pd
+     * @return
+     */
+    public ResponseEntity<String> addStaffPrivilegeOrPrivilegeGroup(IPageData pd){
+
+        ResponseEntity<String> responseEntity = null;
+        try{
+            responseEntity =  staffServiceSMOImpl.addStaffPrivilegeOrPrivilegeGroup(pd);
+        }catch (Exception e){
+            responseEntity = new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
+        }finally {
+            return responseEntity;
+        }
+    }
+
+    public IStaffServiceSMO getStaffServiceSMOImpl() {
+        return staffServiceSMOImpl;
+    }
+
+    public void setStaffServiceSMOImpl(IStaffServiceSMO staffServiceSMOImpl) {
+        this.staffServiceSMOImpl = staffServiceSMOImpl;
+    }
+}

+ 22 - 0
WebService/src/main/java/com/java110/web/smo/IStaffServiceSMO.java

@@ -39,4 +39,26 @@ public interface IStaffServiceSMO {
      * @return
      */
     public ResponseEntity<String> delete(IPageData pd);
+
+    /**
+     * 查询员工没有绑定的权限组
+     * @param pd
+     * @return
+     */
+    public ResponseEntity<String> listNoAddPrivilegeGroup(IPageData pd);
+
+
+    /**
+     * 查询员工没有绑定的权限
+     * @param pd
+     * @return
+     */
+    public ResponseEntity<String> listNoAddPrivilege(IPageData pd);
+
+    /**
+     * 添加权限
+     * @param pd
+     * @return
+     */
+    public ResponseEntity<String> addStaffPrivilegeOrPrivilegeGroup(IPageData pd);
 }

+ 94 - 0
WebService/src/main/java/com/java110/web/smo/impl/StaffServiceSMOImpl.java

@@ -142,6 +142,100 @@ public class StaffServiceSMOImpl extends BaseComponentSMO implements IStaffServi
         return responseEntity;
     }
 
+    /**
+     * 查询 员工没有绑定的权限组
+     * @param pd
+     * @return
+     */
+    @Override
+    public ResponseEntity<String> listNoAddPrivilegeGroup(IPageData pd) {
+
+        ResponseEntity<String> responseEntity = null;
+        Assert.jsonObjectHaveKey(pd.getReqData(),"userId","请求报文格式错误或未包含用户ID信息");
+        JSONObject _paramObj = JSONObject.parseObject(pd.getReqData());
+        responseEntity = super.getStoreInfo(pd,restTemplate);
+        if(responseEntity.getStatusCode() != HttpStatus.OK){
+            return responseEntity;
+        }
+        Assert.jsonObjectHaveKey(responseEntity.getBody().toString(),"storeId","根据用户ID查询商户ID失败,未包含storeId节点");
+
+        String storeId = JSONObject.parseObject(responseEntity.getBody().toString()).getString("storeId");
+        String storeTypeCd = JSONObject.parseObject(responseEntity.getBody().toString()).getString("storeTypeCd");
+        //修改用户信息
+        responseEntity = this.callCenterService(restTemplate,pd,"",
+                ServiceConstant.SERVICE_API_URL+"/api/query.privilegeGroup.noAddPrivilegeGroup?userId="
+                        +_paramObj.getString("userId")+"&storeId="+storeId+"&storeTypeCd="+storeTypeCd,
+                HttpMethod.GET);
+        if(responseEntity.getStatusCode() !=  HttpStatus.OK){
+            return responseEntity;
+        }
+
+        JSONObject outDataObj = JSONObject.parseObject(responseEntity.getBody());
+        return new ResponseEntity<String>(outDataObj.getJSONArray("privilgeGroups").toJSONString(),HttpStatus.OK);
+    }
+
+    /**
+     * 查询 员工没有绑定的权限
+     * @param pd
+     * @return
+     */
+    @Override
+    public ResponseEntity<String> listNoAddPrivilege(IPageData pd) {
+        ResponseEntity<String> responseEntity = null;
+        Assert.jsonObjectHaveKey(pd.getReqData(),"userId","请求报文格式错误或未包含用户ID信息");
+        JSONObject _paramObj = JSONObject.parseObject(pd.getReqData());
+        responseEntity = super.getStoreInfo(pd,restTemplate);
+        if(responseEntity.getStatusCode() != HttpStatus.OK){
+            return responseEntity;
+        }
+        Assert.jsonObjectHaveKey(responseEntity.getBody().toString(),"storeId","根据用户ID查询商户ID失败,未包含storeId节点");
+
+        String storeId = JSONObject.parseObject(responseEntity.getBody().toString()).getString("storeId");
+        String storeTypeCd = JSONObject.parseObject(responseEntity.getBody().toString()).getString("storeTypeCd");
+        //修改用户信息
+        responseEntity = this.callCenterService(restTemplate,pd,"",
+                ServiceConstant.SERVICE_API_URL+"/api/query.privilege.noAddPrivilege?userId="
+                        +_paramObj.getString("userId")+"&storeId="+storeId+"&storeTypeCd="+storeTypeCd,
+                HttpMethod.GET);
+        if(responseEntity.getStatusCode() !=  HttpStatus.OK){
+            return responseEntity;
+        }
+
+        JSONObject outDataObj = JSONObject.parseObject(responseEntity.getBody());
+        return new ResponseEntity<String>(outDataObj.getJSONArray("privilges").toJSONString(),HttpStatus.OK);
+    }
+
+    /**
+     * 添加权限 或权限组
+     * @param pd
+     * @return
+     */
+    @Override
+    public ResponseEntity<String> addStaffPrivilegeOrPrivilegeGroup(IPageData pd) {
+        ResponseEntity<String> responseEntity = null;
+        Assert.jsonObjectHaveKey(pd.getReqData(),"userId","请求报文格式错误或未包含用户ID信息");
+        Assert.jsonObjectHaveKey(pd.getReqData(),"pId","请求报文格式错误或未包含权限ID信息");
+        Assert.jsonObjectHaveKey(pd.getReqData(),"pFlag","请求报文格式错误");
+        JSONObject _paramObj = JSONObject.parseObject(pd.getReqData());
+        responseEntity = super.getStoreInfo(pd,restTemplate);
+        if(responseEntity.getStatusCode() != HttpStatus.OK){
+            return responseEntity;
+        }
+        Assert.jsonObjectHaveKey(responseEntity.getBody().toString(),"storeId","根据用户ID查询商户ID失败,未包含storeId节点");
+
+        String storeId = JSONObject.parseObject(responseEntity.getBody().toString()).getString("storeId");
+        String storeTypeCd = JSONObject.parseObject(responseEntity.getBody().toString()).getString("storeTypeCd");
+        _paramObj.put("storeId",storeId);
+        _paramObj.put("storeTypeCd",storeTypeCd);
+
+        //修改用户信息
+        responseEntity = this.callCenterService(restTemplate,pd,_paramObj.toJSONString(),
+                ServiceConstant.SERVICE_API_URL+"/api/add.privilege.userPrivilege",
+                HttpMethod.POST);
+
+        return responseEntity;
+    }
+
     /**
      * 修改员工 数据校验
      * @param pd

+ 42 - 23
WebService/src/main/resources/components/add-staff-privilege/addStaffPrivilege.html

@@ -1,56 +1,75 @@
 <div id = "addStaffPrivilegeModel" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="addPrivilegeModalLabel" aria-hidden="true" >
     <div class="modal-dialog modal-lg">
         <div class="modal-content">
-            <div class="modal-header">
-                <h3 class="modal-title" id="addPrivilegeModalLabel">添加员工权限</h3>
-                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
-                    <span aria-hidden="true">&times;</span>
-                </button>
-            </div>
             <div class="modal-body">
                 <div class=" row">
                     <div class="col-lg-12">
                         <div class="ibox ">
                             <ul class="nav nav-tabs">
                                 <li class="nav-item">
-                                    <a class="nav-link active" href="#">Active</a>
-                                </li>
-                                <li class="nav-item">
-                                    <a class="nav-link" href="#">Link</a>
+                                    <a class="nav-link" v-bind:class="{active:addStaffPrivilegeInfo._currentTab == 1}" v-on:click="changeTab(1)">权限组</a>
                                 </li>
-                                <li class="nav-item">
-                                    <a class="nav-link" href="#">Link</a>
+                                <li class="nav-item" >
+                                    <a class="nav-link" v-bind:class="{active:addStaffPrivilegeInfo._currentTab == 2}" v-on:click="changeTab(2)">权限</a>
                                 </li>
                             </ul>
-                                <div class="table-responsive" style="margin-top:15px">
-                                    <table class="table table-striped">
+                                <div class="table-responsive"
+                                     style="margin-top:15px">
+                                    <table class="table table-striped" v-if="addStaffPrivilegeInfo._currentTab == 1">
                                         <thead>
                                         <tr>
 
-                                            <th>权限编码</th>
-                                            <th>权限名称</th>
-                                            <th>权限描述</th>
+                                            <th>权限编码</th>
+                                            <th>权限名称</th>
+                                            <th>权限描述</th>
                                             <th>创建时间</th>
                                             <th>操作</th>
                                         </tr>
                                         </thead>
                                         <tbody>
-                                            <tr >
-                                                <td>123</td>
-                                                <td>123</td>
-                                                <td>123</td>
-                                                <td>123</td>
+                                            <tr v-for="privilegeGroup in addStaffPrivilegeInfo._noAddPrivilegeGroup">
+                                                <td>{{privilegeGroup.pgId}}</td>
+                                                <td>{{privilegeGroup.name}}</td>
+                                                <td>{{privilegeGroup.description}}</td>
+                                                <td>{{vc.dateFormat(privilegeGroup.createTime)}}</td>
                                                 <td>
-                                                    <button class="btn btn-primary btn-xs" >添加</button>
+                                                    <button class="btn btn-primary btn-xs" v-on:click="userAddPrivilegeGroup(privilegeGroup.pgId)">添加</button>
                                                 </td>
                                             </tr>
                                         </tbody>
                                     </table>
+                                    <table class="table table-striped" v-if="addStaffPrivilegeInfo._currentTab == 2">
+                                        <thead>
+                                        <tr>
+
+                                            <th>权限编码</th>
+                                            <th>权限名称</th>
+                                            <th>权限描述</th>
+                                            <th>创建时间</th>
+                                            <th>操作</th>
+                                        </tr>
+                                        </thead>
+                                        <tbody>
+                                        <tr v-for="privilege in addStaffPrivilegeInfo._noAddPrivilege">
+                                            <td>{{privilege.pId}}</td>
+                                            <td>{{privilege.name}}</td>
+                                            <td>{{privilege.description}}</td>
+                                            <td>{{vc.dateFormat(privilege.createTime)}}</td>
+                                            <td>
+                                                <button class="btn btn-primary btn-xs" v-on:click="userAddPrivilege(privilege.pId)">添加</button>
+                                            </td>
+                                        </tr>
+                                        </tbody>
+                                    </table>
                                 </div>
 
                         </div>
                     </div>
                 </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
+            </div>
         </div>
     </div>
 </div>

+ 76 - 24
WebService/src/main/resources/components/add-staff-privilege/addStaffPrivilege.js

@@ -1,13 +1,15 @@
-(function(vc){
+(function(vc,vm){
 
     vc.extends({
         data:{
             addStaffPrivilegeInfo:{
-                _currentPgId:'',
+                _currentUserId:'',
                 name:'',
                 description:'',
                 errorInfo:'',
-                _noAddPrivilege:[]
+                _noAddPrivilege:[],
+                _noAddPrivilegeGroup:[],
+                _currentTab:1
             }
         },
          _initMethod:function(){
@@ -16,45 +18,85 @@
          _initEvent:function(){
              vc.on('addStaffPrivilege','addStaffPrivilegeModel',function(_params){
                 $('#addStaffPrivilegeModel').modal('show');
-                /*vc.component.addPrivilegeInfo._currentPgId = _params.pgId;
-                //查询没有添加的权限
-                vc.component.listNoAddPrivilege();*/
+                vc.component._refreshData(_params);
             });
         },
         methods:{
+            _refreshData:function(_params){
+                vc.component.addStaffPrivilegeInfo._currentUserId = _params.userId;
+                vc.component.addStaffPrivilegeInfo._currentTab = 1;
+                vc.component.listNoAddPrivilegeGroup();
+            },
+            changeTab:function(_tempTab){
+                vc.component.addStaffPrivilegeInfo._currentTab= _tempTab;
+                if(_tempTab == 2){
+                    vc.component.listNoAddPrivilege();
+                    return ;
+                }
+                vc.component.listNoAddPrivilegeGroup();
+            },
+            listNoAddPrivilegeGroup:function(){
+                vc.component.addStaffPrivilegeInfo._noAddPrivilegeGroup = [];
+                var param = {
+                    params:{
+                        userId:vc.component.addStaffPrivilegeInfo._currentUserId
+                    }
+                };
+                vc.http.get(
+                    'addStaffPrivilege',
+                    'listNoAddPrivilegeGroup',
+                     param,
+                     function(json,res){
+                        //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
+                        if(res.status == 200){
+                            vc.component.addStaffPrivilegeInfo._noAddPrivilegeGroup = JSON.parse(json);
+                            return ;
+                        }
+                        vc.component.addStaffPrivilegeInfo.errorInfo = json;
+                     },
+                     function(errInfo,error){
+                        console.log('请求失败处理');
+
+                        vc.component.addStaffPrivilegeInfo.errorInfo = errInfo;
+                });
+
+            },
             listNoAddPrivilege:function(){
-                vc.component.addPrivilegeInfo._noAddPrivilege=[];
+                vc.component.addStaffPrivilegeInfo._noAddPrivilege=[];
                 var param = {
                     params:{
-                        pgId:vc.component.addPrivilegeInfo._currentPgId
+                        userId:vc.component.addStaffPrivilegeInfo._currentUserId
                     }
                 }
                 vc.http.get(
-                            'addPrivilege',
+                            'addStaffPrivilege',
                             'listNoAddPrivilege',
                              param,
                              function(json,res){
                                 //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
                                 if(res.status == 200){
-                                    vc.component.addPrivilegeInfo._noAddPrivilege = JSON.parse(json);
+                                    vc.component.addStaffPrivilegeInfo._noAddPrivilege = JSON.parse(json);
                                     return ;
                                 }
-                                vc.component.addPrivilegeInfo.errorInfo = json;
+                                vc.component.addStaffPrivilegeInfo.errorInfo = json;
                              },
                              function(errInfo,error){
                                 console.log('请求失败处理');
 
-                                vc.component.addPrivilegeInfo.errorInfo = errInfo;
+                                vc.component.addStaffPrivilegeInfo.errorInfo = errInfo;
                              });
             },
-            addPrivilegeToPrivilegeGroup:function(_privilegeInfo){
-
-                vc.component.addPrivilegeInfo.errorInfo = "";
-                _privilegeInfo.pgId = vc.component.addPrivilegeInfo._currentPgId;
+            addStaffPrivilege:function(_pId,_privilegeFlag){
+                vc.component.addStaffPrivilegeInfo.errorInfo = "";
+                var param = {
+                    userId:vc.component.addStaffPrivilegeInfo._currentUserId,
+                    pId:_pId,
+                    pFlag:_privilegeFlag
+                };
                 vc.http.post(
-                    'addPrivilege',
-                    'addPrivilegeToPrivilegeGroup',
-                    JSON.stringify(_privilegeInfo),
+                    'addStaffPrivilege',
+                    'addStaffPrivilegeOrPrivilegeGroup',
+                    JSON.stringify(param),
                     {
                         emulateJSON:true
                      },
@@ -62,19 +104,29 @@
                         //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
                         if(res.status == 200){
                             //关闭model
-                            vc.component.listNoAddPrivilege();
-                            vc.component.$emit('privilege_loadPrivilege',vc.component.addPrivilegeInfo._currentPgId);
+                            $('#addStaffPrivilegeModel').modal('hide');
+                            vc.emit('staffPrivilege','_loadStaffPrivileges',{
+                                staffId:vc.component.addStaffPrivilegeInfo._currentUserId
+                            });
                             return ;
                         }
-                        vc.component.addPrivilegeInfo.errorInfo = json;
+                        vc.component.addStaffPrivilegeInfo.errorInfo = json;
                      },
                      function(errInfo,error){
                         console.log('请求失败处理');
 
-                        vc.component.addPrivilegeInfo.errorInfo = errInfo;
+                        vc.component.addStaffPrivilegeInfo.errorInfo = errInfo;
                      });
+            },
+            userAddPrivilegeGroup:function(_pgId){
+                console.log("需要添加权限:",_pgId);
+                vc.component.addStaffPrivilege(_pgId,1)
+            },
+            userAddPrivilege:function(_pId){
+                console.log("需要添加权限:",_pId);
+                vc.component.addStaffPrivilege(_pId,2)
             }
         }
     });
 
-})(window.vc);
+})(window.vc,window.vc.component);

+ 4 - 2
WebService/src/main/resources/components/privilege-staffInfo/privilegeStaffInfo.html

@@ -6,8 +6,10 @@
                 <div class="ibox-tools" style="top:10px;">
                     <button type="button" class="btn btn-primary btn-sm" v-on:click="openSearchStaffModel()">
                         <i class="glyphicon glyphicon-search"></i> 定位员工</button>
-                    <button type="button" class="btn btn-primary btn-sm" style="margin-left:10px">
-                        <i class="glyphicon glyphicon-plus" v-on:click="openAddStaffPrivilegeModel()"></i> 添加权限</button>
+                    <button type="button" class="btn btn-primary btn-sm"
+                            v-if="privilegeStaffInfo.userId != null && privilegeStaffInfo.userId != ''"
+                            style="margin-left:10px" v-on:click="openAddStaffPrivilegeModel()">
+                        <i class="glyphicon glyphicon-plus" ></i> 添加权限</button>
                 </div>
             </div>
             <div class="ibox-content">

+ 5 - 2
WebService/src/main/resources/components/privilege-staffInfo/privilegeStaffInfo.js

@@ -30,8 +30,11 @@
             openSearchStaffModel(){
                 vc.emit('searchStaff','openSearchStaffModel',{});
             },
-            openAddStaffPrivilegeModel:function(){
-                vc.emit('addStaffPrivilege','addStaffPrivilegeModel',{});
+            openAddStaffPrivilegeModel(){
+                console.log("点击openAddStaffPrivilegeModel")
+                vc.emit('addStaffPrivilege','addStaffPrivilegeModel',{
+                    userId:vc.component.privilegeStaffInfo.userId
+                });
             }
         }
     });

+ 42 - 0
java110-config/src/main/resources/mapper/center/PrivilegeDAOImplMapper.xml

@@ -90,4 +90,46 @@
         insert into p_privilege_rel(p_id,pg_id)
         values(#{pId},#{pgId})
     </insert>
+    <!-- 查询权限 -->
+    <select id="queryPrivilege" parameterType="Map" resultType="Map">
+        SELECT
+            pp.`p_id` pId,pp.`name`,pp.`description`,pp.`create_time` createTime,pp.`domain`
+        FROM p_privilege pp
+        WHERE 1= 1
+        <if test="pId != null and pId != ''">
+            and pp.p_id = #{pId}
+        </if>
+        <if test="pId != null and pId != ''">
+            AND pp.domain = '800900000003'
+        </if>
+            AND pp.`status_cd` = '0'
+    </select>
+    <!-- 查询用户权限 -->
+    <select id="queryUserPrivilege" parameterType="Map" resultType="Map">
+        SELECT
+            ppu.`pu_id` puId,
+            ppu.`p_id` pId,
+            ppu.`privilege_flag` privilegeFlag,
+            ppu.`user_id` userId
+        FROM
+            p_privilege_user ppu
+        WHERE 1 = 1
+        <if test="privilegeFlag != null and privilegeFlag != ''">
+            AND ppu.`privilege_flag` = #{privilegeFlag}
+        </if>
+        <if test="pId != null and pId != ''">
+            AND ppu.`p_id` = #{pId}
+        </if>
+        <if test="userId != null and userId != ''">
+            AND ppu.`user_id` = #{userId}
+        </if>
+            AND ppu.`status_cd` = '0'
+    </select>
+    <!-- 保存属性信息 c_business_attrs -->
+    <insert id="addUserPrivilege" parameterType="Map">
+        <![CDATA[
+            INSERT INTO p_privilege_user(p_id,privilege_flag,user_id) VALUES(#{pId},#{privilegeFlag},#{userId})
+        ]]>
+    </insert>
+
 </mapper>