瀏覽代碼

通过token登录系统

xiaolong.yang 5 年之前
父節點
當前提交
abfcc4fed8

+ 204 - 198
pom.xml

@@ -1,198 +1,204 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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>
-    <groupId>com.ygj</groupId>
-    <artifactId>yuemum</artifactId>
-    <version>1</version>
-    <packaging>war</packaging>
-    <name>yuemum</name>
-    <description>Demo project for Spring Boot</description>
-    <!--<profiles>-->
-    <!--<profile>-->
-    <!--<id>dev</id>-->
-    <!--<properties>-->
-    <!--<spring.profiles.active>dev</spring.profiles.active>-->
-    <!--</properties>-->
-    <!--<activation>-->
-    <!--<activeByDefault>true</activeByDefault>-->
-    <!--</activation>-->
-    <!--</profile>-->
-    <!--<profile>-->
-    <!--<id>pro</id>-->
-    <!--<properties>-->
-    <!--<spring.profiles.active>pro</spring.profiles.active>-->
-    <!--</properties>-->
-    <!--</profile>-->
-    <!--</profiles>-->
-
-    <parent>
-        <groupId>org.springframework.boot</groupId>
-        <artifactId>spring-boot-starter-parent</artifactId>
-        <version>1.5.10.RELEASE</version>
-        <relativePath/> <!-- lookup parent from repository -->
-    </parent>
-
-    <properties>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
-        <java.version>1.8</java.version>
-    </properties>
-
-    <dependencies>
-
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-web</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.mybatis.spring.boot</groupId>
-            <artifactId>mybatis-spring-boot-starter</artifactId>
-            <version>1.2.0</version>
-        </dependency>
-
-        <dependency>
-            <groupId>mysql</groupId>
-            <artifactId>mysql-connector-java</artifactId>
-            <scope>runtime</scope>
-        </dependency>
-        <dependency>
-            <groupId>com.alibaba</groupId>
-            <artifactId>fastjson</artifactId>
-            <version>1.2.31</version>
-        </dependency>
-        <dependency>
-            <groupId>org.json</groupId>
-            <artifactId>json</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>com.google.code.gson</groupId>
-            <artifactId>gson</artifactId>
-            <version>2.8.2</version>
-        </dependency>
-        <!--启动-->
-        <!--<dependency>-->
-        <!--<groupId>org.springframework.boot</groupId>-->
-        <!--<artifactId>spring-boot-starter-tomcat</artifactId>-->
-        <!--<scope>provided</scope>-->
-        <!--</dependency>-->
-
-
-        <dependency>
-            <groupId>com.fasterxml.jackson.core</groupId>
-            <artifactId>jackson-annotations</artifactId>
-            <version>2.8.0</version>
-        </dependency>
-        <dependency>
-            <groupId>com.fasterxml.jackson.core</groupId>
-            <artifactId>jackson-core</artifactId>
-            <version>2.8.7</version>
-        </dependency>
-        <dependency>
-            <groupId>com.fasterxml.jackson.core</groupId>
-            <artifactId>jackson-databind</artifactId>
-            <version>2.8.7</version>
-        </dependency>
-
-        <dependency>
-            <groupId>com.alibaba</groupId>
-            <artifactId>druid</artifactId>
-            <version>1.1.3</version>
-        </dependency>
-        <!--分页-->
-        <dependency>
-            <groupId>com.github.pagehelper</groupId>
-            <artifactId>pagehelper</artifactId>
-            <version>4.1.6</version>
-        </dependency>
-        <!--emoji-->
-        <dependency>
-            <groupId>com.vdurmont</groupId>
-            <artifactId>emoji-java</artifactId>
-            <version>3.2.0</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <version>4.5.4</version>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-test</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>com.thetransactioncompany</groupId>
-            <artifactId>cors-filter</artifactId>
-            <version>1.7.1</version>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-thymeleaf</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>commons-fileupload</groupId>
-            <artifactId>commons-fileupload</artifactId>
-            <version>1.3.2</version>
-        </dependency>
-        <dependency>
-            <groupId>commons-io</groupId>
-            <artifactId>commons-io</artifactId>
-            <version>2.5</version>
-        </dependency>
-        <dependency>
-            <groupId>commons-lang</groupId>
-            <artifactId>commons-lang</artifactId>
-            <version>2.6</version>
-        </dependency>
-        <!-- Spring 文件上传的依赖包  -->
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-io</artifactId>
-            <version>1.3.2</version>
-        </dependency>
-        <dependency>
-            <groupId>net.sourceforge.nekohtml</groupId>
-            <artifactId>nekohtml</artifactId>
-            <version>1.9.22</version>
-        </dependency>
-        <dependency>
-            <groupId>org.bouncycastle</groupId>
-            <artifactId>bcprov-jdk15on</artifactId>
-            <version>1.54</version>
-        </dependency>
-        <!--Spring Security-->
-        <!--dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-security</artifactId>
-        </dependency-->
-        <!--Shiro-->
-        <dependency>
-            <groupId>org.apache.shiro</groupId>
-            <artifactId>shiro-spring</artifactId>
-            <version>1.3.2</version>
-        </dependency>
-
-        <!--热部署-->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-devtools</artifactId>
-            <optional>true</optional>
-        </dependency>
-    </dependencies>
-
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-                <configuration>
-                    <fork>true</fork>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-
-
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+    <groupId>com.ygj</groupId>
+    <artifactId>yuemum</artifactId>
+    <version>1</version>
+    <packaging>war</packaging>
+    <name>yuemum</name>
+    <description>Demo project for Spring Boot</description>
+    <!--<profiles>-->
+    <!--<profile>-->
+    <!--<id>dev</id>-->
+    <!--<properties>-->
+    <!--<spring.profiles.active>dev</spring.profiles.active>-->
+    <!--</properties>-->
+    <!--<activation>-->
+    <!--<activeByDefault>true</activeByDefault>-->
+    <!--</activation>-->
+    <!--</profile>-->
+    <!--<profile>-->
+    <!--<id>pro</id>-->
+    <!--<properties>-->
+    <!--<spring.profiles.active>pro</spring.profiles.active>-->
+    <!--</properties>-->
+    <!--</profile>-->
+    <!--</profiles>-->
+
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>1.5.10.RELEASE</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <java.version>1.8</java.version>
+    </properties>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.mybatis.spring.boot</groupId>
+            <artifactId>mybatis-spring-boot-starter</artifactId>
+            <version>1.2.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.31</version>
+        </dependency>
+        <dependency>
+            <groupId>org.json</groupId>
+            <artifactId>json</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+            <version>2.8.2</version>
+        </dependency>
+        <!--启动-->
+        <!--<dependency>-->
+        <!--<groupId>org.springframework.boot</groupId>-->
+        <!--<artifactId>spring-boot-starter-tomcat</artifactId>-->
+        <!--<scope>provided</scope>-->
+        <!--</dependency>-->
+
+
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-annotations</artifactId>
+            <version>2.8.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-core</artifactId>
+            <version>2.8.7</version>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <version>2.8.7</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid</artifactId>
+            <version>1.1.3</version>
+        </dependency>
+        <!--分页-->
+        <dependency>
+            <groupId>com.github.pagehelper</groupId>
+            <artifactId>pagehelper</artifactId>
+            <version>4.1.6</version>
+        </dependency>
+        <!--emoji-->
+        <dependency>
+            <groupId>com.vdurmont</groupId>
+            <artifactId>emoji-java</artifactId>
+            <version>3.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.4</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.thetransactioncompany</groupId>
+            <artifactId>cors-filter</artifactId>
+            <version>1.7.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-thymeleaf</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>commons-fileupload</groupId>
+            <artifactId>commons-fileupload</artifactId>
+            <version>1.3.2</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>2.5</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+            <version>2.6</version>
+        </dependency>
+        <!-- Spring 文件上传的依赖包  -->
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>1.3.2</version>
+        </dependency>
+        <dependency>
+            <groupId>net.sourceforge.nekohtml</groupId>
+            <artifactId>nekohtml</artifactId>
+            <version>1.9.22</version>
+        </dependency>
+        <dependency>
+            <groupId>org.bouncycastle</groupId>
+            <artifactId>bcprov-jdk15on</artifactId>
+            <version>1.54</version>
+        </dependency>
+        <!--Spring Security-->
+        <!--dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-security</artifactId>
+        </dependency-->
+        <!--Shiro-->
+        <dependency>
+            <groupId>org.apache.shiro</groupId>
+            <artifactId>shiro-spring</artifactId>
+            <version>1.3.2</version>
+        </dependency>
+
+        <dependency>
+            <groupId>io.jsonwebtoken</groupId>
+            <artifactId>jjwt</artifactId>
+            <version>0.9.0</version>
+        </dependency>
+
+        <!--热部署-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-devtools</artifactId>
+            <optional>true</optional>
+        </dependency>
+    </dependencies>
+
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <fork>true</fork>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+
+</project>

+ 3 - 0
src/main/java/com/ygj/yuemum/dao/admin/JlAdminUserDao.java

@@ -1,6 +1,7 @@
 package com.ygj.yuemum.dao.admin;
 
 import com.ygj.yuemum.domain.admin.JlAdminUser;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
@@ -52,4 +53,6 @@ public interface JlAdminUserDao {
      * @return
      */
     int updateByPrimaryKeySelective(JlAdminUser record);
+
+    JlAdminUser getUserByEmail(@Param("userEmail") String userEmail);
 }

+ 4 - 0
src/main/java/com/ygj/yuemum/service/admin/JlAdminUserService.java

@@ -101,4 +101,8 @@ public class JlAdminUserService {
     public int getRolePermissionCount(Integer roleid){
         return jladminuserdao.getRolePermissionCount(roleid);
     }
+
+    public JlAdminUser getUserByEmail(String userEmail) {
+        return jladminuserdao.getUserByEmail(userEmail);
+    }
 }

+ 223 - 186
src/main/java/com/ygj/yuemum/shiro/ShiroConfig.java

