Browse Source

Merge remote-tracking branch 'origin/dev/icss' into dev/icss

wangyu 6 years ago
parent
commit
9f34600a42

+ 5 - 8
icssman-service/src/main/java/com/diagbot/client/UserServiceClient.java

@@ -2,13 +2,13 @@ package com.diagbot.client;
 
 import com.diagbot.client.hystrix.UserServiceHystrix;
 import com.diagbot.dto.RespDTO;
-import com.diagbot.entity.Token;
-import com.diagbot.entity.User;
-
+import com.diagbot.dto.UserNameDTO;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 
+import java.util.List;
+
 
 /**
  * @Description: 调用用户服务
@@ -18,11 +18,8 @@ import org.springframework.web.bind.annotation.RequestBody;
 @FeignClient(value = "user-service", fallback = UserServiceHystrix.class)
 public interface UserServiceClient {
 
-    @PostMapping("/user/verifyToken")
-    RespDTO<Boolean> verifyToken(@RequestBody Token token);
-    
-    @PostMapping(value = "/user/getUserAuthStatus")
-    RespDTO<User> getUserByUserId(@RequestBody Long userId);
+    @PostMapping(value = "/user/getUserInfoByIds")
+    RespDTO<List<UserNameDTO>> getUserInfoByIds(@RequestBody List<Long> ids);
 }
 
 

+ 7 - 11
icssman-service/src/main/java/com/diagbot/client/hystrix/UserServiceHystrix.java

@@ -2,10 +2,12 @@ package com.diagbot.client.hystrix;
 
 import com.diagbot.client.UserServiceClient;
 import com.diagbot.dto.RespDTO;
-import com.diagbot.entity.Token;
-import com.diagbot.entity.User;
+import com.diagbot.dto.UserNameDTO;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import java.util.List;
 
 
 /**
@@ -17,17 +19,11 @@ import org.springframework.stereotype.Component;
 @Slf4j
 public class UserServiceHystrix implements UserServiceClient {
 
-    @Override
-    public RespDTO<Boolean> verifyToken(Token token) {
-        log.error("【hystrix】调用{}异常", "verifyToken");
-        return null;
-    }
-
 	@Override
-	public RespDTO<User> getUserByUserId(Long userId) {
-		log.error("【hystrix】调用{}异常", "getUserByUserId");
+    public RespDTO<List<UserNameDTO>> getUserInfoByIds(@RequestBody List<Long> ids){
+        log.error("【hystrix】调用{}异常", "getUserInfoByIds");
         return null;
-	}
+    }
 
     
     

+ 16 - 0
icssman-service/src/main/java/com/diagbot/dto/UserNameDTO.java

@@ -0,0 +1,16 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2018/12/10 15:15
+ */
+@Getter
+@Setter
+public class UserNameDTO {
+    private Long id;//用户ID
+    private String username;// 用户名
+}

+ 0 - 251
icssman-service/src/main/java/com/diagbot/entity/User.java

