Compare commits

...

16 Commits

Author SHA1 Message Date
3d8168c726 fix CI create release
All checks were successful
CI/CD / build-deploy (pull_request) Successful in 19s
2026-01-19 17:22:02 +08:00
381d149cd2 fix CI nexus fail
Some checks failed
CI/CD / build-deploy (pull_request) Failing after 30s
2026-01-19 17:13:40 +08:00
3b572491d0 fix CI build jdk
Some checks failed
CI/CD / build-deploy (pull_request) Failing after 1m2s
2026-01-19 17:08:27 +08:00
452d525d83 add CI Checkout code
Some checks failed
CI/CD / build-deploy (pull_request) Failing after 1m41s
2026-01-19 17:02:45 +08:00
8153df0b90 remove CI upload-artifact
Some checks failed
CI/CD / build-deploy (pull_request) Failing after 1s
2026-01-19 16:58:38 +08:00
af349ca4d6 fix package build fail
Some checks failed
CI/CD / build-deploy (pull_request) Failing after 1s
CI/CD / create-release (pull_request) Has been skipped
2026-01-19 14:42:52 +08:00
4b4dcc00b8 add CI workflow
Some checks failed
CI/CD / build-deploy (pull_request) Failing after 5m7s
CI/CD / create-release (pull_request) Has been skipped
2026-01-19 14:27:33 +08:00
46f79f8b6b add isEmpty and isNotEmpty 2025-12-25 18:25:24 +08:00
2a948a3c59 update defaultIf* call 2025-12-22 10:51:16 +08:00
534f8eef81 keep firstNotNull and not firstNotEmpty 2025-12-22 10:49:41 +08:00
77c53b422e rename firstNotNull to defaultIfNull 2025-12-22 10:47:12 +08:00
50c9a416a6 add safeIterable 2025-12-12 15:36:08 +08:00
90366671d1 upper timi-spring language bean here 2025-12-08 16:54:12 +08:00
f1aede1100 allow long page size 2025-12-08 16:36:41 +08:00
8de5f416f8 add TimiJava.ZERO_UUID 2025-12-02 14:55:58 +08:00
bde63864b1 remove BasePage.keyword 2025-12-02 14:55:44 +08:00
7 changed files with 273 additions and 67 deletions

111
.gitea/workflows/ci.yml Normal file
View File

