当前位置:网站首页>Practice of online question feedback module (XIV): realize online question answering function
Practice of online question feedback module (XIV): realize online question answering function
2022-07-26 07:30:00 【Bug bacteria ¹】
author :bug bacteria
official account : Ape circle wonderful house
important clause : Originality is not easy. , For reprint, please attach the original source link and this statement , Thank you for your cooperation .
Copyright notice : Some words or pictures in the article may come from the Internet or Baidu Encyclopedia , If there is infringement, please contact bug Bacterial treatment .
One 、 summary
The next few issues ,bug I want to share with you that I just received a temporary demand yesterday , It's hot , I would like to share how I faced the temporary requirements and made the whole development cycle , It includes sorting out businesses, creating business tables, realizing business logic to form a closed loop, and connecting with the front end , Some business development and functional development will be interspersed , This one-stop process is witnessed online with you , Share with the novice , I hope it will help you .
Environmental statement :idea2019.3 + springboot2.3.1.REALSE + mybati-plus3.2.0 + mysql5.6 + jdk1.8
If the partners feel that the article is helpful to you in the process of reviewing the article , Please don't be stingy with your praise , Boldly put the article Lighten up Well , Your likes are three in a row ( Collection ️+ Focus on + Leaving a message. ) That's right bug The best encouragement and support on my creative path . Time does not give up *️, Create constantly , come on. ️
Two 、 Text
Speaking of this , The module is nearing the end , Just read the interface document , There should be only twoorthree interfaces left , It's all basic crud, Certainly not more than three phases , This module is coming to an end .
Unknowingly , With the you have written 14 It's time , From framework construction to tool class encapsulation to current interface request , Along the way , In fact, if you look at my friends who wrote this module carefully, you will know , I write every issue with my heart , Teach with heart , The purpose is to bring the young partners who are just starting or entering the company , New requirements for the project , Where should we start , Yes? Step by step , Actually, I just want to give you a head , Because I was also brought out by my boss at that time , These are also a large part of the analysis skills in it , Plus my own practical analysis , So .
So! , Don't be confused , see bug It's written by bacteria these , One by one , For small partners who do not encounter this temporary demand , Or according to my business scenario , Try to write by yourself , incidentally Writing point summary , 1. You can increase your understanding of business scenarios . Isn't it .
The next thing I want to talk about is , Answer the questions fed back by users online , For this business, a closed loop is formally formed . Since someone asks , Then someone should solve it , Right .
Let's not talk more nonsense , Start today's content directly .
3、 ... and 、 How to code the paging query function
Since it is to solve the problem , The first step is to determine the request method , Speaking of this , Then you must make sure to participate in , What are the required parameters , According to my understanding of the business , There are three types of input , ginseng 1: The primary key of the feedback question id. ginseng 2: Q & A details ; ginseng 3: Respondent domain account number id. Why these three parameters ? Because the business told me that only one feedback on the problem needs to be included , It must be recorded who answered the question , As for the primary key id, That is to answer questions about that record . In this way , You all understand ?
Now that the editing parameters have been determined , Let's create a parameter directly pojo Well . After all, we should regulate our behavior .
1️⃣ Define paging pojo
The following is the interface request input parameter pojo, For reference only .
@Data
@ApiModel(value = " Question feedback ", description = " Question feedback ")
public class SolveUserQuestionModel {
@ApiModelProperty(value = " Problem feedback id")
private String questionId;
@ApiModelProperty(value = " Solution details ")
private String solveContent;
@ApiModelProperty(value = " Solve the human domain account id")
private String solver;
}2️⃣ Definition Controller request
Request parameters pojo Also defined , The next step is to define the request body , That's natural 【POST】 Request to receive Object Parameter body , Also is to use @RequestBody Annotation parsing parameters . Then define the request path , Or the old saying , Try to see the famous and know the meaning , Don't name . Because this is to solve the problem , Then define it as “solve” that will do . A sensible man can understand at a glance .
The specific interface request is defined as follows : For reference only .
@PostMapping("/solve")
@ApiOperation(value = " Problem feedback solution ", notes = " Problem feedback solution ")
public ResultResponse<Boolean> solveQuestion(@RequestBody SolveUserQuestionModel model) {
return userQuestionsService.solveQuestion(model);
}3️⃣ Define interface methods solveQuestion()
Just define it directly here , After all, the specific business logic is written in the interface implementation class .
Specific interface definitions are as follows : For reference only .
/**
* Problem feedback solution
*/
ResultResponse<Boolean> solveQuestion(SolveUserQuestionModel model);4️⃣ Realization solveQuestion() Method
Here I will analyze a wave , First, there is a field for the database ,status, The business requires that whether the problem has been solved can be displayed on the page , Here, I share the same field with the business status , That's natural status value . As follows :status The status value (0: normal ,1: Delete ;2: resolved ;3: Not to be resolved ;4: It's being solved ;5: Question closed ). For these States , Some of them are useless , But it also needs to be pre-defined , Maybe the subsequent demand needs to be increased , Just assign values directly .
So answer questions about how to achieve this , There's one more thing to note , First, query whether the data exists , If empty , The direct feedback data does not exist , This avoids update Error reporting scenario .
The specific business code is as follows :
@Override
public ResultResponse<Boolean> solveQuestion(SolveUserQuestionModel model) {
UserQuestionsEntity entity = this.getById(model.getQuestionId());
if (Objects.isNull(entity)) {
return new ResultResponse<>(ErrorCodeEnum.DATA_NOT_EXIST);
}
entity.setSolver(model.getSolver());
entity.setSolveContent(model.getSolveContent());
entity.setStatus(2);//2 Is resolved .
return new ResultResponse<>(this.updateById(entity));
}presumably For you , It's all easy , After all, it is not complicated business logic . So whether it's simple or not , All of them will Think about more scenes , The treatment of the treatment .
5️⃣ The interface test
Next , Interface testing , Let's find an unanswered piece of data from the database and test it . For interface testing , I am still the same , It's just postman perhaps swagger Document direct interface test , But the formal process needs to write test-case Take unit test , But I don't ask for this , Then don't worry about , After all, I dare to teach openly what I wrote , It shows that I am 100% sure that even if I do not pass the unit test, I will have no problem .
As follows, I will go directly through swagger Let's have a look at the test .
Let's take a look at this data first , It is unanswered .

Let's go straight to swagger Interface , Enter the corresponding parameter , Please ;

For this problem in the database id non-existent , Here we are going to directly return to the custom msg.
Let's give you a problem with the database id, We ask again :

The result is that the implementation is successful , Let's do the above sql sentence , Query and check , Whether these contents have been written into the warehouse .

Obviously, it is the content of our parameters , It indicates that there is no problem with the interface logic , For normal use .
6️⃣ summary
For simpler logical interfaces , We all have to write 100% carefully .
... ...
All right. , The above is all about this issue , Have you learned to give up ? If it helps you , Please don't forget to give bug bacteria [ Three companies support ] yo . If you want to get more learning resources or want to communicate with more technology enthusiasts , You can pay attention to my official account. 『 Ape circle wonderful house 』, The backstage replies the key words to get the learning materials 、 Big factory surface 、 Interview templates and other massive resources , Just wait for you to get .
Four 、 I recommend
For the actual development of the problem feedback module , I combed the teaching and link address of each issue completely , For reference only : I hope it can help you .
- Practice of online problem feedback module ( One ): Sort out business requirements and create database tables
- Practice of online problem feedback module ( Two ): Encapsulate code to automatically generate class file
- Practice of online problem feedback module ( 3、 ... and ): Automatically generate all Controller、Service、Mapper Wait for the documents
- Practice of online problem feedback module ( Four ): Encapsulate generic field classes
- Practice of online problem feedback module ( 5、 ... and ): Realize the automatic filling function of general field content
- Practice of online problem feedback module ( 6、 ... and ): Interface document definition
- Practice of online problem feedback module ( 7、 ... and ): Installation and deployment swagger2
- Practice of online problem feedback module ( 8、 ... and ): Realize image upload function - Part 1
- Practice of online problem feedback module ( Nine ): Realize image upload function - The next part
- Practice of online problem feedback module ( Ten ): Realize the picture preview function
- Practice of online problem feedback module ( 11、 ... and ): Realize the picture download function
- Practice of online problem feedback module ( Twelve ): Realize the function of deleting pictures
- Practice of online problem feedback module ( 13、 ... and ): Realize multi parameter paging query list
- Practice of online problem feedback module ( fourteen ): Realize the online question answering function
- Practice of online problem feedback module ( 15、 ... and ): Realize the function of online updating feedback status
- Practice of online problem feedback module ( sixteen ): Realize the function of checking details
- Practice of online problem feedback module ( seventeen ): Realization excel Template online download function
- Practice of online problem feedback module ( eighteen ): Realization excel Batch import function of account file records
- Practice of online problem feedback module ( nineteen ): Realize batch export of data to excel Function in file
- Practice of online problem feedback module ( twenty ): Realize batch export of files to zip Functions in compressed package
- Practice of online problem feedback module ( The 21st ): Conclusion
The above is the content of 21 issues , Each issue is dry , For the development of a module , How to build and test the deployment online bit by bit , I'll say it again , This is not an exercise , It's actual combat ! It's actual combat ! It's actual combat !
If you think you just need to understand one of the knowledge points or business , No objection , Just choose a few of them to study , It's all over anyway ; I just hope you can gain something , Grow up , It's not in vain for me to summarize and update you after work every day .
5、 ... and 、 At the end of the article
If you want to learn more , Little friends can pay attention to bug I created a special column for you 《springboot Zero basic introductory teaching 》, It's all my hands , Ongoing update , I hope I can help more friends .
I am a bug bacteria , A procedural ape who wants to get out of the mountain and change his fate . There's a long way to go , Are waiting for us to break through 、 To challenge . Come on , friends , Let's cheer together ! The future can be expected ,fighting!
Finally, I'll give you two words I like very much , Share with you !
️ Be what you want to be , No time limit , As long as willing , Anytime? start.
You can change... From now on , It can be the same , This matter , There are no rules , You can live your best .

