Know almost Q project

Description: The landlord of a small master a 985, during the undergraduate and graduate failed to seriously study and practice lead to Kenji could not find a second and third tier Internet companies. So, work hard to recruit autumn, spent a few thousand dollars to buy a cow off network algorithm, java interview and other related courses, concentrated practice! To date, Huawei has got the formal Offer, Ctrip, IFLYTEK, cat's eye, Shanghai Pudong Development, CUP, Jingdong, Jingdong current tentative. The last few days before to buy and organize their own collection of algorithms courses, organized, needy students can add me q2897782560. Collection of courses include:

"Niu Cheng Yun left off network (Beginner, Advanced) algorithm"
"cow-off network algorithm topic succinctly high frequency (left Cheng Yun)"
"Cattle off net - straight BAT algorithm succinctly (left Cheng Yun),"
"cow-off network junior high school senior project (Ye gods) "
," IX "dynamic programming" series "- highly recommended, to explain the often test of the" routine "subject to dynamic programming
" algorithm interview clearance 40 stresses "- highly recommended, and the interview machine test exam topics are often spoke again
, "wins the Java interview -Offer train" - highly recommended interview "java backend engineer" essential artifact
"Intensive course IX algorithm", "Nine Chapters on the basis of the algorithm class Curriculum "
" interview algorithms October recommended "," programming algorithms base (JAVA edition) "," Deng Junhui - algorithm training camp (phase II) "
," spike the Java system optimization concurrent high performance and high combat "," Java from zero enterprise business to project combat power, "" before and after the Spring Boot with end progressive development of enterprise-class blog system "," Java concurrent programming and high concurrency solutions (complete no secret), "
a total summary

   这个项目是以现在的知乎、牛客网这类问答平台为原型,基于springboot的SSM框架的问答系统。数据库使用了redis和mysql,同时通过一个异步消息框架来实现事件的异步处理,并使用爬虫对网站进行数据填充。

Second, the source download

https://github.com/hzcforever/nowcoder-project

Third, the project involved technical point of explanation

1) + sensitive issue published word filtering

发布问题时检查标题和内容,防止xss注入,并且过滤敏感词。防止xss注入直接使用HTMLutils的方法即可实现。过滤敏感词首先需要建立一个字典树,并且读取一份保存敏感词的文本文件,然后初始化字典树。最后将过滤器作为一个服务,让需要过滤敏感词的服务进行调用即可。

2) comments and Letters station

 首先建立表comment和message分别代表评论和站内信。评论的逻辑是每一个问题下面都有评论,显示评论数量,具体内容,评论人等信息。消息的逻辑是,两个用户之间发送一条消息,有一个唯一的会话id,这个会话里可以有多条这两个用户的交互信息。通过一个用户id获取该用户的会话列表,再根据会话id再获取具体的会话内的多条消息。逻辑清楚之后,再加上一些附加功能,比如显示未读消息数量,根据时间顺序排列会话和消息。本节内容基本就是业务逻辑的开发,没有新增什么技术点,主要是前后端交互的逻辑比较复杂,前端的开发量也比较大。

3) Redis achieve thumbs up and step on function points

First look at the basics of redis, data structures, jedis use and so on. Writing test cases list, string, hashmap, set, sortset familiar jedis api. Development step and thumbs point function, according deletions traffic before the package good jedis change search operation, on the package util. Determined according to the needs of key fields, the format is like: Entity type: entity id and dislike: Entity type: entity id so you can be like a person there is a collection of news, there is another set did not like. Get thumbs up and step on the number of points by the number of statistics. Usually thumbs point operation step is to obtain the modified value and redis return value, then the value modified asynchronously likecount mysql database. This is to ensure the rapid completion of the operation point of praise, but also to ensure data consistency.

4) Asynchronous messaging

There are some operations or tasks performed in real time is not required before a function, we can transform them into an asynchronous message to send. Specific operation is achieved using redis asynchronous message queue. Code using event event to wrap an event, the event need to record a variety of information events entities: an asynchronous tools (event producer + consumer + eventHandler event interfaces), so that after the implementation class events to implement this interface. Event producers as a general service by calling the business logic of the Controller and generates an event, the event sequencing redis into the queue, the queue event consumers get a thread loop through the event, and were looking for the corresponding handler deal with. The entire framework of asynchronous events developed, later adding a new login, thumbs and other events can be so achieved.

5) attention + to achieve Fans list

New focus on functionality, using redis achieve fan list and a list of objects of interest of each user for each object of interest. By operation of the crud may list corresponding to the acquired fan list and watchlist, and concerns and achieve take-off function. Due to the success of concern and add the same transaction in two operations, you can use the transaction multi redis when fans packed the transaction to a successful and submit. In addition, the success of interest or attention messages may also be generated by the event mechanism send an event to complete the asynchronous event response processor queue, also be achieved according to redis. For a list of fans, fans of the show in addition to the basic information, it should also show whether the current user is a fan of this attention to front-end display. For Watchlist, if the object of interest is the users, in addition to displaying user's basic information, it should also be concerned about the current user is the user, so that the front display.

6) Use reptiles crawling data, data on the site is filled

Python3.x installation and configuration environment variable. Install pycharm, install pip. After installing, be familiar with the syntax of python, write some examples, such as data types, operators, method invocation, and object-oriented technology. Because the data is to be imported into the database, so here MySQLdb install a library, and write the code connecting to the database, and write about simple crud tested. Library used as a tool to resolve requests http request, as a tool used beautifulsoup parsed html code matches the selector using css directly after the request. You can get content. Of course, now we have a more convenient tool pyspider, you can easily parse the request and set up agents, disguised identity, etc., directly into the url and write a lot of class analytic functions, procedures will be performed iteratively, until the content of all pages parsed. Here we start web application pyspider direct and write python code, you can execute the reptiles. Know almost: first find the problem, all the answers and then crawling under question, and finally the process with questions and comments.

Published 100 original articles · won praise 12 · views 10000 +

Guess you like

Origin blog.csdn.net/hmh13548571896/article/details/103963645
Recommended