parent
c67654ac57
commit
0c1acdc345
@ -0,0 +1,69 @@
|
|||||||
|
package com.tamguo.config.redis;
|
||||||
|
|
||||||
|
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,47 @@
|
|||||||
|
package com.tamguo.config.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.config.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,173 @@
|
|||||||
|
package com.tamguo.config.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 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析配置redis的server列表
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 初始化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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.tamguo.config.redis;
|
||||||
|
|
||||||
|
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,53 @@
|
|||||||
|
package com.tamguo.config.redis;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,13 @@
|
|||||||
package com.tamguo.dao;
|
package com.tamguo.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
|
||||||
import com.tamguo.config.dao.SuperMapper;
|
import com.tamguo.config.dao.SuperMapper;
|
||||||
import com.tamguo.model.CrawlerQuestionEntity;
|
import com.tamguo.model.CrawlerQuestionEntity;
|
||||||
|
|
||||||
public interface CrawlerQuestionMapper extends SuperMapper<CrawlerQuestionEntity>{
|
public interface CrawlerQuestionMapper extends SuperMapper<CrawlerQuestionEntity>{
|
||||||
|
|
||||||
|
List<CrawlerQuestionEntity> queryPageOrderUid(Pagination page);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.tamguo.dao;
|
||||||
|
|
||||||
|
import com.tamguo.config.dao.SuperMapper;
|
||||||
|
import com.tamguo.model.QuestionEntity;
|
||||||
|
|
||||||
|
public interface QuestionMapper extends SuperMapper<QuestionEntity>{
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,139 @@
|
|||||||
|
package com.tamguo.model;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import com.baomidou.mybatisplus.annotations.TableName;
|
||||||
|
import com.tamguo.config.dao.SuperEntity;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The persistent class for the tiku_question database table.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@TableName(value="tiku_question")
|
||||||
|
public class QuestionEntity extends SuperEntity<QuestionEntity> implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String analysis;
|
||||||
|
|
||||||
|
private String paperId;
|
||||||
|
|
||||||
|
private String answer;
|
||||||
|
|
||||||
|
private String chapterId;
|
||||||
|
|
||||||
|
private String questionType;
|
||||||
|
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
private String subjectId;
|
||||||
|
|
||||||
|
private String courseId;
|
||||||
|
|
||||||
|
private String reviewPoint;
|
||||||
|
|
||||||
|
private String year;
|
||||||
|
|
||||||
|
private String score;
|
||||||
|
|
||||||
|
private String auditStatus;
|
||||||
|
|
||||||
|
public QuestionEntity() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAnalysis() {
|
||||||
|
return this.analysis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAnalysis(String analysis) {
|
||||||
|
this.analysis = analysis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAnswer() {
|
||||||
|
return this.answer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAnswer(String answer) {
|
||||||
|
this.answer = answer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChapterId() {
|
||||||
|
return this.chapterId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChapterId(String chapterId) {
|
||||||
|
this.chapterId = chapterId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQuestionType() {
|
||||||
|
return this.questionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuestionType(String questionType) {
|
||||||
|
this.questionType = questionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReviewPoint() {
|
||||||
|
return reviewPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReviewPoint(String reviewPoint) {
|
||||||
|
this.reviewPoint = reviewPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getYear() {
|
||||||
|
return year;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setYear(String year) {
|
||||||
|
this.year = year;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getScore() {
|
||||||
|
return score;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScore(String score) {
|
||||||
|
this.score = score;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPaperId() {
|
||||||
|
return paperId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPaperId(String paperId) {
|
||||||
|
this.paperId = paperId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCourseId() {
|
||||||
|
return courseId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCourseId(String courseId) {
|
||||||
|
this.courseId = courseId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSubjectId() {
|
||||||
|
return subjectId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubjectId(String subjectId) {
|
||||||
|
this.subjectId = subjectId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuditStatus() {
|
||||||
|
return auditStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuditStatus(String auditStatus) {
|
||||||
|
this.auditStatus = auditStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,110 @@
|
|||||||
|
package com.tamguo.model.vo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.xuxueli.crawler.annotation.PageFieldSelect;
|
||||||
|
import com.xuxueli.crawler.conf.XxlCrawlerConf;
|
||||||
|
|
||||||
|
public class QuestionVo {
|
||||||
|
|
||||||
|
// 单个题目数据
|
||||||
|
@PageFieldSelect(cssQuery=".question-box-inner .questem-inner", selectType = XxlCrawlerConf.SelectType.HTML)
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
@PageFieldSelect(cssQuery=".exam-answer-content", selectType = XxlCrawlerConf.SelectType.HTML)
|
||||||
|
private String answer;
|
||||||
|
|
||||||
|
@PageFieldSelect(cssQuery = ".exam-answer-content img", selectType = XxlCrawlerConf.SelectType.ATTR, selectVal = "abs:src")
|
||||||
|
private List<String> answerImages;
|
||||||
|
|
||||||
|
@PageFieldSelect(cssQuery=".exam-analysis .exam-analysis-content", selectType = XxlCrawlerConf.SelectType.HTML)
|
||||||
|
private String analysis;
|
||||||
|
|
||||||
|
@PageFieldSelect(cssQuery = ".exam-analysis .exam-analysis-content img", selectType = XxlCrawlerConf.SelectType.ATTR, selectVal = "abs:src")
|
||||||
|
private List<String> analysisImages;
|
||||||
|
|
||||||
|
@PageFieldSelect(cssQuery=".que-title span:eq(0)",selectType = XxlCrawlerConf.SelectType.TEXT)
|
||||||
|
private String questionType;
|
||||||
|
|
||||||
|
@PageFieldSelect(cssQuery=".que-title span:eq(1)",selectType = XxlCrawlerConf.SelectType.TEXT)
|
||||||
|
private String score;
|
||||||
|
|
||||||
|
@PageFieldSelect(cssQuery=".que-title span:eq(2)",selectType = XxlCrawlerConf.SelectType.TEXT)
|
||||||
|
private String year;
|
||||||
|
|
||||||
|
@PageFieldSelect(cssQuery=".kpoint-contain point point-item",selectType = XxlCrawlerConf.SelectType.TEXT)
|
||||||
|
private List<String> reviewPoint;
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAnalysis() {
|
||||||
|
return analysis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAnalysis(String analysis) {
|
||||||
|
this.analysis = analysis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQuestionType() {
|
||||||
|
return questionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuestionType(String questionType) {
|
||||||
|
this.questionType = questionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getScore() {
|
||||||
|
return score;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScore(String score) {
|
||||||
|
this.score = score;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAnswer() {
|
||||||
|
return answer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAnswer(String answer) {
|
||||||
|
this.answer = answer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getReviewPoint() {
|
||||||
|
return reviewPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReviewPoint(List<String> reviewPoint) {
|
||||||
|
this.reviewPoint = reviewPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getYear() {
|
||||||
|
return year;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setYear(String year) {
|
||||||
|
this.year = year;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getAnswerImages() {
|
||||||
|
return answerImages;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAnswerImages(List<String> answerImages) {
|
||||||
|
this.answerImages = answerImages;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getAnalysisImages() {
|
||||||
|
return analysisImages;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAnalysisImages(List<String> analysisImages) {
|
||||||
|
this.analysisImages = analysisImages;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.tamguo.service;
|
||||||
|
|
||||||
|
public interface IQuestionService {
|
||||||
|
/**
|
||||||
|
* 爬取章节数据
|
||||||
|
*/
|
||||||
|
void crawlerQuestion();
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
<?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.QuestionMapper">
|
||||||
|
|
||||||
|
</mapper>
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.tamguo;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
import com.tamguo.service.IQuestionService;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
public class QuestionCrawler {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
IQuestionService iQuestionService;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void crawlerSubject() throws Exception {
|
||||||
|
iQuestionService.crawlerQuestion();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue