├── bitstorm-svr-seckill ├── src │ └── main │ │ ├── java │ │ └── cn │ │ │ └── bitoffer │ │ │ └── seckill │ │ │ ├── dto │ │ │ └── Request.java │ │ │ ├── SecKillApplication.java │ │ │ ├── model │ │ │ ├── SKStatusEnum.java │ │ │ ├── SecKillStock.java │ │ │ ├── Quota.java │ │ │ ├── Example.java │ │ │ ├── UserQuota.java │ │ │ └── PreSecKillRecord.java │ │ │ ├── mapper │ │ │ ├── OrderMapper.java │ │ │ ├── SecKillRecordMapper.java │ │ │ ├── QuotaMapper.java │ │ │ ├── SecKillStockMapper.java │ │ │ ├── ExampleMapper.java │ │ │ ├── GoodsMapper.java │ │ │ └── UserQuotaMapper.java │ │ │ ├── feign │ │ │ └── SecKillFeignController.java │ │ │ ├── common │ │ │ ├── ErrorCode.java │ │ │ ├── BaseModel.java │ │ │ └── ResponseEnum.java │ │ │ ├── exception │ │ │ ├── BusinessException.java │ │ │ └── GlobalExceptionHandler.java │ │ │ └── service │ │ │ └── SecKillService.java │ │ └── resources │ │ └── mapper │ │ ├── QuotaMapper.xml │ │ ├── SecKillStockMapper.xml │ │ ├── SecKillRecordMapper.xml │ │ ├── OrderMapper.xml │ │ └── GoodsMapper.xml ├── wrkbench │ ├── seckillv2_bench.sh │ ├── seckillv1_bench.sh │ ├── luatest.lua │ ├── sec_kill_v1.lua │ ├── sec_kill_v2.lua │ └── sec_kill_v3.lua └── README.md ├── bitstorm-svr-asyncflow ├── worker │ └── src │ │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── zdf │ │ └── worker │ │ ├── boot │ │ └── Launch.java │ │ ├── constant │ │ ├── UserConfig.java │ │ ├── TaskConstant.java │ │ └── TaskUrl.java │ │ ├── data │ │ ├── TaskByTaskIdReturn.java │ │ ├── AsyncTaskRequest.java │ │ ├── TaskList.java │ │ ├── ConfigReturn.java │ │ ├── ReturnStatus.java │ │ ├── NftTaskContext.java │ │ ├── ScheduleData.java │ │ ├── AsyncFlowClientData.java │ │ ├── ScheduleLog.java │ │ ├── AsyncTaskSetStage.java │ │ ├── ScheduleConfig.java │ │ ├── AsyncTaskSetRequest.java │ │ ├── AsyncTaskReturn.java │ │ ├── AsyncTaskBase.java │ │ └── AsyncFlowTask.java │ │ ├── core │ │ ├── AnnType.java │ │ ├── ObserverFunction.java │ │ └── ObserverManager.java │ │ ├── Client │ │ ├── TaskCfgBuilder.java │ │ └── TaskFlower.java │ │ ├── task │ │ └── TaskRet.java │ │ ├── http │ │ └── FlowServer.java │ │ ├── WorkerApplication.java │ │ ├── lock │ │ └── LockParam.java │ │ └── enums │ │ ├── ErrorStatus.java │ │ └── TaskStatus.java ├── flowsvr │ └── src │ │ └── main │ │ ├── java │ │ └── cn │ │ │ └── bitoffer │ │ │ └── asyncflow │ │ │ ├── dto │ │ │ ├── SetTaskReply.java │ │ │ ├── GetTaskScheduleCfgListRequest.java │ │ │ ├── GetTaskRequest.java │ │ │ ├── SetTaskRequest.java │ │ │ ├── CreateTaskRequest.java │ │ │ ├── HoldTasksRequest.java │ │ │ ├── HoldTasksReply.java │ │ │ ├── GetTaskListReply.java │ │ │ ├── GetTaskListRequest.java │ │ │ ├── GetTaskReply.java │ │ │ ├── CreateReply.java │ │ │ ├── GetTaskScheduleCfgListReply.java │ │ │ └── TaskData.java │ │ │ ├── enums │ │ │ └── TaskStatus.java │ │ │ ├── mapper │ │ │ ├── TaskPosMapper.java │ │ │ ├── TaskScheduleCfgMapper.java │ │ │ └── TaskMapper.java │ │ │ ├── AsyncflowApplication.java │ │ │ ├── JacksonConfig.java │ │ │ ├── common │ │ │ ├── ResponseEnum.java │ │ │ ├── ErrorCode.java │ │ │ └── BaseModel.java │ │ │ ├── exception │ │ │ ├── BusinessException.java │ │ │ └── GlobalExceptionHandler.java │ │ │ ├── service │ │ │ └── AsyncflowService.java │ │ │ ├── model │ │ │ ├── TaskPosModel.java │ │ │ └── TaskScheduleCfgModel.java │ │ │ └── utils │ │ │ └── Base62.java │ │ └── resources │ │ └── application.yml └── .gitignore ├── img ├── image-20240810000600723.png ├── image-20240810000619853.png ├── image-20240810014007937.png ├── image-20240810082307839.png ├── image-20240810082314419.png ├── image-20240810082454572.png ├── image-20240810082650461.png ├── image-20240810084818431.png ├── image-20240810085012728.png └── image-20240810145930504.png ├── wrkbench ├── xtimer_bensh.sh └── xtimer_create_timer.lua ├── bitstorm-svr-improve ├── wrkbench │ ├── incr_count_bench.sh │ ├── create_task_bench.sh │ ├── incr_count_async_bench.sh │ ├── luatest.lua │ ├── create_task.lua │ ├── incr_count.lua │ └── incr_count_async.lua ├── src │ └── main │ │ ├── java │ │ └── cn │ │ │ └── bitoffer │ │ │ └── improve │ │ │ ├── service │ │ │ ├── TaskService.java │ │ │ ├── CountService.java │ │ │ └── impl │ │ │ │ └── TaskServiceImpl.java │ │ │ ├── ImproveApplication.java │ │ │ ├── mapper │ │ │ ├── TaskMapper.java │ │ │ ├── CountMapper.java │ │ │ └── ExampleMapper.java │ │ │ ├── exception │ │ │ ├── ErrorCode.java │ │ │ ├── BusinessException.java │ │ │ └── GlobalExceptionHandler.java │ │ │ ├── model │ │ │ ├── Task.java │ │ │ ├── Count.java │ │ │ └── Example.java │ │ │ └── schedued │ │ │ └── ScheduledTask.java │ │ └── resources │ │ └── mapper │ │ ├── TaskMapper.xml │ │ └── CountMapper.xml └── README.md ├── bitstorm-svr-leaf └── src │ └── main │ ├── java │ └── cn │ │ └── bitoffer │ │ └── leaf │ │ ├── common │ │ ├── Status.java │ │ └── Result.java │ │ ├── exception │ │ ├── InitException.java │ │ ├── NoKeyException.java │ │ └── LeafServerException.java │ │ ├── service │ │ ├── IDGen.java │ │ └── SegmentService.java │ │ ├── LeafApplication.java │ │ ├── segment │ │ ├── dao │ │ │ └── IDAllocDao.java │ │ └── model │ │ │ ├── LeafAlloc.java │ │ │ └── Segment.java │ │ └── feign │ │ └── SegmentFeignController.java │ └── resources │ └── application.yml ├── bitstorm-svr-lottery ├── src │ └── main │ │ ├── resources │ │ ├── scripts │ │ │ ├── wrkv1.sh │ │ │ ├── wrkv2.sh │ │ │ ├── wrkv3.sh │ │ │ ├── test.lua │ │ │ └── lottery.lua │ │ └── mapper │ │ │ ├── BlackIpMapper.xml │ │ │ └── LotteryTimesMapper.xml │ │ └── java │ │ └── cn │ │ └── bitoffer │ │ └── lottery │ │ ├── mapper │ │ ├── ResultMapper.java │ │ ├── LotteryTimesMapper.java │ │ ├── CouponMapper.java │ │ ├── BlackIpMapper.java │ │ ├── BlackUserMapper.java │ │ └── PrizeMapper.java │ │ ├── scheduler │ │ ├── TimePrizeInfo.java │ │ ├── ShedulerUserTask.java │ │ └── ShedulerIpTask.java │ │ ├── common │ │ ├── ResponseEnum.java │ │ └── ErrorCode.java │ │ ├── service │ │ └── LotteryService.java │ │ ├── controller │ │ └── ViewCoupon.java │ │ ├── LotteryApplication.java │ │ ├── model │ │ ├── LotteryUserInfo.java │ │ ├── CheckResult.java │ │ ├── LotteryResult.java │ │ ├── BlackIp.java │ │ ├── LotteryTimes.java │ │ └── Coupon.java │ │ ├── config │ │ └── TaskConfig.java │ │ ├── utils │ │ └── UtilTools.java │ │ └── kafka │ │ └── consumer │ │ └── HelloWorldConsumer.java └── README.md ├── bitstorm-svr-xtimer ├── src │ └── main │ │ └── java │ │ └── cn │ │ └── bitoffer │ │ └── xtimer │ │ ├── manager │ │ └── MigratorManager.java │ │ ├── enums │ │ ├── TaskStatus.java │ │ └── TimerStatus.java │ │ ├── service │ │ ├── XTimerService.java │ │ └── trigger │ │ │ └── TriggerPoolTask.java │ │ ├── XTimerApplication.java │ │ ├── controller │ │ ├── TestController.java │ │ └── XtimerWebController.java │ │ ├── exception │ │ ├── ErrorCode.java │ │ ├── BusinessException.java │ │ └── GlobalExceptionHandler.java │ │ ├── feign │ │ └── XTimerFeignController.java │ │ └── mapper │ │ ├── TimerMapper.java │ │ └── TaskMapper.java └── README.md ├── bitstorm-svr-testconsumer ├── src │ └── main │ │ ├── resources │ │ └── application.yml │ │ └── java │ │ └── cn │ │ └── bitoffer │ │ └── testconsumer │ │ ├── ConsumerApplication.java │ │ └── controller │ │ └── ConsumerController.java └── README.md ├── bitstorm-svr-user ├── src │ └── main │ │ ├── resources │ │ └── application.yml │ │ └── java │ │ └── cn │ │ └── bitoffer │ │ └── auth │ │ └── UserApplication.java └── README.md ├── bitstorm-svr-auth ├── README.md └── src │ └── main │ ├── java │ └── cn │ │ └── bitoffer │ │ └── auth │ │ ├── AuthApplication.java │ │ ├── dto │ │ └── AuthRequest.java │ │ ├── model │ │ ├── UserCredential.java │ │ └── LoginUser.java │ │ └── service │ │ ├── AuthService.java │ │ └── CustomUserDetailsService.java │ └── resources │ └── application.yml ├── bitstorm-svr-gateway ├── README.md └── src │ └── main │ └── java │ └── cn │ └── bitoffer │ └── gateway │ └── GatewayApplication.java ├── bitstorm-svr-shorturlx ├── src │ └── main │ │ ├── java │ │ └── cn │ │ │ └── bitoffer │ │ │ └── shorturlx │ │ │ ├── schedued │ │ │ └── ScheduledTask.java │ │ │ ├── common │ │ │ ├── conf │ │ │ │ └── AppConf.java │ │ │ ├── ResponseEnum.java │ │ │ ├── ErrorCode.java │ │ │ └── BaseModel.java │ │ │ ├── service │ │ │ └── ShortUrlXService.java │ │ │ ├── dto │ │ │ └── ExamplePostRequest.java │ │ │ ├── mapper │ │ │ └── UrlMapMapper.java │ │ │ ├── ShortUrlXApplication.java │ │ │ ├── JacksonConfig.java │ │ │ ├── exception │ │ │ ├── BusinessException.java │ │ │ └── GlobalExceptionHandler.java │ │ │ ├── model │ │ │ └── UrlMap.java │ │ │ ├── utils │ │ │ └── Base62.java │ │ │ └── feign │ │ │ └── ShortUrlXFeignController.java │ │ └── resources │ │ ├── application.yml │ │ └── mapper │ │ └── UrlMapMapper.xml └── .gitignore ├── bitstorm-svr-demo ├── README.md └── src │ └── main │ ├── java │ └── cn │ │ └── bitoffer │ │ └── improve │ │ ├── service │ │ ├── ExampleService.java │ │ └── impl │ │ │ └── ExampleServiceImpl.java │ │ ├── schedued │ │ └── ScheduledTask.java │ │ ├── DemoApplication.java │ │ ├── exception │ │ ├── ErrorCode.java │ │ ├── BusinessException.java │ │ └── GlobalExceptionHandler.java │ │ ├── mapper │ │ └── ExampleMapper.java │ │ ├── model │ │ └── Example.java │ │ ├── kafka │ │ └── consumer │ │ │ └── HelloWorldConsumer.java │ │ ├── controller │ │ └── DemoController.java │ │ └── feign │ │ └── DemoFeignController.java │ └── resources │ └── application.yml ├── bitstorm-svr-api ├── src │ └── main │ │ └── java │ │ └── cn │ │ └── bitoffer │ │ └── api │ │ ├── feign │ │ ├── DemoClient.java │ │ ├── TestSeckillClient.java │ │ ├── LeafFeignClient.java │ │ ├── LotteryClient.java │ │ ├── XTimerClient.java │ │ └── interceptor │ │ │ └── ContextFeignInterceptor.java │ │ └── dto │ │ └── xtimer │ │ ├── LotteryParam.java │ │ └── NotifyHTTPParam.java └── pom.xml ├── bitstorm-svr-common ├── src │ └── main │ │ └── java │ │ └── cn │ │ └── bitoffer │ │ └── common │ │ └── model │ │ ├── ResponseEnum.java │ │ └── BaseModel.java └── pom.xml └── db ├── bitstorm-svr-leaf.sql └── bitstorm-svr-demo.sql /bitstorm-svr-seckill/src/main/java/cn/bitoffer/seckill/dto/Request.java: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /img/image-20240810000600723.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnWhite666/HTimer/HEAD/img/image-20240810000600723.png -------------------------------------------------------------------------------- /img/image-20240810000619853.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnWhite666/HTimer/HEAD/img/image-20240810000619853.png -------------------------------------------------------------------------------- /img/image-20240810014007937.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnWhite666/HTimer/HEAD/img/image-20240810014007937.png -------------------------------------------------------------------------------- /img/image-20240810082307839.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnWhite666/HTimer/HEAD/img/image-20240810082307839.png -------------------------------------------------------------------------------- /img/image-20240810082314419.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnWhite666/HTimer/HEAD/img/image-20240810082314419.png -------------------------------------------------------------------------------- /img/image-20240810082454572.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnWhite666/HTimer/HEAD/img/image-20240810082454572.png -------------------------------------------------------------------------------- /img/image-20240810082650461.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnWhite666/HTimer/HEAD/img/image-20240810082650461.png -------------------------------------------------------------------------------- /img/image-20240810084818431.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnWhite666/HTimer/HEAD/img/image-20240810084818431.png -------------------------------------------------------------------------------- /img/image-20240810085012728.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnWhite666/HTimer/HEAD/img/image-20240810085012728.png -------------------------------------------------------------------------------- /img/image-20240810145930504.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShawnWhite666/HTimer/HEAD/img/image-20240810145930504.png -------------------------------------------------------------------------------- /wrkbench/xtimer_bensh.sh: -------------------------------------------------------------------------------- 1 | wrk -t50 -c200 -d30s --script=xtimer_create_timer.lua --latency "http://127.0.0.1:8082/xtimer/createTimer" -------------------------------------------------------------------------------- /bitstorm-svr-improve/wrkbench/incr_count_bench.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | wrk -t8 -c50 -d10s -T1s --script=incr_count.lua --latency "http://127.0.0.1:8081/demo/incr_count" 4 | -------------------------------------------------------------------------------- /bitstorm-svr-improve/wrkbench/create_task_bench.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | wrk -t8 -c50 -d120s -T1s --script=create_task.lua --latency "http://127.0.0.1:8081/demo/create_task" 4 | -------------------------------------------------------------------------------- /bitstorm-svr-leaf/src/main/java/cn/bitoffer/leaf/common/Status.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.leaf.common; 2 | 3 | public enum Status { 4 | SUCCESS, 5 | EXCEPTION 6 | } 7 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/wrkbench/seckillv2_bench.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | wrk -t8 -c100 -d30s -T1s --script=sec_kill_v2.lua --latency "http://127.0.0.1:8001/sec_kill/v2/sec_kill" -------------------------------------------------------------------------------- /bitstorm-svr-seckill/wrkbench/seckillv1_bench.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | wrk -t8 -c100 -d10s -T1s --script=sec_kill_v1.lua --latency "http://127.0.0.1:8001/sec_kill/v1/sec_kill" 4 | -------------------------------------------------------------------------------- /bitstorm-svr-improve/wrkbench/incr_count_async_bench.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | wrk -t8 -c50 -d10s -T1s --script=incr_count_async.lua --latency "http://127.0.0.1:8081/demo/incr_count_async" 4 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/dto/SetTaskReply.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.dto; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class SetTaskReply { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/dto/GetTaskScheduleCfgListRequest.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.dto; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class GetTaskScheduleCfgListRequest { 7 | } 8 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/dto/GetTaskRequest.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.dto; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class GetTaskRequest { 7 | private String taskId; 8 | } 9 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/dto/SetTaskRequest.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.dto; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class SetTaskRequest { 7 | private TaskData taskData; 8 | } 9 | -------------------------------------------------------------------------------- /bitstorm-svr-improve/src/main/java/cn/bitoffer/improve/service/TaskService.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve.service; 2 | 3 | import cn.bitoffer.improve.model.Task; 4 | 5 | public interface TaskService { 6 | 7 | void save(Task task); 8 | } 9 | -------------------------------------------------------------------------------- /bitstorm-svr-leaf/src/main/java/cn/bitoffer/leaf/exception/InitException.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.leaf.exception; 2 | 3 | public class InitException extends Exception{ 4 | public InitException(String msg) { 5 | super(msg); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/resources/scripts/wrkv1.sh: -------------------------------------------------------------------------------- 1 | # /bin/bash 2 | # wrk -t10 -c10 -d5 -s lottery.lua http://localhost:10080/lottery/v1/get_lucky 3 | wrk -t8 -c100 -d10s -T1s --script=lottery.lua --latency "http://localhost:10080/lottery/v1/get_lucky" -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/resources/scripts/wrkv2.sh: -------------------------------------------------------------------------------- 1 | # /bin/bash 2 | # wrk -t10 -c10 -d5 -s lottery.lua http://localhost:10080/lottery/v1/get_lucky 3 | wrk -t10 -c1000 -d30s -T1s --script=lottery.lua --latency "http://localhost:10080/lottery/v2/get_lucky" -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/resources/scripts/wrkv3.sh: -------------------------------------------------------------------------------- 1 | # /bin/bash 2 | # wrk -t10 -c10 -d5 -s lottery.lua http://localhost:10080/lottery/v1/get_lucky 3 | wrk -t10 -c1000 -d30s -T1s --script=lottery.lua --latency "http://localhost:10080/lottery/v3/get_lucky" -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/dto/CreateTaskRequest.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.dto; 2 | 3 | import java.io.Serializable; 4 | 5 | public class CreateTaskRequest implements Serializable { 6 | public TaskData taskData; 7 | } 8 | -------------------------------------------------------------------------------- /bitstorm-svr-xtimer/src/main/java/cn/bitoffer/xtimer/manager/MigratorManager.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.xtimer.manager; 2 | 3 | import cn.bitoffer.xtimer.model.TimerModel; 4 | 5 | public interface MigratorManager{ 6 | public void migrateTimer(TimerModel timerModel); 7 | } 8 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/dto/HoldTasksRequest.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.dto; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class HoldTasksRequest { 7 | private String taskType; 8 | private int limit; 9 | } 10 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/dto/HoldTasksReply.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | @Data 8 | public class HoldTasksReply { 9 | private List taskList; 10 | } 11 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/dto/GetTaskListReply.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | @Data 8 | public class GetTaskListReply { 9 | public List taskList; 10 | } 11 | 12 | 13 | -------------------------------------------------------------------------------- /bitstorm-svr-testconsumer/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | 2 | server: 3 | port: 8093 4 | spring: 5 | application: 6 | name: @artifactId@ 7 | cloud: 8 | nacos: 9 | discovery: 10 | server-addr: 127.0.0.1:8848 11 | username: nacos 12 | password: nacos 13 | 14 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/dto/GetTaskListRequest.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.dto; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class GetTaskListRequest { 7 | private String taskType; 8 | private int limit; 9 | private int status; 10 | } 11 | -------------------------------------------------------------------------------- /bitstorm-svr-user/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | 2 | server: 3 | port: 8090 4 | spring: 5 | application: 6 | name: @artifactId@ 7 | cloud: 8 | nacos: 9 | discovery: 10 | server-addr: 127.0.0.1:8848 11 | username: nacos 12 | password: nacos 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/boot/Launch.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.boot; 2 | 3 | public interface Launch { 4 | /** 5 | * Start the server. 6 | */ 7 | int start(); 8 | 9 | /** 10 | * Destroy the server. 11 | */ 12 | int destroy(); 13 | 14 | int init(); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/dto/GetTaskReply.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.dto; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class GetTaskReply { 7 | private TaskData taskData; 8 | 9 | public GetTaskReply() { 10 | this.taskData = new TaskData(); 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/constant/UserConfig.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.constant; 2 | 3 | // 用户配置信息 4 | public class UserConfig { 5 | public final static String USERID; 6 | static { 7 | USERID = "zdf"; 8 | } 9 | public final static int QUEUE_SIZE = 10000; // 线程池等待队列大小 10 | 11 | } 12 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/data/TaskByTaskIdReturn.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.data; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class TaskByTaskIdReturn { 11 | E taskData; 12 | } 13 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/data/AsyncTaskRequest.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.data; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class AsyncTaskRequest { 11 | AsyncFlowClientData taskData; 12 | } 13 | -------------------------------------------------------------------------------- /bitstorm-svr-leaf/src/main/java/cn/bitoffer/leaf/exception/NoKeyException.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.leaf.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.web.bind.annotation.ResponseStatus; 5 | 6 | @ResponseStatus(code=HttpStatus.INTERNAL_SERVER_ERROR,reason="Key is none") 7 | public class NoKeyException extends RuntimeException { 8 | } 9 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/data/TaskList.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.data; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.util.List; 8 | 9 | @Data 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class TaskList { 13 | List taskList; 14 | } 15 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/dto/CreateReply.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | @Data 8 | public class CreateReply implements Serializable { 9 | public String taskId; 10 | 11 | public CreateReply(String taskId) { 12 | this.taskId = taskId; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/data/ConfigReturn.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.data; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.util.List; 8 | 9 | @Data 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class ConfigReturn { 13 | List scheduleCfgList; 14 | } 15 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/data/ReturnStatus.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.data; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class ReturnStatus { 11 | private String msg; 12 | private int code; 13 | private E result; 14 | } -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/dto/GetTaskScheduleCfgListReply.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.dto; 2 | 3 | import cn.bitoffer.asyncflow.model.TaskScheduleCfgModel; 4 | import lombok.Data; 5 | 6 | import java.util.List; 7 | 8 | @Data 9 | public class GetTaskScheduleCfgListReply { 10 | private List taskScheduleCfgList; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /bitstorm-svr-auth/README.md: -------------------------------------------------------------------------------- 1 | # spring boot 模板服务 2 | 3 | 构建子服务项目模板 4 | 5 | ## 接入能力 6 | 7 | * spring cloud nacos 服务注册 8 | * spring cloud nacos 配置中心 9 | * spring cloud open feign 服务通信 10 | * lombok 简化开发 11 | 12 | ## 模板使用 13 | 14 | 1. 复制`bitstorm-svr-tmpl`修改项目名为新项目名称 15 | 2. 修改新项目`pom.xml`文件`artifactId`节点为新项目名称 16 | 3. 修改根项目`pom.xml`文件`modules`节点,加入新项目 17 | 4. 修改`package`包名,包括 import 的包名 18 | 5. 修改`启动类名称` -------------------------------------------------------------------------------- /bitstorm-svr-user/README.md: -------------------------------------------------------------------------------- 1 | # spring boot 模板服务 2 | 3 | 构建子服务项目模板 4 | 5 | ## 接入能力 6 | 7 | * spring cloud nacos 服务注册 8 | * spring cloud nacos 配置中心 9 | * spring cloud open feign 服务通信 10 | * lombok 简化开发 11 | 12 | ## 模板使用 13 | 14 | 1. 复制`bitstorm-svr-tmpl`修改项目名为新项目名称 15 | 2. 修改新项目`pom.xml`文件`artifactId`节点为新项目名称 16 | 3. 修改根项目`pom.xml`文件`modules`节点,加入新项目 17 | 4. 修改`package`包名,包括 import 的包名 18 | 5. 修改`启动类名称` -------------------------------------------------------------------------------- /bitstorm-svr-gateway/README.md: -------------------------------------------------------------------------------- 1 | # spring boot 模板服务 2 | 3 | 构建子服务项目模板 4 | 5 | ## 接入能力 6 | 7 | * spring cloud nacos 服务注册 8 | * spring cloud nacos 配置中心 9 | * spring cloud open feign 服务通信 10 | * lombok 简化开发 11 | 12 | ## 模板使用 13 | 14 | 1. 复制`bitstorm-svr-tmpl`修改项目名为新项目名称 15 | 2. 修改新项目`pom.xml`文件`artifactId`节点为新项目名称 16 | 3. 修改根项目`pom.xml`文件`modules`节点,加入新项目 17 | 4. 修改`package`包名,包括 import 的包名 18 | 5. 修改`启动类名称` -------------------------------------------------------------------------------- /bitstorm-svr-lottery/README.md: -------------------------------------------------------------------------------- 1 | # spring boot 模板服务 2 | 3 | 构建子服务项目模板 4 | 5 | ## 接入能力 6 | 7 | * spring cloud nacos 服务注册 8 | * spring cloud nacos 配置中心 9 | * spring cloud open feign 服务通信 10 | * lombok 简化开发 11 | 12 | ## 模板使用 13 | 14 | 1. 复制`bitstorm-svr-tmpl`修改项目名为新项目名称 15 | 2. 修改新项目`pom.xml`文件`artifactId`节点为新项目名称 16 | 3. 修改根项目`pom.xml`文件`modules`节点,加入新项目 17 | 4. 修改`package`包名,包括 import 的包名 18 | 5. 修改`启动类名称` -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/java/cn/bitoffer/lottery/mapper/ResultMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.lottery.mapper; 2 | 3 | import cn.bitoffer.lottery.model.Result; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | @Mapper 8 | public interface ResultMapper { 9 | void save(@Param("result") Result result); 10 | 11 | void deleteAll(); 12 | } 13 | -------------------------------------------------------------------------------- /bitstorm-svr-xtimer/README.md: -------------------------------------------------------------------------------- 1 | # spring boot 模板服务 2 | 3 | 构建子服务项目模板 4 | 5 | ## 接入能力 6 | 7 | * spring cloud nacos 服务注册 8 | * spring cloud nacos 配置中心 9 | * spring cloud open feign 服务通信 10 | * lombok 简化开发 11 | 12 | ## 模板使用 13 | 14 | 1. 复制`bitstorm-svr-tmpl`修改项目名为新项目名称 15 | 2. 修改新项目`pom.xml`文件`artifactId`节点为新项目名称 16 | 3. 修改根项目`pom.xml`文件`modules`节点,加入新项目 17 | 4. 修改`package`包名,包括 import 的包名 18 | 5. 修改`启动类名称` -------------------------------------------------------------------------------- /bitstorm-svr-testconsumer/README.md: -------------------------------------------------------------------------------- 1 | # spring boot 模板服务 2 | 3 | 构建子服务项目模板 4 | 5 | ## 接入能力 6 | 7 | * spring cloud nacos 服务注册 8 | * spring cloud nacos 配置中心 9 | * spring cloud open feign 服务通信 10 | * lombok 简化开发 11 | 12 | ## 模板使用 13 | 14 | 1. 复制`bitstorm-svr-tmpl`修改项目名为新项目名称 15 | 2. 修改新项目`pom.xml`文件`artifactId`节点为新项目名称 16 | 3. 修改根项目`pom.xml`文件`modules`节点,加入新项目 17 | 4. 修改`package`包名,包括 import 的包名 18 | 5. 修改`启动类名称` -------------------------------------------------------------------------------- /bitstorm-svr-shorturlx/src/main/java/cn/bitoffer/shorturlx/schedued/ScheduledTask.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.shorturlx.schedued; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class ScheduledTask { 7 | 8 | // @Scheduled(fixedRate = 3000) 9 | // public void scheduledTask() { 10 | // System.out.println("任务执行时间:" + LocalDateTime.now()); 11 | // } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/data/NftTaskContext.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.data; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class NftTaskContext { 11 | private Object[] params; 12 | private Object[] envs; 13 | private Class[] clazz; 14 | } 15 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/data/ScheduleData.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.data; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class ScheduleData { 13 | String traceId; 14 | String errMsg; 15 | String cost; 16 | } 17 | -------------------------------------------------------------------------------- /bitstorm-svr-demo/README.md: -------------------------------------------------------------------------------- 1 | # spring boot 模板服务 2 | 3 | 构建子服务项目模板 4 | 5 | ## 接入能力 6 | 7 | * spring cloud nacos 服务注册 8 | * spring cloud nacos 配置中心 9 | * spring cloud open feign 服务通信 10 | * lombok 简化开发 11 | 12 | ## 模板使用 13 | 14 | 1. 复制`bitstorm-svr-demo`修改项目名为新项目名称(建议本地文件夹复制,不要在idel中复制) 15 | 2. 修改新项目`pom.xml`文件`artifactId`节点为新项目名称 16 | 3. 修改根项目`pom.xml`文件`modules`节点,加入新项目 17 | 4. 修改`package`包名,包括 import 的包名 18 | 5. 修改`启动类名称` -------------------------------------------------------------------------------- /bitstorm-svr-improve/README.md: -------------------------------------------------------------------------------- 1 | # spring boot 模板服务 2 | 3 | 构建子服务项目模板 4 | 5 | ## 接入能力 6 | 7 | * spring cloud nacos 服务注册 8 | * spring cloud nacos 配置中心 9 | * spring cloud open feign 服务通信 10 | * lombok 简化开发 11 | 12 | ## 模板使用 13 | 14 | 1. 复制`bitstorm-svr-demo`修改项目名为新项目名称(建议本地文件夹复制,不要在idel中复制) 15 | 2. 修改新项目`pom.xml`文件`artifactId`节点为新项目名称 16 | 3. 修改根项目`pom.xml`文件`modules`节点,加入新项目 17 | 4. 修改`package`包名,包括 import 的包名 18 | 5. 修改`启动类名称` -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/resources/scripts/test.lua: -------------------------------------------------------------------------------- 1 | -- body1="{\"user_id\": " 2 | -- body2=", \"user_name\": \"zhangsan\", \"ip\":\"192.168.9.9\"}" 3 | -- user_id=tostring(math.random(1000000)) 4 | -- body=body1..user_id..body2 5 | -- print(body) 6 | 7 | body1='{"user_id": ' 8 | body2=', "user_name": "zhangsan", "ip":"192.168.9.9"}' 9 | user_id=tostring(math.random(1000000)) 10 | body=body1..user_id..body2 11 | print(body) 12 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/README.md: -------------------------------------------------------------------------------- 1 | # spring boot 模板服务 2 | 3 | 构建子服务项目模板 4 | 5 | ## 接入能力 6 | 7 | * spring cloud nacos 服务注册 8 | * spring cloud nacos 配置中心 9 | * spring cloud open feign 服务通信 10 | * lombok 简化开发 11 | 12 | ## 模板使用 13 | 14 | 1. 复制`bitstorm-svr-seckill`修改项目名为新项目名称(建议本地文件夹复制,不要在idel中复制) 15 | 2. 修改新项目`pom.xml`文件`artifactId`节点为新项目名称 16 | 3. 修改根项目`pom.xml`文件`modules`节点,加入新项目 17 | 4. 修改`package`包名,包括 import 的包名 18 | 5. 修改`启动类名称` -------------------------------------------------------------------------------- /bitstorm-svr-xtimer/src/main/java/cn/bitoffer/xtimer/enums/TaskStatus.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.xtimer.enums; 2 | 3 | public enum TaskStatus { 4 | NotRun(0), 5 | Running(1), 6 | Succeed(2), 7 | Failed(3); 8 | 9 | private TaskStatus(int status) { 10 | this.status = status; 11 | } 12 | private int status; 13 | 14 | public int getStatus() { 15 | return this.status; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /bitstorm-svr-improve/src/main/java/cn/bitoffer/improve/service/CountService.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve.service; 2 | 3 | import cn.bitoffer.improve.model.Count; 4 | 5 | public interface CountService { 6 | 7 | void save(Count example); 8 | 9 | void update(Count example); 10 | 11 | void incrCount(Integer num); 12 | void incrMemCountAndReset(); 13 | void incrCountAsync(Integer num); 14 | 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /bitstorm-svr-leaf/src/main/java/cn/bitoffer/leaf/service/IDGen.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.leaf.service; 2 | 3 | 4 | import cn.bitoffer.leaf.common.Result; 5 | 6 | /** 7 | * @author leaf 8 | */ 9 | public interface IDGen { 10 | 11 | /** 12 | * get 13 | * @param key key 14 | * @return Result 15 | */ 16 | Result get(String key); 17 | 18 | /** 19 | * init 20 | * @return inited 21 | */ 22 | boolean init(); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /wrkbench/xtimer_create_timer.lua: -------------------------------------------------------------------------------- 1 | wrk.method = "POST" 2 | 3 | wrk.body = "{\"app\":\"testXtimer\",\"name\":\"测试Xtimer\",\"cron\":\"0 * * ? * *\",\"notifyHTTPParam\":{\"url\":\"http://127.0.0.1:8082/xtimer/callback\",\"method\":\"POST\",\"body\":\" its time on. this is a callback msg\"}}" 4 | 5 | wrk.headers["Content-Type"] = "application/json" 6 | 7 | function request() 8 | return wrk.format('POST',nil,headers,body) 9 | end 10 | 11 | -------------------------------------------------------------------------------- /bitstorm-svr-leaf/src/main/java/cn/bitoffer/leaf/exception/LeafServerException.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.leaf.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.web.bind.annotation.ResponseStatus; 5 | 6 | @ResponseStatus(code=HttpStatus.INTERNAL_SERVER_ERROR) 7 | public class LeafServerException extends RuntimeException { 8 | public LeafServerException(String msg) { 9 | super(msg); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/java/cn/bitoffer/seckill/SecKillApplication.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.seckill; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication(scanBasePackages = {"cn.bitoffer"}) 7 | public class SecKillApplication { 8 | public static void main(String[] args) { 9 | SpringApplication.run(SecKillApplication.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /bitstorm-svr-shorturlx/src/main/java/cn/bitoffer/shorturlx/common/conf/AppConf.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.shorturlx.common.conf; 2 | 3 | import lombok.Data; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Data 8 | @Component 9 | public class AppConf { 10 | 11 | @Value("${app.workId}") 12 | private int workId; 13 | 14 | @Value("${app.workerIdBits}") 15 | private int workerIdBits; 16 | } 17 | 18 | 19 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/java/cn/bitoffer/seckill/model/SKStatusEnum.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.seckill.model; 2 | 3 | public enum SKStatusEnum { 4 | SK_STATUS_BEFORE_ORDER(1), 5 | SK_STATUS_BEFORE_PAY(2), 6 | SK_STATUS_PAYED(3), 7 | SK_STATUS_OOT(4), 8 | SK_STATUS_CANCEL(5); 9 | 10 | private int value; 11 | 12 | SKStatusEnum(int value) { 13 | this.value = value; 14 | } 15 | 16 | public int getValue() { 17 | return value; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/enums/TaskStatus.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.enums; 2 | 3 | public enum TaskStatus { 4 | TASK_STATUS_PENDING(1), 5 | TASK_STATUS_PROCESSING(2), 6 | TASK_STATUS_SUCCESS(3), 7 | TASK_STATUS_FAILED(4); 8 | 9 | private TaskStatus(int status) { 10 | this.status = status; 11 | } 12 | 13 | private final int status; 14 | 15 | public int getStatus() { 16 | return this.status; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /bitstorm-svr-leaf/src/main/java/cn/bitoffer/leaf/LeafApplication.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.leaf; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | /** 7 | * @author leaf 8 | */ 9 | @SpringBootApplication(scanBasePackages = {"cn.bitoffer"}) 10 | public class LeafApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(LeafApplication.class, args); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /bitstorm-svr-demo/src/main/java/cn/bitoffer/improve/service/ExampleService.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve.service; 2 | 3 | import cn.bitoffer.improve.model.Example; 4 | 5 | public interface ExampleService { 6 | 7 | void save(Example example); 8 | 9 | void update(Example example); 10 | 11 | Example getExampleById(Long id); 12 | 13 | void deleteExampleById(Long id); 14 | 15 | void cacheExampleToRedis(Example example); 16 | 17 | Example getExampleFromRedis(String exampleId); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/mapper/TaskPosMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.mapper; 2 | 3 | import cn.bitoffer.asyncflow.model.TaskPosModel; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | import java.util.List; 7 | 8 | @Mapper 9 | public interface TaskPosMapper { 10 | void create(TaskPosModel taskPos); 11 | 12 | void save(TaskPosModel taskPos); 13 | 14 | 15 | TaskPosModel getTaskPos(String taskType); 16 | 17 | List getTaskPosList(); 18 | } 19 | -------------------------------------------------------------------------------- /bitstorm-svr-api/src/main/java/cn/bitoffer/api/feign/DemoClient.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.api.feign; 2 | 3 | 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | @FeignClient("bitstorm-svr-demo") 9 | public interface DemoClient { 10 | 11 | /** 12 | * demo 服务接口 13 | */ 14 | @GetMapping(value = "/call") 15 | public String call(@RequestParam("name") String name); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /bitstorm-svr-shorturlx/src/main/java/cn/bitoffer/shorturlx/service/ShortUrlXService.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.shorturlx.service; 2 | 3 | /** 4 | * @author 狂飙训练营 5 | */ 6 | public interface ShortUrlXService { 7 | 8 | String getV1LongUrl(String shortUrl); 9 | String getV2LongUrl(String shortUrl); 10 | 11 | String getV3LongUrl(String shortUrl); 12 | 13 | String createV1ShortUrl(String longUrl); 14 | 15 | String createV2ShortUrl(String longUrl); 16 | 17 | String createV3ShortUrl(String longUrl); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/core/AnnType.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.core; 2 | 3 | import com.zdf.worker.boot.AppLaunch; 4 | 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | @Retention(RetentionPolicy.RUNTIME) 11 | @Target(ElementType.METHOD) 12 | public @interface AnnType { 13 | AppLaunch.ObserverType observerType(); 14 | String taskType() default "*"; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/java/cn/bitoffer/lottery/scheduler/TimePrizeInfo.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.lottery.scheduler; 2 | 3 | public class TimePrizeInfo { 4 | private String time; 5 | private int num; 6 | 7 | public String getTime() { 8 | return time; 9 | } 10 | 11 | public void setTime(String time) { 12 | this.time = time; 13 | } 14 | 15 | public int getNum() { 16 | return num; 17 | } 18 | 19 | public void setNum(int num) { 20 | this.num = num; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/mapper/TaskScheduleCfgMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.mapper; 2 | 3 | import cn.bitoffer.asyncflow.model.TaskScheduleCfgModel; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | import java.util.List; 7 | 8 | @Mapper 9 | public interface TaskScheduleCfgMapper { 10 | TaskScheduleCfgModel getTaskTypeCfg(String taskType); 11 | 12 | 13 | void save(TaskScheduleCfgModel scheduleConfig); 14 | 15 | List getTaskTypeCfgList(); 16 | } 17 | -------------------------------------------------------------------------------- /bitstorm-svr-demo/src/main/java/cn/bitoffer/improve/schedued/ScheduledTask.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve.schedued; 2 | 3 | import org.springframework.scheduling.annotation.Scheduled; 4 | import org.springframework.stereotype.Component; 5 | 6 | import java.time.LocalDateTime; 7 | 8 | /** 9 | * 定时任务模版 10 | * 11 | **/ 12 | @Component 13 | public class ScheduledTask { 14 | 15 | @Scheduled(fixedRate = 3000) 16 | public void scheduledTask() { 17 | System.out.println("任务执行时间 is :" + LocalDateTime.now()); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/Client/TaskCfgBuilder.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.Client; 2 | 3 | import com.zdf.worker.data.ScheduleConfig; 4 | 5 | public class TaskCfgBuilder { 6 | // 构建任务配置 7 | public ScheduleConfig build(Class clazz, int schedule_limit, int schedule_interval, int max_processing_time, int max_retry_num, int retry_interval) { 8 | return new ScheduleConfig(clazz.getSimpleName(), schedule_limit, schedule_interval, max_processing_time, max_retry_num, retry_interval, 0L, 0L); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/task/TaskRet.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.task; 2 | 3 | import com.zdf.worker.data.AsyncTaskSetStage; 4 | import lombok.Data; 5 | 6 | @Data 7 | public class TaskRet { 8 | T result; 9 | AsyncTaskSetStage asyncTaskSetStage; 10 | public TaskRet(T result) { 11 | this(result, null); 12 | } 13 | public TaskRet(T result, AsyncTaskSetStage asyncTaskSetStage) { 14 | this.result = result; 15 | this.asyncTaskSetStage = asyncTaskSetStage; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /bitstorm-svr-api/src/main/java/cn/bitoffer/api/feign/TestSeckillClient.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.api.feign; 2 | 3 | 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | @FeignClient("bitstorm-svr-seckill") 9 | public interface TestSeckillClient { 10 | 11 | /** 12 | * 测试 13 | * 14 | */ 15 | @GetMapping(value = "/call") 16 | public String call(@RequestParam("name") String name); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/data/AsyncFlowClientData.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.data; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class AsyncFlowClientData { 11 | 12 | private String user_id; 13 | 14 | private String task_type; 15 | 16 | private String task_stage; 17 | 18 | private String schedule_log; 19 | 20 | private String task_context; 21 | 22 | 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/data/ScheduleLog.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.data; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | @Data 11 | @AllArgsConstructor 12 | @Builder 13 | public class ScheduleLog { 14 | ScheduleData lastData; 15 | List historyDatas; 16 | public ScheduleLog() { 17 | lastData = new ScheduleData(); 18 | historyDatas = new ArrayList<>(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/java/cn/bitoffer/lottery/common/ResponseEnum.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.lottery.common; 2 | 3 | public enum ResponseEnum { 4 | OK(0, "ok"), 5 | FAIL(1, "fail"), 6 | ; 7 | private final int code; 8 | private final String message; 9 | 10 | ResponseEnum(int code, String message) { 11 | this.code = code; 12 | this.message = message; 13 | } 14 | 15 | public int code() { 16 | return code; 17 | } 18 | 19 | public String message() { 20 | return message; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /bitstorm-svr-shorturlx/src/main/java/cn/bitoffer/shorturlx/common/ResponseEnum.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.shorturlx.common; 2 | 3 | public enum ResponseEnum { 4 | OK(0, "ok"), 5 | FAIL(1, "fail"),; 6 | 7 | private final int code; 8 | private final String message; 9 | 10 | ResponseEnum(int code, String message) { 11 | this.code = code; 12 | this.message = message; 13 | } 14 | 15 | public int code() { 16 | return code; 17 | } 18 | 19 | public String message() { 20 | return message; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /bitstorm-svr-demo/src/main/java/cn/bitoffer/improve/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.scheduling.annotation.EnableScheduling; 6 | 7 | @SpringBootApplication(scanBasePackages = {"cn.bitoffer"}) 8 | @EnableScheduling 9 | public class DemoApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(DemoApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /bitstorm-svr-auth/src/main/java/cn/bitoffer/auth/AuthApplication.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.auth; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | 7 | @SpringBootApplication(scanBasePackages = {"cn.bitoffer"}) 8 | @EnableFeignClients("cn.bitoffer.*") 9 | public class AuthApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(AuthApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /bitstorm-svr-user/src/main/java/cn/bitoffer/auth/UserApplication.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.auth; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | 7 | @SpringBootApplication(scanBasePackages = {"cn.bitoffer"}) 8 | @EnableFeignClients("cn.bitoffer.*") 9 | public class UserApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(UserApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /bitstorm-svr-improve/src/main/java/cn/bitoffer/improve/ImproveApplication.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.scheduling.annotation.EnableScheduling; 6 | 7 | @SpringBootApplication(scanBasePackages = {"cn.bitoffer"}) 8 | @EnableScheduling 9 | public class ImproveApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ImproveApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/constant/TaskConstant.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.constant; 2 | 3 | /** 4 | * 任务常量 5 | */ 6 | public class TaskConstant { 7 | public final static int DEFAULT_TIME_INTERVAL = 20; 8 | public final static int MAX_ERR_MSG_LEN = 256; 9 | private final static int SCHEDULE_LIMIT = 10; 10 | private final static int SCHEDULE_INTERVAL = 10; 11 | private final static int MAX_PROCESSING_TIME = 60; 12 | private final static int MAX_RETRY_NUM = 5; 13 | private final static int RETRY_INTERVAL = 10; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /bitstorm-svr-auth/src/main/java/cn/bitoffer/auth/dto/AuthRequest.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.auth.dto; 2 | 3 | public class AuthRequest { 4 | private String username; 5 | private String password; 6 | 7 | public String getUsername() { 8 | return username; 9 | } 10 | 11 | public void setUsername(String username) { 12 | this.username = username; 13 | } 14 | 15 | public String getPassword() { 16 | return password; 17 | } 18 | 19 | public void setPassword(String password) { 20 | this.password = password; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/java/cn/bitoffer/lottery/service/LotteryService.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.lottery.service; 2 | 3 | import cn.bitoffer.lottery.model.LotteryPrizeInfo; 4 | import cn.bitoffer.lottery.model.LotteryResult; 5 | 6 | import java.text.ParseException; 7 | 8 | public interface LotteryService { 9 | 10 | LotteryResult lottery(Long userID, String userName, String ip) throws ParseException; 11 | 12 | // LotteryPrizeInfo lotteryV2(int userID,String userName,String ip); 13 | // 14 | // LotteryPrizeInfo lotteryV3(int userID,String userName,String ip); 15 | } 16 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/data/AsyncTaskSetStage.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.data; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @Builder 10 | public class AsyncTaskSetStage { 11 | 12 | private String task_stage; //NOT NULL DEFAULT '', 存储任务阶段信息 13 | 14 | private int status; //tinyint(3) unsigned NOT NULL DEFAULT '0', 15 | 16 | private NftTaskContext task_context;// varchar(8192) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '任务上下文,用户自定义', 17 | 18 | } 19 | -------------------------------------------------------------------------------- /bitstorm-svr-gateway/src/main/java/cn/bitoffer/gateway/GatewayApplication.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.gateway; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | 7 | @SpringBootApplication(scanBasePackages = {"cn.bitoffer"}) 8 | @EnableFeignClients("cn.bitoffer.*") 9 | public class GatewayApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(GatewayApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/java/cn/bitoffer/lottery/mapper/LotteryTimesMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.lottery.mapper; 2 | 3 | import cn.bitoffer.lottery.model.LotteryTimes; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | @Mapper 8 | public interface LotteryTimesMapper { 9 | LotteryTimes getByUserIDAndDay(@Param("userID") Long userID, @Param("day") Long day); 10 | 11 | void save(@Param("lotteryTimes") LotteryTimes lotteryTimes); 12 | 13 | void update(@Param("lotteryTimes") LotteryTimes lotteryTimes); 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /bitstorm-svr-improve/wrkbench/luatest.lua: -------------------------------------------------------------------------------- 1 | function getRandom(n) 2 | local t = { 3 | "0","1","2","3","4","5","6","7","8","9", 4 | "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z", 5 | "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z", 6 | } 7 | local s = "" 8 | for i =1, n do 9 | s = s .. t[math.random(#t)] 10 | end; 11 | return s 12 | end; 13 | 14 | local a = getRandom(32) 15 | local b = math.random(1000000) 16 | print(a) 17 | print(b) 18 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/java/cn/bitoffer/lottery/controller/ViewCoupon.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.lottery.controller; 2 | 3 | import java.util.Date; 4 | 5 | public class ViewCoupon { 6 | private int prizeId; 7 | private String code; 8 | 9 | 10 | public int getPrizeId() { 11 | return prizeId; 12 | } 13 | 14 | public void setPrizeId(int prizeId) { 15 | this.prizeId = prizeId; 16 | } 17 | 18 | public String getCode() { 19 | return code; 20 | } 21 | 22 | public void setCode(String code) { 23 | this.code = code; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/java/cn/bitoffer/seckill/mapper/OrderMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.seckill.mapper; 2 | 3 | 4 | import cn.bitoffer.seckill.model.Order; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | @Mapper 9 | public interface OrderMapper { 10 | 11 | /** 12 | * 保存Order 13 | * 14 | * @param order 15 | */ 16 | void save(@Param("order") Order order); 17 | 18 | /** 19 | * 更新Order 20 | * 21 | * @param order 22 | */ 23 | void update(@Param("order") Order order); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/wrkbench/luatest.lua: -------------------------------------------------------------------------------- 1 | function getRandom(n) 2 | local t = { 3 | "0","1","2","3","4","5","6","7","8","9", 4 | "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z", 5 | "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z", 6 | } 7 | local s = "" 8 | for i =1, n do 9 | s = s .. t[math.random(#t)] 10 | end; 11 | return s 12 | end; 13 | 14 | local a = getRandom(32) 15 | local b = math.random(1000000) 16 | print(a) 17 | print(b) 18 | -------------------------------------------------------------------------------- /bitstorm-svr-testconsumer/src/main/java/cn/bitoffer/testconsumer/ConsumerApplication.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.testconsumer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | 7 | @SpringBootApplication(scanBasePackages = {"cn.bitoffer"}) 8 | @EnableFeignClients("cn.bitoffer.*") 9 | public class ConsumerApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ConsumerApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /bitstorm-svr-xtimer/src/main/java/cn/bitoffer/xtimer/service/XTimerService.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.xtimer.service; 2 | 3 | import cn.bitoffer.api.dto.xtimer.TimerDTO; 4 | 5 | import java.util.List; 6 | 7 | public interface XTimerService { 8 | 9 | Long CreateTimer(TimerDTO timerDTO); 10 | 11 | void DeleteTimer(String app, long id); 12 | 13 | void Update(TimerDTO timerDTO); 14 | 15 | TimerDTO GetTimer(String app, long id); 16 | 17 | void EnableTimer(String app, long id); 18 | 19 | void UnEnableTimer(String app, long id); 20 | 21 | List GetAppTimers(String app); 22 | } 23 | -------------------------------------------------------------------------------- /bitstorm-svr-shorturlx/src/main/java/cn/bitoffer/shorturlx/dto/ExamplePostRequest.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.shorturlx.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | 8 | /** 9 | * Post请求 10 | * 11 | */ 12 | @Data 13 | public class ExamplePostRequest implements Serializable { 14 | 15 | /** 16 | * 名称 17 | */ 18 | private String name; 19 | 20 | /** 21 | * 年龄 22 | */ 23 | private int age; 24 | 25 | /** 26 | * 标签列表 27 | */ 28 | private List tags; 29 | 30 | private static final long serialVersionUID = 1L; 31 | } -------------------------------------------------------------------------------- /bitstorm-svr-shorturlx/src/main/java/cn/bitoffer/shorturlx/mapper/UrlMapMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.shorturlx.mapper; 2 | 3 | 4 | import cn.bitoffer.shorturlx.model.UrlMap; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | @Mapper 9 | public interface UrlMapMapper { 10 | 11 | 12 | void dbCreate(@Param("urlMap") UrlMap urlMap); 13 | 14 | String dbGetShortUrl(@Param("longUrl") String longUrl); 15 | String dbGetLongUrl(@Param("shortUrl") String shortUrl); 16 | void dbUpdate(@Param("shortUrl") String shortUrl, @Param("longUrl") String longUrl); 17 | } 18 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/data/ScheduleConfig.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.data; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class ScheduleConfig { 11 | private String task_type; 12 | private Integer schedule_limit; 13 | private Integer schedule_interval; 14 | private Integer max_processing_time; 15 | private Integer max_retry_num; 16 | private Integer retry_interval; 17 | private Long create_time; 18 | private Long modify_time; 19 | } 20 | -------------------------------------------------------------------------------- /bitstorm-svr-shorturlx/src/main/java/cn/bitoffer/shorturlx/ShortUrlXApplication.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.shorturlx; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.scheduling.annotation.EnableScheduling; 6 | 7 | /** 8 | * @author Administrator 9 | */ 10 | @SpringBootApplication(scanBasePackages = {"cn.bitoffer"}) 11 | @EnableScheduling 12 | public class ShortUrlXApplication { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(ShortUrlXApplication.class, args); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/http/FlowServer.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.http; 2 | 3 | import com.zdf.worker.data.*; 4 | 5 | 6 | public interface FlowServer { 7 | ReturnStatus getTaskList(String taskType, int status, int limit); 8 | ReturnStatus createTask(AsyncTaskRequest asyncTaskRequest); 9 | ReturnStatus setTask(AsyncTaskSetRequest asyncTaskSetRequest); 10 | ReturnStatus getTask(String taskId); 11 | 12 | ReturnStatus getTaskTypeCfgList(); 13 | ReturnStatus getUserTaskList(String user_id, int statusList); 14 | ReturnStatus createTaskCFG(ScheduleConfig scheduleConfig); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/AsyncflowApplication.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.scheduling.annotation.EnableScheduling; 6 | 7 | /** 8 | * @author Administrator 9 | */ 10 | @SpringBootApplication(scanBasePackages = {"cn.bitoffer"}) 11 | @EnableScheduling 12 | public class AsyncflowApplication { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(AsyncflowApplication.class, args); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /bitstorm-svr-common/src/main/java/cn/bitoffer/common/model/ResponseEnum.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.common.model; 2 | 3 | public enum ResponseEnum { 4 | OK(0, "ok"), 5 | FAIL(1, "fail"), 6 | /** 7 | * 用于直接显示提示用户的错误,内容由输入内容决定 8 | */ 9 | SHOW_FAIL(1, ""), 10 | ; 11 | private final int code; 12 | private final String message; 13 | 14 | ResponseEnum(int code, String message) { 15 | this.code = code; 16 | this.message = message; 17 | } 18 | 19 | public int code() { 20 | return code; 21 | } 22 | 23 | public String message() { 24 | return message; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /bitstorm-svr-xtimer/src/main/java/cn/bitoffer/xtimer/enums/TimerStatus.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.xtimer.enums; 2 | 3 | public enum TimerStatus { 4 | Unable(1), 5 | Enable(2),; 6 | 7 | private TimerStatus(int status) { 8 | this.status = status; 9 | } 10 | private int status; 11 | 12 | public int getStatus() { 13 | return this.status; 14 | } 15 | 16 | public static TimerStatus getTimerStatus(int status){ 17 | for (TimerStatus value:TimerStatus.values()) { 18 | if(value.status == status){ 19 | return value; 20 | } 21 | } 22 | return null; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/java/cn/bitoffer/seckill/feign/SecKillFeignController.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.seckill.feign; 2 | 3 | import cn.bitoffer.seckill.service.SecKillService; 4 | import cn.bitoffer.api.feign.TestSeckillClient; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | @RestController 10 | @Slf4j 11 | public class SecKillFeignController implements TestSeckillClient { 12 | 13 | @Autowired 14 | private SecKillService secKillService; 15 | public String call(String name) { 16 | return ""; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /bitstorm-svr-api/src/main/java/cn/bitoffer/api/feign/LeafFeignClient.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.api.feign; 2 | 3 | 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.http.ResponseEntity; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RequestParam; 8 | 9 | @FeignClient(name = "bitstorm-svr-leaf", path = "/bitstorm/feign/leaf") 10 | public interface LeafFeignClient { 11 | 12 | /** 13 | * 获取id 14 | * 15 | * @param key 业务标识 16 | */ 17 | @GetMapping(value = "/insider/segment") 18 | ResponseEntity getSegmentID(@RequestParam("key") String key); 19 | } 20 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /bitstorm-svr-shorturlx/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /bitstorm-svr-leaf/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: @artifactId@ 4 | datasource: 5 | url: jdbc:mysql://${MYSQL_HOST:192.168.5.13}:${MYSQL_PORT:3306}/${MYSQL_DATABASE:leaf}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true&useAffectedRows=true 6 | username: ${MYSQL_USERNAME:witt} 7 | password: ${MYSQL_PASSWORD:Witt@2023} 8 | cloud: 9 | nacos: 10 | discovery: 11 | server-addr: ${NACOS_HOST:192.168.5.11}:${NACOS_PORT:8848} 12 | username: nacos 13 | password: nacos -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/java/cn/bitoffer/seckill/mapper/SecKillRecordMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.seckill.mapper; 2 | 3 | 4 | import cn.bitoffer.seckill.model.SecKillRecord; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | @Mapper 9 | public interface SecKillRecordMapper { 10 | 11 | /** 12 | * 保存SecKillRecord 13 | * 14 | * @param secKillRecord 15 | */ 16 | void save(@Param("secKillRecord") SecKillRecord secKillRecord); 17 | 18 | /** 19 | * 更新SecKillRecord 20 | * 21 | * @param secKillRecord 22 | */ 23 | void update(@Param("secKillRecord") SecKillRecord secKillRecord); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/JacksonConfig.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | @Configuration 9 | public class JacksonConfig { 10 | @Bean 11 | public ObjectMapper objectMapper() { 12 | ObjectMapper objectMapper = new ObjectMapper(); 13 | // 设置json下划线自动映射驼峰 14 | objectMapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE); 15 | return objectMapper; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/java/cn/bitoffer/lottery/LotteryApplication.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.lottery; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.scheduling.annotation.EnableAsync; 6 | import org.springframework.scheduling.annotation.EnableScheduling; 7 | 8 | @SpringBootApplication(scanBasePackages = {"cn.bitoffer"}) 9 | //@EnableFeignClients("cn.bitoffer.*") 10 | @EnableScheduling 11 | @EnableAsync 12 | public class LotteryApplication { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(LotteryApplication.class, args); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /bitstorm-svr-shorturlx/src/main/java/cn/bitoffer/shorturlx/JacksonConfig.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.shorturlx; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | @Configuration 9 | public class JacksonConfig { 10 | 11 | @Bean 12 | public ObjectMapper objectMapper() { 13 | ObjectMapper objectMapper = new ObjectMapper(); 14 | // 设置json下划线自动映射驼峰 15 | objectMapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE); 16 | return objectMapper; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /bitstorm-svr-improve/src/main/java/cn/bitoffer/improve/mapper/TaskMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve.mapper; 2 | 3 | 4 | import cn.bitoffer.improve.model.Count; 5 | import cn.bitoffer.improve.model.Task; 6 | import org.apache.ibatis.annotations.Mapper; 7 | import org.apache.ibatis.annotations.Param; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | @Mapper 13 | public interface TaskMapper { 14 | 15 | /** 16 | * 保存Task 17 | * 18 | * @param task 19 | */ 20 | void save(@Param("task") Task task); 21 | 22 | /** 23 | * 根据CountId查询Count 24 | * 25 | * @return Count 26 | */ 27 | Task getTask(@Param("taskID") String taskID); 28 | 29 | } -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/java/cn/bitoffer/seckill/model/SecKillStock.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.seckill.model; 2 | 3 | import cn.bitoffer.seckill.common.BaseModel; 4 | import lombok.Getter; 5 | 6 | import java.io.Serializable; 7 | 8 | public class SecKillStock extends BaseModel implements Serializable { 9 | /** 10 | * Id 11 | */ 12 | private Long ID; 13 | 14 | @Getter 15 | private String secNum; 16 | /** 17 | * Name 18 | */ 19 | @Getter 20 | private Long userID; 21 | private Long goodsID; 22 | private Float price; 23 | private Integer status; 24 | 25 | 26 | @Override 27 | public String toString() { 28 | return secNum; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /bitstorm-svr-auth/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | 2 | server: 3 | port: 8096 4 | spring: 5 | application: 6 | name: @artifactId@ 7 | cloud: 8 | nacos: 9 | discovery: 10 | # server-addr: 127.0.0.1:8848 11 | server-addr: 192.168.5.53:8848 12 | username: nacos 13 | password: nacos 14 | 15 | # redis: 16 | # host: localhost 17 | # port: 6379 18 | # password: root2023 19 | # database: 0 20 | # jedis: 21 | # pool: 22 | # max-active: 8 #最大连接数 23 | 24 | redis: 25 | host: 192.168.5.52 26 | port: 6379 27 | password: 123456 28 | database: 8 29 | jedis: 30 | pool: 31 | max-active: 8 #最大连接数 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /bitstorm-svr-xtimer/src/main/java/cn/bitoffer/xtimer/XTimerApplication.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.xtimer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | import org.springframework.scheduling.annotation.EnableAsync; 7 | import org.springframework.scheduling.annotation.EnableScheduling; 8 | 9 | @SpringBootApplication(scanBasePackages = {"cn.bitoffer"}) 10 | @EnableScheduling 11 | @EnableAsync 12 | public class XTimerApplication { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(XTimerApplication.class, args); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /bitstorm-svr-xtimer/src/main/java/cn/bitoffer/xtimer/controller/TestController.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.xtimer.controller; 2 | 3 | import cn.bitoffer.common.model.ResponseEntity; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.*; 7 | 8 | @RestController 9 | @RequestMapping("/xtimer") 10 | @Slf4j 11 | public class TestController { 12 | 13 | @PostMapping("/callback") 14 | public ResponseEntity callback(@RequestBody String callbackInfo) { 15 | log.info("CALLBACK:"+callbackInfo); 16 | // 消息队列发送消息 17 | return ResponseEntity.ok( 18 | "ok" 19 | ); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/java/cn/bitoffer/lottery/model/LotteryUserInfo.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.lottery.model; 2 | 3 | public class LotteryUserInfo { 4 | Long userId; 5 | String userName; 6 | String ip; 7 | 8 | public Long getUserId() { 9 | return userId; 10 | } 11 | 12 | public void setUserId(Long userId) { 13 | this.userId = userId; 14 | } 15 | 16 | public String getUserName() { 17 | return userName; 18 | } 19 | 20 | public void setUserName(String userName) { 21 | this.userName = userName; 22 | } 23 | 24 | public String getIp() { 25 | return ip; 26 | } 27 | 28 | public void setIp(String ip) { 29 | this.ip = ip; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/common/ResponseEnum.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.common; 2 | 3 | public enum ResponseEnum { 4 | OK(0, "ok"), FAIL(1, "fail"), CREATE_TASK_FAIL(2, "create task fail"), GET_TASK_FAIL(3, "get task fail"), HOLD_TASKS_FAIL(4, "hold tasks fail"), GET_TASK_LIST_FAIL(5, "get task list fail"), Set_Task_Fail(6, "set task fail"); 5 | private final int code; 6 | private final String message; 7 | 8 | ResponseEnum(int code, String message) { 9 | this.code = code; 10 | this.message = message; 11 | } 12 | 13 | public int code() { 14 | return code; 15 | } 16 | 17 | public String message() { 18 | return message; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/java/cn/bitoffer/lottery/mapper/CouponMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.lottery.mapper; 2 | 3 | import cn.bitoffer.lottery.model.BlackUser; 4 | import cn.bitoffer.lottery.model.Coupon; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import java.util.ArrayList; 9 | 10 | @Mapper 11 | public interface CouponMapper { 12 | ArrayList getAll(); 13 | 14 | ArrayList getCouponListByPrizeID(@Param("prizeID") Long prizeID); 15 | 16 | int save(@Param("coupon") Coupon coupon); 17 | 18 | void updateByCode(@Param("code") String code); 19 | 20 | Coupon getGetNextUsefulCoupon(@Param("prizeID") Long prize,@Param("couponID") Long couponID); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/java/cn/bitoffer/seckill/common/ErrorCode.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.seckill.common; 2 | 3 | /** 4 | * 自定义错误码 5 | */ 6 | public enum ErrorCode { 7 | 8 | SUCCESS(0, "ok"), 9 | PARAMS_ERROR(40000, "请求参数错误"), 10 | SYSTEM_ERROR(50000, "系统内部异常"), 11 | ; 12 | 13 | 14 | /** 15 | * 状态码 16 | */ 17 | private final int code; 18 | 19 | /** 20 | * 信息 21 | */ 22 | private final String message; 23 | 24 | ErrorCode(int code, String message) { 25 | this.code = code; 26 | this.message = message; 27 | } 28 | 29 | public int getCode() { 30 | return code; 31 | } 32 | 33 | public String getMessage() { 34 | return message; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /bitstorm-svr-demo/src/main/java/cn/bitoffer/improve/exception/ErrorCode.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve.exception; 2 | 3 | /** 4 | * 自定义错误码 5 | */ 6 | public enum ErrorCode { 7 | 8 | SUCCESS(0, "ok"), 9 | PARAMS_ERROR(40000, "请求参数错误"), 10 | SYSTEM_ERROR(50000, "系统内部异常"), 11 | ; 12 | 13 | 14 | /** 15 | * 状态码 16 | */ 17 | private final int code; 18 | 19 | /** 20 | * 信息 21 | */ 22 | private final String message; 23 | 24 | ErrorCode(int code, String message) { 25 | this.code = code; 26 | this.message = message; 27 | } 28 | 29 | public int getCode() { 30 | return code; 31 | } 32 | 33 | public String getMessage() { 34 | return message; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /bitstorm-svr-improve/src/main/java/cn/bitoffer/improve/exception/ErrorCode.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve.exception; 2 | 3 | /** 4 | * 自定义错误码 5 | */ 6 | public enum ErrorCode { 7 | 8 | SUCCESS(0, "ok"), 9 | PARAMS_ERROR(40000, "请求参数错误"), 10 | SYSTEM_ERROR(50000, "系统内部异常"), 11 | ; 12 | 13 | 14 | /** 15 | * 状态码 16 | */ 17 | private final int code; 18 | 19 | /** 20 | * 信息 21 | */ 22 | private final String message; 23 | 24 | ErrorCode(int code, String message) { 25 | this.code = code; 26 | this.message = message; 27 | } 28 | 29 | public int getCode() { 30 | return code; 31 | } 32 | 33 | public String getMessage() { 34 | return message; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /bitstorm-svr-shorturlx/src/main/java/cn/bitoffer/shorturlx/common/ErrorCode.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.shorturlx.common; 2 | 3 | /** 4 | * 自定义错误码 5 | */ 6 | public enum ErrorCode { 7 | 8 | SUCCESS(0, "ok"), 9 | PARAMS_ERROR(40000, "请求参数错误"), 10 | SYSTEM_ERROR(50000, "系统内部异常"), 11 | ; 12 | 13 | 14 | /** 15 | * 状态码 16 | */ 17 | private final int code; 18 | 19 | /** 20 | * 信息 21 | */ 22 | private final String message; 23 | 24 | ErrorCode(int code, String message) { 25 | this.code = code; 26 | this.message = message; 27 | } 28 | 29 | public int getCode() { 30 | return code; 31 | } 32 | 33 | public String getMessage() { 34 | return message; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/java/cn/bitoffer/lottery/model/CheckResult.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.lottery.model; 2 | 3 | public class CheckResult { 4 | BlackUser blackUser; 5 | BlackIp blackIp; 6 | boolean ok; 7 | 8 | public BlackUser getBlackUser() { 9 | return blackUser; 10 | } 11 | 12 | public void setBlackUser(BlackUser blackUser) { 13 | this.blackUser = blackUser; 14 | } 15 | 16 | public BlackIp getBlackIp() { 17 | return blackIp; 18 | } 19 | 20 | public void setBlackIp(BlackIp blackIp) { 21 | this.blackIp = blackIp; 22 | } 23 | 24 | public boolean isOk() { 25 | return ok; 26 | } 27 | 28 | public void setOk(boolean ok) { 29 | this.ok = ok; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/common/ErrorCode.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.common; 2 | 3 | /** 4 | * 自定义错误码 5 | */ 6 | public enum ErrorCode { 7 | 8 | SUCCESS(0, "ok"), 9 | PARAMS_ERROR(40000, "请求参数错误"), 10 | SYSTEM_ERROR(50000, "系统内部异常"), 11 | ; 12 | 13 | 14 | /** 15 | * 状态码 16 | */ 17 | private final int code; 18 | 19 | /** 20 | * 信息 21 | */ 22 | private final String message; 23 | 24 | ErrorCode(int code, String message) { 25 | this.code = code; 26 | this.message = message; 27 | } 28 | 29 | public int getCode() { 30 | return code; 31 | } 32 | 33 | public String getMessage() { 34 | return message; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/java/cn/bitoffer/lottery/config/TaskConfig.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.lottery.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.scheduling.TaskScheduler; 6 | import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; 7 | 8 | @Configuration 9 | public class TaskConfig { 10 | @Bean 11 | public TaskScheduler taskScheduler() { 12 | ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler(); 13 | threadPoolTaskScheduler.setPoolSize(5); 14 | threadPoolTaskScheduler.setThreadNamePrefix("ThreadPoolTaskScheduler"); 15 | return threadPoolTaskScheduler; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/java/cn/bitoffer/lottery/utils/UtilTools.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.lottery.utils; 2 | 3 | import java.util.Random; 4 | 5 | public class UtilTools { 6 | public static int getRandom(int maxValue) { 7 | Random random = new Random(); 8 | //设置随机数种子 9 | random.setSeed(System.currentTimeMillis()); 10 | return random.nextInt(maxValue); 11 | } 12 | 13 | public static long ipToLong(String ipAddress) { 14 | String[] ipAddressParts = ipAddress.split("\\."); 15 | long result = 0; 16 | for (int i = 0; i < ipAddressParts.length; i++) { 17 | int part = Integer.parseInt(ipAddressParts[i]); 18 | result += part * Math.pow(256, 3 - i); 19 | } 20 | return result; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /bitstorm-svr-auth/src/main/java/cn/bitoffer/auth/model/UserCredential.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.auth.model; 2 | 3 | public class UserCredential { 4 | private String username; 5 | private String password; 6 | 7 | private String userId; 8 | 9 | public String getUsername() { 10 | return username; 11 | } 12 | 13 | public void setUsername(String username) { 14 | this.username = username; 15 | } 16 | 17 | public String getPassword() { 18 | return password; 19 | } 20 | 21 | public void setPassword(String password) { 22 | this.password = password; 23 | } 24 | 25 | public String getUserId() { 26 | return userId; 27 | } 28 | 29 | public void setUserId(String userId) { 30 | this.userId = userId; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /bitstorm-svr-xtimer/src/main/java/cn/bitoffer/xtimer/exception/ErrorCode.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.xtimer.exception; 2 | 3 | /** 4 | * 自定义错误码 5 | */ 6 | public enum ErrorCode { 7 | 8 | SUCCESS(0, "ok"), 9 | UNKNOWN_ERROR(90001, "未知异常"), 10 | SYSTEM_ERROR(90002, "系统内部异常"), 11 | PARAMS_ERROR(90003, "请求参数错误"), 12 | 13 | ; 14 | 15 | 16 | /** 17 | * 状态码 18 | */ 19 | private final int code; 20 | 21 | /** 22 | * 信息 23 | */ 24 | private final String message; 25 | 26 | ErrorCode(int code, String message) { 27 | this.code = code; 28 | this.message = message; 29 | } 30 | 31 | public int getCode() { 32 | return code; 33 | } 34 | 35 | public String getMessage() { 36 | return message; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /bitstorm-svr-improve/src/main/java/cn/bitoffer/improve/model/Task.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve.model; 2 | 3 | 4 | import cn.bitoffer.common.model.BaseModel; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * Example 数据库模型 10 | * 11 | **/ 12 | public class Task extends BaseModel implements Serializable { 13 | /** 14 | * Id 15 | */ 16 | private Long ID; 17 | 18 | private String taskID; 19 | 20 | public String getTaskID() { 21 | return taskID; 22 | } 23 | 24 | public void setTaskId(String taskID) { 25 | this.taskID = taskID; 26 | } 27 | 28 | @Override 29 | public String toString() { 30 | return "Task{" + 31 | "ID=" + ID + 32 | ", taskID='" + taskID + '\'' + 33 | '}'; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/resources/scripts/lottery.lua: -------------------------------------------------------------------------------- 1 | -- local counter = 1 2 | -- local threads = {} 3 | -- -- 设置thread 4 | -- function setup(thread) 5 | -- thread:set("id",counter) 6 | -- thread:set("num",(counter-1)*100000000) -- num在后续的操作中可以直接使用,因为已经设置了 7 | -- table.insert(threads,thread) 8 | -- counter = counter + 1 9 | -- end 10 | 11 | 12 | function request() 13 | -- num = num + 1 14 | local body1='{"user_id": ' 15 | local body2=', "user_name": "zhangsan", "ip":"192.168.9.9"}' 16 | local user_id=tostring(math.random(1000000)) 17 | local req_body=body1..user_id..body2 18 | wrk.body = req_body 19 | wrk.headers["Content-Type"] = "application/json" 20 | wrk.method = "POST" 21 | return wrk.format('POST', nil, headers, body) 22 | end -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/WorkerApplication.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker; 2 | 3 | import com.zdf.worker.boot.AppLaunch; 4 | import com.zdf.worker.boot.Launch; 5 | import com.zdf.worker.task.Lark; 6 | import org.springframework.boot.CommandLineRunner; 7 | import org.springframework.boot.SpringApplication; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | 10 | @SpringBootApplication 11 | public class WorkerApplication implements CommandLineRunner { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(WorkerApplication.class, args); 15 | } 16 | 17 | @Override 18 | public void run(String... args) throws Exception { 19 | Launch l = new AppLaunch(); 20 | // 启动worker 21 | l.start(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/java/cn/bitoffer/lottery/mapper/BlackIpMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.lottery.mapper; 2 | import cn.bitoffer.lottery.model.BlackIp; 3 | import org.apache.ibatis.annotations.Mapper; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | import java.util.Date; 7 | 8 | @Mapper 9 | public interface BlackIpMapper { 10 | /** 11 | * 保存BlackIp 12 | * 13 | * @param blackIp 14 | */ 15 | void save(@Param("blackIp") BlackIp blackIp); 16 | 17 | /** 18 | 通过ip获取ip黑名单信息 19 | @param ip 20 | **/ 21 | BlackIp getByIP(@Param("ip") String ip); 22 | 23 | 24 | /** 25 | * BlackIp 26 | * 27 | * @param ip 28 | * @param blackTime 29 | */ 30 | void updateBlackTimeByIP(@Param("ip") String ip, @Param("blackTime") Date blackTime); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/constant/TaskUrl.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.constant; 2 | 3 | /** 4 | * 请求URL常量 5 | */ 6 | public class TaskUrl { 7 | public final static String IPORT = "http://localhost:8081"; 8 | public final static String CREATE_TASK = "/task/create_task"; 9 | public final static String SET_TASK = "/task/set_task"; 10 | public final static String GET_TASK = "/task/get_task"; 11 | public final static String GET_TASK_LIST = "/task/task_list"; 12 | public final static String HOLD_TASK = "/task/hold_task"; 13 | public final static String GET_CFG_LIST = "/task_schedule_cfg/list"; 14 | public final static String GET_USER_TASK_LIST = "/task/user_task_list"; 15 | public final static String CREATE_TASK_CFG = "/task_schedule_cfg/task_configuration"; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /bitstorm-svr-demo/src/main/java/cn/bitoffer/improve/exception/BusinessException.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve.exception; 2 | 3 | /** 4 | * 自定义异常类 5 | * 6 | */ 7 | public class BusinessException extends RuntimeException { 8 | 9 | /** 10 | * 错误码 11 | */ 12 | private final int code; 13 | 14 | public BusinessException(int code, String message) { 15 | super(message); 16 | this.code = code; 17 | } 18 | 19 | public BusinessException(ErrorCode errorCode) { 20 | super(errorCode.getMessage()); 21 | this.code = errorCode.getCode(); 22 | } 23 | 24 | public BusinessException(ErrorCode errorCode, String message) { 25 | super(message); 26 | this.code = errorCode.getCode(); 27 | } 28 | 29 | public int getCode() { 30 | return code; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /bitstorm-svr-improve/src/main/java/cn/bitoffer/improve/exception/BusinessException.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve.exception; 2 | 3 | /** 4 | * 自定义异常类 5 | * 6 | */ 7 | public class BusinessException extends RuntimeException { 8 | 9 | /** 10 | * 错误码 11 | */ 12 | private final int code; 13 | 14 | public BusinessException(int code, String message) { 15 | super(message); 16 | this.code = code; 17 | } 18 | 19 | public BusinessException(ErrorCode errorCode) { 20 | super(errorCode.getMessage()); 21 | this.code = errorCode.getCode(); 22 | } 23 | 24 | public BusinessException(ErrorCode errorCode, String message) { 25 | super(message); 26 | this.code = errorCode.getCode(); 27 | } 28 | 29 | public int getCode() { 30 | return code; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /bitstorm-svr-xtimer/src/main/java/cn/bitoffer/xtimer/exception/BusinessException.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.xtimer.exception; 2 | 3 | /** 4 | * 自定义异常类 5 | * 6 | */ 7 | public class BusinessException extends RuntimeException { 8 | 9 | /** 10 | * 错误码 11 | */ 12 | private final int code; 13 | 14 | public BusinessException(int code, String message) { 15 | super(message); 16 | this.code = code; 17 | } 18 | 19 | public BusinessException(ErrorCode errorCode) { 20 | super(errorCode.getMessage()); 21 | this.code = errorCode.getCode(); 22 | } 23 | 24 | public BusinessException(ErrorCode errorCode, String message) { 25 | super(message); 26 | this.code = errorCode.getCode(); 27 | } 28 | 29 | public int getCode() { 30 | return code; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /bitstorm-svr-api/src/main/java/cn/bitoffer/api/feign/LotteryClient.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.api.feign; 2 | 3 | import cn.bitoffer.api.dto.xtimer.LotteryParam; 4 | import cn.bitoffer.api.dto.xtimer.TimerDTO; 5 | import org.springframework.cloud.openfeign.FeignClient; 6 | import org.springframework.web.bind.annotation.PostMapping; 7 | import org.springframework.web.bind.annotation.RequestBody; 8 | 9 | @FeignClient("bitstorm-svr-lottery") 10 | public interface LotteryClient 11 | { 12 | @PostMapping(value = "/v1/get_lucky") 13 | public Long lotteryV1(@RequestBody LotteryParam lotteryParam); 14 | 15 | @PostMapping(value = "/v2/get_lucky") 16 | public Long lotteryV2(@RequestBody LotteryParam lotteryParam); 17 | 18 | @PostMapping(value = "/v3/get_lucky") 19 | public Long lotteryV3(@RequestBody LotteryParam lotteryParam); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/java/cn/bitoffer/lottery/mapper/BlackUserMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.lottery.mapper; 2 | 3 | import cn.bitoffer.lottery.model.BlackUser; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.Date; 8 | 9 | @Mapper 10 | public interface BlackUserMapper { 11 | /** 12 | * 保存BlackUser 13 | * 14 | * @param blackUser 15 | */ 16 | void save(@Param("blackUser") BlackUser blackUser); 17 | 18 | /** 19 | 通过ip获取user_id黑名单信息 20 | @param uid 21 | **/ 22 | BlackUser getByUserId(@Param("uid") Long uid); 23 | 24 | /** 25 | * BlackUser 26 | * 27 | * @param uid 28 | * @param blackTime 29 | */ 30 | void updateBlackTimeByUserId(@Param("uid") Long uid,@Param("userId") Date blackTime); 31 | } 32 | -------------------------------------------------------------------------------- /bitstorm-svr-improve/wrkbench/create_task.lua: -------------------------------------------------------------------------------- 1 | math.randomseed(os.time()) 2 | 3 | function getRandom(n) 4 | local t = { 5 | "0","1","2","3","4","5","6","7","8","9", 6 | "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z", 7 | "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z", 8 | } 9 | local s = "" 10 | for i =1, n do 11 | s = s .. t[math.random(#t)] 12 | end; 13 | return s 14 | end; 15 | 16 | wrk.method = "POST" 17 | wrk.body = "{}" 18 | wrk.headers["Content-Type"] = "application/json" 19 | 20 | function request() 21 | wrk.headers["Trace-ID"] = getRandom(32) 22 | wrk.headers["User-ID"] = math.random(1000000) 23 | return wrk.format('POST', nil, headers, body) 24 | end 25 | 26 | -------------------------------------------------------------------------------- /bitstorm-svr-improve/wrkbench/incr_count.lua: -------------------------------------------------------------------------------- 1 | math.randomseed(os.time()) 2 | 3 | function getRandom(n) 4 | local t = { 5 | "0","1","2","3","4","5","6","7","8","9", 6 | "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z", 7 | "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z", 8 | } 9 | local s = "" 10 | for i =1, n do 11 | s = s .. t[math.random(#t)] 12 | end; 13 | return s 14 | end; 15 | 16 | wrk.method = "POST" 17 | wrk.body = "{\"num\":1}" 18 | wrk.headers["Content-Type"] = "application/json" 19 | 20 | function request() 21 | wrk.headers["Trace-ID"] = getRandom(32) 22 | wrk.headers["User-ID"] = math.random(1000000) 23 | return wrk.format('POST', nil, headers, body) 24 | end 25 | 26 | -------------------------------------------------------------------------------- /bitstorm-svr-auth/src/main/java/cn/bitoffer/auth/service/AuthService.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.auth.service; 2 | 3 | import cn.bitoffer.auth.model.UserCredential; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.security.crypto.password.PasswordEncoder; 6 | import org.springframework.stereotype.Service; 7 | 8 | @Service 9 | public class AuthService { 10 | 11 | @Autowired 12 | private PasswordEncoder passwordEncoder; 13 | public UserCredential findUserByUsername(String username){ 14 | // 这里模拟一个测试的,用户账号信息 15 | UserCredential userCredential = new UserCredential(); 16 | userCredential.setUsername(username); 17 | userCredential.setPassword(passwordEncoder.encode("123456")); 18 | userCredential.setUserId("2023001"); 19 | 20 | return userCredential; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /bitstorm-svr-improve/src/main/java/cn/bitoffer/improve/model/Count.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve.model; 2 | 3 | 4 | import cn.bitoffer.common.model.BaseModel; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * Example 数据库模型 10 | * 11 | **/ 12 | public class Count extends BaseModel implements Serializable { 13 | /** 14 | * Id 15 | */ 16 | private Long ID; 17 | 18 | private Integer count; 19 | 20 | public Integer getCount() { 21 | return count; 22 | } 23 | 24 | public void setCount(Integer count) { 25 | this.count = count; 26 | } 27 | 28 | @Override 29 | public String toString() { 30 | return "Count{" + 31 | "count=" + count + 32 | ", createTime=" + createTime + 33 | ", modifyTime=" + modifyTime + 34 | '}'; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /bitstorm-svr-improve/wrkbench/incr_count_async.lua: -------------------------------------------------------------------------------- 1 | math.randomseed(os.time()) 2 | 3 | function getRandom(n) 4 | local t = { 5 | "0","1","2","3","4","5","6","7","8","9", 6 | "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z", 7 | "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z", 8 | } 9 | local s = "" 10 | for i =1, n do 11 | s = s .. t[math.random(#t)] 12 | end; 13 | return s 14 | end; 15 | 16 | wrk.method = "POST" 17 | wrk.body = "{\"num\":1}" 18 | wrk.headers["Content-Type"] = "application/json" 19 | 20 | function request() 21 | wrk.headers["Trace-ID"] = getRandom(32) 22 | wrk.headers["User-ID"] = math.random(1000000) 23 | return wrk.format('POST', nil, headers, body) 24 | end 25 | 26 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/core/ObserverFunction.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.core; 2 | 3 | import com.zdf.worker.data.AsyncTaskBase; 4 | import com.zdf.worker.data.AsyncTaskReturn; 5 | import com.zdf.worker.data.AsyncTaskSetStage; 6 | import com.zdf.worker.data.ScheduleConfig; 7 | 8 | import java.util.List; 9 | 10 | public interface ObserverFunction { 11 | void onBoot(); 12 | void onObtain(List taskList, List asyncTaskBaseList); 13 | void onExecute(AsyncTaskBase asyncTaskReturn); 14 | void onFinish(AsyncTaskBase asyncTaskReturn, AsyncTaskSetStage asyncTaskSetStage, Class aClass); 15 | void onStop(AsyncTaskBase asyncTaskReturn); 16 | void onError(AsyncTaskBase asyncTaskReturn, ScheduleConfig scheduleConfig, List asyncTaskBaseList, Class aClass, Exception e); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /bitstorm-svr-common/src/main/java/cn/bitoffer/common/model/BaseModel.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.common.model; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | 6 | public class BaseModel implements Serializable { 7 | 8 | /** 9 | * 创建时间 10 | */ 11 | protected Date createTime; 12 | 13 | /** 14 | * 更新时间 15 | */ 16 | protected Date modifyTime; 17 | 18 | public Date getCreateTime() { 19 | return createTime; 20 | } 21 | 22 | public void setCreateTime(Date createTime) { 23 | this.createTime = createTime; 24 | } 25 | 26 | public Date getModifyTime() { 27 | return modifyTime; 28 | } 29 | 30 | public void setModifyTime(Date modifyTime) { 31 | this.modifyTime = modifyTime; 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return "BaseModel{" + "createTime=" + createTime + ", updateTime=" + modifyTime + '}'; 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /bitstorm-svr-improve/src/main/java/cn/bitoffer/improve/schedued/ScheduledTask.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve.schedued; 2 | 3 | import cn.bitoffer.improve.mapper.CountMapper; 4 | import cn.bitoffer.improve.service.CountService; 5 | import cn.bitoffer.improve.service.impl.CountServiceImpl; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.scheduling.annotation.Scheduled; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.time.LocalDateTime; 11 | 12 | /** 13 | * 定时任务模版 14 | * 15 | **/ 16 | @Component 17 | public class ScheduledTask { 18 | @Autowired 19 | private CountService service; 20 | @Scheduled(fixedRate = 3000) 21 | public void scheduledTask() { 22 | service.incrMemCountAndReset(); 23 | //System.out.println("任务执行时间 isis:" + LocalDateTime.now()); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/java/cn/bitoffer/seckill/common/BaseModel.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.seckill.common; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | 6 | public class BaseModel implements Serializable { 7 | /** 8 | * 创建时间 9 | */ 10 | protected Date createTime; 11 | 12 | /** 13 | * 更新时间 14 | */ 15 | protected Date modifyTime; 16 | 17 | public Date getCreateTime() { 18 | return createTime; 19 | } 20 | 21 | public void setCreateTime(Date createTime) { 22 | this.createTime = createTime; 23 | } 24 | 25 | public Date getModifyTime() { 26 | return modifyTime; 27 | } 28 | 29 | public void setModifyTime(Date updateTime) { 30 | this.modifyTime = updateTime; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return "BaseModel{" + "createTime=" + createTime + ", updateTime=" + modifyTime + '}'; 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /bitstorm-svr-seckill/wrkbench/sec_kill_v1.lua: -------------------------------------------------------------------------------- 1 | math.randomseed(os.time()) 2 | 3 | function getRandom(n) 4 | local t = { 5 | "0","1","2","3","4","5","6","7","8","9", 6 | "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z", 7 | "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z", 8 | } 9 | local s = "" 10 | for i =1, n do 11 | s = s .. t[math.random(#t)] 12 | end; 13 | return s 14 | end; 15 | 16 | wrk.method = "POST" 17 | wrk.body = "{\"goodsNum\":\"abc123\", \"num\":1}" 18 | wrk.headers["Content-Type"] = "application/json" 19 | 20 | function request() 21 | wrk.headers["Trace-ID"] = getRandom(32) 22 | wrk.headers["User-ID"] = math.random(1000000) 23 | return wrk.format('POST', nil, headers, body) 24 | end 25 | 26 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/wrkbench/sec_kill_v2.lua: -------------------------------------------------------------------------------- 1 | math.randomseed(os.time()) 2 | 3 | function getRandom(n) 4 | local t = { 5 | "0","1","2","3","4","5","6","7","8","9", 6 | "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z", 7 | "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z", 8 | } 9 | local s = "" 10 | for i =1, n do 11 | s = s .. t[math.random(#t)] 12 | end; 13 | return s 14 | end; 15 | 16 | wrk.method = "POST" 17 | wrk.body = "{\"goodsNum\":\"abc123\", \"num\":1}" 18 | wrk.headers["Content-Type"] = "application/json" 19 | 20 | function request() 21 | wrk.headers["Trace-ID"] = getRandom(32) 22 | wrk.headers["User-ID"] = math.random(1000000) 23 | return wrk.format('POST', nil, headers, body) 24 | end 25 | 26 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/wrkbench/sec_kill_v3.lua: -------------------------------------------------------------------------------- 1 | math.randomseed(os.time()) 2 | 3 | function getRandom(n) 4 | local t = { 5 | "0","1","2","3","4","5","6","7","8","9", 6 | "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z", 7 | "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z", 8 | } 9 | local s = "" 10 | for i =1, n do 11 | s = s .. t[math.random(#t)] 12 | end; 13 | return s 14 | end; 15 | 16 | wrk.method = "POST" 17 | wrk.body = "{\"goodsNum\":\"abc123\", \"num\":1}" 18 | wrk.headers["Content-Type"] = "application/json" 19 | 20 | function request() 21 | wrk.headers["Trace-ID"] = getRandom(32) 22 | wrk.headers["User-ID"] = math.random(1000000) 23 | return wrk.format('POST', nil, headers, body) 24 | end 25 | 26 | -------------------------------------------------------------------------------- /bitstorm-svr-shorturlx/src/main/java/cn/bitoffer/shorturlx/common/BaseModel.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.shorturlx.common; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | 6 | public class BaseModel implements Serializable { 7 | 8 | /** 9 | * 创建时间 10 | */ 11 | protected Date createTime; 12 | 13 | /** 14 | * 更新时间 15 | */ 16 | protected Date updateTime; 17 | 18 | public Date getCreateTime() { 19 | return createTime; 20 | } 21 | 22 | public void setCreateTime(Date createTime) { 23 | this.createTime = createTime; 24 | } 25 | 26 | public Date getUpdateTime() { 27 | return updateTime; 28 | } 29 | 30 | public void setUpdateTime(Date updateTime) { 31 | this.updateTime = updateTime; 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return "BaseModel{" + "createTime=" + createTime + ", updateTime=" + updateTime + '}'; 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/common/BaseModel.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.common; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | 6 | public class BaseModel implements Serializable { 7 | 8 | /** 9 | * 创建时间 10 | */ 11 | protected Date createTime; 12 | 13 | /** 14 | * 更新时间 15 | */ 16 | protected Date updateTime; 17 | 18 | public Date getCreateTime() { 19 | return createTime; 20 | } 21 | 22 | public void setCreateTime(Date createTime) { 23 | this.createTime = createTime; 24 | } 25 | 26 | public Date getUpdateTime() { 27 | return updateTime; 28 | } 29 | 30 | public void setUpdateTime(Date updateTime) { 31 | this.updateTime = updateTime; 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return "BaseModel{" + "createTime=" + createTime + ", updateTime=" + updateTime + '}'; 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /bitstorm-svr-improve/src/main/java/cn/bitoffer/improve/service/impl/TaskServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve.service.impl; 2 | 3 | import cn.bitoffer.common.redis.RedisBase; 4 | import cn.bitoffer.improve.mapper.TaskMapper; 5 | import cn.bitoffer.improve.model.Task; 6 | import cn.bitoffer.improve.service.TaskService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | 10 | import java.util.concurrent.locks.Lock; 11 | import java.util.concurrent.locks.ReentrantLock; 12 | 13 | @Service 14 | public class TaskServiceImpl implements TaskService { 15 | public static Integer tmpTask = 0; 16 | public static final Lock lock = new ReentrantLock(); 17 | 18 | @Autowired 19 | private TaskMapper taskMapper; 20 | 21 | @Override 22 | public void save(Task task) { 23 | taskMapper.save(task); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/java/cn/bitoffer/seckill/exception/BusinessException.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.seckill.exception; 2 | 3 | import cn.bitoffer.seckill.common.ErrorCode; 4 | 5 | /** 6 | * 自定义异常类 7 | * 8 | */ 9 | public class BusinessException extends RuntimeException { 10 | 11 | /** 12 | * 错误码 13 | */ 14 | private final int code; 15 | 16 | public BusinessException(int code, String message) { 17 | super(message); 18 | this.code = code; 19 | } 20 | 21 | public BusinessException(ErrorCode errorCode) { 22 | super(errorCode.getMessage()); 23 | this.code = errorCode.getCode(); 24 | } 25 | 26 | public BusinessException(ErrorCode errorCode, String message) { 27 | super(message); 28 | this.code = errorCode.getCode(); 29 | } 30 | 31 | public int getCode() { 32 | return code; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/lock/LockParam.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.lock; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class LockParam { 7 | private static Long HOLD_LOCK_TIME = 5L; 8 | private static Long TRY_LOCK_TIME = 10L; 9 | 10 | private String lockKey; 11 | private String lockValue; 12 | private Long holdLockTime; 13 | // 最大尝试时间,防止无限期抢锁 14 | private Long tryLockTime; 15 | 16 | 17 | public LockParam(String lockKey) { 18 | this(lockKey, 5 * 1000L, 5L); 19 | } 20 | 21 | public LockParam(String lockKey, Long tryLockTime) { 22 | this(lockKey, tryLockTime, 3000L); 23 | } 24 | 25 | public LockParam(String lockKey, Long tryLockTime, Long holdLockTime) { 26 | this.lockKey = lockKey; 27 | this.tryLockTime = tryLockTime; 28 | this.holdLockTime = holdLockTime; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /bitstorm-svr-shorturlx/src/main/java/cn/bitoffer/shorturlx/exception/BusinessException.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.shorturlx.exception; 2 | 3 | import cn.bitoffer.shorturlx.common.ErrorCode; 4 | 5 | /** 6 | * 自定义异常类 7 | * 8 | */ 9 | public class BusinessException extends RuntimeException { 10 | 11 | /** 12 | * 错误码 13 | */ 14 | private final int code; 15 | 16 | public BusinessException(int code, String message) { 17 | super(message); 18 | this.code = code; 19 | } 20 | 21 | public BusinessException(ErrorCode errorCode) { 22 | super(errorCode.getMessage()); 23 | this.code = errorCode.getCode(); 24 | } 25 | 26 | public BusinessException(ErrorCode errorCode, String message) { 27 | super(message); 28 | this.code = errorCode.getCode(); 29 | } 30 | 31 | public int getCode() { 32 | return code; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/java/cn/bitoffer/lottery/model/LotteryResult.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.lottery.model; 2 | 3 | import cn.bitoffer.lottery.common.ErrorCode; 4 | 5 | public class LotteryResult { 6 | private ErrorCode errcode; 7 | private Long userId; 8 | LotteryPrizeInfo lotteryPrize; 9 | 10 | public ErrorCode getErrcode() { 11 | return errcode; 12 | } 13 | 14 | public void setErrcode(ErrorCode errcode) { 15 | this.errcode = errcode; 16 | } 17 | 18 | public LotteryPrizeInfo getLotteryPrize() { 19 | return lotteryPrize; 20 | } 21 | 22 | public Long getUserId() { 23 | return userId; 24 | } 25 | 26 | public void setUserId(Long userId) { 27 | this.userId = userId; 28 | } 29 | 30 | public void setLotteryPrize(LotteryPrizeInfo lotteryPrize) { 31 | this.lotteryPrize = lotteryPrize; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/exception/BusinessException.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.exception; 2 | 3 | import cn.bitoffer.asyncflow.common.ErrorCode; 4 | 5 | /** 6 | * 自定义异常类 7 | * 8 | */ 9 | public class BusinessException extends RuntimeException { 10 | 11 | /** 12 | * 错误码 13 | */ 14 | private final int code; 15 | 16 | public BusinessException(int code, String message) { 17 | super(message); 18 | this.code = code; 19 | } 20 | 21 | public BusinessException(ErrorCode errorCode) { 22 | super(errorCode.getMessage()); 23 | this.code = errorCode.getCode(); 24 | } 25 | 26 | public BusinessException(ErrorCode errorCode, String message) { 27 | super(message); 28 | this.code = errorCode.getCode(); 29 | } 30 | 31 | public int getCode() { 32 | return code; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/Client/TaskFlower.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.Client; 2 | 3 | import com.zdf.worker.data.AsyncTaskRequest; 4 | import com.zdf.worker.data.AsyncTaskReturn; 5 | import com.zdf.worker.data.AsyncTaskSetRequest; 6 | import com.zdf.worker.data.ScheduleConfig; 7 | import com.zdf.worker.enums.TaskStatus; 8 | 9 | import java.util.List; 10 | 11 | public interface TaskFlower { 12 | public String createTask(AsyncTaskRequest asyncTaskRequest); 13 | public void setTask(AsyncTaskSetRequest asyncTaskSetRequest); 14 | public AsyncTaskReturn getTask(String taskId); 15 | public List getTaskList(Class clazz, int status, int limit); 16 | public List getTaskTypeCfgList(); 17 | public List getUserTaskList(List taskStatuses); 18 | public void createTaskCFG(ScheduleConfig scheduleConfig); 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 6099 3 | spring: 4 | application: 5 | name: @artifactId@ 6 | cloud: 7 | nacos: 8 | discovery: 9 | server-addr: 192.168.5.53 10 | username: nacos 11 | password: nacos 12 | 13 | datasource: 14 | driver-class-name: com.mysql.cj.jdbc.Driver 15 | url: jdbc:mysql://192.168.5.51:3306/asyncflow?serverTimezone=GMT%2B8&characterEncoding=utf8&useSSL=false 16 | username: root 17 | password: 123456 18 | redis: 19 | host: 192.168.5.52 20 | port: 6379 21 | password: 123456 22 | database: 6 23 | jedis: 24 | pool: 25 | max-active: 8 #最大连接数 26 | 27 | 28 | mybatis: 29 | mapper-locations: classpath:mapper/*.xml 30 | #开启驼峰命名 31 | configuration: 32 | map-underscore-to-camel-case: false 33 | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /bitstorm-svr-improve/src/main/resources/mapper/TaskMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | `id`, 14 | `task_id`, 15 | `create_time`, 16 | `modify_time` 17 | 18 | 19 | 20 | insert into t_task_test(`task_id`) 21 | values (#{task.taskID}); 22 | 23 | -------------------------------------------------------------------------------- /bitstorm-svr-api/src/main/java/cn/bitoffer/api/feign/XTimerClient.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.api.feign; 2 | 3 | 4 | import cn.bitoffer.api.dto.xtimer.TimerDTO; 5 | import cn.bitoffer.api.feign.interceptor.ContextFeignInterceptor; 6 | import org.springframework.cloud.openfeign.FeignClient; 7 | import org.springframework.util.MultiValueMap; 8 | import org.springframework.web.bind.annotation.*; 9 | 10 | @FeignClient(value = "bitstorm-svr-xtimer",configuration = ContextFeignInterceptor.class) 11 | public interface XTimerClient { 12 | 13 | @PostMapping(value = "/createTimer") 14 | public Long createTimer(@RequestBody TimerDTO timerDTO); 15 | 16 | @GetMapping(value = "/enableTimer") 17 | public void enableTimer(@RequestParam(value = "app") String app, 18 | @RequestParam(value = "timerId") Long timerId, 19 | @RequestHeader MultiValueMap headers); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /bitstorm-svr-improve/src/main/java/cn/bitoffer/improve/mapper/CountMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve.mapper; 2 | 3 | 4 | import cn.bitoffer.improve.model.Count; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | @Mapper 12 | public interface CountMapper { 13 | 14 | /** 15 | * 保存Count 16 | * 17 | * @param count 18 | */ 19 | void save(@Param("count") Count count); 20 | 21 | /** 22 | * 更新Count 23 | * 24 | * @param count 25 | */ 26 | void update(@Param("count") Count count); 27 | 28 | /** 29 | * 根据CountId查询Count 30 | * 31 | * @return Count 32 | */ 33 | Count getCount(); 34 | 35 | /** 36 | * 增加Count计数 37 | * 38 | * @param num 39 | * @return Count 40 | */ 41 | Integer incrCount(@Param("num") Integer num); 42 | } -------------------------------------------------------------------------------- /bitstorm-svr-leaf/src/main/java/cn/bitoffer/leaf/segment/dao/IDAllocDao.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.leaf.segment.dao; 2 | 3 | 4 | import cn.bitoffer.leaf.segment.model.LeafAlloc; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author leaf 10 | */ 11 | public interface IDAllocDao { 12 | 13 | /** 14 | * com.mall4j.cloud.leaf.segment.dao.IDAllocMapper.getAllLeafAllocs 15 | * @return List 16 | */ 17 | List getAllLeafAllocs(); 18 | 19 | /** 20 | * updateMaxIdAndGetLeafAlloc 21 | * @param tag tag 22 | * @return LeafAlloc 23 | */ 24 | LeafAlloc updateMaxIdAndGetLeafAlloc(String tag); 25 | 26 | /** 27 | * updateMaxIdByCustomStepAndGetLeafAlloc 28 | * @param leafAlloc leafAlloc 29 | * @return LeafAlloc 30 | */ 31 | LeafAlloc updateMaxIdByCustomStepAndGetLeafAlloc(LeafAlloc leafAlloc); 32 | 33 | /** 34 | * getAllTags 35 | * @return List 36 | */ 37 | List getAllTags(); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/data/AsyncTaskSetRequest.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.data; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class AsyncTaskSetRequest { 13 | private String task_id; // NOT NULL DEFAULT '', 14 | private String task_stage; 15 | private int status; //tinyint(3) unsigned NOT NULL DEFAULT '0', 16 | private String schedule_log;// varchar(4096) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '调度信息记录', 17 | private String task_context; 18 | private long order_time; 19 | private int priority; 20 | private int crt_retry_num; //NOT NULL DEFAULT '0' COMMENT '已经重试几次了', 21 | private int max_retry_num; //NOT NULL DEFAULT '0' COMMENT '最大能重试几次', 22 | private int max_retry_interval; 23 | 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /bitstorm-svr-demo/src/main/java/cn/bitoffer/improve/exception/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve.exception; 2 | 3 | import cn.bitoffer.common.model.ResponseEntity; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.web.bind.annotation.ExceptionHandler; 6 | import org.springframework.web.bind.annotation.RestControllerAdvice; 7 | 8 | /** 9 | * 全局异常处理器 10 | * 11 | */ 12 | @RestControllerAdvice 13 | @Slf4j 14 | public class GlobalExceptionHandler { 15 | 16 | @ExceptionHandler(BusinessException.class) 17 | public ResponseEntity businessExceptionHandler(BusinessException e) { 18 | log.error("BusinessException", e); 19 | return ResponseEntity.fail(); 20 | } 21 | 22 | @ExceptionHandler(RuntimeException.class) 23 | public ResponseEntity runtimeExceptionHandler(RuntimeException e) { 24 | log.error("RuntimeException", e); 25 | return ResponseEntity.fail(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/service/AsyncflowService.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.service; 2 | 3 | import cn.bitoffer.asyncflow.dto.*; 4 | 5 | /** 6 | * @author 狂飙训练营 7 | */ 8 | public interface AsyncflowService { 9 | 10 | String createTask(CreateTaskRequest request); 11 | 12 | GetTaskListReply getTaskList(GetTaskListRequest request); 13 | 14 | GetTaskScheduleCfgListReply getTaskScheduleCfgList(GetTaskScheduleCfgListRequest request); 15 | 16 | 17 | SetTaskReply setTask(SetTaskRequest request); 18 | 19 | // /** 20 | // * 获取任务 21 | // * 22 | // * @param task_id 23 | // * @param 24 | // * @return 25 | // */ 26 | GetTaskReply getTask(GetTaskRequest request); 27 | 28 | 29 | // ReturnStatus getTaskByUserIdAndStatus(String user_id, int statusList); 30 | 31 | 32 | HoldTasksReply holdTasks(HoldTasksRequest request); 33 | } 34 | -------------------------------------------------------------------------------- /bitstorm-svr-api/src/main/java/cn/bitoffer/api/dto/xtimer/LotteryParam.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.api.dto.xtimer; 2 | 3 | public class LotteryParam { 4 | private int userId; // 用户id 5 | private String userName; // 用户名 6 | private String ip; // ip 7 | 8 | public void setUserId(int userId) { 9 | this.userId = userId; 10 | } 11 | 12 | public int getUserId() { 13 | return userId; 14 | } 15 | 16 | public void setUserName(String userName) { 17 | this.userName = userName; 18 | } 19 | 20 | public String getUserName() { 21 | return userName; 22 | } 23 | 24 | 25 | public void setIp(String ip) { 26 | this.ip = ip; 27 | } 28 | 29 | public String getIp() { 30 | return ip; 31 | } 32 | 33 | public LotteryParam(int userId, String userName, String ip) { 34 | this.userId = userId; 35 | this.userName = userName; 36 | this.ip = ip; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/model/TaskPosModel.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.model; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.time.LocalDateTime; 7 | 8 | @Data 9 | public class TaskPosModel implements Serializable { 10 | public Long id; 11 | public String taskType; 12 | public Integer scheduleBeginPos; 13 | public Integer scheduleEndPos; 14 | public LocalDateTime createTime; 15 | public LocalDateTime modifyTime; 16 | 17 | @Override 18 | public String toString() { 19 | return "TaskPosModel{" + 20 | "id=" + id + 21 | ", taskType='" + taskType + '\'' + 22 | ", scheduleBeginPos=" + scheduleBeginPos + 23 | ", scheduleEndPos=" + scheduleEndPos + 24 | ", createTime=" + createTime + 25 | ", modifyTime=" + modifyTime + 26 | '}'; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /bitstorm-svr-shorturlx/src/main/java/cn/bitoffer/shorturlx/exception/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.shorturlx.exception; 2 | 3 | import cn.bitoffer.shorturlx.common.ResponseEntity; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.web.bind.annotation.ExceptionHandler; 6 | import org.springframework.web.bind.annotation.RestControllerAdvice; 7 | 8 | /** 9 | * 全局异常处理器 10 | * 11 | */ 12 | @RestControllerAdvice 13 | @Slf4j 14 | public class GlobalExceptionHandler { 15 | 16 | @ExceptionHandler(BusinessException.class) 17 | public ResponseEntity businessExceptionHandler(BusinessException e) { 18 | log.error("BusinessException", e); 19 | return ResponseEntity.fail(); 20 | } 21 | 22 | @ExceptionHandler(RuntimeException.class) 23 | public ResponseEntity runtimeExceptionHandler(RuntimeException e) { 24 | log.error("RuntimeException", e); 25 | return ResponseEntity.fail(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /bitstorm-svr-leaf/src/main/java/cn/bitoffer/leaf/common/Result.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.leaf.common; 2 | 3 | public class Result { 4 | private long id; 5 | private Status status; 6 | 7 | public Result() { 8 | 9 | } 10 | public Result(long id, Status status) { 11 | this.id = id; 12 | this.status = status; 13 | } 14 | 15 | public long getId() { 16 | return id; 17 | } 18 | 19 | public void setId(long id) { 20 | this.id = id; 21 | } 22 | 23 | public Status getStatus() { 24 | return status; 25 | } 26 | 27 | public void setStatus(Status status) { 28 | this.status = status; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | final StringBuilder sb = new StringBuilder("Result{"); 34 | sb.append("id=").append(id); 35 | sb.append(", status=").append(status); 36 | sb.append('}'); 37 | return sb.toString(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/exception/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.exception; 2 | 3 | import cn.bitoffer.asyncflow.common.ResponseEntity; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.web.bind.annotation.ExceptionHandler; 6 | import org.springframework.web.bind.annotation.RestControllerAdvice; 7 | 8 | /** 9 | * 全局异常处理器 10 | * 11 | */ 12 | @RestControllerAdvice 13 | @Slf4j 14 | public class GlobalExceptionHandler { 15 | 16 | @ExceptionHandler(BusinessException.class) 17 | public ResponseEntity businessExceptionHandler(BusinessException e) { 18 | log.error("BusinessException", e); 19 | return ResponseEntity.fail(); 20 | } 21 | 22 | @ExceptionHandler(RuntimeException.class) 23 | public ResponseEntity runtimeExceptionHandler(RuntimeException e) { 24 | log.error("RuntimeException", e); 25 | return ResponseEntity.fail(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /bitstorm-svr-xtimer/src/main/java/cn/bitoffer/xtimer/feign/XTimerFeignController.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.xtimer.feign; 2 | 3 | import cn.bitoffer.api.dto.xtimer.TimerDTO; 4 | import cn.bitoffer.api.feign.XTimerClient; 5 | import cn.bitoffer.xtimer.service.XTimerService; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.util.MultiValueMap; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | @RestController 12 | @Slf4j 13 | public class XTimerFeignController implements XTimerClient { 14 | 15 | @Autowired 16 | XTimerService xTimerService; 17 | 18 | @Override 19 | public Long createTimer(TimerDTO timerDTO) { 20 | return xTimerService.CreateTimer(timerDTO); 21 | } 22 | 23 | @Override 24 | public void enableTimer(String app, Long timerId, MultiValueMap headers) { 25 | xTimerService.EnableTimer(app, timerId); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /bitstorm-svr-testconsumer/src/main/java/cn/bitoffer/testconsumer/controller/ConsumerController.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.testconsumer.controller; 2 | 3 | import cn.bitoffer.api.feign.DemoClient; 4 | import cn.bitoffer.common.model.ResponseEntity; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | import javax.annotation.Resource; 11 | 12 | @RestController 13 | @RequestMapping("/demo") 14 | @Slf4j 15 | public class ConsumerController { 16 | 17 | @Resource 18 | private DemoClient demoClient; 19 | 20 | @GetMapping("/example") 21 | public ResponseEntity consumer() { 22 | String resultStr = demoClient.call("testconsumer"); 23 | log.info("Result:" + resultStr); 24 | return ResponseEntity.ok( 25 | "result:"+resultStr 26 | ); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/java/cn/bitoffer/seckill/model/Quota.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.seckill.model; 2 | 3 | import cn.bitoffer.seckill.common.BaseModel; 4 | import lombok.Getter; 5 | 6 | import java.io.Serializable; 7 | 8 | public class Quota extends BaseModel implements Serializable { 9 | /** 10 | * Id 11 | */ 12 | private Long ID; 13 | 14 | 15 | 16 | private Integer num; 17 | private Long goodsID; 18 | 19 | public Integer getNum() { 20 | return num; 21 | } 22 | 23 | public void setNum(Integer num) { 24 | this.num = num; 25 | } 26 | 27 | public Long getID() { 28 | return ID; 29 | } 30 | 31 | public void setID(Long ID) { 32 | this.ID = ID; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return "Quota{" + 38 | "ID=" + ID + 39 | ", num=" + num + 40 | ", goodsID=" + goodsID + 41 | '}'; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /bitstorm-svr-improve/src/main/java/cn/bitoffer/improve/exception/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve.exception; 2 | 3 | import cn.bitoffer.common.model.ResponseEntity; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.web.bind.annotation.ExceptionHandler; 6 | import org.springframework.web.bind.annotation.RestControllerAdvice; 7 | 8 | /** 9 | * 全局异常处理器 10 | * 11 | */ 12 | @RestControllerAdvice 13 | @Slf4j 14 | public class GlobalExceptionHandler { 15 | 16 | @ExceptionHandler(BusinessException.class) 17 | public ResponseEntity businessExceptionHandler(BusinessException e) { 18 | log.error("BusinessException", e); 19 | return ResponseEntity.failBusinessException(e.getCode(),e.getMessage()); 20 | } 21 | 22 | @ExceptionHandler(RuntimeException.class) 23 | public ResponseEntity runtimeExceptionHandler(RuntimeException e) { 24 | log.error("RuntimeException", e); 25 | return ResponseEntity.fail(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/java/cn/bitoffer/seckill/exception/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.seckill.exception; 2 | 3 | import cn.bitoffer.common.model.ResponseEntity; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.web.bind.annotation.ExceptionHandler; 6 | import org.springframework.web.bind.annotation.RestControllerAdvice; 7 | 8 | /** 9 | * 全局异常处理器 10 | * 11 | */ 12 | @RestControllerAdvice 13 | @Slf4j 14 | public class GlobalExceptionHandler { 15 | 16 | @ExceptionHandler(BusinessException.class) 17 | public ResponseEntity businessExceptionHandler(BusinessException e) { 18 | log.error("BusinessException", e); 19 | return ResponseEntity.failBusinessException(e.getCode(),e.getMessage()); 20 | } 21 | 22 | @ExceptionHandler(RuntimeException.class) 23 | public ResponseEntity runtimeExceptionHandler(RuntimeException e) { 24 | //log.error("RuntimeException", e); 25 | return ResponseEntity.fail(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /bitstorm-svr-shorturlx/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 6080 3 | spring: 4 | application: 5 | name: @artifactId@ 6 | cloud: 7 | nacos: 8 | discovery: 9 | server-addr: 192.168.5.53 10 | username: nacos 11 | password: nacos 12 | 13 | datasource: 14 | driver-class-name: com.mysql.cj.jdbc.Driver 15 | url: jdbc:mysql://192.168.5.51:3306/shorturlx?serverTimezone=GMT%2B8&characterEncoding=utf8&useSSL=false 16 | username: root 17 | password: 123456 18 | redis: 19 | host: 192.168.5.52 20 | port: 6379 21 | password: 123456 22 | database: 6 23 | jedis: 24 | pool: 25 | max-active: 8 #最大连接数 26 | logging: 27 | level: 28 | root: DEBUG 29 | 30 | mybatis: 31 | mapper-locations: classpath:mapper/*.xml 32 | #开启驼峰命名 33 | configuration: 34 | map-underscore-to-camel-case: false 35 | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl 36 | 37 | 38 | app: 39 | workId: 1 40 | workerIdBits: 10 41 | -------------------------------------------------------------------------------- /bitstorm-svr-shorturlx/src/main/java/cn/bitoffer/shorturlx/model/UrlMap.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.shorturlx.model; 2 | 3 | import cn.bitoffer.shorturlx.common.BaseModel; 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | 7 | import java.io.Serializable; 8 | import java.util.Date; 9 | 10 | @EqualsAndHashCode(callSuper = true) 11 | @Data 12 | public class UrlMap extends BaseModel implements Serializable { 13 | private Long id; 14 | private String longUrl; 15 | private String shortUrl; 16 | private Date createdAt;; 17 | 18 | @Override 19 | public String toString() { 20 | return "UrlMap{" + "id='" + id + '\'' + ", longUrl='" + longUrl + '\'' + ", shortUrl='" + shortUrl + '\'' + ", createdAt=" + createdAt + '}'; 21 | } 22 | 23 | public UrlMap(String longUrl) { 24 | this.longUrl = longUrl; 25 | } 26 | 27 | public UrlMap(String longUrl, String shortUrl) { 28 | this.longUrl = longUrl; 29 | this.shortUrl = shortUrl; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /bitstorm-svr-api/src/main/java/cn/bitoffer/api/dto/xtimer/NotifyHTTPParam.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.api.dto.xtimer; 2 | 3 | import java.util.Map; 4 | 5 | public class NotifyHTTPParam { 6 | private String method; 7 | private String url; 8 | private Map header; 9 | private String body; 10 | 11 | public String getMethod() { 12 | return method; 13 | } 14 | 15 | public void setMethod(String method) { 16 | this.method = method; 17 | } 18 | 19 | public String getUrl() { 20 | return url; 21 | } 22 | 23 | public void setUrl(String url) { 24 | this.url = url; 25 | } 26 | 27 | public Map getHeader() { 28 | return header; 29 | } 30 | 31 | public void setHeader(Map header) { 32 | this.header = header; 33 | } 34 | 35 | public String getBody() { 36 | return body; 37 | } 38 | 39 | public void setBody(String body) { 40 | this.body = body; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/java/cn/bitoffer/seckill/mapper/QuotaMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.seckill.mapper; 2 | 3 | 4 | import cn.bitoffer.seckill.model.Quota; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | @Mapper 12 | public interface QuotaMapper { 13 | 14 | /** 15 | * 保存Quota 16 | * 17 | * @param quota 18 | */ 19 | void save(@Param("quota") Quota quota); 20 | 21 | /** 22 | * 更新Quota 23 | * 24 | * @param quota 25 | */ 26 | void update(@Param("quota") Quota quota); 27 | 28 | /** 29 | * 根据QuotaId查询Quota 30 | * 31 | * @param quotaId 32 | * @return Quota 33 | */ 34 | Quota getQuotaById(@Param("quotaId") Long quotaId); 35 | 36 | /** 37 | * 根据QuotaId查询Quota 38 | * 39 | * @param goodsID 40 | * @return Quota 41 | */ 42 | Quota getGoodsQuota( @Param("goodsID") Long goodsID); 43 | } 44 | -------------------------------------------------------------------------------- /bitstorm-svr-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | bitoffer.cn 8 | bitstorm-svr 9 | 0.0.1-SNAPSHOT 10 | ../pom.xml 11 | 12 | 13 | bitstorm-svr-api 14 | 15 | 16 | 17 | org.springframework.cloud 18 | spring-cloud-starter-openfeign 19 | 20 | 21 | 22 | org.projectlombok 23 | lombok 24 | 25 | 26 | -------------------------------------------------------------------------------- /bitstorm-svr-demo/src/main/java/cn/bitoffer/improve/mapper/ExampleMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve.mapper; 2 | 3 | 4 | import cn.bitoffer.improve.model.Example; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | /** 9 | * mybatis mapper 接口模版 10 | * 操作数据库的接口 11 | **/ 12 | @Mapper 13 | public interface ExampleMapper { 14 | 15 | /** 16 | * 保存Example 17 | * 18 | * @param example 19 | */ 20 | void save(@Param("example") Example example); 21 | 22 | /** 23 | * 根据ExampleId删除Example 24 | * 25 | * @param exampleId 26 | */ 27 | void deleteById(@Param("exampleId") Long exampleId); 28 | 29 | /** 30 | * 更新Example 31 | * 32 | * @param example 33 | */ 34 | void update(@Param("example") Example example); 35 | 36 | /** 37 | * 根据ExampleId查询Example 38 | * 39 | * @param exampleId 40 | * @return Example 41 | */ 42 | Example getExampleById(@Param("exampleId") Long exampleId); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /bitstorm-svr-improve/src/main/java/cn/bitoffer/improve/mapper/ExampleMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve.mapper; 2 | 3 | 4 | import cn.bitoffer.improve.model.Example; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | /** 9 | * mybatis mapper 接口模版 10 | * 操作数据库的接口 11 | **/ 12 | @Mapper 13 | public interface ExampleMapper { 14 | 15 | /** 16 | * 保存Example 17 | * 18 | * @param example 19 | */ 20 | void save(@Param("example") Example example); 21 | 22 | /** 23 | * 根据ExampleId删除Example 24 | * 25 | * @param exampleId 26 | */ 27 | void deleteById(@Param("exampleId") Long exampleId); 28 | 29 | /** 30 | * 更新Example 31 | * 32 | * @param example 33 | */ 34 | void update(@Param("example") Example example); 35 | 36 | /** 37 | * 根据ExampleId查询Example 38 | * 39 | * @param exampleId 40 | * @return Example 41 | */ 42 | Example getExampleById(@Param("exampleId") Long exampleId); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/java/cn/bitoffer/seckill/service/SecKillService.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.seckill.service; 2 | 3 | import cn.bitoffer.seckill.model.Goods; 4 | import cn.bitoffer.seckill.model.PreSecKillRecord; 5 | 6 | import java.util.ArrayList; 7 | import java.util.Arrays; 8 | import java.util.List; 9 | 10 | public interface SecKillService { 11 | 12 | Goods getGoodsByNum(String traceID, Long userID, String goodsNum); 13 | 14 | ArrayList getGoodsList(String traceID, Long userID, Integer offset, Integer limit); 15 | 16 | String secKillV1(String traceID, Long userID, String goodsNum, Integer num); 17 | 18 | String secKillV2(String traceID, Long userID, String goodsNum, Integer num); 19 | 20 | String secKillV3(String traceID, Long userID, String goodsNum, Integer num); 21 | 22 | String secKillInStore(String traceID, Long userID, Goods goods, String secNum, Integer num); 23 | 24 | void setSuccessInPreSecKill(String traceID, Long userID, Goods goods, String secNum, PreSecKillRecord record); 25 | } 26 | -------------------------------------------------------------------------------- /bitstorm-svr-improve/src/main/resources/mapper/CountMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | `id`, 14 | `num`, 15 | `create_time`, 16 | `modify_time` 17 | 18 | 21 | 22 | update t_count_test 23 | 24 | `count` = count + #{num}, 25 | 26 | limit 1; 27 | 28 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/java/cn/bitoffer/lottery/mapper/PrizeMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.lottery.mapper; 2 | 3 | import cn.bitoffer.lottery.model.Prize; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.ArrayList; 8 | import java.util.Date; 9 | 10 | @Mapper 11 | public interface PrizeMapper { 12 | Prize get(@Param("id") int id); 13 | 14 | ArrayList getAll(); 15 | 16 | void sava(@Param("prize") Prize prize); 17 | 18 | void saveInBatches(@Param("prizeList") ArrayList prizeList); 19 | 20 | void deleteAll(); 21 | 22 | void updatePrizePlan(@Param("id") Long id, @Param("prizePlan") String prizePlan); 23 | 24 | void updatePrizePlanWithTime(@Param("id") Long id, @Param("prizePlan") String prizePlan, @Param("prizeBegin") Date prizeBegin, @Param("prizeEnd") Date prizeEnd); 25 | 26 | ArrayList getAllUsefulPrizeList(@Param("now") Date now); 27 | 28 | int decrLeftNum(@Param("id") Long id,@Param("num")int num); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/java/cn/bitoffer/lottery/scheduler/ShedulerUserTask.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.lottery.scheduler; 2 | 3 | import cn.bitoffer.lottery.constant.Constants; 4 | import cn.bitoffer.lottery.redis.RedisUtil; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.scheduling.annotation.Scheduled; 8 | import org.springframework.stereotype.Component; 9 | 10 | import javax.annotation.PostConstruct; 11 | import java.time.LocalDateTime; 12 | 13 | @Slf4j 14 | @Component 15 | public class ShedulerUserTask { 16 | @Autowired 17 | private RedisUtil redisUtil; 18 | @Scheduled(cron = "0 0 0 * * ?") 19 | @PostConstruct 20 | public void scheduledTask() { 21 | log.info("重置今日用户抽奖次数:{}", LocalDateTime.now()); 22 | for(int i = 0; i< Constants.userFrameSize; i++){ 23 | String key = String.format(Constants.userLotteryDayNumPrefix+"%d", i); 24 | // 清理ip抽奖次数 25 | redisUtil.del(key); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /bitstorm-svr-xtimer/src/main/java/cn/bitoffer/xtimer/exception/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.xtimer.exception; 2 | 3 | import cn.bitoffer.common.model.ResponseEntity; 4 | import cn.bitoffer.xtimer.exception.BusinessException; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.web.bind.annotation.ExceptionHandler; 7 | import org.springframework.web.bind.annotation.RestControllerAdvice; 8 | 9 | /** 10 | * 全局异常处理器 11 | * 12 | */ 13 | @RestControllerAdvice 14 | @Slf4j 15 | public class GlobalExceptionHandler { 16 | 17 | @ExceptionHandler(BusinessException.class) 18 | public ResponseEntity businessExceptionHandler(BusinessException e) { 19 | log.error("BusinessException", e); 20 | return ResponseEntity.failBusinessException(e.getCode(),e.getMessage()); 21 | } 22 | 23 | @ExceptionHandler(RuntimeException.class) 24 | public ResponseEntity runtimeExceptionHandler(RuntimeException e) { 25 | log.error("RuntimeException", e); 26 | return ResponseEntity.fail(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/java/cn/bitoffer/lottery/scheduler/ShedulerIpTask.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.lottery.scheduler; 2 | 3 | import cn.bitoffer.lottery.constant.Constants; 4 | import cn.bitoffer.lottery.redis.RedisUtil; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.scheduling.annotation.Scheduled; 8 | import org.springframework.stereotype.Component; 9 | 10 | import javax.annotation.PostConstruct; 11 | import java.time.LocalDateTime; 12 | 13 | 14 | @Slf4j 15 | @Component 16 | public class ShedulerIpTask { 17 | 18 | @Autowired 19 | private RedisUtil redisUtil; 20 | @Scheduled(cron = "0 0 0 * * ?") 21 | @PostConstruct 22 | public void scheduledTask() { 23 | log.info("重置今日ip抽奖次数:{}", LocalDateTime.now()); 24 | for(int i = 0; i< Constants.ipFrameSize; i++){ 25 | String key = String.format(Constants.ipLotteryDayNumPrefix+"%d", i); 26 | // 清理ip抽奖次数 27 | redisUtil.del(key); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/java/cn/bitoffer/seckill/mapper/SecKillStockMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.seckill.mapper; 2 | 3 | 4 | import cn.bitoffer.seckill.model.SecKillStock; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | @Mapper 9 | public interface SecKillStockMapper { 10 | 11 | /** 12 | * 保存SecKillStock 13 | * 14 | * @param secKillStock 15 | */ 16 | void save(@Param("stock") SecKillStock secKillStock); 17 | 18 | /** 19 | * 更新SecKillStock 20 | * 21 | * @param secKillStock 22 | */ 23 | void update(@Param("stock") SecKillStock secKillStock); 24 | 25 | /** 26 | * 根据SecKillStockId查询SecKillStock 27 | * 28 | * @param stockId 29 | * @return SecKillStock 30 | */ 31 | SecKillStock getSecKillStockById(@Param("stockId") Long stockId); 32 | 33 | /** 34 | * DescStock 35 | * 36 | * @param goodsID 37 | * @param num 38 | * @return void 39 | */ 40 | Integer descStock(@Param("goodsID") Long goodsID, @Param("num") Integer num); 41 | } 42 | -------------------------------------------------------------------------------- /db/bitstorm-svr-leaf.sql: -------------------------------------------------------------------------------- 1 | USE leaf; 2 | 3 | CREATE TABLE `leaf_alloc` 4 | ( 5 | `biz_tag` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '区分业务', 6 | `max_id` bigint unsigned NOT NULL DEFAULT '1' COMMENT '该biz_tag目前所被分配的ID号段的最大值', 7 | `step` int NOT NULL COMMENT '每次分配的号段长度', 8 | `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', 9 | `description` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '描述', 10 | `random_step` int unsigned NOT NULL DEFAULT '1' COMMENT '每次getid时随机增加的长度,这样就不会有连续的id了', 11 | PRIMARY KEY (`biz_tag`) USING BTREE 12 | ) ENGINE = InnoDB 13 | DEFAULT CHARSET = utf8mb4 14 | COLLATE = utf8mb4_0900_ai_ci; 15 | 16 | # 测试 key 17 | INSERT INTO `leaf_alloc` 18 | VALUES ('test', 1, 100, '2023-09-01 08:00:00', '测试', 100); 19 | -------------------------------------------------------------------------------- /bitstorm-svr-leaf/src/main/java/cn/bitoffer/leaf/segment/model/LeafAlloc.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.leaf.segment.model; 2 | 3 | /** 4 | * @author leaf 5 | */ 6 | public class LeafAlloc { 7 | 8 | private String key; 9 | 10 | private long maxId; 11 | 12 | private int step; 13 | 14 | private String updateTime; 15 | 16 | private int randomStep; 17 | 18 | public String getKey() { 19 | return key; 20 | } 21 | 22 | public void setKey(String key) { 23 | this.key = key; 24 | } 25 | 26 | public long getMaxId() { 27 | return maxId; 28 | } 29 | 30 | public void setMaxId(long maxId) { 31 | this.maxId = maxId; 32 | } 33 | 34 | public int getStep() { 35 | return step; 36 | } 37 | 38 | public void setStep(int step) { 39 | this.step = step; 40 | } 41 | 42 | public String getUpdateTime() { 43 | return updateTime; 44 | } 45 | 46 | public void setUpdateTime(String updateTime) { 47 | this.updateTime = updateTime; 48 | } 49 | 50 | public int getRandomStep() { 51 | return randomStep; 52 | } 53 | 54 | public void setRandomStep(int randomStep) { 55 | this.randomStep = randomStep; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/core/ObserverManager.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.core; 2 | 3 | import com.zdf.worker.boot.AppLaunch; 4 | 5 | import java.lang.reflect.InvocationTargetException; 6 | import java.lang.reflect.Method; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | public class ObserverManager { 11 | List observers; 12 | 13 | public ObserverManager() { 14 | observers = new ArrayList<>(); 15 | } 16 | // 添加观察者 17 | public void registerEventObserver(ObserverFunction observerFunction) { 18 | observers.add(observerFunction); 19 | } 20 | 21 | // 通过发射找到对应的方法执行 22 | public void wakeupObserver(AppLaunch.ObserverType observerType, Object... params) throws InvocationTargetException, IllegalAccessException { 23 | for (ObserverFunction observer : observers) { 24 | for (Method method : observer.getClass().getMethods()) { 25 | if (method.getName().equals(observerType.name())) { 26 | method.invoke(observer, params); 27 | } 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /bitstorm-svr-xtimer/src/main/java/cn/bitoffer/xtimer/service/trigger/TriggerPoolTask.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.xtimer.service.trigger; 2 | 3 | import cn.bitoffer.xtimer.model.TaskModel; 4 | import cn.bitoffer.common.redis.ReentrantDistributeLock; 5 | import cn.bitoffer.xtimer.service.executor.ExecutorWorker; 6 | import cn.bitoffer.xtimer.utils.TimerUtils; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.scheduling.annotation.Async; 10 | import org.springframework.stereotype.Component; 11 | 12 | @Slf4j 13 | @Component 14 | public class TriggerPoolTask { 15 | 16 | @Autowired 17 | ReentrantDistributeLock reentrantDistributeLock; 18 | 19 | @Autowired 20 | ExecutorWorker executorWorker; 21 | 22 | @Async("triggerPool") 23 | public void runExecutor(TaskModel task) { 24 | if(task == null){ 25 | return; 26 | } 27 | log.info("start runExecutor"); 28 | 29 | executorWorker.work(TimerUtils.UnionTimerIDUnix(task.getTimerId(),task.getRunTimer())); 30 | 31 | log.info("end executeAsync"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /bitstorm-svr-auth/src/main/java/cn/bitoffer/auth/service/CustomUserDetailsService.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.auth.service; 2 | 3 | import cn.bitoffer.auth.model.UserCredential; 4 | import cn.bitoffer.auth.model.LoginUser; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.security.core.userdetails.UserDetails; 8 | import org.springframework.security.core.userdetails.UserDetailsService; 9 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 10 | import org.springframework.stereotype.Service; 11 | 12 | @Service 13 | @Slf4j 14 | public class CustomUserDetailsService implements UserDetailsService { 15 | 16 | @Autowired 17 | private AuthService authService; 18 | 19 | @Override 20 | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { 21 | UserCredential credential = authService.findUserByUsername(username); 22 | if(credential == null){ 23 | log.error("user not found"); 24 | return null; 25 | } 26 | return new LoginUser(credential); 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/resources/mapper/QuotaMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | `id`, 15 | `num`, 16 | `goods_id`, 17 | `create_time`, 18 | `modify_time` 19 | 20 | 21 | insert into t_quota(`num`,`goods_id`) 22 | values (#{quota.num},#{quota.goodsID}); 23 | 24 | 27 | 28 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/data/AsyncTaskReturn.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.data; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class AsyncTaskReturn { 11 | private String user_id; //NOT NULL DEFAULT '', 12 | 13 | private String task_id; // NOT NULL DEFAULT '', 14 | 15 | private String task_type; //NOT NULL DEFAULT '', 16 | 17 | private String task_stage; //NOT NULL DEFAULT '', 18 | 19 | private long order_time; 20 | 21 | private int priority; 22 | 23 | private int status; //tinyint(3) unsigned NOT NULL DEFAULT '0', 24 | 25 | private int crt_retry_num; //NOT NULL DEFAULT '0' COMMENT '已经重试几次了', 26 | 27 | private int max_retry_num; //NOT NULL DEFAULT '0' COMMENT '最大能重试几次', 28 | 29 | private int max_retry_interval;// int(11) NOT NULL DEFAULT '0' COMMENT '最大重试间隔', 30 | 31 | private String schedule_log;// varchar(4096) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '调度信息记录', 32 | 33 | private String task_context; 34 | 35 | private Long create_time; 36 | 37 | private Long modify_time; 38 | 39 | } 40 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/java/cn/bitoffer/lottery/common/ErrorCode.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.lottery.common; 2 | 3 | public enum ErrorCode { 4 | 5 | SUCCESS(0, "success"), 6 | ERR_INTERNAL_SERCER(500, "internal server error"), 7 | ERR_INPUT_INVALID(8020, "input invalid"), 8 | ERR_SHOULD_BIND(8021, "should bind failed"), 9 | ERR_JSON_PARSE(8022, "json marshal failed"), 10 | ERR_JWT_PARSE(8023, "jwt marshal failed"), 11 | ERR_LOGIN(10000, "login fail"), 12 | ERR_IP_LIMIT_INVALID(10001, "ip day num limited"), 13 | ERR_USER_LIMIT_INVALID(10002, "user day num limited"), 14 | ERR_BLACK_IP(10003, "blacked ip"), 15 | ERR_BLACK_USER(10004, "blacked user"), 16 | ERR_NOT_WON(10005, "not won,please try again!"), 17 | ; 18 | 19 | 20 | /** 21 | * 状态码 22 | */ 23 | private final int code; 24 | 25 | /** 26 | * 信息 27 | */ 28 | private final String message; 29 | 30 | ErrorCode(int code, String message) { 31 | this.code = code; 32 | this.message = message; 33 | } 34 | 35 | public int getCode() { 36 | return code; 37 | } 38 | 39 | public String getMessage() { 40 | return message; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/java/cn/bitoffer/seckill/mapper/ExampleMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.seckill.mapper; 2 | 3 | 4 | import cn.bitoffer.seckill.model.Example; 5 | import cn.bitoffer.seckill.model.Goods; 6 | import org.apache.ibatis.annotations.Mapper; 7 | import org.apache.ibatis.annotations.Param; 8 | 9 | @Mapper 10 | public interface ExampleMapper { 11 | 12 | /** 13 | * 保存Example 14 | * 15 | * @param example 16 | */ 17 | void save(@Param("example") Example example); 18 | 19 | /** 20 | * 根据ExampleId删除Example 21 | * 22 | * @param exampleId 23 | */ 24 | void deleteById(@Param("exampleId") Long exampleId); 25 | 26 | /** 27 | * 更新Example 28 | * 29 | * @param example 30 | */ 31 | void update(@Param("example") Example example); 32 | 33 | /** 34 | * 根据ExampleId查询Example 35 | * 36 | * @param exampleId 37 | * @return Example 38 | */ 39 | Example getExampleById(@Param("exampleId") Long exampleId); 40 | 41 | 42 | /** 43 | * 根据goodsNum查询goods 44 | * 45 | * @param goodsNum 46 | * @return Goods 47 | */ 48 | Goods getGoodsByNum(@Param("goodsNum") String goodsNum); 49 | 50 | } 51 | -------------------------------------------------------------------------------- /bitstorm-svr-xtimer/src/main/java/cn/bitoffer/xtimer/mapper/TimerMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.xtimer.mapper; 2 | 3 | 4 | import cn.bitoffer.xtimer.model.TimerModel; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import java.util.List; 9 | 10 | @Mapper 11 | public interface TimerMapper { 12 | 13 | /** 14 | * 保存timerModel 15 | * 16 | * @param timerModel 17 | */ 18 | void save(@Param("timerModel") TimerModel timerModel); 19 | 20 | /** 21 | * 根据timerId删除TimerModel 22 | * 23 | * @param timerId 24 | */ 25 | void deleteById(@Param("timerId") Long timerId); 26 | 27 | /** 28 | * 更新TimerModel 29 | * 30 | * @param timerModel 31 | */ 32 | void update(@Param("timerModel") TimerModel timerModel); 33 | 34 | /** 35 | * 根据timerId查询TimerModel 36 | * 37 | * @param timerId 38 | * @return TimerModel 39 | */ 40 | TimerModel getTimerById(@Param("timerId") Long timerId); 41 | 42 | /** 43 | * 根据status查询TimerModel 44 | * 45 | * @param status 46 | * @return TimerModel 47 | */ 48 | List getTimersByStatus(@Param("status") int status); 49 | } 50 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/java/cn/bitoffer/lottery/model/BlackIp.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.lottery.model; 2 | 3 | import java.util.Date; 4 | 5 | // BlackIp ip黑明单表 6 | public class BlackIp { 7 | private Long id; 8 | private String ip; 9 | private Date blackTime; 10 | private Date sysCreated; 11 | private Date sysUpdated; 12 | 13 | public Long getId() { 14 | return id; 15 | } 16 | 17 | public void setId(Long id) { 18 | this.id = id; 19 | } 20 | 21 | public String getIp() { 22 | return ip; 23 | } 24 | 25 | public void setIp(String ip) { 26 | this.ip = ip; 27 | } 28 | 29 | public Date getBlackTime() { 30 | return blackTime; 31 | } 32 | 33 | public void setBlackTime(Date blackTime) { 34 | this.blackTime = blackTime; 35 | } 36 | 37 | public Date getSysCreated() { 38 | return sysCreated; 39 | } 40 | 41 | public void setSysCreated(Date sysCreated) { 42 | this.sysCreated = sysCreated; 43 | } 44 | 45 | public Date getSysUpdated() { 46 | return sysUpdated; 47 | } 48 | 49 | public void setSysUpdated(Date sysUpdated) { 50 | this.sysUpdated = sysUpdated; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/dto/TaskData.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.dto; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 5 | import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; 6 | import lombok.Data; 7 | 8 | import java.time.LocalDateTime; 9 | 10 | @Data 11 | public class TaskData { 12 | private int status; 13 | private Long priority; 14 | private Long crtRetryNum; 15 | private Long maxRetryNum; 16 | private Long maxRetryInterval; 17 | private String userId; 18 | private String taskId; 19 | private String taskType; 20 | private String Stage; 21 | private String context; 22 | 23 | private String scheduleLog; 24 | private Long orderTime; 25 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone = "GMT+8", shape = JsonFormat.Shape.STRING) 26 | @JsonSerialize(using = LocalDateTimeSerializer.class) // 序列化 27 | private LocalDateTime createTime; 28 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone = "GMT+8", shape = JsonFormat.Shape.STRING) 29 | @JsonSerialize(using = LocalDateTimeSerializer.class) // 序列化 30 | private LocalDateTime modifyTime; 31 | } -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/mapper/TaskMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.mapper; 2 | 3 | import cn.bitoffer.asyncflow.model.TaskModel; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | @Mapper 10 | public interface TaskMapper { 11 | 12 | void create(@Param("tableName") String tableName, @Param("task") TaskModel task); 13 | 14 | void save(@Param("tableName") String tableName, @Param("task") TaskModel task); 15 | 16 | TaskModel getTask(@Param("tableName") String tableName, @Param("taskId") String taskId); 17 | 18 | List getTaskList(@Param("tableName") String tableName, @Param("status") int status, @Param("limit") int limit); 19 | 20 | int getTaskCountByStatus(@Param("status") int status, @Param("tableName") String tableName); 21 | 22 | int getTaskCount(@Param("statusList") List statusList, @Param("tableName") String tableName); 23 | 24 | void increaseCrtRetryNum(@Param("taskId") String taskId, @Param("tableName") String tableName); 25 | 26 | void updateStatusBatch(@Param("taskIdList") List taskIdList, @Param("status") int status, @Param("tableName") String tableName); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/java/cn/bitoffer/seckill/mapper/GoodsMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.seckill.mapper; 2 | 3 | 4 | import cn.bitoffer.seckill.model.Goods; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | @Mapper 12 | public interface GoodsMapper { 13 | 14 | /** 15 | * 保存Goods 16 | * 17 | * @param goods 18 | */ 19 | void save(@Param("goods") Goods goods); 20 | 21 | /** 22 | * 根据GoodsId删除Goods 23 | * 24 | * @param goodsId 25 | */ 26 | void deleteById(@Param("goodsId") Long goodsId); 27 | 28 | /** 29 | * 更新Goods 30 | * 31 | * @param goods 32 | */ 33 | void update(@Param("goods") Goods goods); 34 | 35 | /** 36 | * 根据GoodsId查询Goods 37 | * 38 | * @param goodsId 39 | * @return Goods 40 | */ 41 | Goods getGoodsById(@Param("goodsId") Long goodsId); 42 | 43 | /** 44 | * 根据GoodsId查询Goods 45 | * 46 | * @param goodsNum 47 | * @return Goods 48 | */ 49 | Goods getGoodsByNum(@Param("goodsNum") String goodsNum); 50 | 51 | ArrayList getGoodsList(@Param("offset") Integer offset, @Param("limit") Integer limit); 52 | } 53 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/model/TaskScheduleCfgModel.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.model; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.time.LocalDateTime; 7 | 8 | @Data 9 | public class TaskScheduleCfgModel implements Serializable { 10 | public String taskType; 11 | public long scheduleLimit; 12 | public long scheduleInterval; 13 | public long maxProcessingTime; 14 | public long maxRetryNum; 15 | public long retryInterval; 16 | public long maxRetryInterval; 17 | public LocalDateTime createTime; 18 | public LocalDateTime modifyTime; 19 | 20 | @Override 21 | public String toString() { 22 | return "TaskScheduleCfgModel{" + 23 | "taskType='" + taskType + '\'' + 24 | ", scheduleLimit=" + scheduleLimit + 25 | ", scheduleInterval=" + scheduleInterval + 26 | ", maxProcessingTime=" + maxProcessingTime + 27 | ", maxRetryNum=" + maxRetryNum + 28 | ", retryInterval=" + retryInterval + 29 | ", maxRetryInterval=" + maxRetryInterval + 30 | ", createTime=" + createTime + 31 | ", modifyTime=" + modifyTime + 32 | '}'; 33 | } 34 | } -------------------------------------------------------------------------------- /bitstorm-svr-shorturlx/src/main/resources/mapper/UrlMapMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | insert into url_map (long_url, short_url, created_at) values (#{urlMap.longUrl}, #{urlMap.shortUrl}, now()) 15 | 16 | 17 | 20 | 21 | 24 | 25 | 26 | update url_map set short_url = #{shortUrl} where long_url = #{longUrl} 27 | 28 | 29 | -------------------------------------------------------------------------------- /bitstorm-svr-xtimer/src/main/java/cn/bitoffer/xtimer/controller/XtimerWebController.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.xtimer.controller; 2 | 3 | import cn.bitoffer.api.dto.xtimer.TimerDTO; 4 | import cn.bitoffer.common.model.ResponseEntity; 5 | import cn.bitoffer.xtimer.service.XTimerService; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.util.MultiValueMap; 8 | import org.springframework.web.bind.annotation.*; 9 | 10 | import javax.annotation.Resource; 11 | 12 | 13 | @RestController 14 | @RequestMapping("/xtimer") 15 | @Slf4j 16 | public class XtimerWebController { 17 | 18 | @Resource 19 | private XTimerService xTimerService; 20 | 21 | @PostMapping(value = "/createTimer") 22 | public ResponseEntity createTimer(@RequestBody TimerDTO timerDTO){ 23 | Long timerId = xTimerService.CreateTimer(timerDTO); 24 | return ResponseEntity.ok(timerId); 25 | } 26 | 27 | @GetMapping(value = "/enableTimer") 28 | public ResponseEntity enableTimer(@RequestParam(value = "app") String app, 29 | @RequestParam(value = "timerId") Long timerId, 30 | @RequestHeader MultiValueMap headers){ 31 | xTimerService.EnableTimer(app,timerId); 32 | return ResponseEntity.ok("ok"); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/java/cn/bitoffer/seckill/common/ResponseEnum.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.seckill.common; 2 | 3 | public enum ResponseEnum { 4 | OK(0, "success"), 5 | FAIL(1, "failed"), 6 | ERR_INPUT_INVALID ( 8020, "input invalid"), 7 | ERR_SHOULD_BIND ( 8021, "should bind failed"), 8 | ERR_JSON_MARSHAL ( 8022, "json marshal failed"), 9 | ERR_FIND_GOODS_FAILED ( 8101, "商品查询失败"), 10 | ERR_GOODS_STOCK_NOT_ENOUGH ( 8102, "商品库存不足"), 11 | ERR_CREATE_ORDER_FAILED ( 8103, "订单创建失败"), 12 | ERR_CREATE_SECKILL_RECORD_FAILED ( 8104, "秒杀记录创建失败"), 13 | ERR_RECORD_USER_KILLED_NUM_FAILED ( 8105, "记录用户已经秒杀到的名额数失败"), 14 | ERR_DESC_STOCK_FAILED ( 8106, "库存扣减失败"), 15 | ERR_CREATER_USER_QUOTA_FAILED ( 8107, "插入用户限额记录失败"), 16 | ERR_USER_QUOTA_NOT_ENOUGH ( 8108, "用户额度不足"), 17 | ERR_FIND_USER_QUOTA_FAILED ( 8109, "查询用户额度失败"), 18 | 19 | 20 | ; 21 | private final int code; 22 | private final String message; 23 | 24 | ResponseEnum(int code, String message) { 25 | this.code = code; 26 | this.message = message; 27 | } 28 | 29 | public int code() { 30 | return code; 31 | } 32 | 33 | public String message() { 34 | return message; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/resources/mapper/SecKillStockMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | `id`, 15 | `goods_id`, 16 | `stock`, 17 | `create_time`, 18 | `modify_time` 19 | 20 | 21 | insert into t_seckill_stock (`secKillStock_name`,`status`) 22 | values (#{secKillStock.secKillStockName},#{secKillStock.status}); 23 | 24 | 25 | update t_seckill_stock 26 | 27 | `stock` = stock - #{num}, 28 | 29 | where goods_id = #{goodsID} and stock >= #{num}; 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/data/AsyncTaskBase.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.data; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class AsyncTaskBase { 11 | private String user_id; //NOT NULL DEFAULT '', 12 | 13 | private String task_id; // NOT NULL DEFAULT '', 14 | 15 | private String task_type; //NOT NULL DEFAULT '', 存储任务的全类名 16 | 17 | private String task_stage; //NOT NULL DEFAULT '', 存储任务阶段信息 18 | 19 | private int status; //tinyint(3) unsigned NOT NULL DEFAULT '0', 20 | 21 | private int crt_retry_num; //NOT NULL DEFAULT '0' COMMENT '已经重试几次了', 22 | 23 | private int max_retry_num; //NOT NULL DEFAULT '0' COMMENT '最大能重试几次', 24 | 25 | private long order_time; 26 | 27 | private int priority; 28 | 29 | private int max_retry_interval;// int(11) NOT NULL DEFAULT '0' COMMENT '最大重试间隔', 30 | 31 | private ScheduleLog schedule_log;// varchar(4096) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '调度信息记录', 32 | 33 | private NftTaskContext task_context;// varchar(8192) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '任务上下文,用户自定义', 34 | 35 | private Long create_time;// datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, 36 | 37 | private Long modify_time; 38 | } 39 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/enums/ErrorStatus.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.enums; 2 | 3 | // 错误状态 4 | public enum ErrorStatus { 5 | SUCCESS(0, "ok"), 6 | ERR_INPUT_INVALID(8020, "input invalid"), 7 | ERR_SHOULD_BIND(8021, "should bind failed"), 8 | ERR_JSON_MARSHAL(8022, "json marshal failed"), 9 | ERR_GET_TASK_INFO(8035, "get task info failed"), 10 | ERR_GET_TASK_HANDLE_PROCESS(8036, "get task handle process Failed"), 11 | ERR_CREATE_TASK(8037, "create task failed"), 12 | ERR_GET_TASK_LIST_FROM_DB(8038, "get task list from db failed"), 13 | ERR_GET_TASK_SET_POS_FROM_DB(8039, "get task set pos from db failed"), 14 | ERR_INCREASE_CRT_RETRY_NUM(8040, "set task failed"), 15 | ERR_SET_TASK(8041, "increase crt retry num failed"), 16 | ERR_GET_TASK_POS(8042, "get task pos failed"), 17 | ERR_GET_PROCESSING_COUNT(8043, "get processing count failed"), 18 | ERR_SET_USER_PRIORITY(8045, "set user priority failed"), 19 | ERR_GET_TASK_CFG_FROM_DB(8039, "get task cfg failed"); 20 | 21 | private int errCode; 22 | private String msg; 23 | private ErrorStatus(int errCode, String msg) { 24 | this.errCode = errCode; 25 | this.msg = msg; 26 | } 27 | 28 | public int getErrCode() { 29 | return errCode; 30 | } 31 | 32 | public String getMsg() { 33 | return msg; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/data/AsyncFlowTask.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.data; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class AsyncFlowTask { 7 | 8 | private Long id; 9 | 10 | private String user_id; //NOT NULL DEFAULT '', 11 | 12 | private String task_id; // NOT NULL DEFAULT '', 13 | 14 | private String task_type; //NOT NULL DEFAULT '', 存储任务的全类名 15 | 16 | private String task_stage; //NOT NULL DEFAULT '', 存储任务阶段信息 17 | 18 | private int status; //tinyint(3) unsigned NOT NULL DEFAULT '0', 19 | 20 | private long order_time; 21 | 22 | private int priority; 23 | 24 | private int crt_retry_num; //NOT NULL DEFAULT '0' COMMENT '已经重试几次了', 25 | 26 | private int max_retry_num; //NOT NULL DEFAULT '0' COMMENT '最大能重试几次', 27 | 28 | private int max_retry_interval;// int(11) NOT NULL DEFAULT '0' COMMENT '最大重试间隔', 29 | 30 | private String schedule_log;// varchar(4096) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '调度信息记录', 31 | 32 | private String task_context;// varchar(8192) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '任务上下文,用户自定义', 33 | 34 | private Long create_time;// datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, 35 | 36 | private Long modify_time;// datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/java/cn/bitoffer/lottery/model/LotteryTimes.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.lottery.model; 2 | 3 | import java.util.Date; 4 | 5 | // LotteryTimes 用户每日抽奖次数表 6 | public class LotteryTimes { 7 | private Long id; 8 | private Long userId; 9 | private Long day; 10 | private int num; 11 | private Date sysCreated; 12 | private Date sysUpdated; 13 | 14 | public Long getId() { 15 | return id; 16 | } 17 | 18 | public void setId(Long id) { 19 | this.id = id; 20 | } 21 | 22 | public Long getUserId() { 23 | return userId; 24 | } 25 | 26 | public void setUserId(Long userId) { 27 | this.userId = userId; 28 | } 29 | 30 | public Long getDay() { 31 | return day; 32 | } 33 | 34 | public void setDay(Long day) { 35 | this.day = day; 36 | } 37 | 38 | public int getNum() { 39 | return num; 40 | } 41 | 42 | public void setNum(int num) { 43 | this.num = num; 44 | } 45 | 46 | public Date getSysCreated() { 47 | return sysCreated; 48 | } 49 | 50 | public void setSysCreated(Date sysCreated) { 51 | this.sysCreated = sysCreated; 52 | } 53 | 54 | public Date getSysUpdated() { 55 | return sysUpdated; 56 | } 57 | 58 | public void setSysUpdated(Date sysUpdated) { 59 | this.sysUpdated = sysUpdated; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /bitstorm-svr-api/src/main/java/cn/bitoffer/api/feign/interceptor/ContextFeignInterceptor.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.api.feign.interceptor; 2 | 3 | import feign.RequestInterceptor; 4 | import feign.RequestTemplate; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.context.ApplicationContext; 8 | import org.springframework.stereotype.Component; 9 | import org.springframework.web.context.request.RequestAttributes; 10 | import org.springframework.web.context.request.RequestContextHolder; 11 | import org.springframework.web.context.request.ServletRequestAttributes; 12 | import org.springframework.web.server.ServerWebExchange; 13 | 14 | import java.util.List; 15 | 16 | @Component 17 | @Slf4j 18 | public class ContextFeignInterceptor implements RequestInterceptor { 19 | 20 | @Override 21 | public void apply(RequestTemplate template) { 22 | log.error("hello hello hellohello"); 23 | // 从请求上下文中获取userId 24 | // 从请求头中获取 X-User-Id 25 | List userId= (List)template.headers().get("X-User-Id"); 26 | if (userId != null) { 27 | // 将 userId 放入上下文(Context)中 28 | //MyContextHolder.setUserId(userId); 29 | } 30 | if (userId != null) { 31 | // 将userId添加到请求头中,以便传递给下游的微服务 32 | template.header("X-User-Id", userId); 33 | } 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/worker/src/main/java/com/zdf/worker/enums/TaskStatus.java: -------------------------------------------------------------------------------- 1 | package com.zdf.worker.enums; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | // 任务状态 7 | public enum TaskStatus { 8 | // 待执行 9 | PENDING(0x01), 10 | // 执行中 11 | EXECUTING(0x02), 12 | // 执行成功 13 | SUCCESS(0x04), 14 | // 执行失败 15 | FAIL(0x08); 16 | 17 | private TaskStatus(int status) { 18 | this.status = status; 19 | } 20 | private int status; 21 | 22 | public int getStatus() { 23 | return this.status; 24 | } 25 | 26 | public List getAliveStatus() { 27 | List aliveList = new ArrayList<>(); 28 | aliveList.add(PENDING); 29 | aliveList.add(EXECUTING); 30 | return aliveList; 31 | } 32 | public List getFailStatus() { 33 | List failList = new ArrayList<>(); 34 | failList.add(FAIL); 35 | return failList; 36 | } 37 | 38 | public List getSuccessStatus() { 39 | List sucList = new ArrayList<>(); 40 | sucList.add(SUCCESS); 41 | return sucList; 42 | } 43 | 44 | public List getAllStatus() { 45 | List list = new ArrayList<>(); 46 | for (TaskStatus value : TaskStatus.values()) { 47 | list.add(value); 48 | } 49 | return list; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/java/cn/bitoffer/lottery/model/Coupon.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.lottery.model; 2 | 3 | import java.util.Date; 4 | 5 | public class Coupon { 6 | private Long id; 7 | private Long prizeId; 8 | private String code; 9 | private Date sysCreated; 10 | private Date sysUpdated; 11 | private int sysStatus; 12 | 13 | public Long getId() { 14 | return id; 15 | } 16 | 17 | public void setId(Long id) { 18 | this.id = id; 19 | } 20 | 21 | public Long getPrizeId() { 22 | return prizeId; 23 | } 24 | 25 | public void setPrizeId(Long prizeId) { 26 | this.prizeId = prizeId; 27 | } 28 | 29 | public String getCode() { 30 | return code; 31 | } 32 | 33 | public void setCode(String code) { 34 | this.code = code; 35 | } 36 | 37 | public Date getSysCreated() { 38 | return sysCreated; 39 | } 40 | 41 | public void setSysCreated(Date sysCreated) { 42 | this.sysCreated = sysCreated; 43 | } 44 | 45 | public Date getSysUpdated() { 46 | return sysUpdated; 47 | } 48 | 49 | public void setSysUpdated(Date sysUpdated) { 50 | this.sysUpdated = sysUpdated; 51 | } 52 | 53 | public int getSysStatus() { 54 | return sysStatus; 55 | } 56 | 57 | public void setSysStatus(int sysStatus) { 58 | this.sysStatus = sysStatus; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /bitstorm-svr-shorturlx/src/main/java/cn/bitoffer/shorturlx/utils/Base62.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.shorturlx.utils; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | import java.util.Random; 6 | 7 | @Component 8 | public class Base62 { 9 | private static final String ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; 10 | private static final Random RANDOM = new Random(); 11 | private static String shuffledAlphabet; 12 | 13 | private Base62() { 14 | // 私有构造函数 15 | shuffledAlphabet = shuffleString(); 16 | } 17 | 18 | public String generateShortUrl(Long id) { 19 | return base62Encode(id); 20 | } 21 | private static String base62Encode(Long decimal) { 22 | StringBuilder result = new StringBuilder(); 23 | while (decimal > 0) { 24 | int remainder = (int) (decimal % 62); 25 | result.append(shuffledAlphabet.charAt(remainder)); 26 | decimal /= 62; 27 | } 28 | return result.reverse().toString(); 29 | } 30 | private static String shuffleString() { 31 | char[] chars = Base62.ALPHABET.toCharArray(); 32 | for (int i = chars.length - 1; i > 0; i--) { 33 | int j = RANDOM.nextInt(i + 1); 34 | char tmp = chars[i]; 35 | chars[i] = chars[j]; 36 | chars[j] = tmp; 37 | } 38 | return new String(chars); 39 | } 40 | } -------------------------------------------------------------------------------- /bitstorm-svr-asyncflow/flowsvr/src/main/java/cn/bitoffer/asyncflow/utils/Base62.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.asyncflow.utils; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | import java.util.Random; 6 | 7 | @Component 8 | public class Base62 { 9 | private static final String ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; 10 | private static final Random RANDOM = new Random(); 11 | private static String shuffledAlphabet; 12 | 13 | private Base62() { 14 | // 私有构造函数 15 | shuffledAlphabet = shuffleString(); 16 | } 17 | 18 | public String generateShortUrl(Long id) { 19 | return base62Encode(id); 20 | } 21 | private static String base62Encode(Long decimal) { 22 | StringBuilder result = new StringBuilder(); 23 | while (decimal > 0) { 24 | int remainder = (int) (decimal % 62); 25 | result.append(shuffledAlphabet.charAt(remainder)); 26 | decimal /= 62; 27 | } 28 | return result.reverse().toString(); 29 | } 30 | private static String shuffleString() { 31 | char[] chars = Base62.ALPHABET.toCharArray(); 32 | for (int i = chars.length - 1; i > 0; i--) { 33 | int j = RANDOM.nextInt(i + 1); 34 | char tmp = chars[i]; 35 | chars[i] = chars[j]; 36 | chars[j] = tmp; 37 | } 38 | return new String(chars); 39 | } 40 | } -------------------------------------------------------------------------------- /bitstorm-svr-leaf/src/main/java/cn/bitoffer/leaf/feign/SegmentFeignController.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.leaf.feign; 2 | 3 | import cn.bitoffer.api.feign.LeafFeignClient; 4 | import cn.bitoffer.leaf.common.Result; 5 | import cn.bitoffer.leaf.common.Status; 6 | import cn.bitoffer.leaf.exception.LeafServerException; 7 | import cn.bitoffer.leaf.exception.NoKeyException; 8 | import cn.bitoffer.leaf.service.SegmentService; 9 | import org.springframework.http.ResponseEntity; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | import java.util.Objects; 13 | 14 | @RestController 15 | public class SegmentFeignController implements LeafFeignClient { 16 | 17 | private final SegmentService segmentService; 18 | 19 | public SegmentFeignController(SegmentService segmentService) { 20 | this.segmentService = segmentService; 21 | } 22 | 23 | @Override 24 | public ResponseEntity getSegmentID(String key) { 25 | return ResponseEntity.ok(get(key, segmentService.getId(key))); 26 | } 27 | 28 | 29 | private Long get(String key, Result id) { 30 | Result result; 31 | if (key == null || key.isEmpty()) { 32 | throw new NoKeyException(); 33 | } 34 | result = id; 35 | if (Objects.equals(result.getStatus(), Status.EXCEPTION)) { 36 | throw new LeafServerException(result.toString()); 37 | } 38 | return result.getId(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/resources/mapper/BlackIpMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | `id`, 15 | `ip`, 16 | `black_time`, 17 | `sys_created`, 18 | `sys_updated` 19 | 20 | 21 | 22 | insert into t_black_ip (`ip`,`black_time`,`sys_created`,`sys_updated`) 23 | values (#{blackIp.ip},#{blackIp.blackTime},#{blackIp.sysCreated},#{blackIp.sysUpdated}); 24 | 25 | 26 | update t_black_ip set black_time = #{blackTime}, sys_updated= now() where ip = #{ip}; 27 | 28 | 31 | 32 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/java/cn/bitoffer/seckill/model/Example.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.seckill.model; 2 | 3 | import cn.bitoffer.seckill.common.BaseModel; 4 | 5 | import java.io.Serializable; 6 | 7 | public class Example extends BaseModel implements Serializable { 8 | /** 9 | * Id 10 | */ 11 | private Long exampleId; 12 | 13 | /** 14 | * Name 15 | */ 16 | private String exampleName; 17 | 18 | /** 19 | * Status 20 | */ 21 | private Integer status; 22 | 23 | public Long getExampleId() { 24 | return exampleId; 25 | } 26 | 27 | public void setExampleId(Long exampleId) { 28 | this.exampleId = exampleId; 29 | } 30 | 31 | public String getExampleName() { 32 | return exampleName; 33 | } 34 | 35 | public void setExampleName(String exampleName) { 36 | this.exampleName = exampleName; 37 | } 38 | 39 | public Integer getStatus() { 40 | return status; 41 | } 42 | 43 | public void setStatus(Integer status) { 44 | this.status = status; 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "Example{" + 50 | "exampleId=" + exampleId + 51 | ", exampleName='" + exampleName + '\'' + 52 | ", status=" + status + 53 | ", createTime=" + createTime + 54 | ", updateTime=" + modifyTime + 55 | '}'; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /bitstorm-svr-leaf/src/main/java/cn/bitoffer/leaf/service/SegmentService.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.leaf.service; 2 | 3 | import cn.bitoffer.leaf.common.Result; 4 | import cn.bitoffer.leaf.exception.InitException; 5 | import cn.bitoffer.leaf.segment.SegmentIDGenImpl; 6 | import cn.bitoffer.leaf.segment.dao.IDAllocDao; 7 | import cn.bitoffer.leaf.segment.dao.impl.IDAllocDaoImpl; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import org.springframework.stereotype.Service; 11 | 12 | import javax.sql.DataSource; 13 | 14 | /** 15 | * @author left 16 | */ 17 | @Service("SegmentService") 18 | public class SegmentService { 19 | 20 | private final Logger logger = LoggerFactory.getLogger(SegmentService.class); 21 | 22 | private final IDGen idGen; 23 | 24 | public SegmentService(DataSource dataSource) throws InitException { 25 | // Config Dao 26 | IDAllocDao dao = new IDAllocDaoImpl(dataSource); 27 | 28 | // Config ID Gen 29 | idGen = new SegmentIDGenImpl(); 30 | ((SegmentIDGenImpl) idGen).setDao(dao); 31 | if (idGen.init()) { 32 | logger.info("Segment Service Init Successfully"); 33 | } 34 | else { 35 | throw new InitException("Segment Service Init Fail"); 36 | } 37 | 38 | } 39 | 40 | public Result getId(String key) { 41 | return idGen.get(key); 42 | } 43 | 44 | public SegmentIDGenImpl getIdGen() { 45 | if (idGen instanceof SegmentIDGenImpl) { 46 | return (SegmentIDGenImpl) idGen; 47 | } 48 | return null; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/java/cn/bitoffer/seckill/mapper/UserQuotaMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.seckill.mapper; 2 | 3 | 4 | import cn.bitoffer.seckill.model.UserQuota; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | @Mapper 12 | public interface UserQuotaMapper { 13 | 14 | /** 15 | * 保存UserQuota 16 | * 17 | * @param userQuota 18 | */ 19 | void save(@Param("userQuota") UserQuota userQuota); 20 | 21 | /** 22 | * 更新UserQuota 23 | * 24 | * @param userQuota 25 | */ 26 | void update(@Param("userQuota") UserQuota userQuota); 27 | 28 | /** 29 | * 根据UserQuotaId查询UserQuota 30 | * 31 | * @param userQuotaId 32 | * @return UserQuota 33 | */ 34 | UserQuota getUserQuotaById(@Param("userQuotaId") Long userQuotaId); 35 | 36 | /** 37 | * 根据UserQuotaId查询UserQuota 38 | * 39 | * @param userID 40 | * @param goodsID 41 | * @return UserQuota 42 | */ 43 | UserQuota getUserGoodsUserQuota(@Param("userID") Long userID, @Param("goodsID") Long goodsID); 44 | 45 | /** 46 | * 根据UserQuotaId查询UserQuota 47 | * 48 | * @param userID 49 | * @param goodsID 50 | * @param num 51 | * @return UserQuota 52 | */ 53 | Integer incrKilledNum(@Param("userID") Long userID, @Param("goodsID") Long goodsID, @Param("num") Integer num); 54 | } 55 | -------------------------------------------------------------------------------- /bitstorm-svr-xtimer/src/main/java/cn/bitoffer/xtimer/mapper/TaskMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.xtimer.mapper; 2 | 3 | 4 | import cn.bitoffer.xtimer.model.TaskModel; 5 | import cn.bitoffer.xtimer.model.TimerModel; 6 | import org.apache.ibatis.annotations.Mapper; 7 | import org.apache.ibatis.annotations.Param; 8 | 9 | import javax.xml.crypto.Data; 10 | import java.util.List; 11 | 12 | @Mapper 13 | public interface TaskMapper { 14 | 15 | /** 16 | * 批量插入taskModel 17 | * 18 | * @param taskList 19 | */ 20 | void batchSave(@Param("taskList") List taskList); 21 | 22 | /** 23 | * 根据timerId删除taskModel 24 | * 25 | * @param taskId 26 | */ 27 | void deleteById(@Param("taskId") Long taskId); 28 | 29 | /** 30 | * 更新TimerModel 31 | * 32 | * @param taskModel 33 | */ 34 | void update(@Param("taskModel") TaskModel taskModel); 35 | 36 | /** 37 | * 根据taskId查询Task 38 | * 39 | * @param startTime 40 | * @param endTime 41 | * @param taskStatus 42 | * @return TaskModel 43 | */ 44 | List getTasksByTimeRange(@Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("taskStatus") int taskStatus); 45 | 46 | /** 47 | * 根据taskId查询Task 48 | * 49 | * @param timerId 50 | * @param runTimer 51 | * @return TaskModel 52 | */ 53 | TaskModel getTasksByTimerIdUnix(@Param("timerId") Long timerId, @Param("runTimer") Long runTimer); 54 | 55 | } 56 | -------------------------------------------------------------------------------- /bitstorm-svr-demo/src/main/java/cn/bitoffer/improve/model/Example.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve.model; 2 | 3 | 4 | import cn.bitoffer.common.model.BaseModel; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * Example 数据库模型 10 | * 11 | **/ 12 | public class Example extends BaseModel implements Serializable { 13 | /** 14 | * Id 15 | */ 16 | private Long exampleId; 17 | 18 | /** 19 | * Name 20 | */ 21 | private String exampleName; 22 | 23 | /** 24 | * Status 25 | */ 26 | private Integer status; 27 | 28 | public Long getExampleId() { 29 | return exampleId; 30 | } 31 | 32 | public void setExampleId(Long exampleId) { 33 | this.exampleId = exampleId; 34 | } 35 | 36 | public String getExampleName() { 37 | return exampleName; 38 | } 39 | 40 | public void setExampleName(String exampleName) { 41 | this.exampleName = exampleName; 42 | } 43 | 44 | public Integer getStatus() { 45 | return status; 46 | } 47 | 48 | public void setStatus(Integer status) { 49 | this.status = status; 50 | } 51 | 52 | @Override 53 | public String toString() { 54 | return "Example{" + 55 | "exampleId=" + exampleId + 56 | ", exampleName='" + exampleName + '\'' + 57 | ", status=" + status + 58 | ", createTime=" + createTime + 59 | ", modifyTime=" + modifyTime + 60 | '}'; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /bitstorm-svr-leaf/src/main/java/cn/bitoffer/leaf/segment/model/Segment.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.leaf.segment.model; 2 | 3 | import java.util.concurrent.atomic.AtomicLong; 4 | 5 | /** 6 | * @author left 7 | */ 8 | public class Segment { 9 | 10 | private AtomicLong value = new AtomicLong(0); 11 | 12 | private volatile long max; 13 | 14 | private volatile int step; 15 | 16 | private volatile int randomStep; 17 | 18 | private final SegmentBuffer buffer; 19 | 20 | public Segment(SegmentBuffer buffer) { 21 | this.buffer = buffer; 22 | } 23 | 24 | public AtomicLong getValue() { 25 | return value; 26 | } 27 | 28 | public void setValue(AtomicLong value) { 29 | this.value = value; 30 | } 31 | 32 | public long getMax() { 33 | return max; 34 | } 35 | 36 | public void setMax(long max) { 37 | this.max = max; 38 | } 39 | 40 | public int getStep() { 41 | return step; 42 | } 43 | 44 | public void setStep(int step) { 45 | this.step = step; 46 | } 47 | 48 | public SegmentBuffer getBuffer() { 49 | return buffer; 50 | } 51 | 52 | public long getIdle() { 53 | return this.getMax() - getValue().get(); 54 | } 55 | 56 | @Override 57 | public String toString() { 58 | return "Segment(" + "value:" + 59 | value + 60 | ",max:" + 61 | max + 62 | ",step:" + 63 | step + 64 | ")"; 65 | } 66 | 67 | public int getRandomStep() { 68 | return randomStep; 69 | } 70 | 71 | public void setRandomStep(int randomStep) { 72 | this.randomStep = randomStep; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /bitstorm-svr-improve/src/main/java/cn/bitoffer/improve/model/Example.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve.model; 2 | 3 | 4 | import cn.bitoffer.common.model.BaseModel; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * Example 数据库模型 10 | * 11 | **/ 12 | public class Example extends BaseModel implements Serializable { 13 | /** 14 | * Id 15 | */ 16 | private Long exampleId; 17 | 18 | /** 19 | * Name 20 | */ 21 | private String exampleName; 22 | 23 | /** 24 | * Status 25 | */ 26 | private Integer status; 27 | 28 | public Long getExampleId() { 29 | return exampleId; 30 | } 31 | 32 | public void setExampleId(Long exampleId) { 33 | this.exampleId = exampleId; 34 | } 35 | 36 | public String getExampleName() { 37 | return exampleName; 38 | } 39 | 40 | public void setExampleName(String exampleName) { 41 | this.exampleName = exampleName; 42 | } 43 | 44 | public Integer getStatus() { 45 | return status; 46 | } 47 | 48 | public void setStatus(Integer status) { 49 | this.status = status; 50 | } 51 | 52 | @Override 53 | public String toString() { 54 | return "Example{" + 55 | "exampleId=" + exampleId + 56 | ", exampleName='" + exampleName + '\'' + 57 | ", status=" + status + 58 | ", createTime=" + createTime + 59 | ", modifyTime=" + modifyTime + 60 | '}'; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/java/cn/bitoffer/seckill/model/UserQuota.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.seckill.model; 2 | 3 | import cn.bitoffer.seckill.common.BaseModel; 4 | import lombok.Getter; 5 | 6 | import java.io.Serializable; 7 | 8 | public class UserQuota extends BaseModel implements Serializable { 9 | /** 10 | * Id 11 | */ 12 | private Long ID; 13 | 14 | private Integer num; 15 | private Integer killedNum; 16 | private Long userID; 17 | private Long goodsID; 18 | 19 | public Integer getNum() { 20 | return num; 21 | } 22 | 23 | public void setNum(Integer num) { 24 | this.num = num; 25 | } 26 | 27 | public Integer getKilledNum() { 28 | return killedNum; 29 | } 30 | 31 | public void setKilledNum(Integer killedNum) { 32 | this.killedNum = killedNum; 33 | } 34 | 35 | public Long getUserID() { 36 | return userID; 37 | } 38 | 39 | public void setUserID(Long userID) { 40 | this.userID = userID; 41 | } 42 | 43 | public Long getGoodsID() { 44 | return goodsID; 45 | } 46 | 47 | public void setGoodsID(Long goodsID) { 48 | this.goodsID = goodsID; 49 | } 50 | 51 | @Override 52 | public String toString() { 53 | return "UserQuota{" + 54 | "ID=" + ID + 55 | ", num=" + num + 56 | ", killedNum=" + killedNum + 57 | ", userID=" + userID + 58 | ", goodsID=" + goodsID + 59 | '}'; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /bitstorm-svr-demo/src/main/java/cn/bitoffer/improve/kafka/consumer/HelloWorldConsumer.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve.kafka.consumer; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.apache.kafka.clients.consumer.ConsumerRecord; 5 | import org.springframework.kafka.annotation.KafkaListener; 6 | import org.springframework.kafka.support.Acknowledgment; 7 | import org.springframework.kafka.support.KafkaHeaders; 8 | import org.springframework.messaging.handler.annotation.Header; 9 | import org.springframework.stereotype.Component; 10 | 11 | import java.util.Optional; 12 | 13 | /** 14 | * kafka 模版:消费者 15 | **/ 16 | @Component 17 | @Slf4j 18 | public class HelloWorldConsumer { 19 | @KafkaListener(topics = "hello-world", groupId = "TEST_GROUP",concurrency = "1", containerFactory = "kafkaManualAckListenerContainerFactory") 20 | public void topic_test(ConsumerRecord record, Acknowledgment ack, @Header(KafkaHeaders.RECEIVED_TOPIC) String topic) { 21 | Optional message = Optional.ofNullable(record.value()); 22 | if (message.isPresent()) { 23 | Object msg = message.get(); 24 | try { 25 | // 这里写你对接收到的消息的处理逻辑 26 | // 手动ACK 27 | ack.acknowledge(); 28 | log.info("Kafka消费成功! Topic:" + topic + ",Message:" + msg); 29 | } catch (Exception e) { 30 | e.printStackTrace(); 31 | log.error("Kafka消费失败!Topic:" + topic + ",Message:" + msg, e); 32 | } 33 | } 34 | } 35 | 36 | } 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/resources/mapper/SecKillRecordMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | `id`, 19 | `sec_num`, 20 | `user_id`, 21 | `goods_id`, 22 | `order_num`, 23 | `price`, 24 | `status`, 25 | `create_time`, 26 | `modify_time` 27 | 28 | 29 | insert into t_seckill_record (`sec_num`,`user_id`,`goods_id`,`order_num`,`price`, `status`) 30 | values (#{secKillRecord.secNum},#{secKillRecord.userID},#{secKillRecord.goodsID},#{secKillRecord.orderNum},#{secKillRecord.price},#{secKillRecord.status}); 31 | 32 | 33 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/java/cn/bitoffer/seckill/model/PreSecKillRecord.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.seckill.model; 2 | 3 | import cn.bitoffer.seckill.common.BaseModel; 4 | 5 | import java.io.Serializable; 6 | 7 | public class PreSecKillRecord extends BaseModel implements Serializable { 8 | private String secNum; 9 | private Long userID; 10 | private Long goodsID; 11 | private String orderNum; 12 | private Float price; 13 | 14 | private Integer status; 15 | 16 | public String getSecNum() { 17 | return secNum; 18 | } 19 | 20 | public void setSecNum(String secNum) { 21 | this.secNum = secNum; 22 | } 23 | 24 | public Long getUserID() { 25 | return userID; 26 | } 27 | 28 | public void setUserID(Long userID) { 29 | this.userID = userID; 30 | } 31 | 32 | public Long getGoodsID() { 33 | return goodsID; 34 | } 35 | 36 | public void setGoodsID(Long goodsID) { 37 | this.goodsID = goodsID; 38 | } 39 | 40 | public String getOrderNum() { 41 | return orderNum; 42 | } 43 | 44 | public void setOrderNum(String orderNum) { 45 | this.orderNum = orderNum; 46 | } 47 | 48 | public Float getPrice() { 49 | return price; 50 | } 51 | 52 | public void setPrice(Float price) { 53 | this.price = price; 54 | } 55 | 56 | public Integer getStatus() { 57 | return status; 58 | } 59 | 60 | public void setStatus(Integer status) { 61 | this.status = status; 62 | } 63 | 64 | 65 | 66 | } 67 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/resources/mapper/OrderMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | `id`, 20 | `seller`, 21 | `buyer`, 22 | `order_num`, 23 | `goods_id`, 24 | `goods_num`, 25 | `price`, 26 | `status`, 27 | `create_time`, 28 | `modify_time` 29 | 30 | 31 | insert into t_order(`seller`,`buyer`,`order_num`,`goods_id`, `goods_num`,`price`, `status`) 32 | values (#{order.seller},#{order.buyer},#{order.orderNum},#{order.goodsID},#{order.goodsNum},#{order.price},#{order.status}); 33 | 34 | 35 | -------------------------------------------------------------------------------- /bitstorm-svr-seckill/src/main/resources/mapper/GoodsMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | `id`, 18 | `goods_num`, 19 | `goods_name`, 20 | `price`, 21 | `pic_url`, 22 | `seller`, 23 | `create_time`, 24 | `modify_time` 25 | 26 | 27 | insert into t_goods (`goods_name`,`status`) 28 | values (#{goods.goodsName},#{goods.status}); 29 | 30 | 33 | 36 | 37 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/resources/mapper/LotteryTimesMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | `id`, 16 | `user_id`, 17 | `day`, 18 | `num`, 19 | `sys_created`, 20 | `sys_updated`, 21 | 22 | 23 | 26 | 27 | 28 | 29 | insert into t_lottery_times (`user_id`,`day`,`num`,`sys_created`,`sys_updated`) 30 | values (#{lotteryTimes.userId},#{lotteryTimes.day},#{lotteryTimes.num},#{lotteryTimes.sysCreated},#{lotteryTimes.sysUpdated}); 31 | 32 | 33 | 34 | update t_lottery_times set num = num + 1,sys_updated= now() where id = #{lotteryTimes.id}; 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /bitstorm-svr-demo/src/main/java/cn/bitoffer/improve/controller/DemoController.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve.controller; 2 | 3 | import cn.bitoffer.common.model.ResponseEntity; 4 | import cn.bitoffer.improve.redis.RedisExample; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.kafka.core.KafkaTemplate; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | /** 13 | * web服务接口:http 接口 14 | **/ 15 | 16 | @RestController 17 | @RequestMapping("/demo") 18 | @Slf4j 19 | public class DemoController { 20 | 21 | @Autowired 22 | private KafkaTemplate kafkaTemplate; 23 | 24 | @Autowired 25 | private RedisExample redisExample; 26 | 27 | @GetMapping("/hello") 28 | public ResponseEntity helloworld() { 29 | // 消息队列发送消息 30 | return ResponseEntity.ok( 31 | "hello world" 32 | ); 33 | } 34 | 35 | @GetMapping("/kafkaDemo") 36 | public ResponseEntity kafkaTest() { 37 | // 消息队列发送消息 38 | kafkaTemplate.send("hello-world","来自Kafka的测试消息【ABAB】"); 39 | return ResponseEntity.ok( 40 | "发送消息成功" 41 | ); 42 | } 43 | 44 | @GetMapping("/redisLuaDemo") 45 | public ResponseEntity redisTest() { 46 | // 消息队列发送消息 47 | redisExample.luaExample(); 48 | return ResponseEntity.ok( 49 | "成功" 50 | ); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /bitstorm-svr-lottery/src/main/java/cn/bitoffer/lottery/kafka/consumer/HelloWorldConsumer.java: -------------------------------------------------------------------------------- 1 | //package cn.bitoffer.lottery.kafka.consumer; 2 | // 3 | //import lombok.extern.slf4j.Slf4j; 4 | //import org.apache.kafka.clients.consumer.ConsumerRecord; 5 | //import org.springframework.kafka.annotation.KafkaListener; 6 | //import org.springframework.kafka.support.Acknowledgment; 7 | //import org.springframework.kafka.support.KafkaHeaders; 8 | //import org.springframework.messaging.handler.annotation.Header; 9 | //import org.springframework.stereotype.Component; 10 | // 11 | //import java.util.Optional; 12 | // 13 | //@Component 14 | //@Slf4j 15 | ////public class HelloWorldConsumer { 16 | //// @KafkaListener(topics = "hello-world", groupId = "TEST_GROUP",concurrency = "1", containerFactory = "kafkaManualAckListenerContainerFactory") 17 | //// public void topic_test(ConsumerRecord record, Acknowledgment ack, @Header(KafkaHeaders.RECEIVED_TOPIC) String topic) { 18 | //// Optional message = Optional.ofNullable(record.value()); 19 | //// if (message.isPresent()) { 20 | //// Object msg = message.get(); 21 | //// try { 22 | //// // 这里写你对接收到的消息的处理逻辑 23 | //// // 手动ACK 24 | //// ack.acknowledge(); 25 | //// log.info("Kafka消费成功! Topic:" + topic + ",Message:" + msg); 26 | //// } catch (Exception e) { 27 | //// e.printStackTrace(); 28 | //// log.error("Kafka消费失败!Topic:" + topic + ",Message:" + msg, e); 29 | //// } 30 | //// } 31 | //// } 32 | //// 33 | ////} 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /bitstorm-svr-auth/src/main/java/cn/bitoffer/auth/model/LoginUser.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.auth.model; 2 | 3 | import org.springframework.security.core.GrantedAuthority; 4 | import org.springframework.security.core.userdetails.UserDetails; 5 | 6 | import java.util.Collection; 7 | 8 | public class LoginUser implements UserDetails { 9 | 10 | private String username; 11 | private String password; 12 | 13 | private String userId; 14 | 15 | public LoginUser(UserCredential userCredential) { 16 | this.username = userCredential.getUsername(); 17 | this.password = userCredential.getPassword(); 18 | this.userId = userCredential.getUserId(); 19 | } 20 | 21 | @Override 22 | public Collection getAuthorities() { 23 | return null; 24 | } 25 | 26 | @Override 27 | public String getPassword() { 28 | return password; 29 | } 30 | 31 | @Override 32 | public String getUsername() { 33 | return username; 34 | } 35 | 36 | @Override 37 | public boolean isAccountNonExpired() { 38 | return true; 39 | } 40 | 41 | @Override 42 | public boolean isAccountNonLocked() { 43 | return true; 44 | } 45 | 46 | @Override 47 | public boolean isCredentialsNonExpired() { 48 | return true; 49 | } 50 | 51 | @Override 52 | public boolean isEnabled() { 53 | return true; 54 | } 55 | 56 | public String getUserId() { 57 | return userId; 58 | } 59 | 60 | public void setUserId(String userId) { 61 | this.userId = userId; 62 | } 63 | } 64 | 65 | -------------------------------------------------------------------------------- /bitstorm-svr-demo/src/main/java/cn/bitoffer/improve/service/impl/ExampleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve.service.impl; 2 | 3 | import cn.bitoffer.common.redis.RedisBase; 4 | import cn.bitoffer.improve.mapper.ExampleMapper; 5 | import cn.bitoffer.improve.model.Example; 6 | import cn.bitoffer.improve.service.ExampleService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | 10 | @Service 11 | public class ExampleServiceImpl implements ExampleService { 12 | 13 | @Autowired 14 | private ExampleMapper exampleMapper; 15 | 16 | @Autowired 17 | private RedisBase redisBase; 18 | 19 | 20 | 21 | @Override 22 | public void save(Example example) { 23 | exampleMapper.save(example); 24 | } 25 | 26 | @Override 27 | public void update(Example example) { 28 | exampleMapper.update(example); 29 | } 30 | 31 | @Override 32 | public Example getExampleById(Long id) { 33 | return exampleMapper.getExampleById(id); 34 | } 35 | 36 | @Override 37 | public void deleteExampleById(Long id) { 38 | 39 | exampleMapper.deleteById(id); 40 | } 41 | 42 | @Override 43 | public void cacheExampleToRedis(Example example) { 44 | redisBase.set(example.getExampleId().toString(),example); 45 | } 46 | 47 | @Override 48 | public Example getExampleFromRedis(String exampleId) { 49 | Object obj = redisBase.get(exampleId); 50 | Example example = null; 51 | if (obj != null){ 52 | example = (Example) obj; 53 | } 54 | return example; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /bitstorm-svr-demo/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | 2 | server: 3 | port: 8081 4 | spring: 5 | application: 6 | name: @artifactId@ 7 | cloud: 8 | nacos: 9 | discovery: 10 | server-addr: 127.0.0.1:8848 11 | username: nacos 12 | password: nacos 13 | datasource: 14 | driver-class-name: com.mysql.cj.jdbc.Driver 15 | url: jdbc:mysql://127.0.0.1:3306/bitstorm-svr?serverTimezone=GMT%2B8&characterEncoding=utf8&useSSL=false 16 | username: root 17 | password: root@2023 18 | redis: 19 | host: localhost 20 | port: 6379 21 | password: root2023 22 | database: 0 23 | jedis: 24 | pool: 25 | max-active: 8 #最大连接数 26 | kafka: 27 | #以逗号分隔的主机:端口对列表,用于建立与Kafka的连接 28 | bootstrap-servers: 127.0.0.1:9092 29 | producer: 30 | # 发生错误后,消息重发的次数。 31 | retries: 0 32 | #当有多个消息需要被发送到同一个分区时,生产者会把它们放在同一个批次里。该参数指定了一个批次可以使用的内存大小,按照字节数计算。 33 | batch-size: 16384 34 | # 设置生产者内存缓冲区的大小。 35 | buffer-memory: 33554432 36 | # 键的序列化方式 37 | key-serializer: org.apache.kafka.common.serialization.StringSerializer 38 | # 值的序列化方式 39 | value-serializer: org.apache.kafka.common.serialization.StringSerializer 40 | acks: 1 41 | consumer: 42 | # 键的反序列化方式 43 | key-deserializer: org.apache.kafka.common.serialization.StringDeserializer 44 | # 值的反序列化方式 45 | value-deserializer: org.apache.kafka.common.serialization.StringDeserializer 46 | 47 | mybatis: 48 | mapper-locations: classpath:mapper/*.xml 49 | #开启驼峰命名 50 | configuration: 51 | map-underscore-to-camel-case: false 52 | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl 53 | -------------------------------------------------------------------------------- /db/bitstorm-svr-demo.sql: -------------------------------------------------------------------------------- 1 | /* 2 | SQLyog Ultimate v13.1.1 (64 bit) 3 | MySQL - 8.0.25 : Database - mall4cloud_order 4 | ********************************************************************* 5 | */ 6 | 7 | /*!40101 SET NAMES utf8 */; 8 | 9 | /*!40101 SET SQL_MODE=''*/; 10 | 11 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 12 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 13 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 14 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 15 | CREATE DATABASE /*!32312 IF NOT EXISTS*/`bitstorm-svr` /*!40100 DEFAULT CHARACTER SET utf8 */ /*!80016 DEFAULT ENCRYPTION='N' */; 16 | 17 | USE `bitstorm-svr`; 18 | 19 | /*Table structure for table `example` */ 20 | 21 | DROP TABLE IF EXISTS `example`; 22 | 23 | CREATE TABLE `example` ( 24 | `example_id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'ExampleID', 25 | `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 26 | `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', 27 | `example_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'Example名称', 28 | `status` tinyint NOT NULL DEFAULT '0' COMMENT '订单状态 1:待付款 2:待发货 3:待收货(已发货) 5:成功 6:失败', 29 | PRIMARY KEY (`example_id`) USING BTREE, 30 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='订单信息'; 31 | 32 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 33 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 34 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 35 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 36 | -------------------------------------------------------------------------------- /bitstorm-svr-demo/src/main/java/cn/bitoffer/improve/feign/DemoFeignController.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.improve.feign; 2 | 3 | import cn.bitoffer.api.feign.DemoClient; 4 | import cn.bitoffer.improve.model.Example; 5 | import cn.bitoffer.improve.service.ExampleService; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | /** 11 | * 微服接口模版 12 | * DemoClient 为对外提供的微服务接口 13 | * ProviderFeignController 为该接口的实现 14 | **/ 15 | @RestController 16 | @Slf4j 17 | public class DemoFeignController implements DemoClient { 18 | 19 | @Autowired 20 | private ExampleService exampleService; 21 | public String call(String name) { 22 | 23 | Example example = new Example(); 24 | example.setExampleName("测试样例 AAA"); 25 | example.setStatus(1); 26 | exampleService.save(example); 27 | System.out.println(exampleService.getExampleById(example.getExampleId())); 28 | example.setExampleName("测试样例 BBB"); 29 | exampleService.update(example); 30 | System.out.println(exampleService.getExampleById(example.getExampleId())); 31 | exampleService.deleteExampleById(example.getExampleId()); 32 | System.out.println(exampleService.getExampleById(example.getExampleId())); 33 | 34 | //redis 35 | exampleService.cacheExampleToRedis(example); 36 | Example example1 = exampleService.getExampleFromRedis(example.getExampleId().toString()); 37 | 38 | //redis lua 39 | 40 | 41 | System.out.println(example1); 42 | 43 | return "我是服务提供者demo,hello: " + name; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /bitstorm-svr-common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | bitoffer.cn 8 | bitstorm-svr 9 | 0.0.1-SNAPSHOT 10 | ../pom.xml 11 | 12 | 13 | bitstorm-svr-common 14 | 15 | 16 | 17 | org.springframework.boot 18 | spring-boot-starter-data-redis 19 | 20 | 21 | 22 | bitoffer.cn 23 | bitstorm-svr-api 24 | ${project.version} 25 | 26 | 27 | 28 | com.alibaba 29 | fastjson 30 | 31 | 32 | 33 | io.jsonwebtoken 34 | jjwt 35 | 36 | 37 | org.apache.commons 38 | commons-lang3 39 | 40 | 41 | org.projectlombok 42 | lombok 43 | 44 | 45 | -------------------------------------------------------------------------------- /bitstorm-svr-shorturlx/src/main/java/cn/bitoffer/shorturlx/feign/ShortUrlXFeignController.java: -------------------------------------------------------------------------------- 1 | package cn.bitoffer.shorturlx.feign; 2 | 3 | import cn.bitoffer.api.feign.DemoClient; 4 | import cn.bitoffer.shorturlx.service.ShortUrlXService; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | @RestController 10 | @Slf4j 11 | public class ShortUrlXFeignController implements DemoClient { 12 | 13 | @Autowired 14 | private ShortUrlXService shortUrlXService; 15 | public String call(String longUrl) { 16 | return shortUrlXService.createV3ShortUrl(longUrl); 17 | } 18 | 19 | // public String call(String name) { 20 | // 21 | // UrlMap urlMap = new UrlMap(longUrl); 22 | // urlMap.setExampleName("测试样例 AAA"); 23 | // urlMap.setStatus(1); 24 | // shortUrlXService.save(urlMap); 25 | // System.out.println(shortUrlXService.getExampleById(urlMap.getExampleId())); 26 | // urlMap.setExampleName("测试样例 BBB"); 27 | // shortUrlXService.update(urlMap); 28 | // System.out.println(shortUrlXService.getExampleById(urlMap.getExampleId())); 29 | // shortUrlXService.deleteExampleById(urlMap.getExampleId()); 30 | // System.out.println(shortUrlXService.getExampleById(urlMap.getExampleId())); 31 | // 32 | // //redis 33 | // shortUrlXService.cacheExampleToRedis(urlMap); 34 | // UrlMap urlMap1 = shortUrlXService.getExampleFromRedis(urlMap.getExampleId().toString()); 35 | // System.out.println(urlMap1); 36 | // 37 | // return "服务提供者1:" + name; 38 | // } 39 | } 40 | --------------------------------------------------------------------------------