@@ -1,251 +0,0 @@
-package com.diagbot.entity;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * <p>
- * 系统用户表
- * </p>
- *
- * @author gaodm
- * @since 2018-08-30
- */
-@TableName("sys_user")
-public class User implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    /**
-     * 用户ID
-     */
-    @TableId(value = "id", type = IdType.AUTO)
-    private Long id;
-
-    /**
-     * 是否删除,N:未删除,Y:删除
-     */
-    private String isDeleted;
-
-    /**
-     * 记录创建时间
-     */
-    private Date gmtCreate;
-
-    /**
-     * 记录修改时间,如果时间是1970年则表示纪录未修改
-     */
-    private Date gmtModified;
-
-    /**
-     * 创建人,0表示无创建人值
-     */
-    private String creator;
-
-    /**
-     * 修改人,如果为0则表示纪录未修改
-     */
-    private String modifier;
-
-    /**
-     * 用户名
-     */
-    private String username;
-
-    /**
-     * 用户密码
-     */
-    private String password;
-
-    /**
-     * 联系人
-     */
-    private String linkman;
-
-    /**
-     * 手机号(如果是客户,phone与username是一样的)
-     */
-    private String phone;
-
-    /**
-     * 所属岗位
-     */
-    private String position;
-
-    /**
-     * 所属部门
-     */
-    private String dept;
-
-    /**
-     * 邮箱
-     */
-    private String email;
-
-    /**
-     * 认证状态: 0 未认证,1 已认证,2 认证中
-     */
-    private Integer authStatus;
-
-    /**
-     * 认证通过时间
-     */
-    private Date passauthTime;
-
-    /**
-     * 1内部用户,0外部用户(默认0)
-     */
-    private Integer type;
-
-    /**
-     * 备注
-     */
-    private String remark;
-
-    public Long getId() {
-        return id;
-    }
-
-    public void setId(Long id) {
-        this.id = id;
-    }
-    public String getIsDeleted() {
-        return isDeleted;
-    }
-
-    public void setIsDeleted(String isDeleted) {
-        this.isDeleted = isDeleted;
-    }
-    public Date getGmtCreate() {
-        return gmtCreate;
-    }
-
-    public void setGmtCreate(Date gmtCreate) {
-        this.gmtCreate = gmtCreate;
-    }
-    public Date getGmtModified() {
-        return gmtModified;
-    }
-
-    public void setGmtModified(Date gmtModified) {
-        this.gmtModified = gmtModified;
-    }
-    public String getCreator() {
-        return creator;
-    }
-
-    public void setCreator(String creator) {
-        this.creator = creator;
-    }
-    public String getModifier() {
-        return modifier;
-    }
-
-    public void setModifier(String modifier) {
-        this.modifier = modifier;
-    }
-    public String getUsername() {
-        return username;
-    }
-
-    public void setUsername(String username) {
-        this.username = username;
-    }
-    public String getPassword() {
-        return password;
-    }
-
-    public void setPassword(String password) {
-        this.password = password;
-    }
-    public String getLinkman() {
-        return linkman;
-    }
-
-    public void setLinkman(String linkman) {
-        this.linkman = linkman;
-    }
-    public String getPhone() {
-        return phone;
-    }
-
-    public void setPhone(String phone) {
-        this.phone = phone;
-    }
-    public String getPosition() {
-        return position;
-    }
-
-    public void setPosition(String position) {
-        this.position = position;
-    }
-    public String getDept() {
-        return dept;
-    }
-
-    public void setDept(String dept) {
-        this.dept = dept;
-    }
-    public String getEmail() {
-        return email;
-    }
-
-    public void setEmail(String email) {
-        this.email = email;
-    }
-    public Integer getAuthStatus() {
-        return authStatus;
-    }
-
-    public void setAuthStatus(Integer authStatus) {
-        this.authStatus = authStatus;
-    }
-    public Date getPassauthTime() {
-        return passauthTime;
-    }
-
-    public void setPassauthTime(Date passauthTime) {
-        this.passauthTime = passauthTime;
-    }
-    public Integer getType() {
-        return type;
-    }
-
-    public void setType(Integer type) {
-        this.type = type;
-    }
-    public String getRemark() {
-        return remark;
-    }
-
-    public void setRemark(String remark) {
-        this.remark = remark;
-    }
-
-    @Override
-    public String toString() {
-        return "User{" +
-        "id=" + id +
-        ", isDeleted=" + isDeleted +
-        ", gmtCreate=" + gmtCreate +
-        ", gmtModified=" + gmtModified +
-        ", creator=" + creator +
-        ", modifier=" + modifier +
-        ", username=" + username +
-        ", password=" + password +
-        ", linkman=" + linkman +
-        ", phone=" + phone +
-        ", position=" + position +
-        ", dept=" + dept +
-        ", email=" + email +
-        ", authStatus=" + authStatus +
-        ", passauthTime=" + passauthTime +
-        ", type=" + type +
-        ", remark=" + remark +
-        "}";
-    }
-}

+ 1 - 0
user-service/src/main/java/com/diagbot/config/ResourceServerConfigurer.java

@@ -45,6 +45,7 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
                 .antMatchers("/userAuthentication/getAuthInfoCount").permitAll()
                 .antMatchers("/user/getUserAllInfo").permitAll()
                 .antMatchers("/user/verifyToken").permitAll()
+                .antMatchers("/user/getUserInfoByIds").permitAll()
                 .antMatchers("/**").authenticated();
         //        .antMatchers("/**").permitAll();
     }