@@ -1,187 +1,224 @@
-package com.ygj.yuemum.shiro;
-
-import org.apache.shiro.mgt.SecurityManager;
-import org.apache.shiro.session.mgt.SessionManager;
-import org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO;
-import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
-import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-@Configuration
-public class ShiroConfig {
-    @Bean
-    public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) {
-        ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
-        // 必须设置 SecurityManager
-        shiroFilterFactoryBean.setSecurityManager(securityManager);
-        // setLoginUrl 如果不设置值,默认会自动寻找Web工程根目录下的"/login.jsp"页面 或 "/login" 映射
-        shiroFilterFactoryBean.setLoginUrl("/webLogin");
-        // 设置无权限时跳转的 url;
-        shiroFilterFactoryBean.setUnauthorizedUrl("/unauth");
-        // 设置拦截器
-        Map<String, String> filterChainDefinitionMap = new LinkedHashMap<>();
-
-        //小程序开放权限
-        filterChainDefinitionMap.put("/addEquipmenteHireDetail", "anon");
-        filterChainDefinitionMap.put("/addEquipmenteHireHeadOnline", "anon");
-        filterChainDefinitionMap.put("/deleteEquipmenteHireHead", "anon");
-        filterChainDefinitionMap.put("/deleteWXUserDefAddress", "anon");
-        filterChainDefinitionMap.put("/checkStockDate", "anon");
-        filterChainDefinitionMap.put("/getBanners", "anon");
-        filterChainDefinitionMap.put("/getConsultant", "anon");
-        filterChainDefinitionMap.put("/getCustomerEq", "anon");
-        filterChainDefinitionMap.put("/getEquipmentTypes", "anon");
-        filterChainDefinitionMap.put("/getEqUserAddress", "anon");
-        filterChainDefinitionMap.put("/getIndexs", "anon");
-        filterChainDefinitionMap.put("/getMktInfos", "anon");
-        filterChainDefinitionMap.put("/getPackageDetail", "anon");
-        filterChainDefinitionMap.put("/getPackageLists", "anon");
-        filterChainDefinitionMap.put("/getPackageShowname", "anon");
-        filterChainDefinitionMap.put("/getPIClasses", "anon");
-        filterChainDefinitionMap.put("/getPIGroups", "anon");
-        filterChainDefinitionMap.put("/getPIServices", "anon");
-        filterChainDefinitionMap.put("/getPromotions", "anon");
-        filterChainDefinitionMap.put("/getWXCustomerCoupons", "anon");
-        filterChainDefinitionMap.put("/getWxDecrypt", "anon");
-        filterChainDefinitionMap.put("/getWXOpenid", "anon");
-        filterChainDefinitionMap.put("/getWXUserAddress", "anon");
-        filterChainDefinitionMap.put("/getYueSuo", "anon");
-        filterChainDefinitionMap.put("/insertCustomerBooking", "anon");
-        filterChainDefinitionMap.put("/insertEqCustomerBooking", "anon");
-        filterChainDefinitionMap.put("/insertWXUserAddress", "anon");
-        filterChainDefinitionMap.put("/updateWXUser", "anon");
-        filterChainDefinitionMap.put("/updateWXUserAddress", "anon");
-        filterChainDefinitionMap.put("/updateWXUserDefAddress", "anon");
-        filterChainDefinitionMap.put("/WXSendBookingMessage", "anon");
-        filterChainDefinitionMap.put("/WXSendOrderMessage", "anon");
-        filterChainDefinitionMap.put("/WXSendYSOrderMessage", "anon");
-        filterChainDefinitionMap.put("/getEquipmentAmount", "anon");
-        filterChainDefinitionMap.put("/getValidPO", "anon");
-        filterChainDefinitionMap.put("/getValidPosition", "anon");
-        filterChainDefinitionMap.put("/getWxPosition", "anon");
-        filterChainDefinitionMap.put("/insertPromotionUserInfo", "anon");
-        filterChainDefinitionMap.put("/checkDcIntroducers", "anon");
-        filterChainDefinitionMap.put("/getDcIntroduceLogs", "anon");
-        filterChainDefinitionMap.put("/getDcIntroducerExtracts", "anon");
-        filterChainDefinitionMap.put("/date_DcIntroducerExtracts", "anon");
-        filterChainDefinitionMap.put("/getAccountNumber", "anon");
-        filterChainDefinitionMap.put("/queryOneDcIntroducerExtract", "anon");
-        filterChainDefinitionMap.put("/insertDcIntroducerExtract", "anon");
-        filterChainDefinitionMap.put("/WXSendExtractMessage", "anon");
-        filterChainDefinitionMap.put("/insertDcIntroduceLog", "anon");
-        filterChainDefinitionMap.put("/getDcIntroducerConsultants", "anon");
-        filterChainDefinitionMap.put("/queryMineOrder", "anon");
-        filterChainDefinitionMap.put("/getYSOrder", "anon");
-        filterChainDefinitionMap.put("/insertYsOrderPay", "anon");
-        filterChainDefinitionMap.put("/checkCustomerPay", "anon");
-        filterChainDefinitionMap.put("/queryYSOrderReturn", "anon");
-        filterChainDefinitionMap.put("/updateEquipmenteHireHeadOnline", "anon");
-        filterChainDefinitionMap.put("/getIndexPromotions", "anon");
-        filterChainDefinitionMap.put("/CreatePOP", "anon");
-        filterChainDefinitionMap.put("/getPromotionDC", "anon");
-        filterChainDefinitionMap.put("/checkMkt", "anon");
-        filterChainDefinitionMap.put("/getBranches", "anon");
-        filterChainDefinitionMap.put("/insertPromotionDCUserInfo", "anon");
-        filterChainDefinitionMap.put("/updateDcIntroducerApplicant", "anon");
-        filterChainDefinitionMap.put("/updateAccountNumber", "anon");
-        filterChainDefinitionMap.put("/insertPromotionChannelLog", "anon");
-        filterChainDefinitionMap.put("/getPromotionTestByPrxID", "anon");
-        filterChainDefinitionMap.put("/getPromotionTestResultByPtID", "anon");
-        filterChainDefinitionMap.put("/insertPromotionTestUserScore", "anon");
-        filterChainDefinitionMap.put("/CreateTestShare", "anon");
-        filterChainDefinitionMap.put("/getPromotionDCByID", "anon");
-        filterChainDefinitionMap.put("/getPromotionTestUserScoreByOpenID", "anon");
-        filterChainDefinitionMap.put("/getPromotionTestResultShowByPrxID", "anon");
-        filterChainDefinitionMap.put("/getWXDianPing", "anon");
-        filterChainDefinitionMap.put("/getWXContentTypes", "anon");
-        filterChainDefinitionMap.put("/queryUserContent", "anon");
-        filterChainDefinitionMap.put("/getWXUser", "anon");
-        filterChainDefinitionMap.put("/getWXMMSearchQuestion", "anon");
-        filterChainDefinitionMap.put("/queryUserMMSearch", "anon");
-        filterChainDefinitionMap.put("/getMmInfoResume", "anon");
-        filterChainDefinitionMap.put("/getPackageImagesByID", "anon");
-        //萌动开放权限
-        filterChainDefinitionMap.put("/getNewUserCoupon", "anon");
-        filterChainDefinitionMap.put("/getConsultTaskCoupon", "anon");
-        filterChainDefinitionMap.put("/getDetectionTaskCoupon", "anon");
-        filterChainDefinitionMap.put("/getRechargeTaskCoupon", "anon");
-        //文件上传临时解决方案
-        filterChainDefinitionMap.put("/uploadPromotionImg","anon");
-        filterChainDefinitionMap.put("/uploadImg","anon");
-        filterChainDefinitionMap.put("/uploadPayImg","anon");
-        filterChainDefinitionMap.put("/uploadMiniImg","anon");
-        filterChainDefinitionMap.put("/uploadDianPingImg","anon");
-        //简历分享问题
-        filterChainDefinitionMap.put("/getWeChatInfo","anon");
-        //超人妈妈学院
-        filterChainDefinitionMap.put("/college/queryUserPoints","anon");
-        filterChainDefinitionMap.put("/college/queryUserLearningCore","anon");
-        filterChainDefinitionMap.put("/college/queryUserLearningPractice","anon");
-        filterChainDefinitionMap.put("/college/queryUserLearningExperience","anon");
-        filterChainDefinitionMap.put("/college/queryUserLearningCoreDetail","anon");
-        filterChainDefinitionMap.put("/college/queryCoreDetail","anon");
-        filterChainDefinitionMap.put("/college/queryTests","anon");
-        filterChainDefinitionMap.put("/college/addTestDetail","anon");
-        filterChainDefinitionMap.put("/college/queryPracticeDetail","anon");
-        filterChainDefinitionMap.put("/college/queryExperienceDetail","anon");
-        filterChainDefinitionMap.put("/college/addCollegeBooking","anon");
-        filterChainDefinitionMap.put("/college/corePositive","anon");
-        filterChainDefinitionMap.put("/college/coreLearningUpdate","anon");
-        filterChainDefinitionMap.put("/college/coreLearningFinish","anon");
-        filterChainDefinitionMap.put("/college/getCollegeBooking","anon");
-        filterChainDefinitionMap.put("/college/bookingCancel","anon");
-        filterChainDefinitionMap.put("/eLearning/index","anon");
-        filterChainDefinitionMap.put("/eLearning/courseworkList","anon");
-        filterChainDefinitionMap.put("/eLearning/courseworkDetail","anon");
-        filterChainDefinitionMap.put("/eLearning/testList","anon");
-        filterChainDefinitionMap.put("/eLearning/testComplete","anon");
-        filterChainDefinitionMap.put("/eLearning/courseworkComplete","anon");
-        filterChainDefinitionMap.put("/eLearning/courseworkUpdate","anon");
-        filterChainDefinitionMap.put("/eLearning/courseworkBooking","anon");
-//        //用户,需要角色权限 “user”
-//        filterChainDefinitionMap.put("/user/**", "roles[user]");
-//        //管理员,需要角色权限 “admin”
-//        filterChainDefinitionMap.put("/admin/**", "roles[admin]");
-        //开放登陆接口
-        filterChainDefinitionMap.put("/login", "anon");
-        //其余接口一律拦截
-        //主要这行代码必须放在所有权限设置的最后,不然会导致所有 url 都被拦截
-        filterChainDefinitionMap.put("/**", "authc");
-
-        shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
-        return shiroFilterFactoryBean;
-    }
-
-    /**
-     * 自定义身份认证 realm;
-     * <p>
-     * 必须写这个类,并加上 @Bean 注解,目的是注入 CustomRealm,
-     * 否则会影响 CustomRealm类 中其他类的依赖注入
-     */
-    @Bean
-    public CustomRealm customRealm() {
-        return new CustomRealm();
-    }
-    @Bean
-    public SessionManager sessionManager(){
-        ShiroSessionManager shiroSessionManager = new ShiroSessionManager();
-        //这里可以不设置。Shiro有默认的session管理。如果缓存为Redis则需改用Redis的管理
-        shiroSessionManager.setSessionDAO(new EnterpriseCacheSessionDAO());
-        return shiroSessionManager;
-    }
-    @Bean
-    public SecurityManager securityManager(){
-        DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
-        securityManager.setRealm(customRealm());
-        //自定义session管理
-        securityManager.setSessionManager(sessionManager());
-        //自定义缓存实现
-//        securityManager.setCacheManager(ehCacheManager());
-        return  securityManager;
-    }
-
+package com.ygj.yuemum.shiro;
+
+import com.ygj.yuemum.service.admin.JlAdminUserService;
+import com.ygj.yuemum.shiro.sso.JWTAuthFilter;
+import com.ygj.yuemum.shiro.sso.JWTShiroRealm;
+import org.apache.shiro.authc.Authenticator;
+import org.apache.shiro.authc.pam.FirstSuccessfulStrategy;
+import org.apache.shiro.authc.pam.ModularRealmAuthenticator;
+import org.apache.shiro.mgt.SecurityManager;
+import org.apache.shiro.realm.Realm;
+import org.apache.shiro.session.mgt.SessionManager;
+import org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO;
+import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
+import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import javax.servlet.Filter;
+import java.util.Arrays;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+@Configuration
+public class ShiroConfig {
+
+    @Autowired
+    private JlAdminUserService jlAdminUserService;
+
+    @Bean
+    public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) {
+        ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
+        // 必须设置 SecurityManager
+        shiroFilterFactoryBean.setSecurityManager(securityManager);
+        Map<String, Filter> filterMap = shiroFilterFactoryBean.getFilters();
+        filterMap.put("authcToken", createAuthFilter(jlAdminUserService));
+        shiroFilterFactoryBean.setFilters(filterMap);
+        // setLoginUrl 如果不设置值,默认会自动寻找Web工程根目录下的"/login.jsp"页面 或 "/login" 映射
+        shiroFilterFactoryBean.setLoginUrl("/webLogin");
+        // 设置无权限时跳转的 url;
+        shiroFilterFactoryBean.setUnauthorizedUrl("/unauth");
+        // 设置拦截器
+        Map<String, String> filterChainDefinitionMap = new LinkedHashMap<>();
+
+        //小程序开放权限
+        filterChainDefinitionMap.put("/addEquipmenteHireDetail", "anon");
+        filterChainDefinitionMap.put("/addEquipmenteHireHeadOnline", "anon");
+        filterChainDefinitionMap.put("/deleteEquipmenteHireHead", "anon");
+        filterChainDefinitionMap.put("/deleteWXUserDefAddress", "anon");
+        filterChainDefinitionMap.put("/checkStockDate", "anon");
+        filterChainDefinitionMap.put("/getBanners", "anon");
+        filterChainDefinitionMap.put("/getConsultant", "anon");
+        filterChainDefinitionMap.put("/getCustomerEq", "anon");
+        filterChainDefinitionMap.put("/getEquipmentTypes", "anon");
+        filterChainDefinitionMap.put("/getEqUserAddress", "anon");
+        filterChainDefinitionMap.put("/getIndexs", "anon");
+        filterChainDefinitionMap.put("/getMktInfos", "anon");
+        filterChainDefinitionMap.put("/getPackageDetail", "anon");
+        filterChainDefinitionMap.put("/getPackageLists", "anon");
+        filterChainDefinitionMap.put("/getPackageShowname", "anon");
+        filterChainDefinitionMap.put("/getPIClasses", "anon");
+        filterChainDefinitionMap.put("/getPIGroups", "anon");
+        filterChainDefinitionMap.put("/getPIServices", "anon");
+        filterChainDefinitionMap.put("/getPromotions", "anon");
+        filterChainDefinitionMap.put("/getWXCustomerCoupons", "anon");
+        filterChainDefinitionMap.put("/getWxDecrypt", "anon");
+        filterChainDefinitionMap.put("/getWXOpenid", "anon");
+        filterChainDefinitionMap.put("/getWXUserAddress", "anon");
+        filterChainDefinitionMap.put("/getYueSuo", "anon");
+        filterChainDefinitionMap.put("/insertCustomerBooking", "anon");
+        filterChainDefinitionMap.put("/insertEqCustomerBooking", "anon");
+        filterChainDefinitionMap.put("/insertWXUserAddress", "anon");
+        filterChainDefinitionMap.put("/updateWXUser", "anon");
+        filterChainDefinitionMap.put("/updateWXUserAddress", "anon");
+        filterChainDefinitionMap.put("/updateWXUserDefAddress", "anon");
+        filterChainDefinitionMap.put("/WXSendBookingMessage", "anon");
+        filterChainDefinitionMap.put("/WXSendOrderMessage", "anon");
+        filterChainDefinitionMap.put("/WXSendYSOrderMessage", "anon");
+        filterChainDefinitionMap.put("/getEquipmentAmount", "anon");
+        filterChainDefinitionMap.put("/getValidPO", "anon");
+        filterChainDefinitionMap.put("/getValidPosition", "anon");
+        filterChainDefinitionMap.put("/getWxPosition", "anon");
+        filterChainDefinitionMap.put("/insertPromotionUserInfo", "anon");
+        filterChainDefinitionMap.put("/checkDcIntroducers", "anon");
+        filterChainDefinitionMap.put("/getDcIntroduceLogs", "anon");
+        filterChainDefinitionMap.put("/getDcIntroducerExtracts", "anon");
+        filterChainDefinitionMap.put("/date_DcIntroducerExtracts", "anon");
+        filterChainDefinitionMap.put("/getAccountNumber", "anon");
+        filterChainDefinitionMap.put("/queryOneDcIntroducerExtract", "anon");
+        filterChainDefinitionMap.put("/insertDcIntroducerExtract", "anon");
+        filterChainDefinitionMap.put("/WXSendExtractMessage", "anon");
+        filterChainDefinitionMap.put("/insertDcIntroduceLog", "anon");
+        filterChainDefinitionMap.put("/getDcIntroducerConsultants", "anon");
+        filterChainDefinitionMap.put("/queryMineOrder", "anon");
+        filterChainDefinitionMap.put("/getYSOrder", "anon");
+        filterChainDefinitionMap.put("/insertYsOrderPay", "anon");
+        filterChainDefinitionMap.put("/checkCustomerPay", "anon");
+        filterChainDefinitionMap.put("/queryYSOrderReturn", "anon");
+        filterChainDefinitionMap.put("/updateEquipmenteHireHeadOnline", "anon");
+        filterChainDefinitionMap.put("/getIndexPromotions", "anon");
+        filterChainDefinitionMap.put("/CreatePOP", "anon");
+        filterChainDefinitionMap.put("/getPromotionDC", "anon");
+        filterChainDefinitionMap.put("/checkMkt", "anon");
+        filterChainDefinitionMap.put("/getBranches", "anon");
+        filterChainDefinitionMap.put("/insertPromotionDCUserInfo", "anon");
+        filterChainDefinitionMap.put("/updateDcIntroducerApplicant", "anon");
+        filterChainDefinitionMap.put("/updateAccountNumber", "anon");
+        filterChainDefinitionMap.put("/insertPromotionChannelLog", "anon");
+        filterChainDefinitionMap.put("/getPromotionTestByPrxID", "anon");
+        filterChainDefinitionMap.put("/getPromotionTestResultByPtID", "anon");
+        filterChainDefinitionMap.put("/insertPromotionTestUserScore", "anon");
+        filterChainDefinitionMap.put("/CreateTestShare", "anon");
+        filterChainDefinitionMap.put("/getPromotionDCByID", "anon");
+        filterChainDefinitionMap.put("/getPromotionTestUserScoreByOpenID", "anon");
+        filterChainDefinitionMap.put("/getPromotionTestResultShowByPrxID", "anon");
+        filterChainDefinitionMap.put("/getWXDianPing", "anon");
+        filterChainDefinitionMap.put("/getWXContentTypes", "anon");
+        filterChainDefinitionMap.put("/queryUserContent", "anon");
+        filterChainDefinitionMap.put("/getWXUser", "anon");
+        filterChainDefinitionMap.put("/getWXMMSearchQuestion", "anon");
+        filterChainDefinitionMap.put("/queryUserMMSearch", "anon");
+        filterChainDefinitionMap.put("/getMmInfoResume", "anon");
+        filterChainDefinitionMap.put("/getPackageImagesByID", "anon");
+        //萌动开放权限
+        filterChainDefinitionMap.put("/getNewUserCoupon", "anon");
+        filterChainDefinitionMap.put("/getConsultTaskCoupon", "anon");
+        filterChainDefinitionMap.put("/getDetectionTaskCoupon", "anon");
+        filterChainDefinitionMap.put("/getRechargeTaskCoupon", "anon");
+        //文件上传临时解决方案
+        filterChainDefinitionMap.put("/uploadPromotionImg", "anon");
+        filterChainDefinitionMap.put("/uploadImg", "anon");
+        filterChainDefinitionMap.put("/uploadPayImg", "anon");
+        filterChainDefinitionMap.put("/uploadMiniImg", "anon");
+        filterChainDefinitionMap.put("/uploadDianPingImg", "anon");
+        //简历分享问题
+        filterChainDefinitionMap.put("/getWeChatInfo", "anon");
+        //超人妈妈学院
+        filterChainDefinitionMap.put("/college/queryUserPoints", "anon");
+        filterChainDefinitionMap.put("/college/queryUserLearningCore", "anon");
+        filterChainDefinitionMap.put("/college/queryUserLearningPractice", "anon");
+        filterChainDefinitionMap.put("/college/queryUserLearningExperience", "anon");
+        filterChainDefinitionMap.put("/college/queryUserLearningCoreDetail", "anon");
+        filterChainDefinitionMap.put("/college/queryCoreDetail", "anon");
+        filterChainDefinitionMap.put("/college/queryTests", "anon");
+        filterChainDefinitionMap.put("/college/addTestDetail", "anon");
+        filterChainDefinitionMap.put("/college/queryPracticeDetail", "anon");
+        filterChainDefinitionMap.put("/college/queryExperienceDetail", "anon");
+        filterChainDefinitionMap.put("/college/addCollegeBooking", "anon");
+        filterChainDefinitionMap.put("/college/corePositive", "anon");
+        filterChainDefinitionMap.put("/college/coreLearningUpdate", "anon");
+        filterChainDefinitionMap.put("/college/coreLearningFinish", "anon");
+        filterChainDefinitionMap.put("/college/getCollegeBooking", "anon");
+        filterChainDefinitionMap.put("/college/bookingCancel", "anon");
+        filterChainDefinitionMap.put("/eLearning/index", "anon");
+        filterChainDefinitionMap.put("/eLearning/courseworkList", "anon");
+        filterChainDefinitionMap.put("/eLearning/courseworkDetail", "anon");
+        filterChainDefinitionMap.put("/eLearning/testList", "anon");
+        filterChainDefinitionMap.put("/eLearning/testComplete", "anon");
+        filterChainDefinitionMap.put("/eLearning/courseworkComplete", "anon");
+        filterChainDefinitionMap.put("/eLearning/courseworkUpdate", "anon");
+        filterChainDefinitionMap.put("/eLearning/courseworkBooking", "anon");
+//        //用户,需要角色权限 “user”
+//        filterChainDefinitionMap.put("/user/**", "roles[user]");
+//        //管理员,需要角色权限 “admin”
+//        filterChainDefinitionMap.put("/admin/**", "roles[admin]");
+        //开放登陆接口
+        filterChainDefinitionMap.put("/login", "anon");
+        //其余接口一律拦截
+        //主要这行代码必须放在所有权限设置的最后,不然会导致所有 url 都被拦截
+        filterChainDefinitionMap.put("/**", "authcToken,authc");
+
+        shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
+        return shiroFilterFactoryBean;
+    }
+
+    /**
+     * 自定义身份认证 realm;
+     * <p>
+     * 必须写这个类,并加上 @Bean 注解,目的是注入 CustomRealm,
+     * 否则会影响 CustomRealm类 中其他类的依赖注入
+     */
+    @Bean
+    public CustomRealm customRealm() {
+        return new CustomRealm();
+    }
+
+    @Bean
+    public SessionManager sessionManager() {
+        ShiroSessionManager shiroSessionManager = new ShiroSessionManager();
+        //这里可以不设置。Shiro有默认的session管理。如果缓存为Redis则需改用Redis的管理
+        shiroSessionManager.setSessionDAO(new EnterpriseCacheSessionDAO());
+        return shiroSessionManager;
+    }
+
+    @Bean
+    public SecurityManager securityManager() {
+        DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
+//        securityManager.setRealm(customRealm());
+        securityManager.setAuthenticator(authenticator(jlAdminUserService));
+        //自定义session管理
+        securityManager.setSessionManager(sessionManager());
+        //自定义缓存实现
+//        securityManager.setCacheManager(ehCacheManager());
+        return securityManager;
+    }
+
+    protected JWTAuthFilter createAuthFilter(JlAdminUserService jlAdminUserService) {
+        return new JWTAuthFilter(jlAdminUserService);
+    }
+
+    @Bean("jwtRealm")
+    public Realm jwtShiroRealm(JlAdminUserService jlAdminUserService) {
+        JWTShiroRealm myShiroRealm = new JWTShiroRealm(jlAdminUserService);
+        return myShiroRealm;
+    }
+
+    @Bean
+    public Authenticator authenticator(JlAdminUserService jlAdminUserService) {
+        ModularRealmAuthenticator authenticator = new ModularRealmAuthenticator();
+        authenticator.setRealms(Arrays.asList(jwtShiroRealm(jlAdminUserService), customRealm()));
+        authenticator.setAuthenticationStrategy(new FirstSuccessfulStrategy());
+        return authenticator;
+    }
 }

+ 136 - 0
src/main/java/com/ygj/yuemum/shiro/sso/JWTAuthFilter.java

@@ -0,0 +1,136 @@
+package com.ygj.yuemum.shiro.sso;
+
+import com.google.gson.Gson;
+import com.ygj.yuemum.service.admin.JlAdminUserService;
+import com.ygj.yuemum.utils.JWTConstants;
+import org.apache.commons.lang.StringUtils;
+import org.apache.http.HttpStatus;
+import org.apache.shiro.authc.AuthenticationException;
+import org.apache.shiro.authc.AuthenticationToken;
+import org.apache.shiro.subject.Subject;
+import org.apache.shiro.web.filter.authc.AuthenticatingFilter;
+import org.apache.shiro.web.util.WebUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.Map;
+
+public class JWTAuthFilter extends AuthenticatingFilter {
+    private final Logger log = LoggerFactory.getLogger(JWTAuthFilter.class);
+
+    private JlAdminUserService jlAdminUserService;
+
+    private Gson gson = new Gson();
+
+    public JWTAuthFilter(JlAdminUserService jlAdminUserService) {
+        this.jlAdminUserService = jlAdminUserService;
+        this.setLoginUrl("/login");
+    }
+
+    @Override
+    protected boolean preHandle(ServletRequest request, ServletResponse response) throws Exception {
+        HttpServletRequest httpServletRequest = WebUtils.toHttp(request);
+        if (httpServletRequest.getMethod().equals(RequestMethod.OPTIONS.name())) //对于OPTION请求做拦截,不做token校验
+            return false;
+
+        return super.preHandle(request, response);
+    }
+
+    @Override
+    protected void postHandle(ServletRequest request, ServletResponse response) throws IOException {
+        this.fillCorsHeader(WebUtils.toHttp(request), WebUtils.toHttp(response));
+    }
+
+    @Override
+    protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) {
+
+        //当token为空时,跳过,直接下一个校验
+        String jwtToken = getAuthToken(request);
+        if (StringUtils.isBlank(jwtToken)) {
+            return true;
+        }
+
+        boolean allowed = false;
+        try {
+            allowed = executeLogin(request, response);
+        } catch (IllegalStateException e) { //not found any token
+            log.error("Not found any token");
+        } catch (Exception e) {
+            log.error("Error occurs when login", e);
+        }
+        return allowed || super.isPermissive(mappedValue);
+    }
+
+    @Override
+    protected AuthenticationToken createToken(ServletRequest servletRequest, ServletResponse servletResponse) {
+        String jwtToken = getAuthToken(servletRequest);
+        if (StringUtils.isNotBlank(jwtToken))
+            return new JWTToken(jwtToken);
+
+        return null;
+    }
+
+    @Override
+    protected boolean onAccessDenied(ServletRequest servletRequest, ServletResponse servletResponse) throws Exception {
+        HttpServletResponse httpResponse = WebUtils.toHttp(servletResponse);
+        httpResponse.setCharacterEncoding("UTF-8");
+        httpResponse.setContentType("application/json;charset=UTF-8");
+        httpResponse.setStatus(HttpStatus.SC_BAD_REQUEST);
+        fillCorsHeader(WebUtils.toHttp(servletRequest), httpResponse);
+        Map<String, Object> map = new HashMap<>();
+        map.put("code", "1000000");
+        map.put("msg", "sso-token不合法!");
+        PrintWriter out = servletResponse.getWriter();
+        out.write(gson.toJson(map));
+        out.flush();
+        out.close();
+        return false;
+    }
+
+    @Override
+    protected boolean onLoginSuccess(AuthenticationToken token, Subject subject, ServletRequest request, ServletResponse response) throws Exception {
+        //自定义登录成功的处理逻辑
+        return true;
+    }
+
+    @Override
+    protected boolean onLoginFailure(AuthenticationToken token, AuthenticationException e, ServletRequest request, ServletResponse response) {
+        log.error("Validate token fail, token:{}, error:{}", token.toString(), e.getMessage());
+        return false;
+    }
+
+    protected String getAuthToken(ServletRequest request) {
+        HttpServletRequest httpRequest = WebUtils.toHttp(request);
+        String token = httpRequest.getHeader(JWTConstants.TOKEN);
+        if (StringUtils.isBlank(token)) {
+            token = httpRequest.getParameter(JWTConstants.TOKEN);
+        }
+        return token;
+    }
+
+    protected void fillCorsHeader(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        // 允许哪些Origin发起跨域请求,nginx下正常
+        // response.setHeader( "Access-Control-Allow-Origin", config.getInitParameter( "AccessControlAllowOrigin" ) );
+        response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));
+        // 允许请求的方法
+        response.setHeader("Access-Control-Allow-Methods", "*");
+        // 多少秒内,不需要再发送预检验请求,可以缓存该结果
+        response.setHeader("Access-Control-Max-Age", "86400");
+        // 表明它允许跨域请求包含xxx头
+        response.setHeader("Access-Control-Allow-Headers", "JSESSIONID,x-auth-token,Origin,Access-Token,X-Requested-With,Content-Type, Accept");
+        //是否允许浏览器携带用户身份信息(cookie)
+        response.setHeader("Access-Control-Allow-Credentials", "true");
+        if (request.getMethod().equals("OPTIONS")) {
+            response.setStatus(HttpStatus.SC_OK);
+            response.getWriter().write("OPTIONS returns OK");
+        }
+    }
+}

