Skip to content

Commit

Permalink
Merge pull request #8 from maiqingqiang/next
Browse files Browse the repository at this point in the history
v1.2.1
  • Loading branch information
johnmai-dev authored Jul 25, 2023
2 parents 4ddd37c + a66a150 commit a651023
Show file tree
Hide file tree
Showing 25 changed files with 325 additions and 108 deletions.
Binary file removed .DS_Store
Binary file not shown.
30 changes: 28 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,21 @@

## [Unreleased]

## [1.2.1] - 2023-07-25

### Added

- Support Inline Conditions.

### Fixed

- Fix GoFrame ORM unsupported syntax.
- Fix Outdated stub in index Exception.

## [1.2.0] - 2023-07-15

### Added

- Support GoFrame ORM.
- Support Go ORM Tags Live Template.
- Refactor Code Completion. Better Performance!
Expand All @@ -15,36 +27,50 @@
## [1.1.0] - 2023-07-04

### Added

- Assisted code completion with @Table annotation.
- Support ORM's table method.

### Fixed

- Fix SQL to Struct error.

## [1.0.2] - 2023-07-04

### Fixed

- Fix the verify SQL exception.

## [1.0.1] - 2023-07-03

### Fixed
- Fix the issue where the scanning paths in the settings cannot utilize the delete, move up, move down, and other functions.

- Fix the issue where the scanning paths in the settings cannot utilize the delete, move up, move down, and other
functions.

### Optimize

- Abstract the core path of the ORM into a common class.
- Implement multi-language support, currently supporting Chinese, English, Japanese, and Korean languages.
- Separate the plugin description.

## [1.0.0] - 2023-07-02

### Added

- ORM Code Completion
- SQL to Struct

[Unreleased]: https://github.com/maiqingqiang/go-orm-helper/compare/v1.2.0...HEAD
[Unreleased]: https://github.com/maiqingqiang/go-orm-helper/compare/v1.2.1...HEAD

[1.2.1]: https://github.com/maiqingqiang/go-orm-helper/compare/v1.2.0...v1.2.1

[1.2.0]: https://github.com/maiqingqiang/go-orm-helper/compare/v1.1.0...v1.2.0

[1.1.0]: https://github.com/maiqingqiang/go-orm-helper/compare/v1.0.2...v1.1.0

[1.0.2]: https://github.com/maiqingqiang/go-orm-helper/compare/v1.0.1...v1.0.2

[1.0.1]: https://github.com/maiqingqiang/go-orm-helper/compare/v1.0.0...v1.0.1

[1.0.0]: https://github.com/maiqingqiang/go-orm-helper/tree/v1.0.0
4 changes: 2 additions & 2 deletions README-ja_JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@

## インストール

### Jetbrains Marketplace からプラグインをインストールする

> 互換性範囲:
> - GoLand — 2022.2+
> - IntelliJ IDEA Ultimate — 2022.2+
### Jetbrains Marketplace からプラグインをインストールする

<a href="https://plugins.jetbrains.com/plugin/22173-go-orm-helper" target="_blank">
<img src="https://blog.johnmai.top/go-orm-helper/assets/installation_button.svg" height="52" alt="Get from Marketplace" title="Get from Marketplace">
</a>
Expand Down
4 changes: 2 additions & 2 deletions README-ko_KR.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@

## 설치

### Jetbrains Marketplace 에서 플러그인 설치

> 호환성 범위:
> - GoLand — 2022.2+
> - IntelliJ IDEA Ultimate — 2022.2+
### Jetbrains Marketplace 에서 플러그인 설치

<a href="https://plugins.jetbrains.com/plugin/22173-go-orm-helper" target="_blank">
<img src="https://blog.johnmai.top/go-orm-helper/assets/installation_button.svg" height="52" alt="Get from Marketplace" title="Get from Marketplace">
</a>
Expand Down
26 changes: 24 additions & 2 deletions README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,38 @@

## 使用

### 代码补全
https://www.jetbrains.com/help/go/auto-completing-code.html#code-completion-for-functions

![guide.gif](assets%2Fguide.gif)

## 安装
### 注解辅助
有些写法此插件可能无法兼容,导致无法补全。你可以使用 @Model 或者 @Table 解决此问题。
![annotation.gif](assets%2Fannotation.gif)

### 通过 Jetbrains Marketplace 安装
插件会扫描项目中所有Struct,建议设置扫描范围。
![setting.png](assets%2Fsetting.png)

### 实时模版
![live-template.gif](assets%2Flive-template.gif)

### SQL 转 Struct
#### 粘贴方式
![paste.gif](assets%2Fpaste.gif)

#### 菜单操作
选中 SQL -> 点击编辑器右键菜单 -> Go ORM 助手工具箱 -> SQL 转 Struct

![manual-sql-to-struct.png](assets%2Fmanual-sql-to-struct.png)

## 安装

> 兼容范围:
> - GoLand — 2022.2+
> - IntelliJ IDEA Ultimate — 2022.2+
### 通过 Jetbrains Marketplace 安装

<a href="https://plugins.jetbrains.com/plugin/22173-go-orm-helper" target="_blank">
<img src="https://blog.johnmai.top/go-orm-helper/assets/installation_button.svg" height="52" alt="Get from Marketplace" title="Get from Marketplace">
</a>
Expand Down
28 changes: 25 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,40 @@ for writing ORM code. Supports: Gorm、Xorm、Beego、GoFrame, etc.<br/>⭐️ S
- [More Supported](./SUPPORTED.md)

## Usage

### Code Completion
https://www.jetbrains.com/help/go/auto-completing-code.html#code-completion-for-functions

![guide.gif](assets%2Fguide.gif)

### Annotation
If the plugin is not compatible with your syntax, you can use the @Model or @Table helper.
![annotation.gif](assets%2Fannotation.gif)

The plugin will scan the Structs in your project. It is recommended to set the scanning scope.
![setting.png](assets%2Fsetting.png)

### Live Template
![live-template.gif](assets%2Flive-template.gif)

### SQL to Struct
#### Paste
![paste.gif](assets%2Fpaste.gif)

#### Menu Action
Selected SQL -> Editor Popup Menu -> Go ORM Helper Tool -> SQL Convert Struct
![manual-sql-to-struct.png](assets%2Fmanual-sql-to-struct.png)

<!-- Plugin description end -->

## Installation

### Install Plugin from Jetbrains Marketplace

> Compatibility Range:
> Compatibility Range:
> - GoLand — 2022.2+
> - IntelliJ IDEA Ultimate — 2022.2+
### Install Plugin from Jetbrains Marketplace

<a href="https://plugins.jetbrains.com/plugin/22173-go-orm-helper" target="_blank">
<img src="https://blog.johnmai.top/go-orm-helper/assets/installation_button.svg" height="52" alt="Get from Marketplace" title="Get from Marketplace">
</a>
Expand Down
Binary file added assets/annotation.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/live-template.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/manual-sql-to-struct.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/paste.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/setting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions example/goframe/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ type User struct {
Age int32 // 年龄
}

func main() {
func test1() (user *User) {
g.Model(&User{}).Where("id = ?")
}

func test1() (user *User) {
g.Model(&User{}).Where("id = ? and user_name = ? OR email != ?")

g.DB().Model(&User{}).Where("id = ? and")

g.Model(&user).Where("id = ?", 1)

g.Model(&User{}).Where(g.Map{"user_name": 1, "name": "john"})
Expand Down
6 changes: 6 additions & 0 deletions example/gorm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,9 @@ func test6(db *gorm.DB) (user *User) {
query.Find(&user)
return
}

func test7(db *gorm.DB) (user *User) {
query := db.Where("id = ? and email != ? OR user_name = ?", "")
query.Find(&user)
return
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pluginGroup = com.github.maiqingqiang.goormhelper
pluginName = Go ORM Helper
pluginRepositoryUrl = https://github.com/maiqingqiang/go-orm-helper
# SemVer format -> https://semver.org
pluginVersion = 1.2.0
pluginVersion = 1.2.1

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 222
Expand Down
20 changes: 19 additions & 1 deletion src/main/java/com/github/maiqingqiang/goormhelper/Types.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,26 @@
public interface Types {

List<String> OPERATOR_EXPR = List.of(
"%s = ?", "%s <> ?", "%s != ?", "%s IN ?", "%s LIKE ?", "%s > ?", "%s >= ?", "%s < ?", "%s <= ?", "%s BETWEEN ? AND ?"
"%s = ?",
"%s <> ?",
"%s != ?",
"%s IN ?",
"%s NOT IN ?",
"%s LIKE ?",
"%s > ?",
"%s >= ?",
"%s < ?",
"%s <= ?",
"%s <=> ?",
"%s IS NULL",
"%s IS NOT NULL",
"%s BETWEEN ? AND ?",
"%s NOT BETWEEN ? AND ?"
);

List<String> LOGICAL_OPERATOR_EXPR = List.of("AND", "OR", "XOR", "NOT");
List<String> USE_LOGICAL_OPERATOR_SCENE = List.of(" ?", " IS NULL", " IS NOT NULL");

String MODEL_ANNOTATION = "@Model";
Pattern MODEL_ANNOTATION_PATTERN = Pattern.compile(MODEL_ANNOTATION + "\\((.*?)\\)");
String TABLE_ANNOTATION = "@Table";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.github.maiqingqiang.goormhelper.codeInsights.completion;

import com.github.maiqingqiang.goormhelper.orm.ORMCompletionProvider;
import com.github.maiqingqiang.goormhelper.orm.goframe.codeInsights.completion.GoFrameColumnCompletionProvider;
import com.github.maiqingqiang.goormhelper.orm.gorm.codeInsights.completion.GormColumnCompletionProvider;
import com.github.maiqingqiang.goormhelper.orm.xorm.codeInsights.completion.XormColumnCompletionProvider;
import com.goide.GoParserDefinition;
import com.intellij.codeInsight.completion.CompletionContributor;
import com.intellij.codeInsight.completion.CompletionType;
import com.intellij.patterns.PlatformPatterns;

import java.util.List;

public class GoORMHelperCompletionContributor extends CompletionContributor {

public GoORMHelperCompletionContributor() {
List<ORMCompletionProvider> providers = List.of(
new GormColumnCompletionProvider(),
new XormColumnCompletionProvider(),
new GoFrameColumnCompletionProvider()
);

for (ORMCompletionProvider provider : providers) {
extend(CompletionType.BASIC,
PlatformPatterns.psiElement().withElementType(GoParserDefinition.Lazy.STRING_LITERALS),
provider);
}
}
}
Loading

0 comments on commit a651023

Please sign in to comment.