Browse Source

web-gateway bug修改

LiTaohong 7 years ago
parent
commit
668a747cbe
22 changed files with 268 additions and 242 deletions
  1. 16 21
      web-gateway/pom.xml
  2. 1 1
      web-gateway/src/main/java/com/yihu/jw/aspect/LogAspect.java
  3. 21 18
      web-gateway/src/main/java/com/yihu/jw/commnon/base/user/BaseUserContants.java
  4. 6 6
      web-gateway/src/main/java/com/yihu/jw/commnon/iot/DataConstants.java
  5. 40 40
      web-gateway/src/main/java/com/yihu/jw/config/security/ClientService.java
  6. 48 48
      web-gateway/src/main/java/com/yihu/jw/config/security/RbasService.java
  7. 61 61
      web-gateway/src/main/java/com/yihu/jw/config/security/UserService.java
  8. 4 4
      web-gateway/src/main/java/com/yihu/jw/controller/base/user/BaseMenuController.java
  9. 2 2
      web-gateway/src/main/java/com/yihu/jw/controller/base/user/BaseRoleController.java
  10. 2 2
      web-gateway/src/main/java/com/yihu/jw/controller/base/version/UserVersionController.java
  11. 32 32
      web-gateway/src/main/java/com/yihu/jw/controller/login/LoginController.java
  12. 1 1
      web-gateway/src/main/java/com/yihu/jw/feign/base/user/BaseMenuFeign.java
  13. 1 1
      web-gateway/src/main/java/com/yihu/jw/feign/base/user/BaseRoleFeign.java
  14. 1 1
      web-gateway/src/main/java/com/yihu/jw/feign/base/user/EmployFeign.java
  15. 2 1
      web-gateway/src/main/java/com/yihu/jw/feign/base/version/UserVersionFeign.java
  16. 2 0
      web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/base/user/BaseMenuFeignFallbackFactory.java
  17. 2 0
      web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/base/user/BaseRoleFeignFallbackFactory.java
  18. 2 0
      web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/base/user/EmployeeFeignFallbackFactory.java
  19. 2 0
      web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/base/version/UserVersionFeignFallbackFactory.java
  20. 2 1
      web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/iot/data_input/DataInputFeignFallbackFactory.java
  21. 2 1
      web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/iot/data_input/DataStandardConvertFeignFallbackFactory.java
  22. 18 1
      web-gateway/src/main/resources/application.yml

+ 16 - 21
web-gateway/pom.xml

@ -32,10 +32,10 @@
            <artifactId>common-swagger</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.base</groupId>
            <artifactId>common-security</artifactId>
        </dependency>
        <!--<dependency>-->
            <!--<groupId>com.yihu.base</groupId>-->
            <!--<artifactId>common-security</artifactId>-->
        <!--</dependency>-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
@ -56,24 +56,24 @@
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>
        <dependency>
      <!--  <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
        </dependency>-->
        <!--<dependency>-->
            <!--<groupId>org.springframework.boot</groupId>-->
            <!--<artifactId>spring-boot-starter-security</artifactId>-->
        <!--</dependency>-->
     <!--   <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        </dependency>-->
        <dependency>
      <!--  <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-oauth2</artifactId>
        </dependency>
        </dependency>-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
@ -121,11 +121,11 @@
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
        </dependency>
        <dependency>
    <!--    <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>RELEASE</version>
        </dependency>
        </dependency>-->
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
@ -134,11 +134,6 @@
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.base</groupId>
            <artifactId>common-security</artifactId>
            <version>1.0.0</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>

+ 1 - 1
web-gateway/src/main/java/com/yihu/jw/aspect/LogAspect.java

@ -38,7 +38,7 @@ public class LogAspect {
            tracer.getCurrentSpan().tag(GatewayContanrts.ZipkinElasticKey.gateway_input_params,new JSONObject(request.getParameterMap()).toString());
            o = point.proceed();
            //访问后日志
            tracer.getCurrentSpan().tag(GatewayContanrts.ZipkinElasticKey.gateway_out_params,new JSONObject(o.toString()).toString());
            tracer.getCurrentSpan().tag(GatewayContanrts.ZipkinElasticKey.gateway_out_params,new JSONObject(o).toString());
        } catch (Exception ex) {
            ex.printStackTrace();
        }

+ 21 - 18
web-gateway/src/main/java/com/yihu/jw/commnon/base/user/BaseUserContants.java

@ -6,14 +6,16 @@ public class BaseUserContants {
    public static final String api_common = "/bases";
    public static final String api_baseRole = api_common+"/baseRole";
    public static final String api_employ = api_common+"/employee";
    public static final String api_baseMenu= api_common+"/employee";
    public static final String api_baseMenu= api_common+"/baseMenu";
    public static final String api_baseRoleMenu= api_common+"/baseRoleMenu";
    public static final String api_employRole= api_common+"/employeeRole";
    //角色常量
    public static class BaseRole{
        public static final String api_create="/";
        public static final String api_update="/";
        public static final String api_delete="/{id}";
        public static final String api_getById="/{id}";
        public static final String api_update="/update";
        public static final String api_delete="/delete/{id}";
        public static final String api_getById="/getById/{id}";
        public static final String api_getListNoPage="/listNoPage";
        public static final String api_getList="/list";
    }
@ -21,37 +23,38 @@ public class BaseUserContants {
    //角色菜单常量
    public static class BaseRoleMenu{
        public static final String api_create="/";
        public static final String api_update="/";
        public static final String api_delete="/{id}";
        public static final String api_getListNoPage="/listNoPage";
        public static final String api_create=api_baseRoleMenu ;
        public static final String api_update=api_baseRoleMenu + "/update";
        public static final String api_delete=api_baseRoleMenu + "/delete/{id}";
        public static final String api_getListNoPage=api_baseRoleMenu + "/listNoPage";
    }
    //用户常量
    public static class Employee{
        public static final String api_create="/";
        public static final String api_update="/";
        public static final String api_delete="/{id}";
        public static final String api_getById="/{id}";
        public static final String api_update="/update";
        public static final String api_delete="/delete/{id}";
        public static final String api_getById="/getById/{id}";
        public static final String api_getListNoPage="/listNoPage";
        public static final String api_getList="/list";
    }
    //用户角色常量
    public static class EmployeeRole{
        public static final String api_create="/";
        public static final String api_update="/";
        public static final String api_delete="/{id}";
        public static final String api_getListNoPage="/listNoPage";
        public static final String api_create= api_employRole;
        public static final String api_update= api_employRole + "/update";
        public static final String api_delete= api_employRole +"/delete/{id}";
        public static final String api_getListNoPage= api_employRole +"/listNoPage";
    }
    //菜单常量
    public static class BaseMenu{
        public static final String api_create="/";
        public static final String api_update="/";
        public static final String api_delete="/{id}";
        public static final String api_getById="/{id}";
        public static final String api_update="/update";
        public static final String api_delete="/delete/{id}";
        public static final String api_getById="/getById/{id}";
        public static final String api_children="/{saasId}/{parentId}";
        public static final String api_getListNoPage="/listNoPage";
        public static final String api_getList="/list";
    }

+ 6 - 6
web-gateway/src/main/java/com/yihu/jw/commnon/iot/DataConstants.java

@ -1,18 +1,18 @@
package com.yihu.jw.commnon.iot;
public class DataConstants {
    public static final String iot = "iot";
    public static final String api_iot_common = "/svr-iot";
    //数据标准转换
    public static class DataConvert{
        public static final String api_common = iot + "/dataConvert";
        public static final String api_convert = "convert";
        public static final String api_common = api_iot_common + "/dataConvert";
        public static final String api_convert = "/convert";
    }
    //数据上传常量
    public static class DataInput {
        public static final String api_common = iot + "/dataInput";
        public static final String api_bind_user = "userBind";
        public static final String api_upload_data = "input";
        public static final String api_common = api_iot_common + "/dataInput";
        public static final String api_bind_user = "/userBind";
        public static final String api_upload_data = "/input";
    }
}

+ 40 - 40
web-gateway/src/main/java/com/yihu/jw/config/security/ClientService.java

@ -1,40 +1,40 @@
package com.yihu.jw.config.security;
import com.yihu.base.security.rbas.ClientServiceProvider;
import org.springframework.context.annotation.Primary;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.ClientRegistrationException;
import org.springframework.security.oauth2.provider.client.BaseClientDetails;
import org.springframework.stereotype.Component;
import java.util.HashSet;
import java.util.Set;
/**
 * Created by chenweida on 2017/12/1.
 */
@Component("baseClientDetailsService")
@Primary
public class ClientService implements ClientServiceProvider {
    @Override
    public ClientDetails loadClientByClientId(String clientId) throws ClientRegistrationException {
//        SaasDO saasDO = saasDao.findByAppId(clientId);
//        if (saasDO == null) {
//            throw new ClientRegistrationException("用户没有注册");
//        }
        BaseClientDetails baseClientDetails = new BaseClientDetails();
        baseClientDetails.setClientId("cwd");
        baseClientDetails.setClientSecret("cwd");
        Set<String> strings = new HashSet<>();
        strings.add("password");
        strings.add("custom_password");
        strings.add("authorization_code");
        strings.add("refresh_token");
        baseClientDetails.setAuthorizedGrantTypes(strings);
        return baseClientDetails;
    }
}
//package com.yihu.jw.config.security;
//
//import com.yihu.base.security.rbas.ClientServiceProvider;
//import org.springframework.context.annotation.Primary;
//import org.springframework.security.oauth2.provider.ClientDetails;
//import org.springframework.security.oauth2.provider.ClientRegistrationException;
//import org.springframework.security.oauth2.provider.client.BaseClientDetails;
//import org.springframework.stereotype.Component;
//
//import java.util.HashSet;
//import java.util.Set;
//
///**
// * Created by chenweida on 2017/12/1.
// */
//@Component("baseClientDetailsService")
//@Primary
//public class ClientService implements ClientServiceProvider {
//
//    @Override
//    public ClientDetails loadClientByClientId(String clientId) throws ClientRegistrationException {
////        SaasDO saasDO = saasDao.findByAppId(clientId);
////        if (saasDO == null) {
////            throw new ClientRegistrationException("用户没有注册");
////        }
//        BaseClientDetails baseClientDetails = new BaseClientDetails();
//        baseClientDetails.setClientId("cwd");
//        baseClientDetails.setClientSecret("cwd");
//
//        Set<String> strings = new HashSet<>();
//        strings.add("password");
//        strings.add("custom_password");
//        strings.add("authorization_code");
//        strings.add("refresh_token");
//        baseClientDetails.setAuthorizedGrantTypes(strings);
//        return baseClientDetails;
//    }
//
//
//}

+ 48 - 48
web-gateway/src/main/java/com/yihu/jw/config/security/RbasService.java

@ -1,48 +1,48 @@
package com.yihu.jw.config.security;
import com.yihu.base.security.rbas.IRbasService;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Service;
import org.springframework.util.AntPathMatcher;
import javax.servlet.http.HttpServletRequest;
import java.util.HashSet;
import java.util.Set;
/**
 * Created by chenweida on 2017/12/5.
 * 判断用户是否有权限访问该路径
 */
@Service("rbasService")
public class RbasService implements IRbasService {
    private AntPathMatcher antPathMatcher = new AntPathMatcher();
    @Override
    public Boolean hasPerssion(HttpServletRequest request, Authentication authentication) {
        Object principal = authentication.getPrincipal();
        boolean hasPerssion = false;
        if (principal instanceof UserDetails) {
            //获取用户名字
            String username = ((UserDetails) principal).getUsername();
            //获取用户全部权限
            Set<String> uris = new HashSet<>();
            for (String uri : uris) {
                if (antPathMatcher.match(uri, request.getRequestURI())) {
                    hasPerssion = true;
                    break;
                }
            }
        }
        return true;
        //  return hasPerssion;
    }
    public Boolean hello() {
        return true;
    }
}
//package com.yihu.jw.config.security;
//
//import com.yihu.base.security.rbas.IRbasService;
//import org.springframework.security.core.Authentication;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.stereotype.Service;
//import org.springframework.util.AntPathMatcher;
//
//import javax.servlet.http.HttpServletRequest;
//import java.util.HashSet;
//import java.util.Set;
//
///**
// * Created by chenweida on 2017/12/5.
// * 判断用户是否有权限访问该路径
// */
//@Service("rbasService")
//public class RbasService implements IRbasService {
//
//    private AntPathMatcher antPathMatcher = new AntPathMatcher();
//
//
//    @Override
//    public Boolean hasPerssion(HttpServletRequest request, Authentication authentication) {
//        Object principal = authentication.getPrincipal();
//        boolean hasPerssion = false;
//        if (principal instanceof UserDetails) {
//            //获取用户名字
//            String username = ((UserDetails) principal).getUsername();
//
//
//            //获取用户全部权限
//            Set<String> uris = new HashSet<>();
//            for (String uri : uris) {
//                if (antPathMatcher.match(uri, request.getRequestURI())) {
//                    hasPerssion = true;
//                    break;
//                }
//            }
//        }
//        return true;
//        //  return hasPerssion;
//    }
//
//    public Boolean hello() {
//        return true;
//    }
//}

+ 61 - 61
web-gateway/src/main/java/com/yihu/jw/config/security/UserService.java

@ -1,61 +1,61 @@
package com.yihu.jw.config.security;
import com.yihu.jw.feign.base.user.EmployFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
/**
 * Created by chenweida on 2017/11/29.
 * 处理用户校验
 */
@Component
public class UserService implements UserDetailsService {
    @Autowired
    private PasswordEncoder passwordEncoder;
    @Autowired
    private EmployFeign employFeign;
    /**
     * 我们只需要把用户返回给spring-security 密码框架自己帮我们校验
     *
     * @param userName
     * @return
     * @throws UsernameNotFoundException
     */
    @Override
    public UserDetails loadUserByUsername(String userName) throws UsernameNotFoundException {
        if ("admin".equals(userName)) {
            System.out.printf("password:" + passwordEncoder.encode("123456"));
            return new User("admin",
                    passwordEncoder.encode("123456"),
                    true,
                    true,
                    true,
                    true
                    , AuthorityUtils.commaSeparatedStringToAuthorityList("admin,ROLE_USER") //权限
            );
        } else if ((!StringUtils.isEmpty(userName))&&userName.length() == 11) {
            System.out.printf("password:" + passwordEncoder.encode("123456"));
            return new User("admin",
                    passwordEncoder.encode("123456"),
                    true,
                    true,
                    true,
                    true
                    , AuthorityUtils.commaSeparatedStringToAuthorityList("admin,ROLE_USER") //权限
            );
        } else {
            throw new UsernameNotFoundException("用户不存在");
        }
    }
}
//package com.yihu.jw.config.security;
//
//
//import com.yihu.jw.feign.base.user.EmployFeign;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.core.authority.AuthorityUtils;
//import org.springframework.security.core.userdetails.User;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.core.userdetails.UsernameNotFoundException;
//import org.springframework.security.crypto.password.PasswordEncoder;
//import org.springframework.stereotype.Component;
//import org.springframework.util.StringUtils;
//
///**
// * Created by chenweida on 2017/11/29.
// * 处理用户校验
// */
//@Component
//public class UserService implements UserDetailsService {
//
//    @Autowired
//    private PasswordEncoder passwordEncoder;
//    @Autowired
//    private EmployFeign employFeign;
//
//    /**
//     * 我们只需要把用户返回给spring-security 密码框架自己帮我们校验
//     *
//     * @param userName
//     * @return
//     * @throws UsernameNotFoundException
//     */
//    @Override
//    public UserDetails loadUserByUsername(String userName) throws UsernameNotFoundException {
//        if ("admin".equals(userName)) {
//            System.out.printf("password:" + passwordEncoder.encode("123456"));
//            return new User("admin",
//                    passwordEncoder.encode("123456"),
//                    true,
//                    true,
//                    true,
//                    true
//                    , AuthorityUtils.commaSeparatedStringToAuthorityList("admin,ROLE_USER") //权限
//            );
//        } else if ((!StringUtils.isEmpty(userName))&&userName.length() == 11) {
//            System.out.printf("password:" + passwordEncoder.encode("123456"));
//            return new User("admin",
//                    passwordEncoder.encode("123456"),
//                    true,
//                    true,
//                    true,
//                    true
//                    , AuthorityUtils.commaSeparatedStringToAuthorityList("admin,ROLE_USER") //权限
//            );
//        } else {
//            throw new UsernameNotFoundException("用户不存在");
//        }
//    }
//
//}

+ 4 - 4
web-gateway/src/main/java/com/yihu/jw/controller/base/user/BaseMenuController.java

@ -84,8 +84,8 @@ public class BaseMenuController extends EnvelopRestController {
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    @GetMapping(value = BaseUserContants.BaseMenu.api_getById)
    @ApiOperation(value = "根据Id查找", notes = "根据uuid查找")
    @GetMapping(value = BaseUserContants.BaseMenu.api_children)
    @ApiOperation(value = "获取子菜单", notes = "根据父菜单id查找")
    public Envelop getChildren(@ApiParam(name = "saasId", value = "saasId") @RequestParam(value = "saasId", required = true) String saasId,
                               @ApiParam(name = "parentId", value = "parentId") @RequestParam(value = "parentId", required = true) String parentId) throws JiWeiException {
        return fegin.getChildren(saasId,parentId);
@ -96,7 +96,7 @@ public class BaseMenuController extends EnvelopRestController {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    @RequestMapping(value = BaseUserContants.BaseMenu.api_getList, method = RequestMethod.GET)
    @ApiOperation(value = "获取功能列表(分页)")
    @ApiOperation(value = "获取菜单列表(分页)")
    public Envelop getBaseMenus(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,saasId,createUser,remark")
            @RequestParam(value = "fields", required = false) String fields,
@ -125,7 +125,7 @@ public class BaseMenuController extends EnvelopRestController {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    @GetMapping(value = BaseUserContants.BaseMenu.api_getListNoPage)
    @ApiOperation(value = "获取功能列表,不分页")
    @ApiOperation(value = "获取菜单列表,不分页")
    public Envelop getListNoPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,saasId,createUser,remark")
            @RequestParam(value = "fields", required = false) String fields,

+ 2 - 2
web-gateway/src/main/java/com/yihu/jw/controller/base/user/BaseRoleController.java

@ -148,7 +148,7 @@ public class BaseRoleController extends EnvelopRestController {
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    @PutMapping(value = BaseUserContants.BaseRoleMenu.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PutMapping(value = BaseUserContants.BaseRoleMenu.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改角色菜单", notes = "修改角色菜单")
    public Envelop updateRoleMenu(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
@ -160,7 +160,7 @@ public class BaseRoleController extends EnvelopRestController {
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    @DeleteMapping(value = BaseUserContants.BaseRoleMenu.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @DeleteMapping(value = BaseUserContants.BaseRoleMenu.api_delete, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "删除角色菜单", notes = "删除角色菜单")
    public Envelop deleteRoleMenus(
            @ApiParam(name = "json_data", value = "", defaultValue = "")

+ 2 - 2
web-gateway/src/main/java/com/yihu/jw/controller/base/version/UserVersionController.java

@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping(BaseContants.api_common)
@Api(description = "灰度发布相关")
public class UserVersionController {
    @Autowired
    private UserVersionFeign userVersionFeign;
//    @Autowired
//    private UserVersionFeign userVersionFeign;
}

+ 32 - 32
web-gateway/src/main/java/com/yihu/jw/controller/login/LoginController.java

@ -1,33 +1,33 @@
package com.yihu.jw.controller.login;
import com.yihu.jw.config.security.UserService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.web.bind.annotation.*;
/**
 * Created by chenweida on 2017/6/16.
 */
@RestController
@Api(value = "登陆相关操作", description = "登陆相关操作")
public class LoginController {
    @Autowired
    private Tracer tracer;
    @Autowired
    private UserService userService;
//    @GetMapping(value = "/employLogin", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "患者登陆", notes = "患者登陆")
//    public Envelop employLogin(
//            @ApiParam(name = "account", value = "账号", defaultValue = "")
//            @RequestParam(name = "account", required = true) String account,
//            @ApiParam(name = "password", value = "密码", defaultValue = "")
//            @RequestParam(name = "password", required = true) String password,
//            @ApiParam(name = "type", value = "登陆方式(默认1):1账号密码 2账号验证码", defaultValue = "")
//            @RequestParam(name = "type", required = false, defaultValue = "1") Integer type) throws Exception {
//package com.yihu.jw.controller.login;
//
//        return null;
//    }
}
//import com.yihu.jw.config.security.UserService;
//import io.swagger.annotations.Api;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.cloud.sleuth.Tracer;
//import org.springframework.web.bind.annotation.*;
//
///**
// * Created by chenweida on 2017/6/16.
// */
//@RestController
//@Api(value = "登陆相关操作", description = "登陆相关操作")
//public class LoginController {
//    @Autowired
//    private Tracer tracer;
//    @Autowired
//    private UserService userService;
//
//
////    @GetMapping(value = "/employLogin", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
////    @ApiOperation(value = "患者登陆", notes = "患者登陆")
////    public Envelop employLogin(
////            @ApiParam(name = "account", value = "账号", defaultValue = "")
////            @RequestParam(name = "account", required = true) String account,
////            @ApiParam(name = "password", value = "密码", defaultValue = "")
////            @RequestParam(name = "password", required = true) String password,
////            @ApiParam(name = "type", value = "登陆方式(默认1):1账号密码 2账号验证码", defaultValue = "")
////            @RequestParam(name = "type", required = false, defaultValue = "1") Integer type) throws Exception {
////
////        return null;
////    }
//}

+ 1 - 1
web-gateway/src/main/java/com/yihu/jw/feign/base/user/BaseMenuFeign.java

@ -25,7 +25,7 @@ public interface BaseMenuFeign {
    Envelop update(@RequestBody String jsonData) throws JiWeiException;
    @RequestMapping(value =  BaseUserRequestMapping.BaseMenu.api_delete,method = RequestMethod.DELETE)
    Envelop delete(@PathVariable String id) throws JiWeiException;
    Envelop delete(@PathVariable(value = "id") String id) throws JiWeiException;
    @GetMapping(value = BaseUserRequestMapping.BaseMenu.api_getOne)
    Envelop findById(@PathVariable(value = "id", required = true) String id) throws JiWeiException;

+ 1 - 1
web-gateway/src/main/java/com/yihu/jw/feign/base/user/BaseRoleFeign.java

@ -25,7 +25,7 @@ public interface BaseRoleFeign {
    Envelop update(@RequestBody String jsonData) throws JiWeiException;
    @RequestMapping(value =  BaseUserRequestMapping.BaseRole.api_delete,method = RequestMethod.DELETE)
    Envelop delete(@PathVariable String id) throws JiWeiException;
    Envelop delete(@PathVariable(value = "id") String id) throws JiWeiException;
    @GetMapping(value = BaseUserRequestMapping.BaseRole.api_getById)
    Envelop findById(@PathVariable(value = "id", required = true) String id) throws JiWeiException;

+ 1 - 1
web-gateway/src/main/java/com/yihu/jw/feign/base/user/EmployFeign.java

@ -27,7 +27,7 @@ public interface EmployFeign {
    Envelop update(@RequestBody String jsonData) throws JiWeiException;
    @RequestMapping(value =  BaseUserRequestMapping.BaseEmploy.api_delete,method = RequestMethod.DELETE)
    Envelop delete(@PathVariable String id) throws JiWeiException;
    Envelop delete(@PathVariable (value = "id") String id) throws JiWeiException;
    @GetMapping(value = BaseUserRequestMapping.BaseEmploy.api_getById)
    Envelop findById(@PathVariable(value = "id", required = true) String id) throws JiWeiException;

+ 2 - 1
web-gateway/src/main/java/com/yihu/jw/feign/base/version/UserVersionFeign.java

@ -1,6 +1,7 @@
package com.yihu.jw.feign.base.version;
import com.yihu.jw.feign.fallbackfactory.base.base.SaasFeignFallbackFactory;
import com.yihu.jw.feign.fallbackfactory.base.version.UserVersionFeignFallbackFactory;
import com.yihu.jw.restmodel.CommonContants;
import com.yihu.jw.rm.base.BaseRequestMapping;
import org.springframework.cloud.netflix.feign.FeignClient;
@ -11,7 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 */
@FeignClient(
        name = CommonContants.svr_base // name值是eurika的实例名字
        ,fallbackFactory  = SaasFeignFallbackFactory.class
        ,fallbackFactory  = UserVersionFeignFallbackFactory.class
)
@RequestMapping(value = BaseRequestMapping.api_base_common)
public interface UserVersionFeign {

+ 2 - 0
web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/base/user/BaseMenuFeignFallbackFactory.java

@ -7,12 +7,14 @@ import com.yihu.jw.restmodel.common.Envelop;
import feign.hystrix.FallbackFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
/**
 * Created by LiTaohong on 2017/11/28.
 */
@Component
public class BaseMenuFeignFallbackFactory implements FallbackFactory<BaseMenuFeign> {
    @Autowired

+ 2 - 0
web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/base/user/BaseRoleFeignFallbackFactory.java

@ -6,12 +6,14 @@ import com.yihu.jw.restmodel.common.Envelop;
import feign.hystrix.FallbackFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
/**
 * Created by LiTaohong on 2017/11/28.
 */
@Component
public class BaseRoleFeignFallbackFactory implements FallbackFactory<BaseRoleFeign> {
    @Autowired

+ 2 - 0
web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/base/user/EmployeeFeignFallbackFactory.java

@ -6,12 +6,14 @@ import com.yihu.jw.restmodel.common.Envelop;
import feign.hystrix.FallbackFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
/**
 * Created by chenweida on 2017/11/29.
 */
@Component
public class EmployeeFeignFallbackFactory  implements FallbackFactory<EmployFeign> {
    @Autowired
    private Tracer tracer;

+ 2 - 0
web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/base/version/UserVersionFeignFallbackFactory.java

@ -2,10 +2,12 @@ package com.yihu.jw.feign.fallbackfactory.base.version;
import com.yihu.jw.feign.base.version.UserVersionFeign;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
/**
 * Created by chenweida on 2017/11/13.
 */
@Component
public class UserVersionFeignFallbackFactory implements FallbackFactory<UserVersionFeign> {
    @Override
    public UserVersionFeign create(Throwable cause) {

+ 2 - 1
web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/iot/data_input/DataInputFeignFallbackFactory.java

@ -5,8 +5,9 @@ import com.yihu.jw.restmodel.common.Envelop;
import feign.hystrix.FallbackFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
@Component
public class DataInputFeignFallbackFactory implements FallbackFactory<DataInputFeign> {
    @Autowired

+ 2 - 1
web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/iot/data_input/DataStandardConvertFeignFallbackFactory.java

@ -8,9 +8,10 @@ import com.yihu.jw.restmodel.common.Envelop;
import feign.hystrix.FallbackFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
@Component
public class DataStandardConvertFeignFallbackFactory implements FallbackFactory<DataStandardConvertFeign> {
    @Autowired

+ 18 - 1
web-gateway/src/main/resources/application.yml

@ -1,7 +1,7 @@
##如果有配置服务的话,远程服务器和本地服务器配置不一致的情况下,优先远程的为主
spring:
  application:
    name:  web-gateway-lith  #注册到发现服务的id 如果id一样 eurika会自动做负载
    name:  web-gateway  #注册到发现服务的id 如果id一样 eurika会自动做负载
  http:
    multipart:
      enabled: true
@ -19,6 +19,23 @@ management:
  security:
    enabled: false  #关闭 refresh的权限认证
hystrix:
  threadpool:
    default:
      coreSize: 500  #并发执行的最大线程数,默认10
  command:
    paas-file:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 3600000
    default:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 8000  #命令执行超时时间,默认1000ms
#zuul 默认会代理所有的微服务  路径 /{appliction.name}/**