yonge 5 年之前
当前提交
e3eff60527
共有 100 个文件被更改,包括 6806 次插入0 次删除
  1. 12 0
      .gitignore
  2. 28 0
      edu-auth/edu-auth-api/pom.xml
  3. 36 0
      edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/client/SysUserFeignService.java
  4. 43 0
      edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/client/fallback/SysUserFeignServiceFallback.java
  5. 59 0
      edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/dto/MenuQueryInfo.java
  6. 51 0
      edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/dto/SysUserInfo.java
  7. 63 0
      edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/entity/LoginEntity.java
  8. 205 0
      edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/entity/SysMenu.java
  9. 146 0
      edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/entity/SysOauthClientDetails.java
  10. 121 0
      edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/entity/SysRole.java
  11. 51 0
      edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/entity/SysRoleDept.java
  12. 48 0
      edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/entity/SysRoleMenu.java
  13. 398 0
      edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/entity/SysUser.java
  14. 100 0
      edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/entity/SysUserLogin.java
  15. 74 0
      edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/entity/SysUserLoginLog.java
  16. 52 0
      edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/entity/SysUserRole.java
  17. 36 0
      edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/enums/SysUserType.java
  18. 42 0
      edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/enums/UserLockFlag.java
  19. 79 0
      edu-auth/edu-auth-server/pom.xml
  20. 36 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/UserApplication.java
  21. 81 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/config/AuthorizationServerConfig.java
  22. 52 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/config/PermissionCheckService.java
  23. 84 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/config/RequestUtils.java
  24. 37 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/config/ResourceServerConfig.java
  25. 36 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/config/WebMvcConfig.java
  26. 132 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/config/WebSecurityConfig.java
  27. 79 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/config/token/PhoneAuthenticationToken.java
  28. 106 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/core/filter/PhoneLoginAuthenticationFilter.java
  29. 189 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/core/filter/UsernameAuthenticationFilter.java
  30. 74 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/core/handler/AuthenticationFailureListener.java
  31. 46 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/core/handler/BaseAuthenticationFailureEvenHandler.java
  32. 153 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/core/handler/BaseAuthenticationSuccessEventHandler.java
  33. 167 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/core/provider/AbstractAuthenticationProvider.java
  34. 97 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/core/provider/PhoneAuthenticationProvider.java
  35. 81 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/core/provider/service/DefaultUserDetailsService.java
  36. 41 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/core/service/AccessTokenService.java
  37. 55 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/dal/dao/SysMenuDao.java
  38. 9 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/dal/dao/SysOauthClientDetailsDao.java
  39. 25 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/dal/dao/SysRoleDao.java
  40. 9 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/dal/dao/SysRoleDeptDao.java
  41. 45 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/dal/dao/SysRoleMenuDao.java
  42. 95 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/dal/dao/SysUserDao.java
  43. 14 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/dal/dao/SysUserLoginDao.java
  44. 8 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/dal/dao/SysUserLoginLogDao.java
  45. 31 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/dal/dao/SysUserRoleDao.java
  46. 41 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/dal/enums/UserGenderEnum.java
  47. 47 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/dal/enums/UserStatus.java
  48. 37 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/SysMenuService.java
  49. 8 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/SysOauthClientDetailsService.java
  50. 8 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/SysRoleDeptService.java
  51. 39 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/SysRoleMenuService.java
  52. 43 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/SysRoleService.java
  53. 8 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/SysUserLoginLogService.java
  54. 20 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/SysUserLoginService.java
  55. 38 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/SysUserRoleService.java
  56. 121 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/SysUserService.java
  57. 92 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/impl/SysMenuServiceImpl.java
  58. 23 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/impl/SysOauthClientDetailsServiceImpl.java
  59. 23 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/impl/SysRoleDeptServiceImpl.java
  60. 66 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/impl/SysRoleMenuServiceImpl.java
  61. 82 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/impl/SysRoleServiceImpl.java
  62. 22 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/impl/SysUserLoginLogServiceImpl.java
  63. 72 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/impl/SysUserLoginServiceImpl.java
  64. 58 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/impl/SysUserRoleServiceImpl.java
  65. 219 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/impl/SysUserServiceImpl.java
  66. 88 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/web/controller/MenuController.java
  67. 126 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/web/controller/RoleController.java
  68. 23 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/web/controller/TaskController.java
  69. 144 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/web/controller/TokenController.java
  70. 325 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/web/controller/UserController.java
  71. 36 0
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/web/controller/queryInfo/SysUserQueryInfo.java
  72. 23 0
      edu-auth/pom.xml
  73. 49 0
      edu-cms/pom.xml
  74. 34 0
      edu-cms/src/main/java/com/keao/edu/cms/CmsServerApplication.java
  75. 42 0
      edu-cms/src/main/java/com/keao/edu/cms/config/ResourceServerConfig.java
  76. 36 0
      edu-cms/src/main/java/com/keao/edu/cms/config/WebMvcConfig.java
  77. 82 0
      edu-cms/src/main/java/com/keao/edu/cms/controller/HelpCenterCatalogController.java
  78. 88 0
      edu-cms/src/main/java/com/keao/edu/cms/controller/HelpCenterContentControlller.java
  79. 76 0
      edu-cms/src/main/java/com/keao/edu/cms/controller/NewsController.java
  80. 42 0
      edu-cms/src/main/java/com/keao/edu/cms/controller/queryinfo/HelpCenterContentQueryInfo.java
  81. 76 0
      edu-cms/src/main/java/com/keao/edu/cms/controller/queryinfo/NewsInformationQueryInfo.java
  82. 13 0
      edu-cms/src/main/java/com/keao/edu/cms/dal/dao/HelpCenterCatalogDao.java
  83. 13 0
      edu-cms/src/main/java/com/keao/edu/cms/dal/dao/HelpCenterContentDao.java
  84. 28 0
      edu-cms/src/main/java/com/keao/edu/cms/dal/dao/SysNewsInformationDao.java
  85. 126 0
      edu-cms/src/main/java/com/keao/edu/cms/dal/entity/HelpCenterCatalog.java
  86. 121 0
      edu-cms/src/main/java/com/keao/edu/cms/dal/entity/HelpCenterContent.java
  87. 20 0
      edu-cms/src/main/java/com/keao/edu/cms/dal/entity/NewsStatusEnum.java
  88. 173 0
      edu-cms/src/main/java/com/keao/edu/cms/dal/entity/SysNewsInformation.java
  89. 31 0
      edu-cms/src/main/java/com/keao/edu/cms/service/HelpCenterCatalogService.java
  90. 11 0
      edu-cms/src/main/java/com/keao/edu/cms/service/HelpCenterContentService.java
  91. 33 0
      edu-cms/src/main/java/com/keao/edu/cms/service/SysNewsInformationService.java
  92. 51 0
      edu-cms/src/main/java/com/keao/edu/cms/service/impl/HelpCenterCatalogServiceImpl.java
  93. 41 0
      edu-cms/src/main/java/com/keao/edu/cms/service/impl/HelpCenterContentServiceImpl.java
  94. 118 0
      edu-cms/src/main/java/com/keao/edu/cms/service/impl/SysNewsInformationServiceImpl.java
  95. 79 0
      edu-cms/src/main/resources/application.yml
  96. 16 0
      edu-cms/src/main/resources/bootstrap-dev.properties
  97. 16 0
      edu-cms/src/main/resources/bootstrap-prod.properties
  98. 16 0
      edu-cms/src/main/resources/bootstrap-test.properties
  99. 21 0
      edu-cms/src/main/resources/config/mybatis/Global.mapper.xml
  100. 96 0
      edu-cms/src/main/resources/config/mybatis/HelpCenterCatalogMapper.xml

+ 12 - 0
.gitignore

@@ -0,0 +1,12 @@
+*.class
+.metadata
+target
+*.classpath
+.settings
+.project
+/p2p-biz/test-output
+bin
+/manage-center/src/main/resources/config/properties/generatorConfig.xml
+/p2p-utils/.gitignore
+.idea
+*.iml

+ 28 - 0
edu-auth/edu-auth-api/pom.xml

@@ -0,0 +1,28 @@
+<?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.keao.edu</groupId>
+		<artifactId>edu-auth</artifactId>
+		<version>1.0</version>
+	</parent>
+	<artifactId>edu-auth-api</artifactId>
+	<name>edu-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>com.keao.edu</groupId>
+			<artifactId>edu-common</artifactId>
+		</dependency>
+	</dependencies>
+</project>

+ 36 - 0
edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/client/SysUserFeignService.java

@@ -0,0 +1,36 @@
+package com.keao.edu.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.keao.edu.auth.api.client.fallback.SysUserFeignServiceFallback;
+import com.keao.edu.auth.api.entity.SysUser;
+import com.keao.edu.common.config.FeignConfiguration;
+
+@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 Object 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);
+}

+ 43 - 0
edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/client/fallback/SysUserFeignServiceFallback.java

@@ -0,0 +1,43 @@
+package com.keao.edu.auth.api.client.fallback;
+
+import java.util.List;
+
+import org.springframework.stereotype.Component;
+
+import com.keao.edu.auth.api.client.SysUserFeignService;
+import com.keao.edu.auth.api.entity.SysUser;
+
+@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 Object addUser(SysUser user){
+		return false;
+	}
+
+	@Override
+	public List<String> queryRoleCodeListByUserId(Integer userId) {
+		return null;
+	}
+
+	@Override
+	public Boolean updateSysUser(SysUser user) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+}

+ 59 - 0
edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/dto/MenuQueryInfo.java

@@ -0,0 +1,59 @@
+package com.keao.edu.auth.api.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+
+public class MenuQueryInfo{
+    @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
edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/dto/SysUserInfo.java

@@ -0,0 +1,51 @@
+package com.keao.edu.auth.api.dto;
+
+import java.io.Serializable;
+
+import com.keao.edu.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;
+	}
+}

+ 63 - 0
edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/entity/LoginEntity.java

@@ -0,0 +1,63 @@
+package com.keao.edu.auth.api.entity;
+
+public class LoginEntity {
+    private String smsCode;
+
+    private String isLessee;
+
+    private String clientId;
+
+    private String clientSecret;
+
+    private String isRegister;
+
+    private String phone;
+
+    public String getIsRegister() {
+        return isRegister;
+    }
+
+    public void setIsRegister(String isRegister) {
+        this.isRegister = isRegister;
+    }
+
+    public String getSmsCode() {
+        return smsCode;
+    }
+
+    public void setSmsCode(String smsCode) {
+        this.smsCode = smsCode;
+    }
+
+    public String getIsLessee() {
+        return isLessee;
+    }
+
+    public void setIsLessee(String isLessee) {
+        this.isLessee = isLessee;
+    }
+
+    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;
+    }
+}

+ 205 - 0
edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/entity/SysMenu.java

