Explorar el Código

添加权限组组件处理逻辑

吴学文 hace 7 años
padre
commit
a60229e6b8

+ 45 - 0
WebService/src/main/java/com/java110/web/components/PrivilegeGroupComponent.java

@@ -0,0 +1,45 @@
+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("privilegeGroup")
+public class PrivilegeGroupComponent {
+
+    @Autowired
+    private IPrivilegeServiceSMO privilegeServiceSMOImpl;
+
+    /**
+     * 查询权限组
+     * @param pd 页面
+     * @return
+     */
+    public ResponseEntity<String> listPrivilegeGroup(IPageData pd){
+
+        ResponseEntity<String> responseEntity = null;
+        try{
+            responseEntity =  privilegeServiceSMOImpl.listPrivilegeGroup(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;
+    }
+}

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

@@ -0,0 +1,17 @@
+package com.java110.web.smo;
+
+import com.java110.core.context.IPageData;
+import org.springframework.http.ResponseEntity;
+
+/**
+ * 权限管理接口类
+ */
+public interface IPrivilegeServiceSMO {
+
+    /**
+     * 查询权限组
+     * @param pd
+     * @return
+     */
+    public ResponseEntity<String> listPrivilegeGroup(IPageData pd);
+}

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

@@ -0,0 +1,69 @@
+package com.java110.web.smo.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.ServiceConstant;
+import com.java110.common.util.Assert;
+import com.java110.core.context.IPageData;
+import com.java110.web.core.BaseComponentSMO;
+import com.java110.web.smo.IPrivilegeServiceSMO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+
+@Service("privilegeServiceSMOImpl")
+public class PrivilegeServiceSMOImpl extends BaseComponentSMO implements IPrivilegeServiceSMO {
+
+    @Autowired
+    private RestTemplate restTemplate;
+
+    /**
+     * 查询 权限组
+     * @param pd
+     * @return
+     */
+    @Override
+    public ResponseEntity<String> listPrivilegeGroup(IPageData pd) {
+
+        Assert.hasLength(pd.getUserId(),"用户未登录请先登录");
+
+        ResponseEntity<String> storeInfo = super.getStoreInfo(pd,restTemplate);
+
+        if(storeInfo.getStatusCode() != HttpStatus.OK){
+            return storeInfo;
+        }
+        // 商户返回信息
+        JSONObject storeInfoObj = JSONObject.parseObject(storeInfo.getBody());
+
+        String  storeId = storeInfoObj.getString("storeId");
+        String  storeTypeCd = storeInfoObj.getString("storeTypeCd");
+
+        //根据商户ID查询 权限组信息
+
+
+        ResponseEntity<String> privilegeGroup = super.callCenterService(restTemplate,pd,"",
+                ServiceConstant.SERVICE_API_URL+"/api/query.store.privilegeGroup?storeId="+storeId +"&storeTypeCd="+storeTypeCd, HttpMethod.GET);
+        if(privilegeGroup.getStatusCode() != HttpStatus.OK){
+            return privilegeGroup;
+        }
+
+        JSONObject privilegeGroupObj = JSONObject.parseObject(privilegeGroup.getBody().toString());
+
+        Assert.jsonObjectHaveKey(privilegeGroupObj,"privilegeGroups","查询菜单未返回privilegeGroups节点");
+
+        JSONArray privilegeGroups = privilegeGroupObj.getJSONArray("privilegeGroups");
+
+        return new ResponseEntity<String>(privilegeGroups.toJSONString(),HttpStatus.OK);
+    }
+
+    public RestTemplate getRestTemplate() {
+        return restTemplate;
+    }
+
+    public void setRestTemplate(RestTemplate restTemplate) {
+        this.restTemplate = restTemplate;
+    }
+}

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

@@ -7,11 +7,11 @@
 
                 <h5>权限组</h5>
                 <ul class="category-list" style="padding: 0">
-                    <li><a href="#"> <i class="fa fa-circle text-navy"></i> 员工管理组 </a></li>
-                    <li><a href="#"> <i class="fa fa-circle text-danger"></i> Documents</a></li>
-                    <li><a href="#"> <i class="fa fa-circle text-primary"></i> Social</a></li>
-                    <li><a href="#"> <i class="fa fa-circle text-info"></i> Advertising</a></li>
-                    <li><a href="#"> <i class="fa fa-circle text-warning"></i> Clients</a></li>
+                    <li v-for="pGroup in privilegeGroupInfo.groups">
+                        <a v-on:click="notifyQueryPrivilege(pGroup)">
+                            <i class="glyphicon glyphicon-chevron-right text-navy"></i>
+                            {{pGroup.name}} </a>
+                    </li>
                 </ul>
 
                 <div class="clearfix"></div>

+ 41 - 0
WebService/src/main/resources/components/privilege-group/privilegeGroup.js

@@ -1,3 +1,44 @@
+/**
+    权限组
+**/
 (function(vc){
 
+    vc.extends({
+        data:{
+            privilegeGroupInfo:{
+                groups:[]
+            }
+        },
+        _initMethod:function(){
+            vc.component.loadPrivilegeGroup();
+        },
+        methods:{
+            loadPrivilegeGroup:function(){
+                var param = {
+                    msg:234
+                };
+
+                //发送get请求
+               vc.http.get('privilegeGroup',
+                            'listPrivilegeGroup',
+                             param,
+                             function(json){
+                                var _groupsInfo = JSON.parse(json);
+                                vc.component.privilegeGroupInfo.groups = _groupsInfo;
+//                                vc.component.$emit('pagination_info_event',{
+//                                    total:_staffInfo.records,
+//                                    currentPage:_staffInfo.page
+//                                });
+
+                             },function(){
+                                console.log('请求失败处理');
+                             }
+                           );
+            },
+            notifyQueryPrivilege:function(_pGroup){
+                console.log("当前点击权限组",_pGroup)
+            }
+        }
+    });
+
 })(window.vc);

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

@@ -1,4 +1,4 @@
-<div class="row">
+<div id="component" class="row">
     <vc:create name="privilegeGroup"></vc:create>
     <div class="col-lg-9 animated fadeInRight">
         <div class="mail-box-header">

+ 1 - 0
java110-config/db/WebService/menu.sql

@@ -34,6 +34,7 @@ create table p_privilege_group(
     name varchar(10) not null comment '权限组名称',
     description VARCHAR(200) COMMENT '权限组描述',
     create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    store_id varchar(30) not null comment '商户ID',
     status_cd VARCHAR(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考c_status表,0在用,1失效',
     UNIQUE KEY (pg_id)