Commit bacd5a0c authored by diaoruifeng's avatar diaoruifeng

服务详细查询

parent da2d8ae0
package com.pms.ocp.controller;
import com.pms.ocp.model.vo.ResponseVO;
import com.pms.ocp.service.ApiDetailsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RequestMapping("/api-base/v1")
@RestController
@Api(tags = "服务库服务详情接口")
public class ApiDetailsController {
@Autowired
private ApiDetailsService apiDetailsService;
@ApiOperation("服务库服务详情-查询")
@GetMapping("/query")
public ResponseVO getApiDetails(String objId) {
return apiDetailsService.getApiDetails(objId);
}
}
package com.pms.ocp.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pms.ocp.model.entity.OcpApiBase;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ApiDetailsMapper extends BaseMapper<OcpApiBase> {
}
package com.pms.ocp.model;
import lombok.ToString;
@ToString
public enum CommonCode implements ResultCode {
SUCCESS(true,0,"操作成功!"),
UNAUTHENTICATED(false,10001,"此操作需要登陆系统!"),
UNAUTHORISE(false,10002,"权限不足,无权操作!"),
INVALID_PARAM(false,10003,"非法参数!"),
PAGE_PARAMS_MISS(false,10004, "分页参数缺失!"),
RECORD_IS_NULL(false,10005, "数据不存在!"),
PARAMS_MISS(false,10007, "参数缺失!"),
FAIL(false,11111,"操作失败!"),
CHECK_SUCCESS(true,10006,"校验成功!"),
SERVER_ERROR(false,99999,"抱歉,系统繁忙,请稍后重试!"),
// private static ImmutableMap<Integer, CommonCode> codes;
EXTIST(false,10007,"账号已存在!");
//操作是否成功
boolean success;
//操作代码
int code;
//提示信息
String message;
CommonCode(boolean success, int code, String message){
this.success = success;
this.code = code;
this.message = message;
}
@Override
public boolean success() {
return success;
}
@Override
public int code() {
return code;
}
@Override
public String message() {
return message;
}
}
package com.pms.ocp.model;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.Data;
import lombok.ToString;
@Data
@ToString
public class QueryResponseResult<T> extends ResponseResult{
IPage<T> data;
public QueryResponseResult(ResultCode resultCode, IPage iPage){
super(resultCode);
this.data = iPage;
}
}
package com.pms.ocp.model;
public interface Response {
public static final boolean SUCCESS = true;
public static final int SUCCESS_CODE = 0;
}
package com.pms.ocp.model;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
@Data
@ToString
@NoArgsConstructor
public class ResponseResult implements Response {
//操作是否成功
boolean success = SUCCESS;
//操作代码
int code = SUCCESS_CODE;
//提示信息
String message;
public ResponseResult(ResultCode resultCode){
this.success = resultCode.success();
this.code = resultCode.code();
this.message = resultCode.message();
}
public ResponseResult(boolean success, int code, String msg){
this.success = success;
this.code = code;
this.message = msg;
}
public static ResponseResult SUCCESS(){
return new ResponseResult(CommonCode.SUCCESS);
}
public static ResponseResult FAIL(){
return new ResponseResult(CommonCode.FAIL);
}
public static ResponseResult EXTIST(){
return new ResponseResult(CommonCode.EXTIST);
}
}
package com.pms.ocp.model;
public interface ResultCode {
//操作是否成功,true为成功,false操作失败
boolean success();
//操作代码
int code();
//提示信息
String message();
}
package com.pms.ocp.service;
import com.pms.ocp.model.vo.ResponseVO;
public interface ApiDetailsService{
/**
*
* @param objId
* @return
*/
ResponseVO getApiDetails(String objId);
}
package com.pms.ocp.service.impl;
import com.pms.ocp.mapper.ApiDetailsMapper;
import com.pms.ocp.model.QueryResponseResult;
import com.pms.ocp.model.entity.OcpApiBase;
import com.pms.ocp.model.vo.ResponseVO;
import com.pms.ocp.service.ApiDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ApiDetailsServiceImpl implements ApiDetailsService {
@Autowired
private ApiDetailsMapper apiDetailsMapper;
@Override
public ResponseVO getApiDetails(String objId) {
OcpApiBase ocpApiBase = apiDetailsMapper.selectById(objId);
return ResponseVO.ok(ocpApiBase);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment