Skip to content

Commit

Permalink
Merge pull request #9 from eiriksgata/open-shamrock
Browse files Browse the repository at this point in the history
Open shamrock
  • Loading branch information
eiriksgata authored Jan 30, 2024
2 parents 13127f7 + 53b237f commit 2d32cb1
Show file tree
Hide file tree
Showing 160 changed files with 7,817 additions and 728 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/docker-image-uat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Docker Image CI/CD

on:
push:
paths-ignore: # 忽略一些不必要的文件
- ".gitignore"
- "README.md"
- ".vscode/**"
branches: [ "main" ]

#tags: # 当我们提交代码为tag 是以'v'开头的时候才会触发自动部署到服务端
# - 'v*'

jobs:
docker-image-build-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '11'
cache: 'maven'
cache-dependency-path: 'pom.xml' # optional

- uses: docker/login-action@v1
with:
registry: ghcr.io # 声明镜像源
username: ${{ github.actor }}
password: ${{ secrets.HUB_GITHUB_ACCESS_TOKEN }}

- uses: docker/login-action@v1
with:
registry: ${{ secrets.TC_DOCKER_HUB_ADDRESS }} # 声明镜像源
username: ${{ secrets.TC_DOCKER_HUB_USERNAME }}
password: ${{ secrets.TC_DOCKER_HUB_PASSWORD }}
- name: Build with Maven
run: mvn -B package --file pom.xml

- name: Build docker image
run:
docker buildx build --file Dockerfile --tag rulateday-api-server-uat:latest .

- name: create ghcr tag
run: docker image tag rulateday-api-server-uat:latest ghcr.io/rulateday/rulateday-api-server-uat:latest

- name: ghcr.io push image
run: docker push ghcr.io/rulateday/rulateday-api-server-uat:latest

- name: create tencent docker hub tag
run: docker image tag rulateday-api-server-uat:latest ${{ secrets.TC_DOCKER_HUB_ADDRESS }}/rulateday/rulateday-api-server-uat:latest

- name: tencent push image
run: docker push ${{ secrets.TC_DOCKER_HUB_ADDRESS }}/rulateday/rulateday-api-server-uat:latest





3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ build/
.vscode/
/application-config.yaml
import
resources
resources
config
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
## Rulateday-api
## Rulateday-api

**本项目是为mirai-rulateday-dice项目提供云端服务的API**
前端的开源项目为 rulateday-api-vue-client


### 主要用途

1. 提供一个用户提交数据的平台服务。
2. 用于收集机器人抛出的特殊异常错误。
3. 用于处理收录消息情况。
4. API平台上的查询数据会更为强大,其中DND5e将会加入更多的拓展包内容查询。
5. 作为指令逻辑业务处理平台。
6. 根据RBAC设计,控制访问权限
7. 一些工具集成(FF14的幻卡模拟器等)。

**拓展内容:**

- [ ] 更多的法术列表
- [ ] 拓展职业
- [ ] 拓展魔法物品
Expand All @@ -20,7 +24,8 @@
- [ ] 一些module物品

### 技术
- SpringBoot 2.x - derivation(web|....)

- SpringBoot 2.x - derivation(Web|Security|Other....)
- jdk8 (因为Heroku机器java version为1.8)
- SQLite + Mybatis plus | other..

Binary file modified data/rulateday-api.db
Binary file not shown.
14 changes: 8 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@


<dependencies>

<dependency>
<groupId>com.github.eiriksgata</groupId>
<artifactId>trpg-java-dice-spring</artifactId>
<version>1.6.1</version>
</dependency>


<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
Expand Down Expand Up @@ -197,12 +205,6 @@
<version>0.4</version>
</dependency>

<dependency>
<groupId>com.github.eiriksgata</groupId>
<artifactId>trpg-java-dice</artifactId>
<version>1.4.1</version>
</dependency>

<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
package com.github.eiriksgata.rulateday.platform;