+ 62 - 0
src/main/java/com/ygj/yuemum/shiro/sso/JWTShiroRealm.java

@@ -0,0 +1,62 @@
+package com.ygj.yuemum.shiro.sso;
+
+import com.ygj.yuemum.domain.admin.JlAdminUser;
+import com.ygj.yuemum.service.admin.JlAdminUserService;
+import com.ygj.yuemum.utils.JWTUtils;
+import org.apache.shiro.authc.AuthenticationException;
+import org.apache.shiro.authc.AuthenticationInfo;
+import org.apache.shiro.authc.AuthenticationToken;
+import org.apache.shiro.authc.SimpleAuthenticationInfo;
+import org.apache.shiro.authz.AuthorizationInfo;
+import org.apache.shiro.authz.SimpleAuthorizationInfo;
+import org.apache.shiro.realm.AuthorizingRealm;
+import org.apache.shiro.subject.PrincipalCollection;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+
+/**
+ * 自定义身份认证
+ *
+ */
+
+@Component
+public class JWTShiroRealm extends AuthorizingRealm {
+
+    private final Logger log = LoggerFactory.getLogger(JWTShiroRealm.class);
+
+    private JlAdminUserService jlAdminUserService;
+
+    public JWTShiroRealm(JlAdminUserService jlAdminUserService) {
+        this.jlAdminUserService = jlAdminUserService;
+    }
+
+    @Override
+    public boolean supports(AuthenticationToken token) {
+        return token instanceof JWTToken;
+    }
+
+    /**
+     * 认证信息.(身份验证) : Authentication 是用来验证用户身份
+     * 默认使用此方法进行用户名正确与否验证,错误抛出异常即可。
+     */
+    @Override
+    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authcToken) throws AuthenticationException {
+        JWTToken jwtToken = (JWTToken) authcToken;
+        String token = jwtToken.getToken();
+
+        String userEmail = JWTUtils.getUserName(token);
+
+        JlAdminUser user = jlAdminUserService.getUserByEmail(userEmail);
+        if (user == null)
+            throw new AuthenticationException("token不合法,请重新登录");
+
+        return new SimpleAuthenticationInfo(user.getName(), token, "jwtRealm");
+    }
+
+    @Override
+    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
+        return new SimpleAuthorizationInfo();
+    }
+}

+ 42 - 0
src/main/java/com/ygj/yuemum/shiro/sso/JWTToken.java

@@ -0,0 +1,42 @@
+package com.ygj.yuemum.shiro.sso;
+
+import org.apache.shiro.authc.HostAuthenticationToken;
+
+public class JWTToken implements HostAuthenticationToken {
+	private static final long serialVersionUID = 9217639903967592166L;
+	
+	private String token;
+    private String host;
+
+    public JWTToken(String token) {
+        this(token, null);
+    }
+
+    public JWTToken(String token, String host) {
+        this.token = token;
+        this.host = host;
+    }
+
+    public String getToken(){
+        return this.token;
+    }
+
+    public String getHost() {
+        return host;
+    }
+
+    @Override
+    public Object getPrincipal() {
+        return token;
+    }
+
+    @Override
+    public Object getCredentials() {
+        return token;
+    }
+
+    @Override
+    public String toString(){
+        return token + ':' + host;
+    }
+}

+ 16 - 0
src/main/java/com/ygj/yuemum/utils/JWTConstants.java

@@ -0,0 +1,16 @@
+package com.ygj.yuemum.utils;
+
+public class JWTConstants {
+
+    //默认redis缓存一天,jwt的失效时间也是一天
+    public static final long CACHE_DEFAULT_STORE_TIME = 60 * 60 * 24;
+
+    public static final String USERNAME = "userName";
+
+    public static final String ROLES = "roles";
+
+    public static final String SALT = "yue-suo";
+
+    public static final String TOKEN = "token";
+
+}

+ 48 - 0
src/main/java/com/ygj/yuemum/utils/JWTUtils.java

@@ -0,0 +1,48 @@
+package com.ygj.yuemum.utils;
+
+import io.jsonwebtoken.Claims;
+import io.jsonwebtoken.Jwts;
+import io.jsonwebtoken.SignatureAlgorithm;
+
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+public class JWTUtils {
+
+    //解析出jwt内容
+    public static Claims decoderJwt(String token) {
+        return Jwts.parser()
+                .setSigningKey(JWTConstants.SALT)
+                .parseClaimsJws(token)
+                .getBody();
+
+    }
+
+
+    //生成jwt
+    public static String encoderJwt(Map<String, Object> claims) {
+        return Jwts.builder()
+                .setClaims(claims)
+                .setExpiration(Date.from((LocalDateTime.now().plusSeconds(60 * 60 * 24)).atZone(ZoneId.systemDefault()).toInstant()))
+                .signWith(SignatureAlgorithm.HS512, JWTConstants.SALT)
+                .compact();
+
+    }
+
+    //获取用户名
+    public static String getUserName(String token) {
+        Claims claims = decoderJwt(token);
+        return claims.get(JWTConstants.USERNAME, String.class);
+    }
+
+
+    public static void main(String[] args) {
+        Map<String, Object> map = new HashMap<>();
+        map.put(JWTConstants.USERNAME, "admin");
+        System.out.println(encoderJwt(map));
+
+    }
+}

