Package com. Laboratory. Domain;
The import lombok. AllArgsConstructor;
The import lombok. Data;
The import lombok. NoArgsConstructor;
/* @ Data */
/* @ AllArgsConstructor */
@ NoArgsConstructor
Public class Achievement {
private Integer id;
private String title;
Private String text;
Public Achievement (Integer id, String title, String text) {
this.id=id;
Enclosing the title=the title;
This. The text=text;
}
Public Integer getId () {
return id;
}
Public void setId (Integer id) {
this.id=id;
}
Public String getTitle () {
Return the title;
}
Public void setTitle (String title) {
Enclosing the title=the title;
}
Public String getText () {
Return the text;
}
Public void setText (String text) {
This. The text=text;
}
@ Override
Public String toString () {
Return "Achievement {+"
"Id=" + id +
"Title=" "+ title + '\' '+
='" + ", the text text +' \ ' '+
'} ';
}
}
The controller layer
Package com. Laboratory. The controller;
The import com. Laboratory. Domain. Achievement;
The import com. Laboratory. Service. AchievementService;
The import com. Laboratory. Utils. ResponseMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
The import org. Springframework. Web. Bind. The annotation. RestController;
Import the Java. Util. List;
@ RestController
@ RequestMapping ("/laboratory/Achievement ")
Public class AchievementController {
The @autowired
Private AchievementService AchievementService;
@ RequestMapping ("/getAllAchievement ")
Public ResponseMessage
- GetAllAchievement () {
List
ResponseMessage
- ResponseMessage=new ResponseMessage
- (a);
ResponseMessage. SetCode (1000);
ResponseMessage. SetMsg (" success ");
ResponseMessage. SetData (allachievement);
Return the responseMessage;
}
}
ResponMessage
Package com. Laboratory. Utils;
Public class ResponseMessage
Private Integer code;
Private T data;
private String msg;
Public ResponseMessage () {
}
Public ResponseMessage (Integer code, T data, String MSG) {
This. Code=code;
this.data=https://bbs.csdn.net/topics/data;
this.msg=msg;
}
Public Integer getCode () {
return code;
}
Public void setCode (Integer code) {
this.code=code;
}
Public T getData () {
return data;
}
Public void setData (T data) {
This data=https://bbs.csdn.net/topics/data;
}
Public String getMsg () {
return msg;
}
Public void setMsg (String MSG) {
This. MSG=MSG;
}
}
CodePudding user response:
https://blog.csdn.net/weixin_40149557/article/details/86568063CodePudding user response:
Achievement this class to implement serializable interface:Achievement implements Serializable
CodePudding user response: