From 148702f73678d40e890ec4d1631e27f701aecbdb Mon Sep 17 00:00:00 2001 From: tamguo Date: Wed, 8 Aug 2018 17:35:10 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- {tamguo-mobile => tamguo-mms}/.classpath | 0 {tamguo-mobile => tamguo-mms}/.gitignore | 0 {tamguo-mobile => tamguo-mms}/.project | 2 +- .../org.eclipse.core.resources.prefs | 0 .../.settings/org.eclipse.jdt.core.prefs | 0 .../.settings/org.eclipse.m2e.core.prefs | 0 {tamguo-mobile => tamguo-mms}/pom.xml | 53 +- .../src/main/java/com/tamguo/Application.java | 12 +- .../config/dao/MyMetaObjectHandler.java | 8 +- .../tamguo/config/dao/MybatisPlusConfig.java | 6 +- .../com/tamguo/config/shiro/MemberRealm.java | 72 +++ .../config/shiro/ShiroConfiguration.java | 69 +++ .../tamguo/config/web/ErrorConfigurar.java | 21 + .../tamguo/config/web/ThymeleafConfig.java | 37 ++ .../java/com/tamguo/config/web/WebConfig.java | 18 + .../main/java/com/tamguo/utils/PageUtils.java | 151 ++++++ .../java/com/tamguo/utils/ShiroUtils.java | 49 ++ .../com/tamguo/web/ChapterController.java | 37 ++ .../java/com/tamguo/web/CourseController.java | 53 ++ .../java/com/tamguo/web/IndexController.java | 25 + .../com/tamguo/web/SubjectController.java | 32 ++ .../src/main/resources/application.properties | 10 +- .../src/main/resources/ehcache-shiro.xml | 0 .../main/resources/mappers/CourseMapper.xml | 0 .../src/main/resources/mappers/MenuMapper.xml | 0 .../main/resources/mappers/QuestionMapper.xml | 0 .../src/main/resources/redis.xml | 0 .../main/resources/static/js/chapter/main.js | 19 + .../main/resources/static/js/index/main.js | 19 + .../main/resources/static/js/question/main.js | 19 + .../src/main/resources/templates/course.html | 73 +++ .../src/main/resources/templates/index.html | 18 +- .../main/resources/templates/question.html | 28 +- .../src/main/resources/templates/subject.html | 60 +++ .../java/com/tamguo/config/WebConfig.java | 51 -- .../com/tamguo/config/dao/SuperEntity.java | 29 -- .../com/tamguo/config/dao/SuperMapper.java | 11 - .../tamguo/config/redis/SessionConfig.java | 27 - .../config/redis/SessionInitializer.java | 10 - .../java/com/tamguo/dao/CourseMapper.java | 17 - .../main/java/com/tamguo/dao/MenuMapper.java | 14 - .../java/com/tamguo/dao/QuestionMapper.java | 14 - .../com/tamguo/dao/redis/CacheService.java | 491 ------------------ .../com/tamguo/dao/redis/PoolConfigBean.java | 47 -- .../tamguo/dao/redis/RedisServerNodeBean.java | 53 -- .../tamguo/dao/redis/RedisXMLConfigure.java | 175 ------- .../tamguo/interceptor/SettingInterptor.java | 39 -- .../java/com/tamguo/model/ChapterEntity.java | 103 ---- .../java/com/tamguo/model/CourseEntity.java | 128 ----- .../java/com/tamguo/model/MenuEntity.java | 104 ---- .../java/com/tamguo/model/QuestionEntity.java | 172 ------ .../java/com/tamguo/model/SubjectEntity.java | 55 -- .../com/tamguo/service/ICourseService.java | 11 - .../java/com/tamguo/service/IMenuService.java | 17 - .../com/tamguo/service/IQuestionService.java | 9 - .../com/tamguo/service/ISubjectService.java | 10 - .../tamguo/service/impl/CourseService.java | 67 --- .../com/tamguo/service/impl/MenuService.java | 38 -- .../tamguo/service/impl/QuestionService.java | 22 - .../tamguo/service/impl/SubjectService.java | 23 - .../util/AbstractRunningLogHandler.java | 114 ---- .../main/java/com/tamguo/util/CException.java | 23 - .../com/tamguo/util/ExceptionSupport.java | 32 -- .../java/com/tamguo/util/Log4jHandler.java | 30 -- .../main/java/com/tamguo/util/LogDebug.java | 17 - .../main/java/com/tamguo/util/LogHandler.java | 21 - .../main/java/com/tamguo/util/ObjectUtil.java | 69 --- .../src/main/java/com/tamguo/util/Result.java | 105 ---- .../com/tamguo/util/SerializeTranscoder.java | 20 - .../main/java/com/tamguo/util/Setting.java | 30 -- .../com/tamguo/util/XMLConfiguration.java | 53 -- .../com/tamguo/web/ChapterController.java | 58 --- .../java/com/tamguo/web/IndexController.java | 14 - .../java/com/tamguo/web/MenuController.java | 36 -- .../com/tamguo/web/QuestionController.java | 41 -- .../main/resources/static/js/chapter/main.js | 53 -- .../main/resources/static/js/index/main.js | 17 - .../main/resources/static/js/question/main.js | 54 -- .../src/main/resources/templates/chapter.html | 111 ---- 79 files changed, 819 insertions(+), 2707 deletions(-) rename {tamguo-mobile => tamguo-mms}/.classpath (100%) rename {tamguo-mobile => tamguo-mms}/.gitignore (100%) rename {tamguo-mobile => tamguo-mms}/.project (90%) rename {tamguo-mobile => tamguo-mms}/.settings/org.eclipse.core.resources.prefs (100%) rename {tamguo-mobile => tamguo-mms}/.settings/org.eclipse.jdt.core.prefs (100%) rename {tamguo-mobile => tamguo-mms}/.settings/org.eclipse.m2e.core.prefs (100%) rename {tamguo-mobile => tamguo-mms}/pom.xml (82%) rename tamguo-mobile/src/main/java/com/tamguo/TamguoMobileApplication.java => tamguo-mms/src/main/java/com/tamguo/Application.java (75%) rename {tamguo-mobile => tamguo-mms}/src/main/java/com/tamguo/config/dao/MyMetaObjectHandler.java (71%) rename {tamguo-mobile => tamguo-mms}/src/main/java/com/tamguo/config/dao/MybatisPlusConfig.java (96%) create mode 100644 tamguo-mms/src/main/java/com/tamguo/config/shiro/MemberRealm.java create mode 100644 tamguo-mms/src/main/java/com/tamguo/config/shiro/ShiroConfiguration.java create mode 100644 tamguo-mms/src/main/java/com/tamguo/config/web/ErrorConfigurar.java create mode 100644 tamguo-mms/src/main/java/com/tamguo/config/web/ThymeleafConfig.java create mode 100644 tamguo-mms/src/main/java/com/tamguo/config/web/WebConfig.java create mode 100644 tamguo-mms/src/main/java/com/tamguo/utils/PageUtils.java create mode 100644 tamguo-mms/src/main/java/com/tamguo/utils/ShiroUtils.java create mode 100644 tamguo-mms/src/main/java/com/tamguo/web/ChapterController.java create mode 100644 tamguo-mms/src/main/java/com/tamguo/web/CourseController.java create mode 100644 tamguo-mms/src/main/java/com/tamguo/web/IndexController.java create mode 100644 tamguo-mms/src/main/java/com/tamguo/web/SubjectController.java rename {tamguo-mobile => tamguo-mms}/src/main/resources/application.properties (86%) rename {tamguo-mobile => tamguo-mms}/src/main/resources/ehcache-shiro.xml (100%) rename {tamguo-mobile => tamguo-mms}/src/main/resources/mappers/CourseMapper.xml (100%) rename {tamguo-mobile => tamguo-mms}/src/main/resources/mappers/MenuMapper.xml (100%) rename {tamguo-mobile => tamguo-mms}/src/main/resources/mappers/QuestionMapper.xml (100%) rename {tamguo-mobile => tamguo-mms}/src/main/resources/redis.xml (100%) create mode 100644 tamguo-mms/src/main/resources/static/js/chapter/main.js create mode 100644 tamguo-mms/src/main/resources/static/js/index/main.js create mode 100644 tamguo-mms/src/main/resources/static/js/question/main.js create mode 100644 tamguo-mms/src/main/resources/templates/course.html rename {tamguo-mobile => tamguo-mms}/src/main/resources/templates/index.html (56%) rename {tamguo-mobile => tamguo-mms}/src/main/resources/templates/question.html (62%) create mode 100644 tamguo-mms/src/main/resources/templates/subject.html delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/config/WebConfig.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/config/dao/SuperEntity.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/config/dao/SuperMapper.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/config/redis/SessionConfig.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/config/redis/SessionInitializer.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/dao/CourseMapper.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/dao/MenuMapper.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/dao/QuestionMapper.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/dao/redis/CacheService.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/dao/redis/PoolConfigBean.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/dao/redis/RedisServerNodeBean.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/dao/redis/RedisXMLConfigure.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/interceptor/SettingInterptor.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/model/ChapterEntity.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/model/CourseEntity.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/model/MenuEntity.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/model/QuestionEntity.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/model/SubjectEntity.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/service/ICourseService.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/service/IMenuService.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/service/IQuestionService.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/service/ISubjectService.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/service/impl/CourseService.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/service/impl/MenuService.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/service/impl/QuestionService.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/service/impl/SubjectService.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/util/AbstractRunningLogHandler.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/util/CException.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/util/ExceptionSupport.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/util/Log4jHandler.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/util/LogDebug.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/util/LogHandler.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/util/ObjectUtil.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/util/Result.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/util/SerializeTranscoder.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/util/Setting.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/util/XMLConfiguration.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/web/ChapterController.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/web/IndexController.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/web/MenuController.java delete mode 100644 tamguo-mobile/src/main/java/com/tamguo/web/QuestionController.java delete mode 100644 tamguo-mobile/src/main/resources/static/js/chapter/main.js delete mode 100644 tamguo-mobile/src/main/resources/static/js/index/main.js delete mode 100644 tamguo-mobile/src/main/resources/static/js/question/main.js delete mode 100644 tamguo-mobile/src/main/resources/templates/chapter.html diff --git a/tamguo-mobile/.classpath b/tamguo-mms/.classpath similarity index 100% rename from tamguo-mobile/.classpath rename to tamguo-mms/.classpath diff --git a/tamguo-mobile/.gitignore b/tamguo-mms/.gitignore similarity index 100% rename from tamguo-mobile/.gitignore rename to tamguo-mms/.gitignore diff --git a/tamguo-mobile/.project b/tamguo-mms/.project similarity index 90% rename from tamguo-mobile/.project rename to tamguo-mms/.project index 1146f3d..9b11dce 100644 --- a/tamguo-mobile/.project +++ b/tamguo-mms/.project @@ -1,6 +1,6 @@ - tamguo-mobile + tamguo-mms diff --git a/tamguo-mobile/.settings/org.eclipse.core.resources.prefs b/tamguo-mms/.settings/org.eclipse.core.resources.prefs similarity index 100% rename from tamguo-mobile/.settings/org.eclipse.core.resources.prefs rename to tamguo-mms/.settings/org.eclipse.core.resources.prefs diff --git a/tamguo-mobile/.settings/org.eclipse.jdt.core.prefs b/tamguo-mms/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from tamguo-mobile/.settings/org.eclipse.jdt.core.prefs rename to tamguo-mms/.settings/org.eclipse.jdt.core.prefs diff --git a/tamguo-mobile/.settings/org.eclipse.m2e.core.prefs b/tamguo-mms/.settings/org.eclipse.m2e.core.prefs similarity index 100% rename from tamguo-mobile/.settings/org.eclipse.m2e.core.prefs rename to tamguo-mms/.settings/org.eclipse.m2e.core.prefs diff --git a/tamguo-mobile/pom.xml b/tamguo-mms/pom.xml similarity index 82% rename from tamguo-mobile/pom.xml rename to tamguo-mms/pom.xml index c8a592d..e3096be 100644 --- a/tamguo-mobile/pom.xml +++ b/tamguo-mms/pom.xml @@ -1,14 +1,13 @@ - - 4.0.0 - com.tamguo - tamguo-mobile - 0.0.1-SNAPSHOT - + + 4.0.0 + com.tamguo + tamguo-mms + 1.0.0 + + org.springframework.boot spring-boot-starter-parent - 1.5.3.RELEASE + 2.0.3.RELEASE @@ -62,6 +61,11 @@ org.springframework.session spring-session-data-redis + + com.github.theborakompanioni + thymeleaf-extras-shiro + 1.2.1 + com.alibaba fastjson @@ -77,11 +81,6 @@ shiro-ehcache 1.2.5 - - com.github.theborakompanioni - thymeleaf-extras-shiro - 1.2.1 - cn.songxinqiang com.baidu.ueditor @@ -100,17 +99,6 @@ commons-io commons-io - - com.github.penggle - kaptcha - 2.3.2 - - - javax.servlet-api - javax.servlet - - - com.alibaba druid @@ -123,7 +111,6 @@ org.apache.commons commons-lang3 - 3.6 com.aliyun @@ -140,6 +127,18 @@ commons-email 1.5 + + + com.bladejava + blade-patchca + 1.0.5 + + + + com.tamguo + tamguo-modules-core + 1.0.0 + @@ -155,7 +154,7 @@ - tamguo-mobile + mms org.springframework.boot diff --git a/tamguo-mobile/src/main/java/com/tamguo/TamguoMobileApplication.java b/tamguo-mms/src/main/java/com/tamguo/Application.java similarity index 75% rename from tamguo-mobile/src/main/java/com/tamguo/TamguoMobileApplication.java rename to tamguo-mms/src/main/java/com/tamguo/Application.java index 6f575e6..d1d90b8 100644 --- a/tamguo-mobile/src/main/java/com/tamguo/TamguoMobileApplication.java +++ b/tamguo-mms/src/main/java/com/tamguo/Application.java @@ -1,11 +1,10 @@ package com.tamguo; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.web.HttpMessageConverters; +import org.springframework.boot.autoconfigure.http.HttpMessageConverters; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; -import org.springframework.http.converter.HttpMessageConverter; import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson.support.config.FastJsonConfig; @@ -13,12 +12,12 @@ import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; @SpringBootApplication @ComponentScan("com.tamguo") -public class TamguoMobileApplication { +public class Application { public static void main(String[] args) { - new SpringApplicationBuilder(TamguoMobileApplication.class).web(true).run(args); + new SpringApplicationBuilder(Application.class).run(args); } - + /** * FastJson替代Jackson * @return @@ -30,7 +29,8 @@ public class TamguoMobileApplication { fastJsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss"); fastJsonConfig.setSerializerFeatures(SerializerFeature.DisableCircularReferenceDetect); fastConverter.setFastJsonConfig(fastJsonConfig); - HttpMessageConverter converter = fastConverter; + FastJsonHttpMessageConverter converter = fastConverter; return new HttpMessageConverters(converter); } + } diff --git a/tamguo-mobile/src/main/java/com/tamguo/config/dao/MyMetaObjectHandler.java b/tamguo-mms/src/main/java/com/tamguo/config/dao/MyMetaObjectHandler.java similarity index 71% rename from tamguo-mobile/src/main/java/com/tamguo/config/dao/MyMetaObjectHandler.java rename to tamguo-mms/src/main/java/com/tamguo/config/dao/MyMetaObjectHandler.java index f846390..9b0c21d 100644 --- a/tamguo-mobile/src/main/java/com/tamguo/config/dao/MyMetaObjectHandler.java +++ b/tamguo-mms/src/main/java/com/tamguo/config/dao/MyMetaObjectHandler.java @@ -1,8 +1,6 @@ package com.tamguo.config.dao; import com.baomidou.mybatisplus.mapper.MetaObjectHandler; -import com.tamguo.TamguoMobileApplication; - import org.apache.ibatis.reflection.MetaObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -13,15 +11,13 @@ import org.slf4j.LoggerFactory; //@Component public class MyMetaObjectHandler extends MetaObjectHandler { - protected final static Logger logger = LoggerFactory.getLogger(TamguoMobileApplication.class); - + protected final static Logger logger = LoggerFactory.getLogger(MyMetaObjectHandler.class); + @Override public void insertFill(MetaObject metaObject) { - logger.info("新增的时候干点不可描述的事情"); } @Override public void updateFill(MetaObject metaObject) { - logger.info("更新的时候干点不可描述的事情"); } } diff --git a/tamguo-mobile/src/main/java/com/tamguo/config/dao/MybatisPlusConfig.java b/tamguo-mms/src/main/java/com/tamguo/config/dao/MybatisPlusConfig.java similarity index 96% rename from tamguo-mobile/src/main/java/com/tamguo/config/dao/MybatisPlusConfig.java rename to tamguo-mms/src/main/java/com/tamguo/config/dao/MybatisPlusConfig.java index dbf23e7..47d0386 100644 --- a/tamguo-mobile/src/main/java/com/tamguo/config/dao/MybatisPlusConfig.java +++ b/tamguo-mms/src/main/java/com/tamguo/config/dao/MybatisPlusConfig.java @@ -20,7 +20,7 @@ import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.LongValue; @Configuration -@MapperScan("com.tamguo.dao*") +@MapperScan("com.tamguo.modules.*.dao*") public class MybatisPlusConfig { @Bean @@ -45,12 +45,12 @@ public class MybatisPlusConfig { tenantSqlParser.setTenantHandler(new TenantHandler() { @Override public Expression getTenantId() { - return new LongValue(""); + return new LongValue(1L); } @Override public String getTenantIdColumn() { - return "company_id"; + return "course_id"; } @Override diff --git a/tamguo-mms/src/main/java/com/tamguo/config/shiro/MemberRealm.java b/tamguo-mms/src/main/java/com/tamguo/config/shiro/MemberRealm.java new file mode 100644 index 0000000..6a55f8d --- /dev/null +++ b/tamguo-mms/src/main/java/com/tamguo/config/shiro/MemberRealm.java @@ -0,0 +1,72 @@ +package com.tamguo.config.shiro; + +import java.util.Set; +import org.apache.shiro.authc.AuthenticationException; +import org.apache.shiro.authc.AuthenticationInfo; +import org.apache.shiro.authc.AuthenticationToken; +import org.apache.shiro.authc.IncorrectCredentialsException; +import org.apache.shiro.authc.LockedAccountException; +import org.apache.shiro.authc.SimpleAuthenticationInfo; +import org.apache.shiro.authc.UnknownAccountException; +import org.apache.shiro.authz.AuthorizationInfo; +import org.apache.shiro.authz.SimpleAuthorizationInfo; +import org.apache.shiro.crypto.hash.Sha256Hash; +import org.apache.shiro.realm.AuthorizingRealm; +import org.apache.shiro.subject.PrincipalCollection; +import org.springframework.beans.factory.annotation.Autowired; + +import com.tamguo.modules.member.model.MemberEntity; +import com.tamguo.modules.member.service.IMemberService; + +/** + * 认证 + * + */ +public class MemberRealm extends AuthorizingRealm { + + @Autowired + private IMemberService iMemberService; + + /** + * 授权(验证权限时调用) + */ + @Override + protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { + Set permsSet = null; + SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); + info.setStringPermissions(permsSet); + + return info; + } + + /** + * 认证(登录时调用) + */ + @Override + protected AuthenticationInfo doGetAuthenticationInfo( + AuthenticationToken token) throws AuthenticationException { + String username = (String) token.getPrincipal(); + String password = new String((char[]) token.getCredentials()); + + MemberEntity member = iMemberService.findByUsername(username); + if(member == null) { + throw new UnknownAccountException("用户名或密码有误,请重新输入或找回密码"); + } + Integer loginFailureCount = iMemberService.getLoginFailureCount(member); + if(loginFailureCount > 10) { + throw new LockedAccountException("账号被锁定"); + } + + if(!new Sha256Hash(password).toHex().equals(member.getPassword())){ + loginFailureCount++; + iMemberService.updateLoginFailureCount(member , loginFailureCount); + throw new IncorrectCredentialsException("用户名或密码有误,请重新输入或找回密码"); + } + // 更新登录时间 + iMemberService.updateLastLoginTime(member.getId()); + + SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(member, password, getName()); + return info; + } + +} diff --git a/tamguo-mms/src/main/java/com/tamguo/config/shiro/ShiroConfiguration.java b/tamguo-mms/src/main/java/com/tamguo/config/shiro/ShiroConfiguration.java new file mode 100644 index 0000000..96f9ab3 --- /dev/null +++ b/tamguo-mms/src/main/java/com/tamguo/config/shiro/ShiroConfiguration.java @@ -0,0 +1,69 @@ +package com.tamguo.config.shiro; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.apache.shiro.cache.ehcache.EhCacheManager; +import org.apache.shiro.spring.LifecycleBeanPostProcessor; +import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor; +import org.apache.shiro.spring.web.ShiroFilterFactoryBean; +import org.apache.shiro.web.mgt.DefaultWebSecurityManager; +import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class ShiroConfiguration { + private static Map filterChainDefinitionMap = new LinkedHashMap(); + + @Bean(name = "shiroRealm") + public MemberRealm getShiroRealm() { + return new MemberRealm(); + } + + @Bean(name = "shiroEhcacheManager") + public EhCacheManager getEhCacheManager() { + EhCacheManager em = new EhCacheManager(); + em.setCacheManagerConfigFile("classpath:ehcache-shiro.xml"); + return em; + } + + @Bean(name = "lifecycleBeanPostProcessor") + public LifecycleBeanPostProcessor getLifecycleBeanPostProcessor() { + return new LifecycleBeanPostProcessor(); + } + + @Bean + public DefaultAdvisorAutoProxyCreator getDefaultAdvisorAutoProxyCreator() { + DefaultAdvisorAutoProxyCreator daap = new DefaultAdvisorAutoProxyCreator(); + daap.setProxyTargetClass(true); + return daap; + } + + @Bean(name = "securityManager") + public DefaultWebSecurityManager getDefaultWebSecurityManager() { + DefaultWebSecurityManager dwsm = new DefaultWebSecurityManager(); + dwsm.setRealm(getShiroRealm()); + dwsm.setCacheManager(getEhCacheManager()); + return dwsm; + } + + @Bean + public AuthorizationAttributeSourceAdvisor getAuthorizationAttributeSourceAdvisor() { + AuthorizationAttributeSourceAdvisor aasa = new AuthorizationAttributeSourceAdvisor(); + aasa.setSecurityManager(getDefaultWebSecurityManager()); + return new AuthorizationAttributeSourceAdvisor(); + } + + @Bean(name = "shiroFilter") + public ShiroFilterFactoryBean getShiroFilterFactoryBean() { + ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean(); + shiroFilterFactoryBean.setSecurityManager(getDefaultWebSecurityManager()); + shiroFilterFactoryBean.setLoginUrl("/login"); + shiroFilterFactoryBean.setSuccessUrl("/index"); + filterChainDefinitionMap.put("/member/**", "authc"); + filterChainDefinitionMap.put("/**", "anon"); + shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap); + return shiroFilterFactoryBean; + } +} \ No newline at end of file diff --git a/tamguo-mms/src/main/java/com/tamguo/config/web/ErrorConfigurar.java b/tamguo-mms/src/main/java/com/tamguo/config/web/ErrorConfigurar.java new file mode 100644 index 0000000..9267271 --- /dev/null +++ b/tamguo-mms/src/main/java/com/tamguo/config/web/ErrorConfigurar.java @@ -0,0 +1,21 @@ +package com.tamguo.config.web; + +import org.springframework.boot.web.server.ErrorPage; +import org.springframework.boot.web.server.ErrorPageRegistrar; +import org.springframework.boot.web.server.ErrorPageRegistry; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Component; + +@Component +public class ErrorConfigurar implements ErrorPageRegistrar { + + @Override + public void registerErrorPages(ErrorPageRegistry registry) { + ErrorPage[] errorPages=new ErrorPage[2]; + errorPages[0]=new ErrorPage(HttpStatus.NOT_FOUND,"/error404"); + errorPages[1]=new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR,"/error500"); + + registry.addErrorPages(errorPages); + } + +} diff --git a/tamguo-mms/src/main/java/com/tamguo/config/web/ThymeleafConfig.java b/tamguo-mms/src/main/java/com/tamguo/config/web/ThymeleafConfig.java new file mode 100644 index 0000000..65fd509 --- /dev/null +++ b/tamguo-mms/src/main/java/com/tamguo/config/web/ThymeleafConfig.java @@ -0,0 +1,37 @@ +package com.tamguo.config.web; + +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Resource; + +import org.springframework.context.EnvironmentAware; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; +import org.thymeleaf.spring5.view.ThymeleafViewResolver; + +@Component +public class ThymeleafConfig implements EnvironmentAware{ + + @Resource + private Environment env; + + @Resource + private void configureThymeleafStaticVars(ThymeleafViewResolver viewResolver) { + if(viewResolver != null) { + Map vars = new HashMap<>(); + vars.put("domainName", env.getProperty("domain.name")); + vars.put("adminDomain", env.getProperty("admin.domain.name")); + vars.put("PAPER_TYPE_ZHENTI", "1"); + vars.put("PAPER_TYPE_MONI", "2"); + vars.put("PAPER_TYPE_YATI", "3"); + vars.put("PAPER_TYPE_MINGXIAO", "4"); + viewResolver.setStaticVariables(vars); + } + } + + @Override + public void setEnvironment(Environment environment) { + env = environment; + } + +} diff --git a/tamguo-mms/src/main/java/com/tamguo/config/web/WebConfig.java b/tamguo-mms/src/main/java/com/tamguo/config/web/WebConfig.java new file mode 100644 index 0000000..9c46b03 --- /dev/null +++ b/tamguo-mms/src/main/java/com/tamguo/config/web/WebConfig.java @@ -0,0 +1,18 @@ +package com.tamguo.config.web; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class WebConfig implements WebMvcConfigurer { + + @Value("${file.storage.path}") + private String fileStoragePath; + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/files/**").addResourceLocations("file:"+fileStoragePath); + } +} diff --git a/tamguo-mms/src/main/java/com/tamguo/utils/PageUtils.java b/tamguo-mms/src/main/java/com/tamguo/utils/PageUtils.java new file mode 100644 index 0000000..9b4bbf0 --- /dev/null +++ b/tamguo-mms/src/main/java/com/tamguo/utils/PageUtils.java @@ -0,0 +1,151 @@ +package com.tamguo.utils; + +import java.util.ArrayList; +import java.util.List; + +import com.baomidou.mybatisplus.plugins.Page; + +public class PageUtils { + + // 是否下一页按钮 + private Boolean isShowNextBtn = false; + + // 是否上一页按钮 + private Boolean isShowPreBtn = false; + + // 当前页 + private String currPageNum; + + // 页码列表 + private List pageNums; + + // 总页数 + private String totalPage; + + // 总数量 + private String total; + + // 数据 + private List list; + + public static PageUtils getPage(Page page){ + PageUtils pg = new PageUtils(); + if(page.getCurrent() > 1){ + pg.setIsShowPreBtn(true); + } + if(page.getCurrent() < page.getPages()){ + pg.setIsShowNextBtn(true); + } + List pgNums = new ArrayList<>(); + if(page.getPages() > 1){ + if(page.getPages() > 10){ + pgNums.add("1"); + pgNums.add("2"); + pgNums.add("3"); + pgNums.add("..."); + if(page.getCurrent() == page.getPages()){ + pgNums.add(((Integer)(page.getCurrent() - 2)).toString()); + pgNums.add(((Integer)(page.getCurrent() - 1)).toString()); + pgNums.add(((Integer)page.getCurrent()).toString()); + }else{ + pgNums.add(((Integer)(page.getCurrent() - 1)).toString()); + pgNums.add(((Integer)page.getCurrent()).toString()); + pgNums.add(((Integer)(page.getCurrent() + 1)).toString()); + } + }else{ + Integer n = 1; + if(page.getTotal() > 0){ + while(true){ + pgNums.add(n.toString()); + if(n >= page.getPages()){ + break; + } + n ++; + } + } + } + } else { + Integer n = 1; + if(page.getTotal() > 0){ + while(true){ + pgNums.add(n.toString()); + if(n >= page.getPages()){ + break; + } + n ++; + } + } + } + pg.setPageNums(pgNums); + pg.setList(page.getRecords()); + pg.setCurrPageNum(((Integer)page.getCurrent()).toString()); + pg.setTotal(((Integer)page.getTotal()).toString()); + pg.setTotalPage(((Integer)page.getPages()).toString()); + return pg; + } + + + public Boolean getIsShowNextBtn() { + return isShowNextBtn; + } + + public void setIsShowNextBtn(Boolean isShowNextBtn) { + this.isShowNextBtn = isShowNextBtn; + } + + public List getPageNums() { + return pageNums; + } + + public void setPageNums(List pageNums) { + this.pageNums = pageNums; + } + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + + public Boolean getIsShowPreBtn() { + return isShowPreBtn; + } + + + public void setIsShowPreBtn(Boolean isShowPreBtn) { + this.isShowPreBtn = isShowPreBtn; + } + + + public String getCurrPageNum() { + return currPageNum; + } + + + public void setCurrPageNum(String currPageNum) { + this.currPageNum = currPageNum; + } + + + public String getTotalPage() { + return totalPage; + } + + + public void setTotalPage(String totalPage) { + this.totalPage = totalPage; + } + + + public String getTotal() { + return total; + } + + + public void setTotal(String total) { + this.total = total; + } +} \ No newline at end of file diff --git a/tamguo-mms/src/main/java/com/tamguo/utils/ShiroUtils.java b/tamguo-mms/src/main/java/com/tamguo/utils/ShiroUtils.java new file mode 100644 index 0000000..e450f99 --- /dev/null +++ b/tamguo-mms/src/main/java/com/tamguo/utils/ShiroUtils.java @@ -0,0 +1,49 @@ +package com.tamguo.utils; + +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.session.Session; +import org.apache.shiro.subject.Subject; + +import com.tamguo.modules.member.model.MemberEntity; + +public class ShiroUtils { + + public static Session getSession() { + return SecurityUtils.getSubject().getSession(); + } + + public static Subject getSubject() { + return SecurityUtils.getSubject(); + } + + public static MemberEntity getMember() { + return (MemberEntity)SecurityUtils.getSubject().getPrincipal(); + } + + public static String getMemberId() { + return getMember().getId(); + } + + public static void setSessionAttribute(Object key, Object value) { + getSession().setAttribute(key, value); + } + + public static Object getSessionAttribute(Object key) { + return getSession().getAttribute(key); + } + + public static boolean isLogin() { + return SecurityUtils.getSubject().getPrincipal() != null; + } + + public static void logout() { + SecurityUtils.getSubject().logout(); + } + + public static String getKaptcha(String key) { + String kaptcha = getSessionAttribute(key).toString(); +// getSession().removeAttribute(key); + return kaptcha; + } + +} diff --git a/tamguo-mms/src/main/java/com/tamguo/web/ChapterController.java b/tamguo-mms/src/main/java/com/tamguo/web/ChapterController.java new file mode 100644 index 0000000..99b9d89 --- /dev/null +++ b/tamguo-mms/src/main/java/com/tamguo/web/ChapterController.java @@ -0,0 +1,37 @@ +package com.tamguo.web; + +import java.util.Arrays; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.ModelAndView;import com.baomidou.mybatisplus.mapper.Condition; +import com.baomidou.mybatisplus.plugins.Page; +import com.tamguo.modules.tiku.model.ChapterEntity; +import com.tamguo.modules.tiku.model.QuestionEntity; +import com.tamguo.modules.tiku.service.IChapterService; +import com.tamguo.modules.tiku.service.IQuestionService; + +@Controller +public class ChapterController { + + @Autowired + private IChapterService iChapterService; + @Autowired + private IQuestionService iQuestionService; + + @SuppressWarnings("unchecked") + @RequestMapping(path="chapter/{chapterId}-{current}-{size}.html") + public ModelAndView list(@PathVariable String chapterId , @PathVariable Integer current + , @PathVariable Integer size, ModelAndView model) { + ChapterEntity chapter = iChapterService.selectById(chapterId); + Page page = iQuestionService.selectPage(new Page<>(current, size) , Condition.create().eq("chapter_id", chapterId).orderDesc(Arrays.asList("id"))); + model.addObject("chapter", chapter); + model.addObject("page", page); + model.addObject("nextPage", current == page.getPages() ? page.getPages() : current+1); + model.addObject("prePage", current == 1 ? 1 : current - 1); + model.setViewName("question"); + return model; + } +} diff --git a/tamguo-mms/src/main/java/com/tamguo/web/CourseController.java b/tamguo-mms/src/main/java/com/tamguo/web/CourseController.java new file mode 100644 index 0000000..34e93a7 --- /dev/null +++ b/tamguo-mms/src/main/java/com/tamguo/web/CourseController.java @@ -0,0 +1,53 @@ +package com.tamguo.web; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.ModelAndView; + +import com.baomidou.mybatisplus.mapper.Condition; +import com.tamguo.modules.tiku.model.BookEntity; +import com.tamguo.modules.tiku.model.ChapterEntity; +import com.tamguo.modules.tiku.model.CourseEntity; +import com.tamguo.modules.tiku.service.IBookService; +import com.tamguo.modules.tiku.service.IChapterService; +import com.tamguo.modules.tiku.service.ICourseService; + +@Controller +public class CourseController { + + @Autowired + private ICourseService iCourseService; + @Autowired + private IBookService iBookService; + @Autowired + private IChapterService iChapterService; + + @SuppressWarnings("unchecked") + @RequestMapping(path= {"course/{courseId}.html"}) + public ModelAndView list(@PathVariable String courseId , ModelAndView model) { + CourseEntity course = iCourseService.selectById(courseId); + List bookList = iBookService.selectList(Condition.create().eq("course_id", courseId)); + List chapterList = null; + if(bookList.size() > 0) { + chapterList = iChapterService.selectList(Condition.create().eq("book_id", bookList.get(0).getId())); + } + model.addObject("course", course); + model.addObject("chapterList", chapterList); + model.addObject("subjectId", course.getSubjectId()); + model.addObject("courseId", course.getId()); + model.setViewName("course"); + return model; + } + + public ICourseService getiCourseService() { + return iCourseService; + } + + public void setiCourseService(ICourseService iCourseService) { + this.iCourseService = iCourseService; + } +} diff --git a/tamguo-mms/src/main/java/com/tamguo/web/IndexController.java b/tamguo-mms/src/main/java/com/tamguo/web/IndexController.java new file mode 100644 index 0000000..937b255 --- /dev/null +++ b/tamguo-mms/src/main/java/com/tamguo/web/IndexController.java @@ -0,0 +1,25 @@ +package com.tamguo.web; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.ModelAndView; + +import com.baomidou.mybatisplus.mapper.Condition; +import com.tamguo.modules.tiku.service.ISubjectService; + +@Controller +public class IndexController { + + @Autowired + private ISubjectService iSubjectService; + + @SuppressWarnings("unchecked") + @RequestMapping(path= {"index","/"}) + public ModelAndView index(ModelAndView model) { + model.setViewName("index"); + model.addObject("subjectList", iSubjectService.selectList(Condition.EMPTY)); + return model; + } + +} diff --git a/tamguo-mms/src/main/java/com/tamguo/web/SubjectController.java b/tamguo-mms/src/main/java/com/tamguo/web/SubjectController.java new file mode 100644 index 0000000..4299cf1 --- /dev/null +++ b/tamguo-mms/src/main/java/com/tamguo/web/SubjectController.java @@ -0,0 +1,32 @@ +package com.tamguo.web; + +import java.util.Arrays; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.ModelAndView; + +import com.baomidou.mybatisplus.mapper.Condition; +import com.tamguo.modules.tiku.service.ICourseService; +import com.tamguo.modules.tiku.service.ISubjectService; + +@Controller +public class SubjectController { + + @Autowired + private ICourseService iCourseService; + @Autowired + private ISubjectService iSubjectService; + + @SuppressWarnings("unchecked") + @RequestMapping(path= {"subject/{subjectId}.html"}) + public ModelAndView list(@PathVariable String subjectId , ModelAndView model) { + model.setViewName("subject"); + model.addObject("subject", iSubjectService.selectById(subjectId)); + model.addObject("courseList", iCourseService.selectList(Condition.create().eq("subject_id", subjectId).orderAsc(Arrays.asList("sort")))); + return model; + } + +} diff --git a/tamguo-mobile/src/main/resources/application.properties b/tamguo-mms/src/main/resources/application.properties similarity index 86% rename from tamguo-mobile/src/main/resources/application.properties rename to tamguo-mms/src/main/resources/application.properties index 0176bb2..bf41d2f 100644 --- a/tamguo-mobile/src/main/resources/application.properties +++ b/tamguo-mms/src/main/resources/application.properties @@ -1,5 +1,4 @@ -sitenum=3 -domain.name=http://m.tamguo.com/ +domain.name=http://localhost:8084/ server.port=8084 jasypt.encryptor.password=tamguo @@ -12,19 +11,20 @@ spring.datasource.maxPoolPreparedStatementPerConnectionSize=20 spring.datasource.maxWait=60000 spring.datasource.minEvictableIdleTimeMillis=300000 spring.datasource.minIdle=5 -spring.datasource.password= +spring.datasource.password=Tanguo spring.datasource.poolPreparedStatements=true spring.datasource.testOnBorrow=false spring.datasource.testOnReturn=false spring.datasource.testWhileIdle=true spring.datasource.timeBetweenEvictionRunsMillis=60000 spring.datasource.type=com.alibaba.druid.pool.DruidDataSource -spring.datasource.url=jdbc:mysql://127.0.0.1:3306/tiku?useUnicode=true&characterEncoding=UTF-8&useSSL=false +spring.datasource.url=jdbc:mysql://47.100.175.14:3306/tamguo?useUnicode=true&characterEncoding=UTF-8&useSSL=false spring.datasource.username=root spring.datasource.validationQuery=SELECT 1 FROM DUAL mybatis-plus.mapper-locations=classpath:/mappers/*Mapper.xml -mybatis-plus.typeAliasesPackage=com.tamguo.model +mybatis-plus.typeAliasesPackage=com.tamguo.modules.*.model +mybatis-plus.typeEnumsPackage=com.tamguo.modules.*.model.enums mybatis-plus.global-config.id-type=5 mybatis-plus.global-config.field-strategy=2 mybatis-plus.global-config.db-column-underline=true diff --git a/tamguo-mobile/src/main/resources/ehcache-shiro.xml b/tamguo-mms/src/main/resources/ehcache-shiro.xml similarity index 100% rename from tamguo-mobile/src/main/resources/ehcache-shiro.xml rename to tamguo-mms/src/main/resources/ehcache-shiro.xml diff --git a/tamguo-mobile/src/main/resources/mappers/CourseMapper.xml b/tamguo-mms/src/main/resources/mappers/CourseMapper.xml similarity index 100% rename from tamguo-mobile/src/main/resources/mappers/CourseMapper.xml rename to tamguo-mms/src/main/resources/mappers/CourseMapper.xml diff --git a/tamguo-mobile/src/main/resources/mappers/MenuMapper.xml b/tamguo-mms/src/main/resources/mappers/MenuMapper.xml similarity index 100% rename from tamguo-mobile/src/main/resources/mappers/MenuMapper.xml rename to tamguo-mms/src/main/resources/mappers/MenuMapper.xml diff --git a/tamguo-mobile/src/main/resources/mappers/QuestionMapper.xml b/tamguo-mms/src/main/resources/mappers/QuestionMapper.xml similarity index 100% rename from tamguo-mobile/src/main/resources/mappers/QuestionMapper.xml rename to tamguo-mms/src/main/resources/mappers/QuestionMapper.xml diff --git a/tamguo-mobile/src/main/resources/redis.xml b/tamguo-mms/src/main/resources/redis.xml similarity index 100% rename from tamguo-mobile/src/main/resources/redis.xml rename to tamguo-mms/src/main/resources/redis.xml diff --git a/tamguo-mms/src/main/resources/static/js/chapter/main.js b/tamguo-mms/src/main/resources/static/js/chapter/main.js new file mode 100644 index 0000000..3013f96 --- /dev/null +++ b/tamguo-mms/src/main/resources/static/js/chapter/main.js @@ -0,0 +1,19 @@ +var vm = new Vue({ + el:'#app', + data : { + docked: false, + open: false, + position: 'left', + panel: '', + total:0, + question:{}, + topUrl:"", + nextUrl:null, + warnOpen:false, + warnMessage:'', + courseList:[] + }, + methods:{ + + } +}); \ No newline at end of file diff --git a/tamguo-mms/src/main/resources/static/js/index/main.js b/tamguo-mms/src/main/resources/static/js/index/main.js new file mode 100644 index 0000000..3013f96 --- /dev/null +++ b/tamguo-mms/src/main/resources/static/js/index/main.js @@ -0,0 +1,19 @@ +var vm = new Vue({ + el:'#app', + data : { + docked: false, + open: false, + position: 'left', + panel: '', + total:0, + question:{}, + topUrl:"", + nextUrl:null, + warnOpen:false, + warnMessage:'', + courseList:[] + }, + methods:{ + + } +}); \ No newline at end of file diff --git a/tamguo-mms/src/main/resources/static/js/question/main.js b/tamguo-mms/src/main/resources/static/js/question/main.js new file mode 100644 index 0000000..3013f96 --- /dev/null +++ b/tamguo-mms/src/main/resources/static/js/question/main.js @@ -0,0 +1,19 @@ +var vm = new Vue({ + el:'#app', + data : { + docked: false, + open: false, + position: 'left', + panel: '', + total:0, + question:{}, + topUrl:"", + nextUrl:null, + warnOpen:false, + warnMessage:'', + courseList:[] + }, + methods:{ + + } +}); \ No newline at end of file diff --git a/tamguo-mms/src/main/resources/templates/course.html b/tamguo-mms/src/main/resources/templates/course.html new file mode 100644 index 0000000..8d70404 --- /dev/null +++ b/tamguo-mms/src/main/resources/templates/course.html @@ -0,0 +1,73 @@ + + + + + + + 探果题库_聪明的学生都在这里 + + + + + + + + + + + +
+ + + + + 探果题库 + + 登录 + 注册 + + + + + + + + Sent mail + + + + + List Item 1 + + + + + List Item 2.1 + + + + + + +
+ + + + + + + + \ No newline at end of file diff --git a/tamguo-mobile/src/main/resources/templates/index.html b/tamguo-mms/src/main/resources/templates/index.html similarity index 56% rename from tamguo-mobile/src/main/resources/templates/index.html rename to tamguo-mms/src/main/resources/templates/index.html index 2ea57ec..5cddd4d 100644 --- a/tamguo-mobile/src/main/resources/templates/index.html +++ b/tamguo-mms/src/main/resources/templates/index.html @@ -4,7 +4,11 @@ - 探果题库为老师创造价值-探果题库 + 探果题库_聪明的学生都在这里 + + + + @@ -31,10 +35,10 @@ 注册 - - {{item.name}} - - {{it.name}} + + + + {{it.name}} @@ -47,10 +51,10 @@ - + \ No newline at end of file diff --git a/tamguo-mobile/src/main/resources/templates/question.html b/tamguo-mms/src/main/resources/templates/question.html similarity index 62% rename from tamguo-mobile/src/main/resources/templates/question.html rename to tamguo-mms/src/main/resources/templates/question.html index 3d48f59..9836eaf 100644 --- a/tamguo-mobile/src/main/resources/templates/question.html +++ b/tamguo-mms/src/main/resources/templates/question.html @@ -42,24 +42,22 @@ - - -

如图,圆O 1 与圆O 2 内切于点A,其半径分别为r 1 与r 2 (r 1 >r 2 ).圆O 1 的弦AB交圆O 2 于点C(O 1 不在AB上)。

-

-

求证:AB∶AC为定值。

+ + + 无 - + B - +

苯巴比妥属于巴比妥类镇静催眠药;佐匹克隆属于环吡咯酮类镇静催眠药;阿普唑仑属于苯二氮䓬类镇静催眠药,同类药物还有地西泮等,苯妥英钠属于乙内酰脲类抗癫痫药。

- + @@ -78,22 +76,18 @@ - - - + + + - + \ No newline at end of file diff --git a/tamguo-mms/src/main/resources/templates/subject.html b/tamguo-mms/src/main/resources/templates/subject.html new file mode 100644 index 0000000..fc3cece --- /dev/null +++ b/tamguo-mms/src/main/resources/templates/subject.html @@ -0,0 +1,60 @@ + + + + + + + 探果题库_聪明的学生都在这里 + + + + + + + + + + + +
+ + + + + 探果题库 + 登录 + 注册 + + + + 高考 + + {{it.name}} + + + + + + + + +
+ + + + + + + + \ No newline at end of file diff --git a/tamguo-mobile/src/main/java/com/tamguo/config/WebConfig.java b/tamguo-mobile/src/main/java/com/tamguo/config/WebConfig.java deleted file mode 100644 index 1ab8f47..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/config/WebConfig.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.tamguo.config; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; -import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer; -import org.springframework.boot.web.servlet.ErrorPage; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.HttpStatus; -import org.springframework.web.servlet.config.annotation.InterceptorRegistry; -import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; - -import com.tamguo.interceptor.SettingInterptor; - - -@Configuration -public class WebConfig extends WebMvcConfigurerAdapter { - - @Value("${file.storage.path}") - private String fileStoragePath; - @Autowired - private SettingInterptor settingInterptor; - - /** - * 拦截器 - */ - @Override - public void addInterceptors(InterceptorRegistry registry) { - registry.addInterceptor(settingInterptor).addPathPatterns("/**"); - } - - @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) { - registry.addResourceHandler("/files/**").addResourceLocations("file:"+fileStoragePath); - super.addResourceHandlers(registry); - } - - @Bean - public EmbeddedServletContainerCustomizer containerCustomizer() { - return new EmbeddedServletContainerCustomizer(){ - @Override - public void customize(ConfigurableEmbeddedServletContainer container) { - container.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/404.html")); - container.addErrorPages(new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500.html")); - } - }; - } - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/config/dao/SuperEntity.java b/tamguo-mobile/src/main/java/com/tamguo/config/dao/SuperEntity.java deleted file mode 100644 index 8906d69..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/config/dao/SuperEntity.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.tamguo.config.dao; - -import java.io.Serializable; -import com.baomidou.mybatisplus.activerecord.Model; -import com.baomidou.mybatisplus.annotations.TableId; - -/** - * 实体父类 - */ -public class SuperEntity> extends Model { - - private static final long serialVersionUID = 1L; - - @TableId("uid") - private String uid; - - @Override - protected Serializable pkVal() { - return this.getUid(); - } - - public String getUid() { - return uid; - } - - public void setUid(String uid) { - this.uid = uid; - } -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/config/dao/SuperMapper.java b/tamguo-mobile/src/main/java/com/tamguo/config/dao/SuperMapper.java deleted file mode 100644 index 6b8b4cf..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/config/dao/SuperMapper.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.tamguo.config.dao; - -import com.baomidou.mybatisplus.mapper.BaseMapper; - -/** - * 演示 mapper 父类,注意这个类不要让 mp 扫描到!! - */ -public interface SuperMapper extends BaseMapper { - - // 这里可以放一些公共的方法 -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/config/redis/SessionConfig.java b/tamguo-mobile/src/main/java/com/tamguo/config/redis/SessionConfig.java deleted file mode 100644 index 6bde953..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/config/redis/SessionConfig.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.tamguo.config.redis; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; -import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession; - -//这个类用配置redis服务器的连接 -@EnableRedisHttpSession(maxInactiveIntervalInSeconds= 1800) -public class SessionConfig { - - @Value("${redis.hostname}") - String HostName; - @Value("${redis.port}") - int Port; - @Value("${redis.password}") - String password; - - @Bean - public JedisConnectionFactory connectionFactory() { - JedisConnectionFactory connection = new JedisConnectionFactory(); - connection.setPort(Port); - connection.setHostName(HostName); - connection.setPassword(password); - return connection; - } -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/config/redis/SessionInitializer.java b/tamguo-mobile/src/main/java/com/tamguo/config/redis/SessionInitializer.java deleted file mode 100644 index 3477712..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/config/redis/SessionInitializer.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.tamguo.config.redis; - -import org.springframework.session.web.context.AbstractHttpSessionApplicationInitializer; - -//初始化Session配置 -public class SessionInitializer extends AbstractHttpSessionApplicationInitializer{ - public SessionInitializer() { - super(SessionConfig.class); - } -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/dao/CourseMapper.java b/tamguo-mobile/src/main/java/com/tamguo/dao/CourseMapper.java deleted file mode 100644 index ed54626..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/dao/CourseMapper.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.tamguo.dao; - -import java.util.List; - -import org.apache.ibatis.annotations.Param; - -import com.tamguo.config.dao.SuperMapper; -import com.tamguo.model.ChapterEntity; -import com.tamguo.model.CourseEntity; - -public interface CourseMapper extends SuperMapper{ - - List findBySubjectId(String uid); - - List findByCourseId(@Param(value="courseId") String courseId); - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/dao/MenuMapper.java b/tamguo-mobile/src/main/java/com/tamguo/dao/MenuMapper.java deleted file mode 100644 index b05b3f9..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/dao/MenuMapper.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.tamguo.dao; - -import java.util.List; -import com.tamguo.config.dao.SuperMapper; -import com.tamguo.model.MenuEntity; - -public interface MenuMapper extends SuperMapper{ - - - public List findMenuByParentId(String parentId); - - public List findAllFatherMenus(); - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/dao/QuestionMapper.java b/tamguo-mobile/src/main/java/com/tamguo/dao/QuestionMapper.java deleted file mode 100644 index d896665..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/dao/QuestionMapper.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.tamguo.dao; - -import java.util.List; - -import com.baomidou.mybatisplus.plugins.pagination.Pagination; -import com.tamguo.config.dao.SuperMapper; -import com.tamguo.model.QuestionEntity; - -public interface QuestionMapper extends SuperMapper{ - - List findPage(String chapterId, Pagination page); - - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/dao/redis/CacheService.java b/tamguo-mobile/src/main/java/com/tamguo/dao/redis/CacheService.java deleted file mode 100644 index d32772a..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/dao/redis/CacheService.java +++ /dev/null @@ -1,491 +0,0 @@ -package com.tamguo.dao.redis; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.tamguo.util.ObjectUtil; -import com.tamguo.util.SerializeTranscoder; - -import redis.clients.jedis.ShardedJedis; - -/** - * 缓存中心 - * - */ -@Service("cacheService") -public class CacheService { - private final static String REDIS_PRE_KEY = "TAMGUO:"; - private SerializeTranscoder objectSerialize = new ObjectUtil(); - - @Autowired - private RedisXMLConfigure redisXMLConfigure; - - /** - * - * @Title: get @Description: @param @return String 返回类型 @throws - */ - public String get(String key) { - key = getPreKey(key); - ShardedJedis conn = null; - try { - conn = redisXMLConfigure.getConnection(); - return conn.get(key); - } finally { - redisXMLConfigure.closeConnection(conn); - } - } - - /** - * - * @Title: set @Description: @param @return void 返回类型 @throws - */ - public void set(String key, String value) { - key = getPreKey(key); - ShardedJedis conn = null; - try { - conn = redisXMLConfigure.getConnection(); - conn.set(key, value); - } finally { - redisXMLConfigure.closeConnection(conn); - } - } - - /** - * - * set 设置带过期时间的字符缓存 - * - * @param key - * @param value - * @param time - * 过期时间,秒 - * @description - * @exception @since - * 1.0.0 - */ - public void set(String key, String value, int time) { - key = getPreKey(key); - ShardedJedis conn = null; - try { - conn = redisXMLConfigure.getConnection(); - conn.set(key, value); - conn.expire(key, time); - } finally { - redisXMLConfigure.closeConnection(conn); - } - } - - /** - * redis中存放对象 - * - * @param key 对象key - * @param value 可序列化的对象 - */ - public void setObject(String key, Object value) { - key = getPreKey(key); - ShardedJedis conn = null; - try { - conn = redisXMLConfigure.getConnection(); - conn.set(key.getBytes(), objectSerialize.serialize(value)); - } catch (Exception ex) { - ex.printStackTrace(); - } finally { - redisXMLConfigure.closeConnection(conn); - } - } - - /** - * 设置过期时间存储对象 - * - * @param key 对象key - * @param value 对象值 - * @param time 过期时间 秒 - */ - public void setObject(String key, Object value, int time) { - key = getPreKey(key); - ShardedJedis conn = null; - try { - conn = redisXMLConfigure.getConnection(); - conn.setex(key.getBytes(), time, objectSerialize.serialize(value)); - } catch (Exception ex) { - ex.printStackTrace(); - } finally { - redisXMLConfigure.closeConnection(conn); - } - } - - /** - * 获取存储的对象 - * - * @param key 对象key - * @return 存储的对象 - */ - public Object getObject(String key) { - key = getPreKey(key); - ShardedJedis conn = null; - try { - conn = redisXMLConfigure.getConnection(); - byte[] obj = conn.get(key.getBytes()); - if (null == obj) - return null; - return objectSerialize.deserialize(obj); - } catch (Exception ex) { - ex.printStackTrace(); - } finally { - redisXMLConfigure.closeConnection(conn); - } - return null; - } - - /** - * 删除一个对象 - * - * @param key 对象key值 - * @return - */ - public boolean deleteObject(String key) { - key = getPreKey(key); - ShardedJedis conn = null; - try { - conn = redisXMLConfigure.getConnection(); - return conn.del(key.getBytes()) == 1L; - } catch (Exception ex) { - ex.printStackTrace(); - } finally { - redisXMLConfigure.closeConnection(conn); - } - return false; - } - - /** - * - * @Title: isExist @Description: 判断key是否存在 @param @return boolean - * 返回类型 @throws - */ - public boolean isExist(String key) { - key = getPreKey(key); - ShardedJedis conn = null; - try { - conn = redisXMLConfigure.getConnection(); - return conn.exists(key); - } catch (Exception ex) { - ex.printStackTrace(); - } finally { - redisXMLConfigure.closeConnection(conn); - } - return false; - } - - public boolean notExist(String key) { - return !isExist(key); - } - - public boolean delete(String key) { - key = getPreKey(key); - ShardedJedis conn = null; - try { - conn = redisXMLConfigure.getConnection(); - return conn.del(key) == 1; - } catch (Exception ex) { - ex.printStackTrace(); - } finally { - redisXMLConfigure.closeConnection(conn); - } - return false; - } - - /** - * 关于 redis list的操作 将 值 value 插入到列表 key 的表尾(最右边)。 - * - * @param key - * @param value - * @return - */ - public long putToListEnd(String key, String value) { - key = getPreKey(key); - ShardedJedis conn = null; - try { - conn = redisXMLConfigure.getConnection(); - long length = conn.rpush(key, value); - return length; - } finally { - redisXMLConfigure.closeConnection(conn); - } - } - - /** - * 将value插入集合key的尾部, 并设置过期时间 - * - * @author zhangxin - * @param key - * @param value - * @param seconds - * @param score - * @return long 被成功添加的新成员的数量,不包括那些被更新的、已经存在的成员 - */ - public long addToSortedSetAndExpire(String key, String value, int seconds, double score) { - return addToSortedSet(key, value, seconds, true, score); - } - - - /** - * 将value插入集合key的尾部 增加value的score - * - * @author zhangxin - * @param key - * @param value - * @param score - * @return long 被成功添加的新成员的分数 - */ - public double addToSortedSetScore(String key, String value, double score) { - key = getPreKey(key); - ShardedJedis conn = null; - try { - conn = redisXMLConfigure.getConnection(); - Double zincrby = conn.zincrby(key, score, value); - return zincrby; - } finally { - redisXMLConfigure.closeConnection(conn); - } - } - - /** - * 获取member的Score - * @param key - * @param value - * @return - */ - public Double getMemberScore(String key, String member) { - key = getPreKey(key); - ShardedJedis conn = null; - try { - conn = redisXMLConfigure.getConnection(); - Double zscore = conn.zscore(key, member); - return zscore == null ? 0 : zscore; - } finally { - redisXMLConfigure.closeConnection(conn); - } - } - - - /** - * 将value插入集合key的尾部, 不设置过期时间 - * - * @author zhangxin - * @param key - * @param value - * @param score - * @return long 被成功添加的新成员的数量,不包括那些被更新的、已经存在的成员 - */ - public long addToSortedSet(String key, String value, double score) { - return addToSortedSet(key, value, -1, false, score); - } - - - /** - * 判断member在集合里是否存在 - * - * @return isExist 存在 true 不存在 - */ - public boolean isExistSortedSet(String key, String member) { - key = getPreKey(key); - ShardedJedis conn = null; - try { - conn = redisXMLConfigure.getConnection(); - Long zrank = conn.zrank(key, member); - return zrank != null; - } finally { - redisXMLConfigure.closeConnection(conn); - } - } - - /** - * 删除member - * - * @return isExist 存在 true 不存在 - */ - public boolean delSortedSetMember(String key, String[] member) { - key = getPreKey(key); - ShardedJedis conn = null; - try { - conn = redisXMLConfigure.getConnection(); - Long zrem = conn.zrem(key, member); - return zrem >= 1; - } finally { - redisXMLConfigure.closeConnection(conn); - } - } - - /** - * 将value插入集合key的尾部, 对于setExpire为false的情况, seconds无效 - * - * @return 被成功添加的新成员的数量,不包括那些被更新的、已经存在的成员 - */ - private long addToSortedSet(String key, String value, int seconds, boolean setExpire, double score) { - key = getPreKey(key); - ShardedJedis conn = null; - try { - conn = redisXMLConfigure.getConnection(); - long addNum = conn.zadd(key, score, value); - if (setExpire) { - conn.expire(key, seconds); - } - return addNum; - } finally { - redisXMLConfigure.closeConnection(conn); - } - } - - /** - * 按score降序分页获取有序集合中内容 - * - * @author zhangxin - * @param key - * @param pageNo - * 首页从1开始 - * @param pageSize - * @return Set - */ - public Set getSortedSetByPage(String key, int pageNo, int pageSize) { - key = getPreKey(key); - ShardedJedis conn = null; - try { - if (pageNo < 1) { - pageNo = 1; - } - if (pageSize < 1) { - pageSize = 1; - } - int start = (pageNo - 1) * pageSize; - conn = redisXMLConfigure.getConnection(); - return conn.zrevrange(key, start, start + pageSize - 1); - } catch (Exception ex) { - ex.printStackTrace(); - } finally { - redisXMLConfigure.closeConnection(conn); - } - return null; - } - - public List getListHead(String key) { - key = getPreKey(key); - ShardedJedis conn = null; - try { - conn = redisXMLConfigure.getConnection(); - List result = conn.blpop(1000, key); - - if (null == result || result.size() == 0) - return null; - return result; - } finally { - redisXMLConfigure.closeConnection(conn); - } - } - - /** - * 存储map - * - * @param key 键值 - * @param field map field - * @param value map value - * @return if filed exist return 0 else return 1 - */ - public Long hset(String key, String field, String value) { - key = getPreKey(key); - ShardedJedis conn = null; - try { - conn = redisXMLConfigure.getConnection(); - return conn.hset(key, field, value); - } finally { - redisXMLConfigure.closeConnection(conn); - } - } - - public String hset(String key, Map values) { - key = getPreKey(key); - ShardedJedis conn = null; - try { - conn = redisXMLConfigure.getConnection(); - return conn.hmset(key, values); - } finally { - redisXMLConfigure.closeConnection(conn); - } - } - - public String hset(String key, Map values, int time) { - key = getPreKey(key); - ShardedJedis conn = null; - try { - conn = redisXMLConfigure.getConnection(); - String hmset = conn.hmset(key, values); - conn.expire(key, time); - return hmset; - } finally { - redisXMLConfigure.closeConnection(conn); - } - } - - /** - * 得到map中存储的field值 - * - * @param key 键值 - * @param field map field - * @return - */ - public String hget(String key, String field) { - key = getPreKey(key); - ShardedJedis conn = null; - try { - conn = redisXMLConfigure.getConnection(); - return conn.hget(key, field); - } finally { - redisXMLConfigure.closeConnection(conn); - } - } - - /** - * 名称为key的string减1操作 - * - * @param key - * @return - */ - public Long decr(String key) { - key = getPreKey(key); - ShardedJedis conn = null; - try { - conn = redisXMLConfigure.getConnection(); - return conn.decr(key); - } finally { - redisXMLConfigure.closeConnection(conn); - } - } - - /** - * 名称为key的string加1操作 - * - * @param key - * @return - */ - public Long incr(String key) { - key = getPreKey(key); - ShardedJedis conn = null; - try { - conn = redisXMLConfigure.getConnection(); - return conn.incr(key); - } finally { - redisXMLConfigure.closeConnection(conn); - } - } - - private String getPreKey(String key) { - String temp_pre = redisXMLConfigure.getPreKey(); - if (null == temp_pre) { - return REDIS_PRE_KEY + key; - } - return temp_pre + key; - } - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/dao/redis/PoolConfigBean.java b/tamguo-mobile/src/main/java/com/tamguo/dao/redis/PoolConfigBean.java deleted file mode 100644 index f94027e..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/dao/redis/PoolConfigBean.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.tamguo.dao.redis; - -public class PoolConfigBean { - private int max_active; - private int max_idle; - private long max_wait; - - public PoolConfigBean() { - } - - public PoolConfigBean(int max_active, int max_idle, long max_wait) { - super(); - this.max_active = max_active; - this.max_idle = max_idle; - this.max_wait = max_wait; - } - - public int getMax_active() { - return max_active; - } - - public void setMax_active(int max_active) { - this.max_active = max_active; - } - - public int getMax_idle() { - return max_idle; - } - - public void setMax_idle(int max_idle) { - this.max_idle = max_idle; - } - - public long getMax_wait() { - return max_wait; - } - - public void setMax_wait(long max_wait) { - this.max_wait = max_wait; - } - - @Override - public String toString() { - return "PoolConfig [max_active=" + max_active + ", max_idle=" + max_idle + ", max_wait=" + max_wait + "]"; - } - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/dao/redis/RedisServerNodeBean.java b/tamguo-mobile/src/main/java/com/tamguo/dao/redis/RedisServerNodeBean.java deleted file mode 100644 index 11f2006..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/dao/redis/RedisServerNodeBean.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.tamguo.dao.redis; - -public class RedisServerNodeBean { - private String ip; - private int port; - private boolean needAuth; - private String auth; - - public RedisServerNodeBean(String ip, int port, boolean needAuth, String auth) { - this.ip = ip; - this.port = port; - this.needAuth = needAuth; - this.auth = auth; - } - - public String getIp() { - return ip; - } - - public void setIp(String ip) { - this.ip = ip; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } - - public boolean isNeedAuth() { - return needAuth; - } - - public void setNeedAuth(boolean needAuth) { - this.needAuth = needAuth; - } - - public String getAuth() { - return auth; - } - - public void setAuth(String auth) { - this.auth = auth; - } - - @Override - public String toString() { - return "RedisServer [ip=" + ip + ", port=" + port + ", needAuth=" + needAuth + ", auth=" + auth + "]"; - } - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/dao/redis/RedisXMLConfigure.java b/tamguo-mobile/src/main/java/com/tamguo/dao/redis/RedisXMLConfigure.java deleted file mode 100644 index ae79ea4..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/dao/redis/RedisXMLConfigure.java +++ /dev/null @@ -1,175 +0,0 @@ -package com.tamguo.dao.redis; - -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.Logger; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.stereotype.Component; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - -import com.tamguo.util.XMLConfiguration; - -import redis.clients.jedis.JedisPoolConfig; -import redis.clients.jedis.JedisShardInfo; -import redis.clients.jedis.ShardedJedis; -import redis.clients.jedis.ShardedJedisPool; - -@Component("redisConfigure") -public class RedisXMLConfigure implements InitializingBean { - private static final Logger logger = Logger.getLogger(RedisXMLConfigure.class); - private static String preKey; - private static Document document = null; - private ShardedJedisPool shardedJedisPool; - - @Override - public void afterPropertiesSet() throws Exception { - XMLConfiguration xmlConfiguration = new XMLConfiguration(); - String REDIS_PATH = "redis.xml"; - InputStream stream = null; - try { - stream = this.getClass().getClassLoader().getResourceAsStream(REDIS_PATH); - if (stream == null) { - logger.error("load redis.xml failed!!!" + REDIS_PATH); - throw new RuntimeException("load redis.xml failed"); - } - logger.info("Redis XML config path:" + REDIS_PATH); - if (xmlConfiguration.readConfigFile(stream)) { - document = xmlConfiguration.getDocument(); - } else { - logger.error("load redis.xml failed!!!"); - } - } finally { - if (null != stream) - stream.close(); - } - //初始化参数 - initPreKey(); - PoolConfigBean pcb = initPoolConfigBean(); - List rsnbs = initRedisServerNodeBeans(); - //实现shardedJedisPool - JedisPoolConfig jedisPoolConfig = new JedisPoolConfig(); - //no maxActive config - jedisPoolConfig.setMaxIdle(pcb.getMax_idle()); - jedisPoolConfig.setMaxWaitMillis(pcb.getMax_wait()); - shardedJedisPool = new ShardedJedisPool(jedisPoolConfig,getJedisShardInfo(rsnbs)); - if(shardedJedisPool == null){ - throw new RuntimeException("config redis.xml error"); - } - } - - /** - * 初始化jedis参数 - */ - private PoolConfigBean initPoolConfigBean() { - PoolConfigBean poolConfigBean = new PoolConfigBean(); - Element poolElement = (Element) document.getElementsByTagName("pool").item(0); - int max_active = poolElement.hasAttribute("maxActive") ? Integer.parseInt(poolElement.getAttribute("maxActive")) : -1; - int max_idle = poolElement.hasAttribute("maxIdle") ? Integer.parseInt(poolElement.getAttribute("maxIdle")) : -1; - long max_wait = poolElement.hasAttribute("maxWait") ? Long.parseLong(poolElement.getAttribute("maxWait")) : -1; - poolConfigBean.setMax_active(max_active); - poolConfigBean.setMax_idle(max_idle); - poolConfigBean.setMax_wait(max_wait); - return poolConfigBean; - } - - /** - * 解析配置redis的server列表 - */ - private List initRedisServerNodeBeans() { - List redisServers = new ArrayList(); - NodeList serverElements = document.getElementsByTagName("server"); - int serverLen = serverElements.getLength(); - if (serverLen < 1) { - logger.error("redis.servers.server must have one !"); - return null; - } - for (int i = 0; i < serverLen; i++) { - Element serverElement = (Element) serverElements.item(i); - String temp_ip = serverElement.hasAttribute("ip") ? serverElement.getAttribute("ip") : null; - if (temp_ip == null) { - logger.error("redis.servers.server.ip must be supplied!"); - return null; - } - - String temp_port = serverElement.hasAttribute("port") ? serverElement.getAttribute("port") : "6379"; - String temp_needAuth = serverElement.hasAttribute("needAuth") ? serverElement.getAttribute("needAuth") : "false"; - String temp_auth = null; - // need auth - if ("true".equals(temp_needAuth)) { - temp_auth = serverElement.hasAttribute("auth") ? serverElement.getAttribute("auth") : null; - if (null == temp_auth) { - logger.error("since needAuth is true,auth must be supplied!"); - return null; - } - } - - RedisServerNodeBean rs = null; - try { - rs = new RedisServerNodeBean(temp_ip, Integer.parseInt(temp_port), Boolean.parseBoolean(temp_needAuth), temp_auth); - } catch (NumberFormatException e) { - logger.error("port must be a number!\n" + e.getMessage()); - return null; - } - redisServers.add(rs); - } - return redisServers; - } - - /** - * 转换自定义配置为JedisShardInfo对象 - * @param redisServers - * @return - */ - private List getJedisShardInfo(List redisServers) { - if(redisServers == null){ - logger.error("redisServers must not be empty null"); - return null; - } - int serverLen = redisServers.size(); - if (serverLen < 1) { - logger.error("redisServers must not be empty "); - return null; - } - List servers = new ArrayList(serverLen); - for (int i = 0; i < serverLen; i++) { - RedisServerNodeBean redisServer = redisServers.get(i); - JedisShardInfo jedisShardInfo = new JedisShardInfo(redisServer.getIp(), redisServer.getPort()); - if (redisServer.isNeedAuth()) { - jedisShardInfo.setPassword(redisServer.getAuth()); - } - servers.add(jedisShardInfo); - } - return servers; - } - - /* - * 初始化redis的key前缀 - */ - private void initPreKey() { - Element preKeyElement = (Element) document.getElementsByTagName("preKey").item(0); - preKey = preKeyElement.hasAttribute("value") ? preKeyElement.getAttribute("value") : ""; - } - - public String getPreKey() { - return preKey; - } - /** - * 从jedis连接池获得一个连接 - * @return - */ - public ShardedJedis getConnection() { - return shardedJedisPool.getResource(); - } - /** - * 把连接放回jedis连接池 - * @param resource - */ - public void closeConnection(ShardedJedis resource) { - resource.close(); - } - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/interceptor/SettingInterptor.java b/tamguo-mobile/src/main/java/com/tamguo/interceptor/SettingInterptor.java deleted file mode 100644 index 3b956d6..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/interceptor/SettingInterptor.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.tamguo.interceptor; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.web.servlet.HandlerInterceptor; -import org.springframework.web.servlet.ModelAndView; - -import com.tamguo.util.Setting; - - -@Component -public class SettingInterptor implements HandlerInterceptor{ - - @Autowired - Setting setting; - - @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) - throws Exception { - return true; - } - - @Override - public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, - ModelAndView modelAndView) throws Exception { - // 设置系统变量 - request.setAttribute("setting", setting); - } - - @Override - public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) - throws Exception { - - } - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/model/ChapterEntity.java b/tamguo-mobile/src/main/java/com/tamguo/model/ChapterEntity.java deleted file mode 100644 index 7e5ba0b..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/model/ChapterEntity.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.tamguo.model; - -import java.io.Serializable; -import com.baomidou.mybatisplus.annotations.TableField; -import com.baomidou.mybatisplus.annotations.TableName; -import com.tamguo.config.dao.SuperEntity; - -import java.util.List; - - -/** - * The persistent class for the tiku_chapter database table. - * - */ -@TableName(value="tiku_chapter") -public class ChapterEntity extends SuperEntity implements Serializable { - private static final long serialVersionUID = 1L; - - private String subjectId; - - private String courseId; - - private String name; - - private String parentId; - - private Integer questionNum; - - private Integer pointNum; - - private Integer orders; - - @TableField(exist=false) - private List childChapterList; - - public ChapterEntity() { - } - - public String getCourseId() { - return this.courseId; - } - - public void setCourseId(String courseId) { - this.courseId = courseId; - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public String getParentId() { - return this.parentId; - } - - public void setParentId(String parentId) { - this.parentId = parentId; - } - - public List getChildChapterList() { - return childChapterList; - } - - public void setChildChapterList(List childChapterList) { - this.childChapterList = childChapterList; - } - - public Integer getQuestionNum() { - return questionNum; - } - - public void setQuestionNum(Integer questionNum) { - this.questionNum = questionNum; - } - - public Integer getPointNum() { - return pointNum; - } - - public void setPointNum(Integer pointNum) { - this.pointNum = pointNum; - } - - public Integer getOrders() { - return orders; - } - - public void setOrders(Integer orders) { - this.orders = orders; - } - - public String getSubjectId() { - return subjectId; - } - - public void setSubjectId(String subjectId) { - this.subjectId = subjectId; - } - -} \ No newline at end of file diff --git a/tamguo-mobile/src/main/java/com/tamguo/model/CourseEntity.java b/tamguo-mobile/src/main/java/com/tamguo/model/CourseEntity.java deleted file mode 100644 index fe20a9b..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/model/CourseEntity.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.tamguo.model; - -import java.io.Serializable; -import com.baomidou.mybatisplus.annotations.TableField; -import com.baomidou.mybatisplus.annotations.TableName; -import com.tamguo.config.dao.SuperEntity; - -import java.util.List; - - -/** - * The persistent class for the tiku_course database table. - * - */ -@TableName(value="tiku_course") -public class CourseEntity extends SuperEntity implements Serializable { - private static final long serialVersionUID = 1L; - - private String name; - - private String subjectId; - - private Integer pointNum; - - private Integer questionNum; - - private Integer orders; - - private String seoTitle; - - private String seoKeywords; - - private String seoDescription; - - @TableField(exist=false) - private String subjectName; - - @TableField(exist=false) - private List chapterList; - - public CourseEntity() { - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public String getSubjectId() { - return this.subjectId; - } - - public void setSubjectId(String subjectId) { - this.subjectId = subjectId; - } - - public Integer getQuestionNum() { - return questionNum; - } - - public void setQuestionNum(Integer questionNum) { - this.questionNum = questionNum; - } - - public Integer getPointNum() { - return pointNum; - } - - public void setPointNum(Integer pointNum) { - this.pointNum = pointNum; - } - - public Integer getOrders() { - return orders; - } - - public void setOrders(Integer orders) { - this.orders = orders; - } - - public List getChapterList() { - return chapterList; - } - - public void setChapterList(List chapterList) { - this.chapterList = chapterList; - } - - public String getSeoTitle() { - return seoTitle; - } - - public void setSeoTitle(String seoTitle) { - this.seoTitle = seoTitle; - } - - public String getSeoKeywords() { - return seoKeywords; - } - - public void setSeoKeywords(String seoKeywords) { - this.seoKeywords = seoKeywords; - } - - public String getSeoDescription() { - return seoDescription; - } - - public void setSeoDescription(String seoDescription) { - this.seoDescription = seoDescription; - } - - public static long getSerialversionuid() { - return serialVersionUID; - } - - public String getSubjectName() { - return subjectName; - } - - public void setSubjectName(String subjectName) { - this.subjectName = subjectName; - } - -} \ No newline at end of file diff --git a/tamguo-mobile/src/main/java/com/tamguo/model/MenuEntity.java b/tamguo-mobile/src/main/java/com/tamguo/model/MenuEntity.java deleted file mode 100644 index 9f41376..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/model/MenuEntity.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.tamguo.model; - -import java.io.Serializable; -import com.baomidou.mybatisplus.annotations.TableField; -import com.baomidou.mybatisplus.annotations.TableName; -import com.tamguo.config.dao.SuperEntity; - -import java.util.List; - - -/** - * The persistent class for the tiku_subject database table. - * - */ -@TableName(value="tiku_menu") -public class MenuEntity extends SuperEntity implements Serializable { - private static final long serialVersionUID = 1L; - - private String name; - - private String pinyin; - - private String parentId; - - private String isShow; - - private Integer orders; - - private String url; - - private String reserve1; - - // 子类型 - @TableField(exist=false) - private List childSubjects; - - public MenuEntity() { - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public String getParentId() { - return this.parentId; - } - - public void setParentId(String parentId) { - this.parentId = parentId; - } - - public List getChildSubjects() { - return childSubjects; - } - - public void setChildSubjects(List childSubjects) { - this.childSubjects = childSubjects; - } - - public String getPinyin() { - return pinyin; - } - - public void setPinyin(String pinyin) { - this.pinyin = pinyin; - } - - public String getIsShow() { - return isShow; - } - - public void setIsShow(String isShow) { - this.isShow = isShow; - } - - public Integer getOrders() { - return orders; - } - - public void setOrders(Integer orders) { - this.orders = orders; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getReserve1() { - return reserve1; - } - - public void setReserve1(String reserve1) { - this.reserve1 = reserve1; - } - -} \ No newline at end of file diff --git a/tamguo-mobile/src/main/java/com/tamguo/model/QuestionEntity.java b/tamguo-mobile/src/main/java/com/tamguo/model/QuestionEntity.java deleted file mode 100644 index 4fe7584..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/model/QuestionEntity.java +++ /dev/null @@ -1,172 +0,0 @@ -package com.tamguo.model; - -import java.io.Serializable; -import com.baomidou.mybatisplus.annotations.TableField; -import com.baomidou.mybatisplus.annotations.TableName; -import com.tamguo.config.dao.SuperEntity; - -/** - * The persistent class for the tiku_question database table. - * - */ -@TableName(value="tiku_question") -public class QuestionEntity extends SuperEntity implements Serializable { - private static final long serialVersionUID = 1L; - - private String analysis; - - private String paperId; - - private String answer; - - private String chapterId; - - private String questionType; - - private String content; - - private String subjectId; - - private String courseId; - - private String reviewPoint; - - private String year; - - private Integer score; - - private String auditStatus; - - @TableField(exist=false) - private String courseName; - - @TableField(exist=false) - private String chapterName; - - @TableField(exist=false) - private String subjectName; - - public QuestionEntity() { - } - - public String getAnalysis() { - return this.analysis; - } - - public void setAnalysis(String analysis) { - this.analysis = analysis; - } - - public String getAnswer() { - return this.answer; - } - - public void setAnswer(String answer) { - this.answer = answer; - } - - public String getChapterId() { - return this.chapterId; - } - - public void setChapterId(String chapterId) { - this.chapterId = chapterId; - } - - public String getQuestionType() { - return this.questionType; - } - - public void setQuestionType(String questionType) { - this.questionType = questionType; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getReviewPoint() { - return reviewPoint; - } - - public void setReviewPoint(String reviewPoint) { - this.reviewPoint = reviewPoint; - } - - public String getYear() { - return year; - } - - public void setYear(String year) { - this.year = year; - } - - public Integer getScore() { - return score; - } - - public void setScore(Integer score) { - this.score = score; - } - - public String getPaperId() { - return paperId; - } - - public void setPaperId(String paperId) { - this.paperId = paperId; - } - - public String getCourseId() { - return courseId; - } - - public void setCourseId(String courseId) { - this.courseId = courseId; - } - - public String getCourseName() { - return courseName; - } - - public void setCourseName(String courseName) { - this.courseName = courseName; - } - - public String getChapterName() { - return chapterName; - } - - public void setChapterName(String chapterName) { - this.chapterName = chapterName; - } - - public String getSubjectId() { - return subjectId; - } - - public void setSubjectId(String subjectId) { - this.subjectId = subjectId; - } - - public String getSubjectName() { - return subjectName; - } - - public void setSubjectName(String subjectName) { - this.subjectName = subjectName; - } - - public String getAuditStatus() { - return auditStatus; - } - - public void setAuditStatus(String auditStatus) { - this.auditStatus = auditStatus; - } - -} \ No newline at end of file diff --git a/tamguo-mobile/src/main/java/com/tamguo/model/SubjectEntity.java b/tamguo-mobile/src/main/java/com/tamguo/model/SubjectEntity.java deleted file mode 100644 index 7c06e88..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/model/SubjectEntity.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.tamguo.model; - -import java.io.Serializable; -import java.util.List; - -import com.baomidou.mybatisplus.annotations.TableField; -import com.baomidou.mybatisplus.annotations.TableName; -import com.tamguo.config.dao.SuperEntity; - -@TableName(value="tiku_subject") -public class SubjectEntity extends SuperEntity implements Serializable { - - private static final long serialVersionUID = 1L; - - private String name; - - private String courseId; - - private String courseName; - - @TableField(exist=false) - private List courseList; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getCourseId() { - return courseId; - } - - public void setCourseId(String courseId) { - this.courseId = courseId; - } - - public String getCourseName() { - return courseName; - } - - public void setCourseName(String courseName) { - this.courseName = courseName; - } - - public List getCourseList() { - return courseList; - } - - public void setCourseList(List courseList) { - this.courseList = courseList; - } -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/service/ICourseService.java b/tamguo-mobile/src/main/java/com/tamguo/service/ICourseService.java deleted file mode 100644 index b65d96e..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/service/ICourseService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.tamguo.service; - -import java.util.List; -import com.tamguo.model.ChapterEntity; - -public interface ICourseService { - - // 获取科目章节 - public List findCourseChapter(String courseId); - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/service/IMenuService.java b/tamguo-mobile/src/main/java/com/tamguo/service/IMenuService.java deleted file mode 100644 index 8ea66f1..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/service/IMenuService.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.tamguo.service; - -import java.util.List; -import com.tamguo.model.MenuEntity; - -/** - * Service - 类型 - * - * @author candy.tam - * - */ -public interface IMenuService { - - /** 获取所有头部菜单 */ - public List findAllMenus(); - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/service/IQuestionService.java b/tamguo-mobile/src/main/java/com/tamguo/service/IQuestionService.java deleted file mode 100644 index de70269..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/service/IQuestionService.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.tamguo.service; - -import com.baomidou.mybatisplus.plugins.Page; -import com.tamguo.model.QuestionEntity; - -public interface IQuestionService { - - Page findPage(String chapterId , Page page); -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/service/ISubjectService.java b/tamguo-mobile/src/main/java/com/tamguo/service/ISubjectService.java deleted file mode 100644 index 0cb03dc..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/service/ISubjectService.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.tamguo.service; - -import java.util.List; -import com.tamguo.model.CourseEntity; - -public interface ISubjectService { - - public List findCourseList(String subjectId); - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/service/impl/CourseService.java b/tamguo-mobile/src/main/java/com/tamguo/service/impl/CourseService.java deleted file mode 100644 index 52368ec..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/service/impl/CourseService.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.tamguo.service.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.tamguo.dao.CourseMapper; -import com.tamguo.model.ChapterEntity; -import com.tamguo.service.ICourseService; - -@Service -public class CourseService implements ICourseService{ - - @Autowired - private CourseMapper courseMapper; - - @Override - public List findCourseChapter(String courseId) { - List chapterList = courseMapper.findByCourseId(courseId); - - // 获取根chapter UID - String rootUid = StringUtils.EMPTY; - for(int i=0 ; i entitys = new ArrayList<>(); - for(int i=0 ; i childs = new ArrayList<>(); - for(int k=0 ; k childs = entitys.get(i).getChildChapterList(); - for(int k=0 ; k tmpChilds = new ArrayList<>(); - for(int n=0 ; n implements IMenuService{ - - @Autowired - private MenuMapper menuMapper; - @Autowired - private CacheService cacheService; - - - @SuppressWarnings("unchecked") - @Override - public List findAllMenus() { - List allMenuList = ((List) cacheService.getObject("all_index_menu")); - if(allMenuList == null || allMenuList.isEmpty()){ - allMenuList = menuMapper.findAllFatherMenus(); - for(MenuEntity menu : allMenuList){ - List childSubjects = menuMapper.findMenuByParentId(menu.getUid()); - menu.setChildSubjects(childSubjects); - } - cacheService.setObject("all_index_menu", allMenuList , 2 * 60 * 60); - } - return allMenuList; - } - - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/service/impl/QuestionService.java b/tamguo-mobile/src/main/java/com/tamguo/service/impl/QuestionService.java deleted file mode 100644 index b28cd01..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/service/impl/QuestionService.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.tamguo.service.impl; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.baomidou.mybatisplus.plugins.Page; -import com.tamguo.dao.QuestionMapper; -import com.tamguo.model.QuestionEntity; -import com.tamguo.service.IQuestionService; - -@Service -public class QuestionService implements IQuestionService{ - - @Autowired - QuestionMapper questionMapper; - - @Override - public Page findPage(String chapterId, Page page) { - return page.setRecords(questionMapper.findPage(chapterId , page)); - } - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/service/impl/SubjectService.java b/tamguo-mobile/src/main/java/com/tamguo/service/impl/SubjectService.java deleted file mode 100644 index 89fd2a9..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/service/impl/SubjectService.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.tamguo.service.impl; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.tamguo.dao.CourseMapper; -import com.tamguo.model.CourseEntity; -import com.tamguo.service.ISubjectService; - -@Service -public class SubjectService implements ISubjectService{ - - @Autowired - CourseMapper courseMapper; - - @Override - public List findCourseList(String subjectId) { - return courseMapper.findBySubjectId(subjectId); - } - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/util/AbstractRunningLogHandler.java b/tamguo-mobile/src/main/java/com/tamguo/util/AbstractRunningLogHandler.java deleted file mode 100644 index feca2a1..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/util/AbstractRunningLogHandler.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.tamguo.util; - -import java.io.InterruptedIOException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -public abstract class AbstractRunningLogHandler implements LogHandler { - - private static Method getStackTraceMethod; - private static Method getClassNameMethod; - private static Method getMethodNameMethod; - private static Method getFileNameMethod; - private static Method getLineNumberMethod; - - static { - try { - Class[] noArgs = null; - getStackTraceMethod = Throwable.class.getMethod("getStackTrace", noArgs); - Class stackTraceElementClass = Class.forName("java.lang.StackTraceElement"); - getClassNameMethod = stackTraceElementClass.getMethod("getClassName", noArgs); - getMethodNameMethod = stackTraceElementClass.getMethod("getMethodName", noArgs); - getFileNameMethod = stackTraceElementClass.getMethod("getFileName", noArgs); - getLineNumberMethod = stackTraceElementClass.getMethod("getLineNumber", noArgs); - } catch (ClassNotFoundException ex) { - LogDebug.debug("will use pre-JDK 1.4 methods to determine location."); - } catch (NoSuchMethodException ex) { - LogDebug.debug("will use pre-JDK 1.4 methods to determine location."); - } - } - - /** - * 获得指定class的StackTraceElement - * - * @param t - * @param fqnOfCallingClass - * - * @return - */ - protected StackTraceElement getRunningStackTrace(Throwable t, String fqnOfCallingClass) { - if (getLineNumberMethod != null) { - try { - Object[] noArgs = null; - Object[] elements = (Object[]) getStackTraceMethod.invoke(t, noArgs); - for (int i = elements.length - 1; i >= 0; i--) { - String thisClass = (String) getClassNameMethod.invoke(elements[i], noArgs); - if (fqnOfCallingClass.equals(thisClass)) { - // 执行class名称 - String className = fqnOfCallingClass; - // 执行方法名称 - String methodName = (String) getMethodNameMethod.invoke(elements[i], noArgs); - // 执行class文件名称 - String fileName = (String) getFileNameMethod.invoke(elements[i], noArgs); - // 执行到行号 - int lineNumber = ((Integer) getLineNumberMethod.invoke(elements[i], noArgs)).intValue(); - return new StackTraceElement(className, methodName, fileName, lineNumber); - } - } - } catch (IllegalAccessException ex) { - LogDebug.debug("failed using JDK 1.4 methods", ex); - } catch (InvocationTargetException ex) { - if (ex.getTargetException() instanceof InterruptedException - || ex.getTargetException() instanceof InterruptedIOException) { - Thread.currentThread().interrupt(); - } - LogDebug.debug("failed using JDK 1.4 methods", ex); - } catch (RuntimeException ex) { - LogDebug.debug("failed using JDK 1.4 methods", ex); - } - } - return this.createDefaultStackTrace(); - } - - /** - * 创建默认StackTraceElement - * - * @return - */ - private StackTraceElement createDefaultStackTrace() { - return new StackTraceElement(this.getClass().getName(), "log", this.getClass().getName(), 0); - } - - @Override - public void info(String msg, String fqnOfCallingClass) { - } - - @Override - public void info(String msg, Throwable t, String fqnOfCallingClass) { - } - - @Override - public void error(String msg, String fqnOfCallingClass) { - } - - @Override - public void error(String msg, Throwable t, String fqnOfCallingClass) { - } - - @Override - public void debug(String msg, String fqnOfCallingClass) { - } - - @Override - public void debug(String msg, Throwable t, String fqnOfCallingClass) { - } - - @Override - public void warning(String msg, String fqnOfCallingClass) { - } - - @Override - public void warning(String msg, Throwable t, String fqnOfCallingClass) { - } - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/util/CException.java b/tamguo-mobile/src/main/java/com/tamguo/util/CException.java deleted file mode 100644 index 541a60d..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/util/CException.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.tamguo.util; - -public class CException extends RuntimeException { - - private static final long serialVersionUID = 6401592364022805815L; - - public CException() { - super(); - } - - public CException(String message, Throwable cause) { - super(message, cause); - } - - public CException(String message) { - super(message); - } - - public CException(Throwable cause) { - super(cause); - } - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/util/ExceptionSupport.java b/tamguo-mobile/src/main/java/com/tamguo/util/ExceptionSupport.java deleted file mode 100644 index 781b9a3..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/util/ExceptionSupport.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.tamguo.util; - -/** - * 统一异常处理 日志处理 - * - */ -public class ExceptionSupport { - - private final static Result failResult = Result.failResult("500"); - private static LogHandler handler = new Log4jHandler(); - - private final static String LOG_INFO_PREFIX = "--info>> "; - private final static String LOG_ERROR_PREFIX = "--error>> "; - - public static Result resolverResult(String methodInfo, Class clazz, Exception e) { - if(e instanceof CException) { - handler.info(formatInfoLevelMsg(methodInfo, e.getMessage()), clazz.getName()); - return Result.failResult(e.getMessage()); - } - handler.error(formatErrorLevelMsg(methodInfo), e, clazz.getName()); - return failResult; - } - - private static String formatInfoLevelMsg(String methodInfo, String infoMsg) { - return LOG_INFO_PREFIX + methodInfo + ": " + infoMsg; - } - - private static String formatErrorLevelMsg(String methodInfo) { - return LOG_ERROR_PREFIX + methodInfo; - } - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/util/Log4jHandler.java b/tamguo-mobile/src/main/java/com/tamguo/util/Log4jHandler.java deleted file mode 100644 index 940f15d..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/util/Log4jHandler.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.tamguo.util; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -public class Log4jHandler extends AbstractRunningLogHandler { - - private static final Logger logger = Logger.getLogger(Log4jHandler.class); - - @Override - public void info(String msg, String fqnOfCallingClass) { - logger.log(fqnOfCallingClass, Level.INFO, msg, null); - } - - @Override - public void info(String msg, Throwable t, String fqnOfCallingClass) { - logger.log(fqnOfCallingClass, Level.INFO, msg, t); - } - - @Override - public void error(String msg, String fqnOfCallingClass) { - logger.log(fqnOfCallingClass, Level.ERROR, msg, null); - } - - @Override - public void error(String msg, Throwable t, String fqnOfCallingClass) { - logger.log(fqnOfCallingClass, Level.ERROR, msg, t); - } - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/util/LogDebug.java b/tamguo-mobile/src/main/java/com/tamguo/util/LogDebug.java deleted file mode 100644 index 1caeabc..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/util/LogDebug.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.tamguo.util; - -public class LogDebug { - - private final static String DEBUG_LOG_KEY = "-- LogHandler: "; - - public static void debug(String msg) { - System.err.println(DEBUG_LOG_KEY + msg); - } - - public static void debug(String msg, Throwable t) { - System.err.println(DEBUG_LOG_KEY + msg); - if (t != null) - t.printStackTrace(System.err); - } - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/util/LogHandler.java b/tamguo-mobile/src/main/java/com/tamguo/util/LogHandler.java deleted file mode 100644 index 790e4e7..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/util/LogHandler.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.tamguo.util; - -public interface LogHandler { - - public void info(String msg, String fqnOfCallingClass); - - public void info(String msg, Throwable t, String fqnOfCallingClass); - - public void error(String msg, String fqnOfCallingClass); - - public void error(String msg, Throwable t, String fqnOfCallingClass); - - public void debug(String msg, String fqnOfCallingClass); - - public void debug(String msg, Throwable t, String fqnOfCallingClass); - - public void warning(String msg, String fqnOfCallingClass); - - public void warning(String msg, Throwable t, String fqnOfCallingClass); - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/util/ObjectUtil.java b/tamguo-mobile/src/main/java/com/tamguo/util/ObjectUtil.java deleted file mode 100644 index 41e79a0..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/util/ObjectUtil.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.tamguo.util; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; - -public class ObjectUtil extends SerializeTranscoder { - @Override - public byte[] serialize(Object value) { - if (value == null) { - throw new NullPointerException("Can't serialize null"); - } - byte[] result = null; - ByteArrayOutputStream bos = null; - ObjectOutputStream os = null; - try { - bos = new ByteArrayOutputStream(); - os = new ObjectOutputStream(bos); - os.writeObject(value); - os.close(); - bos.close(); - result = bos.toByteArray(); - } catch (IOException e) { - throw new IllegalArgumentException("Non-serializable object", e); - } finally { - close(os); - close(bos); - } - return result; - } - - @Override - public Object deserialize(byte[] in) { - Object result = null; - ByteArrayInputStream bis = null; - ObjectInputStream is = null; - try { - if (in != null) { - bis = new ByteArrayInputStream(in); - is = new ObjectInputStream(bis); - result = is.readObject(); - is.close(); - bis.close(); - } - } catch (IOException e) { - e.printStackTrace(); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } finally { - close(is); - close(bis); - } - return result; - } - - public static boolean equals(Object o1, Object o2) { - - if (o1 == o2) { - return true; - } else if (o1 == null || o2 == null) { - return false; - } else { - return o1.equals(o2); - } - } - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/util/Result.java b/tamguo-mobile/src/main/java/com/tamguo/util/Result.java deleted file mode 100644 index 8ac6e41..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/util/Result.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.tamguo.util; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class Result implements Serializable { - - private static final long serialVersionUID = -1651614836984397356L; - - private int code; - - private Object result; - - private String message; - - public static final int SUCCESS_CODE = 0; - - public static final int FAIL_CODE = 1; - - private Result() { - } - - private Result(int code, Object result, String message) { - this.code = code; - this.result = result; - this.message = message; - } - - /** - * 成功响应 - * - * @param result - * @return - */ - public static Result successResult(Object result) { - return result(SUCCESS_CODE, result, ""); - } - - public static Result successResult(Object records, Long recordSum, Long rowsOfPage) { - return successResult(records, recordSum, rowsOfPage, null); - } - - public static Result successResult(Object records, Long recordSum, Long rowsOfPage, Object userData) { - Map result = resultOfList(records, recordSum, rowsOfPage, userData); - - return successResult(result); - } - - public static Map resultOfList(Object records, Long recordSum, Long rowsOfPage) { - return resultOfList(records, recordSum, rowsOfPage, null); - } - - public static Map resultOfList(Object Obj, Long records, Long rowsOfPage, Object userData) { - Map result = new HashMap(); - result.put("rows", Obj); - result.put("records", records); - result.put("total", rowsOfPage); - if (null != userData) { - result.put("userdata", userData); - } - ; - return result; - } - - public static Map jqGridResult(List list, long totalCount, int pageSize, int currPage, - int totalPage) { - Map result = new HashMap(); - result.put("list", list); - result.put("totalCount", totalCount); - result.put("pageSize", pageSize); - result.put("currPage", currPage); - result.put("totalPage", totalPage); - return result; - } - - /** - * 失败响应 - * - * @param errorMsg - * @return - */ - public static Result failResult(String errorMsg) { - return result(FAIL_CODE, "", errorMsg); - } - - public static Result result(int code, Object result, String message) { - Result res = new Result(code, result, message); - return res; - } - - public int getCode() { - return code; - } - - public Object getResult() { - return result; - } - - public String getMessage() { - return message; - } - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/util/SerializeTranscoder.java b/tamguo-mobile/src/main/java/com/tamguo/util/SerializeTranscoder.java deleted file mode 100644 index b7ee8ae..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/util/SerializeTranscoder.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.tamguo.util; - -import java.io.Closeable; - -public abstract class SerializeTranscoder { - - public abstract byte[] serialize(Object value); - - public abstract Object deserialize(byte[] in); - - public void close(Closeable closeable) { - if (closeable != null) { - try { - closeable.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - } -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/util/Setting.java b/tamguo-mobile/src/main/java/com/tamguo/util/Setting.java deleted file mode 100644 index e639124..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/util/Setting.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.tamguo.util; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -/** - * Setting - 系统 - * - * @author candy.tam - * - */ -@Component -public final class Setting { - - /** 域名 */ - @Value(value="${domain.name}") - public String domain; - - /**站点编号 **/ - @Value(value="${sitenum}") - private String sitenum; - - public String getSitenum() { - return sitenum; - } - public void setSitenum(String sitenum) { - this.sitenum = sitenum; - } - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/util/XMLConfiguration.java b/tamguo-mobile/src/main/java/com/tamguo/util/XMLConfiguration.java deleted file mode 100644 index 0af4f73..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/util/XMLConfiguration.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.tamguo.util; - -import java.io.IOException; -import java.io.InputStream; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -import org.w3c.dom.Document; - -public class XMLConfiguration { - private Document document = null; - - public boolean readConfigFile(String configFilename) { - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - try { - DocumentBuilder db = dbf.newDocumentBuilder(); - document = db.parse(configFilename); - } catch (IOException e) { - e.printStackTrace(); - } catch (Exception e) { - e.printStackTrace(); - } - if (document == null) { - return false; - } - return true; - } - - public boolean readConfigFile(InputStream stream) { - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - try { - DocumentBuilder db = dbf.newDocumentBuilder(); - document = db.parse(stream); - } catch (IOException e) { - e.printStackTrace(); - } catch (Exception e) { - e.printStackTrace(); - } - if (document == null) { - return false; - } - return true; - } - - public Document getDocument() { - return document; - } - - protected void setDocument(Document document) { - this.document = document; - } -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/web/ChapterController.java b/tamguo-mobile/src/main/java/com/tamguo/web/ChapterController.java deleted file mode 100644 index a5f51ce..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/web/ChapterController.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.tamguo.web; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.servlet.ModelAndView; - -import com.tamguo.model.ChapterEntity; -import com.tamguo.model.CourseEntity; -import com.tamguo.service.ICourseService; -import com.tamguo.service.ISubjectService; -import com.tamguo.util.ExceptionSupport; -import com.tamguo.util.Result; - -@Controller -public class ChapterController { - - @Autowired - private ISubjectService iSubjectService; - @Autowired - private ICourseService iCourseService; - - @RequestMapping(path= {"chapter/{subjectId}/{courseId}"}) - public String chapter(@PathVariable String subjectId , @PathVariable String courseId , ModelAndView model) { - model.addObject("subjectId", subjectId); - model.addObject("courseId", courseId); - return "chapter"; - } - - - @RequestMapping(path="chapter/findCourseList",method=RequestMethod.POST) - @ResponseBody - public Result findAllMenus(String subjectId) { - try { - List courseList = iSubjectService.findCourseList(subjectId); - return Result.successResult(courseList); - } catch (Exception e) { - return ExceptionSupport.resolverResult("查询科目", this.getClass(), e); - } - } - - @RequestMapping(path="chapter/findChapterList",method=RequestMethod.POST) - @ResponseBody - public Result findChapterList(String courseId) { - try { - List chapterList = iCourseService.findCourseChapter(courseId); - return Result.successResult(chapterList); - } catch (Exception e) { - return ExceptionSupport.resolverResult("查询章节", this.getClass(), e); - } - } - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/web/IndexController.java b/tamguo-mobile/src/main/java/com/tamguo/web/IndexController.java deleted file mode 100644 index 37f110e..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/web/IndexController.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.tamguo.web; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; - -@Controller -public class IndexController { - - @RequestMapping(path= {"index","/"}) - public String index() { - return "index"; - } - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/web/MenuController.java b/tamguo-mobile/src/main/java/com/tamguo/web/MenuController.java deleted file mode 100644 index 7651a32..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/web/MenuController.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.tamguo.web; - -import java.util.List; - -import javax.annotation.Resource; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -import com.tamguo.model.MenuEntity; -import com.tamguo.service.IMenuService; -import com.tamguo.util.ExceptionSupport; -import com.tamguo.util.Result; - -@Controller -public class MenuController { - - @Resource - private IMenuService iMenuService; - - @RequestMapping(path="menu/findAllMenus",method=RequestMethod.POST) - @ResponseBody - public Result findAllMenus() { - // 获取全部菜单 - try { - List allMenuList = iMenuService.findAllMenus(); - return Result.successResult(allMenuList); - } catch (Exception e) { - return ExceptionSupport.resolverResult("查询所有菜单", this.getClass(), e); - } - - } - -} diff --git a/tamguo-mobile/src/main/java/com/tamguo/web/QuestionController.java b/tamguo-mobile/src/main/java/com/tamguo/web/QuestionController.java deleted file mode 100644 index 9afe13d..0000000 --- a/tamguo-mobile/src/main/java/com/tamguo/web/QuestionController.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.tamguo.web; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.servlet.ModelAndView; - -import com.baomidou.mybatisplus.plugins.Page; -import com.tamguo.model.QuestionEntity; -import com.tamguo.service.IQuestionService; -import com.tamguo.util.Result; - -@Controller -public class QuestionController { - - @Autowired - IQuestionService iQuestionService; - - @RequestMapping(path= {"question/{subjectId}/{chapterId}-{current}-{size}"}) - public String index(@PathVariable String subjectId , @PathVariable String chapterId , - @PathVariable String current ,@PathVariable String size , - ModelAndView model) { - model.addObject("chapterId", chapterId); - model.addObject("current" , current); - model.addObject("size", size); - return "question"; - } - - @RequestMapping(path= {"question/{subjectId}/{chapterId}-{current}-{size}"} , method=RequestMethod.POST) - @ResponseBody - public Result getQuestion(@PathVariable String chapterId , - @PathVariable Integer current ,@PathVariable Integer size , - ModelAndView model) { - Page page = new Page(current, size); - return Result.successResult(iQuestionService.findPage(chapterId, page)); - } - -} diff --git a/tamguo-mobile/src/main/resources/static/js/chapter/main.js b/tamguo-mobile/src/main/resources/static/js/chapter/main.js deleted file mode 100644 index 193e56d..0000000 --- a/tamguo-mobile/src/main/resources/static/js/chapter/main.js +++ /dev/null @@ -1,53 +0,0 @@ -var vm = new Vue({ - el:'#app', - data : { - courseList:[], - chapterList:[], - secondLevelChapterList:[], - thirdLevelChapterList:[], - docked: false, - open: true, - position: 'left', - panel: '', - index:1, - secondLevelName:null, - thirdLevelName:null, - mainHttp:mainHttp - }, - methods:{ - findCourseList(subjectId){ - axios({method: 'post',url: mainHttp + 'chapter/findCourseList.html?subjectId='+subjectId}).then(function(response){ - if(response.data.code == 0){ - vm.courseList = response.data.result; - for(var i=0 ; i 0){ - vm.question = response.data.result.records[0]; - } - vm.total = response.data.result.total; - - - // 处理上一页下一页 - var previous = parseInt(current)-1; - var next = parseInt(current)+1; - if(previous <= 0){ - previous = 1; - } - if(next >= vm.total){ - next = vm.total; - } - vm.topUrl = mainHttp + 'question/'+subjectId+'/'+chapterId+'-'+previous+'-'+size+'.html'; - vm.nextUrl = mainHttp + 'question/'+subjectId+'/'+chapterId+'-'+next+'-'+size+'.html'; - } - }); - } - } -}); - -vm.findCourseList(subjectId); -vm.getQuestion(chapterId , current , size); \ No newline at end of file diff --git a/tamguo-mobile/src/main/resources/templates/chapter.html b/tamguo-mobile/src/main/resources/templates/chapter.html deleted file mode 100644 index d216c06..0000000 --- a/tamguo-mobile/src/main/resources/templates/chapter.html +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - 探果题库为老师创造价值-探果题库 - - - - - - - -
- - - - - 探果题库 - - 登录 - 注册 - - - - - - - 理科数学 - - - - 理科数学 - {{secondLevelName}} - - - - 理科数学 - {{secondLevelName}} - {{thirdLevelName}} - - - - - - {{chapter.name}} - - - - - - - - - {{chapter.name}} - - - - - - - - - {{chapter.name}} 题目数:{{chapter.questionNum}} - - - - - - - - - - - - 首页 - - - - {{course.name}} - - - - 关闭 - - - - -
- - - - - - - - \ No newline at end of file