If the article helps you , Just leave your Fabulous Well !(#^.^#);
If you like bug Sharing articles , Just... Please bug Bacteria point Focus on Well !(๑′ᴗ‵๑)づ╭~;
If you have any questions about the article , Please also at the end of the text Leaving a message. perhaps Add group Well 【QQ Communication group :708072830】;
Given the limited personal experience , All viewpoints and technical research points , If there is any objection , Please reply directly to participate in the discussion ( Do not make offensive remarks , thank you );
Copyright notice : Originality is not easy. , For reprint, please attach the original source link and this statement , copyright , Piracy must be investigated !!! thank you .
边栏推荐
- Compose text and icon splicing to realize drawableleft or drawableright
- MMOE multi-objective modeling
- 漂洋过海来看你
- 20220209 create a basic Servlet
- Taishan Office Technology Lecture: how to calculate page blank (margin)
- 3.0.0 alpha blockbuster release! Nine new functions and new UI unlock new capabilities of dispatching system
- Regular expression rules and common regular expressions
- Uncover the mystery of cloud native data management: operation level
- NFT digital collection system development: how enterprises develop their own digital collection platform
- Anaconda 中安装 百度飞浆Paddle 深度学习框架 教程
猜你喜欢

WCF 部署在IIS上

【推荐系统经典论文(十)】阿里SDM模型

Learn browser decoding from XSS payload

Upgrade ecological proposition: what has Alibaba cloud brought to thousands of businesses?

Hcip--- BGP comprehensive experiment

NFT digital collection system development: what are the best digital marketing strategies for NFT digital collection

C51 and MDK coexist keil5 installation tutorial

Comparison and difference between dependence and Association

Become an Apache contributor, so easy!

Hcip - MPLS Technology
随机推荐
Installation of Baidu flying paste deep learning framework tutorial in Anaconda
NFT digital collection system development: how enterprises develop their own digital collection platform
2019中兴捧月·模型压缩方案
系统架构&微服务
Singles cup web WP
PXE高效批量网络装机
Modulenotfounderror: no module named 'pip' solution
Unity3d asynchronous loading of scenes and progress bar loading
【推荐系统经典论文(十)】阿里SDM模型
力扣(LeetCode)206. 反转链表(2022.07.25)
Crawler data analysis
Regular expression rules and common regular expressions
keras学习之:获取神经网络中间层的输出结果
4. Data integrity
PXE efficient batch network installation
正则表达式规则以及常用的正则表达式
The interface automation test with a monthly salary of 12k+ takes you to get started in 3 minutes
Apache dolphin scheduler version 3.0.0-beta-1 was released, and flinksql and Zeppelin task types were added
现在开发人员都开始做测试了,是不是以后就没有软件测试人员了?
NFT数字藏品系统开发:数字藏品赋予品牌新活力