当前位置:网站首页>Interview-01
Interview-01
2022-06-27 03:32:00 【csx_ zzh】
Catalog
3. Yes spring Understanding of the framework (ioc aop)
4.redis Five basic types of + Two advanced data types
5. How do comments on comments come about
[email protected] How to realize the function
7. The realization of like function
8. Is your project front end and back end separated ?
10. Common algorithms you encounter in competitions
1. Longest text substring (dp)
2. Traversal of binary tree ( Deep search + Guang Shu )
11. Do you have anything to ask ?
1. Self introduction.
2. Introduce your project
The overall structure of this project comes from Niuke , Mainly used Springboot、Mybatis、MySQL、Redis、Kafka、 Tools such as . It mainly realizes the registration of users 、 Sign in 、 Post 、 give the thumbs-up 、 System notification 、 Sort by heat 、 Search and other functions . In addition, it introduces redis Database to improve the overall performance of the website , It realizes the access of user credentials 、 Like the functions concerned . be based on Kafka Realize system notification : When users get likes 、 Get notified after comments . Use the timed task to calculate the scores of posts regularly , And show the hot post ranking list on the page .
3. Yes spring Understanding of the framework (ioc aop)
IOC
First of all IOC, What exactly is IOC Well ?IOC(Inversion Of Control) be called Inversion of control . It is mainly a design idea , It can hand over the process of manually creating instances to spring To deal with it . The goal is to simplify development . therefore ,IOC It also provides IOC Container to store these instances .
IOC The main implementation of is DI Dependency injection ,Spring It helps our production objects 、 Management object 、 Manage dependencies between objects . Reduced code coupling 、 Easy to develop .
There are also several ways of dependency injection
1、 Create by constructor
2、 adopt set Method creation
3、 use p Namespace
4、 Use annotations :@Autowired/@Resource
AOP
AOP(Aspect Oriented Programming) be called Section oriented programming .
AOP It's a kind of programming idea , It can combine those with It's not business , But for Jointly called by business modules The logic of ( For example, transaction processing 、 Log management 、 Authority control, etc ) encapsulated , Reduce the repetitive code of the system , Reduce the coupling between modules , have Extensibility and Maintainability
AOP The principle of implementation is A dynamic proxy , There are two kinds of :JDK A dynamic proxy and CGLIB A dynamic proxy
Now realize AOP There are two main ways , One is Spring AOP, The other is AspectJ AOP, among Spring AOP It's integrated AspectJ, The difference between the two :AspectJ More powerful and better performance , but SpringAOP It's simpler ,
4.redis Five basic types of + Two advanced data types
Redis Support 5 Basic data types : character string (String), list (List), aggregate (set), Hash structure (hash), Ordered set (sorted set); There are also two data structures :HyperLogLog and BitMap.
(UV: Unique visitors to the site )(DAU: Daily active user )
HyperLogLogs What problems are cardinality statistics used to solve ?
This structure can save a lot of memory to count all kinds of counts , Such as registration IP Count 、 Visit... Daily IP Number of pages in real time UV、 Number of online users , Number of common friends, etc .
Bitmap Bit graph data structure , It's all operating bits to record , Only 0 and 1 Two states .
What problem to solve ?
such as : Statistics user information , active , Inactive ! Sign in , Not logged in ! Clock in , Don't punch in ! Two states of , You can use Bitmaps!
How much memory is needed to store a year's punch in status ? 365 God = 365 bit 1 byte = 8bit 46 In bytes or so !
5. How do comments on comments come about
There are three ways to add comments :① Reply ,② Reply to comments ,③ Reply to sb.'s comments .
① stay discuss-detail Click the reply at the bottom of the page , Mapping to CommentController Layer of /add/{discussPostId}. Into entityType = 1 and entityId = post.id .
② Reply below the comment , And ① The mapping is the same , Pass in entityType = 2 and entityId = comment.id.
③ Reply to sb.'s comments , And ① The mapping is the same , Pass in entityType = 2 and entityId = comment.id and targetId.
The incoming comment Further settings userId,Status,CreateTime. And then call commentService.addComment(comment) Method to insert the database .
commentService.addComment Transaction annotations are used . The method is right comment Of content Transference HTML Mark and filter sensitive words . And then use commentMapper.insertComment Insert comments . And then through commentMapper.selectCountByEntity Query the number of comments on the post , Reuse discussPostService.updateCommentCount Method to insert the number of comments into the post details table .
[email protected] How to realize the function
7. The realization of like function
give the thumbs-up
Premise : stay util Of RedisKeyUtil Write in the tool class getEntityLikeKey Method , Pass in entityType, entityId Returns an entity ( Post or reply ) Yes yes key value .
Divided into two :① Like the post ② Like the response .
① Like the post content on the post details page , Button pass discuss.js take entityType=0 , post id:entityId and entityUserId adopt /like The mapping is passed to LikeController Layer. like Method .
like Method by calling likeService Layer of like Perform the like function , Then call... In turn findEntityLikeCount,findEntityLikeStatus Method to query the number of likes of the post , Query the like status of the currently logged in user .
likeService Layer of like Methods first, judge whether you have liked it , without , It's just Redis In this post key Corresponding set Add the likes of userId, And add one to the total number of likes of users of this post . If you like it, remove it UserId, And the total number of likes of users of this post is reduced by one .( Transactions are used here , Because two businesses need to be carried out at the same time )
Trigger Topic by TOPIC_LIKE Events : structure Event, Set the current login user id, Like the object type, Like the object id, The post of the liked object id( Because the likes may be posts or replies ), Users who are like objects id. And then call eventProducer take Event Publish to specified Topic.
Load the number and status of likes into map, adopt json String returns . Show... In the browser .
② Reply like on the post details page , Button pass discuss.js take entityType=1 and reply id:entityId and entityUserId adopt /like The mapping is passed to LikeController Layer. like Method .
notes : In addition to HomeController Layer /index Mapping method , Increase the function of returning the number of post likes to the browser . stay DiscussPostController Layer /detail/{discussPostId} Mapping method , Add the function of returning the number and status of likes in the post and reply list to the browser .
8. Is your project front end and back end separated ?
9. About Ajax
10. Common algorithms you encounter in competitions
1. Longest text substring (dp)
2. Traversal of binary tree ( Deep search + Guang Shu )
11. Do you have anything to ask ?
边栏推荐
- SAI钢笔工具如何使用,入门篇
- Agile development - self use
- Uni-app 之uParse 富文本解析 完美解析富文本!
- Paddlepaddle 20 implementation and use of exponentialmovingaverage (EMA) (support static graph and dynamic graph)
- 苹果手机证书构体知识
- How can e-commerce products be promoted and advertised on Zhihu?
- 对数器
- 元透实盘周记20220627
- 2021:Greedy Gradient Ensemble for Robust Visual Question Answering
- 发现一款 JSON 可视化工具神器,太爱了!
猜你喜欢
There are two problems when Nacos calls microservices: 1 Load balancer does not contain an instance for the service 2. Connection refused
Window 加密壳实现
敏捷开发篇--Agile Development-自用
2021:Beyond Question-Based Biases:Assessing Multimodal Shortcut Learning in Visual Question Answeri
Uni app's uparse rich text parsing perfectly parses rich text!
Anaconda3安裝過程及安裝後缺失大量文件,沒有scripts等目錄
Calculation of average wind direction and speed (unit vector method)
Topolvm: kubernetes local persistence scheme based on LVM, capacity aware, dynamically create PV, and easily use local disk
Il manque beaucoup de fichiers et de répertoires tels que scripts pendant et après l'installation d'anaconda3
Anaconda3安装过程及安装后缺失大量文件,没有scripts等目录
随机推荐
How does the brain do arithmetic? Both addition and subtraction methods have special neurons, and the symbol text can activate the same group of cell sub journals
A^2=E | 方程的解 | 这个方程究竟能告诉我们什么
Method of decoding iPhone certificate file
Super détaillé, 20 000 caractères détaillés, mangez à travers es!
How does source insight (SI) display the full path? (do not display omitted paths) (turn off trim long path names with ellipses)
栈溢出漏洞
Brief introduction of 228 dropout methods of pytorch and fast implementation of dropblock with 4 lines of code based on dropout
Learn Tai Chi Maker - mqtt (VI) esp8266 releases mqtt message
记录unity 自带读取excel的方法和遇到的一些坑的解决办法
Pat grade a 1018 public bike management
【一起上水硕系列】Day 6
元透实盘周记20220627
Implementation of window encryption shell
Docker deploy redis cluster
[promise I] introduction of promise and key issues of hand rolling
Regular expressions: Syntax
Easy to use plug-ins in idea
2022年氯碱电解工艺试题及答案
PAT甲级 1023 Have Fun with Numbers
PAT甲级 1018 Public Bike Management