deason 6 жил өмнө
parent
commit
12d962fc09

+ 116 - 0
examcloud-core-print-provider/src/main/java/cn/com/qmth/examcloud/core/print/api/bean/UserInfo.java

@@ -0,0 +1,116 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-11-16 16:01:07.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.print.api.bean;
+
+import cn.com.qmth.examcloud.commons.web.security.bean.Role;
+import cn.com.qmth.examcloud.commons.web.security.bean.User;
+import cn.com.qmth.examcloud.commons.web.security.enums.RoleMeta;
+import cn.com.qmth.examcloud.core.print.service.bean.common.OrgInfo;
+
+import java.util.List;
+
+/**
+ * 用户信息
+ *
+ * @author: fengdesheng
+ * @since: 2018/11/16
+ */
+public class UserInfo {
+    /**
+     * 用户ID
+     */
+    private Long userId;
+    /**
+     * 用户名称
+     */
+    private String userName;
+    /**
+     * 学校机构ID
+     */
+    private Long orgId;
+    /**
+     * 学校机构名称
+     */
+    private String orgName;
+    /**
+     * 是否为项目经理
+     */
+    private boolean isPM;
+    /**
+     * 是否为印刷供应商
+     */
+    private boolean isSupplier;
+    /**
+     * 是否为学校用户
+     */
+    private boolean isSchoolUser;
+    /**
+     * 是否为负责人
+     */
+    private boolean isLeader;
+
+    public UserInfo(User user) {
+        this.userId = user.getUserId();
+        this.userName = user.getDisplayName();
+        this.orgId = user.getRootOrgId();
+        this.orgName = user.getRootOrgName();
+
+        //角色类型
+        List<Role> roles = user.getRoleList();
+        if (roles != null && !roles.isEmpty()) {
+            for (Role role : roles) {
+                if (RoleMeta.PROJECT_MANAGER.name().equals(role.getRoleCode())) {
+                    this.isPM = true;
+                } else if (RoleMeta.PRINT_SUPPLIER.name().equals(role.getRoleCode())) {
+                    this.isSupplier = true;
+                } else if (RoleMeta.PRINTER.name().equals(role.getRoleCode())) {
+                    this.isSchoolUser = true;
+                } else {
+                    this.isLeader = true;
+                }
+            }
+        }
+    }
+
+    public OrgInfo getOrgInfo() {
+        return new OrgInfo(orgId, orgName);
+    }
+
+    public boolean isPM() {
+        return isPM;
+    }
+
+    public boolean isSupplier() {
+        return isSupplier;
+    }
+
+    public boolean isSchoolUser() {
+        return isSchoolUser;
+    }
+
+    public boolean isLeader() {
+        return isLeader;
+    }
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public Long getOrgId() {
+        return orgId;
+    }
+
+    public String getOrgName() {
+        return orgName;
+    }
+
+}

+ 14 - 2
examcloud-core-print-provider/src/main/java/cn/com/qmth/examcloud/core/print/api/controller/PrintingProjectController.java

@@ -8,12 +8,14 @@
 package cn.com.qmth.examcloud.core.print.api.controller;
 
 import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
+import cn.com.qmth.examcloud.core.print.api.bean.UserInfo;
 import cn.com.qmth.examcloud.core.print.common.Result;
 import cn.com.qmth.examcloud.core.print.service.PrintingProjectService;
 import cn.com.qmth.examcloud.core.print.service.bean.common.ExamInfo;
 import cn.com.qmth.examcloud.core.print.service.bean.common.OrgInfo;
 import cn.com.qmth.examcloud.core.print.service.bean.printingproject.PrintingProjectInfo;
 import cn.com.qmth.examcloud.core.print.service.bean.printingproject.PrintingProjectQuery;
+import com.google.common.collect.Lists;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -64,8 +66,18 @@ public class PrintingProjectController extends ControllerSupport {
 
     @PostMapping("/org/list")
     @ApiOperation(value = "获取印刷学校列表")
-    public List<OrgInfo> getOrgList(@RequestParam(required = false) Long pmId, @RequestParam(required = false) Long supplierId) {
-        return printingProjectService.getOrgList(pmId, supplierId);
+    public List<OrgInfo> getOrgList() {
+        //根据登录用户的不同角色取不同的学校数据
+        UserInfo user = new UserInfo(getAccessUser());
+        if (user.isSchoolUser()) {
+            return Lists.newArrayList(user.getOrgInfo());
+        } else if (user.isPM()) {
+            return printingProjectService.getOrgList(user.getUserId(), null);
+        } else if (user.isSupplier()) {
+            return printingProjectService.getOrgList(null, user.getUserId());
+        } else {
+            return printingProjectService.getOrgList(null, null);
+        }
     }
 
     @PostMapping("/exam/list")

+ 9 - 0
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/bean/common/OrgInfo.java

@@ -26,6 +26,15 @@ public class OrgInfo implements JsonSerializable {
      */
     private String orgName;
 
+    public OrgInfo(Long orgId, String orgName) {
+        this.orgId = orgId;
+        this.orgName = orgName;
+    }
+
+    public OrgInfo() {
+
+    }
+
     public Long getOrgId() {
         return orgId;
     }

+ 1 - 1
examcloud-core-print-starter/src/main/resources/application-dev.properties

@@ -13,7 +13,7 @@ spring.redis.host=redis-host
 spring.redis.port=6379
 # spring cloud config
 spring.application.name=EC-CORE-PRINT
-eureka.client.serviceUrl.defaultZone=http://eureka-host:1111/eureka/
+eureka.client.serviceUrl.defaultZone=http://192.168.10.39:1111/eureka/
 # upyun config
 upyun.operator=examcloud
 upyun.psw=ecs87863577!@#

+ 1 - 1
examcloud-core-print-starter/src/main/resources/application-test.properties

@@ -13,7 +13,7 @@ spring.redis.host=redis-host
 spring.redis.port=6379
 # spring cloud config
 spring.application.name=EC-CORE-PRINT
-eureka.client.serviceUrl.defaultZone=http://eureka-host:1111/eureka/
+eureka.client.serviceUrl.defaultZone=http://192.168.10.39:1111/eureka/
 # upyun config
 upyun.operator=examcloud
 upyun.psw=ecs87863577!@#

+ 0 - 1
examcloud-core-print-starter/src/main/resources/security-exclusions.conf

@@ -14,7 +14,6 @@
 [${$rmp.ctrl.print}/printing/project][/{id}][POST]
 [${$rmp.ctrl.print}/printing/project][/update][POST]
 [${$rmp.ctrl.print}/printing/project][/all/init][GET]
-[${$rmp.ctrl.print}/printing/project][/org/list][POST]
 [${$rmp.ctrl.print}/printing/project][/exam/list][POST]
 
 [${$rmp.ctrl.print}/printing/project/statistic][/{orgId}/{examId}][POST]