Skip to content

Commit

Permalink
add backend
Browse files Browse the repository at this point in the history
  • Loading branch information
kala888 committed Mar 18, 2024
1 parent 65bbd9e commit 70bbdb0
Show file tree
Hide file tree
Showing 760 changed files with 80,204 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tixwork-service/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# http://editorconfig.org
root = true

# 空格替代Tab缩进在各种编辑工具下效果一致
[*]
max_line_length = 120
indent_style = space
indent_size = 4
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true

[*.{json,yml}]
indent_size = 2

[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
46 changes: 46 additions & 0 deletions tixwork-service/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
######################################################################
# Build Tools
out/
bin/

.gradle
build/
!gradle/wrapper/gradle-wrapper.jar

target/
!.mvn/wrapper/maven-wrapper.jar

######################################################################
# IDE

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
nbproject/private/
build/*
nbbuild/
dist/
nbdist/
.nb-gradle/

######################################################################
# Others
*.log
*.xml.versionsBackup
*.swp

!*/build/*.java
!*/build/*.html
!*/build/*.xml
20 changes: 20 additions & 0 deletions tixwork-service/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2021 Tixwork

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
51 changes: 51 additions & 0 deletions tixwork-service/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
已经更新到

```
ruoyi-vue-plus: 301111fffde654b6151a27dc35657890364400b9
2023年8月21日 GMT+8 14:08:12
```

开发环境默认开启,可以使用apifox或者postman导入:

openApi docs:http://localhost:8080/api/v3/api-docs

注意gradle: implementation不具有依赖传递性, api传递模块依赖

##### Tip1 打生产的包

如果不指定 -Pprod怎打的是开发的包。

gradle 会在打包时,替换application中的 #spring.profiles.active#

```shell
gradle -Pprod bJ
```

##### Tip2 JVM 参数 和启动

``` shell
export JAVA_OPTS= '-Xms2G -Xmx4G -XX:MetaspaceSize=512m -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:ParallelGCThreads=4 -XX:ConcGCThreads=2 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./log/ -XX:InitiatingHeapOccupancyPercent=70 -XX:ErrorFile=./log/error.log -Dfile.encoding=UTF-8 -Duser.timezone=Asia/Shanghai'
nohup java ${JAVA_OPTS} -jar /app/app.jar &
```

##### Tip3 启动并调试端口:5005

```shell
gradle bR --debug-jvm
```

```javascript
//tips:
// tixwork-service 重构后,大部分代码来自[RuoYi-Vue-Plus v5.X](https://gitee.com/dromara/RuoYi-Vue-Plus) ,感谢 疯狂的狮子Li, 感谢若依。
// 如果您通过后台获得了帮助,开源不易,请去打赏《疯狂的狮子Li》
```


#### 非api module,获取自身模块中的文件的三种方式:
```java
InputStream stream = cn.hutool.core.io.resource.ResourceUtil.getStreamSafe(file);
Resource resource = resourceLoader.getResource("classpath:" + file);
InputStream stream = this.getClass().getClassLoader().getResourceAsStream(file);

```
75 changes: 75 additions & 0 deletions tixwork-service/biz-models/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#代码生成部分, 不要改动和编辑
#代码生成部分, 不要改动和编辑
#代码生成部分, 不要改动和编辑

### 1. Controller 如何覆盖

Controller 生成的时候,会添加ConditionalOnMissingBean。同时也可以在生成时设置disableController来禁用生成类。

例如:
```java
// 自动生成代码
@RestController
@RequestMapping("/hello")
@ConditionalOnMissingBean(name = "TestController")
public class TestController {
@GetMapping("/hello")
public String hello() {
return "hello";
}
}
```

通过新增CustomizedTestController。可以实现复写"/hello"和新增"/hello2"

```java
@RestController("TestController")
public class CustomizedTestController extends TestController {
@Override
public WebResult hello() {
return "customized hello";
}
@GetMapping("/hello2")
public WebResult hello2() {
return "hello";
}
}
```

tips:

1. 无需@Primary
2. 如果自定义的类想要实现类似方案,记得把权限控制拷到子类中,例如@SaIgnore
3. 子类可以复写类上的uri:例如 @RequestMapping("/hello") 修改为 @RequestMapping("/hello-test")
4. 子类中方法覆盖时,可以复写uri:例如 @GetMapping("/hello") 修改为 @PostMapping("/hello")


### 2. Service 如何覆盖

Service 生成的时候只是普通的Bean。通过在子类中添加@Primary来覆盖bean。同时也可以在生成时设置disableService来禁用生成类。

例如:
```java
// 自动生成代码
@Service
public class HelloService {

public void hello() {
Console.log("say hello");
}
}
```

通过新增CustomizedHelloService。可以实现复写"hello"

```java
@Service
@Primary
public class CustomizedHelloService extends HelloService {

@Override
public void hello() {
Console.log("say hello in Customized HelloService");
}
}
```
5 changes: 5 additions & 0 deletions tixwork-service/biz-models/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dependencies {
implementation project(":tixwork-core")
implementation project(":tixwork-system")
api project(":tixwork-db-runner")
}
92 changes: 92 additions & 0 deletions tixwork-service/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
buildscript {
repositories {
mavenLocal()
maven {
url "https://mirrors.huaweicloud.com/repository/maven/"
}
maven {
url 'https://maven.aliyun.com/repository/public/'
}
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}

allprojects {
group 'com.tiandtech'
version '0.0.2'

repositories {
mavenLocal()
maven { url "https://mirrors.huaweicloud.com/repository/maven/" }
mavenCentral()
}
}

subprojects {
apply plugin: "io.spring.dependency-management"
apply plugin: "org.springframework.boot"
apply plugin: "java"
apply plugin: "java-library"


jar {
enabled = true
}

springBoot {
buildInfo()
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

// gradle -Pprod bR 启动prod
// gradle -Pprod bJ 用prod 替换application中的 #spring.profiles.active#
def profiles ="dev"
if(project.hasProperty("prod")) {
profiles = "prod"
}
if(project.hasProperty("profile")){
profiles = project.getProperty("profile")
}

bootRun {
args = ["--spring.profiles.active=" + profiles]
// logback 有些JVM下JXSAXParserFactory的错误,Caused by: javax.xml.parsers.ParserConfigurationException: SAX feature 'http://xml.org/sax/features/external-general-entities' not supported
// 详情看某个https://logback.qos.ch/codes.html
jvmArgs "-Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl"
}

processResources {
inputs.property('version', version)
inputs.property('springProfiles', profiles)
filesMatching("**/application.yml") {
filter {
it.replace("#project.version#", version)
}
filter {
it.replace("#spring.profiles.active#", profiles)
}
}
}