@ -0,0 +1,111 @@
name: CI/CD
on:
pull_request:
branches:
- master
types:
- closed
jobs:
build-deploy:
runs-on: act_runner_java
if: ${{ github.event.pull_request.merged == true }}
env:
JAVA_HOME: /usr/lib/jvm/java-21-openjdk
steps:
- name: Checkout code
run: |
git clone ${{ github.server_url }}/${{ github.repository }}.git .
git checkout ${{ github.sha }}
- name: Set up environment
run: |
echo "PR #${{ github.event.number }} merged into master"
echo "Source branch: ${{ github.event.pull_request.head.ref }}"
echo "Target branch: ${{ github.event.pull_request.base.ref }}"
- name: Run tests
run: |
echo "Running test suite..."
- name: Build project
run: |
mvn -B -DskipTests clean package source:jar javadoc:jar
- name: Deploy to Nexus
if: success()
run: |
if [ -z "${{ secrets.NEXUS_USERNAME }}" ] || [ -z "${{ secrets.NEXUS_PASSWORD }}" ]; then
echo "Missing secrets.NEXUS_USERNAME or secrets.NEXUS_PASSWORD"
exit 1
fi
mkdir -p ~/.m2
cat > ~/.m2/settings.xml <<EOF
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>timi-nexus</id>
<username>${{ secrets.NEXUS_USERNAME }}</username>
<password>${{ secrets.NEXUS_PASSWORD }}</password>
</server>
</servers>
</settings>
EOF
version=$(mvn -q -DforceStdout help:evaluate -Dexpression=project.version)
artifact_id=$(mvn -q -DforceStdout help:evaluate -Dexpression=project.artifactId)
main_jar="target/${artifact_id}-${version}.jar"
sources_jar="target/${artifact_id}-${version}-sources.jar"
javadoc_jar="target/${artifact_id}-${version}-javadoc.jar"
if [ ! -f "$main_jar" ] || [ ! -f "$sources_jar" ] || [ ! -f "$javadoc_jar" ]; then
echo "Missing build artifacts in target"
exit 1
fi
mvn -B deploy:deploy-file \
-Dfile="$main_jar" \
-Dsources="$sources_jar" \
-Djavadoc="$javadoc_jar" \
-DpomFile="./pom.xml" \
-Durl="https://nexus.imyeyu.com/repository/maven-releases/" \
-DrepositoryId="timi-nexus" \
-Dhttps.protocols=TLSv1.2 \
-Djdk.tls.client.protocols=TLSv1.2
- name: Create release
if: ${{ success() && startsWith(github.event.pull_request.title, 'v') }}
env:
GITEA_TOKEN: ${{ secrets.RUNNER_TOKEN }}
GITEA_SERVER_URL: ${{ github.server_url }}
GITEA_REPOSITORY: ${{ github.repository }}
RELEASE_TAG: ${{ github.event.pull_request.title }}
RELEASE_TARGET: ${{ github.sha }}
run: |
if [ -z "$GITEA_TOKEN" ]; then
echo "Missing secrets.RUNNER_TOKEN"
exit 1
fi
api_url="$GITEA_SERVER_URL/api/v1/repos/$GITEA_REPOSITORY/releases"
payload=$(cat <<EOF
{
"tag_name": "$RELEASE_TAG",
"name": "$RELEASE_TAG",
"target_commitish": "$RELEASE_TARGET",
"draft": false,
"prerelease": false
}
EOF
)
response=$(curl -sS -X POST "$api_url" \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \
-d "$payload")
release_id=$(echo "$response" | grep -o '"id":[0-9]*' | head -n 1 | grep -o '[0-9]*')
if [ -z "$release_id" ] || echo "$response" | grep -q '"message"'; then
echo "Create release failed: $response"
exit 1
fi
echo "Release created: id=$release_id"
for asset_path in target/*.jar; do
asset_name=$(basename "$asset_path")
curl -sS -X POST "$api_url/$release_id/assets?name=$asset_name" \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @"$asset_path"
done

4
.gitignore vendored
View File

@ -1,3 +1,7 @@
/.claude
/AGENTS.md
/CLAUDE.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/

18
pom.xml
View File

@ -27,29 +27,11 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.11.2</version>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -3,6 +3,7 @@ package com.imyeyu.java;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
/**
@ -12,6 +13,8 @@ import java.util.Map;
*/
public interface TimiJava {
String ZERO_UUID = "00000000-0000-0000-0000-000000000000";
/**
* 通用判空
* <pre>
@ -66,6 +69,14 @@ public interface TimiJava {
return !isEmpty(object);
}
static <T> T defaultIfNull(T obj, T defaultObj) {
return firstNotNull(obj, defaultObj);
}
static <T> T defaultIfEmpty(T obj, T defaultObj) {
return firstNotEmpty(obj, defaultObj);
}
@SafeVarargs
static <T> T firstNotNull(T... objects) {
for (int i = 0; i < objects.length; i++) {
@ -92,4 +103,8 @@ public interface TimiJava {
e.printStackTrace(pw);
return sw.toString();
}
static <T> Iterable<T> safeIterable(Iterable<T> iterable) {
return defaultIfNull(iterable, Collections::emptyIterator);
}
}

View File

@ -10,15 +10,12 @@ public class BasePage {
protected int index = 0;
/** 数据量 */
protected int size = 16;
/** 关键字 */
protected String keyword;
protected long size = 16;
public BasePage() {
}
public BasePage(int index, int size) {
public BasePage(int index, long size) {
this.index = index;
this.size = size;
}
@ -39,19 +36,11 @@ public class BasePage {
this.index = index;
}
public int getSize() {
public long getSize() {
return size;
}
public void setSize(int size) {
public void setSize(long size) {
this.size = size;
}
public String getKeyword() {
return keyword;
}
public void setKeyword(String keyword) {
this.keyword = keyword;
}
}

View File

@ -18,6 +18,24 @@ public class BasePageResult<T> {
protected List<T> list;
/**
* 结果是否为空
*
* @return true 为空
*/
public boolean isEmpty() {
return list.isEmpty();
}
/**
* 结果是否非空
*
* @return true 为非空
*/
public boolean isNotEmpty() {
return !isEmpty();
}
/**
* 获取总数据量
*

View File

@ -1,47 +1,134 @@
package com.imyeyu.java.bean;
import com.imyeyu.java.ref.Ref;
/**
* 多语言
*
* @author 夜雨
* @since 2022-02-23 11:25
*/
public enum Language {
/** 英语 */
en_US("English"),
/** 简中 */
zh_CN("简体中文"),
/** 繁中 */
zh_TW("繁体中文"),
/** 日语 */
ja_JP("日本語"),
/** 韩语 */
ko_KR("한국인"),
/** 俄语 */
ru_RU("русский"),
/** 德语 */
de_DE("Deutsch");
/** 名称 */
final String name;
Language(String name) {
this.name = name;
}
public class Language {
/**
* 获取语言名称
*
* @return 语言名称
* @author 夜雨
* @since 2025-12-05 14:31
*/
public String getName() {
return name;
public enum Enum {
/** 英语 */
en_US,
/** 简中 */
zh_CN,
/** 繁中 */
zh_TW,
/** 日语 */
ja_JP,
/** 韩语 */
ko_KR,
/** 俄语 */
ru_RU,
/** 德语 */
de_DE;
}
protected String key;
protected String zhCN;
protected String zhTW;
protected String enUS;
protected String ruRU;
protected String koKR;
protected String jaJP;
protected String deDE;
/**
* 获取指定语言值
*
* @param language 指定语言
* @return 值
*/
public String getValue(Enum language) {
try {
return Ref.getFieldValue(this, language.toString().replace("_", ""), String.class);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getZhCN() {
return zhCN;
}
public void setZhCN(String zhCN) {
this.zhCN = zhCN;
}
public String getZhTW() {
return zhTW;
}
public void setZhTW(String zhTW) {
this.zhTW = zhTW;
}
public String getEnUS() {
return enUS;
}
public void setEnUS(String enUS) {
this.enUS = enUS;
}
public String getRuRU() {
return ruRU;
}
public void setRuRU(String ruRU) {
this.ruRU = ruRU;
}
public String getKoKR() {
return koKR;
}
public void setKoKR(String koKR) {
this.koKR = koKR;
}
public String getJaJP() {
return jaJP;
}
public void setJaJP(String jaJP) {
this.jaJP = jaJP;
}
public String getDeDE() {
return deDE;
}
public void setDeDE(String deDE) {
this.deDE = deDE;
}
}