Skip to content

Commit 3935b63

Browse files
committed
v1.0.6 in addition, LiveTemplate: gf-srv-crud and change name for LiveTemplate
1 parent 4ac91c3 commit 3935b63

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515

1616
- FileWatch error on dir outside the project
1717

18+
### Added
19+
20+
- LiveTemplate: gf-srv-crud
21+
1822
## [1.0.5] - 2024-03-03
1923

2024
### Optimize
@@ -106,5 +110,5 @@
106110
[1.0.2]: https://github.com/oldme-git/goframe-helper/compare/v1.0.1...v1.0.2
107111
[1.0.1]: https://github.com/oldme-git/goframe-helper/compare/v1.0.0...v1.0.1
108112
[1.0.0]: https://github.com/oldme-git/goframe-helper/compare/v1.0.0-beta...v1.0.0
109-
[1.0.0-alpha]: https://github.com/oldme-git/goframe-helper/commits/v1.0.0-alpha
110113
[1.0.0-beta]: https://github.com/oldme-git/goframe-helper/compare/v1.0.0-alpha...v1.0.0-beta
114+
[1.0.0-alpha]: https://github.com/oldme-git/goframe-helper/commits/v1.0.0-alpha

src/main/resources/liveTemplates/GoFrame.xml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<templateSet group="GoFrame">
2-
<template name="gfapi" value="type $apiName$Req struct {&#10;&#9;g.Meta `path:&quot;$path$&quot; method:&quot;$method$&quot;`&#10;&#9;$input$&#10;}&#10;&#10;type $apiName$Res struct {&#10;}" description="gen gf api struct" toReformat="false" toShortenFQNames="true">
2+
<template name="gf-api" value="type $apiName$Req struct {&#10;&#9;g.Meta `path:&quot;$path$&quot; method:&quot;$method$&quot;`&#10;&#9;$input$&#10;}&#10;&#10;type $apiName$Res struct {&#10;}" description="gen gf api struct" toReformat="false" toShortenFQNames="true">
33
<variable name="apiName" expression="" defaultValue="" alwaysStopAt="true" />
44
<variable name="path" expression="" defaultValue="" alwaysStopAt="true" />
55
<variable name="method" expression="" defaultValue="" alwaysStopAt="true" />
@@ -8,7 +8,7 @@
88
<option name="GO_FILE" value="true" />
99
</context>
1010
</template>
11-
<template name="gfapicombo" value="type (&#10; $apiName$Req struct {&#10; g.Meta `path:&quot;$path$&quot; method:&quot;$method$&quot;`&#10; $input$&#10; }&#10; &#10; $apiName$Res struct {&#10; }&#10;)" description="gen gf api struct(gf &gt;= 2.5.7)" toReformat="false" toShortenFQNames="true">
11+
<template name="gf-api-combo" value="type (&#10; $apiName$Req struct {&#10; g.Meta `path:&quot;$path$&quot; method:&quot;$method$&quot;`&#10; $input$&#10; }&#10; &#10; $apiName$Res struct {&#10; }&#10;)" description="gen gf api struct(gf &gt;= 2.5.7)" toReformat="false" toShortenFQNames="true">
1212
<variable name="apiName" expression="" defaultValue="" alwaysStopAt="true" />
1313
<variable name="path" expression="" defaultValue="" alwaysStopAt="true" />
1414
<variable name="method" expression="" defaultValue="" alwaysStopAt="true" />
@@ -17,24 +17,32 @@
1717
<option name="GO_FILE" value="true" />
1818
</context>
1919
</template>
20-
<template name="gfservice" value="type s$serviceName$ struct {&#10;}&#10;&#10;func init() {&#10;&#9;service.Register$serviceName$(New())&#10;}&#10;&#10;func New() *s$serviceName$ {&#10;&#9;return &amp;s$serviceName${$content$}&#10;}" description="gen gf service" toReformat="false" toShortenFQNames="true">
20+
<template name="gf-ctrl-func" value="func (c *$cName$) $name$(ctx context.Context, req *$pName$.$name$Req) (res *$pName$.$name$Res, err error) {&#10;&#9;return&#10;}&#10;" description="gen gf controller" toReformat="false" toShortenFQNames="true">
21+
<variable name="cName" expression="" defaultValue="" alwaysStopAt="true" />
22+
<variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
23+
<variable name="pName" expression="" defaultValue="" alwaysStopAt="true" />
24+
<context>
25+
<option name="GO_FILE" value="true" />
26+
</context>
27+
</template>
28+
<template name="gf-srv" value="type s$serviceName$ struct {&#10;}&#10;&#10;func init() {&#10;&#9;service.Register$serviceName$(New())&#10;}&#10;&#10;func New() *s$serviceName$ {&#10;&#9;return &amp;s$serviceName${$content$}&#10;}" description="gen gf service" toReformat="false" toShortenFQNames="true">
2129
<variable name="serviceName" expression="" defaultValue="" alwaysStopAt="true" />
2230
<variable name="content" expression="" defaultValue="" alwaysStopAt="true" />
2331
<context>
2432
<option name="GO_FILE" value="true" />
2533
</context>
2634
</template>
27-
<template name="gfctrlrfunc" value="func (c *$cName$) $name$(ctx context.Context, req *$pName$.$name$Req) (res *$pName$.$name$Res, err error) {&#10;&#9;return&#10;}&#10;" description="gen gf controller" toReformat="false" toShortenFQNames="true">
28-
<variable name="cName" expression="" defaultValue="" alwaysStopAt="true" />
29-
<variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
30-
<variable name="pName" expression="" defaultValue="" alwaysStopAt="true" />
35+
<template name="gf-srv-func" value="func (s *s$serviceName$) $funcName$(ctx context.Context) (err error) {&#10;}" description="gen gf service func" toReformat="false" toShortenFQNames="true">
36+
<variable name="serviceName" expression="" defaultValue="" alwaysStopAt="true" />
37+
<variable name="funcName" expression="" defaultValue="" alwaysStopAt="true" />
3138
<context>
3239
<option name="GO_FILE" value="true" />
3340
</context>
3441
</template>
35-
<template name="gfservicefunc" value="func (s *s$serviceName$) $funcName$(ctx context.Context) (err error) {&#10;}" description="gen gf service func" toReformat="false" toShortenFQNames="true">
42+
<template name="gf-srv-crud" value="func init() {&#10;&#9;service.Register$serviceName$(New())&#10;}&#10;&#10;type s$serviceName$ struct {&#10;}&#10;&#10;func New() *s$serviceName$ {&#10;&#9;return &amp;s$serviceName${}&#10;}&#10;&#10;func (s *s$serviceName$) Create(ctx context.Context, $modelName$ *entity.$model$) (id int, err error) {&#10;&#9;return 0, nil&#10;}&#10;&#10;func (s *s$serviceName$) GetOne(ctx context.Context, id int) ($modelName$ *entity.$model$, err error) {&#10;&#9;return nil, err&#10;}&#10;&#10;func (s *s$serviceName$) GetList(ctx context.Context) (libs []*entity.$model$, err error) {&#10;&#9;return nil, err&#10;}&#10;&#10;func (s *s$serviceName$) Update(ctx context.Context, $modelName$ *entity.$model$) (err error) {&#10;&#9;return nil&#10;}&#10;&#10;func (s *s$serviceName$) Delete(ctx context.Context, id int) (err error) {&#10;&#9;return nil&#10;}&#10;" description="gen gf service crud" toReformat="false" toShortenFQNames="true">
3643
<variable name="serviceName" expression="" defaultValue="" alwaysStopAt="true" />
37-
<variable name="funcName" expression="" defaultValue="" alwaysStopAt="true" />
44+
<variable name="modelName" expression="" defaultValue="" alwaysStopAt="true" />
45+
<variable name="model" expression="" defaultValue="" alwaysStopAt="true" />
3846
<context>
3947
<option name="GO_FILE" value="true" />
4048
</context>

0 commit comments

Comments
 (0)