From 430d8c36ee328d98dd304efb4b7d07ef9d0beb42 Mon Sep 17 00:00:00 2001 From: tamguo Date: Tue, 10 Jul 2018 18:10:16 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E7=AB=AF=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tamguo-mobile/.classpath | 36 ++ tamguo-mobile/.gitignore | 1 + tamguo-mobile/.project | 23 + .../org.eclipse.core.resources.prefs | 6 + .../.settings/org.eclipse.jdt.core.prefs | 5 + .../.settings/org.eclipse.m2e.core.prefs | 4 + tamguo-mobile/pom.xml | 166 ++++++ .../com/tamguo/TamguoMobileApplication.java | 36 ++ .../java/com/tamguo/config/WebConfig.java | 51 ++ .../config/dao/MyMetaObjectHandler.java | 27 + .../tamguo/config/dao/MybatisPlusConfig.java | 93 ++++ .../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 + .../main/java/com/tamguo/dao/MenuMapper.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/MenuEntity.java | 105 ++++ .../java/com/tamguo/service/IMenuService.java | 17 + .../com/tamguo/service/impl/MenuService.java | 38 ++ .../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 | 14 + .../java/com/tamguo/web/IndexController.java | 14 + .../java/com/tamguo/web/MenuController.java | 36 ++ .../com/tamguo/web/QuestionController.java | 14 + .../src/main/resources/application.properties | 61 +++ .../src/main/resources/ehcache-shiro.xml | 11 + .../src/main/resources/mappers/MenuMapper.xml | 23 + tamguo-mobile/src/main/resources/redis.xml | 9 + .../main/resources/static/js/index/main.js | 17 + .../src/main/resources/templates/chapter.html | 127 +++++ .../src/main/resources/templates/index.html | 56 ++ .../main/resources/templates/question.html | 99 ++++ 47 files changed, 2499 insertions(+) create mode 100644 tamguo-mobile/.classpath create mode 100644 tamguo-mobile/.gitignore create mode 100644 tamguo-mobile/.project create mode 100644 tamguo-mobile/.settings/org.eclipse.core.resources.prefs create mode 100644 tamguo-mobile/.settings/org.eclipse.jdt.core.prefs create mode 100644 tamguo-mobile/.settings/org.eclipse.m2e.core.prefs create mode 100644 tamguo-mobile/pom.xml create mode 100644 tamguo-mobile/src/main/java/com/tamguo/TamguoMobileApplication.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/config/WebConfig.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/config/dao/MyMetaObjectHandler.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/config/dao/MybatisPlusConfig.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/config/dao/SuperEntity.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/config/dao/SuperMapper.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/config/redis/SessionConfig.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/config/redis/SessionInitializer.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/dao/MenuMapper.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/dao/redis/CacheService.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/dao/redis/PoolConfigBean.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/dao/redis/RedisServerNodeBean.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/dao/redis/RedisXMLConfigure.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/interceptor/SettingInterptor.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/model/MenuEntity.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/service/IMenuService.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/service/impl/MenuService.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/util/AbstractRunningLogHandler.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/util/CException.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/util/ExceptionSupport.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/util/Log4jHandler.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/util/LogDebug.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/util/LogHandler.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/util/ObjectUtil.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/util/Result.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/util/SerializeTranscoder.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/util/Setting.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/util/XMLConfiguration.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/web/ChapterController.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/web/IndexController.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/web/MenuController.java create mode 100644 tamguo-mobile/src/main/java/com/tamguo/web/QuestionController.java create mode 100644 tamguo-mobile/src/main/resources/application.properties create mode 100644 tamguo-mobile/src/main/resources/ehcache-shiro.xml create mode 100644 tamguo-mobile/src/main/resources/mappers/MenuMapper.xml create mode 100644 tamguo-mobile/src/main/resources/redis.xml create mode 100644 tamguo-mobile/src/main/resources/static/js/index/main.js create mode 100644 tamguo-mobile/src/main/resources/templates/chapter.html create mode 100644 tamguo-mobile/src/main/resources/templates/index.html create mode 100644 tamguo-mobile/src/main/resources/templates/question.html diff --git a/tamguo-mobile/.classpath b/tamguo-mobile/.classpath new file mode 100644 index 0000000..16c89cc --- /dev/null +++ b/tamguo-mobile/.classpath @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tamguo-mobile/.gitignore b/tamguo-mobile/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/tamguo-mobile/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/tamguo-mobile/.project b/tamguo-mobile/.project new file mode 100644 index 0000000..1146f3d --- /dev/null +++ b/tamguo-mobile/.project @@ -0,0 +1,23 @@ + + + tamguo-mobile + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/tamguo-mobile/.settings/org.eclipse.core.resources.prefs b/tamguo-mobile/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..04cfa2c --- /dev/null +++ b/tamguo-mobile/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding//src/test/java=UTF-8 +encoding//src/test/resources=UTF-8 +encoding/=UTF-8 diff --git a/tamguo-mobile/.settings/org.eclipse.jdt.core.prefs b/tamguo-mobile/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..d59e09c --- /dev/null +++ b/tamguo-mobile/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/tamguo-mobile/.settings/org.eclipse.m2e.core.prefs b/tamguo-mobile/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..14b697b --- /dev/null +++ b/tamguo-mobile/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/tamguo-mobile/pom.xml b/tamguo-mobile/pom.xml new file mode 100644 index 0000000..24b35a6 --- /dev/null +++ b/tamguo-mobile/pom.xml @@ -0,0 +1,166 @@ + + 4.0.0 + com.tamguo + tamguo-mobile + 0.0.1-SNAPSHOT + + org.springframework.boot + spring-boot-starter-parent + 1.5.3.RELEASE + + + + + UTF-8 + 1.8 + 2.1.9 + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + org.springframework.boot + spring-boot-starter-jdbc + + + + com.baomidou + mybatis-plus-boot-starter + ${mybatis-plus-boot-starter.version} + + + tomcat-jdbc + org.apache.tomcat + + + + + + net.sourceforge.nekohtml + nekohtml + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.boot + spring-boot-starter-redis + 1.3.8.RELEASE + + + org.springframework.session + spring-session-data-redis + + + com.alibaba + fastjson + 1.2.32 + + + org.apache.shiro + shiro-spring + 1.2.5 + + + org.apache.shiro + shiro-ehcache + 1.2.5 + + + com.github.theborakompanioni + thymeleaf-extras-shiro + 1.2.1 + + + cn.songxinqiang + com.baidu.ueditor + 1.1.2-edit-1.0 + + + commons-codec + commons-codec + + + commons-fileupload + commons-fileupload + 1.3.1 + + + commons-io + commons-io + + + com.github.penggle + kaptcha + 2.3.2 + + + javax.servlet-api + javax.servlet + + + + + com.alibaba + druid + 1.0.18 + + + mysql + mysql-connector-java + + + org.apache.commons + commons-lang3 + 3.6 + + + com.aliyun + aliyun-java-sdk-dysmsapi + 1.0.0 + + + com.aliyun + aliyun-java-sdk-core + 3.2.8 + + + org.apache.commons + commons-email + 1.5 + + + + + + + org.springframework.cloud + spring-cloud-dependencies + Camden.SR6 + pom + import + + + + + + tamguo + + + org.springframework.boot + spring-boot-maven-plugin + + + + \ No newline at end of file diff --git a/tamguo-mobile/src/main/java/com/tamguo/TamguoMobileApplication.java b/tamguo-mobile/src/main/java/com/tamguo/TamguoMobileApplication.java new file mode 100644 index 0000000..6f575e6 --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/TamguoMobileApplication.java @@ -0,0 +1,36 @@ +package com.tamguo; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.web.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; +import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; + +@SpringBootApplication +@ComponentScan("com.tamguo") +public class TamguoMobileApplication { + + public static void main(String[] args) { + new SpringApplicationBuilder(TamguoMobileApplication.class).web(true).run(args); + } + + /** + * FastJson替代Jackson + * @return + */ + @Bean + public HttpMessageConverters fastJsonHttpMessageConverters() { + FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter(); + FastJsonConfig fastJsonConfig = new FastJsonConfig(); + fastJsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss"); + fastJsonConfig.setSerializerFeatures(SerializerFeature.DisableCircularReferenceDetect); + fastConverter.setFastJsonConfig(fastJsonConfig); + HttpMessageConverter converter = fastConverter; + return new HttpMessageConverters(converter); + } +} diff --git a/tamguo-mobile/src/main/java/com/tamguo/config/WebConfig.java b/tamguo-mobile/src/main/java/com/tamguo/config/WebConfig.java new file mode 100644 index 0000000..1ab8f47 --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/config/WebConfig.java @@ -0,0 +1,51 @@ +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/MyMetaObjectHandler.java b/tamguo-mobile/src/main/java/com/tamguo/config/dao/MyMetaObjectHandler.java new file mode 100644 index 0000000..f846390 --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/config/dao/MyMetaObjectHandler.java @@ -0,0 +1,27 @@ +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; + +/** + * 注入公共字段自动填充,任选注入方式即可 + */ +//@Component +public class MyMetaObjectHandler extends MetaObjectHandler { + + protected final static Logger logger = LoggerFactory.getLogger(TamguoMobileApplication.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-mobile/src/main/java/com/tamguo/config/dao/MybatisPlusConfig.java new file mode 100644 index 0000000..dbf23e7 --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/config/dao/MybatisPlusConfig.java @@ -0,0 +1,93 @@ +package com.tamguo.config.dao; + +import java.util.ArrayList; +import java.util.List; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import com.baomidou.mybatisplus.mapper.ISqlInjector; +import com.baomidou.mybatisplus.mapper.LogicSqlInjector; +import com.baomidou.mybatisplus.mapper.MetaObjectHandler; +import com.baomidou.mybatisplus.plugins.PaginationInterceptor; +import com.baomidou.mybatisplus.plugins.PerformanceInterceptor; +import com.baomidou.mybatisplus.plugins.parser.ISqlParser; +import com.baomidou.mybatisplus.plugins.parser.tenant.TenantHandler; +import com.baomidou.mybatisplus.plugins.parser.tenant.TenantSqlParser; + +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.LongValue; + +@Configuration +@MapperScan("com.tamguo.dao*") +public class MybatisPlusConfig { + + @Bean + public PerformanceInterceptor performanceInterceptor() { + return new PerformanceInterceptor(); + } + + /** + * mybatis-plus分页插件
+ * 文档:http://mp.baomidou.com
+ */ + @Bean + public PaginationInterceptor paginationInterceptor() { + PaginationInterceptor paginationInterceptor = new PaginationInterceptor(); + paginationInterceptor.setLocalPage(true);// 开启 PageHelper 的支持 + /* + * 【测试多租户】 SQL 解析处理拦截器
+ * 这里固定写成住户 1 实际情况你可以从cookie读取,因此数据看不到 【 麻花藤 】 这条记录( 注意观察 SQL )
+ */ + List sqlParserList = new ArrayList<>(); + TenantSqlParser tenantSqlParser = new TenantSqlParser(); + tenantSqlParser.setTenantHandler(new TenantHandler() { + @Override + public Expression getTenantId() { + return new LongValue(""); + } + + @Override + public String getTenantIdColumn() { + return "company_id"; + } + + @Override + public boolean doTableFilter(String tableName) { + // 这里可以判断是否过滤表 + return true; + } + }); + + + sqlParserList.add(tenantSqlParser); + paginationInterceptor.setSqlParserList(sqlParserList); + // 以下过滤方式与 @SqlParser(filter = true) 注解等效 +// paginationInterceptor.setSqlParserFilter(new ISqlParserFilter() { +// @Override +// public boolean doFilter(MetaObject metaObject) { +// MappedStatement ms = PluginUtils.getMappedStatement(metaObject); +// // 过滤自定义查询此时无租户信息约束【 麻花藤 】出现 +// if ("com.baomidou.springboot.mapper.UserMapper.selectListBySQL".equals(ms.getId())) { +// return true; +// } +// return false; +// } +// }); + return paginationInterceptor; + } + + @Bean + public MetaObjectHandler metaObjectHandler(){ + return new MyMetaObjectHandler(); + } + + /** + * 注入sql注入器 + */ + @Bean + public ISqlInjector sqlInjector(){ + return new LogicSqlInjector(); + } +} 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 new file mode 100644 index 0000000..8906d69 --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/config/dao/SuperEntity.java @@ -0,0 +1,29 @@ +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 new file mode 100644 index 0000000..6b8b4cf --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/config/dao/SuperMapper.java @@ -0,0 +1,11 @@ +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 new file mode 100644 index 0000000..6bde953 --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/config/redis/SessionConfig.java @@ -0,0 +1,27 @@ +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 new file mode 100644 index 0000000..3477712 --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/config/redis/SessionInitializer.java @@ -0,0 +1,10 @@ +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/MenuMapper.java b/tamguo-mobile/src/main/java/com/tamguo/dao/MenuMapper.java new file mode 100644 index 0000000..b05b3f9 --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/dao/MenuMapper.java @@ -0,0 +1,14 @@ +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/redis/CacheService.java b/tamguo-mobile/src/main/java/com/tamguo/dao/redis/CacheService.java new file mode 100644 index 0000000..d32772a --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/dao/redis/CacheService.java @@ -0,0 +1,491 @@ +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 new file mode 100644 index 0000000..f94027e --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/dao/redis/PoolConfigBean.java @@ -0,0 +1,47 @@ +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 new file mode 100644 index 0000000..11f2006 --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/dao/redis/RedisServerNodeBean.java @@ -0,0 +1,53 @@ +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 new file mode 100644 index 0000000..ae79ea4 --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/dao/redis/RedisXMLConfigure.java @@ -0,0 +1,175 @@ +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 new file mode 100644 index 0000000..3b956d6 --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/interceptor/SettingInterptor.java @@ -0,0 +1,39 @@ +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/MenuEntity.java b/tamguo-mobile/src/main/java/com/tamguo/model/MenuEntity.java new file mode 100644 index 0000000..04f9ffe --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/model/MenuEntity.java @@ -0,0 +1,105 @@ +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.math.BigInteger; +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 BigInteger 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 BigInteger getParentId() { + return this.parentId; + } + + public void setParentId(BigInteger 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/service/IMenuService.java b/tamguo-mobile/src/main/java/com/tamguo/service/IMenuService.java new file mode 100644 index 0000000..8ea66f1 --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/service/IMenuService.java @@ -0,0 +1,17 @@ +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/impl/MenuService.java b/tamguo-mobile/src/main/java/com/tamguo/service/impl/MenuService.java new file mode 100644 index 0000000..598d6cc --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/service/impl/MenuService.java @@ -0,0 +1,38 @@ +package com.tamguo.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import com.tamguo.dao.MenuMapper; +import com.tamguo.dao.redis.CacheService; +import com.tamguo.model.MenuEntity; +import com.tamguo.service.IMenuService; + +@Service +public class MenuService extends ServiceImpl 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/util/AbstractRunningLogHandler.java b/tamguo-mobile/src/main/java/com/tamguo/util/AbstractRunningLogHandler.java new file mode 100644 index 0000000..feca2a1 --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/util/AbstractRunningLogHandler.java @@ -0,0 +1,114 @@ +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 new file mode 100644 index 0000000..541a60d --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/util/CException.java @@ -0,0 +1,23 @@ +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 new file mode 100644 index 0000000..781b9a3 --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/util/ExceptionSupport.java @@ -0,0 +1,32 @@ +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 new file mode 100644 index 0000000..940f15d --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/util/Log4jHandler.java @@ -0,0 +1,30 @@ +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 new file mode 100644 index 0000000..1caeabc --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/util/LogDebug.java @@ -0,0 +1,17 @@ +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 new file mode 100644 index 0000000..790e4e7 --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/util/LogHandler.java @@ -0,0 +1,21 @@ +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 new file mode 100644 index 0000000..41e79a0 --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/util/ObjectUtil.java @@ -0,0 +1,69 @@ +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 new file mode 100644 index 0000000..8ac6e41 --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/util/Result.java @@ -0,0 +1,105 @@ +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 new file mode 100644 index 0000000..b7ee8ae --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/util/SerializeTranscoder.java @@ -0,0 +1,20 @@ +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 new file mode 100644 index 0000000..e639124 --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/util/Setting.java @@ -0,0 +1,30 @@ +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 new file mode 100644 index 0000000..0af4f73 --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/util/XMLConfiguration.java @@ -0,0 +1,53 @@ +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 new file mode 100644 index 0000000..9917e9e --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/web/ChapterController.java @@ -0,0 +1,14 @@ +package com.tamguo.web; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller +public class ChapterController { + + @RequestMapping(path= {"chapter"}) + public String index() { + return "chapter"; + } + +} diff --git a/tamguo-mobile/src/main/java/com/tamguo/web/IndexController.java b/tamguo-mobile/src/main/java/com/tamguo/web/IndexController.java new file mode 100644 index 0000000..37f110e --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/web/IndexController.java @@ -0,0 +1,14 @@ +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 new file mode 100644 index 0000000..7e0fe58 --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/web/MenuController.java @@ -0,0 +1,36 @@ +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 iSubjectService; + + @RequestMapping(path="menu/findAllMenus",method=RequestMethod.POST) + @ResponseBody + public Result findAllMenus() { + // 获取全部菜单 + try { + List allMenuList = iSubjectService.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 new file mode 100644 index 0000000..ddcdc9a --- /dev/null +++ b/tamguo-mobile/src/main/java/com/tamguo/web/QuestionController.java @@ -0,0 +1,14 @@ +package com.tamguo.web; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller +public class QuestionController { + + @RequestMapping(path= {"question","/"}) + public String index() { + return "question"; + } + +} diff --git a/tamguo-mobile/src/main/resources/application.properties b/tamguo-mobile/src/main/resources/application.properties new file mode 100644 index 0000000..0c1f8c7 --- /dev/null +++ b/tamguo-mobile/src/main/resources/application.properties @@ -0,0 +1,61 @@ +sitenum=3 +domain.name=http://localhost:8081/ +server.port=8081 +jasypt.encryptor.password=tamguo + +spring.datasource.connectionProperties=druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 +spring.datasource.driver-class-name=com.mysql.jdbc.Driver +spring.datasource.filters=stat,wall,log4j +spring.datasource.initialSize=5 +spring.datasource.maxActive=20 +spring.datasource.maxPoolPreparedStatementPerConnectionSize=20 +spring.datasource.maxWait=60000 +spring.datasource.minEvictableIdleTimeMillis=300000 +spring.datasource.minIdle=5 +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://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.global-config.id-type=5 +mybatis-plus.global-config.field-strategy=2 +mybatis-plus.global-config.db-column-underline=true +mybatis-plus.global-config.refresh-mapper=true +mybatis-plus.global-config.key-generator=com.baomidou.mybatisplus.incrementer.H2KeyGenerator +mybatis-plus.global-config.logic-delete-value=0 +mybatis-plus.global-config.logic-not-delete-value=1 +mybatis-plus.global-config.sql-injector=com.baomidou.mybatisplus.mapper.LogicSqlInjector +mybatis-plus.global-config.meta-object-handler=com.tamguo.config.dao.MyMetaObjectHandler +mybatis-plus.global-config.sql-parser-cache=true +mybatis-plus.configuration.map-underscore-to-camel-case=true +mybatis-plus.configuration.cache-enabled=false + +spring.thymeleaf.prefix=classpath:/templates/ +spring.thymeleaf.suffix=.html +spring.thymeleaf.mode=LEGACYHTML5 +spring.thymeleaf.encoding=UTF-8 +spring.thymeleaf.content-type=text/html +spring.thymeleaf.cache=false + +redis.hostname=47.100.175.14 +redis.port=6379 +redis.password= + +logging.level.root=INFO +logging.level.org.springframework.web=INFO +logging.file=/home/webdata/log/tamguo.log +logging.pattern.console=%d{yyyy/MM/dd-HH:mm:ss} [%thread] %-5level %logger- %msg%n +logging.pattern.file=%d{yyyy/MM/dd-HH:mm} [%thread] %-5level %logger- %msg%n + +server.compression.enabled=true +server.compression.mime-types=application/json,application/xml,text/html,text/xml,text/plain + +file.storage.path=/home/webdata/files/ \ No newline at end of file diff --git a/tamguo-mobile/src/main/resources/ehcache-shiro.xml b/tamguo-mobile/src/main/resources/ehcache-shiro.xml new file mode 100644 index 0000000..03ae4ff --- /dev/null +++ b/tamguo-mobile/src/main/resources/ehcache-shiro.xml @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/tamguo-mobile/src/main/resources/mappers/MenuMapper.xml b/tamguo-mobile/src/main/resources/mappers/MenuMapper.xml new file mode 100644 index 0000000..f71e955 --- /dev/null +++ b/tamguo-mobile/src/main/resources/mappers/MenuMapper.xml @@ -0,0 +1,23 @@ + + + + + + + + + \ No newline at end of file diff --git a/tamguo-mobile/src/main/resources/redis.xml b/tamguo-mobile/src/main/resources/redis.xml new file mode 100644 index 0000000..4055e0d --- /dev/null +++ b/tamguo-mobile/src/main/resources/redis.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/tamguo-mobile/src/main/resources/static/js/index/main.js b/tamguo-mobile/src/main/resources/static/js/index/main.js new file mode 100644 index 0000000..7d81cc9 --- /dev/null +++ b/tamguo-mobile/src/main/resources/static/js/index/main.js @@ -0,0 +1,17 @@ +var vm = new Vue({ + el:'#app', + data : { + menus:[] + }, + methods:{ + findAllMenus(){ + axios({method: 'post',url: mainHttp + 'menu/findAllMenus.html'}).then(function(response){ + if(response.data.code == 0){ + vm.menus = response.data.result; + } + }); + } + } +}); + +vm.findAllMenus(); \ 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 new file mode 100644 index 0000000..7e71f81 --- /dev/null +++ b/tamguo-mobile/src/main/resources/templates/chapter.html @@ -0,0 +1,127 @@ + + + + + + + MUSEUI Demo + + + + + + +
+ + + + + 探果题库 + + 登录 + 注册 + + + + + + + + 当前位置 + 理科数学 + 第一章 社会工作概述 + + + + 第一章 社会工作概述 + + + + 1.1 社区的含义、要素及功能 + + 1 社会工作的含义、目标与功能 + + + + + + + + + + + + + + 1.2 社区工作的含义及特点 + + + 1 社会工作的含义、目标与功能 + + + + + + 第一章 社会工作概述 + + + + 1.1 社区的含义、要素及功能 + + 1 社会工作的含义、目标与功能 + + + + + + + + + + + + + + 1.2 社区工作的含义及特点 + + + 1 社会工作的含义、目标与功能 + + + + + + + + 理科数学 + + + 文科数学 + + + 物理 + + + 英语 + + + 关闭 + + + + +
+ + + + + + \ No newline at end of file diff --git a/tamguo-mobile/src/main/resources/templates/index.html b/tamguo-mobile/src/main/resources/templates/index.html new file mode 100644 index 0000000..c0a75c9 --- /dev/null +++ b/tamguo-mobile/src/main/resources/templates/index.html @@ -0,0 +1,56 @@ + + + + + + + MUSEUI Demo + + + + + + + +
+ + + + + 探果题库 + 登录 + 注册 + + + + {{item.name}} + + {{it.name}} + + + + + + + + +
+ + + + + + + + \ No newline at end of file diff --git a/tamguo-mobile/src/main/resources/templates/question.html b/tamguo-mobile/src/main/resources/templates/question.html new file mode 100644 index 0000000..7e18167 --- /dev/null +++ b/tamguo-mobile/src/main/resources/templates/question.html @@ -0,0 +1,99 @@ + + + + + + + MUSEUI Demo + + + + + + + +
+ + + + + 探果题库 + + 登录 + 注册 + + + + + + +

如图,圆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 + + + +

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

+
+ +
+ + + + + + 理科数学 + + + 文科数学 + + + 物理 + + + 英语 + + + 关闭 + + + + + + + + + + +
+ + + + + + \ No newline at end of file