修改通用ResponseDto为泛型
This commit is contained in:
+9
-1
@@ -1,23 +1,31 @@
|
|||||||
package com.gzzn.omms.adminapi.controller.schedule;
|
package com.gzzn.omms.adminapi.controller.schedule;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.gzzn.omms.adminapi.domain.secondary.entity.schedule.FimsFlightschdSeason;
|
||||||
import com.gzzn.omms.adminapi.dto.ResponseDto;
|
import com.gzzn.omms.adminapi.dto.ResponseDto;
|
||||||
import com.gzzn.omms.adminapi.enums.ResultCode;
|
import com.gzzn.omms.adminapi.enums.ResultCode;
|
||||||
|
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 航班季度计划
|
* 航班季度计划
|
||||||
* @author Administrator
|
* @author Administrator
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Api(value="航班季度计划",tags="航班季度计划")
|
||||||
|
@RestController
|
||||||
public class FlightSchdSeasonController {
|
public class FlightSchdSeasonController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有航班季度计划
|
* 获取所有航班季度计划
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation(value="获取航班计划列表")
|
||||||
@GetMapping(value="/schedule/flightSchdSeasons")
|
@GetMapping(value="/schedule/flightSchdSeasons")
|
||||||
public ResponseDto getFlightSchdSeason()
|
public ResponseDto<FimsFlightschdSeason> getFlightSchdSeason()
|
||||||
{
|
{
|
||||||
return ResponseDto.failure(ResultCode.INTERFACE_NOT_IMPLEMENT);
|
return ResponseDto.failure(ResultCode.INTERFACE_NOT_IMPLEMENT);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,94 +1,94 @@
|
|||||||
package com.gzzn.omms.adminapi.dto;
|
package com.gzzn.omms.adminapi.dto;
|
||||||
|
|
||||||
import com.gzzn.omms.adminapi.enums.ResultCode;
|
import com.gzzn.omms.adminapi.enums.ResultCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author xiunai
|
* @author xiunai
|
||||||
*
|
*
|
||||||
* @date 2018年5月16日
|
* @date 2018年5月16日
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ResponseDto {
|
public class ResponseDto<T> {
|
||||||
private Boolean is_success;
|
private Boolean is_success;
|
||||||
private Integer err_code;
|
private Integer err_code;
|
||||||
private String err_msg;
|
private String err_msg;
|
||||||
|
|
||||||
private Object body;
|
private T body;
|
||||||
|
|
||||||
public ResponseDto() {}
|
public ResponseDto() {}
|
||||||
|
|
||||||
public ResponseDto(Integer code, String msg) {
|
public ResponseDto(Integer code, String msg) {
|
||||||
this.setIs_success(false);
|
this.setIs_success(false);
|
||||||
this.setErr_code(code);
|
this.setErr_code(code);
|
||||||
this.setErr_msg(msg);
|
this.setErr_msg(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResponseDto success() {
|
public static ResponseDto success() {
|
||||||
ResponseDto result = new ResponseDto();
|
ResponseDto result = new ResponseDto();
|
||||||
result.setIs_success(true);
|
result.setIs_success(true);
|
||||||
result.setResultCode(ResultCode.SUCCESS);
|
result.setResultCode(ResultCode.SUCCESS);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResponseDto success(Object data) {
|
public static <T> ResponseDto<T> success(T data) {
|
||||||
ResponseDto result = new ResponseDto();
|
ResponseDto result = new ResponseDto<T>();
|
||||||
result.setIs_success(true);
|
result.setIs_success(true);
|
||||||
result.setResultCode(ResultCode.SUCCESS);
|
result.setResultCode(ResultCode.SUCCESS);
|
||||||
result.setBody(data);
|
result.setBody(data);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResponseDto failure(ResultCode resultCode) {
|
public static ResponseDto failure(ResultCode resultCode) {
|
||||||
ResponseDto result = new ResponseDto();
|
ResponseDto result = new ResponseDto();
|
||||||
result.setIs_success(false);
|
result.setIs_success(false);
|
||||||
result.setResultCode(resultCode);
|
result.setResultCode(resultCode);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResponseDto failure(ResultCode resultCode, Object data) {
|
public static <T> ResponseDto<T> failure(ResultCode resultCode, T data) {
|
||||||
ResponseDto result = new ResponseDto();
|
ResponseDto result = new ResponseDto<T>();
|
||||||
result.setIs_success(false);
|
result.setIs_success(false);
|
||||||
result.setResultCode(resultCode);
|
result.setResultCode(resultCode);
|
||||||
result.setBody(data);
|
result.setBody(data);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResultCode(ResultCode code) {
|
public void setResultCode(ResultCode code) {
|
||||||
this.setErr_code(code.code());
|
this.setErr_code(code.code());
|
||||||
this.setErr_msg(code.message());
|
this.setErr_msg(code.message());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getBody() {
|
public T getBody() {
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBody(Object body) {
|
public void setBody(T body) {
|
||||||
this.body = body;
|
this.body = body;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getIs_success() {
|
public Boolean getIs_success() {
|
||||||
return is_success;
|
return is_success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIs_success(Boolean is_success) {
|
public void setIs_success(Boolean is_success) {
|
||||||
this.is_success = is_success;
|
this.is_success = is_success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getErr_code() {
|
public Integer getErr_code() {
|
||||||
return err_code;
|
return err_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setErr_code(Integer err_code) {
|
public void setErr_code(Integer err_code) {
|
||||||
this.err_code = err_code;
|
this.err_code = err_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getErr_msg() {
|
public String getErr_msg() {
|
||||||
return err_msg;
|
return err_msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setErr_msg(String err_msg) {
|
public void setErr_msg(String err_msg) {
|
||||||
this.err_msg = err_msg;
|
this.err_msg = err_msg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user