dependencies {
implementation platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}")
implementation platform("org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}")
implementation platform("com.alibaba.cloud:spring-cloud-alibaba-dependencies:${springCloudAlibabaVersion}")

implementation "cn.hutool:hutool-all:${hutoolVersion}"

compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'

annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
annotationProcessor "com.github.therapi:therapi-runtime-javadoc-scribe:${therapiJavadocVersion}"
annotationProcessor "io.github.linpeilie:mapstruct-plus-processor:${mapstructPlusVersion}"
annotationProcessor "org.projectlombok:lombok-mapstruct-binding:${mapstructPlusLombokVersion}"

}
}
47 changes: 47 additions & 0 deletions tixwork-service/cust-models/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
### 如何覆写?

大体有两种方法,1.通过继承。2.通过Bean替换。3.通过不在生成文件。
其中分部分,domain, controller, service, mapper, mapper-xml, sql

#### 1. Domain 如何覆写

#### 2. Controller 如何覆写

#### 3. Service 如何覆写

#### 4. mapper(java) 如何覆写

#### 5. mapper(xml) 如何覆写

#### 6. sql 如何覆写

#### 7. UI 如何覆

Controller 生成的时候,会添加ConditionalOnMissingBean。 例:

```java
// 自动生成代码
@ConditionalOnMissingBean(name = "TestController")
public class TestController extends BaseController {
@GetMapping("/hello")
public WebResult hello() {
return null;
}
}
```

添加组定义类, 复写"/hello"和新增"/hello2"

```java
@RestController(name = "TestController")
public class TestController extends BaseController {
@Override
public WebResult hello() {
return "hello";
}
@GetMapping("/hello2")
public WebResult hello2() {
return "hello";
}
}
```
6 changes: 6 additions & 0 deletions tixwork-service/cust-models/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies {
api project(":tixwork-core")
api project(":biz-models")
api project(":tixwork-system")
api project(":tixwork-websocket")
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.tiandtech.core.service;

import cn.hutool.core.lang.Console;
import com.tiandtech.system.domain.SysTenant;
import com.tiandtech.system.service.SysTenantExtendService;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

@Service
@Primary
public class TenantExtendService implements SysTenantExtendService {

@Override
public void postTenantCreate(SysTenant tenant) {
Console.log("post....", tenant.getCompanyName());
}
}
Loading

0 comments on commit 70bbdb0

Please sign in to comment.