+ 157 - 157
src/main/resources/application.yml

@@ -1,157 +1,157 @@
-server:
-  port: 8888
-mybatis:
-  config-location: classpath:mybatis/mybatis-config.xml
-  mapper-locations: mybatis/mapper/*/*.xml
-  mybatis.type-aliases-package: com.ygj.yuemum.*/*
-  log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
-spring:
-  datasource:
-    driverClassName: com.mysql.jdbc.Driver
-    url: jdbc:mysql://121.43.235.99:3306/yuemum?useUnicode=true&characterEncoding=utf-8&noDatetimeStringSync=true
-    username: jielin
-    password: jielin123
-  thymeleaf:
-    mode: LEGACYHTML5
-    prefix: classpath:/templates
-  servlet:
-    multipart:
-      enabled: true
-      file-size-threshold: 0
-      max-file-size: 5M
-      max-request-size: 50M
-  devtools:
-    restart:
-      enabled: true  #设置开启热部署
-    freemarker:
-      cache: false    #页面不加载缓存,修改即时生效
-pagehelper:
-  helper-dialect: mysql
-  reasonable: true
-  support-methods-arguments: true
-  params: count=countSql
-logging:
-  level:
-     com.ygj.yuemum.dao : debug
-#优惠券批次号信息--------------------
-#测试
-#coupon:
-#  NewUserCoupon : "PVP2018051297451"
-#  ConsultTaskCoupon : "PVP2018051273883"
-#  DetectionTaskCoupon : "PVP2018051211608"
-#  RechargeTaskCoupon : "PVP2018051263016"
-#生产
-coupon:
-  NewUserCoupon : "PVP2018051717019"
-  ConsultTaskCoupon : "PVP2018051739929"
-  DetectionTaskCoupon : "PVP2018051713733"
-  RechargeTaskCoupon : "PVP2018051714111"
-#图片上传路径--------------------------
-#本地
-file:
-  ROOT : "C:/apache-tomcat-9.0.14/webapps/resume/img/"
-  ResumeFile : "C:/apache-tomcat-9.0.14/webapps/resume/"
-  httpRoot : "http://localhost:8080/resume/img/"
-  httphtmlRoot : "http://localhost:8080/resume/"
-  modulePath : "C:/apache-tomcat-9.0.14/webapps/resume/resume.html"
-  payvoucher : "C:/apache-tomcat-9.0.14/webapps/payvoucher"
-  httppayvoucher : "http://localhost:8080/payvoucher"
-  promotionvoucher : "C:/apache-tomcat-9.0.14/webapps/MiniProgram/promotion/offline"
-  httppromotionvoucher : "http://localhost:8080/MiniProgram/promotion/offline"
-  qrcode: "C:/apache-tomcat-9.0.14/webapps/MiniProgram/mgm"
-  httpqrcode: "http://127.0.0.1:8080/MiniProgram/mgm"
-  IMGBANKCARD: "C:/apache-tomcat-9.0.14/webapps/MiniProgram/mgm/bankCard/"
-  HTTPIMGBANKCARD: "http://127.0.0.1:8080/MiniProgram/mgm/bankCard/"
-  LOCALQRCODE: "C:/apache-tomcat-9.0.14/webapps/MiniProgram/mgm"
-  DEMOQRCODE: "C:/apache-tomcat-9.0.14/webapps/MiniProgram/mgm/pop"
-  HTTPOPPQRCODE: "http://127.0.0.1:8080/MiniProgram/mgm/pop"
-  TESTQRCODE: "C:/apache-tomcat-9.0.14/webapps/MiniProgram/promotion/test"
-  HTTTESTQRCODE: "http://127.0.0.1:8080/MiniProgram/promotion/test/dc"
-  BANNERIMGURL: "C:/apache-tomcat-9.0.14/webapps/MiniProgram/index/banner/"
-  HTTPBANNERIMGURL: "http://127.0.0.1:8080/MiniProgram/index/banner/"
-  DIANPINGIMGURL: "C:/apache-tomcat-9.0.14/webapps/MiniProgram/dianping/"
-  HTTPDIANPINGIMGURL: "http://127.0.0.1:8080/MiniProgram/dianping/"
-#测试
-#file:
-#  ROOT : "/home/tomcat/apache-tomcat-8.5.40/webapps/resume/img/"
-#  ResumeFile : "/home/tomcat/apache-tomcat-8.5.40/webapps/resume/"
-#  httpRoot : "http://192.168.1.24:8182/resume/img/"
-#  httphtmlRoot : "http://192.168.1.24:8182/resume/"
-#  modulePath : "/home/tomcat/apache-tomcat-8.5.40/webapps/resume/resume.html"
-#  payvoucher : "/home/tomcat/apache-tomcat-8.5.40/webapps/payvoucher"
-#  httppayvoucher : "http://192.168.1.24:8182/payvoucher"
-#  promotionvoucher : "/home/tomcat/apache-tomcat-8.5.40/webapps/MiniProgram/promotion/offline"
-#  httppromotionvoucher : "http://192.168.1.24:8182/MiniProgram/promotion/offline"
-#  qrcode: "/home/tomcat/apache-tomcat-8.5.40/webapps/MiniProgram/mgm"
-#  httpqrcode: "http://192.168.1.24:8182/MiniProgram/mgm"
-#  IMGBANKCARD: "/home/tomcat/apache-tomcat-8.5.40/webapps/MiniProgram/mgm/bankCard/"
-#  HTTPIMGBANKCARD: "http://192.168.1.24:8182/MiniProgram/mgm/bankCard/"
-#  LOCALQRCODE: "/home/tomcat/apache-tomcat-8.5.40/webapps/MiniProgram/mgm"
-#  DEMOQRCODE: "/home/tomcat/apache-tomcat-8.5.40/webapps/MiniProgram/mgm/pop"
-#  HTTPOPPQRCODE: "http://192.168.1.24:8182/MiniProgram/mgm/pop"
-#  TESTQRCODE: "/home/tomcat/apache-tomcat-8.5.40/webapps/MiniProgram/promotion/test"
-#  HTTTESTQRCODE: "http://192.168.1.24:8182/MiniProgram/promotion/test/dc"
-#  BANNERIMGURL: "/home/tomcat/apache-tomcat-8.5.40/webapps/MiniProgram/index/banner/"
-#  HTTPBANNERIMGURL: "http://192.168.1.24:8182/MiniProgram/index/banner/"
-#  DIANPINGIMGURL: "/home/tomcat/apache-tomcat-8.5.40/webapps/MiniProgram/dianping/"
-#  HTTPDIANPINGIMGURL: "http://192.168.1.24:8182/MiniProgram/dianping/"
-#生产
-#file:
-#  ROOT : "/usr/local/tomcat/tomcat7/webapps/resume/img/"
-#  ResumeFile : "/usr/local/tomcat/tomcat7/webapps/resume/"
-#  httpRoot : "https://yuesuo.yueguanjia.com/resume/img/"
-#  httphtmlRoot : "https://yuesuo.yueguanjia.com/resume/"
-#  modulePath : "/usr/local/tomcat/tomcat7/webapps/resume/resume.html"
-#  payvoucher : "/usr/local/tomcat/tomcat7/webapps/payvoucher"
-#  httppayvoucher : "https://yuesuo.yueguanjia.com/payvoucher"
-#  promotionvoucher : "/usr/local/tomcat/tomcat7/webapps/MiniProgram/promotion/offline"
-#  httppromotionvoucher : "https://yuesuo.yueguanjia.com/MiniProgram/promotion/offline"
-#  qrcode: "/usr/local/tomcat/tomcat7/webapps/MiniProgram/mgm"
-#  httpqrcode: "https://yuesuo.yueguanjia.com/MiniProgram/mgm"
-#  IMGBANKCARD: "/usr/local/tomcat/tomcat7/webapps/MiniProgram/mgm/bankCard/"
-#  HTTPIMGBANKCARD: "https://yuesuo.yueguanjia.com/MiniProgram/mgm/bankCard/"
-#  LOCALQRCODE: "/usr/local/tomcat/tomcat7/webapps/MiniProgram/mgm"
-#  DEMOQRCODE: "/usr/local/tomcat/tomcat7/webapps/MiniProgram/mgm/pop"
-#  HTTPOPPQRCODE: "https://yuesuo.yueguanjia.com/MiniProgram/mgm/pop"
-#  TESTQRCODE: "/usr/local/tomcat/tomcat7/webapps/MiniProgram/promotion/test"
-#  HTTTESTQRCODE: "https://yuesuo.yueguanjia.com/MiniProgram/promotion/test/dc"
-#  BANNERIMGURL: "/usr/local/tomcat/tomcat7/webapps/MiniProgram/index/banner/"
-#  HTTPBANNERIMGURL: "https://yuesuo.yueguanjia.com/MiniProgram/index/banner/"
-#  DIANPINGIMGURL: "/usr/local/tomcat/tomcat7/webapps/MiniProgram/dianping/"
-#  HTTPDIANPINGIMGURL: "https://yuesuo.yueguanjia.com/MiniProgram/dianping/"
-#微信公众号---------------------------------------------------
-wechat:
-  APPID : "wx52852a3c47540fad"
-  APPSECRET : "31e4eef58038830327eb88661e3a681f" #获取access_token
-  GRANT_TYPE : "client_credential"
-  JSAPI_TICKET_TYPE : "jsapi"
-  ACCESS_TOKEN_URL : "https://api.weixin.qq.com/cgi-bin/token"
-  JSAPI_TICKET_URL : "https://api.weixin.qq.com/cgi-bin/ticket/getticket"
-  JSCODE2SESSION : "https://api.weixin.qq.com/sns/jscode2session"
-  SENDMESSAGEURL : "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" #公众号消息发送地址
-  OrderTemplateid : "VyMPKDDGOy85wDIJuXR7sBuiIBEg0OPaCg6C_Dt_D0g"  #公众号消息模版
-  BookingTemplateid : "Wvysqh3Ec9lXpf5tytq0T2zzs662uowNLFCPiAPBFkA" #公众号消息模版
-  ExtractTemplateid : "uAkxPS92FqovRSrg3n2P4xfNMwQ12iEcpRrnSp-D36Q" #公众号消息模版
-  WPOPENID : "oAjHTvxMhnBL4T59ZOG0jKwsFe4k" #公众号发送消息 园园
-  #测试小程序
-  #MINIAPPID : "wx1c3ef3300b74ed86"
-  #MINIAPPSECRET : "ba5624bc087921d5a5832da9193e40f1"
-  #生产小程序
-  MINIAPPID : "wx20a080f3bf83ba47"
-  MINIAPPSECRET : "61021776790449943ba5f40288efa0d6"
-baidu:
-  BAIDUAK: "2PndpvczSX3MdItrRpqVIcPS"
-  BAIDUSK: "Ik3WA4BeyphCmC0z35OZ0OlgT6W7qnRC"
-  AUTHHOST: "https://aip.baidubce.com/oauth/2.0/token?"
-  BANKCARD: "https://aip.baidubce.com/rest/2.0/ocr/v1/bankcard"
-api:
-  MDJAPIURL: "http://120.55.37.107:8763/introduce/activity"
-  BIZOBJECTSERVICE: "http://10.81.168.51:8090/edw/h3/operateObjects"
-  BIZUSERSERVICE: "https://www.h3yun.com/OpenApi/Invoke"
-#  BIZOBJECTSERVICE: "http://192.168.1.213:8010/h3/operateObjects"
-college:
-  LMP: 43
-  AGE: 12
-
-
-
+server:
+  port: 8888
+mybatis:
+  config-location: classpath:mybatis/mybatis-config.xml
+  mapper-locations: mybatis/mapper/*/*.xml
+  mybatis.type-aliases-package: com.ygj.yuemum.*/*
+  log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+spring:
+  datasource:
+    driverClassName: com.mysql.jdbc.Driver
+    url: jdbc:mysql://218.78.47.145:3306/yuemum?useUnicode=true&characterEncoding=utf-8&noDatetimeStringSync=true
+    username: root
+    password: Test2020@
+  thymeleaf:
+    mode: LEGACYHTML5
+    prefix: classpath:/templates
+  servlet:
+    multipart:
+      enabled: true
+      file-size-threshold: 0
+      max-file-size: 5M
+      max-request-size: 50M
+  devtools:
+    restart:
+      enabled: true  #设置开启热部署
+    freemarker:
+      cache: false    #页面不加载缓存,修改即时生效
+pagehelper:
+  helper-dialect: mysql
+  reasonable: true
+  support-methods-arguments: true
+  params: count=countSql
+logging:
+  level:
+     com.ygj.yuemum.dao : debug
+#优惠券批次号信息--------------------
+#测试
+#coupon:
+#  NewUserCoupon : "PVP2018051297451"
+#  ConsultTaskCoupon : "PVP2018051273883"
+#  DetectionTaskCoupon : "PVP2018051211608"
+#  RechargeTaskCoupon : "PVP2018051263016"
+#生产
+coupon:
+  NewUserCoupon : "PVP2018051717019"
+  ConsultTaskCoupon : "PVP2018051739929"
+  DetectionTaskCoupon : "PVP2018051713733"
+  RechargeTaskCoupon : "PVP2018051714111"
+#图片上传路径--------------------------
+#本地
+file:
+  ROOT : "C:/apache-tomcat-9.0.14/webapps/resume/img/"
+  ResumeFile : "C:/apache-tomcat-9.0.14/webapps/resume/"
+  httpRoot : "http://localhost:8080/resume/img/"
+  httphtmlRoot : "http://localhost:8080/resume/"
+  modulePath : "C:/apache-tomcat-9.0.14/webapps/resume/resume.html"
+  payvoucher : "C:/apache-tomcat-9.0.14/webapps/payvoucher"
+  httppayvoucher : "http://localhost:8080/payvoucher"
+  promotionvoucher : "C:/apache-tomcat-9.0.14/webapps/MiniProgram/promotion/offline"
+  httppromotionvoucher : "http://localhost:8080/MiniProgram/promotion/offline"
+  qrcode: "C:/apache-tomcat-9.0.14/webapps/MiniProgram/mgm"
+  httpqrcode: "http://127.0.0.1:8080/MiniProgram/mgm"
+  IMGBANKCARD: "C:/apache-tomcat-9.0.14/webapps/MiniProgram/mgm/bankCard/"
+  HTTPIMGBANKCARD: "http://127.0.0.1:8080/MiniProgram/mgm/bankCard/"
+  LOCALQRCODE: "C:/apache-tomcat-9.0.14/webapps/MiniProgram/mgm"
+  DEMOQRCODE: "C:/apache-tomcat-9.0.14/webapps/MiniProgram/mgm/pop"
+  HTTPOPPQRCODE: "http://127.0.0.1:8080/MiniProgram/mgm/pop"
+  TESTQRCODE: "C:/apache-tomcat-9.0.14/webapps/MiniProgram/promotion/test"
+  HTTTESTQRCODE: "http://127.0.0.1:8080/MiniProgram/promotion/test/dc"
+  BANNERIMGURL: "C:/apache-tomcat-9.0.14/webapps/MiniProgram/index/banner/"
+  HTTPBANNERIMGURL: "http://127.0.0.1:8080/MiniProgram/index/banner/"
+  DIANPINGIMGURL: "C:/apache-tomcat-9.0.14/webapps/MiniProgram/dianping/"
+  HTTPDIANPINGIMGURL: "http://127.0.0.1:8080/MiniProgram/dianping/"
+#测试
+#file:
+#  ROOT : "/home/tomcat/apache-tomcat-8.5.40/webapps/resume/img/"
+#  ResumeFile : "/home/tomcat/apache-tomcat-8.5.40/webapps/resume/"
+#  httpRoot : "http://192.168.1.24:8182/resume/img/"
+#  httphtmlRoot : "http://192.168.1.24:8182/resume/"
+#  modulePath : "/home/tomcat/apache-tomcat-8.5.40/webapps/resume/resume.html"
+#  payvoucher : "/home/tomcat/apache-tomcat-8.5.40/webapps/payvoucher"
+#  httppayvoucher : "http://192.168.1.24:8182/payvoucher"
+#  promotionvoucher : "/home/tomcat/apache-tomcat-8.5.40/webapps/MiniProgram/promotion/offline"
+#  httppromotionvoucher : "http://192.168.1.24:8182/MiniProgram/promotion/offline"
+#  qrcode: "/home/tomcat/apache-tomcat-8.5.40/webapps/MiniProgram/mgm"
+#  httpqrcode: "http://192.168.1.24:8182/MiniProgram/mgm"
+#  IMGBANKCARD: "/home/tomcat/apache-tomcat-8.5.40/webapps/MiniProgram/mgm/bankCard/"
+#  HTTPIMGBANKCARD: "http://192.168.1.24:8182/MiniProgram/mgm/bankCard/"
+#  LOCALQRCODE: "/home/tomcat/apache-tomcat-8.5.40/webapps/MiniProgram/mgm"
+#  DEMOQRCODE: "/home/tomcat/apache-tomcat-8.5.40/webapps/MiniProgram/mgm/pop"
+#  HTTPOPPQRCODE: "http://192.168.1.24:8182/MiniProgram/mgm/pop"
+#  TESTQRCODE: "/home/tomcat/apache-tomcat-8.5.40/webapps/MiniProgram/promotion/test"
+#  HTTTESTQRCODE: "http://192.168.1.24:8182/MiniProgram/promotion/test/dc"
+#  BANNERIMGURL: "/home/tomcat/apache-tomcat-8.5.40/webapps/MiniProgram/index/banner/"
+#  HTTPBANNERIMGURL: "http://192.168.1.24:8182/MiniProgram/index/banner/"
+#  DIANPINGIMGURL: "/home/tomcat/apache-tomcat-8.5.40/webapps/MiniProgram/dianping/"
+#  HTTPDIANPINGIMGURL: "http://192.168.1.24:8182/MiniProgram/dianping/"
+#生产
+#file:
+#  ROOT : "/usr/local/tomcat/tomcat7/webapps/resume/img/"
+#  ResumeFile : "/usr/local/tomcat/tomcat7/webapps/resume/"
+#  httpRoot : "https://yuesuo.yueguanjia.com/resume/img/"
+#  httphtmlRoot : "https://yuesuo.yueguanjia.com/resume/"
+#  modulePath : "/usr/local/tomcat/tomcat7/webapps/resume/resume.html"
+#  payvoucher : "/usr/local/tomcat/tomcat7/webapps/payvoucher"
+#  httppayvoucher : "https://yuesuo.yueguanjia.com/payvoucher"
+#  promotionvoucher : "/usr/local/tomcat/tomcat7/webapps/MiniProgram/promotion/offline"
+#  httppromotionvoucher : "https://yuesuo.yueguanjia.com/MiniProgram/promotion/offline"
+#  qrcode: "/usr/local/tomcat/tomcat7/webapps/MiniProgram/mgm"
+#  httpqrcode: "https://yuesuo.yueguanjia.com/MiniProgram/mgm"
+#  IMGBANKCARD: "/usr/local/tomcat/tomcat7/webapps/MiniProgram/mgm/bankCard/"
+#  HTTPIMGBANKCARD: "https://yuesuo.yueguanjia.com/MiniProgram/mgm/bankCard/"
+#  LOCALQRCODE: "/usr/local/tomcat/tomcat7/webapps/MiniProgram/mgm"
+#  DEMOQRCODE: "/usr/local/tomcat/tomcat7/webapps/MiniProgram/mgm/pop"
+#  HTTPOPPQRCODE: "https://yuesuo.yueguanjia.com/MiniProgram/mgm/pop"
+#  TESTQRCODE: "/usr/local/tomcat/tomcat7/webapps/MiniProgram/promotion/test"
+#  HTTTESTQRCODE: "https://yuesuo.yueguanjia.com/MiniProgram/promotion/test/dc"
+#  BANNERIMGURL: "/usr/local/tomcat/tomcat7/webapps/MiniProgram/index/banner/"
+#  HTTPBANNERIMGURL: "https://yuesuo.yueguanjia.com/MiniProgram/index/banner/"
+#  DIANPINGIMGURL: "/usr/local/tomcat/tomcat7/webapps/MiniProgram/dianping/"
+#  HTTPDIANPINGIMGURL: "https://yuesuo.yueguanjia.com/MiniProgram/dianping/"
+#微信公众号---------------------------------------------------
+wechat:
+  APPID : "wx52852a3c47540fad"
+  APPSECRET : "31e4eef58038830327eb88661e3a681f" #获取access_token
+  GRANT_TYPE : "client_credential"
+  JSAPI_TICKET_TYPE : "jsapi"
+  ACCESS_TOKEN_URL : "https://api.weixin.qq.com/cgi-bin/token"
+  JSAPI_TICKET_URL : "https://api.weixin.qq.com/cgi-bin/ticket/getticket"
+  JSCODE2SESSION : "https://api.weixin.qq.com/sns/jscode2session"
+  SENDMESSAGEURL : "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" #公众号消息发送地址
+  OrderTemplateid : "VyMPKDDGOy85wDIJuXR7sBuiIBEg0OPaCg6C_Dt_D0g"  #公众号消息模版
+  BookingTemplateid : "Wvysqh3Ec9lXpf5tytq0T2zzs662uowNLFCPiAPBFkA" #公众号消息模版
+  ExtractTemplateid : "uAkxPS92FqovRSrg3n2P4xfNMwQ12iEcpRrnSp-D36Q" #公众号消息模版
+  WPOPENID : "oAjHTvxMhnBL4T59ZOG0jKwsFe4k" #公众号发送消息 园园
+  #测试小程序
+  #MINIAPPID : "wx1c3ef3300b74ed86"
+  #MINIAPPSECRET : "ba5624bc087921d5a5832da9193e40f1"
+  #生产小程序
+  MINIAPPID : "wx20a080f3bf83ba47"
+  MINIAPPSECRET : "61021776790449943ba5f40288efa0d6"
+baidu:
+  BAIDUAK: "2PndpvczSX3MdItrRpqVIcPS"
+  BAIDUSK: "Ik3WA4BeyphCmC0z35OZ0OlgT6W7qnRC"
+  AUTHHOST: "https://aip.baidubce.com/oauth/2.0/token?"
+  BANKCARD: "https://aip.baidubce.com/rest/2.0/ocr/v1/bankcard"
+api:
+  MDJAPIURL: "http://120.55.37.107:8763/introduce/activity"
+  BIZOBJECTSERVICE: "http://10.81.168.51:8090/edw/h3/operateObjects"
+  BIZUSERSERVICE: "https://www.h3yun.com/OpenApi/Invoke"
+#  BIZOBJECTSERVICE: "http://192.168.1.213:8010/h3/operateObjects"
+college:
+  LMP: 43
+  AGE: 12
+
+
+

