Browse Source

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

wangyu 6 years ago
parent
commit
6334d3e2c3

+ 1 - 1
config-server/src/main/resources/shared/application-dev.yml

@@ -37,7 +37,7 @@ management:
   endpoints:
     web:
       exposure:
-        include: refresh,health,info,hystrix.stream
+        include: bus-refresh,health,info,hystrix.stream
       cors:
         allowed-origins: "*"
         allowed-methods: "*"

+ 1 - 1
config-server/src/main/resources/shared/application-local.yml

@@ -37,7 +37,7 @@ management:
   endpoints:
     web:
       exposure:
-        include: refresh,health,info,hystrix.stream
+        include: bus-refresh,health,info,hystrix.stream
       cors:
         allowed-origins: "*"
         allowed-methods: "*"

+ 2 - 0
config-server/src/main/resources/shared/gateway-service-dev.yml

@@ -75,4 +75,6 @@ spring:
 server:
   port: 5050
 
+lantone:
+  product: icss,1;icsstry,2
 

+ 2 - 0
config-server/src/main/resources/shared/gateway-service-local.yml

@@ -75,4 +75,6 @@ spring:
 server:
   port: 5050
 
+lantone:
+  product: icss,1;icsstry,2
 

+ 35 - 16
gateway-service/src/main/java/com/diagbot/filter/GlobalGatewayFilter.java

@@ -3,12 +3,12 @@ package com.diagbot.filter;
 import com.diagbot.client.DiagbotmanServiceClient;
 import com.diagbot.client.UserServiceClient;
 import com.diagbot.dto.RespDTO;
-import com.diagbot.entity.ServiceFilter;
 import com.diagbot.entity.ServiceToken;
 import com.diagbot.util.GsonUtil;
-import com.diagbot.util.ListUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.cloud.gateway.filter.GatewayFilterChain;
 import org.springframework.cloud.gateway.filter.GlobalFilter;
 import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
@@ -25,7 +25,6 @@ import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -34,6 +33,7 @@ import java.util.Map;
  * @time: 2018/9/7 13:55
  */
 @Configuration
+@RefreshScope
 @Slf4j
 public class GlobalGatewayFilter implements GlobalFilter {
 
@@ -41,6 +41,9 @@ public class GlobalGatewayFilter implements GlobalFilter {
     private static Boolean IS_GENERATE = false;
     private static Map<String, Long> SERVICE_FILTER = new HashMap<>();
 
+    @Value("${lantone.product}")
+    private String lantonePrduct;
+
     @Autowired
     UserServiceClient userServiceClient;
     @Autowired
@@ -67,19 +70,21 @@ public class GlobalGatewayFilter implements GlobalFilter {
         log.info("APIURL:{}", requestUri);
         log.info("SERVICENAME:{}", serviceName);
 
-        if(!IS_GENERATE) {
-            RespDTO<List<ServiceFilter>> filter = diagbotmanServiceClient.getAll();
-            if (filter != null){
-                List<ServiceFilter> list =  filter.data;
-                if (ListUtil.isNotEmpty(list)){
-                    for(ServiceFilter bean : list) {
-                        SERVICE_FILTER.put(bean.getName(), bean.getProductId());
-                    }
-                    IS_GENERATE = true;
-                }
-            }
-        }
-        if(SERVICE_FILTER.get(serviceName) != null) {
+//        if(!IS_GENERATE) {
+//            RespDTO<List<ServiceFilter>> filter = diagbotmanServiceClient.getAll();
+//            if (filter != null){
+//                List<ServiceFilter> list =  filter.data;
+//                if (ListUtil.isNotEmpty(list)){
+//                    for(ServiceFilter bean : list) {
+//                        SERVICE_FILTER.put(bean.getName(), bean.getProductId());
+//                    }
+//                    IS_GENERATE = true;
+//                }
+//            }
+//        }
+
+        Map<String, Long> serviceFilters = this.dealServiceFilter();
+        if(serviceFilters.get(serviceName) != null) {
             String appkey = request.getHeaders().getFirst("appkey");
             String secret = request.getHeaders().getFirst("secret");
             Long productId = SERVICE_FILTER.get(serviceName);
@@ -114,4 +119,18 @@ public class GlobalGatewayFilter implements GlobalFilter {
         DataBuffer buffer = serverWebExchange.getResponse().bufferFactory().wrap(bytes);
         return serverWebExchange.getResponse().writeWith(Flux.just(buffer));
     }
+
+    /**
+     * 处理需要过滤的列表
+     * @return 过滤的列表
+     */
+    private Map<String, Long> dealServiceFilter(){
+        Map<String, Long> serviceFilters = new HashMap<>();
+        String[] set = lantonePrduct.split(";");
+        for (String s: set){
+            String[] d = s.split(",");
+            serviceFilters.put(d[0],Long.valueOf(d[1]));
+        }
+        return serviceFilters;
+    }
 }

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

@@ -37,6 +37,7 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
                 .antMatchers("/user/getPermission").permitAll()
                 .antMatchers("/userInfo/updateUserInfoAll").permitAll()
                 .antMatchers("/userInfo/updateDeleted").permitAll()
+                .antMatchers("/user/index").permitAll()
                 .antMatchers("/**").authenticated();
 //        .antMatchers("/**").permitAll();
     }

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

@@ -49,6 +49,7 @@ public class UrlAccessDecisionManager implements AccessDecisionManager {
                 || matchers("/getUserEnumsData", request)
                 || matchers("/userInfo/getUserInfoPag", request)
                 || matchers("/user/getPermission", request)
+                || matchers("/user/index", request)
                 || matchers("/userInfo/updateUserInfoAll", request)
                 || matchers("/userInfo/updateDeleted", request)
                 

+ 115 - 0
user-service/src/main/java/com/diagbot/dto/ResultModelDTO.java

@@ -0,0 +1,115 @@
+package com.diagbot.dto;
+import java.io.Serializable;
+/**
+ * 数据服务接口
+ * 返回结果实体类
+ * @version 0.0.1
+ * @author wangfeng
+ * @since  2018-09-19
+ */
+public final class ResultModelDTO implements Serializable {
+    private static final long serialVersionUID = 1L;
+    public static final ResultModelDTO resultModel = new ResultModelDTO(true);
+	/**true表示处理成功**/
+	private boolean result;
+	/**消息体**/
+	private String message;
+    /**返回结果**/
+	private Object data;
+	/**扩展数据**/
+	private Object extendData;
+
+	/**
+	 * 构造
+	 * @param boolean
+	 * @return ResultModel
+	 */
+    public ResultModelDTO(final boolean success){
+        this(success,null,null,null);
+    }
+    /**
+	 * 构造
+	 * @return ResultModel
+	 */
+	public ResultModelDTO() {
+        super();
+    }
+	/**
+	 * 构造
+	 * @param success
+	 * @param msg
+	 * @param data
+	 * @param extendData
+	 * @return ResultModel
+	 */
+    public ResultModelDTO(final boolean success, final String msg,final Object data,final Object extendData) {
+        super();
+        this.result = success;
+        this.message = msg;
+        this.data = data;
+        this.extendData = extendData;
+    }
+     /**
+      * createSuccess 方法
+      * @param msg
+      * @param data
+      * @param extendData
+      * @return ResultModel
+      */
+	public static ResultModelDTO createSuccess(final String msg,final Object data,final Object extendData){
+	    return new ResultModelDTO(true,msg,data,extendData);
+	}
+	/**
+	 * create 方法
+	 * @param success
+	 * @param msg
+	 * @param data
+	 * @param extendData
+	 * @return ResultModel
+	 */
+    public static ResultModelDTO create(final boolean success, final String msg,final Object data,final Object extendData){
+        return new ResultModelDTO(success,msg,data,extendData);
+    }
+    /**
+     * create 方法
+     * @param success
+     * @param msg
+     * @param data
+     * @return create
+     */
+    public static ResultModelDTO create(final boolean success, final String msg,final Object data){
+        return new ResultModelDTO(success,msg,data,null);
+    }
+
+	public boolean isResult() {
+		return result;
+	}
+
+	public void setResult(boolean result) {
+		this.result = result;
+	}
+
+	public String getMessage() {
+		return message;
+	}
+
+	public void setMessage(String message) {
+		this.message = message;
+	}
+
+	public Object getData() {
+		return data;
+	}
+
+	public void setData(Object data) {
+		this.data = data;
+	}
+
+	public Object getExtendData() {
+		return extendData;
+	}
+
+	public void setExtendData(Object extendData) {
+		this.extendData = extendData;
+	}
+}

+ 11 - 0
user-service/src/main/java/com/diagbot/facade/UserFacade.java

@@ -1,5 +1,7 @@
 package com.diagbot.facade;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.diagbot.client.AuthServiceClient;
 import com.diagbot.dto.LoginDTO;
 import com.diagbot.dto.RespDTO;
@@ -91,6 +93,15 @@ public class UserFacade extends UserServiceImpl {
         return  user;
     }
 
+
+    public RespDTO<IPage<User>> index(Page page, UserSaveVO userSaveVO){
+        User user = new User();
+        BeanUtil.copyProperties(userSaveVO, user);
+        IPage<User> res = this.indexPage(page, user);
+        return RespDTO.onSuc(res);
+    }
+
+
     //添加一条默认用户认证信息
     public void doUserAuthentication(UserSaveVO userSaveVO, User user) {
         UserAuthentication ua = new UserAuthentication();

+ 3 - 3
user-service/src/main/java/com/diagbot/mapper/UserMapper.java

@@ -6,10 +6,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.diagbot.dto.UserInfoDTO;
 import com.diagbot.entity.User;
 import com.diagbot.vo.UserInfoOrganizationsVO;
-
 import org.apache.ibatis.annotations.Param;
 
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -25,7 +23,9 @@ public interface UserMapper extends BaseMapper<User> {
     User findByName(String username);
 
     IPage<User> selectUserListPage(Page page, @Param("user") User user);
-    
+
+    IPage<User> indexPage(Page page, @Param("user") User user);
+
     IPage<UserInfoDTO> selectUserInfoListPage(Page page,@Param("userInfo") UserInfoDTO userInfo);
     
     public Integer updateUserInfoAll(UserInfoOrganizationsVO userInfo);

+ 2 - 3
user-service/src/main/java/com/diagbot/service/UserService.java

@@ -7,9 +7,6 @@ import com.diagbot.dto.UserInfoDTO;
 import com.diagbot.entity.User;
 import com.diagbot.vo.UserInfoOrganizationsVO;
 
-import javafx.scene.control.Pagination;
-
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -31,4 +28,6 @@ public interface UserService extends IService<User> {
     public Integer updateUserInfoAll(UserInfoOrganizationsVO userInfo);
 
 	Integer updateDeleted(Map<String, String> map);
+
+    IPage<User> indexPage(Page<User> page, User user);
 }

+ 7 - 2
user-service/src/main/java/com/diagbot/service/impl/UserServiceImpl.java

@@ -8,10 +8,8 @@ import com.diagbot.entity.User;
 import com.diagbot.mapper.UserMapper;
 import com.diagbot.service.UserService;
 import com.diagbot.vo.UserInfoOrganizationsVO;
-
 import org.springframework.stereotype.Service;
 
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -49,4 +47,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 		return baseMapper.updateDeleted(map);
 		
 	}
+
+    @Override
+    public IPage<User> indexPage(Page<User> page, User user) {
+        return baseMapper.indexPage(page, user);
+    }
+
+
 }

+ 39 - 0
user-service/src/main/java/com/diagbot/vo/OrganizationVO.java

@@ -0,0 +1,39 @@
+package com.diagbot.vo;
+
+import java.util.Date;
+
+import lombok.Getter;
+import lombok.Setter;
+/**
+ * 
+ * @author wangfeng
+ * @Description: 添加机构信息
+ * @date 2018年9月19日 下午4:34:30
+ */
+
+@Getter
+@Setter
+public class OrganizationVO {
+	/**
+     * 机构名称
+     */
+    private String organizationName;
+    /**
+     * 机构类型
+     */
+    private Integer type;
+    /**
+     * 负责人
+     */
+    private String principal;
+    /**
+     * 机构地址
+     */
+    private String address;
+    /**
+     * 下属机构数量
+     */
+    private Integer subNum;
+	
+
+}

+ 46 - 0
user-service/src/main/java/com/diagbot/vo/UserAndOrganizationVO.java

@@ -0,0 +1,46 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 
+ * @author wangfeng
+ * @Description: 超级管理员与机构的绑定
+ * @date 2018年9月19日 下午4:56:08
+ */
+@Getter
+@Setter
+public class UserAndOrganizationVO {
+	
+	/**
+     * 机构id
+     */
+    private Long organizationid;
+    
+    /**
+     * 用户密码
+     */
+    private String passWord;
+
+    /**
+     * 用户名
+     */
+    private String userName;
+    
+    /**
+     * 联系人
+     */
+    private String linkman;
+
+    /**
+     * 邮箱
+     */
+    private String email;
+    
+    /**
+     * 岗位信息
+     */
+    private String position;
+
+}

+ 33 - 0
user-service/src/main/java/com/diagbot/vo/UserInfoVO.java

@@ -0,0 +1,33 @@
+package com.diagbot.vo;
+
+import java.util.Date;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Pattern;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 
+ * 
+ * @author wangfeng
+ * @Description: 用于超级管理员增加用户
+ * @date 2018年9月19日 下午5:25:23
+ */
+@Getter
+@Setter
+public class UserInfoVO {
+
+	@NotBlank(message = "请输入密码!")
+    @Pattern(regexp = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$",message = "密码必须数字和字母组成,并且要同时含有数字和字母,且长度要在6-16位之间")
+    private String password;
+    @NotBlank(message = "请输入手机号!")
+    private String username;
+    @NotBlank(message = "请输入机构名称!")
+    private String organization;
+    @NotBlank(message = "请输入联系人姓名!")
+    private String linkman;
+    @NotBlank(message = "请输入邮箱!")
+    private String email; //邮箱
+}

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

@@ -77,6 +77,18 @@ public class UserController {
     }
 
 
+    /**
+     * @Description: 用来测试分页,未用
+     * @Author: ztg
+     * @Date: 2018/9/19 18:43
+     */
+    @PostMapping("/index")
+    @SysLogger("index")
+    @ApiIgnore
+    public RespDTO<IPage<User>> indexUser(Page page, UserSaveVO userSaveVO){
+        return userFacade.index(page, userSaveVO);
+    }
+
     @ApiOperation(value = "获取资源信息",
             notes = "appkey:用户名,必填<br>" +
                     "secret:密码, 必填<br> ")

+ 47 - 10
user-service/src/main/java/com/diagbot/web/UserInfoController.java

@@ -16,11 +16,15 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.diagbot.annotation.SysLogger;
 import com.diagbot.dto.RespDTO;
+import com.diagbot.dto.ResultModelDTO;
 import com.diagbot.dto.UserInfoDTO;
 import com.diagbot.entity.Organization;
+import com.diagbot.entity.User;
 import com.diagbot.facade.OrganizationFacade;
 import com.diagbot.facade.UserFacade;
-import com.diagbot.util.UserUtils;
+import com.diagbot.util.DateUtil;
+import com.diagbot.vo.OrganizationVO;
+import com.diagbot.vo.UserAndOrganizationVO;
 import com.diagbot.vo.UserInfoOrganizationsVO;
 
 import io.swagger.annotations.Api;
@@ -41,6 +45,9 @@ public class UserInfoController {
 	@Autowired
 	OrganizationFacade organizationFacade;
 	
+	private final String MSG_SUCCESS = "操作成功!";
+    private final String MSG_ERROR = "操作失败!";
+	
 	    @ApiOperation(value = "分页查询获取用户信息", notes = "根据每页显示条数,默认 10,和当前页")
 	    @PostMapping("/getUserInfoPag")
 	    @SysLogger("getUserInfoPag")
@@ -68,10 +75,9 @@ public class UserInfoController {
 	    public RespDTO updateDeleted(@RequestParam String  userId){
 	    	Map<String,String> map = new HashMap<String, String>();
 	    	map.put("userId", userId);
-	    	//map.put("modifier",UserUtils.getCurrentPrincipleID());
+	    	//TODO map.put("modifier",UserUtils.getCurrentPrincipleID());
 	    	map.put("modifier","5");
-	    	SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-	    	map.put("gmtModified",df.format(new Date()));
+	    	map.put("gmtModified",DateUtil.DATE_TIME_FORMAT);
 	    	 int res= userFacade.updateDeleted(map);
 	    	 return RespDTO.onSuc("刪除成功"+res);
 	    }
@@ -83,25 +89,56 @@ public class UserInfoController {
 	    	//TODO 返回机构Id和机构
 	    	List<Organization> organization = organizationFacade.findOrganization(organizationName);
 	    	
-	    	 return RespDTO.onSuc("查询成功");
+	    	 return RespDTO.onSuc(organization);
 	    }
 	    
 	    @ApiOperation(value = "添加构信息", notes = "机构信息")
 	    @PostMapping("/addOrganization")
 	    @SysLogger("addOrganization")
-	    public RespDTO addOrganization(Organization  organization){
+	    public RespDTO<OrganizationVO> addOrganization(OrganizationVO  organizationVO){
 	    	//TODO
+	    	ResultModelDTO resultMode = new ResultModelDTO();
+	    	String organizationName = organizationVO.getOrganizationName();
+	    	List<Organization> organizationList = organizationFacade.findOrganization(organizationName);
+	    	if(organizationList.size()>0){
+	    		resultMode.setMessage("该机构存在");
+	    		return RespDTO.onSuc(resultMode);
+	    	}
+	    	Organization organization = new Organization();
+	    	organization.setName(organizationVO.getOrganizationName());
+	    	organization.setType(organizationVO.getType());
+	    	organization.setPrincipal(organizationVO.getPrincipal());
+	    	organization.setSubNum(organizationVO.getSubNum());
+	    	organization.setAddress(organizationVO.getAddress());
+	    	organization.setGmtCreate(DateUtil.now());
+	    	//TODO organization.setModifier(UserUtils.getCurrentPrincipleID());
+	    	organization.setCreator("5");
+	    	
+	    	boolean op = organizationFacade.save(organization);
 	    	
-	    	 return RespDTO.onSuc("成功");
+	    	resultMode.setMessage(op+"");
+	    	 return RespDTO.onSuc(resultMode);
 	    }
 	    
 	    @ApiOperation(value = "添加用户信息和机构信息管理员", notes = "用户信息和机构信息的绑定")
 	    @PostMapping("/addUserInfo")
 	    @SysLogger("addUserInfo")
-	    public RespDTO addUserInfo(@RequestParam String  userId){
+	    public RespDTO<UserAndOrganizationVO> addUserInfo(UserAndOrganizationVO  userAndOrganizationVO){
 	    	//TODO 先查找机构,获取机构id,再注册用户,返回用户id, 取到用户id和 机构id ,查询用户机构关联表,在进行绑定
-	    	
-	    	 return RespDTO.onSuc("成功");
+	    	//User user = new User();
+	    	ResultModelDTO resultMode = new ResultModelDTO();
+	    	String username = userAndOrganizationVO.getUserName();
+	    	 User user=  userFacade.getUserInfo(username);
+	    	 System.out.println(user);
+	    	 if(user!=null){
+	    		 resultMode.setMessage("该用户存在");
+		         return RespDTO.onSuc(resultMode); 
+	    	 }
+	    	 
+	    	 
+	    	 
+	    	 resultMode.setMessage("用户不存在"); 
+	    	 return RespDTO.onSuc(resultMode);
 	    } 
 	    
 	    

+ 1 - 1
user-service/src/main/resources/mapper/OrganizationMapper.xml

@@ -29,7 +29,7 @@
         where a.name = #{name} and a.is_deleted = 'N'
     </select>
 
-	<select id="findOrganization" parameterType="java.lang.String" >
+	<select id="findOrganization" parameterType="java.lang.String" resultType="com.diagbot.entity.Organization" >
 		SELECT id,NAME FROM sys_organization WHERE is_deleted = "N" AND NAME LIKE
 		CONCAT('%',  #{organizationName}, '%')
 	</select>

+ 12 - 0
user-service/src/main/resources/mapper/UserMapper.xml

@@ -33,6 +33,18 @@
         </if>
     </select>
 
+
+	<select id="indexPage" resultMap="BaseResultMap">
+		select u.* from sys_user u where u.is_deleted = 'N'
+		<if test="user.id != null">
+			and u.id = #{user.id}
+		</if>
+		<if test="user.username != null and user.username != '' ">
+			and u.username like concat('%',#{user.username},'%')
+		</if>
+	</select>
+
+
 <!-- 	<select id="selectUserInfoListPage" resultMap="BaseResultMap">
 		select u.*
 		LEFT JOIN sys_user_role ur on u.id= ur.user_id