mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-12 07:02:14 +08:00
5.0
This commit is contained in:
@@ -1,22 +1,23 @@
|
||||
package com.gitee.sop.storyweb.open.impl;
|
||||
package com.gitee.sop.storyweb.impl;
|
||||
|
||||
import com.gitee.sop.storyweb.message.StoryMessageEnum;
|
||||
import com.gitee.sop.storyweb.open.OpenStory;
|
||||
import com.gitee.sop.storyweb.open.req.StorySaveDTO;
|
||||
import com.gitee.sop.storyweb.open.resp.StoryResponse;
|
||||
import com.gitee.sop.support.context.OpenContext;
|
||||
import com.gitee.sop.support.dto.CommonFileData;
|
||||
import com.gitee.sop.support.dto.FileData;
|
||||
import com.gitee.sop.support.exception.OpenException;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
|
||||
/**
|
||||
* 开放接口实现
|
||||
@@ -53,6 +54,14 @@ public class OpenStoryImpl implements OpenStory {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer updateError(Integer id) {
|
||||
// 抛出业务异常
|
||||
if (id == null || id == 0) {
|
||||
throw new OpenException(StoryMessageEnum.ISV_PARAM_ERROR, "id is null or 0");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StoryResponse getById(Integer id) {
|
@@ -0,0 +1,32 @@
|
||||
package com.gitee.sop.storyweb.message;
|
||||
|
||||
import com.gitee.sop.support.message.OpenError;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum StoryMessageEnum implements OpenError {
|
||||
/**
|
||||
* 未知错误
|
||||
*/
|
||||
ISP_UNKNOWN_ERROR("isp.service-unknown-error"),
|
||||
/**
|
||||
* 参数错误
|
||||
*/
|
||||
ISV_PARAM_ERROR("isv.invalid-parameter"),
|
||||
/**
|
||||
* 通用错误
|
||||
*/
|
||||
ISV_COMMON_ERROR("isv.common-error");
|
||||
|
||||
private final String subCode;
|
||||
|
||||
@Override
|
||||
public String modulePrefix() {
|
||||
return "isp.error_";
|
||||
}
|
||||
}
|
@@ -22,6 +22,10 @@ public interface OpenStory {
|
||||
@Open("story.update")
|
||||
Integer update(Integer id, StorySaveDTO storySaveDTO);
|
||||
|
||||
// 演示抛出异常
|
||||
@Open("story.updateError")
|
||||
Integer updateError(Integer id);
|
||||
|
||||
@Open("story.get")
|
||||
StoryResponse getById(@NotNull(message = "id必填") Integer id);
|
||||
|
||||
|
Reference in New Issue
Block a user