@@ -0,0 +1,205 @@
+package com.keao.edu.auth.api.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+import java.util.List;
+
+/**
+ * 对应数据库表(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;
+
+	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
edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/entity/SysOauthClientDetails.java

@@ -0,0 +1,146 @@
+package com.keao.edu.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);
+	}
+
+}

+ 121 - 0
edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/entity/SysRole.java

@@ -0,0 +1,121 @@
+package com.keao.edu.auth.api.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.List;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(sys_role):
+ */
+public class SysRole {
+
+	/**  */
+	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
edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/entity/SysRoleDept.java

@@ -0,0 +1,51 @@
+package com.keao.edu.auth.api.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(sys_role_dept):
+ */
+public class SysRoleDept {
+
+	/**  */
+	private Integer id;
+	
+	/** 角色ID */
+	@ApiModelProperty(value = "角色ID",required = false)
+	private Integer roleId;
+	
+	/** 部门ID */
+	@ApiModelProperty(value = "部门ID",required = false)
+	private Integer deptId;
+	
+	public void setId(Integer id){
+		this.id = id;
+	}
+	
+	public Integer getId(){
+		return this.id;
+	}
+			
+	public void setRoleId(Integer roleId){
+		this.roleId = roleId;
+	}
+	
+	public Integer getRoleId(){
+		return this.roleId;
+	}
+			
+	public void setDeptId(Integer deptId){
+		this.deptId = deptId;
+	}
+	
+	public Integer getDeptId(){
+		return this.deptId;
+	}
+			
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 48 - 0
edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/entity/SysRoleMenu.java

@@ -0,0 +1,48 @@
+package com.keao.edu.auth.api.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(sys_role_menu):
+ */
+public class SysRoleMenu {
+
+	/** 角色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);
+	}
+
+}

+ 398 - 0
edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/entity/SysUser.java

@@ -0,0 +1,398 @@
+package com.keao.edu.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.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(sys_user):
+ */
+public class SysUser 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 Integer 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 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;
+
+	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 Integer getDelFlag() {
+		return delFlag;
+	}
+
+	public void setDelFlag(Integer 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) {
+		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);
+	}
+
+}

+ 100 - 0
edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/entity/SysUserLogin.java

@@ -0,0 +1,100 @@
+package com.keao.edu.auth.api.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(sys_user_login):
+ */
+public class SysUserLogin {
+
+	/**  */
+	@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);
+	}
+
+}

+ 74 - 0
edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/entity/SysUserLoginLog.java

@@ -0,0 +1,74 @@
+package com.keao.edu.auth.api.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(sys_user_login_log):
+ */
+public class SysUserLoginLog {
+
+	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);
+	}
+
+}

+ 52 - 0
edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/entity/SysUserRole.java

@@ -0,0 +1,52 @@
+package com.keao.edu.auth.api.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(sys_user_role):
+ */
+public class SysUserRole {
+	//分部经理
+	public static Integer SECTION_MANAGER = 3;
+	//教务老师
+	public static Integer EDUCATIONAL_TEACHER = 4;
+	//运营主管
+	public static Integer OPERATION_EXECUTIVE = 5;
+	//招生主管
+	public static Integer ADMISSIONS_DIRECTOR = 6;
+	//教学主任
+	public static Integer DEAN_OF_STUDIES = 7;
+	//总部管理员
+	public static Integer ADMINISTRATOR = 25;
+
+	/** 用户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);
+	}
+
+}

+ 36 - 0
edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/enums/SysUserType.java

@@ -0,0 +1,36 @@
+package com.keao.edu.auth.api.enums;
+
+import org.apache.commons.lang3.StringUtils;
+
+import com.keao.edu.common.enums.BaseEnum;
+
+public enum SysUserType implements BaseEnum<String, SysUserType> {
+
+	STUDENT("学生"), EDUCATION("教务老师"), TEACHER("指导老师"), SYSTEM("系统內置"), ADMIN("管理员");
+
+	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;
+	}
+}

+ 42 - 0
edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/enums/UserLockFlag.java

@@ -0,0 +1,42 @@
+package com.keao.edu.auth.api.enums;
+
+import com.keao.edu.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;
+	}
+}

+ 79 - 0
edu-auth/edu-auth-server/pom.xml

@@ -0,0 +1,79 @@
+<?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.keao.edu</groupId>
+    <artifactId>edu-auth</artifactId>
+    <version>1.0</version>
+  </parent>
+  <artifactId>edu-auth-server</artifactId>
+  <name>edu-auth-server</name>
+  <url>http://maven.apache.org</url>
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+  <dependencies>
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-starter-netflix-eureka-client</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>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>com.github.penggle</groupId>
+			<artifactId>kaptcha</artifactId>
+			<version>2.3.2</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.commons</groupId>
+			<artifactId>commons-pool2</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>com.keao.edu</groupId>
+			<artifactId>edu-common</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>com.keao.edu</groupId>
+			<artifactId>edu-auth-api</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>com.keao.edu</groupId>
+			<artifactId>edu-im-api</artifactId>
+		</dependency>
+  </dependencies>
+</project>

+ 36 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/UserApplication.java

@@ -0,0 +1,36 @@
+package com.keao.edu.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.ym.mec"})
+@MapperScan("com.keao.edu.user.dal.dao")
+@ComponentScan(basePackages="com.keao.edu")
+@Configuration
+@EnableSwagger2Doc
+@EnableAsync
+public class UserApplication {
+
+	public static void main(String[] args) {
+		SpringApplication.run(UserApplication.class, args);
+	}
+	
+	@Bean
+	@LoadBalanced
+	public RestTemplate restTemplate(){
+		return new RestTemplate();
+	}
+}

+ 81 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/config/AuthorizationServerConfig.java

@@ -0,0 +1,81 @@
+package com.keao.edu.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.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.DefaultTokenServices;
+import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
+
+import com.keao.edu.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 {
+
+		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_");
+
+		clients.withClientDetails(clientDetailsService);
+	}
+
+	@Bean
+	public RedisTokenStore redisTokenStore() {
+		RedisTokenStore tokenStore = new RedisTokenStore(connectionFactory);
+		tokenStore.setPrefix(CommonConstants.OAUTH_PREFIX);
+		return tokenStore;
+	}
+
+	@Bean
+	public DefaultTokenServices defaultTokenServices() {
+		DefaultTokenServices tokenServices = new DefaultTokenServices();
+		tokenServices.setTokenStore(redisTokenStore());
+		tokenServices.setSupportRefreshToken(true);
+		//tokenServices.setAccessTokenValiditySeconds(60 * 60 * 24); // token有效期自定义设置,默认12小时
+		//tokenServices.setRefreshTokenValiditySeconds(60 * 60 * 24 * 30);// 默认30天,这里修改
+		return tokenServices;
+	}
+
+}

+ 52 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/config/PermissionCheckService.java

@@ -0,0 +1,52 @@
+package com.keao.edu.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.keao.edu.auth.api.entity.SysUser;
+import com.keao.edu.auth.service.SysUserService;
+import com.keao.edu.common.security.AuthUser;
+import com.keao.edu.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
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/config/RequestUtils.java

@@ -0,0 +1,84 @@
+package com.keao.edu.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;
+    }
+}

+ 37 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/config/ResourceServerConfig.java

@@ -0,0 +1,37 @@
+package com.keao.edu.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.keao.edu.common.security.BaseAccessDeniedHandler;
+import com.keao.edu.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").hasIpAddress("0.0.0.0/0").anyRequest().authenticated().and().httpBasic();
+	}
+
+	@Override
+	public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
+		resources.authenticationEntryPoint(baseAuthenticationEntryPoint).accessDeniedHandler(baseAccessDeniedHandler);
+	}
+
+}

+ 36 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/config/WebMvcConfig.java

@@ -0,0 +1,36 @@
+package com.keao.edu.auth.config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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.WebMvcConfigurer;
+
+import com.keao.edu.common.config.EnumConverterFactory;
+import com.keao.edu.common.config.LocalFastJsonHttpMessageConverter;
+
+@Configuration
+public class WebMvcConfig implements WebMvcConfigurer {
+
+	/**
+	 * 枚举类的转换器 addConverterFactory
+	 */
+	@Override
+	public void addFormatters(FormatterRegistry registry) {
+		registry.addConverterFactory(new EnumConverterFactory());
+	}
+	
+	@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);
+    }
+
+}

+ 132 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/config/WebSecurityConfig.java

@@ -0,0 +1,132 @@
+package com.keao.edu.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.keao.edu.auth.core.filter.PhoneLoginAuthenticationFilter;
+import com.keao.edu.auth.core.filter.UsernameAuthenticationFilter;
+import com.keao.edu.auth.core.handler.BaseAuthenticationFailureEvenHandler;
+import com.keao.edu.auth.core.handler.BaseAuthenticationSuccessEventHandler;
+import com.keao.edu.auth.core.provider.PhoneAuthenticationProvider;
+import com.keao.edu.auth.core.provider.service.DefaultUserDetailsService;
+import com.keao.edu.auth.service.SysUserService;
+import com.keao.edu.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;
+	
+	@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.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);
+		return filter;
+	}
+
+	@Bean
+	public PhoneLoginAuthenticationFilter getPhoneLoginAuthenticationFilter() throws Exception {
+		PhoneLoginAuthenticationFilter filter = new PhoneLoginAuthenticationFilter();
+		filter.setAuthenticationManager(authenticationManagerBean());
+		filter.setAuthenticationSuccessHandler(successEventHandler);
+		filter.setAuthenticationFailureHandler(failureEvenHandler);
+		filter.setSysUserService(sysUserService);
+		return filter;
+	}
+
+}

+ 79 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/config/token/PhoneAuthenticationToken.java

@@ -0,0 +1,79 @@
+package com.keao.edu.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;
+	}
+}

+ 106 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/core/filter/PhoneLoginAuthenticationFilter.java

@@ -0,0 +1,106 @@
+package com.keao.edu.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.authentication.LockedException;
+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.keao.edu.auth.api.dto.SysUserInfo;
+import com.keao.edu.auth.api.entity.LoginEntity;
+import com.keao.edu.auth.config.token.PhoneAuthenticationToken;
+import com.keao.edu.auth.service.SysUserService;
+import com.keao.edu.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_REGISTER_PARAMETER = "register";
+	private static final String IS_LESSEE = "isLessee";
+
+	private static final String SPRING_SECURITY_RESTFUL_LOGIN_URL = "/smsLogin";
+	private boolean postOnly = true;
+
+	private SysUserService sysUserService;
+
+	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 isRegister = obtainParameter(request, IS_REGISTER_PARAMETER);
+		// 是否是租户
+		String isLessee = obtainParameter(request, IS_LESSEE);
+
+		String clientId = request.getParameter(clientIdParameter).toUpperCase();
+
+//		SysUserInfo userInfo = sysUserService.queryUserInfoByPhone(principal);
+		SysUserInfo userInfo = sysUserService.queryUserInfoByPhoneAndClient(principal,clientId);
+		if (userInfo != null && StringUtils.isNotEmpty(isLessee)) {
+			throw new LockedException("用户已存在");
+		}
+		if ("EDUCATION".equals(clientId)) {
+			clientId = "SYSTEM";
+		}
+		if (userInfo != null && !userInfo.getSysUser().getUserType().contains(clientId)) {
+			throw new LockedException("用户不存在,请联系教务老师");
+		}
+
+		principal = principal.trim();
+
+		LoginEntity loginEntity = new LoginEntity();
+		loginEntity.setClientId(clientId);
+		loginEntity.setIsLessee(isLessee);
+		loginEntity.setPhone(principal);
+		loginEntity.setSmsCode(credentials);
+		loginEntity.setIsRegister(isRegister);
+
+		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;
+	}
+
+	public void setSysUserService(SysUserService sysUserService) {
+		this.sysUserService = sysUserService;
+	}
+
+}

+ 189 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/core/filter/UsernameAuthenticationFilter.java

