jspblog : common response dto
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package com.example.jspblog.domain.board.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CommonRespDto<T> {
|
||||
private int statusCode;
|
||||
private T data;
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.example.jspblog.domain.board.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DeleteResDto {
|
||||
private String status;
|
||||
}
|
||||
@@ -89,15 +89,11 @@ public class BoardController extends HttpServlet {
|
||||
String data = br.readLine();
|
||||
Gson gson = new Gson();
|
||||
DeleteReqDto dto = gson.fromJson(data, DeleteReqDto.class);
|
||||
CommonRespDto<String> commonRespDto = new CommonRespDto<>();
|
||||
|
||||
int result = boardService.글삭제(dto.getBoardId());
|
||||
DeleteResDto resDto = new DeleteResDto();
|
||||
if (result == 1) {
|
||||
resDto.setStatus("ok");
|
||||
} else {
|
||||
resDto.setStatus("fail");
|
||||
}
|
||||
String resData = gson.toJson(resDto);
|
||||
commonRespDto.setStatusCode(result);
|
||||
String resData = gson.toJson(commonRespDto);
|
||||
PrintWriter out = response.getWriter();
|
||||
out.print(resData);
|
||||
out.flush();
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json"
|
||||
}).done(function(result){
|
||||
if (result.status === 'ok') {
|
||||
if (result.statusCode === 1) {
|
||||
location.href = "index.jsp";
|
||||
} else {
|
||||
alert("삭제 실패");
|
||||
|
||||
Reference in New Issue
Block a user