+ 1 - 0
user-service/src/main/java/com/diagbot/config/security/UrlAccessDecisionManager.java

@@ -105,6 +105,7 @@ public class UrlAccessDecisionManager implements AccessDecisionManager {
                 || matchers("/userAuthentication/getAuthInfoCount", request)
                 || matchers("/user/getUserAllInfo", request)
                 || matchers("/user/verifyToken", request)
+                || matchers("/user/getUserInfoByIds", request)
                 || matchers("/", request)) {
             return true;
         }

+ 16 - 0
user-service/src/main/java/com/diagbot/dto/UserNameDTO.java

@@ -0,0 +1,16 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2018/12/10 15:15
+ */
+@Getter
+@Setter
+public class UserNameDTO {
+    private Long id;//用户ID
+    private String username;// 用户名
+}

+ 39 - 27
user-service/src/main/java/com/diagbot/facade/UserFacade.java

@@ -21,6 +21,7 @@ import com.diagbot.dto.UserAndProdutDTO;
 import com.diagbot.dto.UserInfoDTO;
 import com.diagbot.dto.UserInfoExportDTO;
 import com.diagbot.dto.UserLoginDTO;
+import com.diagbot.dto.UserNameDTO;
 import com.diagbot.dto.UserOrgDTO;
 import com.diagbot.dto.UserOrgizationProductDTO;
 import com.diagbot.entity.JWT;
@@ -819,8 +820,8 @@ public class UserFacade extends UserServiceImpl {
         auditMap.put("gmtModified", DateUtil.now());
         auditMap.put("certificationDate", DateUtil.now());
         User userDate = getById(userInfoAuditVO.getUserId());
-        if(!userDate.getAuthStatus().equals(2)){
-       	 return RespDTO.onError("该用户已被操作"); 
+        if (!userDate.getAuthStatus().equals(2)) {
+            return RespDTO.onError("该用户已被操作");
         }
         if (ByType == 1) {
             auditMap.put("isReject", RejectEnum.PASS.getKey());
@@ -904,7 +905,7 @@ public class UserFacade extends UserServiceImpl {
         User user = new User();
         user.setCreator(UserUtils.getCurrentPrincipleID());//创建id
         user.setUsername(userAndOrganizationVO.getUserName());//用户账号
-        String password= DigestUtils.md5Hex(userAndOrganizationVO.getPassWord());
+        String password = DigestUtils.md5Hex(userAndOrganizationVO.getPassWord());
         //System.out.println(password);
         PasswordEncoder passwordEncoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
         String entryPassword = passwordEncoder.encode(password);
@@ -960,10 +961,10 @@ public class UserFacade extends UserServiceImpl {
         map.put("userId", baseIdVO.getId());
         map.put("modifier", UserUtils.getCurrentPrincipleID());
         map.put("gmtModified", DateUtil.now());
-         User userDate = getById(baseIdVO.getId());
-         if(userDate.getIsDeleted().equals("Y")){
-        	 return RespDTO.onError("该用户已不存在"); 
-         }
+        User userDate = getById(baseIdVO.getId());
+        if (userDate.getIsDeleted().equals("Y")) {
+            return RespDTO.onError("该用户已不存在");
+        }
         //客户中心-查询用户续费数量
         RespDTO<Integer> renewalSums = diagbotmanClient.getUserWaitingRenewal(baseIdVO.getId());
         if (renewalSums == null || !"0".equals(renewalSums.code)) {
@@ -972,9 +973,9 @@ public class UserFacade extends UserServiceImpl {
         }
         int renewalSum = renewalSums.data;
         //System.out.println("========renewalSu====="+renewalSum);
-        if(renewalSum>0){
-   		 return RespDTO.onError("该用户无法删除,请先处理产品申请信息");
-      	}
+        if (renewalSum > 0) {
+            return RespDTO.onError("该用户无法删除,请先处理产品申请信息");
+        }
         //查询用户是否有待审核的产品数量
         RespDTO<Integer> auditSums = diagbotmanClient.getOrderByUserToAudit(baseIdVO.getId());
         if (auditSums == null || !"0".equals(auditSums.code)) {
@@ -983,25 +984,25 @@ public class UserFacade extends UserServiceImpl {
         }
         int auditSum = auditSums.data;
         //System.out.println("=========auditSumauditSum===="+auditSum);
-        if(auditSum>0){
-   		 return RespDTO.onError("该用户存在产品申请单,请先审核");
-    	}
+        if (auditSum > 0) {
+            return RespDTO.onError("该用户存在产品申请单,请先审核");
+        }
         List<Long> userIds = new ArrayList<>();
         userIds.add(baseIdVO.getId());
         RespDTO<List<UserAndProdutDTO>> InformationData = diagbotmanClient.getInformationAvailableAll(userIds);
-        
-            if (InformationData == null || !"0".equals(InformationData.code)) {
-                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
-                        "获取所有开通信息失败");
-            }
-            //获取该用户开通的产品信息的状态
-            List<UserAndProdutDTO> dataList = InformationData.data;
-            for(UserAndProdutDTO InformationDataNew :dataList){
-            	Integer serviceStatus =InformationDataNew.getServiceStatus();
-            	if(serviceStatus.equals(StatusEnum.Enable.getKey())){
-            		 return RespDTO.onError("请先停用所有产品");
-            	}
+
+        if (InformationData == null || !"0".equals(InformationData.code)) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
+                    "获取所有开通信息失败");
+        }
+        //获取该用户开通的产品信息的状态
+        List<UserAndProdutDTO> dataList = InformationData.data;
+        for (UserAndProdutDTO InformationDataNew : dataList) {
+            Integer serviceStatus = InformationDataNew.getServiceStatus();
+            if (serviceStatus.equals(StatusEnum.Enable.getKey())) {
+                return RespDTO.onError("请先停用所有产品");
             }
+        }
         boolean res = updateDeleted(map);
         if (!res) {
             throw new CommonException(CommonErrorCode.UPDATE_INFO_FAIL);
@@ -1403,8 +1404,8 @@ public class UserFacade extends UserServiceImpl {
         amendUserInfo.put("position", amendUserInfoVO.getPosition());
         amendUserInfo.put("linkman", amendUserInfoVO.getLinkman());
         User userDate = getById(amendUserInfoVO.getUserId());
-        if(userDate.getIsDeleted().equals("Y")){
-       	 return RespDTO.onError("该用户已不存在"); 
+        if (userDate.getIsDeleted().equals("Y")) {
+            return RespDTO.onError("该用户已不存在");
         }
         boolean res = updateUserInfo(amendUserInfo);
         if (!res) {
@@ -1433,4 +1434,15 @@ public class UserFacade extends UserServiceImpl {
         return RespDTO.onSuc(this.getById(userId));
     }
 
+    /**
+     * 根据用户ID列表获取用户数据
+     *
+     * @param ids 用户ID列表
+     * @return 用户名信息列表
+     */
+    public List<UserNameDTO> getUserInfoByIds(List<Long> ids) {
+        List<User> userList = this.getByIds(ids);
+        List<UserNameDTO> res = BeanUtil.listCopyTo(userList, UserNameDTO.class);
+        return res;
+    }
 }

+ 9 - 0
user-service/src/main/java/com/diagbot/web/UserController.java

@@ -7,6 +7,7 @@ import com.diagbot.dto.JwtDTO;
 import com.diagbot.dto.LoginDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.dto.UserLoginDTO;
+import com.diagbot.dto.UserNameDTO;
 import com.diagbot.dto.UserOrgDTO;
 import com.diagbot.entity.Permission;
 import com.diagbot.entity.Token;
@@ -347,4 +348,12 @@ public class UserController {
     public RespDTO<GetConsoleUserInfoDTO> getConsoleUserInfo() {
         return RespDTO.onSuc(userFacade.getConsoleUserInfo());
     }
+
+    @ApiOperation(value = "根据用户ID列表获取用户数据(远程调用)[by:gaodm]", notes = "根据用户ID列表获取用户数据")
+    @PostMapping("/getUserInfoByIds")
+    @SysLogger("getUserInfoByIds")
+    @ApiIgnore
+    public RespDTO<List<UserNameDTO>> getUserInfoByIds(@RequestBody List<Long> ids){
+        return RespDTO.onSuc(userFacade.getUserInfoByIds(ids));
+    }
 }