@@ -0,0 +1,189 @@
+package com.keao.edu.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.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.keao.edu.auth.api.dto.SysUserInfo;
+import com.keao.edu.auth.service.SysUserService;
+import com.keao.edu.common.security.SecurityConstants;
+
+public class UsernameAuthenticationFilter extends AbstractAuthenticationProcessingFilter {
+
+	private SysUserService sysUserService;
+
+	// ~ Static fields/initializers
+	// =====================================================================================
+
+	private String usernameParameter = "username";
+	private String passwordParameter = "password";
+	private String clientIdParameter = "clientId";
+	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);
+
+		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);
+	}
+
+	/**
+	 * 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;
+	}
+
+}

+ 74 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/core/handler/AuthenticationFailureListener.java

@@ -0,0 +1,74 @@
+package com.keao.edu.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.keao.edu.auth.api.entity.SysUser;
+import com.keao.edu.auth.api.entity.SysUserLogin;
+import com.keao.edu.auth.service.SysUserLoginService;
+import com.keao.edu.auth.service.SysUserService;
+import com.keao.edu.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.queryByPhone(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
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/core/handler/BaseAuthenticationFailureEvenHandler.java

@@ -0,0 +1,46 @@
+package com.keao.edu.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.keao.edu.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));
+    }
+}

+ 153 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/core/handler/BaseAuthenticationSuccessEventHandler.java

@@ -0,0 +1,153 @@
+package com.keao.edu.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.beans.factory.annotation.Value;
+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.keao.edu.auth.api.entity.SysUser;
+import com.keao.edu.auth.api.entity.SysUserLogin;
+import com.keao.edu.auth.api.entity.SysUserLoginLog;
+import com.keao.edu.auth.service.SysUserLoginLogService;
+import com.keao.edu.auth.service.SysUserLoginService;
+import com.keao.edu.auth.service.SysUserService;
+import com.keao.edu.common.entity.HttpResponseResult;
+import com.keao.edu.common.security.SecurityConstants;
+import com.keao.edu.im.api.client.ImFeignService;
+import com.keao.edu.im.api.entity.ImResult;
+import com.keao.edu.im.api.entity.ImUserModel;
+
+@Component
+public class BaseAuthenticationSuccessEventHandler extends SavedRequestAwareAuthenticationSuccessHandler {
+
+	@Autowired
+	private SysUserLoginService sysUserLoginService;
+	@Autowired
+	private SysUserLoginLogService sysUserLoginLogService;
+	@Autowired
+	private SysUserService sysUserService;
+	@Autowired
+	private ObjectMapper objectMapper;
+	@Autowired
+	private ImFeignService imFeignService;
+	
+	@Autowired
+	private ClientDetailsService clientDetailsService;
+
+	@Value("${auth.sysconfig.tenantId}")
+	private Integer tenantClientId;
+
+	@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.queryByPhone(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);
+			
+			String tenantId = "1";
+			map.put("tenantId", tenantId);
+
+			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
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/core/provider/AbstractAuthenticationProvider.java

@@ -0,0 +1,167 @@
+package com.keao.edu.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");
+			}
+		}
+	}
+}

+ 97 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/core/provider/PhoneAuthenticationProvider.java

@@ -0,0 +1,97 @@
+package com.keao.edu.auth.core.provider;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.security.authentication.BadCredentialsException;
+import org.springframework.security.authentication.InternalAuthenticationServiceException;
+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.keao.edu.auth.api.dto.SysUserInfo;
+import com.keao.edu.auth.api.entity.LoginEntity;
+import com.keao.edu.auth.config.token.PhoneAuthenticationToken;
+import com.keao.edu.auth.service.SysUserService;
+import com.keao.edu.common.security.SecurityConstants;
+import com.keao.edu.common.service.IdGeneratorService;
+
+public class PhoneAuthenticationProvider extends AbstractAuthenticationProvider {
+
+	private UserDetailsService userDetailsService;
+
+	private IdGeneratorService smsCodeService;
+
+	private SysUserService sysUserService;
+
+	@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 phone, Authentication authentication) throws AuthenticationException {
+
+		LoginEntity loginEntity = (LoginEntity) authentication.getCredentials();
+		if (loginEntity == null) {
+			throw new BadCredentialsException("Bad credentials");
+		}
+
+		String smsCode = loginEntity.getSmsCode();
+
+		// 验证码验证
+		boolean b = smsCodeService.verifyValidCode(StringUtils.substringAfter(phone, SecurityConstants.PHONE_PRINCIPAL_PREFIX), smsCode);
+		if (!b) {
+			throw new BadCredentialsException("验证码校验失败");
+		}
+
+		SysUserInfo userInfo = sysUserService.queryUserInfoByPhone(loginEntity.getPhone());
+		if (userInfo == null && StringUtils.isNotEmpty(loginEntity.getIsLessee())) {
+			sysUserService.initUser(loginEntity.getPhone(), loginEntity.getClientId(), loginEntity.getIsRegister(), loginEntity.getIsLessee());
+		}
+
+		UserDetails loadedUser;
+		try {
+			loadedUser = userDetailsService.loadUserByUsername(phone);
+		} 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;
+	}
+}

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

@@ -0,0 +1,81 @@
+package com.keao.edu.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.keao.edu.auth.api.dto.SysUserInfo;
+import com.keao.edu.auth.api.entity.SysUser;
+import com.keao.edu.auth.service.SysUserService;
+import com.keao.edu.common.security.AuthUser;
+import com.keao.edu.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);
+	}
+
+}

+ 41 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/core/service/AccessTokenService.java

@@ -0,0 +1,41 @@
+package com.keao.edu.auth.core.service;
+
+import java.util.HashMap;
+
+import org.springframework.beans.factory.annotation.Autowired;
+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.stereotype.Service;
+
+@Service
+public class AccessTokenService {
+
+	@Autowired
+	private ClientDetailsService clientDetailsService;
+
+	@Autowired
+	private AuthorizationServerTokenServices defaultAuthorizationServerTokenServices;
+
+	public OAuth2AccessToken getAccessToken(String clientId, String clientSecret, Authentication authentication) {
+
+		if (clientId == null || clientSecret == null) {
+			throw new UnapprovedClientAuthenticationException("请求头中client信息为空");
+		}
+
+		ClientDetails clientDetails = clientDetailsService.loadClientByClientId(clientId);
+		TokenRequest tokenRequest = new TokenRequest(new HashMap<String, String>(), clientId, clientDetails.getScope(), "password");
+		OAuth2Request oAuth2Request = tokenRequest.createOAuth2Request(clientDetails);
+
+		OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(oAuth2Request, authentication);
+		OAuth2AccessToken oAuth2AccessToken = defaultAuthorizationServerTokenServices.createAccessToken(oAuth2Authentication);
+
+		return oAuth2AccessToken;
+	}
+}

+ 55 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/dal/dao/SysMenuDao.java

@@ -0,0 +1,55 @@
+package com.keao.edu.auth.dal.dao;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
+
+import com.keao.edu.auth.api.entity.SysMenu;
+import com.keao.edu.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
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/dal/dao/SysOauthClientDetailsDao.java

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

+ 25 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/dal/dao/SysRoleDao.java

@@ -0,0 +1,25 @@
+package com.keao.edu.auth.dal.dao;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
+
+import com.keao.edu.auth.api.entity.SysRole;
+import com.keao.edu.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);
+}

+ 9 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/dal/dao/SysRoleDeptDao.java

@@ -0,0 +1,9 @@
+package com.keao.edu.auth.dal.dao;
+
+import com.keao.edu.auth.api.entity.SysRoleDept;
+import com.keao.edu.common.dal.BaseDAO;
+
+public interface SysRoleDeptDao extends BaseDAO<Integer, SysRoleDept> {
+
+	
+}

+ 45 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/dal/dao/SysRoleMenuDao.java

@@ -0,0 +1,45 @@
+package com.keao.edu.auth.dal.dao;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
+
+import com.keao.edu.auth.api.entity.SysRoleMenu;
+import com.keao.edu.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);
+}

+ 95 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/dal/dao/SysUserDao.java

@@ -0,0 +1,95 @@
+package com.keao.edu.auth.dal.dao;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
+
+import com.keao.edu.auth.api.entity.SysUser;
+import com.keao.edu.auth.api.enums.UserLockFlag;
+import com.keao.edu.common.dal.BaseDAO;
+import com.keao.edu.im.api.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 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);
+}

+ 14 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/dal/dao/SysUserLoginDao.java

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

+ 8 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/dal/dao/SysUserLoginLogDao.java

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

+ 31 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/dal/dao/SysUserRoleDao.java

@@ -0,0 +1,31 @@
+package com.keao.edu.auth.dal.dao;
+
+import java.util.List;
+
+import com.keao.edu.auth.api.entity.SysUserRole;
+import com.keao.edu.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);
+}

+ 41 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/dal/enums/UserGenderEnum.java

@@ -0,0 +1,41 @@
+package com.keao.edu.auth.dal.enums;
+
+import com.keao.edu.common.enums.BaseEnum;
+
+/** 
+ * @author sunzl 
+ * 2015年9月7日 下午1:57:10 
+ * 会员性别枚举
+ */
+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;
+	}
+
+}

+ 47 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/dal/enums/UserStatus.java

@@ -0,0 +1,47 @@
+package com.keao.edu.auth.dal.enums;
+
+import com.keao.edu.common.enums.BaseEnum;
+
+/** 
+ * @author sunzl 
+ * 2015年8月25日 下午4:19:00 
+ * 会员状态枚举类
+ */
+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
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/SysMenuService.java

@@ -0,0 +1,37 @@
+package com.keao.edu.auth.service;
+
+import java.util.List;
+
+import com.keao.edu.auth.api.dto.MenuQueryInfo;
+import com.keao.edu.auth.api.entity.SysMenu;
+import com.keao.edu.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
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/SysOauthClientDetailsService.java

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

+ 8 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/SysRoleDeptService.java

@@ -0,0 +1,8 @@
+package com.keao.edu.auth.service;
+
+import com.keao.edu.auth.api.entity.SysRoleDept;
+import com.keao.edu.common.service.BaseService;
+
+public interface SysRoleDeptService extends BaseService<Integer, SysRoleDept> {
+
+}

+ 39 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/SysRoleMenuService.java

@@ -0,0 +1,39 @@
+package com.keao.edu.auth.service;
+
+import java.util.List;
+
+import com.keao.edu.auth.api.entity.SysRoleMenu;
+import com.keao.edu.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
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/SysRoleService.java

@@ -0,0 +1,43 @@
+package com.keao.edu.auth.service;
+
+import java.util.List;
+
+import com.keao.edu.auth.api.entity.SysRole;
+import com.keao.edu.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);
+}

+ 8 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/SysUserLoginLogService.java

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

+ 20 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/SysUserLoginService.java

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

+ 38 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/SysUserRoleService.java

@@ -0,0 +1,38 @@
+package com.keao.edu.auth.service;
+
+import java.util.List;
+
+import com.keao.edu.auth.api.entity.SysUserRole;
+import com.keao.edu.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);
+}

+ 121 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/SysUserService.java

@@ -0,0 +1,121 @@
+package com.keao.edu.auth.service;
+
+import org.springframework.security.core.Authentication;
+
+import com.keao.edu.auth.api.dto.SysUserInfo;
+import com.keao.edu.auth.api.entity.SysUser;
+import com.keao.edu.common.service.BaseService;
+import com.keao.edu.im.api.entity.ImUserModel;
+
+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 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 phone,String clientId,String isRegister,String isLessee);
+
+	/**
+	 * 获取老师的分部编号
+	 * @param phone
+	 * @return
+	 */
+	void retrieveUser(String phone, Authentication authentication);
+
+	/**
+	 * 刷新token
+	 * @param sysUser
+	 */
+    void refreshImToken(SysUser sysUser);
+
+	/**
+	 * 保存student数据
+	 * @param userId
+	 */
+	void saveStudent(Integer userId);
+}

+ 92 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/impl/SysMenuServiceImpl.java

@@ -0,0 +1,92 @@
+package com.keao.edu.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.keao.edu.auth.api.dto.MenuQueryInfo;
+import com.keao.edu.auth.api.entity.SysMenu;
+import com.keao.edu.auth.api.entity.SysUser;
+import com.keao.edu.auth.dal.dao.SysMenuDao;
+import com.keao.edu.auth.dal.dao.SysUserDao;
+import com.keao.edu.auth.service.SysMenuService;
+import com.keao.edu.common.dal.BaseDAO;
+import com.keao.edu.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);
+	}
+
+	@Override
+	public List<SysMenu> findByUser(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;
+	}
+
+	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
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/impl/SysOauthClientDetailsServiceImpl.java

@@ -0,0 +1,23 @@
+package com.keao.edu.auth.service.impl;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.keao.edu.auth.api.entity.SysOauthClientDetails;
+import com.keao.edu.auth.dal.dao.SysOauthClientDetailsDao;
+import com.keao.edu.auth.service.SysOauthClientDetailsService;
+import com.keao.edu.common.dal.BaseDAO;
+import com.keao.edu.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;
+	}
+	
+}

+ 23 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/impl/SysRoleDeptServiceImpl.java

@@ -0,0 +1,23 @@
+package com.keao.edu.auth.service.impl;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.keao.edu.auth.api.entity.SysRoleDept;
+import com.keao.edu.auth.dal.dao.SysRoleDeptDao;
+import com.keao.edu.auth.service.SysRoleDeptService;
+import com.keao.edu.common.dal.BaseDAO;
+import com.keao.edu.common.service.impl.BaseServiceImpl;
+
+@Service
+public class SysRoleDeptServiceImpl extends BaseServiceImpl<Integer, SysRoleDept>  implements SysRoleDeptService {
+	
+	@Autowired
+	private SysRoleDeptDao sysRoleDeptDao;
+
+	@Override
+	public BaseDAO<Integer, SysRoleDept> getDAO() {
+		return sysRoleDeptDao;
+	}
+	
+}

+ 66 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/impl/SysRoleMenuServiceImpl.java

@@ -0,0 +1,66 @@
+package com.keao.edu.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.keao.edu.auth.api.entity.SysRoleMenu;
+import com.keao.edu.auth.dal.dao.SysRoleMenuDao;
+import com.keao.edu.auth.service.SysRoleMenuService;
+import com.keao.edu.common.dal.BaseDAO;
+import com.keao.edu.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;
+	}
+
+}

+ 82 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/impl/SysRoleServiceImpl.java

@@ -0,0 +1,82 @@
+package com.keao.edu.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.keao.edu.auth.api.entity.SysRole;
+import com.keao.edu.auth.dal.dao.SysRoleDao;
+import com.keao.edu.auth.dal.dao.SysRoleMenuDao;
+import com.keao.edu.auth.service.SysRoleService;
+import com.keao.edu.common.dal.BaseDAO;
+import com.keao.edu.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) {
+		sysRoleDao.insert(sysRole);
+		batchSave(sysRole);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateRole(SysRole sysRole) {
+		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);
+//			});
+		}
+	}
+
+}

+ 22 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/impl/SysUserLoginLogServiceImpl.java

@@ -0,0 +1,22 @@
+package com.keao.edu.auth.service.impl;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.keao.edu.auth.api.entity.SysUserLoginLog;
+import com.keao.edu.auth.dal.dao.SysUserLoginLogDao;
+import com.keao.edu.auth.service.SysUserLoginLogService;
+import com.keao.edu.common.dal.BaseDAO;
+import com.keao.edu.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
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/impl/SysUserLoginServiceImpl.java

@@ -0,0 +1,72 @@
+package com.keao.edu.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.keao.edu.auth.api.entity.SysUser;
+import com.keao.edu.auth.api.entity.SysUserLogin;
+import com.keao.edu.auth.api.enums.UserLockFlag;
+import com.keao.edu.auth.dal.dao.SysUserDao;
+import com.keao.edu.auth.dal.dao.SysUserLoginDao;
+import com.keao.edu.auth.service.SysUserLoginService;
+import com.keao.edu.common.dal.BaseDAO;
+import com.keao.edu.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
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/impl/SysUserRoleServiceImpl.java

@@ -0,0 +1,58 @@
+package com.keao.edu.auth.service.impl;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.keao.edu.auth.api.entity.SysUserRole;
+import com.keao.edu.auth.dal.dao.SysUserRoleDao;
+import com.keao.edu.auth.service.SysUserRoleService;
+import com.keao.edu.common.dal.BaseDAO;
+import com.keao.edu.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;
+	}
+
+}

+ 219 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/impl/SysUserServiceImpl.java

@@ -0,0 +1,219 @@
+package com.keao.edu.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.security.authentication.BadCredentialsException;
+import org.springframework.security.authentication.LockedException;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.keao.edu.auth.api.dto.SysUserInfo;
+import com.keao.edu.auth.api.entity.LoginEntity;
+import com.keao.edu.auth.api.entity.SysUser;
+import com.keao.edu.auth.dal.dao.SysUserDao;
+import com.keao.edu.auth.service.SysRoleMenuService;
+import com.keao.edu.auth.service.SysUserRoleService;
+import com.keao.edu.auth.service.SysUserService;
+import com.keao.edu.common.dal.BaseDAO;
+import com.keao.edu.common.exception.BizException;
+import com.keao.edu.common.service.IdGeneratorService;
+import com.keao.edu.common.service.impl.BaseServiceImpl;
+import com.keao.edu.im.api.client.ImFeignService;
+import com.keao.edu.im.api.entity.ImResult;
+import com.keao.edu.im.api.entity.ImUserModel;
+
+@Service
+public class SysUserServiceImpl extends BaseServiceImpl<Integer, SysUser> implements SysUserService {
+
+	@Autowired
+	private SysUserDao sysUserDao;
+
+	@Autowired
+	private SysUserRoleService sysUserRoleService;
+
+	@Autowired
+	private SysRoleMenuService sysRoleMenuService;
+	@Autowired
+	private ImFeignService imFeignService;
+	@Autowired
+	private SysUserService sysUserService;
+	@Autowired
+	private IdGeneratorService smsCodeService;
+
+	@Value("${message.autoRegister}")
+	private boolean autoRegister;
+	@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 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(queryByPhone(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(1);
+
+		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);
+		ImResult imResult = imFeignService.register(new ImUserModel(sysUser.getId().toString(), sysUser.getUsername(), sysUser.getAvatar()));
+		sysUser.setImToken(imResult.getToken());
+		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);
+		imFeignService.update(new ImUserModel(sysUser.getId().toString(),sysUser.getRealName()==null?sysUser.getUsername():sysUser.getRealName(),sysUser.getAvatar()));
+	}
+
+	@Override
+	public SysUser queryUserInfo(Integer userId) {
+		return sysUserDao.get(userId);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public SysUserInfo initUser(String phone, String clientId,String isRegister,String isLessee) {
+		if("register".equals(isRegister)){
+			throw new UsernameNotFoundException("404.9");
+		}
+		if(StringUtils.isNotEmpty(isLessee) || autoRegister){
+			if(StringUtils.isNotEmpty(isLessee) && 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));
+				//sysTenantAccount
+				sysUserDao.insertSysTenantAccount(sysUser.getId());
+				//创建teacher表
+				sysUserDao.insertTeacher(sysUser.getId(),lesseeOrganId);
+				return queryUserInfoByPhone(phone);
+			}else if(StringUtils.isNotEmpty(isLessee) && StringUtils.equalsIgnoreCase(clientId,"STUDENT")){
+				SysUser sysUser = new SysUser();
+				sysUser.setPhone(phone);
+				sysUser.setUserType("STUDENT");
+				sysUser.setOrganId(lesseeOrganId);
+				sysUserDao.insert(sysUser);
+				sysUserService.saveStudent(sysUser.getId());
+				//添加用户现金账户
+				imFeignService.register(new ImUserModel(sysUser.getId().toString(),phone,null));
+				return queryUserInfoByPhone(phone);
+			}
+		}
+		throw new UsernameNotFoundException("404.9");
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void retrieveUser(String phone, Authentication authentication) {
+		LoginEntity loginEntity = (LoginEntity) authentication.getCredentials();
+		SysUserInfo userInfo = sysUserService.queryUserInfoByPhone(loginEntity.getPhone());
+		if (userInfo == null) {
+			userInfo = sysUserService.initUser(loginEntity.getPhone(),loginEntity.getClientId(),loginEntity.getIsRegister(),loginEntity.getIsLessee());
+		}else if(StringUtils.isNotEmpty(loginEntity.getIsLessee())){
+			throw new LockedException("用户已存在");
+		}
+		if("EDUCATION".equals(loginEntity.getClientId())){
+			loginEntity.setClientId("SYSTEM");
+		}
+		if (!userInfo.getSysUser().getUserType().contains(loginEntity.getClientId())) {
+			throw new LockedException("用户不存在,请联系教务老师");
+		}
+//			 验证码验证
+		boolean b = smsCodeService.verifyValidCode(loginEntity.getPhone(), loginEntity.getSmsCode());
+		if(!b) throw new BadCredentialsException("验证码校验失败");
+	}
+
+	@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);
+	}
+
+}

+ 88 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/web/controller/MenuController.java

@@ -0,0 +1,88 @@
+package com.keao.edu.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.keao.edu.auth.api.dto.MenuQueryInfo;
+import com.keao.edu.auth.api.entity.SysMenu;
+import com.keao.edu.auth.service.SysMenuService;
+import com.keao.edu.common.controller.BaseController;
+import com.keao.edu.common.security.AuthUser;
+import com.keao.edu.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();
+    }
+
+}

+ 126 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/web/controller/RoleController.java

@@ -0,0 +1,126 @@
+package com.keao.edu.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.keao.edu.auth.api.entity.SysRole;
+import com.keao.edu.auth.service.SysMenuService;
+import com.keao.edu.auth.service.SysRoleMenuService;
+import com.keao.edu.auth.service.SysRoleService;
+import com.keao.edu.auth.service.SysUserRoleService;
+import com.keao.edu.common.controller.BaseController;
+import com.keao.edu.common.page.QueryInfo;
+import com.keao.edu.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
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/web/controller/TaskController.java

@@ -0,0 +1,23 @@
+package com.keao.edu.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.keao.edu.auth.service.SysUserLoginService;
+import com.keao.edu.common.controller.BaseController;
+
+@RestController
+@RequestMapping("task")
+public class TaskController extends BaseController {
+
+	@Autowired
+	private SysUserLoginService sysUserLoginService;
+
+	@GetMapping("/autoUnlock")
+	public void autoUnlock() {
+		sysUserLoginService.autoUnlock();
+	}
+
+}

+ 144 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/web/controller/TokenController.java

@@ -0,0 +1,144 @@
+package com.keao.edu.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.Date;
+import java.util.Map;
+
+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.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.oauth2.common.OAuth2AccessToken;
+import org.springframework.security.oauth2.provider.token.DefaultTokenServices;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.client.RestTemplate;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.keao.edu.auth.api.entity.SysUser;
+import com.keao.edu.auth.service.SysUserService;
+import com.keao.edu.common.controller.BaseController;
+import com.keao.edu.common.entity.HttpResponseResult;
+import com.keao.edu.common.security.AuthUser;
+import com.keao.edu.common.security.SecurityUtils;
+import com.keao.edu.im.api.client.ImFeignService;
+import com.keao.edu.im.api.entity.ImResult;
+import com.keao.edu.im.api.entity.ImUserModel;
+
+@RestController
+@Api(tags = "认证服务")
+public class TokenController extends BaseController {
+
+	@Autowired
+	private DefaultTokenServices tokenService;
+
+	@Autowired
+	private RestTemplate restTemplate;
+
+	@Autowired
+	private ObjectMapper objectMapper;
+
+	@Autowired
+	private SysUserService userService;
+
+	@Autowired
+	private ImFeignService imFeignService;
+    
+    @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());
+			if(StringUtils.isEmpty(sysUser.getImToken())){
+				ImResult register = imFeignService.register(new ImUserModel(sysUser.getId().toString(), sysUser.getUsername(), null));
+				sysUser.setImToken(register.getToken());
+				sysUser.setUpdateTime(new Date());
+				userService.update(sysUser);
+			}
+			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 logout(@RequestHeader(value = HttpHeaders.AUTHORIZATION) String authHeader) {
+		if (StringUtils.isBlank(authHeader)) {
+			return failed("退出失败,token 为空");
+		}
+
+		String tokenValue = authHeader.toLowerCase().replace(OAuth2AccessToken.BEARER_TYPE.toLowerCase(), StringUtils.EMPTY).trim();
+
+		tokenService.revokeToken(tokenValue);
+
+		return succeed("退出成功");
+	}
+
+}

+ 325 - 0
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/web/controller/UserController.java

