当前位置:网站首页>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 ?
边栏推荐
- 与STM32或GD32替换说明
- Further exploration of handler (Part 2) (the most complete analysis of the core principles of handler)
- Docker deploy redis cluster
- 2022茶艺师(高级)上岗证题库模拟考试平台操作
- 手机新领域用法知识
- 投资理财产品的钱有保障吗?会不会没有了?
- TP5 spreadsheet excel table export
- 2022年氯碱电解工艺试题及答案
- Regular expressions: Syntax
- 2016Analyzing the Behavior of Visual Question Answering Models
猜你喜欢

resnet152 辣椒病虫害图像识别1.0

Nacos调用微服务两个问题:1.Load balancer does not contain an instance for the service 2.Connection refused
![455. distribute biscuits [distribution questions]](/img/51/c7544d0eaa121cd461ffa678079473.jpg)
455. distribute biscuits [distribution questions]

Anaconda3安装过程及安装后缺失大量文件,没有scripts等目录

PAT甲级 1018 Public Bike Management

Career outlook, money outlook and happiness outlook

Yuantou firm offer weekly record 20220627

Learning Tai Chi Maker - mqtt Chapter 2 (II) esp8266 QoS application

Implementation of window encryption shell
![Promise [II. Promise source code] [detailed code comments / complete test cases]](/img/ac/abf3181fa7b3345efcc9abc046cea5.png)
Promise [II. Promise source code] [detailed code comments / complete test cases]
随机推荐
Career outlook, money outlook and happiness outlook
2021:Beyond Question-Based Biases:Assessing Multimodal Shortcut Learning in Visual Question Answeri
手机新领域用法知识
Topolvm: kubernetes local persistence scheme based on LVM, capacity aware, dynamically create PV, and easily use local disk
记录unity 自带读取excel的方法和遇到的一些坑的解决办法
fplan-电源规划
TopoLVM: 基于LVM的Kubernetes本地持久化方案,容量感知,动态创建PV,轻松使用本地磁盘
Mmdetection uses yolox to train its own coco data set
Implementation of window encryption shell
测试nohup和&的各自作用
jmeter将上一个请求的结果作为下一个请求的参数
Pat grade a 1026 table tennis
卷积神经网络(CNN)网络结构及模型原理介绍
I found a JSON visualization tool artifact. I love it!
再探Handler(上)(Handler核心原理最全解析)
2022年氯碱电解工艺试题及答案
There are two problems when Nacos calls microservices: 1 Load balancer does not contain an instance for the service 2. Connection refused
发现一款 JSON 可视化工具神器,太爱了!
Yiwen teaches you Kali information collection
How can e-commerce products be promoted and advertised on Zhihu?