import com.github.eiriksgata.rulateday.platform.dice.init.LoadDatabaseFile;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@MapperScan(basePackages = "com.github.eiriksgata.rulateday.platform.mapper")
@MapperScan(basePackages = {"com.github.eiriksgata.rulateday.platform.mapper"})
@ComponentScan(basePackages = {
"com.github.eiriksgata.rulateday.platform",
"com.github.eiriksgata.rulateday.platform.dice",
"com.github.eiriksgata.rulateday.platform.dice.service",
"com.github.eiriksgata.rulateday.platform.dice.instruction",
})
public class RulatedayApiApplication {

public static void main(String[] args) {
SpringApplication.run(RulatedayApiApplication.class, args);
}
public static void main(String[] args) {
LoadDatabaseFile.init();
SpringApplication.run(RulatedayApiApplication.class, args);
}

}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import com.github.eiriksgata.rulateday.platform.misc.IgnoreAuthentication;
import com.github.eiriksgata.rulateday.platform.provider.JwtProvider;
import com.github.eiriksgata.rulateday.platform.service.AuthService;
import com.github.eiriksgata.rulateday.platform.service.RobotTokenService;
import com.github.eiriksgata.rulateday.platform.pojo.RobotToken;
import com.github.eiriksgata.rulateday.platform.service.RobotService;
import com.github.eiriksgata.rulateday.platform.utils.VerifyImageUtil;
import com.github.eiriksgata.rulateday.platform.vo.AccessToken;
import com.github.eiriksgata.rulateday.platform.vo.ResponseBean;
import com.github.eiriksgata.rulateday.platform.vo.SliderCaptchaVerifyVo;
import com.github.eiriksgata.rulateday.platform.vo.UserPasswordResetVo;
import com.github.eiriksgata.rulateday.platform.vo.openapi.GenCaptchaVo;
import io.swagger.annotations.Api;
import org.jetbrains.annotations.NotNull;
Expand All @@ -33,9 +33,6 @@ public class AuthController {
@Autowired
AuthService authService;

@Autowired
RobotTokenService robotTokenService;

@Autowired
CaptchaCache captchaCache;

Expand All @@ -45,6 +42,9 @@ public class AuthController {
@Autowired
JwtProvider jwtProvider;

@Autowired
RobotService robotService;

@PutMapping("/authentication/captcha/slider")
@IgnoreAuthentication
public ResponseBean<AccessToken> authenticationBySliderCaptcha(@NotNull HttpServletRequest httpServletRequest, @NotNull HttpServletResponse response) {
Expand All @@ -69,6 +69,7 @@ public ResponseBean<AccessToken> refreshToken(@RequestBody AccessToken accessTok

@GetMapping("/logout")
public ResponseBean<?> logout() {
authService.logout();
return ResponseBean.success();
}

Expand Down Expand Up @@ -120,22 +121,10 @@ public ResponseBean<?> generateSliderCaptcha(@PathVariable("username") String us
}
}

@PutMapping("/robot/token")
public ResponseBean<?> robotTokenGen(@RequestBody RobotToken robotToken) {
robotTokenService.saveRobotToken(robotToken.getMachineCode(), robotToken.getExpirationAt(), robotToken.getDescription());
return ResponseBean.success();
}

@DeleteMapping("/robot/token/delete")
public ResponseBean<?> robotTokenDelete(@RequestBody RobotToken robotToken) {
robotTokenService.deleteRobotToken(robotToken.getId());
@PutMapping("/user/password/reset")
public ResponseBean<?> accessPasswordReset(@RequestBody UserPasswordResetVo passwordResetVo) {
authService.userPasswordReset(passwordResetVo);
return ResponseBean.success();
}

@GetMapping("/robot/token/list")
public ResponseBean<?> getRobotTokenList() {
return ResponseBean.success(robotTokenService.selectAllRobotToken());
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -229,33 +229,5 @@ public ResponseBean<?> bookTestImportDnd5e() {
return ResponseBean.success();
}

@PutMapping("/book/test/import/coc7")
public ResponseBean<?> bookTestImportCoc7() {
List<RuleBook> list = ruleBookMapper.selectAll();
for (RuleBook ruleBook : list) {
BookChapter bookChapter = new BookChapter();
bookChapter.setBookId(1);
bookChapter.setStatus("1");
bookChapter.setTitle(ruleBook.getTitle());
bookChapter.setChapter(ruleBook.getContent());
bookService.saveBookChapter(bookChapter);
}
return ResponseBean.success();
}

@PutMapping("/book/test/import/infinite")
public ResponseBean<?> bookTestImportInfinite() {
List<QueryDataBase> list = infiniteLibLuMapper.selectAll();
for (QueryDataBase queryDataBase : list) {
BookChapter bookChapter = new BookChapter();
bookChapter.setBookId(3);
bookChapter.setStatus("1");
bookChapter.setTitle(queryDataBase.getName());
bookChapter.setChapter(queryDataBase.getDescribe());
bookService.saveBookChapter(bookChapter);
}
return ResponseBean.success();
}


}
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package com.github.eiriksgata.rulateday.platform.controller;

import com.github.eiriksgata.rulateday.platform.dice.dto.DiceMessageDTO;
import com.github.eiriksgata.rulateday.platform.dice.instruction.QueryInstruct;
import com.github.eiriksgata.rulateday.platform.mapper.Dnd5ePhbDataMapper;
import com.github.eiriksgata.rulateday.platform.utils.SpringContextUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.eiriksgata.rulateday.platform.vo.PageHelperBean;
import com.github.eiriksgata.rulateday.platform.vo.ResponseBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.*;

/**
* author: create by Keith
Expand All @@ -25,12 +27,23 @@ public class QueryController {
@Autowired
Dnd5ePhbDataMapper dnd5ePhbDataMapper;

@Autowired
ApplicationContext applicationContext;

@PostMapping("/dnd5e/spell")
@ApiOperation(value = "dnd5e法术列表", httpMethod = "POST")
public ResponseBean<PageInfo<?>> dnd5eLibQuery(@RequestBody PageHelperBean<String> data) {
PageHelper.startPage(data.getPageNumber(), data.getPageSize());
return ResponseBean.success(new PageInfo<>(dnd5ePhbDataMapper.selectAllSkillPhb()));
}

@GetMapping("/test/ti/{class}")
public ResponseBean<?> testTi(@PathVariable("class")String name) {
QueryInstruct queryInstruct = applicationContext.getBean( QueryInstruct.class);
return ResponseBean.success(
queryInstruct.getCrazyState(new DiceMessageDTO())
);
}


}
Loading

0 comments on commit 2d32cb1

Please sign in to comment.