mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
5.0
This commit is contained in:
@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSON;
|
||||
import com.gitee.sop.support.annotation.Open;
|
||||
import com.gitee.sop.support.service.ApiRegisterService;
|
||||
import com.gitee.sop.support.service.dto.RegisterDTO;
|
||||
import com.gitee.sop.support.service.dto.RegisterResult;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -109,10 +110,9 @@ public class ApiRegister {
|
||||
registerDTO.setIsPermission(parseBoolean(open.permission()));
|
||||
registerDTO.setIsNeedToken(parseBoolean(open.needToken()));
|
||||
LOG.info("注册开放接口, apiInfo=" + registerDTO);
|
||||
try {
|
||||
apiRegisterService.register(registerDTO);
|
||||
} catch (Exception e) {
|
||||
LOG.error("接口注册失败, registerDTO=" + registerDTO + ", method=" + method, e);
|
||||
RegisterResult result = apiRegisterService.register(registerDTO);
|
||||
if (!result.getSuccess()) {
|
||||
throw new RuntimeException(result.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.gitee.sop.support.service;
|
||||
|
||||
import com.gitee.sop.support.service.dto.RegisterDTO;
|
||||
import com.gitee.sop.support.service.dto.RegisterResult;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
@@ -11,5 +12,5 @@ public interface ApiRegisterService {
|
||||
*
|
||||
* @param registerDTO 接口信息
|
||||
*/
|
||||
void register(RegisterDTO registerDTO);
|
||||
RegisterResult register(RegisterDTO registerDTO);
|
||||
}
|
||||
|
@@ -0,0 +1,31 @@
|
||||
package com.gitee.sop.support.service.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class RegisterResult implements Serializable {
|
||||
private static final long serialVersionUID = 4605838522659698419L;
|
||||
|
||||
private Boolean success;
|
||||
|
||||
private String msg;
|
||||
|
||||
public static RegisterResult success() {
|
||||
RegisterResult registerResult = new RegisterResult();
|
||||
registerResult.setSuccess(true);
|
||||
return registerResult;
|
||||
}
|
||||
|
||||
public static RegisterResult error(String msg) {
|
||||
RegisterResult registerResult = new RegisterResult();
|
||||
registerResult.setSuccess(false);
|
||||
registerResult.setMsg(msg);
|
||||
return registerResult;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user