+ 353 - 346
src/main/resources/mybatis/mapper/admin/JlAdminUserMapper.xml

@@ -1,347 +1,354 @@
-<?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.ygj.yuemum.dao.admin.JlAdminUserDao" >
-
-    <resultMap id="BaseResultMap" type="com.ygj.yuemum.domain.admin.JlAdminUser" >
-        <id column="id" property="id" jdbcType="INTEGER" />
-        <result column="username" property="username" jdbcType="VARCHAR" />
-        <result column="email" property="email" jdbcType="VARCHAR" />
-        <result column="name" property="name" jdbcType="VARCHAR" />
-        <result column="password" property="password" jdbcType="VARCHAR" />
-        <result column="create_time" property="create_time" jdbcType="VARCHAR" />
-        <result column="last_login_time" property="last_login_time" jdbcType="DATE" />
-        <result column="last_login_ip" property="last_login_ip" jdbcType="VARCHAR" />
-        <result column="role" property="role" jdbcType="INTEGER" />
-        <result column="status" property="status" jdbcType="INTEGER" />
-        <result column="org" property="org" jdbcType="INTEGER" />
-        <result column="last_login_location" property="last_login_location" jdbcType="VARCHAR" />
-        <result column="remark" property="remark" jdbcType="VARCHAR" />
-        <result column="phone" property="phone" jdbcType="VARCHAR" />
-        <result column="province" property="province" jdbcType="VARCHAR" />
-        <result column="city" property="city" jdbcType="VARCHAR" />
-        <result column="district" property="district" jdbcType="VARCHAR" />
-        <result column="province" property="province" jdbcType="VARCHAR" />
-        <result column="enabled" property="enabled" jdbcType="INTEGER" />
-        <result column="update_time" property="update_time" jdbcType="DATE" />
-    </resultMap>
-
-    <sql id="Base_Column_List" >
-        id,username,name,email,password,create_time,last_login_time,last_login_ip,role,status,org,last_login_location,remark,phone,province,city,district,enabled,update_time
-    </sql>
-
-    <select id="checkUsername"  resultType="java.lang.Integer" parameterType="java.lang.String">
-        select
-        count(1)
-        from jl_admin_user
-        where username =  #{username,jdbcType=VARCHAR}
-    </select>
-    <select id="getConsultants"  resultMap="BaseResultMap" >
-        select
-        *
-        from jl_admin_user
-        where role =  3
-    </select>
-    <select id="getRolePermissionCount"  resultType="java.lang.Integer" parameterType="java.lang.Integer">
-        select
-        count(1)
-        from jl_admin_user
-        where role =  #{roleid,jdbcType=VARCHAR}
-    </select>
-    <!-- 得到所有的用户信息 -->
-    <select id="getAll" resultMap="BaseResultMap" >
-        select
-        <include refid="Base_Column_List" />
-        from jl_admin_user
-    </select>
-    <select id="queryAdminUsers" resultMap="BaseResultMap" parameterType="com.ygj.yuemum.domain.admin.JlAdminUser">
-        select
-        id,
-        username,
-        name,
-        role,
-        status,
-        phone,
-        city,
-        IFNULL(fgetbranches_name(city),'ALL') cityname,
-        fgetrole_name(role) rolename
-        from jl_admin_user
-        where username != 'admin'
-        <if test="username != null and username !=''">
-            and username like "%"#{username,jdbcType=VARCHAR}"%"
-        </if>
-        <if test="phone != null and phone !=''">
-            and phone like "%"#{phone,jdbcType=VARCHAR}"%"
-        </if>
-        <if test="name != null and name !=''">
-            and name like "%"#{name,jdbcType=VARCHAR}"%"
-        </if>
-        <if test="role != null and role !=''">
-            and role = #{role,jdbcType=INTEGER}
-        </if>
-        <if test="status != null ">
-            and status = #{status,jdbcType=INTEGER}
-        </if>
-        <if test="city != null and city !=''">
-            and city = #{city,jdbcType=VARCHAR}
-        </if>
-    </select>
-
-    <select id="logIN" resultType="java.lang.Integer" parameterType="com.ygj.yuemum.domain.admin.JlAdminUser">
-        select
-        count(1)
-        from jl_admin_user
-        where 1=1
-        <if test="username != null" >
-            and username =  #{username,jdbcType=VARCHAR}
-        </if>
-        <if test="password != null" >
-            and password = #{password,jdbcType=VARCHAR}
-        </if>
-    </select>
-
-    <select id="getPassword" resultType="java.lang.String" parameterType="java.lang.String">
-        select
-        password
-        from jl_admin_user
-        where
-        username =  #{username,jdbcType=VARCHAR}
-    </select>
-
-    <select id="getStatus" resultType="java.lang.String" parameterType="java.lang.String">
-        select
-        status
-        from jl_admin_user
-        where
-        username =  #{username,jdbcType=VARCHAR}
-    </select>
-
-    <select id="getRole" resultType="java.lang.String" parameterType="java.lang.String">
-        select
-        role
-        from jl_admin_user
-        where
-        username =  #{username,jdbcType=VARCHAR}
-    </select>
-
-    <select id="getUserMkt" resultMap="BaseResultMap" parameterType="java.lang.String">
-        select
-        id,
-        username,
-        email,
-        name,
-        password,
-        create_time,
-        last_login_time,
-        last_login_ip,
-        role,
-        fgetisvisit(role) isvisit,
-        status,
-        org,
-        last_login_location,
-        remark,
-        phone,
-        province,
-        city,
-        district,
-        enabled,
-        update_time
-        from jl_admin_user
-        where
-        username =  #{username,jdbcType=VARCHAR}
-    </select>
-
-    <!-- 根据id查找某个用户信息 -->
-    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
-        select
-        *
-        from jl_admin_user
-        where id = #{id,jdbcType=INTEGER}
-    </select>
-
-    <!-- 根据id删除某个用户信息 -->
-        <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
-            delete from jl_admin_user
-            where id = #{id,jdbcType=INTEGER}
-        </delete>
-
-    <!-- 插入一条用户信息 -->
-    <insert id="insertSelective" parameterType="com.ygj.yuemum.domain.admin.JlAdminUser" >
-        insert into jl_admin_user
-        <trim prefix="(" suffix=")" suffixOverrides="," >
-            <if test="username != null" >
-                username,
-            </if>
-            <if test="email != null" >
-                email,
-            </if>
-            <if test="name != null" >
-                name,
-            </if>
-            <if test="password != null" >
-                password,
-            </if>
-            <if test="create_time != null" >
-                create_time,
-            </if>
-            <if test="last_login_time != null" >
-                last_login_time,
-            </if>
-            <if test="last_login_ip != null" >
-                last_login_ip,
-            </if>
-            <if test="role != null" >
-                role,
-            </if>
-            <if test="status != null" >
-                status,
-            </if>
-            <if test="org != null" >
-                org,
-            </if>
-            <if test="last_login_location != null" >
-                last_login_location,
-            </if>
-            <if test="remark != null" >
-                remark,
-            </if>
-            <if test="phone != null" >
-                phone,
-            </if>
-            <if test="province != null" >
-                province,
-            </if>
-            <if test="city != null" >
-                city,
-            </if>
-
-            <if test="district != null" >
-                district,
-            </if>
-            <if test="enabled != null" >
-                enabled,
-            </if>
-            <if test="update_time != null" >
-                update_time
-            </if>
-        </trim>
-        <trim prefix="values (" suffix=")" suffixOverrides="," >
-            <if test="username != null" >
-                #{username,jdbcType=VARCHAR},
-            </if>
-            <if test="email != null" >
-                #{email,jdbcType=VARCHAR},
-            </if>
-            <if test="name != null" >
-                #{name,jdbcType=VARCHAR},
-            </if>
-            <if test="password != null" >
-                #{password,jdbcType=VARCHAR},
-            </if>
-            <if test="create_time != null" >
-                #{create_time,jdbcType=VARCHAR},
-            </if>
-            <if test="last_login_time != null" >
-                #{last_login_time,jdbcType=DATETIME},
-            </if>
-            <if test="last_login_ip != null" >
-                #{last_login_ip,jdbcType=VARCHAR},
-            </if>
-            <if test="role != null" >
-                #{role,jdbcType=INTEGER},
-            </if>
-            <if test="status != null" >
-                #{status,jdbcType=INTEGER},
-            </if>
-            <if test="org != null" >
-                #{org,jdbcType=INTEGER},
-            </if>
-            <if test="last_login_location != null" >
-                #{last_login_location,jdbcType=VARCHAR},
-            </if>
-            <if test="remark != null" >
-                #{remark,jdbcType=VARCHAR},
-            </if>
-            <if test="phone != null" >
-                #{phone,jdbcType=VARCHAR},
-            </if>
-            <if test="province != null" >
-                #{province,jdbcType=VARCHAR},
-            </if>
-            <if test="city != null" >
-                #{city,jdbcType=VARCHAR},
-            </if>
-            <if test="district != null" >
-                #{district,jdbcType=VARCHAR},
-            </if>
-            <if test="enabled != null" >
-                #{enabled,jdbcType=INTEGER},
-            </if>
-            <if test="update_time != null" >
-                #{update_time,jdbcType=DATE}
-            </if>
-        </trim>
-    </insert>
-
-    <!-- 根据id更新一条用户信息 -->
-    <update id="updateByPrimaryKeySelective" parameterType="com.ygj.yuemum.domain.admin.JlAdminUser" >
-        update jl_admin_user
-        <set >
-            <if test="username != null" >
-                username = #{username,jdbcType=VARCHAR},
-            </if>
-            <if test="name != null" >
-                name = #{name,jdbcType=VARCHAR},
-            </if>
-            <if test="email != null" >
-                email = #{email,jdbcType=VARCHAR},
-            </if>
-            <if test="password != null" >
-                password = #{password,jdbcType=VARCHAR},
-            </if>
-            <if test="create_time != null" >
-                create_time = #{create_time,jdbcType=DATE},
-            </if>
-            <if test="last_login_time != null" >
-                password = #{last_login_time,jdbcType=DATE},
-            </if>
-            <if test="last_login_ip != null" >
-                last_login_ip = #{last_login_ip,jdbcType=VARCHAR},
-            </if>
-            <if test="role != null" >
-                role = #{role,jdbcType=INTEGER},
-            </if>
-            <if test="status != null" >
-                status = #{status,jdbcType=INTEGER},
-            </if>
-            <if test="org != null" >
-                org = #{org,jdbcType=INTEGER},
-            </if>
-            <if test="last_login_location != null" >
-                last_login_location = #{last_login_location,jdbcType=VARCHAR},
-            </if>
-            <if test="remark != null" >
-                remark = #{remark,jdbcType=VARCHAR},
-            </if>
-            <if test="phone != null" >
-                phone = #{phone,jdbcType=VARCHAR},
-            </if>
-            <if test="province != null" >
-                province = #{province,jdbcType=VARCHAR},
-            </if>
-            <if test="city != null" >
-                city = #{city,jdbcType=VARCHAR},
-            </if>
-            <if test="district != null" >
-                district = #{district,jdbcType=VARCHAR},
-            </if>
-            <if test="enabled != null" >
-                enabled = #{enabled,jdbcType=INTEGER},
-            </if>
-            <if test="update_time != null" >
-                update_time = #{update_time,jdbcType=DATE}
-            </if>
-        </set>
-        where id = #{id,jdbcType=INTEGER}
-    </update>
-
+<?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.ygj.yuemum.dao.admin.JlAdminUserDao">
+
+    <resultMap id="BaseResultMap" type="com.ygj.yuemum.domain.admin.JlAdminUser">
+        <id column="id" property="id" jdbcType="INTEGER"/>
+        <result column="username" property="username" jdbcType="VARCHAR"/>
+        <result column="email" property="email" jdbcType="VARCHAR"/>
+        <result column="name" property="name" jdbcType="VARCHAR"/>
+        <result column="password" property="password" jdbcType="VARCHAR"/>
+        <result column="create_time" property="create_time" jdbcType="VARCHAR"/>
+        <result column="last_login_time" property="last_login_time" jdbcType="DATE"/>
+        <result column="last_login_ip" property="last_login_ip" jdbcType="VARCHAR"/>
+        <result column="role" property="role" jdbcType="INTEGER"/>
+        <result column="status" property="status" jdbcType="INTEGER"/>
+        <result column="org" property="org" jdbcType="INTEGER"/>
+        <result column="last_login_location" property="last_login_location" jdbcType="VARCHAR"/>
+        <result column="remark" property="remark" jdbcType="VARCHAR"/>
+        <result column="phone" property="phone" jdbcType="VARCHAR"/>
+        <result column="province" property="province" jdbcType="VARCHAR"/>
+        <result column="city" property="city" jdbcType="VARCHAR"/>
+        <result column="district" property="district" jdbcType="VARCHAR"/>
+        <result column="province" property="province" jdbcType="VARCHAR"/>
+        <result column="enabled" property="enabled" jdbcType="INTEGER"/>
+        <result column="update_time" property="update_time" jdbcType="DATE"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id,username,name,email,password,create_time,last_login_time,last_login_ip,role,status,org,last_login_location,remark,phone,province,city,district,enabled,update_time
+    </sql>
+
+    <select id="checkUsername" resultType="java.lang.Integer" parameterType="java.lang.String">
+        select
+        count(1)
+        from jl_admin_user
+        where username =  #{username,jdbcType=VARCHAR}
+    </select>
+    <select id="getConsultants" resultMap="BaseResultMap">
+        select
+        *
+        from jl_admin_user
+        where role =  3
+    </select>
+    <select id="getRolePermissionCount" resultType="java.lang.Integer" parameterType="java.lang.Integer">
+        select
+        count(1)
+        from jl_admin_user
+        where role =  #{roleid,jdbcType=VARCHAR}
+    </select>
+    <!-- 得到所有的用户信息 -->
+    <select id="getAll" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List"/>
+        from jl_admin_user
+    </select>
+    <select id="queryAdminUsers" resultMap="BaseResultMap" parameterType="com.ygj.yuemum.domain.admin.JlAdminUser">
+        select
+        id,
+        username,
+        name,
+        role,
+        status,
+        phone,
+        city,
+        IFNULL(fgetbranches_name(city),'ALL') cityname,
+        fgetrole_name(role) rolename
+        from jl_admin_user
+        where username != 'admin'
+        <if test="username != null and username !=''">
+            and username like "%"#{username,jdbcType=VARCHAR}"%"
+        </if>
+        <if test="phone != null and phone !=''">
+            and phone like "%"#{phone,jdbcType=VARCHAR}"%"
+        </if>
+        <if test="name != null and name !=''">
+            and name like "%"#{name,jdbcType=VARCHAR}"%"
+        </if>
+        <if test="role != null and role !=''">
+            and role = #{role,jdbcType=INTEGER}
+        </if>
+        <if test="status != null ">
+            and status = #{status,jdbcType=INTEGER}
+        </if>
+        <if test="city != null and city !=''">
+            and city = #{city,jdbcType=VARCHAR}
+        </if>
+    </select>
+
+    <select id="logIN" resultType="java.lang.Integer" parameterType="com.ygj.yuemum.domain.admin.JlAdminUser">
+        select
+        count(1)
+        from jl_admin_user
+        where 1=1
+        <if test="username != null">
+            and username = #{username,jdbcType=VARCHAR}
+        </if>
+        <if test="password != null">
+            and password = #{password,jdbcType=VARCHAR}
+        </if>
+    </select>
+
+    <select id="getPassword" resultType="java.lang.String" parameterType="java.lang.String">
+        select
+        password
+        from jl_admin_user
+        where
+        username =  #{username,jdbcType=VARCHAR}
+    </select>
+
+    <select id="getStatus" resultType="java.lang.String" parameterType="java.lang.String">
+        select
+        status
+        from jl_admin_user
+        where
+        username =  #{username,jdbcType=VARCHAR}
+    </select>
+
+    <select id="getRole" resultType="java.lang.String" parameterType="java.lang.String">
+        select
+        role
+        from jl_admin_user
+        where
+        username =  #{username,jdbcType=VARCHAR}
+    </select>
+
+    <select id="getUserMkt" resultMap="BaseResultMap" parameterType="java.lang.String">
+        select
+        id,
+        username,
+        email,
+        name,
+        password,
+        create_time,
+        last_login_time,
+        last_login_ip,
+        role,
+        fgetisvisit(role) isvisit,
+        status,
+        org,
+        last_login_location,
+        remark,
+        phone,
+        province,
+        city,
+        district,
+        enabled,
+        update_time
+        from jl_admin_user
+        where
+        username =  #{username,jdbcType=VARCHAR}
+    </select>
+
+    <select id="getUserByEmail" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List"/>
+        from jl_admin_user
+        where
+        username = #{userEmail}
+    </select>
+    <!-- 根据id查找某个用户信息 -->
+    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
+        select
+        *
+        from jl_admin_user
+        where id = #{id,jdbcType=INTEGER}
+    </select>
+
+    <!-- 根据id删除某个用户信息 -->
+    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+            delete from jl_admin_user
+            where id = #{id,jdbcType=INTEGER}
+        </delete>
+
+    <!-- 插入一条用户信息 -->
+    <insert id="insertSelective" parameterType="com.ygj.yuemum.domain.admin.JlAdminUser">
+        insert into jl_admin_user
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="username != null">
+                username,
+            </if>
+            <if test="email != null">
+                email,
+            </if>
+            <if test="name != null">
+                name,
+            </if>
+            <if test="password != null">
+                password,
+            </if>
+            <if test="create_time != null">
+                create_time,
+            </if>
+            <if test="last_login_time != null">
+                last_login_time,
+            </if>
+            <if test="last_login_ip != null">
+                last_login_ip,
+            </if>
+            <if test="role != null">
+                role,
+            </if>
+            <if test="status != null">
+                status,
+            </if>
+            <if test="org != null">
+                org,
+            </if>
+            <if test="last_login_location != null">
+                last_login_location,
+            </if>
+            <if test="remark != null">
+                remark,
+            </if>
+            <if test="phone != null">
+                phone,
+            </if>
+            <if test="province != null">
+                province,
+            </if>
+            <if test="city != null">
+                city,
+            </if>
+
+            <if test="district != null">
+                district,
+            </if>
+            <if test="enabled != null">
+                enabled,
+            </if>
+            <if test="update_time != null">
+                update_time
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="username != null">
+                #{username,jdbcType=VARCHAR},
+            </if>
+            <if test="email != null">
+                #{email,jdbcType=VARCHAR},
+            </if>
+            <if test="name != null">
+                #{name,jdbcType=VARCHAR},
+            </if>
+            <if test="password != null">
+                #{password,jdbcType=VARCHAR},
+            </if>
+            <if test="create_time != null">
+                #{create_time,jdbcType=VARCHAR},
+            </if>
+            <if test="last_login_time != null">
+                #{last_login_time,jdbcType=DATETIME},
+            </if>
+            <if test="last_login_ip != null">
+                #{last_login_ip,jdbcType=VARCHAR},
+            </if>
+            <if test="role != null">
+                #{role,jdbcType=INTEGER},
+            </if>
+            <if test="status != null">
+                #{status,jdbcType=INTEGER},
+            </if>
+            <if test="org != null">
+                #{org,jdbcType=INTEGER},
+            </if>
+            <if test="last_login_location != null">
+                #{last_login_location,jdbcType=VARCHAR},
+            </if>
+            <if test="remark != null">
+                #{remark,jdbcType=VARCHAR},
+            </if>
+            <if test="phone != null">
+                #{phone,jdbcType=VARCHAR},
+            </if>
+            <if test="province != null">
+                #{province,jdbcType=VARCHAR},
+            </if>
+            <if test="city != null">
+                #{city,jdbcType=VARCHAR},
+            </if>
+            <if test="district != null">
+                #{district,jdbcType=VARCHAR},
+            </if>
+            <if test="enabled != null">
+                #{enabled,jdbcType=INTEGER},
+            </if>
+            <if test="update_time != null">
+                #{update_time,jdbcType=DATE}
+            </if>
+        </trim>
+    </insert>
+
+    <!-- 根据id更新一条用户信息 -->
+    <update id="updateByPrimaryKeySelective" parameterType="com.ygj.yuemum.domain.admin.JlAdminUser">
+        update jl_admin_user
+        <set>
+            <if test="username != null">
+                username = #{username,jdbcType=VARCHAR},
+            </if>
+            <if test="name != null">
+                name = #{name,jdbcType=VARCHAR},
+            </if>
+            <if test="email != null">
+                email = #{email,jdbcType=VARCHAR},
+            </if>
+            <if test="password != null">
+                password = #{password,jdbcType=VARCHAR},
+            </if>
+            <if test="create_time != null">
+                create_time = #{create_time,jdbcType=DATE},
+            </if>
+            <if test="last_login_time != null">
+                password = #{last_login_time,jdbcType=DATE},
+            </if>
+            <if test="last_login_ip != null">
+                last_login_ip = #{last_login_ip,jdbcType=VARCHAR},
+            </if>
+            <if test="role != null">
+                role = #{role,jdbcType=INTEGER},
+            </if>
+            <if test="status != null">
+                status = #{status,jdbcType=INTEGER},
+            </if>
+            <if test="org != null">
+                org = #{org,jdbcType=INTEGER},
+            </if>
+            <if test="last_login_location != null">
+                last_login_location = #{last_login_location,jdbcType=VARCHAR},
+            </if>
+            <if test="remark != null">
+                remark = #{remark,jdbcType=VARCHAR},
+            </if>
+            <if test="phone != null">
+                phone = #{phone,jdbcType=VARCHAR},
+            </if>
+            <if test="province != null">
+                province = #{province,jdbcType=VARCHAR},
+            </if>
+            <if test="city != null">
+                city = #{city,jdbcType=VARCHAR},
+            </if>
+            <if test="district != null">
+                district = #{district,jdbcType=VARCHAR},
+            </if>
+            <if test="enabled != null">
+                enabled = #{enabled,jdbcType=INTEGER},
+            </if>
+            <if test="update_time != null">
+                update_time = #{update_time,jdbcType=DATE}
+            </if>
+        </set>
+        where id = #{id,jdbcType=INTEGER}
+    </update>
+
 </mapper>