@@ -0,0 +1,325 @@
+package com.keao.edu.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.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.keao.edu.auth.api.entity.SysUser;
+import com.keao.edu.auth.service.SysRoleService;
+import com.keao.edu.auth.service.SysUserRoleService;
+import com.keao.edu.auth.service.SysUserService;
+import com.keao.edu.auth.web.controller.queryInfo.SysUserQueryInfo;
+import com.keao.edu.common.controller.BaseController;
+import com.keao.edu.common.exception.BizException;
+import com.keao.edu.common.security.AuthUser;
+import com.keao.edu.common.security.SecurityConstants;
+import com.keao.edu.common.security.SecurityUtils;
+import com.keao.edu.common.service.IdGeneratorService;
+import com.keao.edu.im.api.client.ImFeignService;
+import com.keao.edu.im.api.entity.ImResult;
+import com.keao.edu.im.api.entity.ImUserModel;
+import com.keao.edu.util.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;
+
+	@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 = "/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 = "新增用户")
+	@PreAuthorize("@pcs.hasPermissions('user/add')")
+	@PostMapping(value = "/add", consumes = MediaType.APPLICATION_JSON_VALUE)
+	public Object 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());
+		}
+		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("出生日期不可超过当前时间");
+			}
+			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) {
+			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();
+	}
+}

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

@@ -0,0 +1,36 @@
+package com.keao.edu.auth.web.controller.queryInfo;
+
+import com.keao.edu.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;
+	}
+}

+ 23 - 0
edu-auth/pom.xml

@@ -0,0 +1,23 @@
+<?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>
+    <groupId>com.keao.edu</groupId>
+    <artifactId>edu-saas</artifactId>
+    <version>1.0</version>
+  </parent>
+  <groupId>com.keao.edu</groupId>
+  <artifactId>edu-auth</artifactId>
+  <version>1.0</version>
+  <packaging>pom</packaging>
+  <name>edu-auth</name>
+  <url>http://maven.apache.org</url>
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+  <dependencies>
+  </dependencies>
+<modules>  <module>edu-auth-api</module>
+    <module>edu-auth-server</module>
+  </modules>
+</project>

+ 49 - 0
edu-cms/pom.xml

@@ -0,0 +1,49 @@
+<?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.keao.edu</groupId>
+		<artifactId>edu-saas</artifactId>
+		<version>1.0</version>
+	</parent>
+	<artifactId>edu-cms</artifactId>
+	<name>edu-cms</name>
+	<url>http://maven.apache.org</url>
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+	</properties>
+	<dependencies>
+		<dependency>
+			<groupId>com.keao.edu</groupId>
+			<artifactId>edu-common</artifactId>
+		</dependency>
+		
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-starter-netflix-eureka-client</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>mysql</groupId>
+			<artifactId>mysql-connector-java</artifactId>
+		</dependency>
+	</dependencies>
+</project>

+ 34 - 0
edu-cms/src/main/java/com/keao/edu/cms/CmsServerApplication.java

@@ -0,0 +1,34 @@
+package com.keao.edu.cms;
+
+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.web.client.RestTemplate;
+
+import com.spring4all.swagger.EnableSwagger2Doc;
+
+@SpringBootApplication
+@EnableDiscoveryClient
+@EnableFeignClients("com.ym.mec")
+@MapperScan("com.ym.mec.cms.dal.dao")
+@ComponentScan(basePackages = { "com.ym.mec.cms", "com.ym.mec.im", "com.ym.mec.auth", "com.ym.mec.common.config", "com.ym.mec.common.security" })
+@Configuration
+@EnableSwagger2Doc
+public class CmsServerApplication {
+
+	public static void main(String[] args) {
+		SpringApplication.run(CmsServerApplication.class, args);
+	}
+
+	@Bean
+	@LoadBalanced
+	public RestTemplate restTemplate() {
+		return new RestTemplate();
+	}
+}

+ 42 - 0
edu-cms/src/main/java/com/keao/edu/cms/config/ResourceServerConfig.java

@@ -0,0 +1,42 @@
+package com.keao.edu.cms.config;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
+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.keao.edu.common.security.BaseAccessDeniedHandler;
+import com.keao.edu.common.security.BaseAuthenticationEntryPoint;
+
+@Configuration
+@EnableResourceServer
+@EnableGlobalMethodSecurity(prePostEnabled = true)
+public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
+
+	@Autowired
+	private BaseAccessDeniedHandler baseAccessDeniedHandler;
+
+	@Autowired
+	private BaseAuthenticationEntryPoint baseAuthenticationEntryPoint;
+
+	@Override
+	public void configure(HttpSecurity http) throws Exception {
+		http.authorizeRequests()
+				.antMatchers("/v2/api-docs", "/news/list", "/news/query", "/news/homeList")
+				.permitAll()
+				// 任何人不登录都可以获取的资源
+				// .antMatchers("/ipController/**").hasIpAddress("127.0.0.1") //特定ip可以不登录获取资源
+				// .antMatchers("/ipControll/**").access("isAuthenticated() and hasIpAddress('127.0.0.1')")// 特定ip必须登录才能获取
+				.anyRequest().authenticated().and().csrf().disable().exceptionHandling().accessDeniedHandler(baseAccessDeniedHandler)
+				.authenticationEntryPoint(baseAuthenticationEntryPoint).and();
+	}
+
+	@Override
+	public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
+		resources.authenticationEntryPoint(baseAuthenticationEntryPoint).accessDeniedHandler(baseAccessDeniedHandler);
+	}
+
+}

+ 36 - 0
edu-cms/src/main/java/com/keao/edu/cms/config/WebMvcConfig.java

@@ -0,0 +1,36 @@
+package com.keao.edu.cms.config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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.WebMvcConfigurer;
+
+import com.keao.edu.common.config.EnumConverterFactory;
+import com.keao.edu.common.config.LocalFastJsonHttpMessageConverter;
+
+@Configuration
+public class WebMvcConfig implements WebMvcConfigurer {
+
+	/**
+	 * 枚举类的转换器 addConverterFactory
+	 */
+	@Override
+	public void addFormatters(FormatterRegistry registry) {
+		registry.addConverterFactory(new EnumConverterFactory());
+	}
+	
+	@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);
+    }
+
+}

+ 82 - 0
edu-cms/src/main/java/com/keao/edu/cms/controller/HelpCenterCatalogController.java

@@ -0,0 +1,82 @@
+package com.keao.edu.cms.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 java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+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.keao.edu.cms.dal.entity.HelpCenterCatalog;
+import com.keao.edu.cms.service.HelpCenterCatalogService;
+import com.keao.edu.cms.service.HelpCenterContentService;
+import com.keao.edu.common.controller.BaseController;
+
+@RestController
+@RequestMapping("helpCenterCatalog")
+@Api(tags = "帮助中心分类")
+public class HelpCenterCatalogController extends BaseController {
+
+	@Autowired
+	private HelpCenterCatalogService helpCenterCatalogService;
+
+	@Autowired
+	private HelpCenterContentService helpCenterContentService;
+
+	@ApiOperation("分类列表分页查询")
+	@GetMapping(value = "list")
+	@ApiImplicitParams({ @ApiImplicitParam(name = "parentId", value = "父分类编号(可为空)", required = true, dataType = "Integer"),
+			@ApiImplicitParam(name = "status", value = "状态(1,显示 0,隐藏;可为空)", required = true, dataType = "Integer") })
+	public Object list(Integer parentId, Integer status) {
+		List<HelpCenterCatalog> dataList = helpCenterCatalogService.queryByParentId(parentId, status);
+		return succeed(dataList);
+	}
+
+	@ApiOperation("分类详情查询")
+	@GetMapping(value = "get")
+	@ApiImplicitParam(name = "id", value = "分类编号", required = true, dataType = "Integer", paramType = "path")
+	public Object findHelpCatalogById(Integer id) {
+		if (id == null || id <= 0)
+			return failed("请检查输入的ID");
+		return succeed(helpCenterCatalogService.get(id));
+	}
+
+	@ApiOperation("修改分类")
+	@PostMapping(value = "modify", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+	public Object modifyHelpCatalog(HelpCenterCatalog helpCatalog) {
+		if (helpCatalog == null)
+			return failed("参数输入有误");
+		if (helpCatalog.getId() != null && helpCatalog.getId() > 0) {
+			helpCatalog.setModifyOn(new Date());
+			return helpCenterCatalogService.updateCatalog(helpCatalog) ? succeed() : failed("修改失败");
+		} else {
+			if (StringUtils.isBlank(helpCatalog.getText())) {
+				return failed("帮助分类不能为空");
+			}
+			helpCatalog.setCreateOn(new Date());
+			return helpCenterCatalogService.insert(helpCatalog) > 0 ? succeed() : failed("添加失败");
+		}
+	}
+
+	@ApiOperation("删除分类")
+	@PostMapping(value = "delete", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+	@ApiImplicitParam(name = "id", value = "分类编号", required = true, dataType = "Integer", paramType = "path")
+	public Object delHelpCatalog(Integer id) {
+		if (id == null || id <= 0)
+			return failed("ID解析失败");
+		List<HelpCenterCatalog> list = helpCenterCatalogService.queryByParentId(id, null);
+		if (list != null && list.size() > 0) {
+			return failed("删除失败,请先删除子集分类");
+		}
+		return helpCenterCatalogService.deleteCatalog(id) ? succeed() : failed("删除失败");
+	}
+}

+ 88 - 0
edu-cms/src/main/java/com/keao/edu/cms/controller/HelpCenterContentControlller.java

@@ -0,0 +1,88 @@
+package com.keao.edu.cms.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+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.http.MediaType;
+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.keao.edu.cms.controller.queryinfo.HelpCenterContentQueryInfo;
+import com.keao.edu.cms.dal.entity.HelpCenterContent;
+import com.keao.edu.cms.service.HelpCenterCatalogService;
+import com.keao.edu.cms.service.HelpCenterContentService;
+import com.keao.edu.common.controller.BaseController;
+import com.keao.edu.common.page.PageInfo;
+
+@RestController
+@RequestMapping("helpCenterContent")
+@Api(tags = "帮助中心内容")
+public class HelpCenterContentControlller extends BaseController {
+
+	@Autowired
+	private HelpCenterContentService helpCenterContentService;
+
+	@Autowired
+	private HelpCenterCatalogService helpCenterCatalogService;
+
+	@ApiOperation("帮助中心内容列表分页查询")
+	@GetMapping(value = "list")
+	public Object findHelpContentByCondition(HelpCenterContentQueryInfo queryInfo) {
+
+		queryInfo.setSort("order_");
+		queryInfo.setOrder("asc");
+		PageInfo<HelpCenterContent> data = helpCenterContentService.queryPage(queryInfo);
+		return succeed(data);
+	}
+
+	@ApiOperation("帮助中心内容明细查询")
+	@GetMapping(value = "get")
+	@ApiImplicitParam(name = "id", value = "编号", required = true, dataType = "Integer", paramType = "path")
+	public Object findHelpContentByKey(Integer id) {
+		if (id == null || id <= 0) {
+			return failed("请检查输入的参数");
+		}
+		return succeed(helpCenterContentService.get(id));
+	}
+
+	@ApiOperation("修改帮助中心内容")
+	@PostMapping(value = "modify", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+	public Object modifyHelpContent(HelpCenterContent helpContent) {
+		if (helpContent == null) {
+			return failed("参数输入有误");
+		}
+
+		if (helpContent.getId() != null && helpContent.getId() > 0) {
+			helpContent.setModifyOn(new Date());
+			return helpCenterContentService.update(helpContent) > 0 ? succeed() : failed("修改失败");
+		} else {
+			if (StringUtils.isBlank(helpContent.getContent())) {
+				return failed("帮助内容不能为空");
+			}
+			if (StringUtils.isBlank(helpContent.getTitle())) {
+				return failed("帮助中心标题不能为空");
+			}
+			if (helpContent.getCatalogId() < 0) {
+				return failed("请选择分类");
+			}
+			helpContent.setCreateOn(new Date());
+			return helpCenterContentService.insert(helpContent) > 0 ? succeed() : failed("添加失败");
+		}
+	}
+
+	@ApiOperation("删除帮助中心内容")
+	@PostMapping(value = "delete", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+	@ApiImplicitParam(name = "id", value = "编号", required = true, dataType = "Integer", paramType = "path")
+	public Object delHelpContent(Integer id) {
+		if (id == null || id <= 0)
+			return failed("ID解析失败");
+		return helpCenterContentService.delete(id) > 0 ? succeed() : failed("删除失败");
+	}
+}

+ 76 - 0
edu-cms/src/main/java/com/keao/edu/cms/controller/NewsController.java

@@ -0,0 +1,76 @@
+package com.keao.edu.cms.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+
+import java.util.Date;
+
+import org.springframework.beans.factory.annotation.Autowired;
+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.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.keao.edu.cms.controller.queryinfo.NewsInformationQueryInfo;
+import com.keao.edu.cms.dal.entity.SysNewsInformation;
+import com.keao.edu.cms.service.SysNewsInformationService;
+import com.keao.edu.common.controller.BaseController;
+
+@RestController
+@RequestMapping("news")
+@Api(tags = "资讯服务")
+public class NewsController extends BaseController {
+
+	@Autowired
+	private SysNewsInformationService sysNewsInformationService;
+	
+	@ApiOperation("资讯列表分页查询")
+	@GetMapping(value = "/list")
+	public Object getList(NewsInformationQueryInfo queryInfo) {
+		if(queryInfo.getTenantId() == null){
+			queryInfo.setTenantId(1);
+		}
+		
+		return succeed(sysNewsInformationService.queryPage(queryInfo));
+	}
+
+	@ApiOperation("资讯列表分页查询")
+	@GetMapping(value = "/homeList")
+	public Object getHomeList(NewsInformationQueryInfo queryInfo) {
+		queryInfo.setRows(5);
+		return succeed(sysNewsInformationService.getHomeList(queryInfo));
+	}
+
+	@ApiOperation("查询资讯详情")
+	@ApiImplicitParam(name = "id", value = "资讯ID编号", required = true, dataType = "Long", paramType = "path")
+	@GetMapping(value = "/query")
+	public Object query(Long id) {
+
+		return succeed(sysNewsInformationService.get(id));
+	}
+
+	@ApiOperation("新增资讯")
+	@PostMapping(value = "/add", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+	public Object add(SysNewsInformation newsInfo) {
+		return succeed(sysNewsInformationService.insert(newsInfo));
+	}
+
+	@ApiOperation("更新资讯")
+	@PostMapping(value = "/update", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+	public Object update(SysNewsInformation newsInfo) {
+		Date date = new Date();
+		newsInfo.setUpdateTime(date);
+
+		return succeed(sysNewsInformationService.update(newsInfo));
+	}
+
+	@ApiOperation("删除")
+	@PostMapping(value = "/del/{id}", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+	public Object add(@PathVariable("id") Long id) {
+		return succeed(sysNewsInformationService.deleteWithLogical(id));
+	}
+
+}

+ 42 - 0
edu-cms/src/main/java/com/keao/edu/cms/controller/queryinfo/HelpCenterContentQueryInfo.java

@@ -0,0 +1,42 @@
+package com.keao.edu.cms.controller.queryinfo;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import com.keao.edu.common.page.QueryInfo;
+
+public class HelpCenterContentQueryInfo extends QueryInfo {
+
+	@ApiModelProperty(value = "父分类ID,多个用逗号分隔", required = false)
+	private String catalogIds;
+
+	@ApiModelProperty(value = "标题", required = false)
+	private String title;
+
+	@ApiModelProperty(value = "状态(1-显示 0-隐藏)", required = false)
+	private Integer status;
+
+	public String getCatalogIds() {
+		return catalogIds;
+	}
+
+	public void setCatalogIds(String catalogIds) {
+		this.catalogIds = catalogIds;
+	}
+
+	public String getTitle() {
+		return title;
+	}
+
+	public void setTitle(String title) {
+		this.title = title;
+	}
+
+	public Integer getStatus() {
+		return status;
+	}
+
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+
+}

+ 76 - 0
edu-cms/src/main/java/com/keao/edu/cms/controller/queryinfo/NewsInformationQueryInfo.java

@@ -0,0 +1,76 @@
+package com.keao.edu.cms.controller.queryinfo;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Date;
+
+import com.keao.edu.cms.dal.entity.NewsStatusEnum;
+import com.keao.edu.common.page.QueryInfo;
+
+public class NewsInformationQueryInfo extends QueryInfo {
+
+	@ApiModelProperty(value = "类型,1精彩活动,2热门资讯,3banner类型", required = false)
+	private Integer type;
+
+	@ApiModelProperty(value = "资讯状态", required = false)
+	private NewsStatusEnum status;
+
+	@ApiModelProperty(value = "标题", required = false)
+	private String title;
+
+	@ApiModelProperty(value = "备注", required = false)
+	private String memo;
+	
+	@ApiModelProperty(value = "租客编号", required = false)
+	private Integer tenantId;
+	
+	private Date date;
+
+	public Integer getType() {
+		return type;
+	}
+
+	public void setType(Integer type) {
+		this.type = type;
+	}
+
+	public NewsStatusEnum getStatus() {
+		return status;
+	}
+
+	public void setStatus(NewsStatusEnum status) {
+		this.status = status;
+	}
+
+	public String getTitle() {
+		return title;
+	}
+
+	public void setTitle(String title) {
+		this.title = title;
+	}
+
+	public Date getDate() {
+		return date;
+	}
+
+	public void setDate(Date date) {
+		this.date = date;
+	}
+
+	public String getMemo() {
+		return memo;
+	}
+
+	public void setMemo(String memo) {
+		this.memo = memo;
+	}
+
+	public Integer getTenantId() {
+		return tenantId;
+	}
+
+	public void setTenantId(Integer tenantId) {
+		this.tenantId = tenantId;
+	}
+}

+ 13 - 0
edu-cms/src/main/java/com/keao/edu/cms/dal/dao/HelpCenterCatalogDao.java

@@ -0,0 +1,13 @@
+package com.keao.edu.cms.dal.dao;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
+
+import com.keao.edu.cms.dal.entity.HelpCenterCatalog;
+import com.keao.edu.common.dal.BaseDAO;
+
+public interface HelpCenterCatalogDao extends BaseDAO<Integer, HelpCenterCatalog> {
+
+	public List<HelpCenterCatalog> queryByParentId(@Param("parentId") Integer parentId, @Param("status") Integer status);
+}

+ 13 - 0
edu-cms/src/main/java/com/keao/edu/cms/dal/dao/HelpCenterContentDao.java

@@ -0,0 +1,13 @@
+package com.keao.edu.cms.dal.dao;
+
+import java.util.Map;
+
+import com.keao.edu.cms.dal.entity.HelpCenterContent;
+import com.keao.edu.common.dal.BaseDAO;
+
+public interface HelpCenterContentDao extends BaseDAO<Integer, HelpCenterContent> {
+
+	public int updateContentByCatalog(Map<String, Object> map);
+
+	public int deleteContentByCatalog(Integer catalogId);
+}

+ 28 - 0
edu-cms/src/main/java/com/keao/edu/cms/dal/dao/SysNewsInformationDao.java

@@ -0,0 +1,28 @@
+package com.keao.edu.cms.dal.dao;
+
+import java.util.List;
+import java.util.Map;
+
+import com.keao.edu.cms.dal.entity.SysNewsInformation;
+import com.keao.edu.common.dal.BaseDAO;
+
+public interface SysNewsInformationDao extends BaseDAO<Long, SysNewsInformation> {
+
+	/**
+	 * 根据类型查询资讯列表
+	 * @param type
+	 * @return
+	 */
+	List<SysNewsInformation> queryByType(Integer type);
+
+	/**
+	 * 逻辑删除
+	 * @param id
+	 * @return
+	 */
+	int deleteWithLogical(Long id);
+	
+	List<SysNewsInformation> queryHomePage(Map<String, Object> params);
+	
+	int queryHomeCount(Map<String, Object> params);
+}

+ 126 - 0
edu-cms/src/main/java/com/keao/edu/cms/dal/entity/HelpCenterCatalog.java

@@ -0,0 +1,126 @@
+package com.keao.edu.cms.dal.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.List;
+
+public class HelpCenterCatalog {
+
+	@ApiModelProperty(value = "编号", required = false)
+	private Integer id;
+
+	@ApiModelProperty(value = "父分类ID", required = false)
+	private Integer parentId;
+
+	@ApiModelProperty(value = "分类名称", required = false)
+	private String text;
+
+	@ApiModelProperty(value = "描述", required = false)
+	private String description;
+
+	/**  */
+	private java.util.Date createOn;
+
+	/**  */
+	private java.util.Date modifyOn;
+
+	@ApiModelProperty(value = "排序", required = false)
+	private Integer order;
+
+	/**
+	 * 子集合
+	 */
+	private List<HelpCenterCatalog> children;
+
+	@ApiModelProperty(value = "状态 1 显示 0隐藏", required = false)
+	private Integer status;
+
+	public void setId(Integer id) {
+		this.id = id;
+	}
+
+	public Integer getId() {
+		return this.id;
+	}
+
+	public String getText() {
+		return text;
+	}
+
+	public void setText(String text) {
+		this.text = text;
+	}
+
+	public List<HelpCenterCatalog> getChildren() {
+		return children;
+	}
+
+	public void setChildren(List<HelpCenterCatalog> children) {
+		this.children = children;
+	}
+
+	public void setParentId(Integer parentId) {
+		this.parentId = parentId;
+	}
+
+	public Integer getParentId() {
+		return this.parentId;
+	}
+
+	public void setDescription(String description) {
+		this.description = description;
+	}
+
+	public String getDescription() {
+		return this.description;
+	}
+
+	public void setCreateOn(java.util.Date createOn) {
+		this.createOn = createOn;
+	}
+
+	public java.util.Date getCreateOn() {
+		return this.createOn;
+	}
+
+	public void setModifyOn(java.util.Date modifyOn) {
+		this.modifyOn = modifyOn;
+	}
+
+	public java.util.Date getModifyOn() {
+		return this.modifyOn;
+	}
+
+	public Integer getOrder() {
+		return order;
+	}
+
+	public void setOrder(Integer order) {
+		this.order = order;
+	}
+
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+
+	public Integer getStatus() {
+		return this.status;
+	}
+
+	public String toString() {
+		StringBuilder buf = new StringBuilder();
+		buf.append("HelpCatalog [");
+		buf.append("id=").append(id).append(",");
+		buf.append("parentId=").append(parentId).append(",");
+		buf.append("text=").append(text).append(",");
+		buf.append("description=").append(description).append(",");
+		buf.append("createOn=").append(createOn).append(",");
+		buf.append("modifyOn=").append(modifyOn).append(",");
+		buf.append("order=").append(order).append(",");
+		buf.append("status=").append(status).append(",");
+		buf.setLength(buf.length() - 1);
+		buf.append("]");
+		return buf.toString();
+	}
+
+}

+ 121 - 0
edu-cms/src/main/java/com/keao/edu/cms/dal/entity/HelpCenterContent.java

@@ -0,0 +1,121 @@
+package com.keao.edu.cms.dal.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+
+public class HelpCenterContent {
+
+	@ApiModelProperty(value = "编号", required = false)
+	private Integer id;
+
+	@ApiModelProperty(value = "标题", required = false)
+	private String title;
+
+	@ApiModelProperty(value = "内容", required = false)
+	private String content = "";
+
+	@ApiModelProperty(value = "分类ID", required = false)
+	private Integer catalogId;
+
+	/** 创建时间 */
+	private java.util.Date createOn;
+
+	/** 修改时间 */
+	private java.util.Date modifyOn;
+
+	@ApiModelProperty(value = "状态 1显示 0隐藏", required = false)
+	private Integer status;
+
+	@ApiModelProperty(value = "排序", required = false)
+	private Integer order;
+
+	private HelpCenterCatalog catalog;
+
+	public HelpCenterCatalog getCatalog() {
+		return catalog;
+	}
+
+	public void setCatalog(HelpCenterCatalog catalog) {
+		this.catalog = catalog;
+	}
+
+	public Integer getOrder() {
+		return order;
+	}
+
+	public void setOrder(Integer order) {
+		this.order = order;
+	}
+
+	public void setId(Integer id) {
+		this.id = id;
+	}
+
+	public Integer getId() {
+		return this.id;
+	}
+
+	public void setTitle(String title) {
+		this.title = title;
+	}
+
+	public String getTitle() {
+		return this.title;
+	}
+
+	public void setContent(String content) {
+		this.content = content;
+	}
+
+	public String getContent() {
+		return this.content;
+	}
+
+	public void setCatalogId(Integer catalogId) {
+		this.catalogId = catalogId;
+	}
+
+	public Integer getCatalogId() {
+		return this.catalogId;
+	}
+
+	public void setCreateOn(java.util.Date createOn) {
+		this.createOn = createOn;
+	}
+
+	public java.util.Date getCreateOn() {
+		return this.createOn;
+	}
+
+	public void setModifyOn(java.util.Date modifyOn) {
+		this.modifyOn = modifyOn;
+	}
+
+	public java.util.Date getModifyOn() {
+		return this.modifyOn;
+	}
+
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+
+	public Integer getStatus() {
+		return this.status;
+	}
+
+	public String toString() {
+		StringBuilder buf = new StringBuilder();
+		buf.append("HelpContent [");
+		buf.append("id=").append(id).append(",");
+		buf.append("title=").append(title).append(",");
+		buf.append("content=").append(content).append(",");
+		buf.append("order=").append(order).append(",");
+		buf.append("catalogId=").append(catalogId).append(",");
+		buf.append("createOn=").append(createOn).append(",");
+		buf.append("modifyOn=").append(modifyOn).append(",");
+		buf.append("status=").append(status).append(",");
+		buf.setLength(buf.length() - 1);
+		buf.append("]");
+		return buf.toString();
+	}
+
+}

+ 20 - 0
edu-cms/src/main/java/com/keao/edu/cms/dal/entity/NewsStatusEnum.java

@@ -0,0 +1,20 @@
+package com.keao.edu.cms.dal.entity;
+
+import com.keao.edu.common.enums.BaseEnum;
+
+public enum NewsStatusEnum implements BaseEnum<Integer, NewsStatusEnum> {
+
+	SHOW(1), HIDDEN(0);
+
+	private Integer code;
+
+	NewsStatusEnum(int code) {
+		this.code = code;
+	}
+
+	@Override
+	public Integer getCode() {
+		return code;
+	}
+
+}

+ 173 - 0
edu-cms/src/main/java/com/keao/edu/cms/dal/entity/SysNewsInformation.java

@@ -0,0 +1,173 @@
+package com.keao.edu.cms.dal.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(sys_news_information):
+ */
+public class SysNewsInformation {
+
+	/**  */
+	private Long id;
+
+	/** 标题 */
+	@ApiModelProperty(value = "标题", required = true)
+	private String title;
+
+	/** 内容 */
+	@ApiModelProperty(value = "内容", required = true)
+	private String content;
+
+	/** 封面图片 */
+	@ApiModelProperty(value = "封面图片", required = false)
+	private String coverImage;
+
+	/** 类型 */
+	@ApiModelProperty(value = "类型,1精彩活动,2热门资讯,3banner类型", required = true)
+	private Integer type;
+
+	/** 状态(1-可见 0-不可见) */
+	@ApiModelProperty(value = "状态(1-可见 0-不可见)", required = true)
+	private NewsStatusEnum status;
+
+	@ApiModelProperty(value = "链接地址", required = true)
+	private String linkUrl;
+
+	@ApiModelProperty(value = "跳转类型_bank,_slef", required = true)
+	private String hrefTarget;
+
+	@ApiModelProperty(value = "顺序号", required = true)
+	private Integer order;
+
+	/**  */
+	private java.util.Date createTime;
+
+	/**  */
+	private java.util.Date updateTime;
+
+	@ApiModelProperty(value = "备注", required = false)
+	private String memo;
+
+	private Boolean delFlag;
+
+	private Integer tenantId;
+
+	public String getLinkUrl() {
+		return linkUrl;
+	}
+
+	public void setLinkUrl(String linkUrl) {
+		this.linkUrl = linkUrl;
+	}
+
+	public String getHrefTarget() {
+		return hrefTarget;
+	}
+
+	public void setHrefTarget(String hrefTarget) {
+		this.hrefTarget = hrefTarget;
+	}
+
+	public Integer getOrder() {
+		return order;
+	}
+
+	public void setOrder(Integer order) {
+		this.order = order;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public Long getId() {
+		return this.id;
+	}
+
+	public void setTitle(String title) {
+		this.title = title;
+	}
+
+	public String getTitle() {
+		return this.title;
+	}
+
+	public void setContent(String content) {
+		this.content = content;
+	}
+
+	public String getContent() {
+		return this.content;
+	}
+
+	public void setCoverImage(String coverImage) {
+		this.coverImage = coverImage;
+	}
+
+	public String getCoverImage() {
+		return this.coverImage;
+	}
+
+	public void setType(Integer type) {
+		this.type = type;
+	}
+
+	public Integer getType() {
+		return this.type;
+	}
+
+	public NewsStatusEnum getStatus() {
+		return status;
+	}
+
+	public void setStatus(NewsStatusEnum status) {
+		this.status = status;
+	}
+
+	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 String getMemo() {
+		return memo;
+	}
+
+	public void setMemo(String memo) {
+		this.memo = memo;
+	}
+
+	public Boolean getDelFlag() {
+		return delFlag;
+	}
+
+	public void setDelFlag(Boolean delFlag) {
+		this.delFlag = delFlag;
+	}
+
+	public Integer getTenantId() {
+		return tenantId;
+	}
+
+	public void setTenantId(Integer tenantId) {
+		this.tenantId = tenantId;
+	}
+
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 31 - 0
edu-cms/src/main/java/com/keao/edu/cms/service/HelpCenterCatalogService.java

@@ -0,0 +1,31 @@
+package com.keao.edu.cms.service;
+
+import java.util.List;
+
+import com.keao.edu.cms.dal.entity.HelpCenterCatalog;
+import com.keao.edu.common.service.BaseService;
+
+public interface HelpCenterCatalogService extends BaseService<Integer, HelpCenterCatalog> {
+
+	/**
+	 * 根据父节点查询所有子节点对象
+	 * @param parentId 父节点(可为null)
+	 * @param status 状态(可为null)
+	 * @return
+	 */
+	public List<HelpCenterCatalog> queryByParentId(Integer parentId, Integer status);
+
+	/**
+	 * 修改分类信息
+	 * @param catalog
+	 * @return
+	 */
+	public boolean updateCatalog(HelpCenterCatalog catalog);
+
+	/**
+	 * 删除分类信息
+	 * @param id
+	 * @return
+	 */
+	public boolean deleteCatalog(Integer id);
+}

+ 11 - 0
edu-cms/src/main/java/com/keao/edu/cms/service/HelpCenterContentService.java

@@ -0,0 +1,11 @@
+package com.keao.edu.cms.service;
+
+import com.keao.edu.cms.dal.entity.HelpCenterContent;
+import com.keao.edu.common.service.BaseService;
+
+public interface HelpCenterContentService extends BaseService<Integer,HelpCenterContent>{
+	
+	public boolean updateContentByCatalog(Integer catalogId,Integer status);
+	
+	public boolean deleteContentByCatalog(Integer catalogId);
+}

+ 33 - 0
edu-cms/src/main/java/com/keao/edu/cms/service/SysNewsInformationService.java

@@ -0,0 +1,33 @@
+package com.keao.edu.cms.service;
+
+import java.util.List;
+import java.util.Map;
+
+import com.keao.edu.cms.controller.queryinfo.NewsInformationQueryInfo;
+import com.keao.edu.cms.dal.entity.SysNewsInformation;
+import com.keao.edu.common.page.PageInfo;
+import com.keao.edu.common.service.BaseService;
+
+public interface SysNewsInformationService extends BaseService<Long, SysNewsInformation> {
+
+	/**
+	 * 根据类型查询资讯列表
+	 * @param type
+	 * @return
+	 */
+	List<SysNewsInformation> queryByType(Integer type);
+
+	/**
+	 * 逻辑删除
+	 * @param id
+	 * @return
+	 */
+	boolean deleteWithLogical(Long id);
+
+	/**
+	 * 获取首页新闻列表
+	 * @param queryInfo
+	 * @return
+	 */
+	Map<String, PageInfo<SysNewsInformation>> getHomeList(NewsInformationQueryInfo queryInfo);
+}

+ 51 - 0
edu-cms/src/main/java/com/keao/edu/cms/service/impl/HelpCenterCatalogServiceImpl.java

@@ -0,0 +1,51 @@
+package com.keao.edu.cms.service.impl;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.keao.edu.cms.dal.dao.HelpCenterCatalogDao;
+import com.keao.edu.cms.dal.entity.HelpCenterCatalog;
+import com.keao.edu.cms.service.HelpCenterCatalogService;
+import com.keao.edu.cms.service.HelpCenterContentService;
+import com.keao.edu.common.dal.BaseDAO;
+import com.keao.edu.common.service.impl.BaseServiceImpl;
+
+@Service
+public class HelpCenterCatalogServiceImpl extends BaseServiceImpl<Integer, HelpCenterCatalog> implements HelpCenterCatalogService {
+
+	@Autowired
+	private HelpCenterCatalogDao helpCenterCatalogDao;
+
+	@Autowired
+	private HelpCenterContentService helpCenterContentService;
+
+	@Override
+	public BaseDAO<Integer, HelpCenterCatalog> getDAO() {
+
+		return helpCenterCatalogDao;
+	}
+
+	@Override
+	public List<HelpCenterCatalog> queryByParentId(Integer parentId, Integer status) {
+
+		List<HelpCenterCatalog> dataList = helpCenterCatalogDao.queryByParentId(parentId, status);
+		if (dataList != null) {
+			for (HelpCenterCatalog sub : dataList) {
+				sub.setChildren(queryByParentId(sub.getId(), status));
+			}
+		}
+		return dataList;
+	}
+
+	public boolean updateCatalog(HelpCenterCatalog catalog) {
+		return helpCenterCatalogDao.update(catalog) > 0 && helpCenterContentService.updateContentByCatalog(catalog.getId(), catalog.getStatus());
+	}
+
+	@Override
+	public boolean deleteCatalog(Integer id) {
+		return helpCenterCatalogDao.delete(id) > 0 && helpCenterContentService.deleteContentByCatalog(id);
+	}
+
+}

+ 41 - 0
edu-cms/src/main/java/com/keao/edu/cms/service/impl/HelpCenterContentServiceImpl.java

@@ -0,0 +1,41 @@
+package com.keao.edu.cms.service.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.keao.edu.cms.dal.dao.HelpCenterContentDao;
+import com.keao.edu.cms.dal.entity.HelpCenterContent;
+import com.keao.edu.cms.service.HelpCenterContentService;
+import com.keao.edu.common.dal.BaseDAO;
+import com.keao.edu.common.service.impl.BaseServiceImpl;
+
+@Service
+public class HelpCenterContentServiceImpl extends BaseServiceImpl<Integer, HelpCenterContent> implements HelpCenterContentService {
+
+	@Autowired
+	private HelpCenterContentDao contentCenterDao;
+
+	@Override
+	public BaseDAO<Integer, HelpCenterContent> getDAO() {
+		return contentCenterDao;
+	}
+
+	@Override
+	public boolean updateContentByCatalog(Integer catalogId, Integer status) {
+		Map<String, Object> map = new HashMap<String, Object>();
+		map.put("catalogId", catalogId);
+		map.put("status", status);
+		contentCenterDao.updateContentByCatalog(map);
+		return true;
+	}
+
+	@Override
+	public boolean deleteContentByCatalog(Integer catalogId) {
+		contentCenterDao.deleteContentByCatalog(catalogId);
+		return true;
+	}
+
+}

+ 118 - 0
edu-cms/src/main/java/com/keao/edu/cms/service/impl/SysNewsInformationServiceImpl.java

@@ -0,0 +1,118 @@
+package com.keao.edu.cms.service.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import com.keao.edu.cms.controller.queryinfo.NewsInformationQueryInfo;
+import com.keao.edu.cms.dal.dao.SysNewsInformationDao;
+import com.keao.edu.cms.dal.entity.NewsStatusEnum;
+import com.keao.edu.cms.dal.entity.SysNewsInformation;
+import com.keao.edu.cms.service.SysNewsInformationService;
+import com.keao.edu.common.dal.BaseDAO;
+import com.keao.edu.common.page.PageInfo;
+import com.keao.edu.common.page.QueryInfo;
+import com.keao.edu.common.service.impl.BaseServiceImpl;
+import com.keao.edu.util.collection.MapUtil;
+
+@Service
+public class SysNewsInformationServiceImpl extends BaseServiceImpl<Long, SysNewsInformation> implements SysNewsInformationService {
+
+	@Autowired
+	private SysNewsInformationDao sysNewsInformationDao;
+	
+	@Value("${cms.server.context.path}")
+	private String serverContextPath;
+	
+	public void setServerContextPath(String serverContextPath) {
+		this.serverContextPath = serverContextPath;
+	}
+
+	@Override
+	public BaseDAO<Long, SysNewsInformation> getDAO() {
+		return sysNewsInformationDao;
+	}
+
+	@Override
+	public List<SysNewsInformation> queryByType(Integer type) {
+		return sysNewsInformationDao.queryByType(type);
+	}
+
+	@Override
+	public boolean deleteWithLogical(Long id) {
+		sysNewsInformationDao.deleteWithLogical(id);
+		return true;
+	}
+
+	@Override
+	public Map<String,PageInfo<SysNewsInformation>> getHomeList(NewsInformationQueryInfo queryInfo) {
+		//1精彩活动,2热门资讯,3banner类型
+		Map<String,PageInfo<SysNewsInformation>> homeList = new HashMap<>();
+		queryInfo.setStatus(NewsStatusEnum.SHOW);
+		
+		if(queryInfo.getTenantId() == null){
+			queryInfo.setTenantId(1);
+		}
+		
+		String memo = queryInfo.getMemo();
+		
+		Map<String, Object> params = new HashMap<String, Object>();
+		MapUtil.populateMap(params, queryInfo);
+
+		queryInfo.setType(3); 
+		int count = sysNewsInformationDao.queryHomeCount(params);
+		if(count == 0){
+			queryInfo.setMemo(null);
+		}
+		PageInfo<SysNewsInformation> pageInfos = queryHomePage(queryInfo);
+
+		homeList.put("banner",pageInfos);
+		
+		queryInfo.setMemo(memo);
+		queryInfo.setType(6);
+		count = sysNewsInformationDao.queryHomeCount(params);
+		if(count == 0){
+			queryInfo.setMemo(null);
+		}
+		homeList.put("app",queryHomePage(queryInfo));
+		
+		queryInfo.setMemo(null);
+		queryInfo.setType(1);
+		homeList.put("active",queryHomePage(queryInfo));
+		queryInfo.setType(2);
+		homeList.put("hot",queryHomePage(queryInfo));
+		
+		queryInfo.setType(5);
+		pageInfos = new PageInfo<SysNewsInformation>();
+		SysNewsInformation info = new SysNewsInformation();
+		info.setOrder(1);
+		pageInfos = queryHomePage(queryInfo);
+		homeList.put("flash",pageInfos);
+		return homeList;
+	}
+	
+	private PageInfo<SysNewsInformation> queryHomePage(QueryInfo queryInfo) {
+		PageInfo<SysNewsInformation> pageInfo = new PageInfo<SysNewsInformation>(queryInfo.getPage(), queryInfo.getRows());
+		Map<String, Object> params = new HashMap<String, Object>();
+		MapUtil.populateMap(params, queryInfo);
+		
+		List<SysNewsInformation> dataList = null;
+		int count = sysNewsInformationDao.queryHomeCount(params);
+		if (count > 0) {
+			pageInfo.setTotal(count);
+			params.put("offset", pageInfo.getOffset());
+			dataList = sysNewsInformationDao.queryHomePage(params);
+		}
+		if (count == 0) {
+			dataList = new ArrayList<SysNewsInformation>();
+		}
+		pageInfo.setRows(dataList);
+		return pageInfo;
+	}
+
+}

+ 79 - 0
edu-cms/src/main/resources/application.yml

@@ -0,0 +1,79 @@
+server:
+  port: 8006
+  tomcat:
+    accesslog:
+      enabled: true
+      buffered: true
+      directory: /var/logs
+      file-date-format: -yyyy-MM-dd
+      pattern: common
+      prefix: tomcat-cms
+      rename-on-rotate: false
+      request-attributes-enabled: false
+      rotate: true
+      suffix: .log
+
+eureka:
+  client:
+    serviceUrl:
+      defaultZone: http://admin:admin123@localhost:8761/eureka/eureka/
+    instance: 
+      lease-renewal-interval-in-seconds: 5
+
+spring:
+  application:
+    name: cms-server
+    
+  datasource:
+    name: test
+    url: jdbc:mysql://47.99.212.176:3306/mec_dev?useUnicode=true&characterEncoding=UTF8&serverTimezone=Asia/Shanghai
+    username: mec_dev
+    password: mec_dev
+    # 使用druid数据源
+    type: com.alibaba.druid.pool.DruidDataSource
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    filters: stat
+    maxActive: 20
+    initialSize: 1
+    maxWait: 60000
+    minIdle: 1
+    timeBetweenEvictionRunsMillis: 60000
+    minEvictableIdleTimeMillis: 300000
+    validationQuery: select 'x'
+    testWhileIdle: true
+    testOnBorrow: false
+    testOnReturn: false
+    poolPreparedStatements: true
+    maxOpenPreparedStatements: 20
+    
+
+mybatis:
+    mapperLocations: classpath:config/mybatis/*.xml
+    
+swagger:
+  base-package: com.ym.mec.cms.controller
+  
+  
+##认证 
+security:
+  oauth2:
+    client:
+      client-id: app
+      client-secret: app
+    resource:
+      token-info-uri: http://localhost:8001/oauth/check_token
+  
+#spring boot admin 相关配置
+management:
+  endpoints:
+    web:
+      exposure:
+        include: "*"
+  endpoint:
+    health:
+      show-details: ALWAYS
+      
+
+ribbon:  
+    ReadTimeout: 60000  
+    ConnectTimeout: 60000

+ 16 - 0
edu-cms/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.99.212.176:8848
+#\u9ed8\u8ba4\u4e3aPublic\u547d\u540d\u7a7a\u95f4,\u53ef\u4ee5\u7701\u7565\u4e0d\u5199
+spring.cloud.nacos.config.namespace=e246d169-227d-4012-8c34-e90e057d95d2
+#\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=cms
+#\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

+ 16 - 0
edu-cms/src/main/resources/bootstrap-prod.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.96.80.97:8848
+#\u9ed8\u8ba4\u4e3aPublic\u547d\u540d\u7a7a\u95f4,\u53ef\u4ee5\u7701\u7565\u4e0d\u5199
+spring.cloud.nacos.config.namespace=f40a7594-4bd0-4bc6-8397-9353c6d2e63a
+#\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=cms
+#\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

+ 16 - 0
edu-cms/src/main/resources/bootstrap-test.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.96.85.100:8848
+#\u9ed8\u8ba4\u4e3aPublic\u547d\u540d\u7a7a\u95f4,\u53ef\u4ee5\u7701\u7565\u4e0d\u5199
+spring.cloud.nacos.config.namespace=02105743-16b8-46ab-87df-2aca0f3dbca3
+#\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=cms
+#\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
edu-cms/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>

+ 96 - 0
edu-cms/src/main/resources/config/mybatis/HelpCenterCatalogMapper.xml

@@ -0,0 +1,96 @@
+<?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.keao.edu.cms.dal.dao.HelpCenterCatalogDao">
+	<resultMap id="HelpCenterCatalog" type="com.keao.edu.cms.dal.entity.HelpCenterCatalog">
+		<id column="id_" property="id" jdbcType="INTEGER" />
+		<result column="parent_id_" property="parentId" jdbcType="INTEGER" />
+		<result column="name_" property="text" jdbcType="VARCHAR" />
+		<result column="description_" property="description" jdbcType="VARCHAR" />
+		<result column="create_on_" property="createOn" jdbcType="TIMESTAMP" />
+		<result column="modify_on_" property="modifyOn" jdbcType="TIMESTAMP" />
+		<result column="order_" property="order" jdbcType="INTEGER" />
+		<result column="status_" property="status" jdbcType="INTEGER" />
+	</resultMap>
+
+	<sql id="Base_Column_List">
+		id_, parent_id_, name_, description_, create_on_, modify_on_, order_,status_
+	</sql>
+
+	<select id="get" resultMap="HelpCenterCatalog" parameterType="java.lang.Integer">
+		select
+		<include refid="Base_Column_List" />
+		from help_center_catalog
+		where id_ = #{id,jdbcType=INTEGER}
+	</select>
+
+	<select id="queryPage" parameterType="map" resultMap="HelpCenterCatalog">
+		select
+		<include refid="Base_Column_List" />
+		from
+		help_center_catalog
+		order by order_ asc
+	</select>
+
+	<select id="queryByParentId" parameterType="map" resultMap="HelpCenterCatalog">
+		select
+		<include refid="Base_Column_List" />
+		from
+		help_center_catalog
+		where 1 = 1
+		<if test="parentId != null">
+			and parent_id_= #{parentId,jdbcType=INTEGER}
+		</if>
+		<if test="status != null">
+			and status_ = #{status,jdbcType=INTEGER}
+		</if>
+		order by order_ desc
+	</select>
+
+	<delete id="delete" parameterType="java.lang.Integer">
+		delete from help_center_catalog
+		where id_ = #{id,jdbcType=INTEGER}
+	</delete>
+	
+	<delete id="batchDelete" parameterType="String">
+		delete from help_center_catalog
+		where id_ in #{ids}
+	</delete>
+	
+	<insert id="insert" parameterType="com.keao.edu.cms.dal.entity.HelpCenterCatalog">
+		insert into help_center_catalog (id_, parent_id_, name_,
+		description_, create_on_, modify_on_,
+		order_,status_)
+		values (#{id,jdbcType=INTEGER}, #{parentId,jdbcType=INTEGER},
+		#{text,jdbcType=VARCHAR},
+		#{description,jdbcType=VARCHAR}, #{createOn,jdbcType=TIMESTAMP}, #{modifyOn,jdbcType=TIMESTAMP},
+		#{order,jdbcType=INTEGER},#{status,jdbcType=INTEGER})
+	</insert>
+	
+	<update id="update" parameterType="com.keao.edu.cms.dal.entity.HelpCenterCatalog">
+		update help_center_catalog
+		<set>
+			<if test="parentId != null">
+				parent_id_ = #{parentId,jdbcType=INTEGER},
+			</if>
+			<if test="text != null">
+				name_ = #{text,jdbcType=VARCHAR},
+			</if>
+			<if test="description != null">
+				description_ = #{description,jdbcType=VARCHAR},
+			</if>
+			<if test="createOn != null">
+				create_on_ = #{createOn,jdbcType=TIMESTAMP},
+			</if>
+			<if test="modifyOn != null">
+				modify_on_ = #{modifyOn,jdbcType=TIMESTAMP},
+			</if>
+			<if test="order != null">
+				order_ = #{order,jdbcType=INTEGER},
+			</if>
+			<if test="status != null">
+				status_ = #{status,jdbcType=INTEGER},
+			</if>
+		</set>
+		where id_ = #{id,jdbcType=INTEGER}
+	</update>
+</mapper>

部分文件因为文件数量过多而无法显示