| | |
| | | <curator.version>4.0.1</curator.version> |
| | | <zookeeper.version>3.4.6</zookeeper.version> |
| | | <seata.version>1.4.1</seata.version> |
| | | <kafka.client.version>0.10.1.1</kafka.client.version> |
| | | </properties> |
| | | |
| | | |
| | | <repositories> |
| | | <repository> |
| | | <id>nexus</id> |
| | | <name>nexus</name> |
| | | <url>http://193.112.35.168:8081/nexus/content/groups/public/</url> |
| | | </repository> |
| | | </repositories> |
| | | |
| | | <dependencies> |
| | | |
| | | <dependency> |
| | | <groupId>org.yeshi</groupId> |
| | | <groupId>com.yeshi</groupId> |
| | | <artifactId>utils</artifactId> |
| | | <version>1.2-SNAPSHOT</version> |
| | | <version>0.1.1</version> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>org.slf4j</groupId> |
| | |
| | | <artifactId>log4j</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | <scope>system</scope> |
| | | <systemPath>${basedir}/src/main/webapp/WEB-INF/lib/utils.jar</systemPath> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | |
| | | </dependency> |
| | | |
| | | |
| | | <!-- kafka --> |
| | | |
| | | <dependency> |
| | | <groupId>org.apache.kafka</groupId> |
| | | <artifactId>kafka-clients</artifactId> |
| | | <version>${kafka.client.version}</version> |
| | | <scope>compile</scope> |
| | | <exclusions> |
| | | <exclusion> |
| | | <artifactId>slf4j-api</artifactId> |
| | | <groupId>org.slf4j</groupId> |
| | | </exclusion> |
| | | <exclusion> |
| | | <groupId>org.slf4j</groupId> |
| | | <artifactId>slf4j-log4j12</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | |
| | | |
| | | <dependency> |
| | | <groupId>org.apache.kafka</groupId> |
| | | <artifactId>kafka_2.11</artifactId> |
| | | <version>${kafka.client.version}</version> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>org.slf4j</groupId> |
| | | <artifactId>slf4j-log4j12</artifactId> |
| | | </exclusion> |
| | | <exclusion> |
| | | <groupId>org.slf4j</groupId> |
| | | <artifactId>slf4j-log4j12</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | |
| | | |
| | | </dependencies> |
| | | |
| | |
| | | import com.yeshi.buwan.vo.video.VideoListResultVO; |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Controller; |
| | | import redis.clients.jedis.Jedis; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | |
| | | @Controller |
| | | public class UserParser { |
| | | |
| | | Logger searchKeyLogger = LoggerFactory.getLogger("searchKey"); |
| | | |
| | | |
| | | @Resource |
| | | private SystemService systemService; |
| | |
| | | private ConfigParser configParser; |
| | | @Resource |
| | | private SystemConfigService systemConfigService; |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | public void getUid(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | |
| | | return; |
| | | } |
| | | |
| | | final String id = StringUtil.Md5(String.format("%s#%s#%s#%s", acceptData.getDetailSystem().getId(), acceptData.getDevice(), key, type)); |
| | | ThreadUtil.run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | String redisKey = "search-" + id; |
| | | Jedis jedis = redisManager.getJedis(); |
| | | try { |
| | | //重复请求过滤 |
| | | if (jedis.setnx(redisKey, "1") <= 0) { |
| | | return; |
| | | } |
| | | jedis.expire(redisKey, 120); |
| | | JSONObject searchData = new JSONObject(); |
| | | searchData.put("key", key); |
| | | searchData.put("type", type); |
| | | searchData.put("detailSystemId", acceptData.getDetailSystem().getId()); |
| | | searchData.put("device", acceptData.getDevice()); |
| | | searchData.put("createTime", System.currentTimeMillis()); |
| | | searchKeyLogger.info(new Gson().toJson(searchData)); |
| | | } finally { |
| | | jedis.close(); |
| | | } |
| | | } |
| | | }); |
| | | LoggerUtil.getUserActiveLogger().info(UserActiveLogFactory.createSearch(new BaseLog(acceptData, ""), key, type)); |
| | | |
| | | int pageIndex = StringUtil.getPage(page); |
New file |
| | |
| | | package com.yeshi.buwan.dao.search; |
| | | |
| | | import com.yeshi.buwan.query.BaseQuery; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.data.mongodb.core.query.Update; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.yeshi.buwan.domain.special.SearchSpecialPosition; |
| | | import com.yeshi.buwan.dao.base.MongodbBaseDao; |
| | | |
| | | import java.util.Date; |
| | | import java.lang.String; |
| | | import java.util.ArrayList; |
| | | |
| | | |
| | | @Repository |
| | | public class SearchSpecialPositionDao extends MongodbBaseDao<SearchSpecialPosition> { |
| | | |
| | | public void updateSelective(SearchSpecialPosition bean) { |
| | | Query query = new Query(); |
| | | Update update = new Update(); |
| | | query.addCriteria(Criteria.where("id").is(bean.getId())); |
| | | if (bean.getName() != null) { |
| | | update.set("name", bean.getName()); |
| | | } |
| | | if (bean.getSystemId() != null) { |
| | | update.set("systemId", bean.getSystemId()); |
| | | } |
| | | if (bean.getCreateTime() != null) { |
| | | update.set("createTime", bean.getCreateTime()); |
| | | } |
| | | update.set("updateTime", new Date()); |
| | | update(query, update); |
| | | } |
| | | |
| | | |
| | | public List<SearchSpecialPosition> list(DaoQuery daoQuery) { |
| | | Query query = getQuery(daoQuery); |
| | | if (daoQuery.sortList != null && daoQuery.sortList.size() > 0) { |
| | | query.with(new Sort(daoQuery.sortList)); |
| | | } |
| | | query.skip((int) daoQuery.start); |
| | | query.limit(daoQuery.count); |
| | | return findList(query); |
| | | } |
| | | |
| | | public long count(DaoQuery daoQuery) { |
| | | Query query = getQuery(daoQuery); |
| | | return count(query); |
| | | } |
| | | |
| | | private Query getQuery(DaoQuery daoQuery) { |
| | | List<Criteria> andList = new ArrayList<>(); |
| | | if (daoQuery.key != null) { |
| | | andList.add(Criteria.where("name").regex(daoQuery.key)); |
| | | } |
| | | if (daoQuery.systemId != null) { |
| | | andList.add(Criteria.where("systemId").is(daoQuery.systemId)); |
| | | } |
| | | if (daoQuery.minCreateTime != null) { |
| | | andList.add(Criteria.where("createTime").gte(daoQuery.minCreateTime)); |
| | | } |
| | | if (daoQuery.maxCreateTime != null) { |
| | | andList.add(Criteria.where("createTime").lt(daoQuery.maxCreateTime)); |
| | | } |
| | | Query query = new Query(); |
| | | Criteria[] ands = new Criteria[andList.size()]; |
| | | andList.toArray(ands); |
| | | if (ands.length > 0) { |
| | | query.addCriteria(new Criteria().andOperator(ands)); |
| | | } |
| | | return query; |
| | | } |
| | | |
| | | public static class DaoQuery extends BaseQuery { |
| | | public String key; |
| | | public String systemId; |
| | | public Date minCreateTime; |
| | | public Date maxCreateTime; |
| | | public List<Sort.Order> sortList; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.dao.search; |
| | | |
| | | import com.yeshi.buwan.query.BaseQuery; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.data.mongodb.core.query.Update; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import com.yeshi.buwan.domain.special.SearchSpecialPositionMap; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.yeshi.buwan.dao.base.MongodbBaseDao; |
| | | |
| | | import java.util.Date; |
| | | import java.lang.String; |
| | | import java.lang.Integer; |
| | | import java.util.ArrayList; |
| | | |
| | | |
| | | @Repository |
| | | public class SearchSpecialPositionMapDao extends MongodbBaseDao<SearchSpecialPositionMap> { |
| | | |
| | | public void updateSelective(SearchSpecialPositionMap bean) { |
| | | Query query = new Query(); |
| | | Update update = new Update(); |
| | | query.addCriteria(Criteria.where("id").is(bean.getId())); |
| | | if (bean.getSpecialId() != null) { |
| | | update.set("specialId", bean.getSpecialId()); |
| | | } |
| | | if (bean.getPositionId() != null) { |
| | | update.set("positionId", bean.getPositionId()); |
| | | } |
| | | if (bean.getWeight() != null) { |
| | | update.set("weight", bean.getWeight()); |
| | | } |
| | | if (bean.getIcon() != null) { |
| | | update.set("icon", bean.getIcon()); |
| | | } |
| | | if (bean.getCreateTime() != null) { |
| | | update.set("createTime", bean.getCreateTime()); |
| | | } |
| | | update.set("updateTime", new Date()); |
| | | update(query, update); |
| | | } |
| | | |
| | | |
| | | public List<SearchSpecialPositionMap> list(DaoQuery daoQuery) { |
| | | Query query = getQuery(daoQuery); |
| | | if (daoQuery.sortList != null && daoQuery.sortList.size() > 0) { |
| | | query.with(new Sort(daoQuery.sortList)); |
| | | } |
| | | query.skip((int) daoQuery.start); |
| | | query.limit(daoQuery.count); |
| | | return findList(query); |
| | | } |
| | | |
| | | public long count(DaoQuery daoQuery) { |
| | | Query query = getQuery(daoQuery); |
| | | return count(query); |
| | | } |
| | | |
| | | private Query getQuery(DaoQuery daoQuery) { |
| | | List<Criteria> andList = new ArrayList<>(); |
| | | if (daoQuery.specialId != null) { |
| | | andList.add(Criteria.where("specialId").is(daoQuery.specialId)); |
| | | } |
| | | if (daoQuery.positionId != null) { |
| | | andList.add(Criteria.where("positionId").is(daoQuery.positionId)); |
| | | } |
| | | if (daoQuery.weight != null) { |
| | | andList.add(Criteria.where("weight").is(daoQuery.weight)); |
| | | } |
| | | if (daoQuery.icon != null) { |
| | | andList.add(Criteria.where("icon").is(daoQuery.icon)); |
| | | } |
| | | if (daoQuery.minCreateTime != null) { |
| | | andList.add(Criteria.where("createTime").gte(daoQuery.minCreateTime)); |
| | | } |
| | | if (daoQuery.maxCreateTime != null) { |
| | | andList.add(Criteria.where("createTime").lt(daoQuery.maxCreateTime)); |
| | | } |
| | | Query query = new Query(); |
| | | Criteria[] ands = new Criteria[andList.size()]; |
| | | andList.toArray(ands); |
| | | if (ands.length > 0) { |
| | | query.addCriteria(new Criteria().andOperator(ands)); |
| | | } |
| | | return query; |
| | | } |
| | | |
| | | public static class DaoQuery extends BaseQuery { |
| | | public String specialId; |
| | | public String positionId; |
| | | public Integer weight; |
| | | public String icon; |
| | | public Date minCreateTime; |
| | | public Date maxCreateTime; |
| | | public List<Sort.Order> sortList; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.domain.special; |
| | | |
| | | import org.springframework.data.annotation.Id; |
| | | import org.springframework.data.mongodb.core.mapping.Document; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 搜索专题位置 |
| | | */ |
| | | @Document(collection = "searchSpecialPosition") |
| | | public class SearchSpecialPosition { |
| | | |
| | | @Id |
| | | //位置主键ID |
| | | private String id; |
| | | //专题名称 |
| | | private String name; |
| | | //系统ID |
| | | private String systemId; |
| | | private Date createTime; |
| | | private Date updateTime; |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public Date getCreateTime() { |
| | | return createTime; |
| | | } |
| | | |
| | | public void setCreateTime(Date createTime) { |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | | public Date getUpdateTime() { |
| | | return updateTime; |
| | | } |
| | | |
| | | public void setUpdateTime(Date updateTime) { |
| | | this.updateTime = updateTime; |
| | | } |
| | | |
| | | public String getSystemId() { |
| | | return systemId; |
| | | } |
| | | |
| | | public void setSystemId(String systemId) { |
| | | this.systemId = systemId; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.domain.special; |
| | | |
| | | import org.springframework.data.annotation.Id; |
| | | import org.springframework.data.annotation.Transient; |
| | | import org.springframework.data.mongodb.core.mapping.Document; |
| | | |
| | | import javax.xml.parsers.SAXParserFactory; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 专题位置映射 |
| | | */ |
| | | @Document(collection = "searchSpecialPositionMap") |
| | | public class SearchSpecialPositionMap { |
| | | |
| | | @Id |
| | | //位置主键ID |
| | | private String id; |
| | | //专题ID |
| | | private String specialId; |
| | | //位置ID |
| | | private String positionId; |
| | | private Integer weight; |
| | | private String icon; |
| | | private Date createTime; |
| | | private Date updateTime; |
| | | |
| | | @Transient |
| | | private SearchSpecial special; |
| | | |
| | | public static String createId(String specialId, String positionId) { |
| | | return positionId + "#" + specialId; |
| | | } |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getSpecialId() { |
| | | return specialId; |
| | | } |
| | | |
| | | public void setSpecialId(String specialId) { |
| | | this.specialId = specialId; |
| | | } |
| | | |
| | | public String getPositionId() { |
| | | return positionId; |
| | | } |
| | | |
| | | public void setPositionId(String positionId) { |
| | | this.positionId = positionId; |
| | | } |
| | | |
| | | public Integer getWeight() { |
| | | return weight; |
| | | } |
| | | |
| | | public void setWeight(Integer weight) { |
| | | this.weight = weight; |
| | | } |
| | | |
| | | public String getIcon() { |
| | | return icon; |
| | | } |
| | | |
| | | public void setIcon(String icon) { |
| | | this.icon = icon; |
| | | } |
| | | |
| | | public Date getCreateTime() { |
| | | return createTime; |
| | | } |
| | | |
| | | public void setCreateTime(Date createTime) { |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | | public Date getUpdateTime() { |
| | | return updateTime; |
| | | } |
| | | |
| | | public void setUpdateTime(Date updateTime) { |
| | | this.updateTime = updateTime; |
| | | } |
| | | |
| | | public SearchSpecial getSpecial() { |
| | | return special; |
| | | } |
| | | |
| | | public void setSpecial(SearchSpecial special) { |
| | | this.special = special; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.log; |
| | | |
| | | import ch.qos.logback.classic.spi.ILoggingEvent; |
| | | import ch.qos.logback.core.ConsoleAppender; |
| | | import org.apache.kafka.clients.producer.Callback; |
| | | import org.apache.kafka.clients.producer.Producer; |
| | | import org.apache.kafka.clients.producer.ProducerRecord; |
| | | import org.apache.kafka.clients.producer.RecordMetadata; |
| | | |
| | | public class KafkaAppender extends ConsoleAppender<ILoggingEvent> { |
| | | |
| | | |
| | | private String bootstrapServers; |
| | | private String topic; |
| | | private String batchSize; |
| | | private String lingerMs; |
| | | private String compressionType; |
| | | private String retries; |
| | | private String maxRequestSize; |
| | | private String isSend; |
| | | |
| | | private Producer<String, String> producer; |
| | | |
| | | public KafkaAppender() { |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void start() { |
| | | super.start(); |
| | | if ("true".equals(this.isSend)) { |
| | | if (producer == null) { |
| | | producer = KafkaUtil.createProducer(this.bootstrapServers, this.batchSize, |
| | | this.lingerMs, this.compressionType, this.retries, this.maxRequestSize, "", ""); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void stop() { |
| | | super.stop(); |
| | | if ("true".equals(this.isSend)) { |
| | | this.producer.close(); |
| | | } |
| | | |
| | | System.out.println("Stopping kafkaAppender..."); |
| | | } |
| | | |
| | | @Override |
| | | protected void append(ILoggingEvent eventObject) { |
| | | byte[] byteArray; |
| | | String log; |
| | | // 对日志格式进行解码 |
| | | byteArray = this.encoder.encode(eventObject); |
| | | log = new String(byteArray); |
| | | ProducerRecord<String, String> record = new ProducerRecord<>(this.topic, log); |
| | | if (eventObject.getMarker() == null && "true".equals(this.isSend)) { |
| | | //如果需要进行分析日志,可以对record进行数据结构重构下 |
| | | producer.send(record, new Callback() { |
| | | @Override |
| | | public void onCompletion(RecordMetadata metadata, Exception exception) { |
| | | if (exception != null) { |
| | | System.out.println(String.format("Send log to kafka failed: [%s]", log)); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | public String getBootstrapServers() { |
| | | return bootstrapServers; |
| | | } |
| | | |
| | | public void setBootstrapServers(String bootstrapServers) { |
| | | this.bootstrapServers = bootstrapServers; |
| | | } |
| | | |
| | | public String getTopic() { |
| | | return topic; |
| | | } |
| | | |
| | | public void setTopic(String topic) { |
| | | this.topic = topic; |
| | | } |
| | | |
| | | public String getBatchSize() { |
| | | return batchSize; |
| | | } |
| | | |
| | | public void setBatchSize(String batchSize) { |
| | | this.batchSize = batchSize; |
| | | } |
| | | |
| | | public String getLingerMs() { |
| | | return lingerMs; |
| | | } |
| | | |
| | | public void setLingerMs(String lingerMs) { |
| | | this.lingerMs = lingerMs; |
| | | } |
| | | |
| | | public String getCompressionType() { |
| | | return compressionType; |
| | | } |
| | | |
| | | public void setCompressionType(String compressionType) { |
| | | this.compressionType = compressionType; |
| | | } |
| | | |
| | | public String getRetries() { |
| | | return retries; |
| | | } |
| | | |
| | | public void setRetries(String retries) { |
| | | this.retries = retries; |
| | | } |
| | | |
| | | public String getMaxRequestSize() { |
| | | return maxRequestSize; |
| | | } |
| | | |
| | | public void setMaxRequestSize(String maxRequestSize) { |
| | | this.maxRequestSize = maxRequestSize; |
| | | } |
| | | |
| | | public String getIsSend() { |
| | | return isSend; |
| | | } |
| | | |
| | | public void setIsSend(String isSend) { |
| | | this.isSend = isSend; |
| | | } |
| | | |
| | | public Producer<String, String> getProducer() { |
| | | return producer; |
| | | } |
| | | |
| | | public void setProducer(Producer<String, String> producer) { |
| | | this.producer = producer; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.log; |
| | | |
| | | import org.apache.kafka.clients.consumer.KafkaConsumer; |
| | | import org.apache.kafka.clients.producer.KafkaProducer; |
| | | import org.apache.kafka.clients.producer.Producer; |
| | | import org.apache.kafka.clients.producer.ProducerConfig; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Properties; |
| | | |
| | | public class KafkaUtil { |
| | | public static Producer<String, String> createProducer( |
| | | String bootstrapServers, String batchSize, String lingerMs, |
| | | String compressionType, String retries, String maxRequestSize, String username, String password) { |
| | | // 当配置项为IS_UNDEFINED时,使用默认值 |
| | | if (bootstrapServers == null) { |
| | | bootstrapServers = "kafka地址"; |
| | | } |
| | | if (batchSize.contains("IS_UNDEFINED")) { |
| | | batchSize = "50000"; |
| | | } |
| | | if (lingerMs.contains("IS_UNDEFINED")) { |
| | | lingerMs = "60000"; |
| | | } |
| | | |
| | | if (retries.contains("IS_UNDEFINED")) { |
| | | retries = "3"; |
| | | } |
| | | if (maxRequestSize.contains("IS_UNDEFINED")) { |
| | | maxRequestSize = "5242880"; |
| | | } |
| | | |
| | | Properties properties = new Properties(); |
| | | // kafka地址,集群用逗号分隔开 |
| | | properties.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); |
| | | // acks取值: |
| | | // 0: kafka不返回确认信息,不保证record是否被收到,因为没有返回所以重试机制不会生效 |
| | | // 1: partition leader确认record写入到日志中,但不保证信息是否被正确复制 |
| | | // all: leader会等待所有信息被同步后返回确认信息 |
| | | properties.put(ProducerConfig.ACKS_CONFIG, "1"); |
| | | properties.put(ProducerConfig.RETRIES_CONFIG, Integer.valueOf(retries)); |
| | | // 批量发送,当达到batch size最大值触发发送机制(10.0后支持批量发送) |
| | | properties.put(ProducerConfig.BATCH_SIZE_CONFIG, Integer.valueOf(batchSize)); |
| | | // 该配置是指在batch.size数量未达到时,指定时间内也会推送数据 |
| | | properties.put(ProducerConfig.LINGER_MS_CONFIG, Integer.valueOf(lingerMs)); |
| | | |
| | | // 配置缓存 |
| | | properties.put(ProducerConfig.BUFFER_MEMORY_CONFIG, 33554432); |
| | | if (!compressionType.contains("IS_UNDEFINED")) { |
| | | // 指定压缩算法 |
| | | // properties.put(ProducerConfig.COMPRESSION_TYPE_CONFIG, compressionType); |
| | | } |
| | | // 每个请求的消息大小 |
| | | properties.put(ProducerConfig.MAX_REQUEST_SIZE_CONFIG, Integer.valueOf(maxRequestSize)); |
| | | properties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, |
| | | "org.apache.kafka.common.serialization.StringSerializer"); |
| | | properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, |
| | | "org.apache.kafka.common.serialization.StringSerializer"); |
| | | if (!"".equals(username)) { |
| | | properties.put("security.protocol", "SASL_PLAINTEXT"); |
| | | properties.put("sasl.mechanism", "PLAIN"); |
| | | properties.put("sasl.jaas.config", |
| | | "org.apache.kafka.common.security.scram.ScramLoginModule required username=\"" + "用戶名" + "\" password=\"" + "密碼" + "\";"); |
| | | } |
| | | return new KafkaProducer<String, String>(properties); |
| | | } |
| | | |
| | | |
| | | public static KafkaConsumer<String, String> createConsumer(String servers, String topic) { |
| | | Properties props = new Properties(); |
| | | props.put("bootstrap.servers", servers); |
| | | props.put("group.id", "test"); |
| | | props.put("enable.auto.commit", true);//设置是否为自动提交 |
| | | props.put("auto.offset.reset", "earliest"); |
| | | props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer"); |
| | | props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer"); |
| | | KafkaConsumer consumer = new KafkaConsumer<String, String>(props); |
| | | consumer.subscribe(Arrays.asList(new String[]{topic})); |
| | | return consumer; |
| | | } |
| | | |
| | | } |
| | |
| | | return null; |
| | | |
| | | final IqiyiAlbum2 album = iqiyiAlbum2Dao.get(videoIqiyi2.getIqiyiId()); |
| | | if (album != null) { |
| | | // if (album != null) { |
| | | ThreadUtil.run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | CMQManager.getInstance().addUpdateResourceVideoMsg(new UpdateResourceVideoMQMsg(album.getId() + "", IqiyiUtil2.RESOURCE_ID, new Date())); |
| | | CMQManager.getInstance().addUpdateResourceVideoMsg(new UpdateResourceVideoMQMsg(videoIqiyi2.getIqiyiId() + "", IqiyiUtil2.RESOURCE_ID, new Date())); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | // } |
| | | |
| | | List<IqiyiAlbum2> album2List = new ArrayList<>(); |
| | | if (album.getFeatureAlbumId() > 0) {//单视频 |
New file |
| | |
| | | package com.yeshi.buwan.service.imp.search; |
| | | |
| | | import com.yeshi.buwan.dao.search.SearchSpecialPositionMapDao; |
| | | import com.yeshi.buwan.domain.special.SearchSpecial; |
| | | import com.yeshi.buwan.domain.special.SearchSpecialPositionMap; |
| | | import com.yeshi.buwan.exception.ParamsException; |
| | | import com.yeshi.buwan.service.inter.search.SearchSpecialPositionMapService; |
| | | import com.yeshi.buwan.service.inter.search.SearchSpecialService; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | |
| | | @Service |
| | | public class SearchSpecialPositionMapServiceImpl implements SearchSpecialPositionMapService { |
| | | |
| | | @Resource |
| | | private SearchSpecialPositionMapDao searchSpecialPositionMapDao; |
| | | |
| | | @Resource |
| | | private SearchSpecialService searchSpecialService; |
| | | |
| | | |
| | | @Override |
| | | public SearchSpecialPositionMap add(SearchSpecialPositionMap positionMap) throws ParamsException, Exception { |
| | | if (positionMap == null || positionMap.getPositionId() == null || positionMap.getSpecialId() == null) { |
| | | throw new ParamsException("参数不完整"); |
| | | } |
| | | |
| | | if (positionMap.getWeight() == null) |
| | | positionMap.setWeight(1); |
| | | |
| | | if (positionMap.getCreateTime() == null) |
| | | positionMap.setCreateTime(new Date()); |
| | | |
| | | if (positionMap.getId() == null) { |
| | | positionMap.setId(SearchSpecialPositionMap.createId(positionMap.getSpecialId(), positionMap.getPositionId())); |
| | | } |
| | | |
| | | return searchSpecialPositionMapDao.save(positionMap); |
| | | } |
| | | |
| | | @Override |
| | | public void updateSelective(SearchSpecialPositionMap positionMap) { |
| | | if (positionMap == null || positionMap.getId() == null) { |
| | | return; |
| | | } |
| | | if (positionMap.getUpdateTime() == null) { |
| | | positionMap.setUpdateTime(new Date()); |
| | | } |
| | | searchSpecialPositionMapDao.updateSelective(positionMap); |
| | | } |
| | | |
| | | @Override |
| | | public List<SearchSpecialPositionMap> listByPosition(String positionId, int page, int pageSize) { |
| | | SearchSpecialPositionMapDao.DaoQuery daoQuery = new SearchSpecialPositionMapDao.DaoQuery(); |
| | | daoQuery.positionId = positionId; |
| | | daoQuery.start = (page - 1) * pageSize; |
| | | daoQuery.count = pageSize; |
| | | daoQuery.sortList = Arrays.asList(new Sort.Order[]{ |
| | | new Sort.Order(Sort.Direction.DESC, "weight") |
| | | }); |
| | | return searchSpecialPositionMapDao.list(daoQuery); |
| | | } |
| | | |
| | | @Override |
| | | public List<SearchSpecialPositionMap> listDetailByPosition(String positionId, int page, int pageSize) { |
| | | List<SearchSpecialPositionMap> mapList = listByPosition(positionId, page, pageSize); |
| | | //批量查询ID |
| | | List<String> ids = new ArrayList<>(); |
| | | for (SearchSpecialPositionMap map : mapList) { |
| | | ids.add(map.getSpecialId()); |
| | | } |
| | | List<SearchSpecial> searchSpecials = searchSpecialService.listByIds(ids); |
| | | Map<String, SearchSpecial> maps = new HashMap<>(); |
| | | for (SearchSpecial ss : searchSpecials) { |
| | | maps.put(ss.getId(), ss); |
| | | } |
| | | |
| | | for (SearchSpecialPositionMap map : mapList) { |
| | | map.setSpecial(maps.get(map.getSpecialId())); |
| | | } |
| | | return mapList; |
| | | } |
| | | |
| | | @Override |
| | | public long countByPosition(String positionId) { |
| | | SearchSpecialPositionMapDao.DaoQuery daoQuery = new SearchSpecialPositionMapDao.DaoQuery(); |
| | | daoQuery.positionId = positionId; |
| | | return searchSpecialPositionMapDao.count(daoQuery); |
| | | } |
| | | |
| | | @Override |
| | | public List<SearchSpecialPositionMap> listBySpecial(String specialId, int page, int pageSize) { |
| | | SearchSpecialPositionMapDao.DaoQuery daoQuery = new SearchSpecialPositionMapDao.DaoQuery(); |
| | | daoQuery.specialId = specialId; |
| | | daoQuery.start = (page - 1) * pageSize; |
| | | daoQuery.count = pageSize; |
| | | daoQuery.sortList = Arrays.asList(new Sort.Order[]{ |
| | | new Sort.Order(Sort.Direction.DESC, "weight") |
| | | }); |
| | | return searchSpecialPositionMapDao.list(daoQuery); |
| | | } |
| | | |
| | | @Override |
| | | public long countBySpecial(String specialId) { |
| | | SearchSpecialPositionMapDao.DaoQuery daoQuery = new SearchSpecialPositionMapDao.DaoQuery(); |
| | | daoQuery.specialId = specialId; |
| | | return searchSpecialPositionMapDao.count(daoQuery); |
| | | } |
| | | |
| | | @Override |
| | | public void delete(String id) { |
| | | searchSpecialPositionMapDao.delete(id); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.service.imp.search; |
| | | |
| | | import com.yeshi.buwan.dao.search.SearchSpecialPositionDao; |
| | | import com.yeshi.buwan.domain.special.SearchSpecialPosition; |
| | | import com.yeshi.buwan.exception.ParamsException; |
| | | import com.yeshi.buwan.service.inter.search.SearchSpecialPositionService; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | @Service |
| | | public class SearchSpecialPositionServiceImpl implements SearchSpecialPositionService { |
| | | |
| | | @Resource |
| | | private SearchSpecialPositionDao searchSpecialPositionDao; |
| | | |
| | | @Override |
| | | public SearchSpecialPosition add(SearchSpecialPosition position) throws ParamsException, Exception { |
| | | if (position == null || StringUtil.isNullOrEmpty(position.getName()) || StringUtil.isNullOrEmpty(position.getSystemId())) { |
| | | throw new ParamsException("参数不完整"); |
| | | } |
| | | if (position.getId() == null) { |
| | | position.setId(UUID.randomUUID().toString()); |
| | | } |
| | | if (position.getCreateTime() == null) { |
| | | position.setCreateTime(new Date()); |
| | | } |
| | | //查询是否存在 |
| | | SearchSpecialPosition old = searchSpecialPositionDao.get(position.getId()); |
| | | if (old != null) |
| | | throw new Exception("位置已存在"); |
| | | searchSpecialPositionDao.save(position); |
| | | return position; |
| | | } |
| | | |
| | | @Override |
| | | public void updateSelective(SearchSpecialPosition position) { |
| | | if (position == null || position.getId() == null) |
| | | return; |
| | | if (position.getUpdateTime() == null) { |
| | | position.setUpdateTime(new Date()); |
| | | } |
| | | searchSpecialPositionDao.updateSelective(position); |
| | | } |
| | | |
| | | @Override |
| | | public List<SearchSpecialPosition> list(String systemId, String key, int page, int pageSize) { |
| | | SearchSpecialPositionDao.DaoQuery daoQuery = new SearchSpecialPositionDao.DaoQuery(); |
| | | daoQuery.key = key; |
| | | daoQuery.systemId = systemId; |
| | | daoQuery.start = (page - 1) * pageSize; |
| | | daoQuery.count = pageSize; |
| | | return searchSpecialPositionDao.list(daoQuery); |
| | | } |
| | | |
| | | @Override |
| | | public long count(String systemId, String key) { |
| | | SearchSpecialPositionDao.DaoQuery daoQuery = new SearchSpecialPositionDao.DaoQuery(); |
| | | daoQuery.key = key; |
| | | daoQuery.systemId = systemId; |
| | | return searchSpecialPositionDao.count(daoQuery); |
| | | } |
| | | |
| | | @Override |
| | | public void delete(String id) { |
| | | searchSpecialPositionDao.delete(id); |
| | | } |
| | | } |
| | |
| | | import com.yeshi.buwan.domain.special.SearchSpecial; |
| | | import com.yeshi.buwan.service.inter.search.SearchSpecialService; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<SearchSpecial> listByIds(List<String> ids) { |
| | | Query query = new Query(); |
| | | Criteria[] ors = new Criteria[ids.size()]; |
| | | for (int i = 0; i < ids.size(); i++) { |
| | | ors[i] = Criteria.where("_id").is(ids.get(0)); |
| | | } |
| | | query.addCriteria(new Criteria().orOperator(ors)); |
| | | return searchSpecialDao.findList(query); |
| | | } |
| | | |
| | | @Override |
| | | public long countSpecial(String key, String systemId) { |
| | | SearchSpecialDao.DaoQuery daoQuery = new SearchSpecialDao.DaoQuery(); |
| | | daoQuery.regexName = key; |
New file |
| | |
| | | package com.yeshi.buwan.service.inter.search; |
| | | |
| | | import com.yeshi.buwan.domain.special.SearchSpecialPosition; |
| | | import com.yeshi.buwan.domain.special.SearchSpecialPositionMap; |
| | | import com.yeshi.buwan.exception.ParamsException; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 搜索专题位置映射 |
| | | */ |
| | | public interface SearchSpecialPositionMapService { |
| | | |
| | | |
| | | /** |
| | | * 添加位置 |
| | | * |
| | | * @param positionMap |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public SearchSpecialPositionMap add(SearchSpecialPositionMap positionMap) throws ParamsException, Exception; |
| | | |
| | | /** |
| | | * 修改 |
| | | * |
| | | * @param positionMap |
| | | */ |
| | | public void updateSelective(SearchSpecialPositionMap positionMap); |
| | | |
| | | |
| | | /** |
| | | * 查询列表 |
| | | * |
| | | * @param positionId |
| | | * @param page |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | public List<SearchSpecialPositionMap> listByPosition(String positionId, int page, int pageSize); |
| | | |
| | | /** |
| | | * 查询列表详情(根据位置ID) |
| | | * |
| | | * @param positionId |
| | | * @param page |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | public List<SearchSpecialPositionMap> listDetailByPosition(String positionId, int page, int pageSize); |
| | | |
| | | public long countByPosition(String positionId); |
| | | |
| | | |
| | | /** |
| | | * 查询列表(根据专题ID) |
| | | * |
| | | * @param specialId |
| | | * @param page |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | public List<SearchSpecialPositionMap> listBySpecial(String specialId, int page, int pageSize); |
| | | |
| | | public long countBySpecial(String specialId); |
| | | |
| | | /** |
| | | * 删除 |
| | | * |
| | | * @param id |
| | | */ |
| | | public void delete(String id); |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.service.inter.search; |
| | | |
| | | import com.yeshi.buwan.domain.special.SearchSpecialPosition; |
| | | import com.yeshi.buwan.exception.ParamsException; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface SearchSpecialPositionService { |
| | | |
| | | |
| | | /** |
| | | * 添加位置 |
| | | * |
| | | * @param position |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public SearchSpecialPosition add(SearchSpecialPosition position) throws ParamsException, Exception; |
| | | |
| | | /** |
| | | * 修改 |
| | | * |
| | | * @param position |
| | | */ |
| | | public void updateSelective(SearchSpecialPosition position); |
| | | |
| | | |
| | | /** |
| | | * 列表 |
| | | * |
| | | * @param systemId |
| | | * @param key |
| | | * @param page |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | public List<SearchSpecialPosition> list(String systemId, String key, int page, int pageSize); |
| | | |
| | | public long count(String systemId, String key); |
| | | |
| | | /** |
| | | * 删除 |
| | | * |
| | | * @param id |
| | | */ |
| | | public void delete(String id); |
| | | |
| | | |
| | | } |
| | |
| | | */ |
| | | public List<SearchSpecial> listSpecial(String key, String systemId, int page, int pageSize); |
| | | |
| | | /** |
| | | * 主键查询 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | public List<SearchSpecial> listByIds(List<String> ids); |
| | | |
| | | |
| | | public long countSpecial(String key, String systemId); |
| | | |
| | |
| | | package com.yeshi.buwan.util; |
| | | |
| | | import com.alibaba.druid.pool.DruidDataSource; |
| | | import com.yeshi.buwan.dao.juhe.iqiyi.IqiyiAlbum2Dao; |
| | | import com.yeshi.buwan.dao.juhe.iqiyi.VideoIqiyi2Dao; |
| | | import com.yeshi.buwan.domain.ResourceVideo; |
| | | import com.yeshi.buwan.domain.VideoInfo; |
| | |
| | | private Iqiyi2Service iqiyi2Service; |
| | | |
| | | @Resource |
| | | private IqiyiUtil2 iqiyiUtil2; |
| | | |
| | | @Resource |
| | | private FunTV2Service funTV2Service; |
| | | |
| | | @Resource |
| | |
| | | |
| | | @Resource |
| | | private PPTVService pptvService; |
| | | |
| | | |
| | | private static boolean isInited = false; |
| | | |
| | |
| | | String key = "resourcevideo-update-" + StringUtil.Md5(videoMQMsg.getResourceId() + "#" + videoMQMsg.getId()); |
| | | //可以更新 |
| | | if (StringUtil.isNullOrEmpty(redisManager.getCommonString(key))) { |
| | | //12小时内不再更新 |
| | | redisManager.cacheCommonString(key, "1", 60 * 60 * 12); |
| | | switch (videoMQMsg.getResourceId()) { |
| | | case IqiyiUtil2 |
| | | .RESOURCE_ID: |
| | |
| | | //下架 |
| | | resourceVideoService.delete(videoIqiyi2.getVideoId() + "", videoMQMsg.getResourceId() + ""); |
| | | } |
| | | } |
| | | //删除爱奇艺资源 |
| | | iqiyi2Service.offlineIqiyiAlbum(Long.parseLong(videoMQMsg.getId())); |
| | | } else { |
| | | //保存 |
| | | iqiyiUtil2.syncByAid(iqiyiAlbum2.getId()); |
| | | } |
| | | break; |
| | | } |
| | | //12小时内不再更新 |
| | | redisManager.cacheCommonString(key, "1", 60 * 60 * 12); |
| | | |
| | | } |
| | | } |
| | | } catch (Exception e) { |
New file |
| | |
| | | package com.yeshi.buwan.util.factory; |
| | | |
| | | import com.yeshi.buwan.domain.solr.SolrShortVideo; |
| | | import com.yeshi.buwan.iqiyi.entity.IqiyiAlbum2; |
| | | import com.yeshi.buwan.iqiyi.util.IqiyiUtil2; |
| | | import com.yeshi.buwan.tencent.TencentVideoUtil; |
| | | import com.yeshi.buwan.util.TimeUtil; |
| | | import com.yeshi.buwan.util.video.shortvideo.TencentWebUtil; |
| | | |
| | | public class SolrShortVideoFactory { |
| | | |
| | | /** |
| | | * @param tencentWebVideoInfo |
| | | * @param area |
| | | * @param rootVideoType |
| | | * @return |
| | | */ |
| | | public static SolrShortVideo create(TencentWebUtil.TencentWebVideoInfo tencentWebVideoInfo, String area, int rootVideoType) { |
| | | SolrShortVideo solrShortVideo = new SolrShortVideo(); |
| | | solrShortVideo.setArea(area); |
| | | solrShortVideo.setDuration(tencentWebVideoInfo.getDuration()); |
| | | solrShortVideo.setId(SolrShortVideo.createId(TencentVideoUtil.RESOURCE_ID, tencentWebVideoInfo.getPlayUrl())); |
| | | solrShortVideo.setName(tencentWebVideoInfo.getTitle()); |
| | | solrShortVideo.setNameStr(tencentWebVideoInfo.getTitle()); |
| | | solrShortVideo.setPicture(tencentWebVideoInfo.getPicture()); |
| | | solrShortVideo.setResourceId(TencentVideoUtil.RESOURCE_ID); |
| | | solrShortVideo.setRootVideoType(rootVideoType); |
| | | solrShortVideo.setThirdUpdateTime(System.currentTimeMillis()); |
| | | return solrShortVideo; |
| | | } |
| | | |
| | | public static SolrShortVideo create(IqiyiAlbum2 album, int rootVideoType) { |
| | | int h = album.getDuration() / (60 * 60); |
| | | int m = (album.getDuration() - h * 3600) / 60; |
| | | int s = album.getDuration() % 60; |
| | | String duration = ""; |
| | | if (h > 0) { |
| | | duration += (h > 9 ? h + "" : "0" + h); |
| | | } |
| | | |
| | | if (duration.length() > 0) { |
| | | duration += ":"; |
| | | } |
| | | duration += (m > 9 ? m + "" : "0" + m); |
| | | duration += ":"; |
| | | duration += (s > 9 ? s + "" : "0" + s); |
| | | |
| | | SolrShortVideo solrShortVideo = new SolrShortVideo(); |
| | | solrShortVideo.setArea(album.getAreas()); |
| | | solrShortVideo.setDuration(duration); |
| | | solrShortVideo.setId(SolrShortVideo.createId(IqiyiUtil2.RESOURCE_ID, album.getUrl())); |
| | | solrShortVideo.setName(album.getName()); |
| | | solrShortVideo.setNameStr(album.getName()); |
| | | solrShortVideo.setPicture(album.getImageUrl()); |
| | | solrShortVideo.setResourceId(IqiyiUtil2.RESOURCE_ID); |
| | | solrShortVideo.setRootVideoType(rootVideoType); |
| | | solrShortVideo.setThirdUpdateTime(TimeUtil.convertGernalTime(album.getUpdateTime(), "yyyy-MM-dd HH:mm:dd")); |
| | | return solrShortVideo; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.yeshi.buwan.service.imp.DetailSystemConfigService; |
| | | import com.yeshi.buwan.service.inter.push.PushDeviceTokenService; |
| | | import org.yeshi.utils.StringUtil; |
| | | import org.yeshi.utils.push.*; |
| | | import org.yeshi.utils.push.entity.PushAppInfo; |
| | | import org.yeshi.utils.push.entity.PushMessage; |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | if (platform == PushDeviceToken.PushPlatform.xm) { |
| | | XiaoMiPushUtil.pushNotificationByRegIds(appInfo, message, tempTokens); |
| | | } else if (platform == PushDeviceToken.PushPlatform.hw) { |
| | | HuaWeiPushUtil.pushNotificationByTokens(appInfo, message, tempTokens); |
| | | } else if (platform == PushDeviceToken.PushPlatform.oppo) { |
| | | OppoPushUtil.pushNotificationAll(appInfo, message, tempTokens); |
| | | } else if (platform == PushDeviceToken.PushPlatform.vivo) { |
| | | VIVOPushUtil.pushNotificationByRegIds(appInfo, message, tempTokens); |
| | | } else if (platform == PushDeviceToken.PushPlatform.mz) { |
| | | MeiZuPushUtil.pushNotificationByPushId(appInfo, message, tempTokens); |
| | | } |
| | | // if (platform == PushDeviceToken.PushPlatform.xm) { |
| | | // XiaoMiPushUtil.pushNotificationByRegIds(appInfo, message, tempTokens); |
| | | // } else if (platform == PushDeviceToken.PushPlatform.hw) { |
| | | // HuaWeiPushUtil.pushNotificationByTokens(appInfo, message, tempTokens); |
| | | // } else if (platform == PushDeviceToken.PushPlatform.oppo) { |
| | | // OppoPushUtil.pushNotificationAll(appInfo, message, tempTokens); |
| | | // } else if (platform == PushDeviceToken.PushPlatform.vivo) { |
| | | // VIVOPushUtil.pushNotificationByRegIds(appInfo, message, tempTokens); |
| | | // } else if (platform == PushDeviceToken.PushPlatform.mz) { |
| | | // MeiZuPushUtil.pushNotificationByPushId(appInfo, message, tempTokens); |
| | | // } |
| | | |
| | | if (leftTokens != null && leftTokens.size() > 0) { |
| | | pushAndroidNotifycation(message, appInfo, leftTokens, platform); |
| | |
| | | package com.yeshi.buwan.util.video.shortvideo; |
| | | |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | import org.jsoup.Jsoup; |
| | | import org.jsoup.nodes.Document; |
| | | import org.jsoup.nodes.Element; |
| | |
| | | import org.yeshi.utils.HttpUtil; |
| | | |
| | | import java.net.URLDecoder; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public class TencentWebUtil { |
| | | |
| | | public static class TencentWebVideoInfo { |
| | | private String playUrl; |
| | | private String id; |
| | | private String title; |
| | | private String picture; |
| | | private String duration; |
| | | |
| | | public String getPlayUrl() { |
| | | return playUrl; |
| | | } |
| | | |
| | | public void setPlayUrl(String playUrl) { |
| | | this.playUrl = playUrl; |
| | | } |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getTitle() { |
| | | return title; |
| | | } |
| | | |
| | | public void setTitle(String title) { |
| | | this.title = title; |
| | | } |
| | | |
| | | public String getPicture() { |
| | | return picture; |
| | | } |
| | | |
| | | public void setPicture(String picture) { |
| | | this.picture = picture; |
| | | } |
| | | |
| | | public String getDuration() { |
| | | return duration; |
| | | } |
| | | |
| | | public void setDuration(String duration) { |
| | | this.duration = duration; |
| | | } |
| | | } |
| | | |
| | | |
| | | public static Map<String, String> parseParams(String url) { |
| | |
| | | } |
| | | |
| | | |
| | | public static void getVideoList(Map<String, String> params, int page) throws Exception { |
| | | /** |
| | | * 获取短视频列表 |
| | | * |
| | | * @param params |
| | | * @param page |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public static List<TencentWebVideoInfo> getVideoList(Map<String, String> params, int page) throws Exception { |
| | | if (params == null) |
| | | throw new Exception("参数为空"); |
| | | int pageSize = 30; |
| | |
| | | String result = HttpUtil.get(url, params, headers); |
| | | Document document = Jsoup.parse(result); |
| | | Elements els = document.getElementsByClass("list_item"); |
| | | |
| | | List<TencentWebVideoInfo> list = new ArrayList<>(); |
| | | for (int i = 0; i < els.size(); i++) { |
| | | Element ele = els.get(i); |
| | | String href = ele.getElementsByTag("a").get(0).attr("href"); |
| | |
| | | picture = picture.startsWith("http") ? picture : "https:" + picture; |
| | | String duration = ele.getElementsByClass("figure_caption").get(0).ownText(); |
| | | System.out.println(duration); |
| | | } |
| | | |
| | | TencentWebVideoInfo videoInfo = new TencentWebVideoInfo(); |
| | | videoInfo.setDuration(duration); |
| | | videoInfo.setId(id); |
| | | videoInfo.setPicture(picture); |
| | | videoInfo.setPlayUrl(href); |
| | | videoInfo.setTitle(title); |
| | | list.add(videoInfo); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args) throws Exception { |
| | | getVideoList(parseParams("https://v.qq.com/channel/ent?_all=1&channel=ent&iarea=2&itype=-1&listpage=1&sort=40"), 1); |
| | | List<TencentWebVideoInfo> videoInfos = getVideoList(parseParams("https://v.qq.com/channel/ent?_all=1&channel=ent&iarea=2&itype=-1&listpage=1&sort=40"), 1); |
| | | System.out.println(videoInfos); |
| | | } |
| | | } |
New file |
| | |
| | | log.config.kafka.isSend=true |
| | | log.config.kafka.bootstrapServers= 134.175.68.214:9092,134.175.68.214:9093,134.175.68.214:9094 |
| | | log.config.kafka.topic= log_buwan_search_key |
| | | log.config.kafka.batchSize=5 |
| | | log.config.kafka.lingerMs=1000 |
| | | log.config.kafka.compressionType=gzip |
| | | log.config.kafka.retries=3 |
| | | log.config.kafka.maxRequestSize=5242880 |
| | | |
| | |
| | | <!--日志展示的格式--> |
| | | <property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n"/> |
| | | |
| | | <property resource="kafka_log.properties"></property> |
| | | |
| | | <!--appender是为了配置日志信息输出到哪个地方--> |
| | | <!--控制台设置,输出到控制台中--> |
| | | <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> |
| | |
| | | </logger> |
| | | |
| | | |
| | | <appender name="KAFKA_SEARCH_KEY" class="com.yeshi.buwan.log.KafkaAppender"> |
| | | <!-- encoder必须配置, 日志格式 --> |
| | | <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> |
| | | <!--<pattern>--> |
| | | <!--%red(%d{yyyy-MM-dd HH:mm:ss.SSS}) %highlight(%-5level) %green([%thread]) %boldMagenta(%logger{10}) - %cyan(%msg%n)--> |
| | | <!--</pattern>--> |
| | | <!--为了便于分析将日志数据转为json格式--> |
| | | <pattern>${log.pattern}</pattern> |
| | | <!-- 控制台也要使用UTF-8,不要使用GBK,否则会中文乱码 --> |
| | | <charset>UTF-8</charset> |
| | | </encoder> |
| | | <bootstrapServers>${log.config.kafka.bootstrapServers}</bootstrapServers> |
| | | <topic>${log.config.kafka.topic}</topic> |
| | | <batchSize>${log.config.kafka.batchSize}</batchSize> |
| | | <lingerMs>${log.config.kafka.lingerMs}</lingerMs> |
| | | <compressionType>${log.config.kafka.compressionType}</compressionType> |
| | | <retries>${log.config.kafka.retries}</retries> |
| | | <maxRequestSize>${log.config.kafka.maxRequestSize}</maxRequestSize> |
| | | <isSend>${log.config.kafka.isSend}</isSend> |
| | | </appender> |
| | | <!-- 关键词搜索 --> |
| | | <logger name="searchKey" level="INFO" additivity="false"> |
| | | <appender-ref ref="KAFKA_SEARCH_KEY"></appender-ref> |
| | | </logger> |
| | | |
| | | |
| | | <logger name="org.hibernate.type" level="ALL" /> |
| | | <logger name="org.hibernate" level="DEBUG" /> |
| | | <logger name="org.springframework.transaction" level="INFO" /> |
New file |
| | |
| | | log.config.kafka.isSend=true |
| | | log.config.kafka.bootstrapServers= 172.16.16.38:9092,172.16.16.38:9093,172.16.16.38:9094 |
| | | log.config.kafka.topic= log_buwan_search_key |
| | | log.config.kafka.batchSize=5 |
| | | log.config.kafka.lingerMs=1000 |
| | | log.config.kafka.compressionType=gzip |
| | | log.config.kafka.retries=3 |
| | | log.config.kafka.maxRequestSize=5242880 |
| | | |
| | |
| | | <!--日志展示的格式--> |
| | | <property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n"/> |
| | | |
| | | <property resource="kafka_log.properties"></property> |
| | | |
| | | |
| | | <!--appender是为了配置日志信息输出到哪个地方--> |
| | | <!--控制台设置,输出到控制台中--> |
| | |
| | | </filter> |
| | | </appender> |
| | | |
| | | <appender name="KAFKA_SEARCH_KEY" class="com.yeshi.buwan.log.KafkaAppender"> |
| | | <!-- encoder必须配置, 日志格式 --> |
| | | <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> |
| | | <!--<pattern>--> |
| | | <!--%red(%d{yyyy-MM-dd HH:mm:ss.SSS}) %highlight(%-5level) %green([%thread]) %boldMagenta(%logger{10}) - %cyan(%msg%n)--> |
| | | <!--</pattern>--> |
| | | <!--为了便于分析将日志数据转为json格式--> |
| | | <pattern>${log.pattern}</pattern> |
| | | <!-- 控制台也要使用UTF-8,不要使用GBK,否则会中文乱码 --> |
| | | <charset>UTF-8</charset> |
| | | </encoder> |
| | | <bootstrapServers>${log.config.kafka.bootstrapServers}</bootstrapServers> |
| | | <topic>${log.config.kafka.topic}</topic> |
| | | <batchSize>${log.config.kafka.batchSize}</batchSize> |
| | | <lingerMs>${log.config.kafka.lingerMs}</lingerMs> |
| | | <compressionType>${log.config.kafka.compressionType}</compressionType> |
| | | <retries>${log.config.kafka.retries}</retries> |
| | | <maxRequestSize>${log.config.kafka.maxRequestSize}</maxRequestSize> |
| | | <isSend>${log.config.kafka.isSend}</isSend> |
| | | </appender> |
| | | |
| | | |
| | | <!--name表示为哪一个logger指定层级和输出的方式 |
| | | additivity表示叠加祖先的输出方式(默认为true,会叠加),所以com.lxc.o2o以及其子类都会输出在控制台中,因为这个logger继承了root中的appender |
| | |
| | | </logger> |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | <appender name="vipAppender" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
| | | <file>${log.filePath}/vip/vip.log</file> |
| | | <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
| | |
| | | <appender-ref ref="testAppender"></appender-ref> |
| | | </logger> |
| | | |
| | | <!-- 关键词搜索 --> |
| | | <logger name="searchKey" level="INFO" additivity="false"> |
| | | <appender-ref ref="KAFKA_SEARCH_KEY"></appender-ref> |
| | | </logger> |
| | | |
| | | |
| | | <!-- 一切logger都会继承自root,root默认的层级level为debug --> |
| | | <root> |
| | |
| | | <p class="MsoNormal" align="center" style="text-align:center;"> |
| | | Copyright © 2005-2018 影视大全布丸版权所有。</p> |
| | | </p> |
| | | <script > |
| | | window.location.href="http://h5.ysdq.yeshitv.com/abountOur/index_ios.html"; |
| | | |
| | | </script> |
| | | </body> |
| | | </html> |
| | |
| | | import com.yeshi.buwan.domain.live.*; |
| | | import com.yeshi.buwan.domain.pptv.PPTVPlayProcessRecord; |
| | | import com.yeshi.buwan.domain.special.SearchSpecial; |
| | | import com.yeshi.buwan.domain.special.SearchSpecialPosition; |
| | | import com.yeshi.buwan.domain.special.SearchSpecialPositionMap; |
| | | import com.yeshi.buwan.domain.tb.YouZhiHaoHuoGoods; |
| | | import com.yeshi.buwan.domain.video.VideoResourceVersionMap; |
| | | import com.yeshi.buwan.domain.vip.VideoBuyRecord; |
| | |
| | | @org.junit.Test |
| | | public void createDao() { |
| | | try { |
| | | SpringComponentGenerater.createMongoDao(new MongoDBDaoData.Builder().setBaseDaoClass(MongodbBaseDao.class).setDaoPackageName("com.yeshi.buwan.dao.search").setEntityClass(SearchSpecial.class).create(), "D:\\workspace\\BuWan\\src\\main\\java\\com\\yeshi\\buwan\\dao\\search\\"); |
| | | SpringComponentGenerater.createMongoDao(new MongoDBDaoData.Builder().setBaseDaoClass(MongodbBaseDao.class).setDaoPackageName("com.yeshi.buwan.dao.search").setEntityClass(SearchSpecialPosition.class).create(), "D:\\workspace\\BuWan\\src\\main\\java\\com\\yeshi\\buwan\\dao\\search\\"); |
| | | |
| | | |
| | | } catch (Exception e) { |
| | |
| | | |
| | | @Test |
| | | public void getDetail() { |
| | | IqiYiNewAPI.getAlbumOrVideoDetail(524533200L); |
| | | |
| | | iqiyiUtil2.syncByAid(222728201L); |
| | | // System.out.println(album2); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void searchKey() { |
| | | Logger logger = LoggerFactory.getLogger("searchKey"); |
| | | logger.info("{}"); |
| | | } |
| | | |
| | | private void printAction(String utdId, List<UserActiveLogInfo> infoList) { |
| | | StringBuilder builder = new StringBuilder(); |
| | | |
| | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import org.junit.Test; |
| | | import org.yeshi.utils.push.MeiZuPushUtil; |
| | | import org.yeshi.utils.push.entity.PushAppInfo; |
| | | import org.yeshi.utils.push.entity.PushMessage; |
| | | import org.yeshi.utils.push.exception.MeiZuPushException; |
| | |
| | | // e.printStackTrace(); |
| | | // } |
| | | |
| | | try { |
| | | MeiZuPushUtil.pushNotificationByPushId(createMeiZuApp(), message, Arrays.asList(new String[]{"UCI4e0f4070047c4949057e76446d6474484500447b05"})); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } catch (MeiZuPushException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | // try { |
| | | // MeiZuPushUtil.pushNotificationByPushId(createMeiZuApp(), message, Arrays.asList(new String[]{"UCI4e0f4070047c4949057e76446d6474484500447b05"})); |
| | | // } catch (IOException e) { |
| | | // e.printStackTrace(); |
| | | // } catch (MeiZuPushException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | } |
| | | |
| | | |