yonge 3 years ago
parent
commit
33e425cb36
100 changed files with 7953 additions and 38 deletions
  1. 35 0
      cooleshow-auth/auth-api/pom.xml
  2. 18 0
      cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/client/AuthTaskFeignService.java
  3. 40 0
      cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/client/SysUserFeignService.java
  4. 20 0
      cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/client/fallback/AuthTaskFeignServiceFallback.java
  5. 47 0
      cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/client/fallback/SysUserFeignServiceFallback.java
  6. 61 0
      cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/dto/MenuQueryInfo.java
  7. 51 0
      cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/dto/SysUserInfo.java
  8. 75 0
      cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/entity/LoginEntity.java
  9. 216 0
      cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/entity/SysMenu.java
  10. 146 0
      cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/entity/SysOauthClientDetails.java
  11. 123 0
      cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/entity/SysRole.java
  12. 51 0
      cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/entity/SysRoleMenu.java
  13. 522 0
      cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/entity/SysUser.java
  14. 114 0
      cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/entity/SysUserDevice.java
  15. 103 0
      cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/entity/SysUserLogin.java
  16. 77 0
      cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/entity/SysUserLoginLog.java
  17. 41 0
      cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/entity/SysUserRole.java
  18. 41 0
      cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/enums/CertificateTypeEnum.java
  19. 36 0
      cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/enums/SysUserType.java
  20. 45 0
      cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/enums/UserLockFlag.java
  21. 33 0
      cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/enums/YesOrNoEnum.java
  22. 72 0
      cooleshow-auth/auth-server/pom.xml
  23. 36 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/AuthServerApplication.java
  24. 91 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/config/AuthorizationServerConfig.java
  25. 52 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/config/PermissionCheckService.java
  26. 84 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/config/RequestUtils.java
  27. 38 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/config/ResourceServerConfig.java
  28. 46 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/config/WebMvcConfig.java
  29. 137 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/config/WebSecurityConfig.java
  30. 79 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/config/token/PhoneAuthenticationToken.java
  31. 96 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/core/filter/PhoneLoginAuthenticationFilter.java
  32. 206 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/core/filter/UsernameAuthenticationFilter.java
  33. 74 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/core/handler/AuthenticationFailureListener.java
  34. 46 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/core/handler/BaseAuthenticationFailureEvenHandler.java
  35. 141 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/core/handler/BaseAuthenticationSuccessEventHandler.java
  36. 167 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/core/provider/AbstractAuthenticationProvider.java
  37. 151 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/core/provider/PhoneAuthenticationProvider.java
  38. 81 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/core/provider/service/DefaultUserDetailsService.java
  39. 35 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/core/service/CustomAuthenticationKeyGenerator.java
  40. 438 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/core/service/CustomTokenServices.java
  41. 55 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/dal/dao/SysMenuDao.java
  42. 9 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/dal/dao/SysOauthClientDetailsDao.java
  43. 32 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/dal/dao/SysRoleDao.java
  44. 45 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/dal/dao/SysRoleMenuDao.java
  45. 102 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/dal/dao/SysUserDao.java
  46. 15 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/dal/dao/SysUserDeviceDao.java
  47. 14 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/dal/dao/SysUserLoginDao.java
  48. 8 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/dal/dao/SysUserLoginLogDao.java
  49. 31 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/dal/dao/SysUserRoleDao.java
  50. 39 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/dal/enums/UserGenderEnum.java
  51. 45 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/dal/enums/UserStatus.java
  52. 37 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/interceptor/OperationLogInterceptor.java
  53. 37 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/SysMenuService.java
  54. 8 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/SysOauthClientDetailsService.java
  55. 39 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/SysRoleMenuService.java
  56. 43 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/SysRoleService.java
  57. 29 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/SysUserDeviceService.java
  58. 8 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/SysUserLoginLogService.java
  59. 20 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/SysUserLoginService.java
  60. 38 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/SysUserRoleService.java
  61. 127 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/SysUserService.java
  62. 126 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/impl/SysMenuServiceImpl.java
  63. 23 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/impl/SysOauthClientDetailsServiceImpl.java
  64. 66 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/impl/SysRoleMenuServiceImpl.java
  65. 91 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/impl/SysRoleServiceImpl.java
  66. 108 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/impl/SysUserDeviceServiceImpl.java
  67. 22 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/impl/SysUserLoginLogServiceImpl.java
  68. 72 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/impl/SysUserLoginServiceImpl.java
  69. 58 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/impl/SysUserRoleServiceImpl.java
  70. 204 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/impl/SysUserServiceImpl.java
  71. 88 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/web/controller/MenuController.java
  72. 125 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/web/controller/RoleController.java
  73. 23 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/web/controller/TaskController.java
  74. 194 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/web/controller/TokenController.java
  75. 350 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/web/controller/UserController.java
  76. 42 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/web/controller/UserDeviceController.java
  77. 38 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/web/controller/queryInfo/SysUserDeviceQueryInfo.java
  78. 36 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/web/controller/queryInfo/SysUserQueryInfo.java
  79. 16 0
      cooleshow-auth/auth-server/src/main/resources/bootstrap-dev.properties
  80. 21 0
      cooleshow-auth/auth-server/src/main/resources/config/mybatis/Global.mapper.xml
  81. 187 0
      cooleshow-auth/auth-server/src/main/resources/config/mybatis/SysMenuMapper.xml
  82. 99 0
      cooleshow-auth/auth-server/src/main/resources/config/mybatis/SysOauthClientDetailsMapper.xml
  83. 89 0
      cooleshow-auth/auth-server/src/main/resources/config/mybatis/SysRoleMapper.xml
  84. 65 0
      cooleshow-auth/auth-server/src/main/resources/config/mybatis/SysRoleMenuMapper.xml
  85. 128 0
      cooleshow-auth/auth-server/src/main/resources/config/mybatis/SysUserDeviceMapper.xml
  86. 44 0
      cooleshow-auth/auth-server/src/main/resources/config/mybatis/SysUserLoginLogMapper.xml
  87. 87 0
      cooleshow-auth/auth-server/src/main/resources/config/mybatis/SysUserLoginMapper.xml
  88. 221 0
      cooleshow-auth/auth-server/src/main/resources/config/mybatis/SysUserMapper.xml
  89. 58 0
      cooleshow-auth/auth-server/src/main/resources/config/mybatis/SysUserRoleMapper.xml
  90. 36 0
      cooleshow-auth/auth-server/src/main/resources/logback-spring.xml
  91. 6 9
      cooleshow-auth/pom.xml
  92. 73 29
      cooleshow-common/pom.xml
  93. 89 0
      cooleshow-common/src/main/java/com/yonge/cooleshow/common/cache/Cache.java
  94. 27 0
      cooleshow-common/src/main/java/com/yonge/cooleshow/common/cache/CacheException.java
  95. 60 0
      cooleshow-common/src/main/java/com/yonge/cooleshow/common/config/DateConverter.java
  96. 34 0
      cooleshow-common/src/main/java/com/yonge/cooleshow/common/config/EnumConverter.java
  97. 17 0
      cooleshow-common/src/main/java/com/yonge/cooleshow/common/config/EnumConverterFactory.java
  98. 22 0
      cooleshow-common/src/main/java/com/yonge/cooleshow/common/config/FeignConfiguration.java
  99. 74 0
      cooleshow-common/src/main/java/com/yonge/cooleshow/common/config/LocalFastJsonHttpMessageConverter.java
  100. 88 0
      cooleshow-common/src/main/java/com/yonge/cooleshow/common/config/ParameterCheckServletRequestWrapper.java

+ 35 - 0
cooleshow-auth/auth-api/pom.xml

@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<project
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+	xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>com.yonge.cooleshow</groupId>
+		<artifactId>cooleshow-auth</artifactId>
+		<version>1.0</version>
+	</parent>
+	<groupId>com.yonge.cooleshow</groupId>
+	<artifactId>auth-api</artifactId>
+	<version>1.0</version>
+	<name>auth-api</name>
+	<url>http://maven.apache.org</url>
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+	</properties>
+	<dependencies>
+		<dependency>
+			<groupId>com.spring4all</groupId>
+			<artifactId>swagger-spring-boot-starter</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-starter-openfeign</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>com.yonge.cooleshow</groupId>
+			<artifactId>cooleshow-common</artifactId>
+		</dependency>
+	</dependencies>
+</project>

+ 18 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/client/AuthTaskFeignService.java

@@ -0,0 +1,18 @@
+package com.yonge.cooleshow.auth.api.client;
+
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+
+import com.yonge.cooleshow.auth.api.client.fallback.AuthTaskFeignServiceFallback;
+import com.yonge.cooleshow.common.config.FeignConfiguration;
+
+@FeignClient(contextId = "authTaskFeignService", name = "auth-server", configuration = { FeignConfiguration.class }, fallback = AuthTaskFeignServiceFallback.class)
+public interface AuthTaskFeignService {
+
+	/**
+	 * 用户自动解锁
+	 * @return
+	 */
+	@GetMapping(value = "task/autoUnlock")
+	public boolean autoUnlock();
+}

+ 40 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/client/SysUserFeignService.java

