移动端初始化

main
tamguo 7 years ago
parent b37b979778
commit 430d8c36ee

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

@ -0,0 +1 @@
/target/

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>tamguo-mobile</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

@ -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/<project>=UTF-8

@ -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

@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

@ -0,0 +1,166 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tamguo</groupId>
<artifactId>tamguo-mobile</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<mybatis-plus-boot-starter.version>2.1.9</mybatis-plus-boot-starter.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<!-- mybatis-plus begin -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatis-plus-boot-starter.version}</version>
<exclusions>
<exclusion>
<artifactId>tomcat-jdbc</artifactId>
<groupId>org.apache.tomcat</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- mybatis-plus end -->
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
<version>1.3.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.32</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-ehcache</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>com.github.theborakompanioni</groupId>
<artifactId>thymeleaf-extras-shiro</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>cn.songxinqiang</groupId>
<artifactId>com.baidu.ueditor</artifactId>
<version>1.1.2-edit-1.0</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>com.github.penggle</groupId>
<artifactId>kaptcha</artifactId>
<version>2.3.2</version>
<exclusions>
<exclusion>
<artifactId>javax.servlet-api</artifactId>
<groupId>javax.servlet</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.18</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.6</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>3.2.8</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
<version>1.5</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Camden.SR6</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<finalName>tamguo</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

@ -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);
}
/**
* FastJsonJackson
* @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);
}
}

@ -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"));
}
};
}
}

@ -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("更新的时候干点不可描述的事情");
}
}

@ -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<br>
* http://mp.baomidou.com<br>
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
paginationInterceptor.setLocalPage(true);// 开启 PageHelper 的支持
/*
* SQL <br>
* 1 cookie SQL <br>
*/
List<ISqlParser> 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();
}
}

@ -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<T extends Model<?>> extends Model<T> {
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;
}
}

@ -0,0 +1,11 @@
package com.tamguo.config.dao;
import com.baomidou.mybatisplus.mapper.BaseMapper;
/**
* mapper mp
*/
public interface SuperMapper<T> extends BaseMapper<T> {
// 这里可以放一些公共的方法
}

@ -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;
}
}

@ -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);
}
}

@ -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<MenuEntity>{
public List<MenuEntity> findMenuByParentId(String parentId);
public List<MenuEntity> findAllFatherMenus();
}

@ -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);
}
}
/**
* valuekey,
*
* @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);
}
/**
* valuekey valuescore
*
* @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);
}
}
/**
* memberScore
* @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);
}
}
/**
* valuekey,
*
* @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);
}
}
/**
* valuekey, setExpirefalse, 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<String>
*/
public Set<String> 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<String> getListHead(String key) {
key = getPreKey(key);
ShardedJedis conn = null;
try {
conn = redisXMLConfigure.getConnection();
List<String> 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<String, String> 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<String, String> 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);
}
}
/**
* mapfield
*
* @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);
}
}
/**
* keystring1
*
* @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);
}
}
/**
* keystring1
*
* @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;
}
}

@ -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 + "]";
}
}

@ -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 + "]";
}
}

@ -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<RedisServerNodeBean> 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;
}
/**
* redisserver
*/
private List<RedisServerNodeBean> initRedisServerNodeBeans() {
List<RedisServerNodeBean> redisServers = new ArrayList<RedisServerNodeBean>();
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<JedisShardInfo> getJedisShardInfo(List<RedisServerNodeBean> 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<JedisShardInfo> servers = new ArrayList<JedisShardInfo>(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;
}
/*
* rediskey
*/
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();
}
}

@ -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 {
}
}

@ -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<MenuEntity> 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<MenuEntity> 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<MenuEntity> getChildSubjects() {
return childSubjects;
}
public void setChildSubjects(List<MenuEntity> 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;
}
}

@ -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<MenuEntity> findAllMenus();
}

@ -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<MenuMapper, MenuEntity> implements IMenuService{
@Autowired
private MenuMapper menuMapper;
@Autowired
private CacheService cacheService;
@SuppressWarnings("unchecked")
@Override
public List<MenuEntity> findAllMenus() {
List<MenuEntity> allMenuList = ((List<MenuEntity>) cacheService.getObject("all_index_menu"));
if(allMenuList == null || allMenuList.isEmpty()){
allMenuList = menuMapper.findAllFatherMenus();
for(MenuEntity menu : allMenuList){
List<MenuEntity> childSubjects = menuMapper.findMenuByParentId(menu.getUid());
menu.setChildSubjects(childSubjects);
}
cacheService.setObject("all_index_menu", allMenuList , 2 * 60 * 60);
}
return allMenuList;
}
}

@ -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.");
}
}
/**
* classStackTraceElement
*
* @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) {
}
}

@ -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);
}
}

@ -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;
}
}

@ -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);
}
}

@ -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);
}
}

@ -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);
}

@ -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);
}
}
}

@ -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<String, Object> result = resultOfList(records, recordSum, rowsOfPage, userData);
return successResult(result);
}
public static Map<String, Object> resultOfList(Object records, Long recordSum, Long rowsOfPage) {
return resultOfList(records, recordSum, rowsOfPage, null);
}
public static Map<String, Object> resultOfList(Object Obj, Long records, Long rowsOfPage, Object userData) {
Map<String, Object> result = new HashMap<String, Object>();
result.put("rows", Obj);
result.put("records", records);
result.put("total", rowsOfPage);
if (null != userData) {
result.put("userdata", userData);
}
;
return result;
}
public static Map<String, Object> jqGridResult(List<?> list, long totalCount, int pageSize, int currPage,
int totalPage) {
Map<String, Object> result = new HashMap<String, Object>();
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;
}
}

@ -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();
}
}
}
}

@ -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;
}
}

@ -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;
}
}

@ -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";
}
}

@ -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";
}
}

@ -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<MenuEntity> allMenuList = iSubjectService.findAllMenus();
return Result.successResult(allMenuList);
} catch (Exception e) {
return ExceptionSupport.resolverResult("查询所有菜单", this.getClass(), e);
}
}
}

@ -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";
}
}

@ -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/

@ -0,0 +1,11 @@
<ehcache updateCheck="false" name="shiroCache">
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="false"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
/>
</ehcache>

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tamguo.dao.MenuMapper">
<select id="findMenuByParentId" resultType="MenuEntity">
SELECT
uid,name,parent_id,pinyin,is_show,orders,url,reserve_1
FROM
tiku_menu
where parent_id = #{parentId}
order by orders desc
</select>
<select id="findAllFatherMenus" resultType="MenuEntity">
SELECT
uid,name,parent_id,pinyin,is_show,orders,url,reserve_1
FROM
tiku_menu
where parent_id = 1
order by orders desc
</select>
</mapper>

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<redis>
<preKey value="TAMGUO:" />
<pool maxActive="50" maxIdle="20" maxWait="1000" />
<servers>
<!-- test -->
<server ip="47.100.175.14" port="6379"/>
</servers>
</redis>

@ -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();

@ -0,0 +1,127 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0, user-scalable=no">
<title>MUSEUI Demo</title>
<!-- 引入 FrozenUI -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/muse-ui@3.0.0-rc.5/dist/muse-ui.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic">
<link rel="stylesheet" href="https://cdn.bootcss.com/material-design-icons/3.0.1/iconfont/material-icons.css">
</head>
<body>
<div id="app">
<mu-appbar style="width: 100%;" color="primary">
<mu-button icon slot="left" @click="open = true">
<mu-icon value="menu"></mu-icon>
</mu-button>
探果题库
<mu-button flat slot="right">登录</mu-button>
<mu-button flat slot="right">注册</mu-button>
</mu-appbar>
<mu-container>
<mu-container>
<mu-breadcrumbs divider="—">
<mu-icon value="chevron_right" slot="divider"></mu-icon>
<mu-breadcrumbs-item :disabled="true">当前位置</mu-breadcrumbs-item>
<mu-breadcrumbs-item :disabled="true">理科数学</mu-breadcrumbs-item>
<mu-breadcrumbs-item :disabled="true">第一章 社会工作概述</mu-breadcrumbs-item>
</mu-breadcrumbs>
</mu-container>
<mu-list textline="three-line">
<mu-sub-header>第一章 社会工作概述</mu-sub-header>
<mu-divider></mu-divider>
<mu-list-item avatar :ripple="true" button href="question">
<mu-list-item-content>
1.1 社区的含义、要素及功能</mu-list-item-title>
<mu-list-item-sub-title>
1 社会工作的含义、目标与功能
</mu-list-item-sub-title>
</mu-list-item-content>
<mu-list-item-action>
<mu-badge content="12" circle color="secondary">
<mu-button icon>
<mu-icon value="help"></mu-icon>
</mu-button>
</mu-badge>
</mu-list-item-action>
</mu-list-item>
<mu-divider></mu-divider>
<mu-list-item avatar :ripple="false" button>
<mu-list-item-content>
1.2 社区工作的含义及特点
</mu-list-item-title>
<mu-list-item-sub-title>
1 社会工作的含义、目标与功能
</mu-list-item-sub-title>
</mu-list-item-content>
</mu-list-item>
<mu-divider></mu-divider>
<mu-sub-header>第一章 社会工作概述</mu-sub-header>
<mu-divider></mu-divider>
<mu-list-item avatar :ripple="false" button href="question">
<mu-list-item-content>
1.1 社区的含义、要素及功能</mu-list-item-title>
<mu-list-item-sub-title>
1 社会工作的含义、目标与功能
</mu-list-item-sub-title>
</mu-list-item-content>
<mu-list-item-action>
<mu-badge content="12" circle color="secondary">
<mu-button icon>
<mu-icon value="help"></mu-icon>
</mu-button>
</mu-badge>
</mu-list-item-action>
</mu-list-item>
<mu-divider></mu-divider>
<mu-list-item avatar :ripple="false" button>
<mu-list-item-content>
1.2 社区工作的含义及特点
</mu-list-item-title>
<mu-list-item-sub-title>
1 社会工作的含义、目标与功能
</mu-list-item-sub-title>
</mu-list-item-content>
</mu-list-item>
</mu-list>
<mu-drawer :open.sync="open" :docked="docked" :right="position === 'right'">
<mu-list>
<mu-list-item button>
<mu-list-item-title>理科数学</mu-list-item-title>
</mu-list-item>
<mu-list-item button>
<mu-list-item-title>文科数学</mu-list-item-title>
</mu-list-item>
<mu-list-item button>
<mu-list-item-title>物理</mu-list-item-title>
</mu-list-item>
<mu-list-item button>
<mu-list-item-title>英语</mu-list-item-title>
</mu-list-item>
<mu-list-item @click="open = false" button>
<mu-list-item-title>关闭</mu-list-item-title>
</mu-list-item>
</mu-list>
</mu-drawer>
<mu-container>
</div>
</body>
<!-- 引入 Vue -->
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16"></script>
<script src="https://cdn.jsdelivr.net/npm/muse-ui@3.0.0-rc.5/dist/muse-ui.min.js"></script>
<script type="text/javascript">
new Vue({data:{docked: false,
open: true,
position: 'left',panel: ''},methods: {
toggle (panel) {
this.panel = panel === this.panel ? '' : panel;
}
}}).$mount('#app')
</script>
</html>

@ -0,0 +1,56 @@
<!DOCTYPE html>
<html lang="Zh-hans" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0, user-scalable=no">
<title>MUSEUI Demo</title>
<!-- 引入 FrozenUI -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/muse-ui@3.0.0-rc.5/dist/muse-ui.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic">
<link rel="stylesheet" href="https://cdn.bootcss.com/material-design-icons/3.0.1/iconfont/material-icons.css">
<style type="text/css">
.mu-appbar-header {
position: fixed;
left: 0;
right: 0;
top: 0;
z-index: 101;
overflow: hidden
}
</style>
</head>
<body>
<div id="app">
<mu-appbar style="width: 100%;" color="primary" class="mu-appbar-header">
<mu-button icon slot="left">
<mu-icon value="menu"></mu-icon>
</mu-button>
探果题库
<mu-button flat slot="right">登录</mu-button>
<mu-button flat slot="right">注册</mu-button>
</mu-appbar>
<mu-paper :z-depth="1" class="demo-list-wrap" style="margin-top:70px;">
<mu-list :item="item" v-for="item in menus">
<mu-sub-header>{{item.name}}</mu-sub-header>
<mu-list-item avatar button :ripple="true" href="chapter" :item="it" v-for="it in item.childSubjects">
<mu-list-item-title>{{it.name}}</mu-list-item-title>
<mu-list-item-action>
<mu-icon value="keyboard_arrow_right"></mu-icon>
</mu-list-item-action>
</mu-list-item>
</mu-list-item>
<mu-divider></mu-divider>
</mu-list>
</mu-paper>
</div>
</body>
<!-- 引入 Vue -->
<script type="text/javascript" th:inline="javascript">
var mainHttp = [[${setting.domain}]];
</script>
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16"></script>
<script src="https://cdn.jsdelivr.net/npm/muse-ui@3.0.0-rc.5/dist/muse-ui.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/axios@0.18.0/dist/axios.min.js"></script>
<script th:src="${setting.domain + 'js/index/main.js'}"></script>
</html>

@ -0,0 +1,99 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0, user-scalable=no">
<title>MUSEUI Demo</title>
<!-- 引入 FrozenUI -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/muse-ui@3.0.0-rc.5/dist/muse-ui.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic">
<link rel="stylesheet" href="https://cdn.bootcss.com/material-design-icons/3.0.1/iconfont/material-icons.css">
<style type="text/css">
.mu-appbar-header {
position: fixed;
left: 0;
right: 0;
top: 0;
z-index: 101;
overflow: hidden
}
.mu-appbar-footer {
position: fixed;
left: 0;
right: 0;
bottom:0px;
z-index: 101;
overflow: hidden
}
</style>
</head>
<body>
<div id="app">
<mu-appbar style="width: 100%;" color="primary" class="mu-appbar-header">
<mu-button icon slot="left" @click="open = true">
<mu-icon value="menu"></mu-icon>
</mu-button>
探果题库
<mu-button flat slot="right">登录</mu-button>
<mu-button flat slot="right">注册</mu-button>
</mu-appbar>
<mu-container>
<mu-card style="width: 100%;margin-top: 80px;margin-bottom:80px;" raised="true">
<mu-card-text>
<p> <span> 如图圆O </span> <span class="ext_valign_sub"> 1 </span> <span> 与圆O </span> <span class="ext_valign_sub"> 2 </span> <span> 内切于点A其半径分别为r </span> <span class="ext_valign_sub"> 1 </span> <span> 与r </span> <span class="ext_valign_sub"> 2 </span> <span> (r </span> <span class="ext_valign_sub"> 1 </span> <span> &gt;r </span> <span class="ext_valign_sub"> 2 </span> <span> ).圆O </span> <span class="ext_valign_sub"> 1 </span> <span> 的弦AB交圆O </span> <span class="ext_valign_sub"> 2 </span> <span> 于点C(O </span> <span class="ext_valign_sub"> 1 </span> <span> 不在AB上)。 </span> </p>
<p> <img src="http://www.tamguo.com//files/20180706/FP161217.jpg" width="189px" height="171px" class="scale-img"> </p>
<p class="ext_text-align_left"> 求证ABAC为定值。 </p>
</mu-card-text>
<mu-card-title sub-title="答案"></mu-card-title>
<mu-card-text>
<span> B </span>
</mu-card-text>
<mu-card-title sub-title="解析"></mu-card-title>
<mu-card-text>
<p> 苯巴比妥属于巴比妥类镇静催眠药;佐匹克隆属于环吡咯酮类镇静催眠药;阿普唑仑属于苯二氮䓬类镇静催眠药,同类药物还有地西泮等,苯妥英钠属于乙内酰脲类抗癫痫药。 </p>
</mu-card-text>
</mu-card>
<mu-drawer :open.sync="open" :docked="docked" :right="position === 'right'">
<mu-list>
<mu-list-item button>
<mu-list-item-title>理科数学</mu-list-item-title>
</mu-list-item>
<mu-list-item button>
<mu-list-item-title>文科数学</mu-list-item-title>
</mu-list-item>
<mu-list-item button>
<mu-list-item-title>物理</mu-list-item-title>
</mu-list-item>
<mu-list-item button>
<mu-list-item-title>英语</mu-list-item-title>
</mu-list-item>
<mu-list-item @click="open = false" button>
<mu-list-item-title>关闭</mu-list-item-title>
</mu-list-item>
</mu-list>
</mu-drawer>
<mu-container>
<mu-bottom-nav class="mu-appbar-footer">
<mu-bottom-nav-item title="上一题" icon="keyboard_arrow_left"></mu-bottom-nav-item>
<mu-bottom-nav-item title="此章节共10题"></mu-bottom-nav-item>
<mu-bottom-nav-item title="下一题" icon="keyboard_arrow_right"></mu-bottom-nav-item>
</mu-bottom-nav>
</div>
</body>
<!-- 引入 Vue -->
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16"></script>
<script src="https://cdn.jsdelivr.net/npm/muse-ui@3.0.0-rc.5/dist/muse-ui.min.js"></script>
<script type="text/javascript">
new Vue({data:{docked: false,
open: false,
position: 'left',panel: ''}}).$mount('#app')
</script>
</html>
Loading…
Cancel
Save