提交 43268426 编写于 作者: 小傅哥's avatar 小傅哥

小傅哥,feat:更新说明

上级 5db822e7
package cn.bugstack.xfg.frame.trigger.http;
import cn.bugstack.types.common.Constants;
import cn.bugstack.types.model.Response;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Random;
import java.util.concurrent.ThreadPoolExecutor;
@Slf4j
@RestController
public class Controller {
@Resource
private ThreadPoolExecutor threadPoolExecutor;
/**
* http://localhost:8090/success
*/
@RequestMapping("/success")
public Response<String> success() {
log.info("测试调用");
try {
// 随机休眠
Thread.sleep(new Random().nextInt(1000));
// 开启线程
threadPoolExecutor.execute(() -> {
log.info("开启线程");
});
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
if (new Random().nextInt(100) == 1) throw new RuntimeException("异常");
return Response.<String>builder()
.code(Constants.ResponseCode.SUCCESS.getCode())
.info(Constants.ResponseCode.SUCCESS.getInfo())
.data("查询用户信息,小傅哥")
.build();
}
}
/**
* HTTP 接口服务
*/
package cn.bugstack.trigger.http;
\ No newline at end of file
/**
* 任务服务,可以选择使用 Spring 默认提供的 Schedule https://bugstack.cn/md/road-map/quartz.html
*/
package cn.bugstack.trigger.job;
\ No newline at end of file
/**
* 监听服务;在单体服务中,解耦流程。类似MQ的使用,如Spring的Event,Guava的事件总线都可以。如果使用了 Redis 那么也可以有发布/订阅使用。
* Guava:https://bugstack.cn/md/road-map/guava.html
*/
package cn.bugstack.trigger.listener;
\ No newline at end of file
/**
* http 提供服务
* job xxl-job 任务调度
* listener RocketMQ 监听
* rpc Dubbo 接口,实现RPC服务
*/
package cn.bugstack.trigger;
\ No newline at end of file
package cn.bugstack.types.common;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
public class Constants {
public final static String SPLIT = ",";
@AllArgsConstructor
@NoArgsConstructor
@Getter
public enum ResponseCode {
SUCCESS("0000", "成功"),
UN_ERROR("0001", "未知失败"),
ILLEGAL_PARAMETER("0002", "非法参数"),
;
private String code;
private String info;
}
}
package cn.bugstack.types.enums;
package cn.bugstack.types.model;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@AllArgsConstructor
import java.io.Serializable;
@Data
@Builder
@NoArgsConstructor
@Getter
public enum ResponseCode {
@AllArgsConstructor
public class Response<T> implements Serializable {
SUCCESS("0000", "成功"),
UN_ERROR("0001", "未知失败"),
ILLEGAL_PARAMETER("0002", "非法参数"),
;
private static final long serialVersionUID = 5130392244064623509L;
private String code;
private String info;
private T data;
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册