@@ -0,0 +1,40 @@
+package com.yonge.cooleshow.auth.api.client;
+
+import java.util.List;
+
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import com.yonge.cooleshow.auth.api.client.fallback.SysUserFeignServiceFallback;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.common.config.FeignConfiguration;
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
+
+@FeignClient(contextId = "sysUserFeignService", name = "auth-server", configuration = { FeignConfiguration.class }, fallback = SysUserFeignServiceFallback.class)
+public interface SysUserFeignService {
+
+	@GetMapping(value = "user/queryUserById/{userId}")
+	public SysUser queryUserById(@PathVariable("userId") Integer userId);
+
+	@GetMapping(value = "user/queryUserByPhone")
+	public SysUser queryUserByMobile(@RequestParam("mobile") String mobile);
+
+	@PostMapping(value = "user/add", consumes = MediaType.APPLICATION_JSON_VALUE)
+	public HttpResponseResult<Integer> addUser(SysUser user);
+
+	@GetMapping(value = "queryUserInfo")
+	public SysUser queryUserInfo();
+
+	@GetMapping(value = "role/queryRoleCodeListByUserId")
+	public List<String> queryRoleCodeListByUserId(@RequestParam("userId") Integer userId);
+
+	@PostMapping(value = "user/updateSysUser", consumes = MediaType.APPLICATION_JSON_VALUE)
+	public Boolean updateSysUser(SysUser user);
+
+	@PostMapping(value = "exit/{clientId}/{phone}", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
+	public HttpResponseResult<String> exitByPhone(@PathVariable("clientId") String clientId, @PathVariable("phone") String phone);
+}

+ 20 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/client/fallback/AuthTaskFeignServiceFallback.java

@@ -0,0 +1,20 @@
+package com.yonge.cooleshow.auth.api.client.fallback;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+import com.yonge.cooleshow.auth.api.client.AuthTaskFeignService;
+
+@Component
+public class AuthTaskFeignServiceFallback implements AuthTaskFeignService {
+
+	private final static Logger logger = LoggerFactory.getLogger(AuthTaskFeignServiceFallback.class);
+
+	@Override
+	public boolean autoUnlock() {
+		logger.warn("用户自动解锁服务调用失败");
+		return false;
+	}
+
+}

+ 47 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/client/fallback/SysUserFeignServiceFallback.java

@@ -0,0 +1,47 @@
+package com.yonge.cooleshow.auth.api.client.fallback;
+
+import java.util.List;
+
+import org.springframework.stereotype.Component;
+
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
+
+@Component
+public class SysUserFeignServiceFallback implements SysUserFeignService {
+
+	@Override
+	public SysUser queryUserById(Integer userId) {
+		return null;
+	}
+
+	@Override
+	public SysUser queryUserInfo() {
+		return null;
+	}
+
+	@Override
+	public SysUser queryUserByMobile(String mobile) {
+		return null;
+	}
+
+	public HttpResponseResult<Integer> addUser(SysUser user){
+		return null;
+	}
+
+	@Override
+	public List<String> queryRoleCodeListByUserId(Integer userId) {
+		return null;
+	}
+
+	@Override
+	public Boolean updateSysUser(SysUser user) {
+		return false;
+	}
+
+	@Override
+	public HttpResponseResult<String> exitByPhone(String clientId, String phone) {
+		return null;
+	}
+}

+ 61 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/dto/MenuQueryInfo.java

@@ -0,0 +1,61 @@
+package com.yonge.cooleshow.auth.api.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import com.yonge.cooleshow.common.page.QueryInfo;
+
+public class MenuQueryInfo extends QueryInfo{
+    @ApiModelProperty(value = "父节点编号,默认0",required = false)
+    private Integer parentId = 0;
+
+    @ApiModelProperty(value = "节点状态,默认0未删除,1删除",required = false)
+    private String delFlag = "0";
+
+    @ApiModelProperty(value = "节点状态,默认0显示,1不显示",required = false)
+    private Integer hid;
+
+    @ApiModelProperty(value = "科目编号",required = false)
+    private Integer subjectId;
+
+    private Integer userId;
+
+    public Integer getSubjectId() {
+        return subjectId;
+    }
+
+    public void setSubjectId(Integer subjectId) {
+        this.subjectId = subjectId;
+    }
+
+    public Integer getHid() {
+        return hid;
+    }
+
+    public void setHid(Integer hid) {
+        this.hid = hid;
+    }
+
+    public Integer getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(Integer parentId) {
+        this.parentId = parentId;
+    }
+
+    public String getDelFlag() {
+        return delFlag;
+    }
+
+    public void setDelFlag(String delFlag) {
+        this.delFlag = delFlag;
+    }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+}

+ 51 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/dto/SysUserInfo.java

@@ -0,0 +1,51 @@
+package com.yonge.cooleshow.auth.api.dto;
+
+import java.io.Serializable;
+
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+
+public class SysUserInfo implements Serializable {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 7022224608947495223L;
+
+	/**
+	 * 用户基本信息
+	 */
+	private SysUser sysUser;
+	/**
+	 * 权限标识集合
+	 */
+	private String[] permissions;
+
+	/**
+	 * 角色集合
+	 */
+	private String[] roles;
+
+	public SysUser getSysUser() {
+		return sysUser;
+	}
+
+	public void setSysUser(SysUser sysUser) {
+		this.sysUser = sysUser;
+	}
+
+	public String[] getPermissions() {
+		return permissions;
+	}
+
+	public void setPermissions(String[] permissions) {
+		this.permissions = permissions;
+	}
+
+	public String[] getRoles() {
+		return roles;
+	}
+
+	public void setRoles(String[] roles) {
+		this.roles = roles;
+	}
+}

+ 75 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/entity/LoginEntity.java

@@ -0,0 +1,75 @@
+package com.yonge.cooleshow.auth.api.entity;
+
+import com.yonge.cooleshow.common.entity.BaseEntity;
+
+public class LoginEntity extends BaseEntity {
+    private String smsCode;
+
+    private String clientId;
+
+    private String clientSecret;
+
+    private Boolean isRegister;
+
+    private String phone;
+    
+    private String deviceNum;
+    
+    private String organId;
+
+    public Boolean getIsRegister() {
+		return isRegister;
+	}
+
+	public void setIsRegister(Boolean isRegister) {
+		this.isRegister = isRegister;
+	}
+
+	public String getSmsCode() {
+        return smsCode;
+    }
+
+    public void setSmsCode(String smsCode) {
+        this.smsCode = smsCode;
+    }
+
+    public String getClientId() {
+        return clientId;
+    }
+
+    public void setClientId(String clientId) {
+        this.clientId = clientId;
+    }
+
+    public String getClientSecret() {
+        return clientSecret;
+    }
+
+    public void setClientSecret(String clientSecret) {
+        this.clientSecret = clientSecret;
+    }
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
+	public String getDeviceNum() {
+		return deviceNum;
+	}
+
+	public void setDeviceNum(String deviceNum) {
+		this.deviceNum = deviceNum;
+	}
+
+	public String getOrganId() {
+		return organId;
+	}
+
+	public void setOrganId(String organId) {
+		this.organId = organId;
+	}
+}

+ 216 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/entity/SysMenu.java

@@ -0,0 +1,216 @@
+package com.yonge.cooleshow.auth.api.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.List;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(sys_menu):
+ */
+public class SysMenu {
+
+	/** 菜单ID */
+	@ApiModelProperty(value = "菜单ID",required = false)
+	private Integer id;
+
+	/** 菜单名称 */
+	@ApiModelProperty(value = "菜单名称",required = false)
+	private String name;
+
+	/** 菜单权限标识 */
+	@ApiModelProperty(value = "菜单权限标识",required = false)
+	private String permission;
+
+	/** 菜单权限标识 */
+	@ApiModelProperty(value = "顶级菜单权限标识",required = false)
+	private String parentPermission;
+
+	/** 接口路径 */
+	@ApiModelProperty(value = "接口路径",required = false)
+	private String path;
+
+	/** 父菜单ID */
+	@ApiModelProperty(value = "父菜单ID",required = false)
+	private Integer parentId;
+
+	/** 图标 */
+	@ApiModelProperty(value = "图标 */",required = false)
+	private String icon;
+
+	/** 前端页面地址 */
+	@ApiModelProperty(value = "前端页面地址",required = false)
+	private String component;
+
+	/** 排序值 */
+	@ApiModelProperty(value = "排序值",required = false)
+	private Integer sort;
+
+	/** 0-开启,1- 关闭 */
+	@ApiModelProperty(value = "0-开启,1- 关闭",required = false)
+	private String keepAlive;
+
+	/** 菜单类型 (0菜单 1按钮) */
+	@ApiModelProperty(value = "菜单类型 (0菜单 1按钮)",required = false)
+	private String type;
+
+	/** 创建时间 */
+	private java.util.Date createTime;
+
+	/** 更新时间 */
+	private java.util.Date updateTime;
+
+	/** 逻辑删除标记(0--正常 1--删除) */
+	@ApiModelProperty(value = "逻辑删除标记(0--正常 1--删除)",required = false)
+	private String delFlag;
+
+	private Integer hid;
+
+	@ApiModelProperty(value = "子节点列表",required = false)
+	private List<SysMenu> sysMenus;
+
+	private String memo;
+
+	public String getMemo() {
+		return memo;
+	}
+
+	public void setMemo(String memo) {
+		this.memo = memo;
+	}
+
+	public String getParentPermission() {
+		return parentPermission;
+	}
+
+	public void setParentPermission(String parentPermission) {
+		this.parentPermission = parentPermission;
+	}
+
+	public Integer getHid() {
+		return hid;
+	}
+
+	public void setHid(Integer hid) {
+		this.hid = hid;
+	}
+
+	public List<SysMenu> getSysMenus() {
+		return sysMenus;
+	}
+
+	public void setSysMenus(List<SysMenu> sysMenus) {
+		this.sysMenus = sysMenus;
+	}
+
+	public Integer getId() {
+		return id;
+	}
+
+	public void setId(Integer id) {
+		this.id = id;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public String getName() {
+		return this.name;
+	}
+
+	public void setPermission(String permission) {
+		this.permission = permission;
+	}
+
+	public String getPermission() {
+		return this.permission;
+	}
+
+	public void setPath(String path) {
+		this.path = path;
+	}
+
+	public String getPath() {
+		return this.path;
+	}
+
+	public void setParentId(Integer parentId) {
+		this.parentId = parentId;
+	}
+
+	public Integer getParentId() {
+		return this.parentId;
+	}
+
+	public void setIcon(String icon) {
+		this.icon = icon;
+	}
+
+	public String getIcon() {
+		return this.icon;
+	}
+
+	public String getComponent() {
+		return component;
+	}
+
+	public void setComponent(String component) {
+		this.component = component;
+	}
+
+	public void setSort(Integer sort) {
+		this.sort = sort;
+	}
+
+	public Integer getSort() {
+		return this.sort;
+	}
+
+	public void setKeepAlive(String keepAlive) {
+		this.keepAlive = keepAlive;
+	}
+
+	public String getKeepAlive() {
+		return this.keepAlive;
+	}
+
+	public void setType(String type) {
+		this.type = type;
+	}
+
+	public String getType() {
+		return this.type;
+	}
+
+	public void setCreateTime(java.util.Date createTime) {
+		this.createTime = createTime;
+	}
+
+	public java.util.Date getCreateTime() {
+		return this.createTime;
+	}
+
+	public void setUpdateTime(java.util.Date updateTime) {
+		this.updateTime = updateTime;
+	}
+
+	public java.util.Date getUpdateTime() {
+		return this.updateTime;
+	}
+
+	public void setDelFlag(String delFlag) {
+		this.delFlag = delFlag;
+	}
+
+	public String getDelFlag() {
+		return this.delFlag;
+	}
+
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 146 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/entity/SysOauthClientDetails.java

@@ -0,0 +1,146 @@
+package com.yonge.cooleshow.auth.api.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(sys_oauth_client_details):
+ */
+public class SysOauthClientDetails {
+
+	/** 客户端ID */
+	@ApiModelProperty(value = "客户端ID",required = false)
+	private String id;
+	
+	/** 资源ID */
+	@ApiModelProperty(value = "资源ID",required = false)
+	private String resourceIds;
+	
+	/** 客户端密钥 */
+	@ApiModelProperty(value = "客户端密钥",required = false)
+	private String clientSecret;
+	
+	/** 作用域 */
+	@ApiModelProperty(value = "作用域",required = false)
+	private String scope;
+	
+	/** 授权方式 */
+	@ApiModelProperty(value = "授权方式",required = false)
+	private String authorizedGrantTypes;
+	
+	/**  */
+	private String webServerRedirectUri;
+	
+	/**  */
+	private String authorities;
+	
+	/** 请求令牌有效时间 */
+	@ApiModelProperty(value = "请求令牌有效时间",required = false)
+	private Integer accessTokenValidity;
+	
+	/** 刷新令牌有效时间 */
+	@ApiModelProperty(value = "刷新令牌有效时间",required = false)
+	private Integer refreshTokenValidity;
+	
+	/** 扩展信息 */
+	@ApiModelProperty(value = "扩展信息",required = false)
+	private String additionalInformation;
+	
+	/** 是否自动放行 */
+	@ApiModelProperty(value = "是否自动放行",required = false)
+	private String autoapprove;
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public void setResourceIds(String resourceIds){
+		this.resourceIds = resourceIds;
+	}
+	
+	public String getResourceIds(){
+		return this.resourceIds;
+	}
+			
+	public void setClientSecret(String clientSecret){
+		this.clientSecret = clientSecret;
+	}
+	
+	public String getClientSecret(){
+		return this.clientSecret;
+	}
+			
+	public void setScope(String scope){
+		this.scope = scope;
+	}
+	
+	public String getScope(){
+		return this.scope;
+	}
+			
+	public void setAuthorizedGrantTypes(String authorizedGrantTypes){
+		this.authorizedGrantTypes = authorizedGrantTypes;
+	}
+	
+	public String getAuthorizedGrantTypes(){
+		return this.authorizedGrantTypes;
+	}
+			
+	public void setWebServerRedirectUri(String webServerRedirectUri){
+		this.webServerRedirectUri = webServerRedirectUri;
+	}
+	
+	public String getWebServerRedirectUri(){
+		return this.webServerRedirectUri;
+	}
+			
+	public void setAuthorities(String authorities){
+		this.authorities = authorities;
+	}
+	
+	public String getAuthorities(){
+		return this.authorities;
+	}
+			
+	public void setAccessTokenValidity(Integer accessTokenValidity){
+		this.accessTokenValidity = accessTokenValidity;
+	}
+	
+	public Integer getAccessTokenValidity(){
+		return this.accessTokenValidity;
+	}
+			
+	public void setRefreshTokenValidity(Integer refreshTokenValidity){
+		this.refreshTokenValidity = refreshTokenValidity;
+	}
+	
+	public Integer getRefreshTokenValidity(){
+		return this.refreshTokenValidity;
+	}
+			
+	public void setAdditionalInformation(String additionalInformation){
+		this.additionalInformation = additionalInformation;
+	}
+	
+	public String getAdditionalInformation(){
+		return this.additionalInformation;
+	}
+			
+	public void setAutoapprove(String autoapprove){
+		this.autoapprove = autoapprove;
+	}
+	
+	public String getAutoapprove(){
+		return this.autoapprove;
+	}
+			
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 123 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/entity/SysRole.java

@@ -0,0 +1,123 @@
+package com.yonge.cooleshow.auth.api.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.List;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+import com.yonge.cooleshow.common.entity.BaseEntity;
+
+/**
+ * 对应数据库表(sys_role):
+ */
+public class SysRole extends BaseEntity {
+
+	/**  */
+	private Integer id;
+	
+	/**  */
+	@ApiModelProperty(value = "角色名称",required = false)
+	private String roleName;
+	
+	/**  */
+	@ApiModelProperty(value = "角色编码",required = false)
+	private String roleCode;
+	
+	/**  */
+	@ApiModelProperty(value = "角色描述",required = false)
+	private String roleDesc;
+	
+	/**  */
+	private java.util.Date createTime;
+	
+	/**  */
+	private java.util.Date updateTime;
+	
+	/** 删除标识(0-正常,1-删除) */
+	@ApiModelProperty(value = "删除标识(0-正常,1-删除)",required = false)
+	private String delFlag;
+
+	private Integer organId;
+
+	@ApiModelProperty(value = "菜单列表",required = false)
+	private List<Integer> menuIds;
+
+	public List<Integer> getMenuIds() {
+		return menuIds;
+	}
+
+	public void setMenuIds(List<Integer> menuIds) {
+		this.menuIds = menuIds;
+	}
+
+	public Integer getId() {
+		return id;
+	}
+
+	public void setId(Integer id) {
+		this.id = id;
+	}
+
+	public void setRoleName(String roleName){
+		this.roleName = roleName;
+	}
+	
+	public String getRoleName(){
+		return this.roleName;
+	}
+			
+	public void setRoleCode(String roleCode){
+		this.roleCode = roleCode;
+	}
+	
+	public String getRoleCode(){
+		return this.roleCode;
+	}
+			
+	public void setRoleDesc(String roleDesc){
+		this.roleDesc = roleDesc;
+	}
+	
+	public String getRoleDesc(){
+		return this.roleDesc;
+	}
+			
+	public void setCreateTime(java.util.Date createTime){
+		this.createTime = createTime;
+	}
+	
+	public java.util.Date getCreateTime(){
+		return this.createTime;
+	}
+			
+	public void setUpdateTime(java.util.Date updateTime){
+		this.updateTime = updateTime;
+	}
+	
+	public java.util.Date getUpdateTime(){
+		return this.updateTime;
+	}
+			
+	public void setDelFlag(String delFlag){
+		this.delFlag = delFlag;
+	}
+	
+	public String getDelFlag(){
+		return this.delFlag;
+	}
+			
+	public Integer getOrganId() {
+		return organId;
+	}
+
+	public void setOrganId(Integer organId) {
+		this.organId = organId;
+	}
+
+    @Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 51 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/entity/SysRoleMenu.java

@@ -0,0 +1,51 @@
+package com.yonge.cooleshow.auth.api.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+import com.yonge.cooleshow.common.entity.BaseEntity;
+
+/**
+ * 对应数据库表(sys_role_menu):
+ */
+public class SysRoleMenu extends BaseEntity {
+
+	/** 角色ID */
+	@ApiModelProperty(value = "角色ID",required = false)
+	private Integer roleId;
+	
+	/** 菜单ID */
+	@ApiModelProperty(value = "菜单ID",required = false)
+	private Integer menuId;
+
+	public SysRoleMenu(Integer roleId, Integer menuId) {
+		this.roleId = roleId;
+		this.menuId = menuId;
+	}
+
+	public SysRoleMenu() {
+	}
+
+	public void setRoleId(Integer roleId){
+		this.roleId = roleId;
+	}
+	
+	public Integer getRoleId(){
+		return this.roleId;
+	}
+			
+	public void setMenuId(Integer menuId){
+		this.menuId = menuId;
+	}
+	
+	public Integer getMenuId(){
+		return this.menuId;
+	}
+			
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 522 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/entity/SysUser.java

@@ -0,0 +1,522 @@
+package com.yonge.cooleshow.auth.api.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+import com.yonge.cooleshow.auth.api.enums.YesOrNoEnum;
+import com.yonge.cooleshow.common.entity.BaseEntity;
+
+/**
+ * 对应数据库表(sys_user):
+ */
+public class SysUser extends BaseEntity implements Serializable{
+
+	/**
+	 *
+	 */
+	private static final long serialVersionUID = -1374403507360017093L;
+
+	/** 主键ID */
+	private Integer id;
+	
+	/** 用户名 */
+	@ApiModelProperty(value = "用户名",required = false)
+	private String username;
+
+	/**  */
+	@ApiModelProperty(value = "密码",required = false)
+	private String password;
+
+	/** 随机盐 */
+	@ApiModelProperty(value = "随机盐",required = false)
+	private String salt;
+
+	@ApiModelProperty(value = "手机号",required = false)
+	private String phone;
+
+	/** 头像 */
+	@ApiModelProperty(value = "头像",required = false)
+	private String avatar;
+
+	/** 部门ID */
+	@ApiModelProperty(value = "部门ID",required = false)
+	private Integer organId;
+
+	/** 部门ID */
+	@ApiModelProperty(value = "部门名称",required = false)
+	private String organName;
+
+	/** 创建时间 */
+	private java.util.Date createTime;
+
+	/** 修改时间 */
+	private java.util.Date updateTime;
+
+	/** 0-正常,9-锁定 */
+	@ApiModelProperty(value = "0-正常,9-锁定",required = false)
+	private Integer lockFlag;
+
+	/** 0-正常,1-删除 */
+	@ApiModelProperty(value = "0-正常,1-删除",required = false)
+	private YesOrNoEnum delFlag;
+
+	/** 微信openid */
+	@ApiModelProperty(value = "微信openid",required = false)
+	private String wxOpenid;
+
+	/** QQ openid */
+	@ApiModelProperty(value = "QQ openid",required = false)
+	private String qqOpenid;
+
+	/** 用户类型 */
+//	@ApiModelProperty(value = "用户类型",required = false)
+//	private String userType;
+
+	/** 用户类型 */
+//	@ApiModelProperty(value = "用户类型",required = false)
+	//STUDENT("学生"), EDU_TEACHER("教务老师"), TEACHER("指导老师"), SYSTEM("系统內置"), ADMIN("管理员")
+	private String userType;
+
+	@ApiModelProperty(value = "性别0女1男",required = false)
+	private Integer gender;
+
+	@ApiModelProperty(value = "民族",required = false)
+	private String nation;
+
+	@ApiModelProperty(value = "生日",required = false)
+	private Date birthdate;
+
+	@ApiModelProperty(value = "邮箱",required = false)
+	private String email;
+
+	@ApiModelProperty(value = "融云token",required = false)
+	private String imToken;
+
+	@ApiModelProperty(value = "身份证号",required = false)
+	private String idCardNo;
+
+	@ApiModelProperty(value = "真实姓名",required = false)
+	private String realName;
+
+	@ApiModelProperty(value = "年级",required = false)
+	private String currentGrade;
+
+	@ApiModelProperty(value = "年级(数字表示)",required = false)
+	private Integer currentGradeNum;
+
+	@ApiModelProperty(value = "班级",required = false)
+	private String currentClass;
+
+	@ApiModelProperty(value = "微信号",required = false)
+	private String wechatId;
+
+	@ApiModelProperty(value = "是否是超管",required = false)
+	private Boolean isSuperAdmin = false;
+
+	private Integer serviceTag;
+
+	private Integer operatingTag;
+
+	private Integer teacherId;
+
+	@ApiModelProperty(value = "用户角色",required = false)
+	private List<Integer> roles;
+
+	@ApiModelProperty(value = "联系地址",required = false)
+	private String contactAddress;
+
+	@ApiModelProperty(value = "邮编",required = false)
+	private String postalCode;
+
+	private String certificateType;
+
+	@ApiModelProperty(value = "社保部门id",required = false)
+	private Integer deptId;
+
+	@ApiModelProperty(value = "部门ids",required = false)
+	private String deptIds;
+
+	@ApiModelProperty(value = "岗位id",required = false)
+	private String postIds;
+
+	@ApiModelProperty(value = "岗位管理部门",required = false)
+	private String postDeptIds;
+
+	@ApiModelProperty(value = "银行卡号",required = false)
+	private String bankCard;
+
+	@ApiModelProperty(value = "开户行",required = false)
+	private String openBankAddress;
+	
+	private String positionName;
+
+	@ApiModelProperty(value = "用户职位",required = false)
+	private String positions;
+	
+	private String organIdList;
+
+	public String getPositions() {
+		return positions;
+	}
+
+	public void setPositions(String positions) {
+		this.positions = positions;
+	}
+
+	public String getCertificateType() {
+		return certificateType;
+	}
+
+	public void setCertificateType(String certificateType) {
+		this.certificateType = certificateType;
+	}
+
+	public Integer getServiceTag() {
+		return serviceTag;
+	}
+
+	public void setServiceTag(Integer serviceTag) {
+		this.serviceTag = serviceTag;
+	}
+
+	public Integer getOperatingTag() {
+		return operatingTag;
+	}
+
+	public void setOperatingTag(Integer operatingTag) {
+		this.operatingTag = operatingTag;
+	}
+
+	public String getCurrentGrade() {
+		return currentGrade;
+	}
+
+	public void setCurrentGrade(String currentGrade) {
+		this.currentGrade = currentGrade;
+	}
+
+	public String getCurrentClass() {
+		return currentClass;
+	}
+
+	public void setCurrentClass(String currentClass) {
+		this.currentClass = currentClass;
+	}
+
+	public String getOrganName() {
+		return organName;
+	}
+
+	public void setOrganName(String organName) {
+		this.organName = organName;
+	}
+
+	public String getRealName() {
+		return realName;
+	}
+
+	public void setRealName(String realName) {
+		this.realName = realName;
+	}
+
+	public String getImToken() {
+		return imToken;
+	}
+
+	public void setImToken(String imToken) {
+		this.imToken = imToken;
+	}
+
+	public Integer getId() {
+		return id;
+	}
+
+	public void setId(Integer id) {
+		this.id = id;
+	}
+
+	public void setUsername(String username) {
+		this.username = username;
+	}
+
+	public String getUsername() {
+		return this.username;
+	}
+
+	public void setPassword(String password) {
+		this.password = password;
+	}
+
+	public String getPassword() {
+		return this.password;
+	}
+
+	public void setSalt(String salt) {
+		this.salt = salt;
+	}
+
+	public String getSalt() {
+		return this.salt;
+	}
+
+	public void setPhone(String phone) {
+		this.phone = phone;
+	}
+
+	public String getPhone() {
+		return this.phone;
+	}
+
+	public void setAvatar(String avatar) {
+		this.avatar = avatar;
+	}
+
+	public String getAvatar() {
+		return this.avatar;
+	}
+
+	public Integer getOrganId() {
+		return organId;
+	}
+
+	public void setOrganId(Integer organId) {
+		this.organId = organId;
+	}
+
+	public void setCreateTime(java.util.Date createTime) {
+		this.createTime = createTime;
+	}
+
+	public java.util.Date getCreateTime() {
+		return this.createTime;
+	}
+
+	public void setUpdateTime(java.util.Date updateTime) {
+		this.updateTime = updateTime;
+	}
+
+	public java.util.Date getUpdateTime() {
+		return this.updateTime;
+	}
+
+	public Integer getLockFlag() {
+		return lockFlag;
+	}
+
+	public void setLockFlag(Integer lockFlag) {
+		this.lockFlag = lockFlag;
+	}
+
+	public Boolean getSuperAdmin() {
+		return isSuperAdmin;
+	}
+
+	public void setSuperAdmin(Boolean superAdmin) {
+		isSuperAdmin = superAdmin;
+	}
+
+	public YesOrNoEnum getDelFlag() {
+		return delFlag;
+	}
+
+	public void setDelFlag(YesOrNoEnum delFlag) {
+		this.delFlag = delFlag;
+	}
+
+	public void setWxOpenid(String wxOpenid) {
+		this.wxOpenid = wxOpenid;
+	}
+
+	public String getWxOpenid() {
+		return this.wxOpenid;
+	}
+
+	public void setQqOpenid(String qqOpenid) {
+		this.qqOpenid = qqOpenid;
+	}
+
+	public String getQqOpenid() {
+		return this.qqOpenid;
+	}
+
+	public String getUserType() {
+		return userType;
+	}
+
+	public void setUserType(String userType) {
+		if(StringUtils.isNotEmpty(userType) && userType.startsWith(",")){
+			userType = userType.substring(1);
+		}
+		this.userType = userType;
+	}
+
+	public Integer getGender() {
+		return gender;
+	}
+
+	public void setGender(Integer gender) {
+		this.gender = gender;
+	}
+
+	public String getNation() {
+		return nation;
+	}
+
+	public void setNation(String nation) {
+		this.nation = nation;
+	}
+
+	public Date getBirthdate() {
+		return birthdate;
+	}
+
+	public void setBirthdate(Date birthdate) {
+		this.birthdate = birthdate;
+	}
+
+	public String getEmail() {
+		return email;
+	}
+
+	public void setEmail(String email) {
+		this.email = email;
+	}
+
+	public String getIdCardNo() {
+		return idCardNo;
+	}
+
+	public void setIdCardNo(String idCardNo) {
+		this.idCardNo = idCardNo;
+	}
+
+	public String getWechatId() {
+		return wechatId;
+	}
+
+	public void setWechatId(String wechatId) {
+		this.wechatId = wechatId;
+	}
+
+	public Boolean getIsSuperAdmin() {
+		return isSuperAdmin;
+	}
+
+	public void setIsSuperAdmin(Boolean isSuperAdmin) {
+		this.isSuperAdmin = isSuperAdmin;
+	}
+
+	public Integer getTeacherId() {
+		return teacherId;
+	}
+
+	public void setTeacherId(Integer teacherId) {
+		this.teacherId = teacherId;
+	}
+
+	public List<Integer> getRoles() {
+		return roles;
+	}
+
+	public void setRoles(List<Integer> roles) {
+		this.roles = roles;
+	}
+	public String getContactAddress() {
+		return contactAddress;
+	}
+
+	public void setContactAddress(String contactAddress) {
+		this.contactAddress = contactAddress;
+	}
+
+	public String getPostalCode() {
+		return postalCode;
+	}
+
+	public void setPostalCode(String postalCode) {
+		this.postalCode = postalCode;
+	}
+
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+	public Integer getCurrentGradeNum() {
+		return currentGradeNum;
+	}
+
+	public void setCurrentGradeNum(Integer currentGradeNum) {
+		this.currentGradeNum = currentGradeNum;
+	}
+
+	public String getDeptIds() {
+		return deptIds;
+	}
+
+	public void setDeptIds(String deptId) {
+		this.deptIds = deptId;
+	}
+
+	public String getPostIds() {
+		return postIds;
+	}
+
+	public void setPostIds(String postIds) {
+		this.postIds = postIds;
+	}
+
+	public String getBankCard() {
+		return bankCard;
+	}
+
+	public void setBankCard(String bankCard) {
+		this.bankCard = bankCard;
+	}
+
+	public String getOpenBankAddress() {
+		return openBankAddress;
+	}
+
+	public void setOpenBankAddress(String openBankAddress) {
+		this.openBankAddress = openBankAddress;
+	}
+
+	public String getPostDeptIds() {
+		return postDeptIds;
+	}
+
+	public void setPostDeptIds(String postDeptIds) {
+		this.postDeptIds = postDeptIds;
+	}
+
+	public Integer getDeptId() {
+		return deptId;
+	}
+
+	public void setDeptId(Integer deptId) {
+		this.deptId = deptId;
+	}
+
+	public String getPositionName() {
+		return positionName;
+	}
+
+	public void setPositionName(String positionName) {
+		this.positionName = positionName;
+	}
+
+	public String getOrganIdList() {
+		return organIdList;
+	}
+
+	public void setOrganIdList(String organIdList) {
+		this.organIdList = organIdList;
+	}
+}

+ 114 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/entity/SysUserDevice.java

@@ -0,0 +1,114 @@
+package com.yonge.cooleshow.auth.api.entity;
+
+import java.util.Date;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+import com.yonge.cooleshow.common.entity.BaseEntity;
+
+/**
+ * 对应数据库表(sys_user_device):
+ */
+public class SysUserDevice extends BaseEntity {
+
+	/**  */
+	private Integer id;
+	
+	/** 用户编号 */
+	private Integer userId;
+	
+	/** 设备号 */
+	private String deviceNum;
+	
+	/** 绑定时间 */
+	private java.util.Date bindTime;
+	
+	private Date updateTime;
+	
+	/** 设备类型 */
+	private String deviceType;
+	
+	private String clientId;
+	
+	private Integer delFlag;
+	
+	private SysUser user;
+	
+	public void setId(Integer id){
+		this.id = id;
+	}
+	
+	public Integer getId(){
+		return this.id;
+	}
+			
+	public void setUserId(Integer userId){
+		this.userId = userId;
+	}
+	
+	public Integer getUserId(){
+		return this.userId;
+	}
+			
+	public void setDeviceNum(String deviceNum){
+		this.deviceNum = deviceNum;
+	}
+	
+	public String getDeviceNum(){
+		return this.deviceNum;
+	}
+			
+	public void setBindTime(java.util.Date bindTime){
+		this.bindTime = bindTime;
+	}
+	
+	public java.util.Date getBindTime(){
+		return this.bindTime;
+	}
+			
+	public Date getUpdateTime() {
+		return updateTime;
+	}
+
+	public void setUpdateTime(Date updateTime) {
+		this.updateTime = updateTime;
+	}
+
+	public void setDeviceType(String deviceType){
+		this.deviceType = deviceType;
+	}
+	
+	public String getDeviceType(){
+		return this.deviceType;
+	}
+			
+	public String getClientId() {
+		return clientId;
+	}
+
+	public void setClientId(String clientId) {
+		this.clientId = clientId;
+	}
+
+	public Integer getDelFlag() {
+		return delFlag;
+	}
+
+	public void setDelFlag(Integer delFlag) {
+		this.delFlag = delFlag;
+	}
+
+	public SysUser getUser() {
+		return user;
+	}
+
+	public void setUser(SysUser user) {
+		this.user = user;
+	}
+
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 103 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/entity/SysUserLogin.java

@@ -0,0 +1,103 @@
+package com.yonge.cooleshow.auth.api.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+import com.yonge.cooleshow.common.entity.BaseEntity;
+
+/**
+ * 对应数据库表(sys_user_login):
+ */
+public class SysUserLogin extends BaseEntity {
+
+	/**  */
+	@ApiModelProperty(value = "用户编号",required = false)
+	private Integer userId;
+	
+	/** 用户登录总次数 */
+	@ApiModelProperty(value = "用户登录总次数",required = false)
+	private Integer loginCount;
+	
+	/** 最后登录时间 */
+	@ApiModelProperty(value = "最后登录时间",required = false)
+	private java.util.Date lastLoginTime;
+	
+	/** 最后登录IP */
+	@ApiModelProperty(value = "最后登录IP",required = false)
+	private String lastLoginIp;
+	
+	/** 连续登陆失败的次数 */
+	@ApiModelProperty(value = "连续登陆失败的次数",required = false)
+	private Integer failCount;
+	
+	/** 锁定时间 单位:分钟(超过锁定时间自动解锁) */
+	@ApiModelProperty(value = "锁定时间 单位:分钟",required = false)
+	private Integer lockTime;
+	
+	/** 锁定日期 */
+	@ApiModelProperty(value = "锁定日期",required = false)
+	private java.util.Date lockDate;
+
+	public Integer getUserId() {
+		return userId;
+	}
+
+	public void setUserId(Integer userId) {
+		this.userId = userId;
+	}
+
+	public void setLoginCount(Integer loginCount){
+		this.loginCount = loginCount;
+	}
+	
+	public Integer getLoginCount(){
+		return this.loginCount;
+	}
+			
+	public void setLastLoginTime(java.util.Date lastLoginTime){
+		this.lastLoginTime = lastLoginTime;
+	}
+	
+	public java.util.Date getLastLoginTime(){
+		return this.lastLoginTime;
+	}
+			
+	public void setLastLoginIp(String lastLoginIp){
+		this.lastLoginIp = lastLoginIp;
+	}
+	
+	public String getLastLoginIp(){
+		return this.lastLoginIp;
+	}
+			
+	public void setFailCount(Integer failCount){
+		this.failCount = failCount;
+	}
+	
+	public Integer getFailCount(){
+		return this.failCount;
+	}
+			
+	public void setLockTime(Integer lockTime){
+		this.lockTime = lockTime;
+	}
+	
+	public Integer getLockTime(){
+		return this.lockTime;
+	}
+			
+	public void setLockDate(java.util.Date lockDate){
+		this.lockDate = lockDate;
+	}
+	
+	public java.util.Date getLockDate(){
+		return this.lockDate;
+	}
+			
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 77 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/entity/SysUserLoginLog.java

@@ -0,0 +1,77 @@
+package com.yonge.cooleshow.auth.api.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+import com.yonge.cooleshow.common.entity.BaseEntity;
+
+/**
+ * 对应数据库表(sys_user_login_log):
+ */
+public class SysUserLoginLog extends BaseEntity {
+
+	private Long id;
+
+	/** 会员ID */
+	@ApiModelProperty(value = "会员ID",required = false)
+	private Integer userId;
+
+	/** 登录IP */
+	@ApiModelProperty(value = "登录IP",required = false)
+	private String loginIp;
+
+	/** 登录时间 */
+	@ApiModelProperty(value = "登录时间",required = false)
+	private java.util.Date loginTime;
+
+	/** 终端类型(0,pc端;1,人工;2,移动端;3,自动) */
+	@ApiModelProperty(value = "终端类型(0,pc端;1,人工;2,移动端;3,自动)",required = false)
+	private Integer source;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public Integer getUserId() {
+		return userId;
+	}
+
+	public void setUserId(Integer userId) {
+		this.userId = userId;
+	}
+
+	public void setLoginIp(String loginIp) {
+		this.loginIp = loginIp;
+	}
+
+	public String getLoginIp() {
+		return this.loginIp;
+	}
+
+	public void setLoginTime(java.util.Date loginTime) {
+		this.loginTime = loginTime;
+	}
+
+	public java.util.Date getLoginTime() {
+		return this.loginTime;
+	}
+
+	public void setSource(Integer source) {
+		this.source = source;
+	}
+
+	public Integer getSource() {
+		return this.source;
+	}
+
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 41 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/entity/SysUserRole.java

@@ -0,0 +1,41 @@
+package com.yonge.cooleshow.auth.api.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+import com.yonge.cooleshow.common.entity.BaseEntity;
+
+/**
+ * 对应数据库表(sys_user_role):
+ */
+public class SysUserRole extends BaseEntity {
+	/** 用户ID */
+	@ApiModelProperty(value = "用户ID",required = false)
+	private Integer userId;
+	/** 角色ID */
+	@ApiModelProperty(value = "角色ID",required = false)
+	private Integer roleId;
+	
+	public void setUserId(Integer userId){
+		this.userId = userId;
+	}
+	
+	public Integer getUserId(){
+		return this.userId;
+	}
+			
+	public void setRoleId(Integer roleId){
+		this.roleId = roleId;
+	}
+	
+	public Integer getRoleId(){
+		return this.roleId;
+	}
+			
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 41 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/enums/CertificateTypeEnum.java

@@ -0,0 +1,41 @@
+package com.yonge.cooleshow.auth.api.enums;
+
+import com.yonge.cooleshow.common.enums.BaseEnum;
+
+/**
+ * @Author Joburgess
+ * @Date 2021/1/6 0006
+ **/
+public enum CertificateTypeEnum implements BaseEnum<String, CertificateTypeEnum> {
+
+    IDENTITY("IDENTITY", "身份证"),
+    HK_MAC("HK_MAC", "港澳居民往来内地通行证"),
+    TAIWAN("TAIWAN", "台湾居民往来内地通行证"),
+    FOREIGN_PASSPORT("FOREIGN_PASSPORT", "外国护照");
+
+    private String code;
+
+    private String msg;
+
+    CertificateTypeEnum(String code, String msg) {
+        this.code = code;
+        this.msg = msg;
+    }
+
+    @Override
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+}

+ 36 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/enums/SysUserType.java

@@ -0,0 +1,36 @@
+package com.yonge.cooleshow.auth.api.enums;
+
+import org.apache.commons.lang3.StringUtils;
+
+import com.yonge.cooleshow.common.enums.BaseEnum;
+
+public enum SysUserType implements BaseEnum<String, SysUserType> {
+
+	STUDENT("学生"), TEACHER("指导老师"), SYSTEM("系统內置");
+
+	private String desc;
+
+	private SysUserType(String desc) {
+	}
+
+	@Override
+	public String getCode() {
+		return name();
+	}
+
+	public String getDesc() {
+		return desc;
+	}
+
+	public static SysUserType queryByName(String name) {
+		if (StringUtils.isBlank(name)) {
+			return null;
+		}
+		for (SysUserType sysUserType : SysUserType.values()) {
+			if (name.equals(sysUserType.getCode())) {
+				return sysUserType;
+			}
+		}
+		return null;
+	}
+}

+ 45 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/enums/UserLockFlag.java

@@ -0,0 +1,45 @@
+package com.yonge.cooleshow.auth.api.enums;
+
+import com.yonge.cooleshow.common.enums.BaseEnum;
+
+/** 
+ * 会员状态枚举类
+ */
+public enum UserLockFlag implements BaseEnum<Integer, UserLockFlag> {
+
+	NORMAL(0, "正常"), LOCKED(9, "锁定"), CANCELLED(1, "冻结");
+
+	private int code;
+
+	UserLockFlag(int code, String remark) {
+		this.code = code;
+		this.remark = remark;
+	}
+
+	private String remark;
+
+	public Integer getCode() {
+		return code;
+	}
+
+	public void setCode(int code) {
+		this.code = code;
+	}
+
+	public String getRemark() {
+		return remark;
+	}
+
+	public void setRemark(String remark) {
+		this.remark = remark;
+	}
+
+	public static UserLockFlag codeOf(int code) {
+		for (UserLockFlag userStatus : UserLockFlag.values()) {
+			if (code == userStatus.getCode()) {
+				return userStatus;
+			}
+		}
+		return null;
+	}
+}

+ 33 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/enums/YesOrNoEnum.java

@@ -0,0 +1,33 @@
+package com.yonge.cooleshow.auth.api.enums;
+
+import com.yonge.cooleshow.common.enums.BaseEnum;
+
+public enum YesOrNoEnum implements BaseEnum<Integer, YesOrNoEnum> {
+    NO(0,"否"),
+    YES(1,"是");
+
+    private Integer code;
+    private String msg;
+
+    YesOrNoEnum(Integer code, String msg) {
+        this.code = code;
+        this.msg = msg;
+    }
+
+    public void setCode(Integer code) {
+        this.code = code;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+
+    @Override
+    public Integer getCode() {
+        return this.code;
+    }
+}

+ 72 - 0
cooleshow-auth/auth-server/pom.xml

@@ -0,0 +1,72 @@
+<?xml version="1.0"?>
+<project
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+	xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>com.yonge.cooleshow</groupId>
+		<artifactId>cooleshow-auth</artifactId>
+		<version>1.0</version>
+	</parent>
+	<groupId>com.yonge.cooleshow</groupId>
+	<artifactId>auth-server</artifactId>
+	<version>1.0</version>
+	<name>auth-server</name>
+	<url>http://maven.apache.org</url>
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+	</properties>
+	<dependencies>
+
+		<dependency>
+			<groupId>com.alibaba.cloud</groupId>
+			<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>com.alibaba.cloud</groupId>
+			<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-starter-oauth2</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-starter-security</artifactId>
+		</dependency>
+
+		<!-- swagger-spring-boot -->
+		<dependency>
+			<groupId>com.spring4all</groupId>
+			<artifactId>swagger-spring-boot-starter</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>com.github.xiaoymin</groupId>
+			<artifactId>swagger-bootstrap-ui</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>com.alibaba</groupId>
+			<artifactId>druid-spring-boot-starter</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>com.yonge.cooleshow</groupId>
+			<artifactId>auth-api</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>com.yonge.toolset</groupId>
+			<artifactId>audit-log</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.commons</groupId>
+			<artifactId>commons-pool2</artifactId>
+		</dependency>
+	</dependencies>
+</project>

+ 36 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/AuthServerApplication.java

@@ -0,0 +1,36 @@
+package com.yonge.cooleshow.auth;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.client.loadbalancer.LoadBalanced;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.web.client.RestTemplate;
+
+import com.spring4all.swagger.EnableSwagger2Doc;
+
+@SpringBootApplication
+@EnableDiscoveryClient
+@EnableFeignClients({"com.yonge.cooleshow"})
+@MapperScan("com.yonge.cooleshow.auth.dal.dao")
+@ComponentScan(basePackages={"com.yonge.cooleshow", "com.yonge.toolset.log"})
+@Configuration
+@EnableSwagger2Doc
+@EnableAsync
+public class AuthServerApplication {
+
+	public static void main(String[] args) {
+		SpringApplication.run(AuthServerApplication.class, args);
+	}
+	
+	@Bean
+	@LoadBalanced
+	public RestTemplate restTemplate(){
+		return new RestTemplate();
+	}
+}

+ 91 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/config/AuthorizationServerConfig.java

@@ -0,0 +1,91 @@
+package com.yonge.cooleshow.auth.config;
+
+import javax.sql.DataSource;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
+import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
+import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
+import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
+import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer;
+import org.springframework.security.oauth2.provider.client.JdbcClientDetailsService;
+import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
+
+import com.yonge.cooleshow.auth.core.service.CustomAuthenticationKeyGenerator;
+import com.yonge.cooleshow.auth.core.service.CustomTokenServices;
+import com.yonge.cooleshow.common.constant.CommonConstants;
+
+/**
+ * 授权服务器配置
+ */
+@Configuration
+@EnableAuthorizationServer
+public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {
+
+	@Autowired
+	private RedisConnectionFactory connectionFactory;
+	@Autowired
+	private AuthenticationManager authenticationManager;
+
+	@Autowired
+	private DataSource dataSource;
+
+	@Override
+	public void configure(AuthorizationServerEndpointsConfigurer endpoints){
+		endpoints
+				.authenticationManager(authenticationManager)
+				.tokenServices(defaultTokenServices())
+				.tokenStore(redisTokenStore());
+	}
+
+	@Override
+	public void configure(AuthorizationServerSecurityConfigurer security){
+		security.tokenKeyAccess("isAuthenticated()")
+				.checkTokenAccess("permitAll()")
+				.allowFormAuthenticationForClients();
+	}
+
+	@Override
+	public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
+
+		clients.withClientDetails(jdbcClientDetailsService());
+	}
+
+	@Bean
+	public JdbcClientDetailsService jdbcClientDetailsService() {
+		JdbcClientDetailsService clientDetailsService = new JdbcClientDetailsService(dataSource);
+
+		clientDetailsService
+				.setSelectClientDetailsSql("select id_, CONCAT('{noop}',client_secret_) as client_secret, resource_ids_, scope_, authorized_grant_types_, web_server_redirect_uri_, authorities_, access_token_validity_, refresh_token_validity_, additional_information_, autoapprove_ from sys_oauth_client_details where id_ = ?");
+		clientDetailsService
+				.setFindClientDetailsSql("select id_, CONCAT('{noop}',client_secret_) as client_secret, resource_ids_, scope_, authorized_grant_types_, web_server_redirect_uri_, authorities_, access_token_validity_, refresh_token_validity_, additional_information_, autoapprove_ from sys_oauth_client_details order by id_");
+
+		return clientDetailsService;
+	}
+
+	@Bean
+	public RedisTokenStore redisTokenStore() {
+		RedisTokenStore tokenStore = new RedisTokenStore(connectionFactory);
+		tokenStore.setAuthenticationKeyGenerator(new CustomAuthenticationKeyGenerator());
+		tokenStore.setPrefix(CommonConstants.OAUTH_PREFIX);
+		return tokenStore;
+	}
+
+	@Bean
+	@Primary
+	public CustomTokenServices defaultTokenServices() {
+		CustomTokenServices tokenServices = new CustomTokenServices();
+		tokenServices.setTokenStore(redisTokenStore());
+		tokenServices.setSupportRefreshToken(true);
+		tokenServices.setClientDetailsService(jdbcClientDetailsService());
+		//tokenServices.setAccessTokenValiditySeconds(60 * 60 * 24); // token有效期自定义设置,默认12小时
+		//tokenServices.setRefreshTokenValiditySeconds(60 * 60 * 24 * 30);// 默认30天,这里修改
+		return tokenServices;
+	}
+
+}

+ 52 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/config/PermissionCheckService.java

@@ -0,0 +1,52 @@
+package com.yonge.cooleshow.auth.config;
+
+import java.util.Collection;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.stereotype.Component;
+
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.auth.service.SysUserService;
+import com.yonge.cooleshow.common.security.AuthUser;
+import com.yonge.cooleshow.common.security.SecurityUtils;
+
+@Component("pcs")
+public class PermissionCheckService {
+
+	@Autowired
+	private SysUserService sysUserService;
+
+	public boolean hasPermissions(String... permissions) {
+		Authentication authentication = SecurityUtils.getAuthentication();
+		if (authentication == null) {
+			return false;
+		}
+
+		AuthUser authUser = SecurityUtils.getUser();
+		SysUser user = sysUserService.get(authUser.getUserId());
+		if (user.getIsSuperAdmin()) {
+			return true;
+		}
+
+		Collection<? extends GrantedAuthority> authorities = authentication.getAuthorities();
+
+		for (String perm : permissions) {
+			for (GrantedAuthority authority : authorities) {
+				if (StringUtils.equalsIgnoreCase(perm, authority.getAuthority())) {
+					return true;
+				}
+			}
+		}
+
+		return false;
+	}
+
+	public boolean hasRoles(String... roles) {
+
+		return hasPermissions(roles);
+	}
+
+}

+ 84 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/config/RequestUtils.java

@@ -0,0 +1,84 @@
+package com.yonge.cooleshow.auth.config;
+
+import com.alibaba.fastjson.JSONObject;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+
+public class RequestUtils {
+
+    public static JSONObject getRequestJsonObject(HttpServletRequest request) throws IOException {
+        String json = getRequestJsonString(request);
+        return JSONObject.parseObject(json);
+    }
+    /***
+     * 获取 request 中 json 字符串的内容
+     *
+     * @param request
+     * @return : <code>byte[]</code>
+     * @throws IOException
+     */
+    public static String getRequestJsonString(HttpServletRequest request)
+            throws IOException {
+        String submitMehtod = request.getMethod();
+        // GET
+        if (submitMehtod.equals("GET")) {
+            return new String(request.getQueryString().getBytes("iso-8859-1"),"utf-8").replaceAll("%22", "\"");
+            // POST
+        } else {
+            return getRequestPostStr(request);
+        }
+    }
+
+    /**
+     * 描述:获取 post 请求的 byte[] 数组
+     * <pre>
+     * 举例:
+     * </pre>
+     * @param request
+     * @return
+     * @throws IOException
+     */
+    public static byte[] getRequestPostBytes(HttpServletRequest request)
+            throws IOException {
+        int contentLength = request.getContentLength();
+        if(contentLength<0){
+            return null;
+        }
+        byte buffer[] = new byte[contentLength];
+        for (int i = 0; i < contentLength;) {
+
+            int readlen = request.getInputStream().read(buffer, i,
+                    contentLength - i);
+            if (readlen == -1) {
+                break;
+            }
+            i += readlen;
+        }
+        return buffer;
+    }
+
+    /**
+     * 描述:获取 post 请求内容
+     * <pre>
+     * 举例:
+     * </pre>
+     * @param request
+     * @return
+     * @throws IOException
+     */
+    public static String getRequestPostStr(HttpServletRequest request){
+        byte buffer[] = new byte[0];
+        try {
+            buffer = getRequestPostBytes(request);
+            String charEncoding = request.getCharacterEncoding();
+            if (charEncoding == null) {
+                charEncoding = "UTF-8";
+            }
+            return new String(buffer, charEncoding);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+}

+ 38 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/config/ResourceServerConfig.java

@@ -0,0 +1,38 @@
+package com.yonge.cooleshow.auth.config;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
+import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
+import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
+
+import com.yonge.cooleshow.common.security.BaseAccessDeniedHandler;
+import com.yonge.cooleshow.common.security.BaseAuthenticationEntryPoint;
+
+/**
+ * 资源服务器配置
+ */
+@Configuration
+@EnableResourceServer
+public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
+
+	@Autowired
+	private BaseAccessDeniedHandler baseAccessDeniedHandler;
+
+	@Autowired
+	private BaseAuthenticationEntryPoint baseAuthenticationEntryPoint;
+
+	@Override
+	public void configure(HttpSecurity http) throws Exception {
+		http.csrf().disable().exceptionHandling().accessDeniedHandler(baseAccessDeniedHandler).authenticationEntryPoint(baseAuthenticationEntryPoint).and()
+				.authorizeRequests().antMatchers("/task/**", "/user/updatePassword", "/user/noAuth/queryUserByPhone", "/user/queryUserByPhone", "/user/add", "/user/queryUserById/*").hasIpAddress("0.0.0.0/0")
+				.anyRequest().authenticated().and().httpBasic();
+	}
+
+	@Override
+	public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
+		resources.authenticationEntryPoint(baseAuthenticationEntryPoint).accessDeniedHandler(baseAccessDeniedHandler);
+	}
+
+}

+ 46 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/config/WebMvcConfig.java

@@ -0,0 +1,46 @@
+package com.yonge.cooleshow.auth.config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.format.FormatterRegistry;
+import org.springframework.http.MediaType;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+import com.yonge.cooleshow.auth.interceptor.OperationLogInterceptor;
+import com.yonge.cooleshow.common.config.EnumConverterFactory;
+import com.yonge.cooleshow.common.config.LocalFastJsonHttpMessageConverter;
+
+@Configuration
+public class WebMvcConfig implements WebMvcConfigurer {
+	
+	@Autowired
+	private OperationLogInterceptor operationLogInterceptor;
+
+	/**
+	 * 枚举类的转换器 addConverterFactory
+	 */
+	@Override
+	public void addFormatters(FormatterRegistry registry) {
+		registry.addConverterFactory(new EnumConverterFactory());
+	}
+	
+	@Override
+	public void addInterceptors(InterceptorRegistry registry) {
+		registry.addInterceptor(operationLogInterceptor).addPathPatterns("/userDevice/unbind").excludePathPatterns("/*");
+	}
+	
+	@Bean
+    public HttpMessageConverters fastJsonHttpMessageConverters(){
+		LocalFastJsonHttpMessageConverter converter = new LocalFastJsonHttpMessageConverter();
+        List<MediaType> fastMediaTypes =  new ArrayList<MediaType>();
+        fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
+        converter.setSupportedMediaTypes(fastMediaTypes);
+        return new HttpMessageConverters(converter);
+    }
+}

+ 137 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/config/WebSecurityConfig.java

@@ -0,0 +1,137 @@
+package com.yonge.cooleshow.auth.config;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
+import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
+import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.builders.WebSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.crypto.factory.PasswordEncoderFactories;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
+
+import com.yonge.cooleshow.auth.core.filter.PhoneLoginAuthenticationFilter;
+import com.yonge.cooleshow.auth.core.filter.UsernameAuthenticationFilter;
+import com.yonge.cooleshow.auth.core.handler.BaseAuthenticationFailureEvenHandler;
+import com.yonge.cooleshow.auth.core.handler.BaseAuthenticationSuccessEventHandler;
+import com.yonge.cooleshow.auth.core.provider.PhoneAuthenticationProvider;
+import com.yonge.cooleshow.auth.core.provider.service.DefaultUserDetailsService;
+import com.yonge.cooleshow.auth.service.SysUserDeviceService;
+import com.yonge.cooleshow.auth.service.SysUserService;
+import com.yonge.cooleshow.common.service.IdGeneratorService;
+
+@Configuration
+@EnableWebSecurity
+@EnableGlobalMethodSecurity(prePostEnabled = true)//会拦截注解了@PreAuthrize注解的配置.
+public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
+
+	@Autowired
+	private DefaultUserDetailsService defaultUserDetailsService;
+	
+	@Autowired
+	private BaseAuthenticationSuccessEventHandler successEventHandler;
+
+	@Autowired
+	private BaseAuthenticationFailureEvenHandler failureEvenHandler;
+
+	@Autowired
+	private IdGeneratorService smsCodeService;
+
+	@Autowired
+	private SysUserService sysUserService;
+	
+	@Autowired
+	private SysUserDeviceService sysUserDeviceService;
+	
+	@Override
+	protected void configure(AuthenticationManagerBuilder auth) throws Exception {
+		auth.authenticationProvider(daoAuthenticationProvider());
+		
+		PhoneAuthenticationProvider provider = phoneAuthenticationProvider();
+		provider.setSysUserService(sysUserService);
+		auth.authenticationProvider(provider);
+	}
+
+	@Override
+	protected void configure(HttpSecurity http) throws Exception {
+		// 表单登录 方式
+		http.formLogin().loginPage("/loginIn").loginPage("/smsLogin").and()
+			.addFilterBefore(getUsernameAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class)
+			.addFilterBefore(getPhoneLoginAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class)
+				//.exceptionHandling().accessDeniedHandler(baseAccessDeniedHandler).authenticationEntryPoint(baseAuthenticationEntryPoint).and()// 当未登录访问资源时
+				// 请求授权
+				.authorizeRequests()// 不需要权限认证的url
+				.antMatchers("/usernameLogin","/smsLogin", "/refreshToken", "/v2/api-docs").permitAll()// 任何请求
+				.anyRequest()// 需要身份认证
+				.authenticated().and()// 关闭跨站请求防护
+				.csrf().disable();
+	}
+
+	@Override
+	public void configure(WebSecurity web) throws Exception {
+		web.ignoring().antMatchers("/usernameLogin", "/smsLogin", "/refreshToken", "/v2/api-docs","/loginIn","/user/updatePassword");
+	}
+
+	@Bean
+	@Override
+	public AuthenticationManager authenticationManagerBean() throws Exception {
+		return super.authenticationManagerBean();
+	}
+
+	@Bean
+	public PasswordEncoder passwordEncoder() {
+		return PasswordEncoderFactories.createDelegatingPasswordEncoder();
+	}
+
+	@Bean
+	public DaoAuthenticationProvider daoAuthenticationProvider() {
+		DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
+		// 设置userDetailsService
+		provider.setUserDetailsService(defaultUserDetailsService);
+		// 禁止隐藏用户未找到异常
+		provider.setHideUserNotFoundExceptions(false);
+		// 使用BCrypt进行密码的hash
+		provider.setPasswordEncoder(passwordEncoder());
+		return provider;
+	}
+
+    @Bean
+    public PhoneAuthenticationProvider phoneAuthenticationProvider(){
+    	PhoneAuthenticationProvider provider = new PhoneAuthenticationProvider();
+        // 设置userDetailsService
+        provider.setUserDetailsService(defaultUserDetailsService);
+        provider.setSmsCodeService(smsCodeService);
+        provider.setSysUserService(sysUserService);
+        provider.setSysUserDeviceService(sysUserDeviceService);
+		// 禁止隐藏用户未找到异常
+		provider.setHideUserNotFoundExceptions(false);
+		
+        return provider;
+    }
+
+	@Bean
+	public UsernameAuthenticationFilter getUsernameAuthenticationFilter() throws Exception {
+		UsernameAuthenticationFilter filter = new UsernameAuthenticationFilter();
+		filter.setAuthenticationManager(authenticationManagerBean());
+		filter.setAuthenticationSuccessHandler(successEventHandler);
+		filter.setAuthenticationFailureHandler(failureEvenHandler);
+		filter.setSysUserService(sysUserService);
+		filter.setSysUserDeviceService(sysUserDeviceService);
+		return filter;
+	}
+
+	@Bean
+	public PhoneLoginAuthenticationFilter getPhoneLoginAuthenticationFilter() throws Exception {
+		PhoneLoginAuthenticationFilter filter = new PhoneLoginAuthenticationFilter();
+		filter.setAuthenticationManager(authenticationManagerBean());
+		filter.setAuthenticationSuccessHandler(successEventHandler);
+		filter.setAuthenticationFailureHandler(failureEvenHandler);
+		return filter;
+	}
+
+}

+ 79 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/config/token/PhoneAuthenticationToken.java

@@ -0,0 +1,79 @@
+package com.yonge.cooleshow.auth.config.token;
+
+import java.util.Collection;
+
+import org.springframework.security.authentication.AbstractAuthenticationToken;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.SpringSecurityCoreVersion;
+
+/**
+ * 手机验证码token
+ */
+public class PhoneAuthenticationToken extends AbstractAuthenticationToken {
+
+	private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;
+
+	// ~ Instance fields
+	// ================================================================================================
+
+	private final Object principal;
+	private Object credentials;
+
+	// ~ Constructors
+	// ===================================================================================================
+
+	/**
+	 * This constructor can be safely used by any code that wishes to create a
+	 * <code>UsernamePasswordAuthenticationToken</code>, as the {@link #isAuthenticated()}
+	 * will return <code>false</code>.
+	 *
+	 */
+	public PhoneAuthenticationToken(Object principal, Object credentials) {
+		super(null);
+		this.principal = principal;
+		this.credentials = credentials;
+		setAuthenticated(false);
+	}
+
+	/**
+	 * This constructor should only be used by <code>AuthenticationManager</code> or
+	 * <code>AuthenticationProvider</code> implementations that are satisfied with
+	 * producing a trusted (i.e. {@link #isAuthenticated()} = <code>true</code>)
+	 * authentication token.
+	 *
+	 * @param principal
+	 * @param credentials
+	 * @param authorities
+	 */
+	public PhoneAuthenticationToken(Object principal, Object credentials, Collection<? extends GrantedAuthority> authorities) {
+		super(authorities);
+		this.principal = principal;
+		this.credentials = credentials;
+		super.setAuthenticated(true); // must use super, as we override
+	}
+
+	// ~ Methods
+	// ========================================================================================================
+
+	public Object getCredentials() {
+		return this.credentials;
+	}
+
+	public Object getPrincipal() {
+		return this.principal;
+	}
+
+	public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException {
+		if (isAuthenticated) {
+			throw new IllegalArgumentException("Cannot set this token to trusted - use constructor which takes a GrantedAuthority list instead");
+		}
+
+		super.setAuthenticated(false);
+	}
+
+	@Override
+	public void eraseCredentials() {
+		super.eraseCredentials();
+		credentials = null;
+	}
+}

+ 96 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/core/filter/PhoneLoginAuthenticationFilter.java

@@ -0,0 +1,96 @@
+package com.yonge.cooleshow.auth.core.filter;
+
+import java.io.IOException;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.security.authentication.AbstractAuthenticationToken;
+import org.springframework.security.authentication.AuthenticationServiceException;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.AuthenticationException;
+import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter;
+import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
+
+import com.yonge.cooleshow.auth.api.entity.LoginEntity;
+import com.yonge.cooleshow.auth.config.token.PhoneAuthenticationToken;
+import com.yonge.cooleshow.common.security.SecurityConstants;
+
+public class PhoneLoginAuthenticationFilter extends AbstractAuthenticationProcessingFilter {
+
+	private static final String SPRING_SECURITY_RESTFUL_PHONE_KEY = "phone";
+	private static final String SPRING_SECURITY_RESTFUL_VERIFY_CODE_KEY = "smsCode";
+	private static final String clientIdParameter = "clientId";
+	private static final String IS_SURPORT_REGISTER = "isSurportRegister";
+
+	private static final String ORGAN_ID = "organId";
+	
+	private static final String DEVICE_NUM = "deviceNum";
+
+	private static final String SPRING_SECURITY_RESTFUL_LOGIN_URL = "/smsLogin";
+	private boolean postOnly = true;
+
+	public PhoneLoginAuthenticationFilter() {
+		super(new AntPathRequestMatcher(SPRING_SECURITY_RESTFUL_LOGIN_URL, "POST"));
+	}
+
+	@Override
+	public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException {
+		if (postOnly && !request.getMethod().equals("POST")) {
+			throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod());
+		}
+
+		AbstractAuthenticationToken authRequest;
+		// 手机验证码登陆
+		String principal = obtainParameter(request, SPRING_SECURITY_RESTFUL_PHONE_KEY);
+		String credentials = obtainParameter(request, SPRING_SECURITY_RESTFUL_VERIFY_CODE_KEY);
+		
+		String organId = obtainParameter(request, ORGAN_ID);
+
+		boolean isRegister = StringUtils.equals("true", request.getParameter(IS_SURPORT_REGISTER));
+
+		String clientId = request.getParameter(clientIdParameter).toUpperCase();
+
+		if ("EDUCATION".equals(clientId)) {
+			clientId = "SYSTEM";
+		}
+		
+		String deviceNum = request.getParameter(DEVICE_NUM);
+
+		principal = principal.trim();
+
+		LoginEntity loginEntity = new LoginEntity();
+		loginEntity.setClientId(clientId);
+		loginEntity.setPhone(principal);
+		loginEntity.setSmsCode(credentials);
+		loginEntity.setIsRegister(isRegister);
+		loginEntity.setDeviceNum(deviceNum);
+		loginEntity.setOrganId(organId);
+
+		authRequest = new PhoneAuthenticationToken(SecurityConstants.PHONE_PRINCIPAL_PREFIX + principal, loginEntity);
+
+		// Allow subclasses to set the "details" property
+		setDetails(request, authRequest);
+		return this.getAuthenticationManager().authenticate(authRequest);
+	}
+
+	@Override
+	protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain, Authentication authResult)
+			throws IOException, ServletException {
+		super.successfulAuthentication(request, response, chain, authResult);
+		// chain.doFilter(request, response);
+	}
+
+	private void setDetails(HttpServletRequest request, AbstractAuthenticationToken authRequest) {
+		authRequest.setDetails(authenticationDetailsSource.buildDetails(request));
+	}
+
+	private String obtainParameter(HttpServletRequest request, String parameter) {
+		String result = request.getParameter(parameter);
+		return result == null ? "" : result;
+	}
+
+}

+ 206 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/core/filter/UsernameAuthenticationFilter.java

@@ -0,0 +1,206 @@
+package com.yonge.cooleshow.auth.core.filter;
+
+import java.io.IOException;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.security.authentication.AuthenticationServiceException;
+import org.springframework.security.authentication.LockedException;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.AuthenticationException;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
+import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter;
+import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
+import org.springframework.util.Assert;
+
+import com.yonge.cooleshow.auth.api.dto.SysUserInfo;
+import com.yonge.cooleshow.auth.service.SysUserDeviceService;
+import com.yonge.cooleshow.auth.service.SysUserService;
+import com.yonge.cooleshow.common.security.SecurityConstants;
+
+public class UsernameAuthenticationFilter extends AbstractAuthenticationProcessingFilter {
+
+	private SysUserService sysUserService;
+	
+	private SysUserDeviceService sysUserDeviceService;
+
+	// ~ Static fields/initializers
+	// =====================================================================================
+
+	private String usernameParameter = "username";
+	private String passwordParameter = "password";
+	private String clientIdParameter = "clientId";
+	private String deviceNumParameter = "deviceNum";
+	private boolean postOnly = true;
+
+	// ~ Constructors
+	// ===================================================================================================
+
+	public UsernameAuthenticationFilter() {
+		super(new AntPathRequestMatcher("/usernameLogin", "POST"));
+	}
+
+	// ~ Methods
+	// ========================================================================================================
+
+	public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException {
+		if (postOnly && !request.getMethod().equals("POST")) {
+			throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod());
+		}
+
+		String username = obtainUsername(request);
+		String password = obtainPassword(request);
+		if (username == null) {
+			username = "";
+		}
+
+		if (password == null) {
+			password = "";
+		}
+
+		username = username.trim();
+		password = password.trim();
+
+		SysUserInfo userInfo = sysUserService.queryUserInfoByUsername(username);
+
+		String clientId = request.getParameter(clientIdParameter).toUpperCase();
+
+		if (userInfo == null) {
+			throw new UsernameNotFoundException("404.9");
+		}
+	
+//		if (userInfo.getSysUser().getUserType() != SysUserType.SYSTEM && !StringUtils.equalsIgnoreCase(clientId, userInfo.getSysUser().getUserType().getCode())) {
+//			throw new LockedException("登录失败");
+//		}
+		if("EDUCATION".equals(clientId)){
+			clientId = "SYSTEM";
+		}
+		if (!userInfo.getSysUser().getUserType().contains(clientId)) {
+			throw new LockedException("用户不存在,请联系教务老师");
+		}
+
+		UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(SecurityConstants.USERNAME_PRINCIPAL_PREFIX + username,
+				password);
+
+		// Allow subclasses to set the "details" property
+		setDetails(request, authRequest);
+		
+		Authentication authentication = this.getAuthenticationManager().authenticate(authRequest);
+		
+		String deviceNum = request.getParameter(deviceNumParameter);
+		if (StringUtils.isNotBlank(deviceNum)) {
+			// 检查设备
+			sysUserDeviceService.bindDevice(clientId, userInfo.getSysUser().getId(), deviceNum);
+		}
+
+		return authentication;
+	}
+
+	@Override
+	protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain, Authentication authResult)
+			throws IOException, ServletException {
+		super.successfulAuthentication(request, response, chain, authResult);
+		// chain.doFilter(request, response);
+	}
+
+	/**
+	 * Enables subclasses to override the composition of the password, such as by
+	 * including additional values and a separator.
+	 * <p>
+	 * This might be used for example if a postcode/zipcode was required in addition to
+	 * the password. A delimiter such as a pipe (|) should be used to separate the
+	 * password and extended value(s). The <code>AuthenticationDao</code> will need to
+	 * generate the expected password in a corresponding manner.
+	 * </p>
+	 *
+	 * @param request so that request attributes can be retrieved
+	 *
+	 * @return the password that will be presented in the <code>Authentication</code>
+	 * request token to the <code>AuthenticationManager</code>
+	 */
+	protected String obtainPassword(HttpServletRequest request) {
+		return request.getParameter(passwordParameter);
+	}
+
+	/**
+	 * Enables subclasses to override the composition of the username, such as by
+	 * including additional values and a separator.
+	 *
+	 * @param request so that request attributes can be retrieved
+	 *
+	 * @return the username that will be presented in the <code>Authentication</code>
+	 * request token to the <code>AuthenticationManager</code>
+	 */
+	protected String obtainUsername(HttpServletRequest request) {
+		return request.getParameter(usernameParameter);
+	}
+
+	/**
+	 * Provided so that subclasses may configure what is put into the authentication
+	 * request's details property.
+	 *
+	 * @param request that an authentication request is being created for
+	 * @param authRequest the authentication request object that should have its details
+	 * set
+	 */
+	protected void setDetails(HttpServletRequest request, UsernamePasswordAuthenticationToken authRequest) {
+		authRequest.setDetails(authenticationDetailsSource.buildDetails(request));
+	}
+
+	/**
+	 * Sets the parameter name which will be used to obtain the username from the login
+	 * request.
+	 *
+	 * @param usernameParameter the parameter name. Defaults to "username".
+	 */
+	public void setUsernameParameter(String usernameParameter) {
+		Assert.hasText(usernameParameter, "Username parameter must not be empty or null");
+		this.usernameParameter = usernameParameter;
+	}
+
+	/**
+	 * Sets the parameter name which will be used to obtain the password from the login
+	 * request..
+	 *
+	 * @param passwordParameter the parameter name. Defaults to "password".
+	 */
+	public void setPasswordParameter(String passwordParameter) {
+		Assert.hasText(passwordParameter, "Password parameter must not be empty or null");
+		this.passwordParameter = passwordParameter;
+	}
+
+	/**
+	 * Defines whether only HTTP POST requests will be allowed by this filter. If set to
+	 * true, and an authentication request is received which is not a POST request, an
+	 * exception will be raised immediately and authentication will not be attempted. The
+	 * <tt>unsuccessfulAuthentication()</tt> method will be called as if handling a failed
+	 * authentication.
+	 * <p>
+	 * Defaults to <tt>true</tt> but may be overridden by subclasses.
+	 */
+	public void setPostOnly(boolean postOnly) {
+		this.postOnly = postOnly;
+	}
+
+	public final String getUsernameParameter() {
+		return usernameParameter;
+	}
+
+	public final String getPasswordParameter() {
+		return passwordParameter;
+	}
+
+	public void setSysUserService(SysUserService sysUserService) {
+		this.sysUserService = sysUserService;
+	}
+
+	public void setSysUserDeviceService(SysUserDeviceService sysUserDeviceService) {
+		this.sysUserDeviceService = sysUserDeviceService;
+	}
+
+}

+ 74 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/core/handler/AuthenticationFailureListener.java

@@ -0,0 +1,74 @@
+package com.yonge.cooleshow.auth.core.handler;
+
+import java.util.Date;
+import java.util.HashMap;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationListener;
+import org.springframework.security.authentication.event.AuthenticationFailureBadCredentialsEvent;
+import org.springframework.security.core.Authentication;
+import org.springframework.stereotype.Component;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.auth.api.entity.SysUserLogin;
+import com.yonge.cooleshow.auth.service.SysUserLoginService;
+import com.yonge.cooleshow.auth.service.SysUserService;
+import com.yonge.cooleshow.common.security.SecurityConstants;
+
+@Component
+public class AuthenticationFailureListener implements ApplicationListener<AuthenticationFailureBadCredentialsEvent> {
+    private final static Logger logger = LoggerFactory.getLogger(AuthenticationFailureListener.class);
+
+    @Autowired
+    private SysUserLoginService sysUserLoginService;
+    @Autowired
+    private SysUserService sysUserService;
+    @Autowired
+    private ObjectMapper objectMapper;
+
+    @Override
+    public void onApplicationEvent(AuthenticationFailureBadCredentialsEvent authenticationFailureBadCredentialsEvent) {
+        Authentication authentication = authenticationFailureBadCredentialsEvent.getAuthentication();
+        HashMap<String,String> hashMap = objectMapper.convertValue(authentication.getDetails(), HashMap.class);
+        String username = authentication.getPrincipal().toString();
+        Date date = new Date();
+        SysUser sysUser = null;
+        if(username.split(":").length > 1){
+        	if(username.startsWith(SecurityConstants.USERNAME_PRINCIPAL_PREFIX)){
+                sysUser = sysUserService.queryByUsername(username.split(":")[1]);
+            }else {
+                sysUser = sysUserService.queryLockByPhone(username.split(":")[1]);
+            }
+        }
+        if(sysUser != null){
+            SysUserLogin userLogin = sysUserLoginService.findLoginByUserId(sysUser.getId());
+            if(userLogin == null){
+                userLogin = new SysUserLogin();
+                userLogin.setUserId(sysUser.getId());
+                userLogin.setFailCount(0);
+                userLogin.setLoginCount(1);
+                userLogin.setLastLoginTime(date);
+                userLogin.setLastLoginIp(hashMap.get("remoteAddress"));
+                sysUserLoginService.insert(userLogin);
+            }else {
+//                userLogin.setFailCount(userLogin.getFailCount() + 1);
+                userLogin.setLastLoginTime(date);
+                userLogin.setLastLoginIp(hashMap.get("remoteAddress"));
+                /*if(userLogin.getFailCount() >= 5){
+                    userLogin.setLockTime(30);
+                    userLogin.setLockDate(date);
+                    sysUser.setLockFlag(9);
+                    sysUser.setUpdateTime(date);
+                    sysUserService.update(sysUser);
+                }*/
+                sysUserLoginService.update(userLogin);
+            }
+            logger.info("用户:{} 登录失败", sysUser.getPhone());
+        }else {
+            logger.info("用户:{} 不存在", username);
+        }
+    }
+}

+ 46 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/core/handler/BaseAuthenticationFailureEvenHandler.java

@@ -0,0 +1,46 @@
+package com.yonge.cooleshow.auth.core.handler;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.http.HttpStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.AuthenticationException;
+import org.springframework.security.web.authentication.ExceptionMappingAuthenticationFailureHandler;
+import org.springframework.stereotype.Component;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
+
+@Component
+public class BaseAuthenticationFailureEvenHandler extends ExceptionMappingAuthenticationFailureHandler {
+
+    private final static Logger logger = LoggerFactory.getLogger(BaseAuthenticationFailureEvenHandler.class);
+
+    @Autowired
+    private ObjectMapper objectMapper;
+
+    @Override
+    public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException {
+    	
+    	int resultCode = HttpStatus.SC_CONFLICT;
+    	
+        String message = exception.getLocalizedMessage();
+        if (message.equals("Bad credentials")) {
+            message = "用户名或密码错误";
+        }else if(message.equals("User is disabled")){
+            message = "账户被锁定";
+        }else if(message.equals("404.9")){
+        	message = "用户名或密码错误";
+        	resultCode = 99;
+        }
+        logger.info("登录失败,异常:{}", message);
+        HttpResponseResult result = new HttpResponseResult(false, resultCode, null, message);
+        response.setContentType("application/json; charset=utf-8");
+        response.getWriter().write(objectMapper.writeValueAsString(result));
+    }
+}

+ 141 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/core/handler/BaseAuthenticationSuccessEventHandler.java

@@ -0,0 +1,141 @@
+package com.yonge.cooleshow.auth.core.handler;
+
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.security.authentication.BadCredentialsException;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.oauth2.common.OAuth2AccessToken;
+import org.springframework.security.oauth2.common.exceptions.UnapprovedClientAuthenticationException;
+import org.springframework.security.oauth2.provider.ClientDetails;
+import org.springframework.security.oauth2.provider.ClientDetailsService;
+import org.springframework.security.oauth2.provider.OAuth2Authentication;
+import org.springframework.security.oauth2.provider.OAuth2Request;
+import org.springframework.security.oauth2.provider.TokenRequest;
+import org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices;
+import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
+import org.springframework.stereotype.Component;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.auth.api.entity.SysUserLogin;
+import com.yonge.cooleshow.auth.api.entity.SysUserLoginLog;
+import com.yonge.cooleshow.auth.service.SysUserLoginLogService;
+import com.yonge.cooleshow.auth.service.SysUserLoginService;
+import com.yonge.cooleshow.auth.service.SysUserService;
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import com.yonge.cooleshow.common.security.SecurityConstants;
+
+@Component
+public class BaseAuthenticationSuccessEventHandler extends SavedRequestAwareAuthenticationSuccessHandler {
+
+	@Autowired
+	private SysUserLoginService sysUserLoginService;
+	@Autowired
+	private SysUserLoginLogService sysUserLoginLogService;
+	@Autowired
+	private SysUserService sysUserService;
+	@Autowired
+	private ObjectMapper objectMapper;
+	
+	@Autowired
+	private ClientDetailsService clientDetailsService;
+
+	@Autowired
+	private AuthorizationServerTokenServices defaultAuthorizationServerTokenServices;
+
+	private final static Logger logger = LoggerFactory.getLogger(BaseAuthenticationSuccessEventHandler.class);
+
+	@Override
+	public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication){
+		logger.info("用户:{} 登录成功", authentication.getPrincipal());
+		HashMap<String,String> hashMap = objectMapper.convertValue(authentication.getPrincipal(), HashMap.class);
+		String username = hashMap.get("username");
+		SysUser sysUser;
+		if(username.startsWith(SecurityConstants.USERNAME_PRINCIPAL_PREFIX)){
+			sysUser = sysUserService.queryByUsername(username.split(":")[1]);
+		}else {
+			sysUser = sysUserService.queryLockByPhone(username.split(":")[1]);
+		}
+		if(StringUtils.isEmpty(sysUser.getImToken())){
+			String name = sysUser.getRealName();
+			if(StringUtils.isEmpty(name)){
+				name = sysUser.getUsername();
+			}
+			/*ImResult register = imFeignService.register(new ImUserModel(sysUser.getId().toString(), name, sysUser.getAvatar()));
+			sysUser.setImToken(register.getToken());
+			sysUser.setUpdateTime(new Date());
+			sysUserService.update(sysUser);*/
+		}
+		Date date = new Date();
+		//修改添加登录信息
+		SysUserLogin userLogin = sysUserLoginService.findLoginByUserId(sysUser.getId());
+		if(userLogin == null){
+			userLogin = new SysUserLogin();
+			userLogin.setLastLoginIp(request.getRemoteAddr());
+			userLogin.setUserId(sysUser.getId());
+			userLogin.setLoginCount(1);
+			sysUserLoginService.insert(setUserLogin(userLogin,date));
+		}else {
+			userLogin.setLastLoginIp(request.getRemoteAddr());
+			userLogin.setLoginCount(userLogin.getLoginCount() + 1);
+			sysUserLoginService.update(setUserLogin(userLogin,date));
+		}
+		//添加登录日志
+		SysUserLoginLog sysUserLoginLog = new SysUserLoginLog();
+		sysUserLoginLog.setLoginTime(date);
+		sysUserLoginLog.setLoginIp(request.getRemoteAddr());
+		sysUserLoginLog.setUserId(sysUser.getId());
+		sysUserLoginLogService.insert(sysUserLoginLog);
+		
+		try {
+			String clientId = request.getParameter("clientId");
+			String clientSecret = request.getParameter("clientSecret");
+			if (clientId == null || clientSecret == null) {
+				throw new UnapprovedClientAuthenticationException("请求头中client信息为空");
+			}
+			String base64ClientCredentials = Base64.getEncoder().encodeToString((clientId + ":" + clientSecret).getBytes());
+			HttpHeaders headers = new HttpHeaders();
+			headers.add("Authorization", "Basic " + base64ClientCredentials);
+			headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
+
+			ClientDetails clientDetails = clientDetailsService.loadClientByClientId(clientId);
+			TokenRequest tokenRequest = new TokenRequest(MapUtils.EMPTY_MAP, clientId, clientDetails.getScope(), "password");
+			OAuth2Request oAuth2Request = tokenRequest.createOAuth2Request(clientDetails);
+
+			OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(oAuth2Request, authentication);
+			OAuth2AccessToken oAuth2AccessToken = defaultAuthorizationServerTokenServices.createAccessToken(oAuth2Authentication);
+			logger.info("获取token 成功:{}", oAuth2AccessToken.getValue());
+			Map<String,Object> map = new HashMap<>(3);
+			map.put("password", StringUtils.isEmpty(sysUser.getPassword())?false:true);
+			map.put("authentication",oAuth2AccessToken);
+			
+			response.setContentType("application/json; charset=utf-8");
+			HttpResponseResult result = new HttpResponseResult(true, HttpStatus.OK.value(), map, "");
+			response.getWriter().write(objectMapper.writeValueAsString(result));
+		} catch (IOException e) {
+			throw new BadCredentialsException("Failed to decode basic authentication token");
+		}
+	}
+
+	private SysUserLogin setUserLogin(SysUserLogin userLogin,Date date){
+		userLogin.setFailCount(0);
+		userLogin.setLastLoginTime(date);
+		return userLogin;
+	}
+
+}

+ 167 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/core/provider/AbstractAuthenticationProvider.java

@@ -0,0 +1,167 @@
+package com.yonge.cooleshow.auth.core.provider;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.context.MessageSource;
+import org.springframework.context.MessageSourceAware;
+import org.springframework.context.support.MessageSourceAccessor;
+import org.springframework.security.authentication.AccountExpiredException;
+import org.springframework.security.authentication.AuthenticationProvider;
+import org.springframework.security.authentication.BadCredentialsException;
+import org.springframework.security.authentication.CredentialsExpiredException;
+import org.springframework.security.authentication.DisabledException;
+import org.springframework.security.authentication.LockedException;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.AuthenticationException;
+import org.springframework.security.core.SpringSecurityMessageSource;
+import org.springframework.security.core.userdetails.UserCache;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsChecker;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
+import org.springframework.security.core.userdetails.cache.NullUserCache;
+import org.springframework.util.Assert;
+
+public abstract class AbstractAuthenticationProvider implements AuthenticationProvider, InitializingBean, MessageSourceAware {
+
+	protected final Log logger = LogFactory.getLog(this.getClass());
+	protected MessageSourceAccessor messages = SpringSecurityMessageSource.getAccessor();
+	private UserCache userCache = new NullUserCache();
+	private boolean forcePrincipalAsString = false;
+	protected boolean hideUserNotFoundExceptions = true;
+	private UserDetailsChecker preAuthenticationChecks = new AbstractAuthenticationProvider.DefaultPreAuthenticationChecks();
+	private UserDetailsChecker postAuthenticationChecks = new AbstractAuthenticationProvider.DefaultPostAuthenticationChecks();
+
+	protected abstract void additionalAuthenticationChecks(UserDetails var1, Authentication var2) throws AuthenticationException;
+
+	public final void afterPropertiesSet() throws Exception {
+		Assert.notNull(this.userCache, "A user cache must be set");
+		Assert.notNull(this.messages, "A message source must be set");
+		this.doAfterPropertiesSet();
+	}
+
+	public Authentication authenticate(Authentication authentication) throws AuthenticationException {
+		String username = authentication.getPrincipal() == null ? "NONE_PROVIDED" : authentication.getName();
+		boolean cacheWasUsed = true;
+		UserDetails user = this.userCache.getUserFromCache(username);
+		if (user == null) {
+			cacheWasUsed = false;
+
+			try {
+				user = this.retrieveUser(username, authentication);
+			} catch (UsernameNotFoundException var6) {
+				this.logger.debug("User \'" + username + "\' not found");
+				if (this.hideUserNotFoundExceptions) {
+					throw new BadCredentialsException(this.messages.getMessage("MyAbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"));
+				}
+
+				throw var6;
+			}
+
+			Assert.notNull(user, "retrieveUser returned null - a violation of the interface contract");
+		}
+
+		try {
+			this.preAuthenticationChecks.check(user);
+			this.additionalAuthenticationChecks(user, authentication);
+		} catch (AuthenticationException var7) {
+			if (!cacheWasUsed) {
+				throw var7;
+			}
+
+			cacheWasUsed = false;
+			user = this.retrieveUser(username, authentication);
+			this.preAuthenticationChecks.check(user);
+			this.additionalAuthenticationChecks(user, authentication);
+		}
+
+		this.postAuthenticationChecks.check(user);
+		if (!cacheWasUsed) {
+			this.userCache.putUserInCache(user);
+		}
+
+		Object principalToReturn = user;
+		if (this.forcePrincipalAsString) {
+			principalToReturn = user.getUsername();
+		}
+
+		return this.createSuccessAuthentication(principalToReturn, authentication, user);
+	}
+
+	protected abstract Authentication createSuccessAuthentication(Object principal, Authentication authentication, UserDetails user);
+
+	protected void doAfterPropertiesSet() throws Exception {
+	}
+
+	public UserCache getUserCache() {
+		return this.userCache;
+	}
+
+	public boolean isForcePrincipalAsString() {
+		return this.forcePrincipalAsString;
+	}
+
+	public boolean isHideUserNotFoundExceptions() {
+		return this.hideUserNotFoundExceptions;
+	}
+
+	protected abstract UserDetails retrieveUser(String var1, Authentication var2) throws AuthenticationException;
+
+	public void setForcePrincipalAsString(boolean forcePrincipalAsString) {
+		this.forcePrincipalAsString = forcePrincipalAsString;
+	}
+
+	public void setHideUserNotFoundExceptions(boolean hideUserNotFoundExceptions) {
+		this.hideUserNotFoundExceptions = hideUserNotFoundExceptions;
+	}
+
+	public void setMessageSource(MessageSource messageSource) {
+		this.messages = new MessageSourceAccessor(messageSource);
+	}
+
+	public void setUserCache(UserCache userCache) {
+		this.userCache = userCache;
+	}
+
+	protected UserDetailsChecker getPreAuthenticationChecks() {
+		return this.preAuthenticationChecks;
+	}
+
+	public void setPreAuthenticationChecks(UserDetailsChecker preAuthenticationChecks) {
+		this.preAuthenticationChecks = preAuthenticationChecks;
+	}
+
+	protected UserDetailsChecker getPostAuthenticationChecks() {
+		return this.postAuthenticationChecks;
+	}
+
+	public void setPostAuthenticationChecks(UserDetailsChecker postAuthenticationChecks) {
+		this.postAuthenticationChecks = postAuthenticationChecks;
+	}
+
+	private class DefaultPostAuthenticationChecks implements UserDetailsChecker {
+		private DefaultPostAuthenticationChecks() {
+		}
+
+		public void check(UserDetails user) {
+			if (!user.isCredentialsNonExpired()) {
+				throw new CredentialsExpiredException("User account credentials have expired");
+			}
+		}
+	}
+
+	private class DefaultPreAuthenticationChecks implements UserDetailsChecker {
+		private DefaultPreAuthenticationChecks() {
+		}
+
+		public void check(UserDetails user) {
+			if (!user.isAccountNonLocked()) {
+				throw new LockedException("User account is locked");
+			} else if (!user.isEnabled()) {
+				throw new DisabledException("User account is disabled");
+			} else if (!user.isAccountNonExpired()) {
+				throw new AccountExpiredException("User account is expired");
+			}
+		}
+	}
+}

+ 151 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/core/provider/PhoneAuthenticationProvider.java

@@ -0,0 +1,151 @@
+package com.yonge.cooleshow.auth.core.provider;
+
+import java.util.Date;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.security.authentication.BadCredentialsException;
+import org.springframework.security.authentication.InternalAuthenticationServiceException;
+import org.springframework.security.authentication.LockedException;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.AuthenticationException;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.yonge.cooleshow.auth.api.dto.SysUserInfo;
+import com.yonge.cooleshow.auth.api.entity.LoginEntity;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.auth.config.token.PhoneAuthenticationToken;
+import com.yonge.cooleshow.auth.service.SysUserDeviceService;
+import com.yonge.cooleshow.auth.service.SysUserService;
+import com.yonge.cooleshow.common.service.IdGeneratorService;
+
+public class PhoneAuthenticationProvider extends AbstractAuthenticationProvider {
+
+	private UserDetailsService userDetailsService;
+
+	private IdGeneratorService smsCodeService;
+
+	private SysUserService sysUserService;
+	
+	private SysUserDeviceService sysUserDeviceService;
+	
+	@Override
+	protected void additionalAuthenticationChecks(UserDetails userDetails, Authentication authentication) throws AuthenticationException {
+
+		if (authentication.getCredentials() == null) {
+			throw new BadCredentialsException(this.messages.getMessage("PhoneAuthenticationProvider.badCredentials", "Bad credentials"));
+		}
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	protected UserDetails retrieveUser(String username, Authentication authentication) throws AuthenticationException {
+
+		LoginEntity loginEntity = (LoginEntity) authentication.getCredentials();
+		if (loginEntity == null) {
+			throw new BadCredentialsException("Bad credentials");
+		}
+
+		String smsCode = loginEntity.getSmsCode();
+		
+		String phone = loginEntity.getPhone();
+
+		// 验证码验证
+		boolean b = smsCodeService.verifyValidCode(phone, smsCode);
+		if (!b) {
+			throw new BadCredentialsException("验证码校验失败");
+		}
+
+		String clientId = loginEntity.getClientId();
+
+		Boolean isRegister = loginEntity.getIsRegister();
+		
+		String deviceNum = loginEntity.getDeviceNum();
+
+		SysUserInfo userInfo = sysUserService.queryUserInfoByPhone(phone);
+
+		if (userInfo == null) {
+			if (isRegister == false || StringUtils.equals("SYSTEM", clientId)) {
+				throw new LockedException("用户不存在");
+			}
+			
+			userInfo = sysUserService.initUser(loginEntity.getOrganId(), loginEntity.getPhone(), clientId);
+			
+			if (StringUtils.isNotBlank(deviceNum)) {
+				sysUserDeviceService.bindDevice(clientId, userInfo.getSysUser().getId(), deviceNum);
+			}
+		} else {
+			SysUser user = userInfo.getSysUser();
+			if (user == null) {
+				throw new LockedException("用户不存在");
+			}
+			
+			if (StringUtils.isNotBlank(deviceNum)) {
+				sysUserDeviceService.bindDevice(clientId, user.getId(), deviceNum);
+			}
+			
+			if (!userInfo.getSysUser().getUserType().contains(clientId)) {
+				if (isRegister == false || StringUtils.equals("SYSTEM", clientId)) {
+					throw new LockedException("用户不存在");
+				} else {
+					user.setUserType(user.getUserType() + "," + clientId);
+					user.setUpdateTime(new Date());
+
+					// 添加userType以及附加信息
+					if (StringUtils.equals("STUDENT", clientId)) {
+						user.setOrganId(sysUserService.getLesseeOrganId());
+						sysUserService.saveStudent(user.getId());
+					} else if (StringUtils.equals("TEACHER", clientId)) {
+						sysUserService.saveTeacher(user.getId());
+					}
+					sysUserService.update(user);
+				}
+			}
+		}
+
+		UserDetails loadedUser;
+		try {
+			loadedUser = userDetailsService.loadUserByUsername(username);
+		} catch (UsernameNotFoundException e) {
+			throw e;
+		} catch (Exception e) {
+			throw new InternalAuthenticationServiceException(e.getMessage(), e);
+		}
+
+		if (loadedUser == null) {
+			throw new InternalAuthenticationServiceException("账户不存在");
+		} else {
+			return loadedUser;
+		}
+	}
+
+	@Override
+	protected Authentication createSuccessAuthentication(Object principal, Authentication authentication, UserDetails user) {
+		PhoneAuthenticationToken result = new PhoneAuthenticationToken(principal, authentication.getCredentials(), user.getAuthorities());
+		result.setDetails(authentication.getDetails());
+		return result;
+	}
+
+	@Override
+	public boolean supports(Class<?> aClass) {
+		return PhoneAuthenticationToken.class.isAssignableFrom(aClass);
+	}
+
+	public void setUserDetailsService(UserDetailsService userDetailsService) {
+		this.userDetailsService = userDetailsService;
+	}
+
+	public void setSysUserService(SysUserService sysUserService) {
+		this.sysUserService = sysUserService;
+	}
+
+	public void setSmsCodeService(IdGeneratorService smsCodeService) {
+		this.smsCodeService = smsCodeService;
+	}
+
+	public void setSysUserDeviceService(SysUserDeviceService sysUserDeviceService) {
+		this.sysUserDeviceService = sysUserDeviceService;
+	}
+}

+ 81 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/core/provider/service/DefaultUserDetailsService.java

@@ -0,0 +1,81 @@
+package com.yonge.cooleshow.auth.core.provider.service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.authentication.LockedException;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.authority.AuthorityUtils;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+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.Service;
+
+import com.yonge.cooleshow.auth.api.dto.SysUserInfo;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.auth.service.SysUserService;
+import com.yonge.cooleshow.common.security.AuthUser;
+import com.yonge.cooleshow.common.security.SecurityConstants;
+
+@Service
+public class DefaultUserDetailsService implements UserDetailsService {
+
+	@Autowired
+	private PasswordEncoder passwordEncoder;
+
+	@Autowired
+	private SysUserService sysUserService;
+
+	private final String BCRYPT = "{bcrypt}";
+
+	@Override
+	public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
+		if (StringUtils.isBlank(username)) {
+			return null;
+		}
+
+		SysUserInfo userInfo = null;
+
+		if (StringUtils.startsWith(username, SecurityConstants.PHONE_PRINCIPAL_PREFIX)) {
+			userInfo = sysUserService.queryUserInfoByPhone(StringUtils.substringAfter(username, SecurityConstants.PHONE_PRINCIPAL_PREFIX));
+		} else if (StringUtils.startsWith(username, SecurityConstants.USERNAME_PRINCIPAL_PREFIX)) {
+			userInfo = sysUserService.queryUserInfoByUsername(StringUtils.substringAfter(username, SecurityConstants.USERNAME_PRINCIPAL_PREFIX));
+		} else {
+			userInfo = sysUserService.queryUserInfoByUsername(username);
+		}
+		if (userInfo == null) {
+			throw new UsernameNotFoundException("账户不存在");
+		} else if (userInfo.getSysUser().getLockFlag() == 9) {
+			throw new LockedException("账户被锁定");
+		}
+
+		List<GrantedAuthority> authorities = null;
+
+		String userType = userInfo.getSysUser().getUserType();
+		String[] roles = userType.split(",");
+
+		if (userType.contains("SYSTEM")) {
+			authorities = AuthorityUtils.createAuthorityList(userInfo.getPermissions());
+		}
+
+		if (authorities == null) {
+			authorities = new ArrayList<>();
+		}
+		
+		authorities.add(new SimpleGrantedAuthority(StringUtils.lowerCase(userType)));
+
+		for (String role : roles) {
+			authorities.add(new SimpleGrantedAuthority(StringUtils.lowerCase(role)));
+		}
+
+		SysUser sysUser = userInfo.getSysUser();
+
+		return new AuthUser(sysUser.getId(), sysUser.getOrganId(), username, BCRYPT + sysUser.getPassword(), sysUser.getLockFlag() == 0, true, true, true,
+				authorities);
+	}
+
+}

+ 35 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/core/service/CustomAuthenticationKeyGenerator.java

@@ -0,0 +1,35 @@
+package com.yonge.cooleshow.auth.core.service;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.TreeSet;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.security.oauth2.common.util.OAuth2Utils;
+import org.springframework.security.oauth2.provider.OAuth2Authentication;
+import org.springframework.security.oauth2.provider.OAuth2Request;
+import org.springframework.security.oauth2.provider.token.DefaultAuthenticationKeyGenerator;
+
+public class CustomAuthenticationKeyGenerator extends DefaultAuthenticationKeyGenerator {
+	
+	private static final String CLIENT_ID = "client_id";
+
+	private static final String SCOPE = "scope";
+
+	private static final String USERNAME = "username";
+
+	@Override
+	public String extractKey(OAuth2Authentication authentication) {
+		Map<String, String> values = new LinkedHashMap<String, String>();
+		OAuth2Request authorizationRequest = authentication.getOAuth2Request();
+		if (!authentication.isClientOnly()) {
+			values.put(USERNAME, StringUtils.substringAfter(authentication.getName(), ":"));
+		}
+		values.put(CLIENT_ID, authorizationRequest.getClientId());
+		if (authorizationRequest.getScope() != null) {
+			values.put(SCOPE, OAuth2Utils.formatParameterList(new TreeSet<String>(authorizationRequest.getScope())));
+		}
+		return generateKey(values);
+	}
+
+}

+ 438 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/core/service/CustomTokenServices.java

@@ -0,0 +1,438 @@
+package com.yonge.cooleshow.auth.core.service;
+
+import java.util.Date;
+import java.util.Set;
+import java.util.UUID;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.AuthenticationException;
+import org.springframework.security.oauth2.common.DefaultExpiringOAuth2RefreshToken;
+import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
+import org.springframework.security.oauth2.common.DefaultOAuth2RefreshToken;
+import org.springframework.security.oauth2.common.ExpiringOAuth2RefreshToken;
+import org.springframework.security.oauth2.common.OAuth2AccessToken;
+import org.springframework.security.oauth2.common.OAuth2RefreshToken;
+import org.springframework.security.oauth2.common.exceptions.InvalidGrantException;
+import org.springframework.security.oauth2.common.exceptions.InvalidScopeException;
+import org.springframework.security.oauth2.common.exceptions.InvalidTokenException;
+import org.springframework.security.oauth2.provider.ClientDetails;
+import org.springframework.security.oauth2.provider.ClientDetailsService;
+import org.springframework.security.oauth2.provider.ClientRegistrationException;
+import org.springframework.security.oauth2.provider.OAuth2Authentication;
+import org.springframework.security.oauth2.provider.OAuth2Request;
+import org.springframework.security.oauth2.provider.TokenRequest;
+import org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices;
+import org.springframework.security.oauth2.provider.token.ConsumerTokenServices;
+import org.springframework.security.oauth2.provider.token.ResourceServerTokenServices;
+import org.springframework.security.oauth2.provider.token.TokenEnhancer;
+import org.springframework.security.oauth2.provider.token.TokenStore;
+import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.Assert;
+
+/**
+ * Base implementation for token services using random UUID values for the access token and refresh token values. The
+ * main extension point for customizations is the {@link TokenEnhancer} which will be called after the access and
+ * refresh tokens have been generated but before they are stored.
+ * <p>
+ * Persistence is delegated to a {@code TokenStore} implementation and customization of the access token to a
+ * {@link TokenEnhancer}.
+ * 
+ * @author Ryan Heaton
+ * @author Luke Taylor
+ * @author Dave Syer
+ */
+public class CustomTokenServices implements AuthorizationServerTokenServices, ResourceServerTokenServices,
+		ConsumerTokenServices, InitializingBean {
+
+	private int refreshTokenValiditySeconds = 60 * 60 * 24 * 30; // default 30 days.
+
+	private int accessTokenValiditySeconds = 60 * 60 * 12; // default 12 hours.
+
+	private boolean supportRefreshToken = false;
+
+	private boolean reuseRefreshToken = true;
+
+	private TokenStore tokenStore;
+
+	private ClientDetailsService clientDetailsService;
+
+	private TokenEnhancer accessTokenEnhancer;
+
+	private AuthenticationManager authenticationManager;
+
+	/**
+	 * Initialize these token services. If no random generator is set, one will be created.
+	 */
+	public void afterPropertiesSet() throws Exception {
+		Assert.notNull(tokenStore, "tokenStore must be set");
+	}
+
+	@Transactional
+	public OAuth2AccessToken createAccessToken(OAuth2Authentication authentication) throws AuthenticationException {
+
+		OAuth2AccessToken existingAccessToken = tokenStore.getAccessToken(authentication);
+		OAuth2RefreshToken refreshToken = null;
+		if (existingAccessToken != null) {
+			if (existingAccessToken.getRefreshToken() != null) {
+				refreshToken = existingAccessToken.getRefreshToken();
+				// The token store could remove the refresh token when the
+				// access token is removed, but we want to
+				// be sure...
+				tokenStore.removeRefreshToken(refreshToken);
+			}
+			tokenStore.removeAccessToken(existingAccessToken);
+		}
+
+		// Only create a new refresh token if there wasn't an existing one
+		// associated with an expired access token.
+		// Clients might be holding existing refresh tokens, so we re-use it in
+		// the case that the old access token
+		// expired.
+		if (refreshToken == null) {
+			refreshToken = createRefreshToken(authentication);
+		}
+		// But the refresh token itself might need to be re-issued if it has
+		// expired.
+		else if (refreshToken instanceof ExpiringOAuth2RefreshToken) {
+			ExpiringOAuth2RefreshToken expiring = (ExpiringOAuth2RefreshToken) refreshToken;
+			if (System.currentTimeMillis() > expiring.getExpiration().getTime()) {
+				refreshToken = createRefreshToken(authentication);
+			}
+		}
+
+		OAuth2AccessToken accessToken = createAccessToken(authentication, refreshToken);
+		tokenStore.storeAccessToken(accessToken, authentication);
+		// In case it was modified
+		refreshToken = accessToken.getRefreshToken();
+		if (refreshToken != null) {
+			tokenStore.storeRefreshToken(refreshToken, authentication);
+		}
+		return accessToken;
+
+	}
+
+	@Transactional(noRollbackFor={InvalidTokenException.class, InvalidGrantException.class})
+	public OAuth2AccessToken refreshAccessToken(String refreshTokenValue, TokenRequest tokenRequest)
+			throws AuthenticationException {
+
+		if (!supportRefreshToken) {
+			throw new InvalidGrantException("Invalid refresh token: " + refreshTokenValue);
+		}
+
+		OAuth2RefreshToken refreshToken = tokenStore.readRefreshToken(refreshTokenValue);
+		if (refreshToken == null) {
+			throw new InvalidGrantException("Invalid refresh token: " + refreshTokenValue);
+		}
+
+		OAuth2Authentication authentication = tokenStore.readAuthenticationForRefreshToken(refreshToken);
+		if (this.authenticationManager != null && !authentication.isClientOnly()) {
+			// The client has already been authenticated, but the user authentication might be old now, so give it a
+			// chance to re-authenticate.
+			Authentication user = new PreAuthenticatedAuthenticationToken(authentication.getUserAuthentication(), "", authentication.getAuthorities());
+			user = authenticationManager.authenticate(user);
+			Object details = authentication.getDetails();
+			authentication = new OAuth2Authentication(authentication.getOAuth2Request(), user);
+			authentication.setDetails(details);
+		}
+		String clientId = authentication.getOAuth2Request().getClientId();
+		if (clientId == null || !clientId.equals(tokenRequest.getClientId())) {
+			throw new InvalidGrantException("Wrong client for this refresh token: " + refreshTokenValue);
+		}
+
+		// clear out any access tokens already associated with the refresh
+		// token.
+		tokenStore.removeAccessTokenUsingRefreshToken(refreshToken);
+
+		if (isExpired(refreshToken)) {
+			tokenStore.removeRefreshToken(refreshToken);
+			throw new InvalidTokenException("Invalid refresh token (expired): " + refreshToken);
+		}
+
+		authentication = createRefreshedAuthentication(authentication, tokenRequest);
+
+		if (!reuseRefreshToken) {
+			tokenStore.removeRefreshToken(refreshToken);
+			refreshToken = createRefreshToken(authentication);
+		}
+
+		OAuth2AccessToken accessToken = createAccessToken(authentication, refreshToken);
+		tokenStore.storeAccessToken(accessToken, authentication);
+		if (!reuseRefreshToken) {
+			tokenStore.storeRefreshToken(accessToken.getRefreshToken(), authentication);
+		}
+		return accessToken;
+	}
+
+	public OAuth2AccessToken getAccessToken(OAuth2Authentication authentication) {
+		return tokenStore.getAccessToken(authentication);
+	}
+
+	/**
+	 * Create a refreshed authentication.
+	 * 
+	 * @param authentication The authentication.
+	 * @param request The scope for the refreshed token.
+	 * @return The refreshed authentication.
+	 * @throws InvalidScopeException If the scope requested is invalid or wider than the original scope.
+	 */
+	private OAuth2Authentication createRefreshedAuthentication(OAuth2Authentication authentication, TokenRequest request) {
+		OAuth2Authentication narrowed = authentication;
+		Set<String> scope = request.getScope();
+		OAuth2Request clientAuth = authentication.getOAuth2Request().refresh(request);
+		if (scope != null && !scope.isEmpty()) {
+			Set<String> originalScope = clientAuth.getScope();
+			if (originalScope == null || !originalScope.containsAll(scope)) {
+				throw new InvalidScopeException("Unable to narrow the scope of the client authentication to " + scope
+						+ ".", originalScope);
+			}
+			else {
+				clientAuth = clientAuth.narrowScope(scope);
+			}
+		}
+		narrowed = new OAuth2Authentication(clientAuth, authentication.getUserAuthentication());
+		return narrowed;
+	}
+
+	protected boolean isExpired(OAuth2RefreshToken refreshToken) {
+		if (refreshToken instanceof ExpiringOAuth2RefreshToken) {
+			ExpiringOAuth2RefreshToken expiringToken = (ExpiringOAuth2RefreshToken) refreshToken;
+			return expiringToken.getExpiration() == null
+					|| System.currentTimeMillis() > expiringToken.getExpiration().getTime();
+		}
+		return false;
+	}
+
+	public OAuth2AccessToken readAccessToken(String accessToken) {
+		OAuth2AccessToken token = tokenStore.readAccessToken(accessToken);
+		if (token == null) {
+			throw new InvalidTokenException("Token was not recognised");
+		}
+
+		if (token.isExpired()) {
+			throw new InvalidTokenException("Token has expired");
+		}
+
+		DefaultOAuth2AccessToken oAuth2AccessToken = (DefaultOAuth2AccessToken) token;
+
+		OAuth2Authentication authentication = tokenStore.readAuthentication(accessToken);
+
+		if (StringUtils.equalsIgnoreCase("system", authentication.getOAuth2Request().getClientId())) {
+			int validitySeconds = getAccessTokenValiditySeconds(authentication.getOAuth2Request());
+			if (validitySeconds > 0) {
+				oAuth2AccessToken.setExpiration(new Date(System.currentTimeMillis() + (validitySeconds * 1000L)));
+				
+				tokenStore.storeAccessToken(oAuth2AccessToken, authentication);
+			}
+		}
+
+		return oAuth2AccessToken;
+	}
+
+	public OAuth2Authentication loadAuthentication(String accessTokenValue) throws AuthenticationException,
+			InvalidTokenException {
+		OAuth2AccessToken accessToken = tokenStore.readAccessToken(accessTokenValue);
+		if (accessToken == null) {
+			throw new InvalidTokenException("Invalid access token: " + accessTokenValue);
+		}
+		else if (accessToken.isExpired()) {
+			tokenStore.removeAccessToken(accessToken);
+			throw new InvalidTokenException("Access token expired: " + accessTokenValue);
+		}
+
+		OAuth2Authentication result = tokenStore.readAuthentication(accessToken);
+		if (result == null) {
+			// in case of race condition
+			throw new InvalidTokenException("Invalid access token: " + accessTokenValue);
+		}
+		if (clientDetailsService != null) {
+			String clientId = result.getOAuth2Request().getClientId();
+			try {
+				clientDetailsService.loadClientByClientId(clientId);
+			}
+			catch (ClientRegistrationException e) {
+				throw new InvalidTokenException("Client not valid: " + clientId, e);
+			}
+		}
+		return result;
+	}
+
+	public String getClientId(String tokenValue) {
+		OAuth2Authentication authentication = tokenStore.readAuthentication(tokenValue);
+		if (authentication == null) {
+			throw new InvalidTokenException("Invalid access token: " + tokenValue);
+		}
+		OAuth2Request clientAuth = authentication.getOAuth2Request();
+		if (clientAuth == null) {
+			throw new InvalidTokenException("Invalid access token (no client id): " + tokenValue);
+		}
+		return clientAuth.getClientId();
+	}
+
+	public boolean revokeToken(String tokenValue) {
+		OAuth2AccessToken accessToken = tokenStore.readAccessToken(tokenValue);
+		if (accessToken == null) {
+			return false;
+		}
+		if (accessToken.getRefreshToken() != null) {
+			tokenStore.removeRefreshToken(accessToken.getRefreshToken());
+		}
+		tokenStore.removeAccessToken(accessToken);
+		return true;
+	}
+
+	private OAuth2RefreshToken createRefreshToken(OAuth2Authentication authentication) {
+		if (!isSupportRefreshToken(authentication.getOAuth2Request())) {
+			return null;
+		}
+		int validitySeconds = getRefreshTokenValiditySeconds(authentication.getOAuth2Request());
+		String value = UUID.randomUUID().toString();
+		if (validitySeconds > 0) {
+			return new DefaultExpiringOAuth2RefreshToken(value, new Date(System.currentTimeMillis()
+					+ (validitySeconds * 1000L)));
+		}
+		return new DefaultOAuth2RefreshToken(value);
+	}
+
+	private OAuth2AccessToken createAccessToken(OAuth2Authentication authentication, OAuth2RefreshToken refreshToken) {
+		DefaultOAuth2AccessToken token = new DefaultOAuth2AccessToken(UUID.randomUUID().toString());
+		int validitySeconds = getAccessTokenValiditySeconds(authentication.getOAuth2Request());
+		if (validitySeconds > 0) {
+			token.setExpiration(new Date(System.currentTimeMillis() + (validitySeconds * 1000L)));
+		}
+		token.setRefreshToken(refreshToken);
+		token.setScope(authentication.getOAuth2Request().getScope());
+
+		return accessTokenEnhancer != null ? accessTokenEnhancer.enhance(token, authentication) : token;
+	}
+
+	/**
+	 * The access token validity period in seconds
+	 * 
+	 * @param clientAuth the current authorization request
+	 * @return the access token validity period in seconds
+	 */
+	protected int getAccessTokenValiditySeconds(OAuth2Request clientAuth) {
+		if (clientDetailsService != null) {
+			ClientDetails client = clientDetailsService.loadClientByClientId(clientAuth.getClientId());
+			Integer validity = client.getAccessTokenValiditySeconds();
+			if (validity != null) {
+				return validity;
+			}
+		}
+		return accessTokenValiditySeconds;
+	}
+
+	/**
+	 * The refresh token validity period in seconds
+	 * 
+	 * @param clientAuth the current authorization request
+	 * @return the refresh token validity period in seconds
+	 */
+	protected int getRefreshTokenValiditySeconds(OAuth2Request clientAuth) {
+		if (clientDetailsService != null) {
+			ClientDetails client = clientDetailsService.loadClientByClientId(clientAuth.getClientId());
+			Integer validity = client.getRefreshTokenValiditySeconds();
+			if (validity != null) {
+				return validity;
+			}
+		}
+		return refreshTokenValiditySeconds;
+	}
+
+	/**
+	 * Is a refresh token supported for this client (or the global setting if
+	 * {@link #setClientDetailsService(ClientDetailsService) clientDetailsService} is not set.
+	 * 
+	 * @param clientAuth the current authorization request
+	 * @return boolean to indicate if refresh token is supported
+	 */
+	protected boolean isSupportRefreshToken(OAuth2Request clientAuth) {
+		if (clientDetailsService != null) {
+			ClientDetails client = clientDetailsService.loadClientByClientId(clientAuth.getClientId());
+			return client.getAuthorizedGrantTypes().contains("refresh_token");
+		}
+		return this.supportRefreshToken;
+	}
+
+	/**
+	 * An access token enhancer that will be applied to a new token before it is saved in the token store.
+	 * 
+	 * @param accessTokenEnhancer the access token enhancer to set
+	 */
+	public void setTokenEnhancer(TokenEnhancer accessTokenEnhancer) {
+		this.accessTokenEnhancer = accessTokenEnhancer;
+	}
+
+	/**
+	 * The validity (in seconds) of the refresh token. If less than or equal to zero then the tokens will be
+	 * non-expiring.
+	 * 
+	 * @param refreshTokenValiditySeconds The validity (in seconds) of the refresh token.
+	 */
+	public void setRefreshTokenValiditySeconds(int refreshTokenValiditySeconds) {
+		this.refreshTokenValiditySeconds = refreshTokenValiditySeconds;
+	}
+
+	/**
+	 * The default validity (in seconds) of the access token. Zero or negative for non-expiring tokens. If a client
+	 * details service is set the validity period will be read from the client, defaulting to this value if not defined
+	 * by the client.
+	 * 
+	 * @param accessTokenValiditySeconds The validity (in seconds) of the access token.
+	 */
+	public void setAccessTokenValiditySeconds(int accessTokenValiditySeconds) {
+		this.accessTokenValiditySeconds = accessTokenValiditySeconds;
+	}
+
+	/**
+	 * Whether to support the refresh token.
+	 * 
+	 * @param supportRefreshToken Whether to support the refresh token.
+	 */
+	public void setSupportRefreshToken(boolean supportRefreshToken) {
+		this.supportRefreshToken = supportRefreshToken;
+	}
+
+	/**
+	 * Whether to reuse refresh tokens (until expired).
+	 * 
+	 * @param reuseRefreshToken Whether to reuse refresh tokens (until expired).
+	 */
+	public void setReuseRefreshToken(boolean reuseRefreshToken) {
+		this.reuseRefreshToken = reuseRefreshToken;
+	}
+
+	/**
+	 * The persistence strategy for token storage.
+	 * 
+	 * @param tokenStore the store for access and refresh tokens.
+	 */
+	public void setTokenStore(TokenStore tokenStore) {
+		this.tokenStore = tokenStore;
+	}
+
+	/**
+	 * An authentication manager that will be used (if provided) to check the user authentication when a token is
+	 * refreshed.
+	 * 
+	 * @param authenticationManager the authenticationManager to set
+	 */
+	public void setAuthenticationManager(AuthenticationManager authenticationManager) {
+		this.authenticationManager = authenticationManager;
+	}
+
+	/**
+	 * The client details service to use for looking up clients (if necessary). Optional if the access token expiry is
+	 * set globally via {@link #setAccessTokenValiditySeconds(int)}.
+	 * 
+	 * @param clientDetailsService the client details service
+	 */
+	public void setClientDetailsService(ClientDetailsService clientDetailsService) {
+		this.clientDetailsService = clientDetailsService;
+	}
+
+}

+ 55 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/dal/dao/SysMenuDao.java

@@ -0,0 +1,55 @@
+package com.yonge.cooleshow.auth.dal.dao;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
+
+import com.yonge.cooleshow.auth.api.entity.SysMenu;
+import com.yonge.cooleshow.common.dal.BaseDAO;
+
+public interface SysMenuDao extends BaseDAO<Integer, SysMenu> {
+
+
+    /**
+     * 根据角色编号查询拥有的菜单列表
+     * @param roleId
+     * @return
+     */
+    List<SysMenu> getMenusByRoleId(Integer roleId);
+
+    /**
+     * 根据用户编号查询用户可访问菜单
+     * @param userId
+     * @return
+     */
+    List<SysMenu> findByUser(Integer userId);
+
+    /**
+     * 根据权限标识查菜单
+     * @return
+     */
+    SysMenu findMenuByPermission(@Param("permission") String permission);
+
+    /**
+     * 获取用户菜单树状结构
+     * @param menuId
+     * @param delFlag
+     * @param userId
+     * @return
+     */
+    List<SysMenu> findByParentId(@Param("parentId") Integer menuId,@Param("delFlag") String delFlag,@Param("userId") Integer userId,@Param("hid") Integer hid);
+
+    /**
+     * 获取所有菜单列表
+     * @param menuId
+     * @param delFlag
+     * @return
+     */
+    List<SysMenu> findList(@Param("parentId") Integer menuId,@Param("delFlag") String delFlag,@Param("hid") Integer hid);
+
+    /**
+     * 批量删除菜单列表
+     * @param collect
+     */
+    void batchDel(List<Integer> collect);
+}

+ 9 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/dal/dao/SysOauthClientDetailsDao.java

@@ -0,0 +1,9 @@
+package com.yonge.cooleshow.auth.dal.dao;
+
+import com.yonge.cooleshow.auth.api.entity.SysOauthClientDetails;
+import com.yonge.cooleshow.common.dal.BaseDAO;
+
+public interface SysOauthClientDetailsDao extends BaseDAO<String, SysOauthClientDetails> {
+
+	
+}

+ 32 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/dal/dao/SysRoleDao.java

@@ -0,0 +1,32 @@
+package com.yonge.cooleshow.auth.dal.dao;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
+
+import com.yonge.cooleshow.auth.api.entity.SysRole;
+import com.yonge.cooleshow.common.dal.BaseDAO;
+
+public interface SysRoleDao extends BaseDAO<Integer, SysRole> {
+
+    /**
+     * 根据userId查询角色列表
+     * @param userId 用户编号
+     * @return
+     */
+    List<SysRole> findRoleByUserId(Integer userId);
+
+    /**
+     * 根据role_code 查询角色
+     * @param code
+     * @return
+     */
+    SysRole findRoleByCode(@Param("code") String code);
+
+    /**
+     * 根据角色名称获取角色
+     * @param roleName
+     * @return
+     */
+    SysRole findByRoleName(String roleName);
+}

+ 45 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/dal/dao/SysRoleMenuDao.java

@@ -0,0 +1,45 @@
+package com.yonge.cooleshow.auth.dal.dao;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
+
+import com.yonge.cooleshow.auth.api.entity.SysRoleMenu;
+import com.yonge.cooleshow.common.dal.BaseDAO;
+
+public interface SysRoleMenuDao extends BaseDAO<Integer, SysRoleMenu> {
+
+	/**
+	 * 根据角色查询权限列表
+	 * @param roleId
+	 * @return
+	 */
+	List<String> queryPermissionsByRoleId(Integer roleId);
+
+	/**
+	 * 根据角色查询权限列表
+	 * @param roleId
+	 * @return
+	 */
+	List<Integer> queryMenuIdByRoleId(Integer roleId);
+
+	/**
+	 * 删除角色菜单权限
+	 * @param sysRoleMenu
+	 * @return
+	 */
+	int delete(SysRoleMenu sysRoleMenu);
+
+	/**
+	 * 删除角色所有的菜单权限
+	 * @param id
+	 */
+	void deleteAllMenu(Integer id);
+
+	/**
+	 * 批量插入角色菜单
+	 * @param roleId
+	 * @param menuIds
+	 */
+    void batchAdd(@Param("roleId") Integer roleId,@Param("menuIds")  List<Integer> menuIds);
+}

+ 102 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/dal/dao/SysUserDao.java

@@ -0,0 +1,102 @@
+package com.yonge.cooleshow.auth.dal.dao;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
+
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.auth.api.enums.UserLockFlag;
+import com.yonge.cooleshow.common.dal.BaseDAO;
+import com.yonge.cooleshow.common.entity.ImUserModel;
+
+public interface SysUserDao extends BaseDAO<Integer, SysUser> {
+
+	/**
+	 * 根据用户名查询对象
+	 * @param username
+	 * @return
+	 */
+	SysUser queryByUsername(String username);
+
+	/**
+	 * 根据手机号查询对象
+	 * @param phone
+	 * @return
+	 */
+	SysUser queryByPhone(String phone);
+
+	/**
+	 * 根据手机号查询对象
+	 * @param phone
+	 * @return
+	 */
+	SysUser queryLockByPhone(String phone);
+
+	/**
+	 * 根据手机号查询对象
+	 * @param phone
+	 * @return
+	 */
+	SysUser queryByPhoneAndClient(@Param("phone") String phone, @Param("client") String client);
+
+	/**
+	 * 修改密码
+	 * @param mobile
+	 * @param password
+	 */
+	void updatePassword(@Param("mobile") String mobile, @Param("password") String password);
+
+	/**
+	 * 获取用户基本信息
+	 * @param userId
+	 * @return
+	 */
+	ImUserModel getBasic(Integer userId);
+
+	/**
+	 * 根据状态查询
+	 * @param status
+	 * @return
+	 */
+	List<SysUser> queryByStatus(UserLockFlag status);
+
+	/**
+	 * 获取随机盐不为null的一条数据
+	 * @param userType
+	 * @return
+	 */
+	SysUser findUserBySalt(String userType);
+
+	/**
+	 * 创建teacher表
+	 * @param userId
+	 * @param lesseeOrganId
+	 */
+	void insertTeacher(@Param("userId") Integer userId, @Param("lesseeOrganId") Integer lesseeOrganId);
+
+	/**
+	 * 获取教师分部编号
+	 * @param userId
+	 * @return
+	 */
+	Integer getTeacherOrganId(Integer userId);
+
+	/**
+	 * 创建租户账户表
+	 * @param userId
+	 */
+    void insertSysTenantAccount(Integer userId);
+
+	/**
+	 * 刷新用户token
+	 * @param userId
+	 * @param imToken
+	 */
+	void refreshImToken(@Param("userId") Integer userId, @Param("imToken") String imToken);
+
+	/**
+	 * 保存student
+	 * @param userId
+	 */
+    void saveStudent(@Param("userId") Integer userId);
+}

+ 15 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/dal/dao/SysUserDeviceDao.java

@@ -0,0 +1,15 @@
+package com.yonge.cooleshow.auth.dal.dao;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
+
+import com.yonge.cooleshow.auth.api.entity.SysUserDevice;
+import com.yonge.cooleshow.common.dal.BaseDAO;
+
+public interface SysUserDeviceDao extends BaseDAO<Integer, SysUserDevice> {
+
+	List<SysUserDevice> queryByUserId(@Param("clientId") String clientId, @Param("userId") Integer userId);
+
+	List<SysUserDevice> queryByDeviceNum(@Param("clientId") String clientId, @Param("deviceNum") String deviceNum);
+}

+ 14 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/dal/dao/SysUserLoginDao.java

@@ -0,0 +1,14 @@
+package com.yonge.cooleshow.auth.dal.dao;
+
+import com.yonge.cooleshow.auth.api.entity.SysUserLogin;
+import com.yonge.cooleshow.common.dal.BaseDAO;
+
+public interface SysUserLoginDao extends BaseDAO<Integer, SysUserLogin> {
+
+    /**
+     * 根据用户查询登录信息
+     * @param userId
+     * @return
+     */
+    SysUserLogin findLoginByUserId(Integer userId);
+}

+ 8 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/dal/dao/SysUserLoginLogDao.java

@@ -0,0 +1,8 @@
+package com.yonge.cooleshow.auth.dal.dao;
+
+import com.yonge.cooleshow.auth.api.entity.SysUserLoginLog;
+import com.yonge.cooleshow.common.dal.BaseDAO;
+
+public interface SysUserLoginLogDao extends BaseDAO<Long, SysUserLoginLog> {
+	
+}

+ 31 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/dal/dao/SysUserRoleDao.java

@@ -0,0 +1,31 @@
+package com.yonge.cooleshow.auth.dal.dao;
+
+import java.util.List;
+
+import com.yonge.cooleshow.auth.api.entity.SysUserRole;
+import com.yonge.cooleshow.common.dal.BaseDAO;
+
+public interface SysUserRoleDao extends BaseDAO<Integer, SysUserRole> {
+
+	/**
+	 * 查询指定用户具有的角色编号
+	 * @param userId 用户编号
+	 * @return
+	 */
+	List<Integer> queryRoleIdListByUserId(Integer userId);
+	
+	/**
+	 * 查询指定用户的角色编码
+	 * @param userId
+	 * @return
+	 */
+	List<String> queryRoleCodeListByUserId(Integer userId);
+
+
+	/**
+	 * 删除用户角色
+	 * @param sysUserRole
+	 * @return
+	 */
+	int delete(SysUserRole sysUserRole);
+}

+ 39 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/dal/enums/UserGenderEnum.java

@@ -0,0 +1,39 @@
+package com.yonge.cooleshow.auth.dal.enums;
+
+import com.yonge.cooleshow.common.enums.BaseEnum;
+
+/** 
+ * 会员性别枚举
+ */
+public enum UserGenderEnum implements BaseEnum<Integer, UserGenderEnum> {
+
+	WOMAN(0, "女"), MAN(1, "男");
+
+	private int code;
+
+	private String description;
+
+	private UserGenderEnum(int code, String description) {
+		this.code = code;
+		this.description = description;
+	}
+
+	public static UserGenderEnum get(int code) {
+		for (UserGenderEnum info : UserGenderEnum.values()) {
+			if (info.getCode() == code) {
+				return info;
+			}
+		}
+		return null;
+	}
+
+	public String getDescription() {
+		return description;
+	}
+
+	@Override
+	public Integer getCode() {
+		return code;
+	}
+
+}

+ 45 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/dal/enums/UserStatus.java

@@ -0,0 +1,45 @@
+package com.yonge.cooleshow.auth.dal.enums;
+
+import com.yonge.cooleshow.common.enums.BaseEnum;
+
+/** 
+ * 会员状态枚举类
+ */
+public enum UserStatus implements BaseEnum<Integer, UserStatus> {
+
+	NOACTIVATED(0, "未激活"), CANCELLED(-1, "注销"), NORMAL(1, "正常"), LOCKED(2, "锁定");
+
+	private int code;
+
+	private UserStatus(int code, String remark) {
+		this.code = code;
+		this.remark = remark;
+	}
+
+	private String remark;
+
+	public Integer getCode() {
+		return code;
+	}
+
+	public void setCode(int code) {
+		this.code = code;
+	}
+
+	public String getRemark() {
+		return remark;
+	}
+
+	public void setRemark(String remark) {
+		this.remark = remark;
+	}
+
+	public static UserStatus codeOf(int code) {
+		for (UserStatus userStatus : UserStatus.values()) {
+			if (code == userStatus.getCode()) {
+				return userStatus;
+			}
+		}
+		return null;
+	}
+}

+ 37 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/interceptor/OperationLogInterceptor.java

@@ -0,0 +1,37 @@
+package com.yonge.cooleshow.auth.interceptor;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.auth.service.SysUserService;
+import com.yonge.cooleshow.common.security.AuthUser;
+import com.yonge.cooleshow.common.security.SecurityUtils;
+import com.yonge.toolset.log.interceptor.AuditLogInterceptor;
+
+@Component
+public class OperationLogInterceptor extends AuditLogInterceptor {
+
+	@Autowired
+	private SysUserService sysUserService;
+
+	@Override
+	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws ServletException, IOException {
+		AuthUser authUser = SecurityUtils.getUser();
+		if (authUser != null) {
+			SysUser sysUser = sysUserService.get(authUser.getUserId());
+
+			if (sysUser != null) {
+				setUsername(sysUser.getRealName(), sysUser.getId());
+			}
+		}
+		return true;
+	}
+
+}

+ 37 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/SysMenuService.java

@@ -0,0 +1,37 @@
+package com.yonge.cooleshow.auth.service;
+
+import java.util.List;
+
+import com.yonge.cooleshow.auth.api.dto.MenuQueryInfo;
+import com.yonge.cooleshow.auth.api.entity.SysMenu;
+import com.yonge.cooleshow.common.service.BaseService;
+
+public interface SysMenuService extends BaseService<Integer, SysMenu> {
+
+    /**
+     * 根据角色编号查询拥有的菜单列表
+     * @param roleId
+     * @return
+     */
+    List<SysMenu> getMenusByRoleId(Integer roleId);
+
+    /**
+     * 根据用户编号查询用户可访问菜单
+     * @param menuQueryInfo
+     * @return
+     */
+    List<SysMenu> findByUser(MenuQueryInfo menuQueryInfo);
+
+    /**
+     * 根据权限标识查菜单
+     * @param permission
+     * @return
+     */
+    SysMenu findMenuByPermission(String permission);
+
+    /**
+     * 删除菜单列表,包含所有子节点
+     * @param id
+     */
+    void recursiveDel(Integer id);
+}

+ 8 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/SysOauthClientDetailsService.java

@@ -0,0 +1,8 @@
+package com.yonge.cooleshow.auth.service;
+
+import com.yonge.cooleshow.auth.api.entity.SysOauthClientDetails;
+import com.yonge.cooleshow.common.service.BaseService;
+
+public interface SysOauthClientDetailsService extends BaseService<String, SysOauthClientDetails> {
+
+}

+ 39 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/SysRoleMenuService.java

@@ -0,0 +1,39 @@
+package com.yonge.cooleshow.auth.service;
+
+import java.util.List;
+
+import com.yonge.cooleshow.auth.api.entity.SysRoleMenu;
+import com.yonge.cooleshow.common.service.BaseService;
+
+public interface SysRoleMenuService extends BaseService<Integer, SysRoleMenu> {
+
+	/**
+	 * 根据角色查询权限列表
+	 * @param roleId
+	 * @return
+	 */
+	List<String> queryPermissionsByRoleId(Integer roleId);
+
+	/**
+	 * 根据角色查询权限列表
+	 * @param roleIdList
+	 * @return
+	 */
+	List<String> queryPermissionsByRoleIdList(List<Integer> roleIdList);
+
+	/**
+	 * 角色添加菜单访问权限
+	 * @param roleId
+	 * @param menuIds
+	 * @return
+	 */
+    boolean batchInsert(Integer roleId, String menuIds);
+
+	/**
+	 * 角色删除菜单访问权限
+	 * @param roleId
+	 * @param menuIds
+	 * @return
+	 */
+    boolean batchdel(Integer roleId, String menuIds);
+}

+ 43 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/SysRoleService.java

@@ -0,0 +1,43 @@
+package com.yonge.cooleshow.auth.service;
+
+import java.util.List;
+
+import com.yonge.cooleshow.auth.api.entity.SysRole;
+import com.yonge.cooleshow.common.service.BaseService;
+
+public interface SysRoleService extends BaseService<Integer, SysRole> {
+
+    /**
+     * 根据userId查询角色列表
+     * @param userId 用户编号
+     * @return
+     */
+    List<SysRole> findRoleByUserId(Integer userId);
+
+    /**
+     * 根据角色标识查询角色
+     * @param code
+     * @return
+     */
+    SysRole findRoleByCode(String code);
+
+    /**
+     * 添加角色
+     * @param sysRole
+     */
+    void addRole(SysRole sysRole);
+
+    /**
+     * 修改角色信息
+     * @param sysRole
+     */
+    void updateRole(SysRole sysRole);
+
+    /**
+     * 删除角色
+     * @param id
+     */
+    void delRole(Integer id);
+
+    SysRole getRole(Integer id);
+}

+ 29 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/SysUserDeviceService.java

@@ -0,0 +1,29 @@
+package com.yonge.cooleshow.auth.service;
+
+import java.util.List;
+
+import com.yonge.cooleshow.auth.api.entity.SysUserDevice;
+import com.yonge.cooleshow.common.service.BaseService;
+
+public interface SysUserDeviceService extends BaseService<Integer, SysUserDevice> {
+
+	List<SysUserDevice> queryByUserId(String clientId, Integer userId);
+
+	List<SysUserDevice> queryByDeviceNum(String clientId, String deviceNum);
+
+	/**
+	 * 绑定设备号
+	 * @param clientId
+	 * @param userId
+	 * @param deviceNum
+	 * @return
+	 */
+	boolean bindDevice(String clientId, Integer userId, String deviceNum);
+
+	/**
+	 * 逻辑删除
+	 * @param id
+	 * @return
+	 */
+	boolean deleteWithLogic(Integer id);
+}

+ 8 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/SysUserLoginLogService.java

@@ -0,0 +1,8 @@
+package com.yonge.cooleshow.auth.service;
+
+import com.yonge.cooleshow.auth.api.entity.SysUserLoginLog;
+import com.yonge.cooleshow.common.service.BaseService;
+
+public interface SysUserLoginLogService extends BaseService<Long,SysUserLoginLog>{
+
+}

+ 20 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/SysUserLoginService.java

@@ -0,0 +1,20 @@
+package com.yonge.cooleshow.auth.service;
+
+import com.yonge.cooleshow.auth.api.entity.SysUserLogin;
+import com.yonge.cooleshow.common.service.BaseService;
+
+public interface SysUserLoginService extends BaseService<Integer, SysUserLogin> {
+
+	/**
+	 * 根据用户查询登录信息
+	 * @param userId
+	 * @return
+	 */
+	SysUserLogin findLoginByUserId(Integer userId);
+
+	/**
+	 * 自动解锁
+	 * @return
+	 */
+	public boolean autoUnlock();
+}

+ 38 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/SysUserRoleService.java

@@ -0,0 +1,38 @@
+package com.yonge.cooleshow.auth.service;
+
+import java.util.List;
+
+import com.yonge.cooleshow.auth.api.entity.SysUserRole;
+import com.yonge.cooleshow.common.service.BaseService;
+
+public interface SysUserRoleService extends BaseService<Integer, SysUserRole> {
+
+	/**
+	 * 查询指定用户具有的角色编号
+	 * @param userId 用户编号
+	 * @return
+	 */
+	List<Integer> queryRoleIdListByUserId(Integer userId);
+
+	/**
+	 * 查询指定用户的角色编码
+	 * @param userId
+	 * @return
+	 */
+	List<String> queryRoleCodeListByUserId(Integer userId);
+	/**
+	 * 新增用户角色(批量)
+	 * @param userId
+	 * @param roleIds
+	 * @return
+	 */
+	boolean batchInsert(Integer userId, String roleIds);
+
+	/**
+	 * 删除用户角色(批量)
+	 * @param userId
+	 * @param roleIds
+	 * @return
+	 */
+	boolean batchDel(Integer userId, String roleIds);
+}

+ 127 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/SysUserService.java

@@ -0,0 +1,127 @@
+package com.yonge.cooleshow.auth.service;
+
+import com.yonge.cooleshow.auth.api.dto.SysUserInfo;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.common.entity.ImUserModel;
+import com.yonge.cooleshow.common.service.BaseService;
+
+public interface SysUserService extends BaseService<Integer, SysUser> {
+
+	/**
+	 * 根据用户名查询对象
+	 * @param username
+	 * @return
+	 */
+	SysUser queryByUsername(String username);
+
+	/**
+	 * 根据手机号查询对象
+	 * @param phone
+	 * @return
+	 */
+	SysUser queryByPhone(String phone);
+
+	/**
+	 * 根据手机号查询对象
+	 * @param phone
+	 * @return
+	 */
+	SysUser queryLockByPhone(String phone);
+
+	/**
+	 * 根据手机号查询对象
+	 * @param phone
+	 * @return
+	 */
+	SysUser queryByPhoneAndClient(String phone,String client);
+
+	/**
+	 * 根据用户名获取系统用户详细信息
+	 * @param username
+	 * @return
+	 */
+	SysUserInfo queryUserInfoByUsername(String username);
+
+	/**
+	 * 根据手机号获取系统用户详细信息
+	 * @param phone
+	 * @return
+	 */
+	SysUserInfo queryUserInfoByPhone(String phone);
+
+	/**
+	 * 根据手机号获取系统用户详细信息
+	 * @param phone
+	 * @return
+	 */
+	SysUserInfo queryUserInfoByPhoneAndClient(String phone,String client);
+
+	/**
+	 * 删除指定用户
+	 * @param id
+	 * @return
+	 */
+	boolean deleteById(Integer id);
+
+	/**
+	 * 根据用户手机号修改密码
+	 * @param mobile
+	 * @param password
+	 */
+	void updatePassword(String mobile, String password);
+
+	/**
+	 * 新增用户
+	 * @param sysUser
+	 * @return
+	 */
+    Integer add(SysUser sysUser);
+
+	/**
+	 * 获取用户基本信息
+	 * @param userId
+	 * @return
+	 */
+	ImUserModel getBasic(Integer userId);
+
+	/**
+	 * 修改用户基本信息
+	 * @param sysUser
+	 */
+    void updateBaseInfo(SysUser sysUser);
+
+	/**
+	 * 获取用户基本信息
+	 * @param userId
+	 * @return
+	 */
+	SysUser queryUserInfo(Integer userId);
+
+	/**
+	 * 上线时初始化用户数据
+	 * @param phone
+	 * @param clientId
+	 * @return
+	 */
+	SysUserInfo initUser(String organId, String phone,String clientId);
+
+	/**
+	 * 刷新token
+	 * @param sysUser
+	 */
+    void refreshImToken(SysUser sysUser);
+
+	/**
+	 * 保存student数据
+	 * @param userId
+	 */
+	void saveStudent(Integer userId);
+	
+	/**
+	 * 保存teacher数据
+	 * @param userId
+	 */
+	void saveTeacher(Integer userId);
+	
+	Integer getLesseeOrganId();
+}

+ 126 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/impl/SysMenuServiceImpl.java

@@ -0,0 +1,126 @@
+package com.yonge.cooleshow.auth.service.impl;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.yonge.cooleshow.auth.api.dto.MenuQueryInfo;
+import com.yonge.cooleshow.auth.api.entity.SysMenu;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.auth.dal.dao.SysMenuDao;
+import com.yonge.cooleshow.auth.dal.dao.SysUserDao;
+import com.yonge.cooleshow.auth.service.SysMenuService;
+import com.yonge.cooleshow.common.dal.BaseDAO;
+import com.yonge.cooleshow.common.service.impl.BaseServiceImpl;
+
+@Service
+public class SysMenuServiceImpl extends BaseServiceImpl<Integer, SysMenu>  implements SysMenuService {
+	
+	@Autowired
+	private SysMenuDao sysMenuDao;
+	@Autowired
+	private SysUserDao sysUserDao;
+
+	@Override
+	public BaseDAO<Integer, SysMenu> getDAO() {
+		return sysMenuDao;
+	}
+
+	@Override
+	public List<SysMenu> getMenusByRoleId(Integer roleId) {
+		return sysMenuDao.getMenusByRoleId(roleId);
+	}
+
+	public List<SysMenu> findByUser1(MenuQueryInfo menuQueryInfo) {
+		SysUser sysUser = sysUserDao.get(menuQueryInfo.getUserId());
+		List<SysMenu> sysMenus = null;
+		if(sysUser.getIsSuperAdmin()){
+			menuQueryInfo.setUserId(null);
+			sysMenus = sysMenuDao.findList(menuQueryInfo.getParentId(),menuQueryInfo.getDelFlag(),menuQueryInfo.getHid());
+		}else {
+			sysMenus = sysMenuDao.findByParentId(menuQueryInfo.getParentId(),menuQueryInfo.getDelFlag(),menuQueryInfo.getUserId(),menuQueryInfo.getHid());
+		}
+		for (SysMenu menu:sysMenus) {
+			menu = getTree(menu,menuQueryInfo.getDelFlag(),menuQueryInfo.getUserId(),menuQueryInfo.getHid());
+		}
+		return sysMenus;
+	}
+
+	public List<SysMenu> findByUser(MenuQueryInfo menuQueryInfo) {
+		SysUser sysUser = sysUserDao.get(menuQueryInfo.getUserId());
+		List<SysMenu> sysMenus;
+		List<SysMenu> sysMenusAllList;
+
+		if(sysUser.getIsSuperAdmin()){
+			sysMenus = sysMenuDao.findList(menuQueryInfo.getParentId(),menuQueryInfo.getDelFlag(),menuQueryInfo.getHid());
+			sysMenusAllList = sysMenuDao.findList(null,menuQueryInfo.getDelFlag(),menuQueryInfo.getHid());
+		}else {
+			sysMenus = sysMenuDao.findByParentId(menuQueryInfo.getParentId(),menuQueryInfo.getDelFlag(),menuQueryInfo.getUserId(),menuQueryInfo.getHid());
+			sysMenusAllList = sysMenuDao.findByParentId(null,menuQueryInfo.getDelFlag(),menuQueryInfo.getUserId(),menuQueryInfo.getHid());
+		}
+
+		for (SysMenu menu:sysMenus) {
+			menu = getTree1(menu,sysMenusAllList);
+		}
+		return sysMenus;
+	}
+
+	private SysMenu getTree1(SysMenu menu,List<SysMenu> sysMenusAllList){
+		//得到根节点对象
+		//获取子节点list
+		List<SysMenu> sysMenus = sysMenusAllList.stream().filter(e->e.getParentId().equals(menu.getId())).collect(Collectors.toList());
+		//如果存在子节点
+		if(sysMenus != null && sysMenus.size() > 0) {
+			//将子节点list放入父节点对象
+			menu.setSysMenus(sysMenus);
+			//遍历子节点....
+			for (SysMenu sysMenu : sysMenus) {
+				getTree1(sysMenu,sysMenusAllList);
+			}
+		}
+		return menu;
+	}
+
+	private SysMenu getTree(SysMenu menu, String delFlag,Integer userId,Integer hid){
+		//得到根节点对象
+		//获取子节点list
+		List<SysMenu> sysMenus = null;
+		if(userId == null){
+			sysMenus = sysMenuDao.findList(menu.getId(),delFlag,hid);
+		}else {
+			sysMenus = sysMenuDao.findByParentId(menu.getId(),delFlag,userId,hid);
+		}
+		//如果存在子节点
+		if(sysMenus != null && sysMenus.size() > 0) {
+			//将子节点list放入父节点对象
+			menu.setSysMenus(sysMenus);
+			//遍历子节点....
+			for (SysMenu sysMenu : sysMenus) {
+				getTree(sysMenu,delFlag,userId,hid);
+			}
+		}
+		return menu;
+	}
+
+	@Override
+	public SysMenu findMenuByPermission(String permission){
+		return sysMenuDao.findMenuByPermission(permission);
+	}
+
+	@Override
+	public void recursiveDel(Integer parentId) {
+		List<SysMenu> sysMenus = sysMenuDao.findList(parentId, "0",0);
+		for (SysMenu menu:sysMenus) {
+			menu = getTree(menu,"0",null,null);
+		}
+		List<Integer> collect = sysMenus.stream().map(sysMenu -> sysMenu.getId()).collect(Collectors.toList());
+		if(collect == null || collect.size() <= 0){
+			sysMenuDao.delete(parentId);
+			return;
+		}
+		collect.add(parentId);
+		sysMenuDao.batchDel(collect);
+	}
+}

+ 23 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/impl/SysOauthClientDetailsServiceImpl.java

@@ -0,0 +1,23 @@
+package com.yonge.cooleshow.auth.service.impl;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.yonge.cooleshow.auth.api.entity.SysOauthClientDetails;
+import com.yonge.cooleshow.auth.dal.dao.SysOauthClientDetailsDao;
+import com.yonge.cooleshow.auth.service.SysOauthClientDetailsService;
+import com.yonge.cooleshow.common.dal.BaseDAO;
+import com.yonge.cooleshow.common.service.impl.BaseServiceImpl;
+
+@Service
+public class SysOauthClientDetailsServiceImpl extends BaseServiceImpl<String, SysOauthClientDetails>  implements SysOauthClientDetailsService {
+	
+	@Autowired
+	private SysOauthClientDetailsDao sysOauthClientDetailsDao;
+
+	@Override
+	public BaseDAO<String, SysOauthClientDetails> getDAO() {
+		return sysOauthClientDetailsDao;
+	}
+	
+}

+ 66 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/impl/SysRoleMenuServiceImpl.java

@@ -0,0 +1,66 @@
+package com.yonge.cooleshow.auth.service.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.yonge.cooleshow.auth.api.entity.SysRoleMenu;
+import com.yonge.cooleshow.auth.dal.dao.SysRoleMenuDao;
+import com.yonge.cooleshow.auth.service.SysRoleMenuService;
+import com.yonge.cooleshow.common.dal.BaseDAO;
+import com.yonge.cooleshow.common.service.impl.BaseServiceImpl;
+
+@Service
+public class SysRoleMenuServiceImpl extends BaseServiceImpl<Integer, SysRoleMenu> implements SysRoleMenuService {
+
+	@Autowired
+	private SysRoleMenuDao sysRoleMenuDao;
+
+	@Override
+	public BaseDAO<Integer, SysRoleMenu> getDAO() {
+		return sysRoleMenuDao;
+	}
+
+	@Override
+	public List<String> queryPermissionsByRoleId(Integer roleId) {
+		return sysRoleMenuDao.queryPermissionsByRoleId(roleId);
+	}
+
+	@Override
+	public List<String> queryPermissionsByRoleIdList(List<Integer> roleIdList) {
+
+		List<String> list = new ArrayList<String>();
+
+		for (Integer roleId : roleIdList) {
+			list.addAll(queryPermissionsByRoleId(roleId));
+		}
+		return list;
+	}
+
+	@Override
+	public boolean batchInsert(Integer roleId, String menuIds) {
+		SysRoleMenu sysRoleMenu = new SysRoleMenu();
+		sysRoleMenu.setRoleId(roleId);
+		String[] split = menuIds.split(",");
+		for (String string:split) {
+			sysRoleMenu.setMenuId(Integer.parseInt(string));
+			sysRoleMenuDao.delete(sysRoleMenu);
+		}
+		return true;
+	}
+
+	@Override
+	public boolean batchdel(Integer roleId, String menuIds) {
+		SysRoleMenu sysRoleMenu = new SysRoleMenu();
+		sysRoleMenu.setRoleId(roleId);
+		String[] split = menuIds.split(",");
+		for (String string:split) {
+			sysRoleMenu.setMenuId(Integer.parseInt(string));
+			sysRoleMenuDao.insert(sysRoleMenu);
+		}
+		return true;
+	}
+
+}

+ 91 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/impl/SysRoleServiceImpl.java

@@ -0,0 +1,91 @@
+package com.yonge.cooleshow.auth.service.impl;
+
+import java.util.Date;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.yonge.cooleshow.auth.api.entity.SysRole;
+import com.yonge.cooleshow.auth.dal.dao.SysRoleDao;
+import com.yonge.cooleshow.auth.dal.dao.SysRoleMenuDao;
+import com.yonge.cooleshow.auth.service.SysRoleService;
+import com.yonge.cooleshow.common.dal.BaseDAO;
+import com.yonge.cooleshow.common.exception.BizException;
+import com.yonge.cooleshow.common.service.impl.BaseServiceImpl;
+
+@Service
+public class SysRoleServiceImpl extends BaseServiceImpl<Integer, SysRole>  implements SysRoleService {
+	
+	@Autowired
+	private SysRoleDao sysRoleDao;
+	@Autowired
+	private SysRoleMenuDao sysRoleMenuDao;
+
+	@Override
+	public BaseDAO<Integer, SysRole> getDAO() {
+		return sysRoleDao;
+	}
+
+	@Override
+	public List<SysRole> findRoleByUserId(Integer userId) {
+		return sysRoleDao.findRoleByUserId(userId);
+	}
+
+	@Override
+	public SysRole findRoleByCode(String code){
+		return sysRoleDao.findRoleByCode(code);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void addRole(SysRole sysRole) {
+		SysRole findByName = sysRoleDao.findByRoleName(sysRole.getRoleName());
+		if(findByName != null){
+			throw new BizException("操作失败:角色 {} 已存在",sysRole.getRoleName());
+		}
+		sysRoleDao.insert(sysRole);
+		batchSave(sysRole);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateRole(SysRole sysRole) {
+		SysRole findByName = sysRoleDao.findByRoleName(sysRole.getRoleName());
+		if(findByName != null && !findByName.getId().equals(sysRole.getId())){
+			throw new BizException("操作失败:角色 {} 已存在",sysRole.getRoleName());
+		}
+		sysRole.setUpdateTime(new Date());
+		sysRoleDao.update(sysRole);
+		sysRoleMenuDao.deleteAllMenu(sysRole.getId());
+		batchSave(sysRole);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delRole(Integer id) {
+		sysRoleDao.delete(id);
+		sysRoleMenuDao.deleteAllMenu(id);
+	}
+
+	@Override
+	public SysRole getRole(Integer id) {
+		SysRole sysRole = sysRoleDao.get(id);
+		sysRole.setMenuIds(sysRoleMenuDao.queryMenuIdByRoleId(id));
+		return sysRole;
+	}
+
+	private void batchSave(SysRole sysRole){
+		List<Integer> menuIds = sysRole.getMenuIds();
+		if(menuIds != null && menuIds.size() > 0){
+//			SysRoleMenu sysRoleMenu = new SysRoleMenu(sysRole.getId(),null);
+			sysRoleMenuDao.batchAdd(sysRole.getId(),menuIds);
+//			menuIds.forEach(e->{
+//				sysRoleMenu.setMenuId(e);
+//				sysRoleMenuDao.insert(sysRoleMenu);
+//			});
+		}
+	}
+
+}

+ 108 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/impl/SysUserDeviceServiceImpl.java

@@ -0,0 +1,108 @@
+package com.yonge.cooleshow.auth.service.impl;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.authentication.BadCredentialsException;
+import org.springframework.stereotype.Service;
+
+import com.yonge.cooleshow.auth.api.entity.SysUserDevice;
+import com.yonge.cooleshow.auth.dal.dao.SysUserDeviceDao;
+import com.yonge.cooleshow.auth.service.SysUserDeviceService;
+import com.yonge.cooleshow.common.dal.BaseDAO;
+import com.yonge.cooleshow.common.service.impl.BaseServiceImpl;
+
+@Service
+public class SysUserDeviceServiceImpl extends BaseServiceImpl<Integer, SysUserDevice>  implements SysUserDeviceService {
+	
+	@Autowired
+	private SysUserDeviceDao sysUserDeviceDao;
+
+	@Override
+	public BaseDAO<Integer, SysUserDevice> getDAO() {
+		return sysUserDeviceDao;
+	}
+
+	@Override
+	public List<SysUserDevice> queryByUserId(String clientId, Integer userId) {
+		return sysUserDeviceDao.queryByUserId(clientId, userId);
+	}
+
+	@Override
+	public List<SysUserDevice> queryByDeviceNum(String clientId, String deviceNum) {
+		return sysUserDeviceDao.queryByDeviceNum(clientId, deviceNum);
+	}
+
+	@Override
+	public boolean bindDevice(String clientId, Integer userId, String deviceNum) {
+
+		if (StringUtils.equals(clientId, "STUDENT")) {
+			// 检查学生是否绑定了多个设备号
+			List<SysUserDevice> studentDeviceList = queryByUserId(clientId, userId);
+
+			if (studentDeviceList == null) {
+				studentDeviceList = new ArrayList<SysUserDevice>();
+			}
+
+			List<String> deviceList = studentDeviceList.stream().map(t -> t.getDeviceNum()).collect(Collectors.toList());
+
+			if (!deviceList.contains(deviceNum)) {
+				if (deviceList.size() >= 5) {
+					throw new BadCredentialsException("当前账号绑定设备过多,请联系主教老师");
+				}
+
+				SysUserDevice sysUserDevice = new SysUserDevice();
+				sysUserDevice.setUserId(userId);
+				sysUserDevice.setDeviceNum(deviceNum);
+				sysUserDevice.setBindTime(new Date());
+				sysUserDevice.setClientId(clientId);
+				sysUserDeviceDao.insert(sysUserDevice);
+			}
+		} else {
+			// 查询设备号是否已存在
+			List<SysUserDevice> sysUserDeviceList = sysUserDeviceDao.queryByDeviceNum(null, deviceNum);
+
+			if (sysUserDeviceList == null) {
+				sysUserDeviceList = new ArrayList<SysUserDevice>();
+			}
+
+			sysUserDeviceList = sysUserDeviceList.stream().filter(sud -> !StringUtils.equals(sud.getClientId(), "STUDENT")).collect(Collectors.toList());
+
+			if (sysUserDeviceList != null && sysUserDeviceList.size() > 0) {
+				if (sysUserDeviceList.stream().filter(sud -> sud.getUserId().equals(userId)).count() > 0) {
+
+					return true;
+				}
+
+				throw new BadCredentialsException("当前设备已绑定账号,请更换设备");
+			}
+
+			SysUserDevice sysUserDevice = new SysUserDevice();
+			sysUserDevice.setUserId(userId);
+			sysUserDevice.setDeviceNum(deviceNum);
+			sysUserDevice.setBindTime(new Date());
+			sysUserDevice.setClientId(clientId);
+			sysUserDeviceDao.insert(sysUserDevice);
+		}
+
+		return true;
+	}
+
+	@Override
+	public boolean deleteWithLogic(Integer id) {
+		
+		SysUserDevice sysUserDevice = sysUserDeviceDao.get(id);
+		if(sysUserDevice != null){
+			sysUserDevice.setDelFlag(1);
+			
+			sysUserDeviceDao.update(sysUserDevice);
+		}
+		
+		return true;
+	}
+	
+}

+ 22 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/impl/SysUserLoginLogServiceImpl.java

@@ -0,0 +1,22 @@
+package com.yonge.cooleshow.auth.service.impl;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.yonge.cooleshow.auth.api.entity.SysUserLoginLog;
+import com.yonge.cooleshow.auth.dal.dao.SysUserLoginLogDao;
+import com.yonge.cooleshow.auth.service.SysUserLoginLogService;
+import com.yonge.cooleshow.common.dal.BaseDAO;
+import com.yonge.cooleshow.common.service.impl.BaseServiceImpl;
+
+@Service
+public class SysUserLoginLogServiceImpl extends BaseServiceImpl<Long,SysUserLoginLog> implements SysUserLoginLogService {
+
+	@Autowired
+	private SysUserLoginLogDao sysUserLoginLogDao;
+
+	@Override
+	public BaseDAO<Long, SysUserLoginLog> getDAO() {
+		return sysUserLoginLogDao;
+	}
+}

+ 72 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/impl/SysUserLoginServiceImpl.java

@@ -0,0 +1,72 @@
+package com.yonge.cooleshow.auth.service.impl;
+
+import java.util.Date;
+import java.util.List;
+
+import org.apache.commons.lang3.time.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.auth.api.entity.SysUserLogin;
+import com.yonge.cooleshow.auth.api.enums.UserLockFlag;
+import com.yonge.cooleshow.auth.dal.dao.SysUserDao;
+import com.yonge.cooleshow.auth.dal.dao.SysUserLoginDao;
+import com.yonge.cooleshow.auth.service.SysUserLoginService;
+import com.yonge.cooleshow.common.dal.BaseDAO;
+import com.yonge.cooleshow.common.service.impl.BaseServiceImpl;
+
+@Service
+public class SysUserLoginServiceImpl extends BaseServiceImpl<Integer, SysUserLogin> implements SysUserLoginService {
+
+	@Autowired
+	private SysUserLoginDao sysUserLoginDao;
+
+	@Autowired
+	private SysUserDao sysUserDao;
+
+	@Override
+	public BaseDAO<Integer, SysUserLogin> getDAO() {
+		return sysUserLoginDao;
+	}
+
+	@Override
+	public SysUserLogin findLoginByUserId(Integer userId) {
+		return sysUserLoginDao.findLoginByUserId(userId);
+	}
+
+	@Override
+	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+	public boolean autoUnlock() {
+		List<SysUser> users = sysUserDao.queryByStatus(UserLockFlag.LOCKED);
+		if (users != null) {
+			SysUserLogin userLogin = null;
+			Date targetDate = null;
+			Date currentDate = new Date();
+			Integer lockTime = null;
+			for (SysUser user : users) {
+				userLogin = get(user.getId());
+				if (userLogin != null) {
+					lockTime = userLogin.getLockTime();
+					if (lockTime == null || lockTime == 0) {
+						continue;
+					}
+					targetDate = DateUtils.addMinutes(userLogin.getLockDate(), lockTime);
+					if (targetDate.getTime() < currentDate.getTime()) {
+						userLogin.setFailCount(0);
+						userLogin.setLockDate(null);
+						userLogin.setLockTime(0);
+						update(userLogin);
+
+						user.setLockFlag(0);
+						user.setUpdateTime(currentDate);
+						sysUserDao.update(user);
+					}
+				}
+			}
+		}
+		return false;
+	}
+}

+ 58 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/impl/SysUserRoleServiceImpl.java

@@ -0,0 +1,58 @@
+package com.yonge.cooleshow.auth.service.impl;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.yonge.cooleshow.auth.api.entity.SysUserRole;
+import com.yonge.cooleshow.auth.dal.dao.SysUserRoleDao;
+import com.yonge.cooleshow.auth.service.SysUserRoleService;
+import com.yonge.cooleshow.common.dal.BaseDAO;
+import com.yonge.cooleshow.common.service.impl.BaseServiceImpl;
+
+@Service
+public class SysUserRoleServiceImpl extends BaseServiceImpl<Integer, SysUserRole>  implements SysUserRoleService {
+	
+	@Autowired
+	private SysUserRoleDao sysUserRoleDao;
+
+	@Override
+	public BaseDAO<Integer, SysUserRole> getDAO() {
+		return sysUserRoleDao;
+	}
+
+	@Override
+	public List<Integer> queryRoleIdListByUserId(Integer userId) {
+		return sysUserRoleDao.queryRoleIdListByUserId(userId);
+	}
+	@Override
+	public List<String> queryRoleCodeListByUserId(Integer userId) {
+		return sysUserRoleDao.queryRoleCodeListByUserId(userId);
+	}
+
+	@Override
+	public boolean batchInsert(Integer userId, String roleIds) {
+		SysUserRole sysUserRole = new SysUserRole();
+		sysUserRole.setUserId(userId);
+		String[] split = roleIds.split(",");
+		for (String string:split) {
+			sysUserRole.setRoleId(Integer.parseInt(string));
+			sysUserRoleDao.insert(sysUserRole);
+		}
+		return true;
+	}
+
+	@Override
+	public boolean batchDel(Integer userId, String roleIds) {
+		SysUserRole sysUserRole = new SysUserRole();
+		sysUserRole.setUserId(userId);
+		String[] split = roleIds.split(",");
+		for (String string:split) {
+			sysUserRole.setRoleId(Integer.parseInt(string));
+			sysUserRoleDao.delete(sysUserRole);
+		}
+		return true;
+	}
+
+}

+ 204 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/impl/SysUserServiceImpl.java

@@ -0,0 +1,204 @@
+package com.yonge.cooleshow.auth.service.impl;
+
+import java.util.Date;
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.yonge.cooleshow.auth.api.dto.SysUserInfo;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.auth.api.enums.YesOrNoEnum;
+import com.yonge.cooleshow.auth.dal.dao.SysUserDao;
+import com.yonge.cooleshow.auth.service.SysRoleMenuService;
+import com.yonge.cooleshow.auth.service.SysUserRoleService;
+import com.yonge.cooleshow.auth.service.SysUserService;
+import com.yonge.cooleshow.common.dal.BaseDAO;
+import com.yonge.cooleshow.common.entity.ImUserModel;
+import com.yonge.cooleshow.common.exception.BizException;
+import com.yonge.cooleshow.common.service.IdGeneratorService;
+import com.yonge.cooleshow.common.service.impl.BaseServiceImpl;
+
+@Service
+public class SysUserServiceImpl extends BaseServiceImpl<Integer, SysUser> implements SysUserService {
+
+	@Autowired
+	private SysUserDao sysUserDao;
+
+	@Autowired
+	private SysUserRoleService sysUserRoleService;
+
+	@Autowired
+	private SysRoleMenuService sysRoleMenuService;
+	@Autowired
+	private SysUserService sysUserService;
+	@Autowired
+	private IdGeneratorService smsCodeService;
+
+	@Value("${auth.sysconfig.tenantId}")
+	private Integer lesseeOrganId;
+
+	@Override
+	public BaseDAO<Integer, SysUser> getDAO() {
+		return sysUserDao;
+	}
+
+	@Override
+	public SysUser queryByUsername(String username) {
+		return sysUserDao.queryByUsername(username);
+	}
+
+	@Override
+	public SysUser queryByPhone(String phone) {
+		return sysUserDao.queryByPhone(phone);
+	}
+	@Override
+	public SysUser queryLockByPhone(String phone) {
+		return sysUserDao.queryLockByPhone(phone);
+	}
+
+	@Override
+	public SysUser queryByPhoneAndClient(String phone,String client) {
+		return sysUserDao.queryByPhoneAndClient(phone,client);
+	}
+
+	@Override
+	public SysUserInfo queryUserInfoByUsername(String username) {
+		return getSysUserInfo(queryByUsername(username));
+	}
+
+	@Override
+	public SysUserInfo queryUserInfoByPhone(String phone) {
+		return getSysUserInfo(queryLockByPhone(phone));
+	}
+
+	@Override
+	public SysUserInfo queryUserInfoByPhoneAndClient(String phone,String client) {
+		return getSysUserInfo(queryByPhoneAndClient(phone,client));
+	}
+
+	private SysUserInfo getSysUserInfo(SysUser sysUser) {
+		if (sysUser == null) {
+			return null;
+		}
+		SysUserInfo userInfo = new SysUserInfo();
+		userInfo.setSysUser(sysUser);
+
+		List<String> roleCodeList = sysUserRoleService.queryRoleCodeListByUserId(sysUser.getId());
+		userInfo.setRoles(roleCodeList.toArray(new String[roleCodeList.size()]));
+
+		List<Integer> roleIdList = sysUserRoleService.queryRoleIdListByUserId(sysUser.getId());
+		List<String> permissionList = sysRoleMenuService.queryPermissionsByRoleIdList(roleIdList);
+
+		userInfo.setPermissions(permissionList.toArray(new String[permissionList.size()]));
+
+		return userInfo;
+	}
+
+	@Override
+	public boolean deleteById(Integer id) {
+		SysUser user = get(id);
+
+		if (user == null) {
+			throw new BizException("账户不存在");
+		}
+
+		user.setUpdateTime(new Date());
+		user.setDelFlag(YesOrNoEnum.YES);
+
+		update(user);
+
+		return true;
+	}
+
+	@Override
+	public void updatePassword(String mobile, String password) {
+		sysUserDao.updatePassword(mobile,password);
+	}
+
+	@Override
+	public Integer add(SysUser sysUser) {
+		sysUserDao.insert(sysUser);
+		sysUserDao.update(sysUser);
+		return sysUser.getId();
+	}
+
+	@Override
+	public ImUserModel getBasic(Integer userId) {
+		return sysUserDao.getBasic(userId);
+	}
+
+	@Override
+	public void updateBaseInfo(SysUser sysUser) {
+		sysUserDao.update(sysUser);
+	}
+
+	@Override
+	public SysUser queryUserInfo(Integer userId) {
+		return sysUserDao.get(userId);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public SysUserInfo initUser(String organId, String phone,String clientId) {
+		if(StringUtils.equalsIgnoreCase(clientId,"TEACHER")){
+			SysUser sysUser = new SysUser();
+			sysUser.setPhone(phone);
+			sysUser.setUserType("TEACHER");
+			sysUserDao.insert(sysUser);
+			//添加用户现金账户
+			//imFeignService.register(new ImUserModel(sysUser.getId().toString(),phone,null));
+			//userFeignService.createCashAccount(sysUser.getId());
+			//sysTenantAccount
+			sysUserDao.insertSysTenantAccount(sysUser.getId());
+			//创建teacher表
+			sysUserDao.insertTeacher(sysUser.getId(),lesseeOrganId);
+			return queryUserInfoByPhone(phone);
+		}else if(StringUtils.equalsIgnoreCase(clientId,"STUDENT")){
+			SysUser sysUser = new SysUser();
+			sysUser.setPhone(phone);
+			sysUser.setUserType("STUDENT");
+			if(StringUtils.isBlank(organId)){
+				sysUser.setOrganId(lesseeOrganId);
+			}else{
+				sysUser.setOrganId(Integer.parseInt(organId));
+			}
+			//注册是否赠送会员
+			if(sysUser.getOrganId() == 59){
+				
+			}
+			
+			sysUserDao.insert(sysUser);
+			sysUserService.saveStudent(sysUser.getId());
+			//添加用户现金账户
+			//imFeignService.register(new ImUserModel(sysUser.getId().toString(),phone,null));
+			return queryUserInfoByPhone(phone);
+		}
+		return null;
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void refreshImToken(SysUser sysUser) {
+		sysUserDao.refreshImToken(sysUser.getId(),sysUser.getImToken());
+	}
+
+	@Override
+	public void saveStudent(Integer userId) {
+		sysUserDao.saveStudent(userId);
+	}
+
+	@Override
+	public void saveTeacher(Integer userId) {
+		sysUserDao.insertTeacher(userId, lesseeOrganId);
+	}
+
+	@Override
+	public Integer getLesseeOrganId() {
+		return lesseeOrganId;
+	}
+
+}

+ 88 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/web/controller/MenuController.java

@@ -0,0 +1,88 @@
+package com.yonge.cooleshow.auth.web.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+
+import java.util.Date;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.yonge.cooleshow.auth.api.dto.MenuQueryInfo;
+import com.yonge.cooleshow.auth.api.entity.SysMenu;
+import com.yonge.cooleshow.auth.service.SysMenuService;
+import com.yonge.cooleshow.common.controller.BaseController;
+import com.yonge.cooleshow.common.security.AuthUser;
+import com.yonge.cooleshow.common.security.SecurityUtils;
+
+@RestController()
+@RequestMapping("menu")
+@Api(tags = "菜单服务")
+public class MenuController extends BaseController {
+
+    @Autowired
+    private SysMenuService sysMenuService;
+
+    @ApiOperation("新增菜单")
+    @PutMapping(value = "/add",consumes = MediaType.APPLICATION_JSON_VALUE)
+    @PreAuthorize("@pcs.hasPermissions('menu/add')")
+    public Object getMenu(@RequestBody SysMenu sysMenu) {
+//        SysMenu menuByPermission = sysMenuService.findMenuByPermission(sysMenu.getPermission());
+//        if(menuByPermission != null){
+//            return failed("权限标识不能重复");
+//        }
+        return succeed(sysMenuService.insert(sysMenu));
+    }
+
+    @ApiOperation("根据菜单id删除菜单")
+    @DeleteMapping("/del/{id}")
+    @PreAuthorize("@pcs.hasPermissions('menu/del')")
+    public Object delMenu(@ApiParam(value = "菜单编号", required = true) @PathVariable("id") Integer id) {
+        sysMenuService.recursiveDel(id);
+        return succeed();
+    }
+
+    @ApiOperation("根据菜单id修改菜单")
+    @PutMapping(value = "/update",consumes = MediaType.APPLICATION_JSON_VALUE)
+    @PreAuthorize("@pcs.hasPermissions('menu/update')")
+    public Object updateMenu(@RequestBody SysMenu sysMenu) {
+//        SysMenu menuByPermission = sysMenuService.findMenuByPermission(sysMenu.getPermission());
+//        if(menuByPermission != null && !menuByPermission.getId().equals(sysMenu.getId())){
+//            return failed("权限标识不能重复");
+//        }
+        Date date = new Date();
+        sysMenu.setUpdateTime(date);
+        return succeed(sysMenuService.update(sysMenu));
+    }
+
+    @ApiOperation("根据菜单id查询菜单")
+    @GetMapping(value = "/{id}",consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
+    @PreAuthorize("@pcs.hasPermissions('menu')")
+    public Object getMenu(@ApiParam(value = "菜单编号", required = true) @PathVariable("id") Integer id) {
+        return succeed(sysMenuService.get(id));
+    }
+
+    @ApiOperation("查询用户可访问菜单树状结构")
+    @GetMapping(value = "/findByUser")
+    public Object findByUser(@RequestBody(required = false) MenuQueryInfo menuQueryInfo) {
+        AuthUser user = SecurityUtils.getUser();
+        if(user != null){
+            if(menuQueryInfo == null){
+                menuQueryInfo = new MenuQueryInfo();
+            }
+            menuQueryInfo.setUserId(user.getUserId());
+            return succeed(sysMenuService.findByUser(menuQueryInfo));
+        }
+        return failed();
+    }
+
+}

+ 125 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/web/controller/RoleController.java

@@ -0,0 +1,125 @@
+package com.yonge.cooleshow.auth.web.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+
+import java.util.Date;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.yonge.cooleshow.auth.api.entity.SysRole;
+import com.yonge.cooleshow.auth.service.SysMenuService;
+import com.yonge.cooleshow.auth.service.SysRoleMenuService;
+import com.yonge.cooleshow.auth.service.SysRoleService;
+import com.yonge.cooleshow.auth.service.SysUserRoleService;
+import com.yonge.cooleshow.common.controller.BaseController;
+import com.yonge.cooleshow.common.page.QueryInfo;
+import com.yonge.cooleshow.common.security.SecurityConstants;
+
+@RestController()
+@RequestMapping("role")
+@Api(tags = "角色服务")
+public class RoleController extends BaseController {
+
+	@Autowired
+	private SysRoleService sysRoleService;
+	@Autowired
+	private SysRoleMenuService sysRoleMenuService;
+	@Autowired
+	private SysMenuService sysMenuService;
+	@Autowired
+	private SysUserRoleService sysUserRoleService;
+
+	@GetMapping(value = "/queryRoleCodeListByUserId")
+	public Object queryRoleCodeListByUserId(Integer userId) {
+		return sysUserRoleService.queryRoleCodeListByUserId(userId);
+	}
+
+	@ApiOperation("根据权限id查询角色")
+	@GetMapping(value = "/{id}")
+    @PreAuthorize("@pcs.hasPermissions('role')")
+	public Object getRole(@ApiParam(value = "权限编号", required = true) @PathVariable("id") Integer id) {
+		return succeed(sysRoleService.getRole(id));
+	}
+
+	@ApiOperation("删除角色")
+	@PostMapping(value = "/del")
+    @PreAuthorize("@pcs.hasPermissions('role/del')")
+	public Object delRole(Integer id) {
+		sysRoleService.delRole(id);
+		return succeed();
+	}
+
+	@ApiOperation("修改角色")
+	@PostMapping(value = "/update")
+    @PreAuthorize("@pcs.hasPermissions('role/update')")
+	public Object updateRole(@RequestBody SysRole sysRole) {
+		sysRole.setUpdateTime(new Date());
+		sysRoleService.updateRole(sysRole);
+		return succeed();
+	}
+
+	@ApiOperation("新增角色")
+	@PostMapping(value = "/add")
+    @PreAuthorize("@pcs.hasPermissions('role/add')")
+	public Object addRole(@RequestBody SysRole sysRole) {
+		sysRoleService.addRole(sysRole);
+		return succeed();
+	}
+
+	@ApiOperation("分页查询角色列表")
+	@GetMapping(value = "/queryPage")
+    @PreAuthorize("@pcs.hasPermissions('role/queryPage')")
+	public Object queryPage(QueryInfo queryInfo) {
+		return succeed(sysRoleService.queryPage(queryInfo));
+	}
+
+	@ApiOperation("角色新增菜单权限(批量)")
+	@ApiImplicitParams({ @ApiImplicitParam(name = "roleId", value = "角色编号", required = true, dataType = "Integer"),
+			@ApiImplicitParam(name = "menuIds", value = "菜单id,逗号分隔", required = true, dataType = "String") })
+	@PostMapping(value = "/addRoleMenu", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
+    @PreAuthorize("@pcs.hasPermissions('role/addRoleMenu')")
+	public Object addRoleMenu(String roleId, String menuIds) {
+		if (StringUtils.isEmpty(roleId) || StringUtils.isEmpty(menuIds)) {
+			return failed(SecurityConstants.PARAM_VERIFY_EXCEPTION);
+		}
+		sysRoleMenuService.batchInsert(Integer.parseInt(roleId), menuIds);
+		return succeed();
+	}
+
+	@ApiOperation("角色删除菜单权限(批量)")
+	@ApiImplicitParams({ @ApiImplicitParam(name = "roleId", value = "角色编号", required = true, dataType = "Integer"),
+			@ApiImplicitParam(name = "menuIds", value = "菜单id,逗号分隔", required = true, dataType = "String") })
+	@PostMapping(value = "/delRoleMenu", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
+    @PreAuthorize("@pcs.hasPermissions('role/delRoleMenu')")
+	public Object delRoleMenu(String roleId, String menuIds) {
+		if (StringUtils.isEmpty(roleId) || StringUtils.isEmpty(menuIds)) {
+			return failed(SecurityConstants.PARAM_VERIFY_EXCEPTION);
+		}
+		sysRoleMenuService.batchdel(Integer.parseInt(roleId), menuIds);
+		return succeed();
+	}
+
+	@ApiOperation("根据角色编号查询拥有的菜单列表")
+	@ApiImplicitParams({ @ApiImplicitParam(name = "roleId", value = "角色编号", required = true, dataType = "Integer") })
+	@GetMapping(value = "/getMenus")
+    @PreAuthorize("@pcs.hasPermissions('role/getMenus')")
+	public Object getMenus(Integer roleId) {
+		if (roleId == null) {
+			return failed(SecurityConstants.PARAM_VERIFY_EXCEPTION);
+		}
+		return succeed(sysMenuService.getMenusByRoleId(roleId));
+	}
+}

+ 23 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/web/controller/TaskController.java

@@ -0,0 +1,23 @@
+package com.yonge.cooleshow.auth.web.controller;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.yonge.cooleshow.auth.service.SysUserLoginService;
+import com.yonge.cooleshow.common.controller.BaseController;
+
+@RestController
+@RequestMapping("task")
+public class TaskController extends BaseController {
+
+	@Autowired
+	private SysUserLoginService sysUserLoginService;
+
+	@GetMapping("/autoUnlock")
+	public void autoUnlock() {
+		sysUserLoginService.autoUnlock();
+	}
+
+}

+ 194 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/web/controller/TokenController.java

@@ -0,0 +1,194 @@
+package com.yonge.cooleshow.auth.web.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Collection;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.oauth2.common.OAuth2AccessToken;
+import org.springframework.security.oauth2.provider.token.ResourceServerTokenServices;
+import org.springframework.security.oauth2.provider.token.TokenStore;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.client.RestTemplate;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.auth.core.service.CustomTokenServices;
+import com.yonge.cooleshow.auth.service.SysUserService;
+import com.yonge.cooleshow.common.controller.BaseController;
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import com.yonge.cooleshow.common.security.AuthUser;
+import com.yonge.cooleshow.common.security.SecurityConstants;
+import com.yonge.cooleshow.common.security.SecurityUtils;
+
+@RestController
+@Api(tags = "认证服务")
+public class TokenController extends BaseController {
+
+	@Autowired
+	private CustomTokenServices tokenService;
+	
+	@Autowired
+	private ResourceServerTokenServices resourceServerTokenServices;
+	
+	@Autowired
+	private TokenStore tokenStore;
+
+	@Autowired
+	private RestTemplate restTemplate;
+
+	@Autowired
+	private ObjectMapper objectMapper;
+
+	@Autowired
+	private SysUserService userService;
+
+    @PostMapping(value = "/smsLogin",consumes = MediaType.APPLICATION_JSON_VALUE)
+	@ApiOperation(value = "短信验证码的方式登录")
+	@ApiImplicitParams({ @ApiImplicitParam(name = "smsCode", value = "验证码", required = true, dataType = "String"),
+			@ApiImplicitParam(name = "clientSecret", value = "固定传 app", required = true, dataType = "String"),
+			@ApiImplicitParam(name = "clientId", value = "固定传 app", required = true, dataType = "String"),
+			@ApiImplicitParam(name = "phone", value = "手机号", required = true, dataType = "String") })
+    public Object smsLogin() {
+		return succeed();
+    }
+
+    @GetMapping("/queryUserInfo")
+    public SysUser queryUserInfo() {
+		AuthUser authUser = SecurityUtils.getUser();
+		if(authUser != null){
+			SysUser sysUser = userService.get(authUser.getUserId());
+			return userService.get(authUser.getUserId());
+		}
+		return null;
+    }
+
+	@ApiOperation(value = "获取用户信息")
+    @GetMapping("/api/queryUserInfo")
+    public Object apiQueryUserInfo() {
+		AuthUser authUser = SecurityUtils.getUser();
+		if(authUser != null){
+			return succeed(userService.queryUserInfo(authUser.getUserId()));
+		}
+		return failed("获取用户信息失败");
+    }
+    
+    @PostMapping(value = "/usernameLogin",consumes = MediaType.APPLICATION_JSON_VALUE)
+	@ApiOperation(value = "手机号密码方式登录")
+	@ApiImplicitParams({ @ApiImplicitParam(name = "password", value = "密码", required = true, dataType = "String"),
+			@ApiImplicitParam(name = "clientSecret", value = "固定传 app", required = true, dataType = "String"),
+			@ApiImplicitParam(name = "clientId", value = "固定传 app", required = true, dataType = "String"),
+			@ApiImplicitParam(name = "username", value = "手机号", required = true, dataType = "String") })
+    public Object usernameLogin() {
+		return succeed();
+    }
+
+	@PostMapping(value = "/refreshToken",consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
+	@ApiOperation(value = "刷新token")
+	public HttpResponseResult refreshToken(String refreshToken, String clientId, String clientSecret) throws IOException {
+		String url = "http://auth-server/oauth/token";
+
+		String base64ClientCredentials = Base64.getEncoder().encodeToString((clientId + ":" + clientSecret).getBytes());
+
+		HttpHeaders headers = new HttpHeaders();
+		headers.add("Authorization", "Basic " + base64ClientCredentials);
+		headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
+
+		MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();
+		params.add("refresh_token", refreshToken);
+		params.add("grant_type", "refresh_token");
+		params.add("client_id", clientId);
+		params.add("client_secret", clientSecret);
+
+		HttpEntity<MultiValueMap<String, String>> entity = new HttpEntity<MultiValueMap<String, String>>(params, headers);
+
+		ResponseEntity<String> resp = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);
+
+		return succeed(objectMapper.readValue(resp.getBody(), Map.class));
+	}
+
+	@PostMapping(value = "exit",consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
+	@ApiOperation(value = "退出登录")
+	public HttpResponseResult<String> logout(HttpServletRequest request) {
+		
+		String authHeader = request.getHeader(HttpHeaders.AUTHORIZATION);
+		if (StringUtils.isBlank(authHeader)) {
+			return failed("退出失败,token 为空");
+		}
+
+		String tokenValue = authHeader.toLowerCase().replace(OAuth2AccessToken.BEARER_TYPE.toLowerCase(), StringUtils.EMPTY).trim();
+
+		tokenService.revokeToken(tokenValue);
+
+		return succeed("退出成功");
+	}
+
+	@PostMapping(value = "exit/{clientId}/{phone}", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
+	@ApiOperation(value = "指定用户退出登录")
+	public HttpResponseResult<String> exitByPhone(@PathVariable("clientId") String clientId, @PathVariable("phone") String phone) {
+
+		Collection<OAuth2AccessToken> list = tokenStore.findTokensByClientIdAndUserName(clientId, SecurityConstants.PHONE_PRINCIPAL_PREFIX + phone);
+
+		if (list == null || list.size() == 0) {
+			list = tokenStore.findTokensByClientIdAndUserName(clientId, SecurityConstants.USERNAME_PRINCIPAL_PREFIX + phone);
+		} else {
+			list.addAll(tokenStore.findTokensByClientIdAndUserName(clientId, SecurityConstants.USERNAME_PRINCIPAL_PREFIX + phone));
+		}
+		if (list != null) {
+			for (OAuth2AccessToken accessToken : list) {
+				if (accessToken != null) {
+					if (accessToken.getRefreshToken() != null) {
+						tokenStore.removeRefreshToken(accessToken.getRefreshToken());
+					}
+					tokenStore.removeAccessToken(accessToken);
+				}
+			}
+		}
+
+		return succeed("退出成功");
+	}
+
+	@GetMapping(value = "/checkToken",consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
+	@ApiOperation(value = "检查token")
+	public HttpResponseResult<Object> checkToken(HttpServletRequest request) throws IOException {
+
+		String authHeader = request.getHeader(HttpHeaders.AUTHORIZATION);
+		if (StringUtils.isBlank(authHeader)) {
+			return failed(HttpStatus.FORBIDDEN, "token 为空");
+		}
+
+		String tokenValue = authHeader.toLowerCase().replace(OAuth2AccessToken.BEARER_TYPE.toLowerCase(), StringUtils.EMPTY).trim();
+
+		OAuth2AccessToken accessToken = resourceServerTokenServices.readAccessToken(tokenValue);
+		if (accessToken == null) {
+			return failed(HttpStatus.FORBIDDEN, "token 无效");
+		}
+
+		if (accessToken.isExpired()) {
+			return failed(HttpStatus.FORBIDDEN, "token 已过期");
+		}
+
+		return succeed();
+	}
+
+}

+ 350 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/web/controller/UserController.java

@@ -0,0 +1,350 @@
+package com.yonge.cooleshow.auth.web.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+
+import java.util.Date;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.MediaType;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.ym.mec.thirdparty.user.realname.RealnameAuthenticationPluginContext;
+import com.ym.mec.thirdparty.user.realname.provider.LinkfaceRealnameAuthenticationPlugin;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.auth.service.SysRoleService;
+import com.yonge.cooleshow.auth.service.SysUserRoleService;
+import com.yonge.cooleshow.auth.service.SysUserService;
+import com.yonge.cooleshow.auth.web.controller.queryInfo.SysUserQueryInfo;
+import com.yonge.cooleshow.common.controller.BaseController;
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import com.yonge.cooleshow.common.entity.ImResult;
+import com.yonge.cooleshow.common.entity.ImUserModel;
+import com.yonge.cooleshow.common.exception.BizException;
+import com.yonge.cooleshow.common.page.QueryInfo;
+import com.yonge.cooleshow.common.security.AuthUser;
+import com.yonge.cooleshow.common.security.SecurityConstants;
+import com.yonge.cooleshow.common.security.SecurityUtils;
+import com.yonge.cooleshow.common.service.IdGeneratorService;
+import com.yonge.toolset.utils.date.DateUtil;
+
+@RestController()
+@RequestMapping("user")
+@Api(tags = "会员服务")
+public class UserController extends BaseController {
+
+	@Autowired
+	private SysUserService sysUserService;
+	@Autowired
+	private SysRoleService sysRoleService;
+	/*@Autowired
+	private ImFeignService imFeignService;*/
+	@Autowired
+	private SysUserRoleService sysUserRoleService;
+	@Autowired
+	private IdGeneratorService smsCodeService;
+	@Value("${message.debugMode}")
+	private boolean debugMode;
+	@Autowired
+	private RealnameAuthenticationPluginContext realnameAuthenticationPluginContext;
+
+	@ApiOperation(value = "分页查询用户信息")
+	@ApiImplicitParams({ @ApiImplicitParam(name = "userType", value = "用户类型", required = false, dataType = "String"),
+			@ApiImplicitParam(name = "createStartDate", value = "开始注册时间", required = true, dataType = "String"),
+			@ApiImplicitParam(name = "createEndDate", value = "结束注册时间", required = true, dataType = "String") })
+	@GetMapping(value = "/queryPage")
+	@PreAuthorize("@pcs.hasPermissions('user/queryPage')")
+	public Object queryPage(SysUserQueryInfo queryInfo) {
+		return succeed(sysUserService.queryPage(queryInfo));
+	}
+
+	@ApiOperation(value = "查询用户信息接口")
+	@GetMapping("/query")
+	@PreAuthorize("@pcs.hasPermissions('user/query')")
+	public Object query() {
+		AuthUser user = SecurityUtils.getUser();
+		if (user != null) {
+			return succeed(sysUserService.get(user.getUserId()));
+		}
+		return failed();
+	}
+
+	@ApiOperation(value = "根据用户编号获取用户基本信息")
+	@GetMapping("/getBasic")
+	public Object getBasic(Integer userId) {
+		if (userId == null) {
+			return failed("参数校验异常");
+		}
+		return succeed(sysUserService.getBasic(userId));
+	}
+
+	@GetMapping(value = "/findByPhone")
+	public Object findByPhone(String mobile) {
+		return succeed(sysUserService.queryByPhone(mobile));
+	}
+
+	@GetMapping(value = "/queryUserByPhone")
+	public SysUser queryUserByPhone(String mobile) {
+		return sysUserService.queryByPhone(mobile);
+	}
+
+	@GetMapping(value = "/noAuth/queryUserByPhone")
+	public Object noAuthQueryUserByPhone(String mobile) {
+		SysUser sysUser = sysUserService.queryByPhone(mobile);
+		if(sysUser == null){
+			return succeed(0);
+		}
+		return succeed(1);
+	}
+
+	@GetMapping(value = "/queryUserById/{userId}")
+	public SysUser queryUserById(@PathVariable("userId") Integer userId) {
+		return sysUserService.get(userId);
+	}
+
+	@PostMapping(value = "/updateSysUser", consumes = MediaType.APPLICATION_JSON_VALUE)
+	public boolean updateSysUser(@RequestBody SysUser user) {
+		user.setUpdateTime(new Date());
+		sysUserService.update(user);
+		return true;
+	}
+
+	@ApiOperation(value = "新增用户")
+	@PostMapping(value = "/add", consumes = MediaType.APPLICATION_JSON_VALUE)
+	public HttpResponseResult<Integer> add(@RequestBody SysUser sysUser) {
+		return succeed(sysUserService.add(sysUser));
+	}
+
+	@ApiOperation(value = "设置密码")
+	@PostMapping(value = "/setPassword", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
+	@ApiImplicitParams({@ApiImplicitParam(name = "password", value = "密码", required = true, dataType = "String"),
+			@ApiImplicitParam(name = "username", value = "用户名", required = true, dataType = "String") })
+	public Object setPassword(String password, String username) {
+		if (StringUtils.isEmpty(password)) {
+			return failed("参数校验失败");
+		}
+		AuthUser authUser = SecurityUtils.getUser();
+		if (authUser == null) {
+			return failed("获取用户信息失败");
+		}
+		SysUser sysUser = sysUserService.get(authUser.getUserId());
+		if (sysUser == null) {
+			return failed("用户不存在");
+		}
+		if(sysUser.getUserType().contains("TEACHER") || sysUser.getUserType().contains("SYSTEM")){
+			sysUser.setRealName(username);
+		}else {
+			sysUser.setUsername(username);
+		}
+		/*if(StringUtils.isEmpty(sysUser.getImToken())){
+			ImResult register = imFeignService.register(new ImUserModel(sysUser.getId().toString(), username, sysUser.getAvatar()));
+			sysUser.setImToken(register.getToken());
+		}else {
+			imFeignService.update(new ImUserModel(sysUser.getId().toString(),username,sysUser.getAvatar()));
+		}*/
+		password = new BCryptPasswordEncoder().encode(password);
+		sysUser.setPassword(password);
+		sysUser.setUpdateTime(new Date());
+		sysUserService.update(sysUser);
+		return succeed();
+	}
+
+	@ApiOperation(value = "修改密码")
+	@PostMapping(value = "/updatePassword", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
+	@ApiImplicitParams({ @ApiImplicitParam(name = "mobile", value = "手机号", required = true, dataType = "String"),
+			@ApiImplicitParam(name = "authCode", value = "验证码", required = true, dataType = "String"),
+			@ApiImplicitParam(name = "newPassword", value = "新密码", required = true, dataType = "String") })
+	public Object updatePassword(String mobile, String authCode, String newPassword) {
+		if (StringUtils.isEmpty(mobile) || StringUtils.isEmpty(authCode) || StringUtils.isEmpty(newPassword)) {
+			return failed("参数校验异常");
+		}
+		SysUser sysUser = sysUserService.queryByPhone(mobile);
+		if (sysUser == null) {
+			return failed("用户不存在");
+		}
+		if (smsCodeService.verifyValidCode(mobile, authCode)) {
+			String password = new BCryptPasswordEncoder().encode(newPassword);
+			sysUser.setPassword(password);
+			sysUser.setUpdateTime(new Date());
+			sysUserService.update(sysUser);
+			return succeed();
+		} else {
+			return failed("验证码错误");
+		}
+	}
+
+
+	@ApiOperation(value = "修改手机号")
+	@PostMapping(value = "/updatePhone")
+	public Object updatePhone(String oldPhone, String authCode, String newPhone) {
+		if (StringUtils.isEmpty(oldPhone) || StringUtils.isEmpty(authCode) || StringUtils.isEmpty(newPhone)) {
+			return failed("参数校验异常");
+		}
+		if(oldPhone.equals(newPhone)){
+			return failed("新旧手机号一致");
+		}
+		SysUser sysUser = sysUserService.queryByPhone(oldPhone);
+		if (sysUser == null) {
+			return failed("用户不存在");
+		}
+		SysUser newSysUser = sysUserService.queryByPhone(newPhone);
+		if (newSysUser != null) {
+			return failed("手机号被占用");
+		}
+		if (smsCodeService.verifyValidCode(newPhone, authCode)) {
+			sysUser.setPhone(newPhone);
+			sysUser.setUpdateTime(new Date());
+			sysUserService.update(sysUser);
+			return succeed();
+		} else {
+			return failed("验证码错误");
+		}
+	}
+
+	@ApiOperation(value = "修改密码")
+	@PostMapping(value = "/updatePassword2", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
+	@ApiImplicitParams({ @ApiImplicitParam(name = "mobile", value = "手机号", required = true, dataType = "String"),
+			@ApiImplicitParam(name = "userId", value = "用户编号", required = true, dataType = "Integer"),
+			@ApiImplicitParam(name = "newPassword", value = "新密码", required = true, dataType = "String") })
+	public Object updatePassword2(Integer userId, String mobile, String newPassword) {
+		if (StringUtils.isEmpty(mobile) || userId == null || StringUtils.isEmpty(newPassword)) {
+			return failed("参数校验异常");
+		}
+		SysUser sysUser = sysUserService.queryByPhone(mobile);
+		if (sysUser == null) {
+			return failed("用户不存在");
+		}
+		if (sysUser.getId().intValue() != userId) {
+			return failed("非法操作");
+		}
+		String password = new BCryptPasswordEncoder().encode(newPassword);
+		sysUser.setPassword(password);
+		sysUser.setUpdateTime(new Date());
+		sysUserService.update(sysUser);
+		return succeed();
+	}
+
+	@ApiOperation(value = "修改用户")
+	@PostMapping(value = "/update", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
+	public Object update(SysUser sysUser) {
+		AuthUser user = SecurityUtils.getUser();
+		if (user != null) {
+			Date date = new Date();
+			sysUser.setId(user.getUserId());
+			sysUser.setUpdateTime(date);
+			if(sysUser.getBirthdate() != null && DateUtil.daysBetween(sysUser.getBirthdate(),date) <= 0){
+				throw new BizException("出生日期不可超过当前时间");
+			}
+
+			if(!debugMode&&StringUtils.isNotBlank(sysUser.getCertificateType())&&"IDENTITY".equals(sysUser.getCertificateType())){
+				realnameAuthenticationPluginContext.getRealnameAuthenticationPlugin(LinkfaceRealnameAuthenticationPlugin.getName()).verify(sysUser.getRealName(), sysUser.getIdCardNo());
+			}
+
+			sysUserService.updateBaseInfo(sysUser);
+			return succeed();
+		}
+		return failed();
+	}
+
+	@ApiOperation(value = "刷新token")
+	@PostMapping(value = "/refreshImToken")
+	public Object refreshImToken() {
+		AuthUser user = SecurityUtils.getUser();
+		if (user != null) {
+			SysUser sysUser = sysUserService.get(user.getUserId());
+			String username;
+			if(sysUser.getUserType().contains("TEACHER") || sysUser.getUserType().contains("SYSTEM")){
+				username = sysUser.getRealName();
+			}else {
+				username = sysUser.getUsername();
+			}
+			if(StringUtils.isEmpty(username)){
+				return failed("获取Token失败: 用户名为空");
+			}else {
+				/*ImResult register = imFeignService.register(new ImUserModel(sysUser.getId().toString(), username, sysUser.getAvatar()));
+				if(StringUtils.isEmpty(register.getToken())){
+					return failed("获取Token失败: 请联系教务老师");
+				}
+				sysUser.setImToken(register.getToken());
+				sysUserService.refreshImToken(sysUser);
+				return succeed(register.getToken());*/
+			}
+		}
+		return failed();
+	}
+
+	@ApiOperation(value = "校验用户手机号和密码")
+	@GetMapping(value = "/checkUser")
+	public Object checkUser(String phone,String password) {
+		if(StringUtils.isEmpty(phone) || StringUtils.isEmpty(password)){
+			throw new BizException("请录入用户名和密码");
+		}
+		AuthUser user = SecurityUtils.getUser();
+		if (user != null) {
+			SysUser sysUser = sysUserService.get(user.getUserId());
+			if(!sysUser.getPhone().equals(phone)){
+				return failed("手机号校验失败");
+			}
+			if(new BCryptPasswordEncoder().matches(password,sysUser.getPassword())){
+				return succeed();
+			}else {
+				return failed("密码校验失败");
+			}
+		}
+		return failed();
+	}
+
+	@ApiOperation(value = "获取用户角色列表")
+	@GetMapping("/getRole")
+	@PreAuthorize("@pcs.hasPermissions('user/getRole')")
+	public Object getRole() {
+		AuthUser user = SecurityUtils.getUser();
+		if (user != null) {
+			SysUser sysUser = sysUserService.get(user.getUserId());
+			if(sysUser.getIsSuperAdmin()){
+				QueryInfo queryInfo = new QueryInfo();
+				queryInfo.setRows(9999);
+				return succeed(sysRoleService.queryPage(queryInfo).getRows());
+			}
+			return succeed(sysRoleService.findRoleByUserId(user.getUserId()));
+		}
+		return failed();
+	}
+
+	@ApiOperation(value = "用户角色新增")
+	@ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "用户编号", required = true, dataType = "Integer"),
+			@ApiImplicitParam(name = "roleIds", value = "角色id,逗号分隔", required = true, dataType = "String") })
+	@PostMapping(value = "/addRole", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
+	@PreAuthorize("@pcs.hasPermissions('user/addRole')")
+	public Object getRole(String userId, String roleIds) {
+		if (StringUtils.isEmpty(userId) || StringUtils.isEmpty(roleIds)) {
+			return failed(SecurityConstants.PARAM_VERIFY_EXCEPTION);
+		}
+		sysUserRoleService.batchInsert(Integer.parseInt(userId), roleIds);
+		return succeed();
+	}
+
+	@ApiOperation(value = "用户角色删除")
+	@ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "用户编号", required = true, dataType = "Integer"),
+			@ApiImplicitParam(name = "roleIds", value = "角色id,逗号分隔", required = true, dataType = "String") })
+	@PostMapping(value = "/delRole", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
+	@PreAuthorize("@pcs.hasPermissions('user/delRole')")
+	public Object delRole(String userId, String roleIds) {
+		if (StringUtils.isEmpty(userId) || StringUtils.isEmpty(roleIds)) {
+			return failed(SecurityConstants.PARAM_VERIFY_EXCEPTION);
+		}
+		sysUserRoleService.batchDel(Integer.parseInt(userId), roleIds);
+		return succeed();
+	}
+}

+ 42 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/web/controller/UserDeviceController.java

@@ -0,0 +1,42 @@
+package com.yonge.cooleshow.auth.web.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.yonge.cooleshow.auth.service.SysUserDeviceService;
+import com.yonge.cooleshow.auth.service.SysUserService;
+import com.yonge.cooleshow.auth.web.controller.queryInfo.SysUserDeviceQueryInfo;
+import com.yonge.cooleshow.common.controller.BaseController;
+import com.yonge.toolset.log.model.AuditLogAnnotation;
+
+@RestController()
+@RequestMapping("userDevice")
+@Api(tags = "会员设备服务")
+public class UserDeviceController extends BaseController {
+
+	@Autowired
+	private SysUserService sysUserService;
+	
+	@Autowired
+	private SysUserDeviceService sysUserDeviceService;
+
+	@ApiOperation(value = "分页查询用户信息")
+	@GetMapping(value = "/queryPage")
+	public Object queryPage(SysUserDeviceQueryInfo queryInfo) {
+		return succeed(sysUserDeviceService.queryPage(queryInfo));
+	}
+
+	@ApiOperation(value = "设备号解除绑定")
+	@PostMapping(value = "/unbind")
+	@AuditLogAnnotation(operateName = "设备号解除绑定",interfaceURL = "userDevice/unbind")
+	public Object unbind(Integer id) {
+		return succeed(sysUserDeviceService.deleteWithLogic(id));
+	}
+
+}

+ 38 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/web/controller/queryInfo/SysUserDeviceQueryInfo.java

@@ -0,0 +1,38 @@
+package com.yonge.cooleshow.auth.web.controller.queryInfo;
+
+import java.util.Date;
+
+import com.yonge.cooleshow.common.page.QueryInfo;
+
+public class SysUserDeviceQueryInfo extends QueryInfo {
+
+	private String deviceNum;
+
+	private Date bindStartTime;
+
+	private Date bindEndTime;
+
+	public String getDeviceNum() {
+		return deviceNum;
+	}
+
+	public void setDeviceNum(String deviceNum) {
+		this.deviceNum = deviceNum;
+	}
+
+	public Date getBindStartTime() {
+		return bindStartTime;
+	}
+
+	public void setBindStartTime(Date bindStartTime) {
+		this.bindStartTime = bindStartTime;
+	}
+
+	public Date getBindEndTime() {
+		return bindEndTime;
+	}
+
+	public void setBindEndTime(Date bindEndTime) {
+		this.bindEndTime = bindEndTime;
+	}
+}

+ 36 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/web/controller/queryInfo/SysUserQueryInfo.java

@@ -0,0 +1,36 @@
+package com.yonge.cooleshow.auth.web.controller.queryInfo;
+
+import com.yonge.cooleshow.common.page.QueryInfo;
+
+public class SysUserQueryInfo extends QueryInfo {
+
+	private String userType;
+
+	private String createStartDate;
+
+	private String createEndDate;
+
+	public String getUserType() {
+		return userType;
+	}
+
+	public void setUserType(String userType) {
+		this.userType = userType;
+	}
+
+	public String getCreateStartDate() {
+		return createStartDate;
+	}
+
+	public void setCreateStartDate(String createStartDate) {
+		this.createStartDate = createStartDate;
+	}
+
+	public String getCreateEndDate() {
+		return createEndDate;
+	}
+
+	public void setCreateEndDate(String createEndDate) {
+		this.createEndDate = createEndDate;
+	}
+}

+ 16 - 0
cooleshow-auth/auth-server/src/main/resources/bootstrap-dev.properties

@@ -0,0 +1,16 @@
+#\u6307\u5b9a\u5f00\u53d1\u73af\u5883
+#spring.profiles.active=dev
+#\u670d\u52a1\u5668\u5730\u5740
+spring.cloud.nacos.config.server-addr=47.114.1.200:8848
+#\u9ed8\u8ba4\u4e3aPublic\u547d\u540d\u7a7a\u95f4,\u53ef\u4ee5\u7701\u7565\u4e0d\u5199
+spring.cloud.nacos.config.namespace=a5c10b43-0c4d-4e3b-a0ad-9af651cfe89c
+#\u6307\u5b9a\u914d\u7f6e\u7fa4\u7ec4 --\u5982\u679c\u662fPublic\u547d\u540d\u7a7a\u95f4 \u5219\u53ef\u4ee5\u7701\u7565\u7fa4\u7ec4\u914d\u7f6e
+spring.cloud.nacos.config.group=DEFAULT_GROUP
+#\u6587\u4ef6\u540d -- \u5982\u679c\u6ca1\u6709\u914d\u7f6e\u5219\u9ed8\u8ba4\u4e3a ${spring.appliction.name}
+spring.cloud.nacos.config.prefix=auth
+#\u6307\u5b9a\u6587\u4ef6\u540e\u7f00
+spring.cloud.nacos.config.file-extension=yaml
+#\u662f\u5426\u52a8\u6001\u5237\u65b0
+spring.cloud.nacos.config.refresh.enabled=true
+#\u662f\u5426\u542f\u7528nacos\u914d\u7f6e\u4e2d\u5fc3
+spring.cloud.nacos.config.enabled=true

+ 21 - 0
cooleshow-auth/auth-server/src/main/resources/config/mybatis/Global.mapper.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="global">
+
+	<sql id="limit">
+		<if test="offset != null">
+			 limit #{offset},#{rows}
+		</if>
+	</sql>
+
+	<sql id="orderby">
+		<if test="sort != null and sort != ''">
+			 ORDER BY ${sort}
+			 <if test="order != null and order != ''">
+			 	${order}
+			 </if>
+		</if>
+	</sql>	
+ </mapper>

+ 187 - 0
cooleshow-auth/auth-server/src/main/resources/config/mybatis/SysMenuMapper.xml

@@ -0,0 +1,187 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!--
+这个文件是自动生成的。
+不要修改此文件。所有改动将在下次重新自动生成时丢失。
+-->
+<mapper namespace="com.yonge.cooleshow.auth.dal.dao.SysMenuDao">
+
+    <resultMap type="com.yonge.cooleshow.auth.api.entity.SysMenu" id="SysMenu">
+        <result column="id_" property="id"/>
+        <result column="name_" property="name"/>
+        <result column="permission_" property="permission"/>
+        <result column="parent_permission_" property="parentPermission"/>
+        <result column="path_" property="path"/>
+        <result column="parent_id_" property="parentId"/>
+        <result column="icon_" property="icon"/>
+        <result column="component_" property="component"/>
+        <result column="sort_" property="sort"/>
+        <result column="keep_alive_" property="keepAlive"/>
+        <result column="type_" property="type"/>
+        <result column="type_" property="type"/>
+        <result column="create_time_" property="createTime"/>
+        <result column="update_time_" property="updateTime"/>
+        <result column="del_flag_" property="delFlag"/>
+        <result column="hidden_" property="hid"/>
+        <result column="memo_" property="memo"/>
+    </resultMap>
+
+    <!-- 根据主键查询一条记录 -->
+    <select id="get" resultMap="SysMenu">
+		SELECT * FROM sys_menu WHERE id_ = #{id}
+	</select>
+
+    <!-- 全查询 -->
+    <select id="findAll" resultMap="SysMenu">
+		SELECT * FROM sys_menu ORDER BY id_
+	</select>
+
+    <!-- 向数据库增加一条记录 -->
+    <insert id="insert" parameterType="com.yonge.cooleshow.auth.api.entity.SysMenu" useGeneratedKeys="true" keyColumn="id"
+            keyProperty="id">
+        INSERT INTO sys_menu
+        (id_,name_,permission_,path_,parent_id_,icon_,component_,sort_,type_,create_time_,update_time_,hidden_,parent_permission_,memo_,keep_alive_)
+        VALUES(#{id},#{name},#{permission},#{path},#{parentId},#{icon},#{component},#{sort},#{type},now(),now(),#{hid},#{parentPermission},#{memo},#{keepAlive})
+    </insert>
+
+    <!-- 根据主键查询一条记录 -->
+    <update id="update" parameterType="com.yonge.cooleshow.auth.api.entity.SysMenu">
+        UPDATE sys_menu
+        <set>
+            <if test="parentId != null">
+                parent_id_ = #{parentId},
+            </if>
+            <if test="delFlag != null">
+                del_flag_ = #{delFlag},
+            </if>
+            <if test="keepAlive != null">
+                keep_alive_ = #{keepAlive},
+            </if>
+            <if test="permission != null">
+                permission_ = #{permission},
+            </if>
+            <if test="parentPermission != null">
+                parent_permission_ = #{parentPermission},
+            </if>
+            <if test="path != null">
+                path_ = #{path},
+            </if>
+            <if test="sort != null">
+                sort_ = #{sort},
+            </if>
+            <if test="name != null">
+                name_ = #{name},
+            </if>
+            <if test="icon != null">
+                icon_ = #{icon},
+            </if>
+            <if test="component != null">
+                component_ = #{component},
+            </if>
+            <if test="updateTime != null">
+                update_time_ = NOW(),
+            </if>
+            <if test="type != null">
+                type_ = #{type},
+            </if>
+            <if test="hid != null">
+                hidden_ = #{hid},
+            </if>
+            <if test="memo != null">
+                memo_ = #{memo},
+            </if>
+        </set>
+        WHERE id_ = #{id}
+    </update>
+
+    <!-- 根据主键删除一条记录 -->
+    <update id="delete">
+		UPDATE sys_menu SET del_flag_ = 1 WHERE id_ = #{id}
+	</update>
+
+    <update id="batchDel" parameterType="java.util.List">
+        UPDATE sys_menu SET del_flag_ = 1 WHERE id_ IN
+        <foreach collection="list" item="item" open="(" separator="," close=")">
+          #{item}
+        </foreach>
+    </update>
+
+    <!-- 分页查询 -->
+    <select id="queryPage" resultMap="SysMenu" parameterType="map">
+        SELECT sm.* FROM sys_user_role sur
+        LEFT JOIN sys_role_menu srm ON sur.role_id_ = srm.role_id_
+        LEFT JOIN sys_menu sm ON srm.menu_id_ = sm.id_
+        <include refid="queryTree"/>
+        GROUP BY sm.id_
+        ORDER BY sm.sort_ DESC
+        <include refid="global.limit"/>
+    </select>
+
+    <!-- 查询当前表的总记录数 -->
+    <select id="queryCount" resultType="int">
+        SELECT COUNT(DISTINCT sm.id_) FROM sys_user_role sur
+        LEFT JOIN sys_role_menu srm ON sur.role_id_ = srm.role_id_
+        LEFT JOIN sys_menu sm ON srm.menu_id_ = sm.id_
+        <include refid="queryTree"/>
+	</select>
+
+    <select id="getMenusByRoleId" resultMap="SysMenu">
+		SELECT sm.* FROM sys_role_menu srm
+		LEFT JOIN sys_menu sm ON srm.menu_id_ = sm.id_
+		WHERE srm.role_id_ = #{roleId} AND sm.del_flag_ = 0
+	</select>
+
+    <select id="findByUser" resultMap="SysMenu">
+		SELECT sm.* FROM sys_user_role sur
+		LEFT JOIN sys_role sr ON sur.role_id_ = sr.id_
+		LEFT JOIN sys_role_menu srm ON sr.id_ = srm.role_id_
+		LEFT JOIN sys_menu sm ON srm.menu_id_ = sm.id_
+		WHERE sur.user_id_ = #{userId} AND sr.del_flag_ = 0 AND sm.del_flag_ = 0
+	</select>
+
+    <!-- 根据权限标识查菜单 -->
+    <select id="findMenuByPermission" resultMap="SysMenu">
+        SELECT * FROM `sys_menu` WHERE `permission_` = #{permission} AND del_flag_ = 0
+    </select>
+    <sql id="queryTree">
+        <where>
+            <if test="userId != null">
+                AND sur.user_id_ = #{userId}
+            </if>
+            <if test="hid != null">
+                AND sm.hidden_ = #{hid}
+            </if>
+            <if test="delFlag != null">
+                AND sm.del_flag_ = #{delFlag}
+            </if>
+            <if test="parentId != null">
+                AND sm.parent_id_ = #{parentId}
+            </if>
+        </where>
+    </sql>
+
+    <select id="findByParentId" resultMap="SysMenu">
+        SELECT sm.* FROM sys_menu sm
+        LEFT JOIN sys_role_menu srm ON srm.menu_id_ = sm.id_
+        LEFT JOIN sys_user_role sur ON sur.role_id_ = srm.role_id_
+        <include refid="queryTree"/>
+        GROUP BY sm.id_
+        ORDER BY sm.sort_ DESC,sm.id_ DESC
+    </select>
+
+    <select id="findList" resultMap="SysMenu">
+        SELECT * FROM sys_menu
+        <where>
+            <if test="delFlag != null">
+                AND del_flag_ = #{delFlag}
+            </if>
+            <if test="parentId != null">
+                AND parent_id_ = #{parentId}
+            </if>
+            <if test="hid != null">
+                AND hidden_ = #{hid}
+            </if>
+        </where>
+        ORDER BY sort_ DESC,id_ DESC
+    </select>
+</mapper>

+ 99 - 0
cooleshow-auth/auth-server/src/main/resources/config/mybatis/SysOauthClientDetailsMapper.xml

@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!--
+这个文件是自动生成的。
+不要修改此文件。所有改动将在下次重新自动生成时丢失。
+-->
+<mapper namespace="com.yonge.cooleshow.auth.dal.dao.SysOauthClientDetailsDao">
+
+    <resultMap type="com.yonge.cooleshow.auth.api.entity.SysOauthClientDetails" id="SysOauthClientDetails">
+        <result column="id_" property="id"/>
+        <result column="resource_ids_" property="resourceIds"/>
+        <result column="client_secret_" property="clientSecret"/>
+        <result column="scope_" property="scope"/>
+        <result column="authorized_grant_types_" property="authorizedGrantTypes"/>
+        <result column="web_server_redirect_uri_" property="webServerRedirectUri"/>
+        <result column="authorities_" property="authorities"/>
+        <result column="access_token_validity_" property="accessTokenValidity"/>
+        <result column="refresh_token_validity_" property="refreshTokenValidity"/>
+        <result column="additional_information_" property="additionalInformation"/>
+        <result column="autoapprove_" property="autoapprove"/>
+    </resultMap>
+
+    <!-- 根据主键查询一条记录 -->
+    <select id="get" resultMap="SysOauthClientDetails">
+		SELECT * FROM sys_oauth_client_details WHERE id_ = #{id}
+	</select>
+
+    <!-- 全查询 -->
+    <select id="findAll" resultMap="SysOauthClientDetails">
+		SELECT * FROM sys_oauth_client_details ORDER BY id_
+	</select>
+
+    <!-- 向数据库增加一条记录 -->
+    <insert id="insert" parameterType="com.yonge.cooleshow.auth.api.entity.SysOauthClientDetails" useGeneratedKeys="true"
+            keyColumn="id" keyProperty="id">
+        <!--
+        <selectKey resultClass="int" keyProperty="id" >
+        SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
+        </selectKey>
+        -->
+        INSERT INTO sys_oauth_client_details
+        (id_,resource_ids_,client_secret_,scope_,authorized_grant_types_,web_server_redirect_uri_,authorities_,access_token_validity_,refresh_token_validity_,additional_information_,autoapprove_)
+        VALUES(#{id},#{resourceIds},#{clientSecret},#{scope},#{authorizedGrantTypes},#{webServerRedirectUri},#{authorities},#{accessTokenValidity},#{refreshTokenValidity},#{additionalInformation},#{autoapprove})
+    </insert>
+
+    <!-- 根据主键查询一条记录 -->
+    <update id="update" parameterType="com.yonge.cooleshow.auth.api.entity.SysOauthClientDetails">
+        UPDATE sys_oauth_client_details
+        <set>
+            <if test="accessTokenValidity != null">
+                access_token_validity_ = #{accessTokenValidity},
+            </if>
+            <if test="resourceIds != null">
+                resource_ids_ = #{resourceIds},
+            </if>
+            <if test="refreshTokenValidity != null">
+                refresh_token_validity_ = #{refreshTokenValidity},
+            </if>
+            <if test="additionalInformation != null">
+                additional_information_ = #{additionalInformation},
+            </if>
+            <if test="clientSecret != null">
+                client_secret_ = #{clientSecret},
+            </if>
+            <if test="webServerRedirectUri != null">
+                web_server_redirect_uri_ = #{webServerRedirectUri},
+            </if>
+            <if test="authorizedGrantTypes != null">
+                authorized_grant_types_ = #{authorizedGrantTypes},
+            </if>
+            <if test="authorities != null">
+                authorities_ = #{authorities},
+            </if>
+            <if test="scope != null">
+                scope_ = #{scope},
+            </if>
+            <if test="autoapprove != null">
+                autoapprove_ = #{autoapprove},
+            </if>
+        </set>
+        WHERE id_ = #{id}
+    </update>
+
+    <!-- 根据主键删除一条记录 -->
+    <delete id="delete">
+		DELETE FROM sys_oauth_client_details WHERE id_ = #{id}
+	</delete>
+
+    <!-- 分页查询 -->
+    <select id="queryPage" resultMap="SysOauthClientDetails" parameterType="map">
+        SELECT * FROM sys_oauth_client_details ORDER BY id_
+        <include refid="global.limit"/>
+    </select>
+
+    <!-- 查询当前表的总记录数 -->
+    <select id="queryCount" resultType="int">
+		SELECT COUNT(*) FROM sys_oauth_client_details
+	</select>
+</mapper>

+ 89 - 0
cooleshow-auth/auth-server/src/main/resources/config/mybatis/SysRoleMapper.xml

@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!--
+这个文件是自动生成的。
+不要修改此文件。所有改动将在下次重新自动生成时丢失。
+-->
+<mapper namespace="com.yonge.cooleshow.auth.dal.dao.SysRoleDao">
+
+    <resultMap type="com.yonge.cooleshow.auth.api.entity.SysRole" id="SysRole">
+        <result column="id_" property="id"/>
+        <result column="role_name_" property="roleName"/>
+        <result column="role_code_" property="roleCode"/>
+        <result column="role_desc_" property="roleDesc"/>
+        <result column="create_time_" property="createTime"/>
+        <result column="update_time_" property="updateTime"/>
+        <result column="del_flag_" property="delFlag"/>
+        <result column="organ_id_" property="organId"/>
+    </resultMap>
+
+    <!-- 根据主键查询一条记录 -->
+    <select id="get" resultMap="SysRole">
+		SELECT * FROM sys_role WHERE id_ = #{id}
+	</select>
+
+    <!-- 全查询 -->
+    <select id="findAll" resultMap="SysRole">
+		SELECT * FROM sys_role WHERE del_flag_ = 0 ORDER BY upate_time_ DESC
+	</select>
+
+    <!-- 向数据库增加一条记录 -->
+    <insert id="insert" parameterType="com.yonge.cooleshow.auth.api.entity.SysRole" useGeneratedKeys="true" keyColumn="id"
+            keyProperty="id">
+        INSERT INTO sys_role (id_,role_name_,role_code_,role_desc_,create_time_,update_time_,organ_id_)
+        VALUES(#{id},#{roleName},#{roleCode},#{roleDesc},now(),now(),#{organId})
+    </insert>
+
+    <!-- 根据主键查询一条记录 -->
+    <update id="update" parameterType="com.yonge.cooleshow.auth.api.entity.SysRole">
+        UPDATE sys_role
+        <set>
+            <if test="delFlag != null">
+                del_flag_ = #{delFlag},
+            </if>
+            <if test="roleCode != null">
+                role_code_ = #{roleCode},
+            </if>
+            <if test="roleName != null">
+                role_name_ = #{roleName},
+            </if>
+            <if test="roleDesc != null">
+                role_desc_ = #{roleDesc},
+            </if>
+            <if test="updateTime != null">
+                update_time_ = NOW(),
+            </if>
+            <if test="organId != null">
+                organ_id_ = #{organId},
+            </if>
+        </set>
+        WHERE id_ = #{id}
+    </update>
+
+    <!-- 根据主键删除一条记录 -->
+    <delete id="delete">
+		UPDATE sys_role SET del_flag_ = 1 WHERE id_ = #{id}
+	</delete>
+
+    <!-- 分页查询 -->
+    <select id="queryPage" resultMap="SysRole" parameterType="map">
+        SELECT * FROM sys_role WHERE del_flag_ = 0 ORDER BY update_time_ DESC
+        <include refid="global.limit"/>
+    </select>
+
+    <!-- 查询当前表的总记录数 -->
+    <select id="queryCount" resultType="int">
+		SELECT COUNT(*) FROM sys_role WHERE del_flag_ = 0
+	</select>
+
+    <select id="findRoleByUserId" resultMap="SysRole">
+		SELECT sr.* FROM sys_user_role sur LEFT JOIN sys_role sr ON sur.role_id_ = sr.id_ WHERE sur.user_id_ = #{userId} AND sr.del_flag_ = 0
+	</select>
+
+    <select id="findRoleByCode" resultMap="SysRole">
+        SELECT sr.* FROM sys_role WHERE role_code_ = #{code} AND sr.del_flag_ = 0
+    </select>
+    <select id="findByRoleName" resultMap="SysRole">
+        SELECT * FROM sys_role WHERE role_name_ = #{roleName} AND del_flag_ = 0 LIMIT 1
+    </select>
+</mapper>

+ 65 - 0
cooleshow-auth/auth-server/src/main/resources/config/mybatis/SysRoleMenuMapper.xml

@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!--
+这个文件是自动生成的。
+不要修改此文件。所有改动将在下次重新自动生成时丢失。
+-->
+<mapper namespace="com.yonge.cooleshow.auth.dal.dao.SysRoleMenuDao">
+	
+	<resultMap type="com.yonge.cooleshow.auth.api.entity.SysRoleMenu" id="SysRoleMenu">
+		<result column="role_id_" property="roleId" />
+		<result column="menu_id_" property="menuId" />
+	</resultMap>
+	
+	<!-- 根据主键查询一条记录 -->
+	<select id="get" resultMap="SysRoleMenu" parameterType="java.util.Map">
+		SELECT * FROM sys_role_menu WHERE role_id_ = #{roleId} AND menu_id_ = #{menuId}
+	</select>
+	
+	<!-- 全查询 -->
+	<select id="findAll" resultMap="SysRoleMenu">
+		SELECT * FROM sys_role_menu ORDER BY role_id_,menu_id_
+	</select>
+	
+	<!-- 向数据库增加一条记录 -->
+	<insert id="insert" parameterType="com.yonge.cooleshow.auth.api.entity.SysRoleMenu" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+		<!--
+		<selectKey resultClass="int" keyProperty="id" > 
+		SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL 
+		</selectKey>
+		-->
+		INSERT INTO sys_role_menu (role_id_,menu_id_) VALUES(#{roleId},#{menuId})
+	</insert>
+    <insert id="batchAdd">
+		INSERT INTO sys_role_menu (role_id_,menu_id_) VALUES
+		<foreach collection="menuIds" item="item" index="index" separator=",">
+			(#{roleId},#{item})
+		</foreach>
+	</insert>
+
+    <!-- 根据主键删除一条记录 -->
+	<delete id="delete" parameterType="java.util.Map">
+		DELETE FROM sys_role_menu WHERE role_id_ = #{roleId} AND menu_id_ = #{menuId}
+	</delete>
+    <delete id="deleteAllMenu">
+		DELETE FROM sys_role_menu WHERE role_id_ = #{roleId}
+	</delete>
+
+    <!-- 分页查询 -->
+	<select id="queryPage" resultMap="SysRoleMenu" parameterType="map">
+		SELECT * FROM sys_role_menu ORDER BY role_id_,menu_id_ <include refid="global.limit"/>
+	</select>
+	
+	<!-- 查询当前表的总记录数 -->
+	<select id="queryCount" resultType="int">
+		SELECT COUNT(*) FROM sys_role_menu
+	</select>
+	
+	<select id="queryPermissionsByRoleId" resultType="string" parameterType="int">
+		SELECT m.permission_ FROM sys_role_menu rm left join sys_menu m on rm.menu_id_ = m.id_ where rm.role_id_ = #{roleId} and m.del_flag_ = 0
+	</select>
+
+	<select id="queryMenuIdByRoleId" resultType="integer" parameterType="int">
+		SELECT m.id_ FROM sys_role_menu rm left join sys_menu m on rm.menu_id_ = m.id_ where rm.role_id_ = #{roleId} and m.del_flag_ = 0
+	</select>
+</mapper>

+ 128 - 0
cooleshow-auth/auth-server/src/main/resources/config/mybatis/SysUserDeviceMapper.xml

@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!-- 这个文件是自动生成的。 不要修改此文件。所有改动将在下次重新自动生成时丢失。 -->
+<mapper namespace="com.yonge.cooleshow.auth.dal.dao.SysUserDeviceDao">
+
+	<resultMap type="com.yonge.cooleshow.auth.api.entity.SysUserDevice" id="SysUserDevice">
+		<result column="id_" property="id" />
+		<result column="user_id_" property="userId" />
+		<result column="device_num_" property="deviceNum" />
+		<result column="bind_time_" property="bindTime" />
+		<result column="device_type_" property="deviceType" />
+		<result column="client_id_" property="clientId" />
+		<result column="del_flag_" property="delFlag" />
+		<result column="update_time_" property="updateTime" />
+		<result column="phone_" property="user.phone" />
+		<result column="real_name_" property="user.realName" />
+	</resultMap>
+
+	<!-- 根据主键查询一条记录 -->
+	<select id="get" resultMap="SysUserDevice">
+		SELECT * FROM
+		sys_user_device WHERE id_ = #{id}
+	</select>
+
+	<!-- 全查询 -->
+	<select id="findAll" resultMap="SysUserDevice">
+		SELECT * FROM sys_user_device
+		ORDER BY id_
+	</select>
+
+	<!-- 向数据库增加一条记录 -->
+	<insert id="insert" parameterType="com.yonge.cooleshow.auth.api.entity.SysUserDevice"
+		useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+		<!-- <selectKey resultClass="int" keyProperty="id" > SELECT SEQ_WSDEFINITION_ID.nextval 
+			AS ID FROM DUAL </selectKey> -->
+		INSERT INTO sys_user_device
+		(id_,user_id_,device_num_,bind_time_,device_type_,client_id_,del_flag_)
+		VALUES(#{id},#{userId},#{deviceNum},#{bindTime},#{deviceType},#{clientId},0)
+	</insert>
+
+	<!-- 根据主键查询一条记录 -->
+	<update id="update" parameterType="com.yonge.cooleshow.auth.api.entity.SysUserDevice">
+		UPDATE sys_user_device
+		<set>
+			<if test="deviceType != null">
+				device_type_ = #{deviceType},
+			</if>
+			<if test="userId != null">
+				user_id_ = #{userId},
+			</if>
+			<if test="deviceNum != null">
+				device_num_ = #{deviceNum},
+			</if>
+			<if test="id != null">
+				id_ = #{id},
+			</if>
+			<if test="bindTime != null">
+				bind_time_ = #{bindTime},
+			</if>
+			<if test="clientId != null">
+				client_id_ = #{clientId},
+			</if>
+			<if test="delFlag != null">
+				del_flag_ = #{delFlag},
+			</if>
+			update_time_ = now()
+		</set>
+		WHERE id_ = #{id}
+	</update>
+
+	<!-- 根据主键删除一条记录 -->
+	<delete id="delete">
+		DELETE FROM sys_user_device WHERE id_ = #{id}
+	</delete>
+
+	<!-- 分页查询 -->
+	<select id="queryPage" resultMap="SysUserDevice" parameterType="map">
+		SELECT ud.*,u.phone_,u.real_name_ FROM sys_user_device ud left join sys_user u on ud.user_id_ = u.id_ 
+		where ud.del_flag_ = 0
+		<if test="search != null and search != ''">
+			and (u.real_name_ LIKE CONCAT('%',#{search},'%') OR u.phone_ LIKE CONCAT('%',#{search},'%') OR u.id_ like CONCAT('%',#{search},'%'))
+		</if>
+		<if test="deviceNum != null">
+			and device_num_ = #{deviceNum}
+		</if>
+		<if test="bindStartTime != null">
+			and date(bind_time_) &gt;= #{bindStartTime}
+		</if>
+		<if test="bindEndTime != null">
+			and date(bind_time_) &lt;= #{bindEndTime}
+		</if>
+		ORDER BY id_
+		<include refid="global.limit" />
+	</select>
+
+	<!-- 查询当前表的总记录数 -->
+	<select id="queryCount" resultType="int">
+		SELECT COUNT(ud.user_id_) FROM sys_user_device ud left join sys_user u on ud.user_id_ = u.id_
+		where ud.del_flag_ = 0
+		<if test="search != null and search != ''">
+			and (u.real_name_ LIKE CONCAT('%',#{search},'%') OR u.phone_ LIKE CONCAT('%',#{search},'%') OR u.id_ like CONCAT('%',#{search},'%'))
+		</if>
+		<if test="deviceNum != null">
+			and device_num_ = #{deviceNum}
+		</if>
+		<if test="bindStartTime != null">
+			and date(bind_time_) &gt;= #{bindStartTime}
+		</if>
+		<if test="bindEndTime != null">
+			and date(bind_time_) &lt;= #{bindEndTime}
+		</if>
+	</select>
+	
+	<select id="queryByUserId" resultMap="SysUserDevice" parameterType="map">
+		SELECT * FROM sys_user_device WHERE user_id_ = #{userId} and del_flag_ = 0
+		<if test="clientId != null">
+			and client_id_ = #{clientId}
+		</if>
+	</select>
+	
+	<select id="queryByDeviceNum" resultMap="SysUserDevice" parameterType="map">
+		SELECT * FROM sys_user_device WHERE device_num_ = #{deviceNum} and del_flag_ = 0
+		<if test="clientId != null">
+			and client_id_ = #{clientId}
+		</if>
+	</select>
+	
+</mapper>

+ 44 - 0
cooleshow-auth/auth-server/src/main/resources/config/mybatis/SysUserLoginLogMapper.xml

@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!--
+这个文件是自动生成的。
+不要修改此文件。所有改动将在下次重新自动生成时丢失。
+-->
+<mapper namespace="com.yonge.cooleshow.auth.dal.dao.SysUserLoginLogDao">
+	
+	<resultMap type="com.yonge.cooleshow.auth.api.entity.SysUserLoginLog" id="SysUserLoginLog">
+		<result column="id_" property="id"/>
+		<result column="user_id_" property="userId" />
+		<result column="login_ip_" property="loginIp" />
+		<result column="login_time_" property="loginTime" />
+		<result column="source_" property="source" />
+	</resultMap>
+	
+	
+	<!-- 全查询 -->
+	<select id="findAll" resultMap="SysUserLoginLog">
+		SELECT * FROM sys_user_login_log
+	</select>
+	
+	<!-- 向数据库增加一条记录 -->
+	<insert id="insert" parameterType="com.yonge.cooleshow.auth.api.entity.SysUserLoginLog" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+		<!--
+		<selectKey resultClass="int" keyProperty="id" > 
+		SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL 
+		</selectKey>
+		-->
+		INSERT INTO sys_user_login_log (id_,user_id_,login_ip_,login_time_,source_) VALUES(#{id},#{userId},#{loginIp},#{loginTime},#{source})
+	</insert>
+	
+	
+	
+	<!-- 分页查询 -->
+	<select id="queryPage" resultMap="SysUserLoginLog" parameterType="map">
+		SELECT * FROM sys_user_login_log <include refid="global.limit"/>
+	</select>
+	
+	<!-- 查询当前表的总记录数 -->
+	<select id="queryCount" resultType="int">
+		SELECT COUNT(*) FROM sys_user_login_log
+	</select>
+</mapper>

+ 87 - 0
cooleshow-auth/auth-server/src/main/resources/config/mybatis/SysUserLoginMapper.xml

@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!--
+这个文件是自动生成的。
+不要修改此文件。所有改动将在下次重新自动生成时丢失。
+-->
+<mapper namespace="com.yonge.cooleshow.auth.dal.dao.SysUserLoginDao">
+
+    <resultMap type="com.yonge.cooleshow.auth.api.entity.SysUserLogin" id="SysUserLogin">
+        <result column="user_id_" property="userId"/>
+        <result column="login_count_" property="loginCount"/>
+        <result column="last_login_time_" property="lastLoginTime"/>
+        <result column="last_login_ip_" property="lastLoginIp"/>
+        <result column="fail_count_" property="failCount"/>
+        <result column="lock_time_" property="lockTime"/>
+        <result column="lock_date_" property="lockDate"/>
+    </resultMap>
+
+    <!-- 根据主键查询一条记录 -->
+    <select id="get" resultMap="SysUserLogin">
+		SELECT * FROM sys_user_login WHERE user_id_ = #{userId}
+	</select>
+
+    <!-- 全查询 -->
+    <select id="findAll" resultMap="SysUserLogin">
+		SELECT * FROM sys_user_login ORDER BY user_id_
+	</select>
+
+    <!-- 向数据库增加一条记录 -->
+    <insert id="insert" parameterType="com.yonge.cooleshow.auth.api.entity.SysUserLogin" useGeneratedKeys="true" keyColumn="id"
+            keyProperty="id">
+        <!--
+        <selectKey resultClass="int" keyProperty="id" >
+        SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
+        </selectKey>
+        -->
+        INSERT INTO sys_user_login
+        (user_id_,login_count_,last_login_time_,last_login_ip_,fail_count_,lock_time_,lock_date_)
+        VALUES(#{userId},#{loginCount},#{lastLoginTime},#{lastLoginIp},#{failCount},#{lockTime},#{lockDate})
+    </insert>
+
+    <!-- 根据主键查询一条记录 -->
+    <update id="update" parameterType="com.yonge.cooleshow.auth.api.entity.SysUserLogin">
+        UPDATE sys_user_login
+        <set>
+            <if test="failCount != null">
+                fail_count_ = #{failCount},
+            </if>
+            <if test="lastLoginIp != null">
+                last_login_ip_ = #{lastLoginIp},
+            </if>
+            <if test="lockTime != null">
+                lock_time_ = #{lockTime},
+            </if>
+            <if test="loginCount != null">
+                login_count_ = #{loginCount},
+            </if>
+            <if test="lastLoginTime != null">
+                last_login_time_ = #{lastLoginTime},
+            </if>
+            <if test="lockDate != null">
+                lock_date_ = #{lockDate},
+            </if>
+        </set>
+        WHERE user_id_ = #{userId}
+    </update>
+
+    <!-- 根据主键删除一条记录 -->
+    <delete id="delete">
+		DELETE FROM sys_user_login WHERE user_id_ = #{userId}
+	</delete>
+
+    <!-- 分页查询 -->
+    <select id="queryPage" resultMap="SysUserLogin" parameterType="map">
+        SELECT * FROM sys_user_login ORDER BY user_id_
+        <include refid="global.limit"/>
+    </select>
+
+    <!-- 查询当前表的总记录数 -->
+    <select id="queryCount" resultType="int">
+		SELECT COUNT(*) FROM sys_user_login
+	</select>
+
+    <select id="findLoginByUserId" resultMap="SysUserLogin">
+		SELECT * FROM sys_user_login WHERE user_id_ = #{userId}
+	</select>
+</mapper>

+ 221 - 0
cooleshow-auth/auth-server/src/main/resources/config/mybatis/SysUserMapper.xml

@@ -0,0 +1,221 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!--
+这个文件是自动生成的。
+不要修改此文件。所有改动将在下次重新自动生成时丢失。
+-->
+<mapper namespace="com.yonge.cooleshow.auth.dal.dao.SysUserDao">
+
+    <resultMap type="com.yonge.cooleshow.auth.api.entity.SysUser" id="SysUser">
+        <result column="id_" property="id"/>
+        <result column="username_" property="username"/>
+        <result column="real_name_" property="realName"/>
+        <result column="password_" property="password"/>
+        <result column="salt_" property="salt"/>
+        <result column="phone_" property="phone"/>
+        <result column="avatar_" property="avatar"/>
+        <result column="organ_id_" property="organId"/>
+        <result column="create_time_" property="createTime"/>
+        <result column="update_time_" property="updateTime"/>
+        <result column="lock_flag_" property="lockFlag"/>
+        <result column="del_flag_" property="delFlag" typeHandler="com.yonge.cooleshow.common.dal.CustomEnumTypeHandler"/>
+        <result column="wx_openid_" property="wxOpenid"/>
+        <result column="qq_openid_" property="qqOpenid"/>
+        <result column="user_type_" property="userType"/>
+        <result column="gender_" property="gender"/>
+        <result column="nation_" property="nation"/>
+        <result column="birthdate_" property="birthdate"/>
+        <result column="email_" property="email"/>
+        <result column="im_token_" property="imToken"/>
+        <result column="id_card_no_" property="idCardNo"/>
+        <result column="wechat_id_" property="wechatId"/>
+        <result column="is_super_admin_" property="isSuperAdmin"/>
+        <result column="current_grade_" property="currentGrade"/>
+        <result column="current_grade_num_" property="currentGradeNum"/>
+        <result column="current_class_" property="currentClass"/>
+        <result column="certificate_type_" property="certificateType"/>
+    </resultMap>
+
+    <!-- 查询条件 -->
+    <sql id="queryCondition">
+        <if test="userStartDate != null">
+            and create_time_ &gt;= #{createStartDate}
+        </if>
+        <if test="userEndDate != null">
+            and create_time_ &lt;= #{createEndDate}
+        </if>
+        <if test="userType != null">
+            and user_type_ = #{userType}
+        </if>
+        <if test="organId != null">
+            and organ_id_ = #{organId}
+        </if>
+    </sql>
+
+    <!-- 根据主键查询一条记录 -->
+    <select id="get" resultMap="SysUser">
+		SELECT su.*,s.current_class_,s.current_grade_num_
+        FROM sys_user su LEFT JOIN student s ON su.id_ = s.user_id_
+        WHERE su.id_ = #{id}
+	</select>
+
+    <!-- 全查询 -->
+    <select id="findAll" resultMap="SysUser">
+		SELECT * FROM sys_user ORDER BY id_
+	</select>
+
+    <!-- 向数据库增加一条记录 -->
+    <insert id="insert" parameterType="com.yonge.cooleshow.auth.api.entity.SysUser" useGeneratedKeys="true" keyColumn="id"
+            keyProperty="id">
+        INSERT INTO sys_user
+        (is_super_admin_,im_token_,id_,username_,salt_,phone_,avatar_,organ_id_,create_time_,update_time_,wx_openid_,qq_openid_,user_type_,
+        gender_,nation_,birthdate_,email_,id_card_no_,wechat_id_,real_name_,certificate_type_)
+        VALUES(#{isSuperAdmin},#{imToken},#{id},#{username},#{salt},#{phone},#{avatar},#{organId},now(),now(),#{wxOpenid},#{qqOpenid},#{userType},
+        #{gender},#{nation},#{birthdate},#{email},#{idCardNo},#{wechatId},#{realName},#{certificateType})
+    </insert>
+    <insert id="insertTeacher">
+        INSERT INTO teacher
+        (id_,organ_id_,create_time_,update_time_)VALUES(#{userId},#{lesseeOrganId},NOW(),NOW())
+    </insert>
+    <insert id="insertSysTenantAccount">
+        INSERT INTO sys_tenant_account
+        (user_id_,available_minutes_,frozen_minutes_,status_,create_time_,update_time_)
+		VALUES(#{userId},0,0,1,NOW(),NOW())
+    </insert>
+    <insert id="saveStudent">
+        INSERT INTO student (user_id_,create_time_,update_time_,service_tag_,operating_tag_) VALUES(#{userId},NOW(),NOW(),0,0)
+    </insert>
+
+    <!-- 根据主键查询一条记录 -->
+    <update id="update" parameterType="com.yonge.cooleshow.auth.api.entity.SysUser">
+        UPDATE sys_user
+        <set>
+            <if test="delFlag != null">
+                del_flag_ = #{delFlag, typeHandler=com.yonge.cooleshow.common.dal.CustomEnumTypeHandler},
+            </if>
+            <if test="wxOpenid != null and wxOpenid != ''">
+                wx_openid_ = #{wxOpenid},
+            </if>
+            <if test="avatar != null and avatar != ''">
+                avatar_ = #{avatar},
+            </if>
+            <if test="email != null and email != ''">
+                email_ = #{email},
+            </if>
+            <if test="gender != null">
+                gender_ = #{gender},
+            </if>
+            <if test="salt != null and salt != ''">
+                salt_ = #{salt},
+            </if>
+            <if test="username != null and username != ''">
+                username_ = #{username},
+            </if>
+            <if test="userType != null and userType != ''">
+                user_type_ = #{userType},
+            </if>
+            <if test="updateTime != null">
+                update_time_ = NOW(),
+            </if>
+            <if test="lockFlag != null">
+                lock_flag_ = #{lockFlag},
+            </if>
+            <if test="birthdate != null">
+                birthdate_ = #{birthdate},
+            </if>
+            <if test="phone != null and phone != ''">
+                phone_ = #{phone},
+            </if>
+            <if test="qqOpenid != null and qqOpenid != ''">
+                qq_openid_ = #{qqOpenid},
+            </if>
+            <if test="nation != null and nation != ''">
+                nation_ = #{nation},
+            </if>
+            <if test="organId != null">
+                organ_id_ = #{organId},
+            </if>
+            <if test="imToken != null and imToken != ''">
+                im_token_ = #{imToken},
+            </if>
+            <if test="idCardNo != null and idCardNo != ''">
+                id_card_no_ = #{idCardNo},
+            </if>
+            <if test="password != null and password != ''">
+                password_ = #{password},
+            </if>
+            <if test="wechatId != null and wechatId != ''">
+                wechat_id_ = #{wechatId},
+            </if>
+            <if test="realName != null and realName != ''">
+                real_name_ = #{realName},
+            </if>
+            <if test="isSuperAdmin != null">
+                is_super_admin_ = #{isSuperAdmin},
+            </if>
+            <if test="certificateType != null">
+                certificate_type_ = #{certificateType},
+            </if>
+        </set>
+        WHERE id_ = #{id}
+    </update>
+    <update id="updatePassword">
+        UPDATE sys_user SET password_ = #{password} WHERE phone_ = #{mobile}
+    </update>
+    <update id="refreshImToken">
+        UPDATE sys_user SET im_token_ = #{imToken},update_time_ = NOW() WHERE id_ = #{userId}
+    </update>
+
+    <!-- 根据主键删除一条记录 -->
+    <delete id="delete">
+		UPDATE sys_user SET del_flag_ = 1 WHERE id_ = #{id}
+	</delete>
+
+    <!-- 分页查询 -->
+    <select id="queryPage" resultMap="SysUser" parameterType="map">
+        SELECT * FROM sys_user ORDER BY id_
+        <include refid="queryCondition"/>
+        <include refid="global.orderby"/>
+        <include refid="global.limit"/>
+    </select>
+
+    <!-- 查询当前表的总记录数 -->
+    <select id="queryCount" resultType="int">
+        SELECT COUNT(*) FROM sys_user
+        <include refid="queryCondition"/>
+    </select>
+
+    <select id="queryByUsername" resultMap="SysUser">
+		select * from sys_user where username_ = #{username} OR phone_ = #{username} LIMIT 1 FOR UPDATE
+	</select>
+
+    <select id="queryByPhone" resultMap="SysUser">
+		select * from sys_user where phone_ = #{phone} OR username_ = #{phone} LIMIT 1
+	</select>
+
+    <select id="queryLockByPhone" resultMap="SysUser">
+		select * from sys_user where phone_ = #{phone} OR username_ = #{phone} LIMIT 1 FOR UPDATE
+	</select>
+    <resultMap id="ImUserModel" type="com.yonge.cooleshow.common.entity.ImUserModel">
+        <result column="id_" property="id"/>
+        <result property="name" column="username_"/>
+        <result property="portrait" column="avatar_"/>
+    </resultMap>
+    <select id="getBasic" resultMap="ImUserModel">
+        select CASE WHEN user_type_ LIKE '%TEACHER%' OR user_type_ LIKE '%SYSTEM%' THEN real_name_ ELSE username_ END username_,id_,avatar_
+        from sys_user where id_ = #{userId} LIMIT 1
+    </select>
+    
+    <select id="queryByStatus" resultMap="SysUser">
+        select * from sys_user where lock_flag_ = #{status}
+    </select>
+    <select id="findUserBySalt" resultMap="SysUser">
+        SELECT * FROM sys_user WHERE salt_ IS NOT NULL AND salt_ = 'replace' AND user_type_ LIKE CONCAT('%',#{userType},'%') LIMIT 1
+    </select>
+    <select id="getTeacherOrganId" resultType="java.lang.Integer">
+        SELECT organ_id_ FROM teacher WHERE id_ = #{userId}
+    </select>
+    <select id="queryByPhoneAndClient" resultMap="SysUser">
+        select * from sys_user where (phone_ = #{phone} OR username_ = #{phone}) AND user_type_ LIKE CONCAT('%',#{client},'%') LIMIT 1 FOR UPDATE
+    </select>
+</mapper>

+ 58 - 0
cooleshow-auth/auth-server/src/main/resources/config/mybatis/SysUserRoleMapper.xml

@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!--
+这个文件是自动生成的。
+不要修改此文件。所有改动将在下次重新自动生成时丢失。
+-->
+<mapper namespace="com.yonge.cooleshow.auth.dal.dao.SysUserRoleDao">
+
+    <resultMap type="com.yonge.cooleshow.auth.api.entity.SysUserRole" id="SysUserRole">
+        <result column="user_id_" property="userId"/>
+        <result column="role_id_" property="roleId"/>
+    </resultMap>
+
+    <!-- 根据主键查询一条记录 -->
+    <select id="get" resultMap="SysUserRole" parameterType="java.util.Map">
+		SELECT * FROM sys_user_role WHERE user_id_ = #{userId} AND role_id_ = #{roleId}
+	</select>
+
+    <!-- 全查询 -->
+    <select id="findAll" resultMap="SysUserRole">
+		SELECT * FROM sys_user_role ORDER BY user_id_,role_id_
+	</select>
+
+    <!-- 向数据库增加一条记录 -->
+    <insert id="insert" parameterType="com.yonge.cooleshow.auth.api.entity.SysUserRole" useGeneratedKeys="true" keyColumn="id"
+            keyProperty="id">
+        <!--
+        <selectKey resultClass="int" keyProperty="id" >
+        SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
+        </selectKey>
+        -->
+        INSERT INTO sys_user_role (user_id_,role_id_) VALUES(#{userId},#{roleId})
+    </insert>
+
+    <!-- 根据主键删除一条记录 -->
+    <delete id="delete" parameterType="java.util.Map">
+		DELETE FROM sys_user_role WHERE user_id = #{userId} AND role_id = #{roleId} 
+	</delete>
+
+    <!-- 分页查询 -->
+    <select id="queryPage" resultMap="SysUserRole" parameterType="map">
+        SELECT * FROM sys_user_role ORDER BY user_id_,role_id_
+        <include refid="global.limit"/>
+    </select>
+
+    <!-- 查询当前表的总记录数 -->
+    <select id="queryCount" resultType="int">
+		SELECT COUNT(*) FROM sys_user_role
+	</select>
+
+    <select id="queryRoleIdListByUserId" resultType="int" parameterType="int">
+		SELECT ur.role_id_ FROM sys_user_role ur left join sys_role r on ur.role_id_ = r.id_ where ur.user_id_ = #{userId} and r.del_flag_ = 0
+	</select>
+
+    <select id="queryRoleCodeListByUserId" resultType="string" parameterType="int">
+		SELECT r.role_code_ FROM sys_user_role ur left join sys_role r on ur.role_id_ = r.id_ where ur.user_id_ = #{userId} and r.del_flag_ = 0
+	</select>
+</mapper>

+ 36 - 0
cooleshow-auth/auth-server/src/main/resources/logback-spring.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration scan="true" scanPeriod="10 seconds">
+
+	<property name="LOG_HOME" value="/mdata/logs/auth-%d{yyyy-MM-dd_HH}-%i.log" />
+	<property name="CONSOLE_LOG_PATTERN"
+		value="[%X{username} %X{ip} %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}] : %msg%n" />
+
+	<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
+		<encoder charset="UTF-8">
+			<pattern>${CONSOLE_LOG_PATTERN}</pattern>
+		</encoder>
+	</appender>
+
+	<appender name="file"
+		class="ch.qos.logback.core.rolling.RollingFileAppender">
+		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+			<FileNamePattern>${LOG_HOME}</FileNamePattern>
+			<MaxHistory>90</MaxHistory>
+			<TimeBasedFileNamingAndTriggeringPolicy
+				class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+				<MaxFileSize>20MB</MaxFileSize>
+			</TimeBasedFileNamingAndTriggeringPolicy>
+		</rollingPolicy>
+
+		<encoder>
+			<pattern>${CONSOLE_LOG_PATTERN}</pattern>
+		</encoder>
+	</appender>
+
+	<logger name="com.ym.mec" level="WARN" />
+	<root level="WARN">
+		<appender-ref ref="stdout" />
+		<appender-ref ref="file" />
+	</root>
+
+</configuration>

+ 6 - 9
cooleshow-auth/pom.xml

@@ -1,5 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   
   <parent>
@@ -11,7 +11,7 @@
   <groupId>com.yonge.cooleshow</groupId>
   <artifactId>cooleshow-auth</artifactId>
   <version>1.0</version>
-  <packaging>jar</packaging>
+  <packaging>pom</packaging>
 
   <name>cooleshow-auth</name>
   <url>http://maven.apache.org</url>
@@ -21,11 +21,8 @@
   </properties>
 
   <dependencies>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>3.8.1</version>
-      <scope>test</scope>
-    </dependency>
   </dependencies>
+<modules>  <module>auth-api</module>
+    <module>auth-server</module>
+  </modules>
 </project>

+ 73 - 29
cooleshow-common/pom.xml

@@ -1,31 +1,75 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  
-  <parent>
-    <groupId>com.yonge.cooleshow</groupId>
-    <artifactId>cooleshow</artifactId>
-    <version>1.0</version>
-  </parent>
-
-  <groupId>com.yonge.cooleshow</groupId>
-  <artifactId>cooleshow-common</artifactId>
-  <version>1.0</version>
-  <packaging>jar</packaging>
-
-  <name>cooleshow-common</name>
-  <url>http://maven.apache.org</url>
-
-  <properties>
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-  </properties>
-
-  <dependencies>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>3.8.1</version>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+
+	<parent>
+		<groupId>com.yonge.cooleshow</groupId>
+		<artifactId>cooleshow</artifactId>
+		<version>1.0</version>
+	</parent>
+
+	<groupId>com.yonge.cooleshow</groupId>
+	<artifactId>cooleshow-common</artifactId>
+	<version>1.0</version>
+	<packaging>jar</packaging>
+
+	<name>cooleshow-common</name>
+	<url>http://maven.apache.org</url>
+
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+	</properties>
+
+	<dependencies>
+
+		<dependency>
+			<groupId>com.yonge.toolset</groupId>
+			<artifactId>thirdparty-component</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.mybatis.spring.boot</groupId>
+			<artifactId>mybatis-spring-boot-starter</artifactId>
+		</dependency>
+
+		<!-- Redis缓存整合开始 -->
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-data-redis</artifactId>
+			<exclusions>
+				<exclusion>
+					<groupId>io.lettuce</groupId>
+					<artifactId>lettuce-core</artifactId>
+				</exclusion>
+			</exclusions>
+		</dependency>
+		<!-- Redis缓存整合结束 -->
+
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-starter-oauth2</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-starter-openfeign</artifactId>
+		</dependency>
+		
+		<dependency>
+			<groupId>redis.clients</groupId>
+			<artifactId>jedis</artifactId>
+		</dependency>
+		
+		<dependency>
+			<groupId>org.springframework.security.oauth</groupId>
+			<artifactId>spring-security-oauth2</artifactId>
+			<version>2.2.1.RELEASE</version>
+		</dependency>
+
+		<dependency>
+			<groupId>com.vdurmont</groupId>
+			<artifactId>emoji-java</artifactId>
+		</dependency>
+
+	</dependencies>
 </project>

+ 89 - 0
cooleshow-common/src/main/java/com/yonge/cooleshow/common/cache/Cache.java

@@ -0,0 +1,89 @@
+package com.yonge.cooleshow.common.cache;
+
+import java.util.Set;
+
+public interface Cache<K, V> {
+
+	/**
+	 * 获得缓存值
+	 * 
+	 * @param key
+	 *            缓存key
+	 * @return 缓存值
+	 */
+	Object get(K key) throws CacheException;
+
+	/**
+	 * 设置缓存
+	 * 
+	 * @param key
+	 *            缓存key
+	 * @param value
+	 *            缓存值
+	 */
+	void put(K key, V value) throws CacheException;
+
+	/**
+	 * 设置缓存
+	 * 
+	 * @param key
+	 *            缓存key
+	 * @param value
+	 *            缓存值
+	 * @param expireTimes
+	 * 		过期时间(单位:秒)
+	 */
+	void put(K key, V value, int expireTimes) throws CacheException;
+
+	/**
+	 * 删除缓存
+	 * 
+	 * @param key
+	 */
+	void delete(K key) throws CacheException;
+
+	/**
+	 * 判断key是否已经存在
+	 * @param key
+	 * @return
+	 */
+	public boolean exists(K key);
+
+	/**
+	 * 获得所有的key
+	 * 
+	 * @return key集合
+	 */
+	Set<K> keys() throws CacheException;
+
+	/**
+	 * 获得缓存的key-value个数
+	 * 
+	 * @return key-value个数
+	 */
+	long size() throws CacheException;
+
+	/**
+	 * 重置某一个对应key的cache过期时间
+	 * @param key
+	 * @param expireTimes
+	 */
+	void expire(K key, int expireTimes);
+
+	/**
+	 * 获取分布式锁
+	 * @param key 业务唯一标识
+	 * @param threadId 线程编号
+	 * @param seconds 锁的有效期
+	 * @return
+	 */
+	boolean getLocked(K key, V threadId, int seconds);
+
+	/**
+	 * 释放分布式锁
+	 * @param key
+	 * @param threadId
+	 * @return
+	 */
+	boolean releaseLocked(K key, V threadId);
+}

+ 27 - 0
cooleshow-common/src/main/java/com/yonge/cooleshow/common/cache/CacheException.java

@@ -0,0 +1,27 @@
+package com.yonge.cooleshow.common.cache;
+
+/**
+ * 缓存异常处理类
+ * 
+ */
+public class CacheException extends RuntimeException {
+
+	private static final long serialVersionUID = 3299789908114028688L;
+
+	public CacheException(String message, Throwable cause) {
+		super(message, cause);
+	}
+
+	public CacheException(String message) {
+		super(message);
+	}
+
+	public CacheException(Throwable cause) {
+		super(cause);
+	}
+
+	public CacheException() {
+		super();
+	}
+
+}

+ 60 - 0
cooleshow-common/src/main/java/com/yonge/cooleshow/common/config/DateConverter.java

@@ -0,0 +1,60 @@
+package com.yonge.cooleshow.common.config;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.springframework.core.convert.converter.Converter;
+import org.springframework.stereotype.Component;
+
+@Component
+public class DateConverter implements Converter<String, Date> {
+
+	private static final List<String> formarts = new ArrayList<String>(4);
+
+	static {
+		formarts.add("yyyy-MM");
+		formarts.add("yyyy-MM-dd");
+		formarts.add("yyyy-MM-dd HH:mm");
+		formarts.add("yyyy-MM-dd HH:mm:ss");
+	}
+
+	@Override
+	public Date convert(String source) {
+		String value = source.trim();
+		if ("".equals(value)) {
+			return null;
+		}
+		if (source.matches("^\\d{4}-\\d{1,2}$")) {
+			return parseDate(source, formarts.get(0));
+		} else if (source.matches("^\\d{4}-\\d{1,2}-\\d{1,2}$")) {
+			return parseDate(source, formarts.get(1));
+		} else if (source.matches("^\\d{4}-\\d{1,2}-\\d{1,2} {1}\\d{1,2}:\\d{1,2}$")) {
+			return parseDate(source, formarts.get(2));
+		} else if (source.matches("^\\d{4}-\\d{1,2}-\\d{1,2} {1}\\d{1,2}:\\d{1,2}:\\d{1,2}$")) {
+			return parseDate(source, formarts.get(3));
+		} else {
+			throw new IllegalArgumentException("Invalid boolean value '" + source + "'");
+		}
+	}
+
+	/**
+	 * 格式化日期
+	 * @param dateStr String 字符型日期
+	 * @param format String 格式
+	 * @return Date 日期
+	 */
+	public Date parseDate(String dateStr, String format) {
+		Date date = null;
+		try {
+			DateFormat dateFormat = new SimpleDateFormat(format);
+			date = dateFormat.parse(dateStr);
+		} catch (Exception e) {
+
+		}
+		return date;
+	}
+
+}

+ 34 - 0
cooleshow-common/src/main/java/com/yonge/cooleshow/common/config/EnumConverter.java

@@ -0,0 +1,34 @@
+package com.yonge.cooleshow.common.config;
+
+import org.springframework.core.convert.converter.Converter;
+
+import com.yonge.cooleshow.common.enums.BaseEnum;
+
+public class EnumConverter<T extends BaseEnum<?, ?>> implements Converter<String, T> {
+
+	private Class<T> enumType;
+
+	public EnumConverter(Class<T> enumType) {
+		this.enumType = enumType;
+	}
+
+	@Override
+	public T convert(String source) {
+		return getEnum(enumType, source);
+	}
+
+	private T getEnum(Class<T> targerType, String source) {
+		for (T en : targerType.getEnumConstants()) {
+			if (en.getCode() instanceof Integer) {
+				if ((Integer) en.getCode() == Integer.parseInt(source)) {
+					return en;
+				}
+			} else {
+				if (source.equals(String.valueOf(en.getCode()))) {
+					return en;
+				}
+			}
+		}
+		return null;
+	}
+}

+ 17 - 0
cooleshow-common/src/main/java/com/yonge/cooleshow/common/config/EnumConverterFactory.java

@@ -0,0 +1,17 @@
+package com.yonge.cooleshow.common.config;
+
+import com.yonge.cooleshow.common.enums.BaseEnum;
+
+import org.springframework.core.convert.converter.Converter;
+import org.springframework.core.convert.converter.ConverterFactory;
+import org.springframework.stereotype.Component;
+
+@Component
+public class EnumConverterFactory implements ConverterFactory<String, BaseEnum<?, ?>> {
+
+	@Override
+	public <T extends BaseEnum<?, ?>> Converter<String, T> getConverter(Class<T> targetType) {
+		return new EnumConverter<T>(targetType);
+	}
+
+}

+ 22 - 0
cooleshow-common/src/main/java/com/yonge/cooleshow/common/config/FeignConfiguration.java

@@ -0,0 +1,22 @@
+package com.yonge.cooleshow.common.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import feign.Logger;
+import feign.RequestInterceptor;
+
+@Configuration
+public class FeignConfiguration {
+
+	@Bean
+	Logger.Level feignLoggerLevel() {
+		// 这里记录所有,根据实际情况选择合适的日志level
+		return Logger.Level.FULL;
+	}
+
+	@Bean
+	public RequestInterceptor requestInterceptor(){
+		return new RequestHeaderConfiguration();
+	}
+}

+ 74 - 0
cooleshow-common/src/main/java/com/yonge/cooleshow/common/config/LocalFastJsonHttpMessageConverter.java

@@ -0,0 +1,74 @@
+package com.yonge.cooleshow.common.config;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.reflect.Type;
+import java.math.BigDecimal;
+import java.util.Date;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.http.HttpInputMessage;
+import org.springframework.http.HttpOutputMessage;
+import org.springframework.http.converter.HttpMessageNotReadableException;
+import org.springframework.http.converter.HttpMessageNotWritableException;
+
+import com.alibaba.fastjson.serializer.JSONSerializer;
+import com.alibaba.fastjson.serializer.ObjectSerializer;
+import com.alibaba.fastjson.serializer.SimpleDateFormatSerializer;
+import com.alibaba.fastjson.serializer.ValueFilter;
+import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
+import com.vdurmont.emoji.EmojiParser;
+import com.yonge.cooleshow.common.enums.BaseEnum;
+import com.yonge.toolset.utils.json.JsonUtil;
+
+public class LocalFastJsonHttpMessageConverter extends FastJsonHttpMessageConverter {
+
+	private static final String FORMAT = "yyyy-MM-dd HH:mm:ss";
+
+	@Override
+	protected Object readInternal(Class<? extends Object> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException {
+		return super.readInternal(clazz, inputMessage);
+	}
+
+	@Override
+	protected void writeInternal(Object obj, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
+
+		OutputStream out = outputMessage.getBody();
+		JsonUtil.getConfig().put(Date.class, new SimpleDateFormatSerializer(FORMAT));
+		//JsonUtil.getConfig().put(String.class, new EmojiSerializer());
+		String text = JsonUtil.toJSONString(obj, EnumFilter.instance, getFeatures());
+		byte[] bytes = text.getBytes(getCharset());
+		out.write(bytes);
+	}
+}
+
+class EmojiSerializer implements ObjectSerializer{
+
+	@Override
+	public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
+		serializer.write(EmojiParser.parseToUnicode(object.toString()));
+	}
+	
+}
+
+class EnumFilter implements ValueFilter {
+
+	public static EnumFilter instance = new EnumFilter();
+
+	public EnumFilter() {
+	}
+
+	@Override
+	public Object process(Object object, String name, Object value) {
+		if (value == null || StringUtils.isBlank(value.toString())) {
+			return value;
+		}
+		if (value instanceof BigDecimal || value instanceof Double || value instanceof Float) {
+			return new BigDecimal(value.toString());
+		}
+		if (BaseEnum.class.isAssignableFrom(value.getClass())) {
+			return ((BaseEnum<?, ?>) value).getCode();
+		}
+		return value;
+	}
+}

+ 88 - 0
cooleshow-common/src/main/java/com/yonge/cooleshow/common/config/ParameterCheckServletRequestWrapper.java

@@ -0,0 +1,88 @@
+package com.yonge.cooleshow.common.config;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.charset.Charset;
+
+import javax.servlet.ReadListener;
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.util.StreamUtils;
+
+import com.vdurmont.emoji.EmojiParser;
+
+public class ParameterCheckServletRequestWrapper extends HttpServletRequestWrapper {
+
+	private byte[] requestBody;
+	private Charset charSet;
+
+	public ParameterCheckServletRequestWrapper(HttpServletRequest request) throws IOException {
+		super(request);
+
+		String requestBodyStr = getRequestPostStr(request);
+		if (StringUtils.isNotBlank(requestBodyStr)) {
+			requestBodyStr = EmojiParser.removeAllEmojis(requestBodyStr);
+			requestBody = requestBodyStr.getBytes(charSet);
+		} else {
+			requestBody = new byte[0];
+		}
+	}
+
+	public String getRequestPostStr(HttpServletRequest request) throws IOException {
+		String charSetStr = request.getCharacterEncoding();
+		if (charSetStr == null) {
+			charSetStr = "UTF-8";
+		}
+		charSet = Charset.forName(charSetStr);
+
+		return StreamUtils.copyToString(request.getInputStream(), charSet);
+	}
+
+	/**
+	 * 重写 getInputStream()
+	 */
+	@Override
+	public ServletInputStream getInputStream() {
+		if (requestBody == null) {
+			requestBody = new byte[0];
+		}
+
+		final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(requestBody);
+
+		return new ServletInputStream() {
+			@Override
+			public boolean isFinished() {
+				return false;
+			}
+
+			@Override
+			public boolean isReady() {
+				return false;
+			}
+
+			@Override
+			public void setReadListener(ReadListener readListener) {
+
+			}
+
+			@Override
+			public int read() {
+				return byteArrayInputStream.read();
+			}
+		};
+	}
+
+	/**
+	 * 重写 getReader()
+	 */
+	@Override
+	public BufferedReader getReader() {
+		return new BufferedReader(new InputStreamReader(getInputStream()));
+	}
+
+}

Some files were not shown because too many files changed in this diff