Selaa lähdekoodia

权限组代码提交

吴学文 7 vuotta sitten
vanhempi
commit
6b62159b5f

+ 42 - 0
WebService/src/main/java/com/java110/web/components/PrivilegeComponent.java

@@ -0,0 +1,42 @@
+package com.java110.web.components;
+
+
+import com.java110.core.context.IPageData;
+import com.java110.web.smo.IPrivilegeServiceSMO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+
+@Component("privilege")
+public class PrivilegeComponent {
+
+
+    @Autowired
+    private IPrivilegeServiceSMO privilegeServiceSMOImpl;
+
+    /**
+     * 查询权限
+     * @param pd
+     * @return
+     */
+    public ResponseEntity<String> listPrivilege(IPageData pd){
+        ResponseEntity<String> responseEntity = null;
+        try{
+            responseEntity =  privilegeServiceSMOImpl.loadListPrivilege(pd);
+        }catch (Exception e){
+            responseEntity = new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
+        }finally {
+            return responseEntity;
+        }
+
+    }
+
+    public IPrivilegeServiceSMO getPrivilegeServiceSMOImpl() {
+        return privilegeServiceSMOImpl;
+    }
+
+    public void setPrivilegeServiceSMOImpl(IPrivilegeServiceSMO privilegeServiceSMOImpl) {
+        this.privilegeServiceSMOImpl = privilegeServiceSMOImpl;
+    }
+}

+ 7 - 0
WebService/src/main/java/com/java110/web/smo/IPrivilegeServiceSMO.java

@@ -14,4 +14,11 @@ public interface IPrivilegeServiceSMO {
      * @return
      */
     public ResponseEntity<String> listPrivilegeGroup(IPageData pd);
+
+    /**
+     * 查下权限
+     * @param pd
+     * @return
+     */
+    public ResponseEntity<String> loadListPrivilege(IPageData pd);
 }

+ 28 - 0
WebService/src/main/java/com/java110/web/smo/impl/PrivilegeServiceSMOImpl.java

@@ -59,6 +59,34 @@ public class PrivilegeServiceSMOImpl extends BaseComponentSMO implements IPrivil
         return new ResponseEntity<String>(privilegeGroups.toJSONString(),HttpStatus.OK);
     }
 
+    /**
+     * 查询权限
+     * @param pd
+     * @return
+     */
+    @Override
+    public ResponseEntity<String> loadListPrivilege(IPageData pd) {
+        JSONObject privilegeInfoObj = JSONObject.parseObject(pd.getReqData());
+        Assert.jsonObjectHaveKey(privilegeInfoObj,"pgId","请求报文中未包含pgId 节点");
+
+        String pgId = privilegeInfoObj.getString("pgId");
+
+        ResponseEntity<String> privilegeGroup = super.callCenterService(restTemplate,pd,"",
+                ServiceConstant.SERVICE_API_URL+"/api/query.privilege.byPgId?pgId="+pgId , HttpMethod.GET);
+        if(privilegeGroup.getStatusCode() != HttpStatus.OK){
+            return privilegeGroup;
+        }
+
+        JSONObject privilegeObj = JSONObject.parseObject(privilegeGroup.getBody().toString());
+
+        Assert.jsonObjectHaveKey(privilegeObj,"privileges","查询菜单未返回privileges节点");
+
+        JSONArray privileges = privilegeObj.getJSONArray("privileges");
+
+        return new ResponseEntity<String>(privileges.toJSONString(),HttpStatus.OK);
+
+    }
+
     public RestTemplate getRestTemplate() {
         return restTemplate;
     }

+ 28 - 0
WebService/src/main/resources/components/add-privilege-group/addPrivilegeGroup.html

@@ -0,0 +1,28 @@
+<div id = "addPrivilegeGroupModel" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" >
+    <div class="modal-dialog modal-lg">
+        <div class="modal-content">
+            <div class="modal-body">
+                <h3 class="m-t-none m-b ">添加权限组</h3>
+                <div class="ibox-content">
+                    <div>
+                        <p style="color:red;">{{addPrivilegeGroupInfo.errorInfo}}</p>
+                        <div>
+                            <div class="form-group row">
+                                <label class="col-sm-2 col-form-label">权限组名称</label>
+                                <div class="col-sm-10"><input v-model="addPrivilegeGroupInfo.name" type="text" placeholder="必填,请填写员工名称" class="form-control"></div>
+                            </div>
+                            <div class="form-group row">
+                                <label class="col-sm-2 col-form-label">权限组描述</label>
+                                <div class="col-sm-10"><input v-model="addPrivilegeGroupInfo.description" type="text" placeholder="必填,请填写员工名称" class="form-control"></div>
+                            </div>
+                            <div class="ibox-content">
+                                <button class="btn btn-primary float-right" type="button" v-on:click="saveAddPrivilegeGroup()" ><i class="fa fa-check"></i>&nbsp;保存</button>
+                                <button type="button" class="btn btn-warning float-right" style="margin-right:20px;" data-dismiss="modal">取消</button>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>

+ 92 - 0
WebService/src/main/resources/components/add-privilege-group/addPrivilegeGroup.js

@@ -0,0 +1,92 @@
+(function(vc){
+
+    vc.extends({
+        data:{
+            addPrivilegeGroupInfo:{
+                name:'',
+                description:'',
+                errorInfo:''
+            }
+        },
+         _initMethod:function(){
+
+         },
+         _initEvent:function(){
+             vc.component.$on('add_privilege_group_event',function(){
+                $('#addPrivilegeGroupModel').modal('show');
+            });
+        },
+        methods:{
+            addPrivilegeGroupValidate(){
+                return vc.validate.validate({
+                    addStaffInfo:vc.component.addStaffInfo
+                },{
+                    'addPrivilegeGroupInfo.name':[
+                        {
+                            limit:"required",
+                            param:"",
+                            errInfo:"用户名不能为空"
+                        },
+                        {
+                            limit:"maxin",
+                            param:"2,10",
+                            errInfo:"权限组长度必须在2位至10位"
+                        },
+                    ],
+                    'addPrivilegeGroupInfo.description':[
+                        {
+                            limit:"required",
+                            param:"",
+                            errInfo:"地址不能为空"
+                        },
+                        {
+                            limit:"maxLength",
+                            param:"200",
+                            errInfo:"权限组描述长度不能超过200位"
+                        },
+                    ]
+
+                });
+            },
+            saveAddPrivilegeGroup:function(){
+                if(!vc.component.addPrivilegeGroupValidate()){
+                    vc.component.addPrivilegeGroupInfo.errorInfo = vc.validate.errInfo;
+                    return ;
+                }
+
+                vc.component.addPrivilegeGroupInfo.errorInfo = "";
+                vc.http.post(
+                    'addPrivilegeGroup',
+                    'saveStaff',
+                    JSON.stringify(vc.component.addStaffInfo),
+                    {
+                        emulateJSON:true
+                     },
+                     function(json,res){
+                        //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
+                        if(res.status == 200){
+                            //关闭model
+                            $('#addPrivilegeGroupModel').modal('hide');
+                            vc.component.clearAddPrivilegeGroupInfo();
+                            vc.component.$emit('addStaff_reload_event',{});
+                            return ;
+                        }
+                        vc.component.addStaffInfo.errorInfo = json;
+                     },
+                     function(errInfo,error){
+                        console.log('请求失败处理');
+
+                        vc.component.addStaffInfo.errorInfo = errInfo;
+                     });
+            },
+            clearAddPrivilegeGroupInfo:function(){
+                vc.component.addPrivilegeGroupInfo = {
+                                            name:'',
+                                            description:'',
+                                            errorInfo:''
+                                        };
+            }
+        }
+    });
+
+})(window.vc);

+ 1 - 1
WebService/src/main/resources/components/privilege-group/privilegeGroup.html

@@ -2,7 +2,7 @@
     <div class="ibox ">
         <div class="ibox-content mailbox-content">
             <div class="file-manager">
-                <a class="btn btn-block btn-primary compose-mail" href="mail_compose.html">添加权限组</a>
+                <a class="btn btn-block btn-primary compose-mail" v-on:click="openPrivilegeGroup()">添加权限组</a>
                 <div class="space-25"></div>
 
                 <h5>权限组</h5>

+ 14 - 5
WebService/src/main/resources/components/privilege-group/privilegeGroup.js

@@ -25,10 +25,13 @@
                              function(json){
                                 var _groupsInfo = JSON.parse(json);
                                 vc.component.privilegeGroupInfo.groups = _groupsInfo;
-//                                vc.component.$emit('pagination_info_event',{
-//                                    total:_staffInfo.records,
-//                                    currentPage:_staffInfo.page
-//                                });
+                                if(_groupsInfo.length > 0){
+                                    vc.component.$emit('privilege_group_event',{
+                                                                    _pgId:_groupsInfo[0].pgId,
+                                                                    _pgName:_groupsInfo[0].name
+                                                                });
+                                }
+
 
                              },function(){
                                 console.log('请求失败处理');
@@ -36,7 +39,13 @@
                            );
             },
             notifyQueryPrivilege:function(_pGroup){
-                console.log("当前点击权限组",_pGroup)
+                vc.component.$emit('privilege_group_event',{
+                    _pgId:_pGroup.pgId,
+                    _pgName:_pGroup.name
+                });
+            },
+            openPrivilegeGroup:function(){
+
             }
         }
     });

+ 7 - 89
WebService/src/main/resources/components/privilege/privilege.html

@@ -2,8 +2,6 @@
     <vc:create name="privilegeGroup"></vc:create>
     <div class="col-lg-9 animated fadeInRight">
         <div class="mail-box-header">
-
-
             <button class="btn btn-primary btn-sm float-right" data-toggle="tooltip"  title="Refresh inbox"><i class="fa fa-plus"></i> 添加权限</button>
             <form method="get" action="index.html" class="float-right mail-search" style="margin-right:10px">
                 <div class="input-group">
@@ -16,7 +14,7 @@
                 </div>
             </form>
             <h2>
-                员工管理组
+                {{privilegeInfo._currentPgName}}
             </h2>
         </div>
         <div class="mail-box">
@@ -32,96 +30,16 @@
                     </tr>
                 </thead>
                 <tbody>
-                <tr class="read">
-                    <td class="check-mail">
-                        500201904001
-                    </td>
-                    <td class="mail-ontact">添加员工</td>
-                    <td class="mail-subject">添加员工</td>
-                    <td class="">2019-04-01 02:24:53</td>
-                    <td class="text-right mail-date"><i class="glyphicon glyphicon-remove"></i></td>
-                </tr>
-                <tr class="read">
-                    <td class="check-mail">
-                        500201904001
-                    </td>
-                    <td class="mail-ontact">添加员工</td>
-                    <td class="mail-subject">添加员工</td>
-                    <td class="">2019-04-01 02:24:53</td>
-                    <td class="text-right mail-date"><i class="glyphicon glyphicon-remove"></i></td>
-                </tr>
-                <tr class="read">
+                <tr v-for="privilege in privilegeInfo._privileges" class="read">
                     <td class="check-mail">
-                        500201904001
+                        {{privilege.pId}}
                     </td>
-                    <td class="mail-ontact">添加员工</td>
-                    <td class="mail-subject">添加员工</td>
-                    <td class="">2019-04-01 02:24:53</td>
-                    <td class="text-right mail-date"><i class="glyphicon glyphicon-remove"></i></td>
-                </tr>
-                <tr class="read">
-                    <td class="check-mail">
-                        500201904001
-                    </td>
-                    <td class="mail-ontact">添加员工</td>
-                    <td class="mail-subject">添加员工</td>
-                    <td class="">2019-04-01 02:24:53</td>
-                    <td class="text-right mail-date"><i class="glyphicon glyphicon-remove"></i></td>
-                </tr>
-                <tr class="read">
-                    <td class="check-mail">
-                        500201904001
-                    </td>
-                    <td class="mail-ontact">添加员工</td>
-                    <td class="mail-subject">添加员工</td>
-                    <td class="">2019-04-01 02:24:53</td>
-                    <td class="text-right mail-date"><i class="glyphicon glyphicon-remove"></i></td>
-                </tr>
-                <tr class="read">
-                    <td class="check-mail">
-                        500201904001
-                    </td>
-                    <td class="mail-ontact">添加员工</td>
-                    <td class="mail-subject">添加员工</td>
-                    <td class="">2019-04-01 02:24:53</td>
-                    <td class="text-right mail-date"><i class="glyphicon glyphicon-remove"></i></td>
-                </tr>
-                <tr class="read">
-                    <td class="check-mail">
-                        500201904001
-                    </td>
-                    <td class="mail-ontact">添加员工</td>
-                    <td class="mail-subject">添加员工</td>
-                    <td class="">2019-04-01 02:24:53</td>
-                    <td class="text-right mail-date"><i class="glyphicon glyphicon-remove"></i></td>
-                </tr>
-                <tr class="read">
-                    <td class="check-mail">
-                        500201904001
-                    </td>
-                    <td class="mail-ontact">添加员工</td>
-                    <td class="mail-subject">添加员工</td>
-                    <td class="">2019-04-01 02:24:53</td>
-                    <td class="text-right mail-date"><i class="glyphicon glyphicon-remove"></i></td>
-                </tr>
-                <tr class="read">
-                    <td class="check-mail">
-                        500201904001
-                    </td>
-                    <td class="mail-ontact">添加员工</td>
-                    <td class="mail-subject">添加员工</td>
-                    <td class="">2019-04-01 02:24:53</td>
-                    <td class="text-right mail-date"><i class="glyphicon glyphicon-remove"></i></td>
-                </tr>
-                <tr class="read">
-                    <td class="check-mail">
-                        500201904001
-                    </td>
-                    <td class="mail-ontact">添加员工</td>
-                    <td class="mail-subject">添加员工</td>
-                    <td class="">2019-04-01 02:24:53</td>
+                    <td class="mail-ontact">{{privilege.name}}</td>
+                    <td class="mail-subject">{{privilege.description}}</td>
+                    <td class="">{{vc.dateFormat(privilege.createTime)}}</td>
                     <td class="text-right mail-date"><i class="glyphicon glyphicon-remove"></i></td>
                 </tr>
+
                 </tbody>
             </table>
 

+ 39 - 0
WebService/src/main/resources/components/privilege/privilege.js

@@ -1,5 +1,44 @@
 (function(vc){
 
+    vc.extends({
+        data:{
+            privilegeInfo:{
+                _currentPgId:"",
+                _currentPgName:"",
+                _privileges:[]
+            }
+        },
+        _initMethod:function(){
 
+        },
+        _initEvent:function(){
+            vc.component.$on('privilege_group_event',function(_pgObj){
+                vc.component.privilegeInfo._currentPgId = _pgObj._pgId;
+                vc.component.privilegeInfo._currentPgName = _pgObj._pgName;
+
+                //调用接口查询权限
+                vc.component._loadPrivilege(_pgObj._pgId);
+            });
+        },
+        methods:{
+            _loadPrivilege:function(_pgId){
+                var param = {
+                                    params:{pgId:_pgId}
+                                };
+
+                                //发送get请求
+               vc.http.get('privilege',
+                            'listPrivilege',
+                             param,
+                             function(json){
+                                var _privileges = JSON.parse(json);
+                                vc.component.privilegeInfo._privileges = _privileges;
+                             },function(){
+                                console.log('请求失败处理');
+                             }
+                           );
+            }
+        }
+    });
 
 })(window.vc);