gorig-cli 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/cli.js ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env node
2
+
3
+ import chalk from 'chalk';
4
+ import path from 'path';
5
+
6
+ // 获取命令行参数
7
+ const args = process.argv.slice(2);
8
+
9
+ // 验证是否提供了命令
10
+ if (args.length < 1) {
11
+ console.error(chalk.red('请提供一个有效的命令,例如: create'));
12
+ process.exit(1);
13
+ }
14
+
15
+ // 提取命令
16
+ const command = args[0];
17
+
18
+ // 获取当前文件的目录
19
+ const __dirname = path.dirname(new URL(import.meta.url).pathname);
20
+
21
+ // 根据命令执行不同的逻辑
22
+ switch (command) {
23
+ case 'create':
24
+ // 动态导入 create.js,命令放在 commands 目录下
25
+ import(path.join(__dirname, '../commands/create.js')).then(module => {
26
+ const createModule = module.default;
27
+ createModule(args.slice(1)); // 将命令行的其他参数传递给 create.js
28
+ }).catch(error => {
29
+ console.error(chalk.red('无法加载 create 命令模块:', error.message));
30
+ });
31
+ break;
32
+
33
+ default:
34
+ console.error(chalk.red(`未知的命令: ${command}`));
35
+ console.error(chalk.yellow('可用的命令: create'));
36
+ process.exit(1);
37
+ }
@@ -0,0 +1,129 @@
1
+ import fs from 'fs-extra';
2
+ import path from 'path';
3
+ import ejs from 'ejs';
4
+ import chalk from 'chalk';
5
+ import { fileURLToPath } from 'url';
6
+
7
+ // 定义 __dirname 变量
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = path.dirname(__filename);
10
+
11
+ // 获取 go.mod 文件中的模块名称
12
+ const getGoModModuleName = async () => {
13
+ try {
14
+ const goModPath = path.join(process.cwd(), 'go.mod');
15
+ const goModContent = await fs.readFile(goModPath, 'utf-8');
16
+ const moduleLine = goModContent.split('\n').find(line => line.startsWith('module '));
17
+ if (moduleLine) {
18
+ return moduleLine.split(' ')[1].trim();
19
+ } else {
20
+ throw new Error('未找到模块名称');
21
+ }
22
+ } catch (error) {
23
+ console.error(chalk.red('无法读取 go.mod 文件。请确认您是否在 Go 项目的根目录下运行该命令。'));
24
+ process.exit(1);
25
+ }
26
+ };
27
+
28
+ // 创建模块的主函数
29
+ const createModule = async (args) => {
30
+ if (args.length < 1) {
31
+ console.error(chalk.yellow('请使用正确的命令格式: npx <你的包名> create <模块名>'));
32
+ process.exit(1);
33
+ }
34
+
35
+ const moduleName = args[0];
36
+ const ModuleName = moduleName.charAt(0).toUpperCase() + moduleName.slice(1);
37
+
38
+ // 获取当前工作目录,即执行命令的目录
39
+ const currentDir = process.cwd();
40
+
41
+ // 构建 domain 目录和模块目录的路径
42
+ const domainDir = path.join(currentDir, 'domain');
43
+ const moduleDir = path.join(domainDir, moduleName);
44
+
45
+ // 定义需要创建的子目录
46
+ const subDirs = ['api', 'model', 'internal', 'api/req'];
47
+
48
+ console.log(chalk.blue(`\n开始创建模块: ${chalk.bold(moduleName)}`));
49
+
50
+ try {
51
+ const projectName = await getGoModModuleName();
52
+
53
+ await fs.ensureDir(domainDir);
54
+ await fs.ensureDir(moduleDir);
55
+
56
+ // 创建子目录
57
+ const createSubDirs = subDirs.map((subDir) => {
58
+ const subDirPath = path.join(moduleDir, subDir);
59
+ return fs.ensureDir(subDirPath);
60
+ });
61
+ await Promise.all(createSubDirs);
62
+
63
+ // 创建并写入 model.go 文件
64
+ const modelDir = path.join(moduleDir, 'model');
65
+ const modelFilePath = path.join(modelDir, `${moduleName}.go`);
66
+ const modelTemplatePath = path.join(__dirname, '../templates/model.go.ejs');
67
+ const modelContent = await ejs.renderFile(modelTemplatePath, { moduleName, ModuleName, projectName });
68
+ await fs.writeFile(modelFilePath, modelContent);
69
+ console.log(chalk.green(`成功创建 ${chalk.bold('model.go')} 文件`));
70
+
71
+ // 创建并写入 req.go 文件
72
+ const apiDir = path.join(moduleDir, 'api');
73
+ const reqDir = path.join(apiDir, 'req');
74
+ const reqFilePath = path.join(reqDir, `req.go`);
75
+ const reqTemplatePath = path.join(__dirname, '../templates/req.go.ejs');
76
+ const reqContent = await ejs.renderFile(reqTemplatePath, { moduleName, ModuleName, projectName });
77
+ await fs.writeFile(reqFilePath, reqContent);
78
+ console.log(chalk.green(`成功创建 ${chalk.bold('req.go')} 文件`));
79
+
80
+ // 创建并写入 resp.go 文件
81
+ const respFilePath = path.join(reqDir, `resp.go`);
82
+ const respTemplatePath = path.join(__dirname, '../templates/resp.go.ejs');
83
+ const respContent = await ejs.renderFile(respTemplatePath, { moduleName, ModuleName, projectName });
84
+ await fs.writeFile(respFilePath, respContent);
85
+ console.log(chalk.green(`成功创建 ${chalk.bold('resp.go')} 文件`));
86
+
87
+ // 创建并写入 internal.go 文件
88
+ const internalDir = path.join(moduleDir, 'internal');
89
+ const internalFilePath = path.join(internalDir, `${moduleName}.go`);
90
+ const internalTemplatePath = path.join(__dirname, '../templates/internal.go.ejs');
91
+ const internalContent = await ejs.renderFile(internalTemplatePath, { moduleName, ModuleName, projectName });
92
+ await fs.writeFile(internalFilePath, internalContent);
93
+ console.log(chalk.green(`成功创建 ${chalk.bold('internal.go')} 文件`));
94
+
95
+ // 创建并写入 service.pub.go 文件
96
+ const serviceFilePath = path.join(apiDir, `service.pub.go`);
97
+ const serviceTemplatePath = path.join(__dirname, '../templates/service.pub.go.ejs');
98
+ const serviceContent = await ejs.renderFile(serviceTemplatePath, { moduleName, ModuleName, projectName });
99
+ await fs.writeFile(serviceFilePath, serviceContent);
100
+ console.log(chalk.green(`成功创建 ${chalk.bold('service.pub.go')} 文件`));
101
+
102
+ // 创建并写入 service.go 文件
103
+ const serviceGoFilePath = path.join(apiDir, `service.go`);
104
+ const serviceGoTemplatePath = path.join(__dirname, '../templates/service.go.ejs');
105
+ const serviceGoContent = await ejs.renderFile(serviceGoTemplatePath, { moduleName, ModuleName, projectName });
106
+ await fs.writeFile(serviceGoFilePath, serviceGoContent);
107
+ console.log(chalk.green(`成功创建 ${chalk.bold('service.go')} 文件`));
108
+
109
+ // 创建并写入 controller.go 文件
110
+ const controllerGoFilePath = path.join(apiDir, `controller.go`);
111
+ const controllerGoTemplatePath = path.join(__dirname, '../templates/controller.go.ejs');
112
+ const controllerGoContent = await ejs.renderFile(controllerGoTemplatePath, { moduleName, ModuleName, projectName });
113
+ await fs.writeFile(controllerGoFilePath, controllerGoContent);
114
+ console.log(chalk.green(`成功创建 ${chalk.bold('controller.go')} 文件`));
115
+
116
+ // 创建并写入 router.go 文件
117
+ const routerGoFilePath = path.join(apiDir, `router.go`);
118
+ const routerGoTemplatePath = path.join(__dirname, '../templates/router.go.ejs');
119
+ const routerGoContent = await ejs.renderFile(routerGoTemplatePath, { moduleName, ModuleName, projectName });
120
+ await fs.writeFile(routerGoFilePath, routerGoContent);
121
+ console.log(chalk.green(`成功创建 ${chalk.bold('router.go')} 文件`));
122
+
123
+ console.log(chalk.blue(`\n模块 ${chalk.bold(moduleName)} 已成功创建在 ${chalk.bold(`domain/${moduleName}`)} 目录下`));
124
+ } catch (error) {
125
+ console.error(chalk.red('创建模块时出错:'), chalk.redBright(error.message));
126
+ }
127
+ };
128
+
129
+ export default createModule;
package/npm_publish.sh ADDED
@@ -0,0 +1,65 @@
1
+ #!/bin/bash
2
+
3
+ # 确保脚本有执行权限
4
+ # chmod +x npm_publish.sh
5
+
6
+ # 设置官方源地址和原仓库源地址
7
+ NPM_OFFICIAL_REGISTRY="https://registry.npmjs.org/"
8
+ CUSTOM_REGISTRY=$(npm config get registry)
9
+
10
+ # 检查原始仓库源是否为官方源
11
+ if [ "$CUSTOM_REGISTRY" = "$NPM_OFFICIAL_REGISTRY" ]; then
12
+ echo "当前已经是官方源,不需要切换。"
13
+ else
14
+ echo "当前仓库源为: $CUSTOM_REGISTRY"
15
+ echo "正在切换为官方源: $NPM_OFFICIAL_REGISTRY"
16
+ npm config set registry $NPM_OFFICIAL_REGISTRY
17
+ fi
18
+
19
+ # 验证是否成功切换到官方源
20
+ CURRENT_REGISTRY=$(npm config get registry)
21
+ if [ "$CURRENT_REGISTRY" = "$NPM_OFFICIAL_REGISTRY" ]; then
22
+ echo "仓库源已成功切换为官方源。"
23
+ else
24
+ echo "切换仓库源失败,请检查。"
25
+ exit 1
26
+ fi
27
+
28
+ # 登录 npm 账户
29
+ echo "开始登录 npm,请根据提示输入用户名、密码和邮箱地址。"
30
+ npm login
31
+ if [ $? -ne 0 ]; then
32
+ echo "npm 登录失败,请检查用户名、密码和邮箱是否正确。"
33
+ exit 1
34
+ fi
35
+
36
+ # 执行 yarn publish 或 npm publish
37
+ echo "请选择使用 yarn 还是 npm 发布包(输入 y 表示使用 yarn,输入 n 表示使用 npm):"
38
+ read -p "[y/n]: " CHOICE
39
+
40
+ if [ "$CHOICE" = "y" ]; then
41
+ yarn publish
42
+ elif [ "$CHOICE" = "n" ]; then
43
+ npm publish
44
+ else
45
+ echo "无效输入,请重新运行脚本并选择 y 或 n。"
46
+ exit 1
47
+ fi
48
+
49
+ if [ $? -ne 0 ]; then
50
+ echo "发布失败,请检查日志。"
51
+ exit 1
52
+ else
53
+ echo "发布成功!"
54
+ fi
55
+
56
+ # 恢复原始仓库源
57
+ if [ "$CUSTOM_REGISTRY" != "$NPM_OFFICIAL_REGISTRY" ]; then
58
+ echo "正在恢复原始仓库源: $CUSTOM_REGISTRY"
59
+ npm config set registry $CUSTOM_REGISTRY
60
+ echo "仓库源已恢复为: $(npm config get registry)"
61
+ else
62
+ echo "仓库源保持为官方源,无需恢复。"
63
+ fi
64
+
65
+ echo "脚本执行完成。"
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "gorig-cli",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "description": "gorig构建工具",
6
+ "main": "bin/cli.js",
7
+ "bin": {
8
+ "gorig-cli": "./bin/cli.js"
9
+ },
10
+ "scripts": {
11
+ "start": "node bin/cli.js"
12
+ },
13
+ "keywords": [
14
+ "go",
15
+ "cli",
16
+ "gorig"
17
+ ],
18
+ "author": "jom",
19
+ "license": "MIT",
20
+ "dependencies": {
21
+ "chalk": "^5.3.0",
22
+ "commander": "^12.1.0",
23
+ "ejs": "^3.1.10",
24
+ "fs-extra": "^11.2.0"
25
+ }
26
+ }
@@ -0,0 +1,62 @@
1
+ package <%= moduleName %>
2
+
3
+ import (
4
+ "github.com/gin-gonic/gin"
5
+ "github.com/jom-io/gorig/apix"
6
+ "github.com/jom-io/gorig/global/consts"
7
+ "<%= projectName %>/domain/<%= moduleName %>/api/req"
8
+ )
9
+
10
+ func Page<%= ModuleName %>(ctx *gin.Context) {
11
+ defer apix.HandlePanic(ctx)
12
+ pageReq, e := apix.GetPageReq(ctx)
13
+ filter := &req.<%= ModuleName %>Req{}
14
+ e = apix.BindParams(ctx, filter)
15
+ if e != nil {
16
+ return
17
+ }
18
+ result, err := gService.Page<%= ModuleName %>(ctx, pageReq, filter)
19
+ apix.HandleData(ctx, consts.CurdSelectFailCode, &result, err)
20
+ }
21
+
22
+ func List<%= ModuleName %>(ctx *gin.Context) {
23
+ defer apix.HandlePanic(ctx)
24
+ filter := &req.<%= ModuleName %>Req{}
25
+ e := apix.BindParams(ctx, filter)
26
+ if e != nil {
27
+ return
28
+ }
29
+ result, err := gService.List<%= ModuleName %>(ctx, filter)
30
+ apix.HandleData(ctx, consts.CurdSelectFailCode, &result, err)
31
+ }
32
+
33
+ func Save<%= ModuleName %>(ctx *gin.Context) {
34
+ defer apix.HandlePanic(ctx)
35
+ <%= ModuleName %>Req := &req.<%= ModuleName %>Req{}
36
+ e := apix.BindParams(ctx, <%= ModuleName %>Req)
37
+ if e != nil {
38
+ return
39
+ }
40
+ err := gService.Save<%= ModuleName %>(ctx, <%= ModuleName %>Req)
41
+ apix.HandleData(ctx, consts.CurdUpdateFailCode, nil, err)
42
+ }
43
+
44
+ func Get<%= ModuleName %>(ctx *gin.Context) {
45
+ defer apix.HandlePanic(ctx)
46
+ id, e := apix.GetParamInt64(ctx, "id", apix.Force)
47
+ if e != nil {
48
+ return
49
+ }
50
+ result, err := gService.Get<%= ModuleName %>(ctx, id)
51
+ apix.HandleData(ctx, consts.CurdSelectFailCode, &result, err)
52
+ }
53
+
54
+ func Delete<%= ModuleName %>(ctx *gin.Context) {
55
+ defer apix.HandlePanic(ctx)
56
+ id, e := apix.GetParamInt64(ctx, "id", apix.Force)
57
+ if e != nil {
58
+ return
59
+ }
60
+ err := gService.Delete<%= ModuleName %>(ctx, id)
61
+ apix.HandleData(ctx, consts.CurdUpdateFailCode, nil, err)
62
+ }
@@ -0,0 +1,49 @@
1
+ package internal
2
+
3
+ import (
4
+ "github.com/jom-io/gorig/domainx"
5
+ "<%= projectName %>/domain/<%= moduleName %>/model"
6
+ "<%= projectName %>/domain/<%= moduleName %>/api/req"
7
+ "<%= projectName %>/global/constants"
8
+ "<%= projectName %>/global/varb"
9
+ )
10
+
11
+ func <%= ModuleName %>() *<%= ModuleName %>M {
12
+ return &<%= ModuleName %>M{Complex: domainx.UseComplex[model.<%= ModuleName %>D](domainx.Mysql, constants.Main, "<%= moduleName %>")}
13
+ }
14
+
15
+ type <%= ModuleName %>M struct {
16
+ *domainx.Complex[model.<%= ModuleName %>D]
17
+ }
18
+
19
+ func (u *<%= ModuleName %>M) TableName() string {
20
+ return varb.GetApp().TableName("<%= moduleName %>")
21
+ }
22
+
23
+ func init() {
24
+ domainx.AutoMigrate(func() (value domainx.ConTable) {
25
+ return <%= ModuleName %>()
26
+ })
27
+ }
28
+
29
+ func (u *<%= ModuleName %>M) ParseReq(req *req.<%= ModuleName %>Req) {
30
+ u.Data = &req.<%= ModuleName %>D
31
+ }
32
+
33
+ func (u *<%= ModuleName %>M) ToResp() *req.<%= ModuleName %>Resp {
34
+ if u.Data == nil {
35
+ return nil
36
+ }
37
+ return &req.<%= ModuleName %>Resp{
38
+ ID: u.ID,
39
+ <%= ModuleName %>D: *u.Data,
40
+ }
41
+ }
42
+
43
+ func (u *<%= ModuleName %>M) ToRespList(list *[]<%= ModuleName %>M) []*req.<%= ModuleName %>Resp {
44
+ respList := make([]*req.<%= ModuleName %>Resp, 0)
45
+ for _, v := range *list {
46
+ respList = append(respList, v.ToResp())
47
+ }
48
+ return respList
49
+ }
@@ -0,0 +1,7 @@
1
+ package model
2
+
3
+ type <%= moduleName.charAt(0).toUpperCase() + moduleName.slice(1) %>D struct {
4
+ UserID int64 `gorm:"column:user_id;type:bigint(20);comment:user_id" json:"userID"`
5
+ FiledStr string `gorm:"column:fieldStr;type:varchar(255);comment:fieldStr" json:"fieldStr"`
6
+ FieldInt int64 `gorm:"column:fieldInt;type:bigint(20);comment:fieldInt" json:"fieldInt"`
7
+ }
@@ -0,0 +1,8 @@
1
+ package req
2
+
3
+ import "<%= projectName %>/domain/<%= moduleName %>/model"
4
+
5
+ type <%= ModuleName %>Req struct {
6
+ ID int64 `json:"id" form:"id"`
7
+ model.<%= ModuleName %>D
8
+ }
@@ -0,0 +1,8 @@
1
+ package req
2
+
3
+ import "<%= projectName %>/domain/<%= moduleName %>/model"
4
+
5
+ type <%= ModuleName %>Resp struct {
6
+ ID int64 `json:"id" form:"id"`
7
+ model.<%= ModuleName %>D
8
+ }
@@ -0,0 +1,18 @@
1
+ package <%= moduleName %>
2
+
3
+ import (
4
+ "github.com/gin-gonic/gin"
5
+ "github.com/jom-io/gorig/httpx"
6
+ )
7
+
8
+ func init() {
9
+ httpx.RegisterRouter(func(groupRouter *gin.RouterGroup) {
10
+ <%= ModuleName %> := groupRouter.Group("<%= moduleName %>")
11
+ //<%= ModuleName %>.Use(mid.SignMP())
12
+ <%= ModuleName %>.GET("page", Page<%= ModuleName %>)
13
+ <%= ModuleName %>.GET("list", List<%= ModuleName %>)
14
+ <%= ModuleName %>.POST("save", Save<%= ModuleName %>)
15
+ <%= ModuleName %>.GET("info", Get<%= ModuleName %>)
16
+ <%= ModuleName %>.DELETE("delete", Delete<%= ModuleName %>)
17
+ })
18
+ }
@@ -0,0 +1,93 @@
1
+ package <%= moduleName %>
2
+
3
+ import (
4
+ "github.com/gin-gonic/gin"
5
+ "github.com/jom-io/gorig/apix/load"
6
+ "github.com/jom-io/gorig/domainx"
7
+ "github.com/jom-io/gorig/httpx"
8
+ "github.com/jom-io/gorig/utils/errors"
9
+ "github.com/jom-io/gorig/utils/logger"
10
+ "go.uber.org/zap"
11
+ "<%= projectName %>/domain/<%= moduleName %>/api/req"
12
+ "<%= projectName %>/domain/<%= moduleName %>/internal"
13
+ )
14
+
15
+ var gService = &service{}
16
+
17
+ type service struct {
18
+ }
19
+
20
+ func (s service) Save<%= ModuleName %>(ctx *gin.Context, req *req.<%= ModuleName %>Req) *errors.Error {
21
+ logger.Info(ctx, "Save<%= ModuleName %>", zap.Any("req", req))
22
+ <%= moduleName %>M := internal.<%= ModuleName %>()
23
+ if req.ID > 0 {
24
+ get<%= ModuleName %> := internal.<%= ModuleName %>()
25
+ if e := domainx.MustGetByID(get<%= ModuleName %>.Con, req.ID, get<%= ModuleName %>); e != nil {
26
+ return e
27
+ }
28
+ <%= moduleName %>M.ID = get<%= ModuleName %>.ID
29
+ <%= moduleName %>M.Options = get<%= ModuleName %>.Options
30
+ }
31
+ <%= moduleName %>M.ParseReq(req)
32
+ if _, e := domainx.SaveOrUpdate(<%= moduleName %>M.Con, <%= moduleName %>M); e != nil {
33
+ return e
34
+ }
35
+ return nil
36
+ }
37
+
38
+ func (s service) Page<%= ModuleName %>(ctx *gin.Context, pageReq *load.Page, filter *req.<%= ModuleName %>Req) (*load.PageResp, *errors.Error) {
39
+ logger.Info(ctx, "Page<%= ModuleName %>", zap.Any("pageReq", pageReq), zap.Any("filter", filter))
40
+ if filter == nil {
41
+ return nil, errors.Verify("参数错误")
42
+ }
43
+ query := domainx.Matches{}
44
+ query.Eq("user_id", httpx.GetUserIDInt64(ctx))
45
+ <%= moduleName %>Resp := new(load.PageResp)
46
+ <%= moduleName %> := internal.<%= ModuleName %>()
47
+ list := &[]internal.<%= ModuleName %>M{}
48
+ if e := domainx.FindByPageMatch(<%= moduleName %>.Con, query, pageReq, <%= moduleName %>Resp, list); e != nil {
49
+ return nil, e
50
+ }
51
+ <%= moduleName %>Resp.Result = <%= moduleName %>.ToRespList(list)
52
+ return <%= moduleName %>Resp, nil
53
+ }
54
+
55
+ func (s service) List<%= ModuleName %>(ctx *gin.Context, filter *req.<%= ModuleName %>Req) ([]*req.<%= ModuleName %>Resp, *errors.Error) {
56
+ logger.Info(ctx, "List<%= ModuleName %>", zap.Any("filter", filter))
57
+ if filter == nil {
58
+ return nil, errors.Verify("参数错误")
59
+ }
60
+ query := domainx.Matches{}
61
+ query.Eq("user_id", httpx.GetUserIDInt64(ctx))
62
+ <%= moduleName %> := internal.<%= ModuleName %>()
63
+ list := &[]internal.<%= ModuleName %>M{}
64
+ if e := domainx.FindByMatch(<%= moduleName %>.Con, query, list); e != nil {
65
+ return nil, e
66
+ }
67
+ return <%= moduleName %>.ToRespList(list), nil
68
+ }
69
+
70
+ func (s service) Get<%= ModuleName %>(ctx *gin.Context, id int64) (*req.<%= ModuleName %>Resp, *errors.Error) {
71
+ logger.Info(ctx, "Get<%= ModuleName %>", zap.Any("id", id))
72
+ <%= moduleName %>M := internal.<%= ModuleName %>()
73
+ if e := domainx.MustGetByID(<%= moduleName %>M.Con, id, <%= moduleName %>M); e != nil {
74
+ return nil, e
75
+ }
76
+ return <%= moduleName %>M.ToResp(), nil
77
+ }
78
+
79
+ func (s service) Delete<%= ModuleName %>(ctx *gin.Context, id int64) *errors.Error {
80
+ logger.Info(ctx, "Delete<%= ModuleName %>", zap.Any("id", id))
81
+ <%= moduleName %>M := internal.<%= ModuleName %>()
82
+ if e := domainx.MustGetByID(<%= moduleName %>M.Con, id, <%= moduleName %>M); e != nil {
83
+ return e
84
+ }
85
+ if e := domainx.Delete(<%= moduleName %>M.Con, <%= moduleName %>M); e != nil {
86
+ return e
87
+ }
88
+ return nil
89
+ }
90
+
91
+ func init() {
92
+ setService(gService)
93
+ }
@@ -0,0 +1,22 @@
1
+ package <%= moduleName %>
2
+
3
+ import (
4
+ "github.com/gin-gonic/gin"
5
+ "github.com/jom-io/gorig/apix/load"
6
+ "github.com/jom-io/gorig/utils/errors"
7
+ "<%= projectName %>/domain/<%= moduleName %>/api/req"
8
+ )
9
+
10
+ var GService <%= moduleName %>Service
11
+
12
+ func setService(s <%= moduleName %>Service) {
13
+ GService = s
14
+ }
15
+
16
+ type <%= moduleName %>Service interface {
17
+ Save<%= moduleName.charAt(0).toUpperCase() + moduleName.slice(1) %>(ctx *gin.Context, req *req.<%= moduleName.charAt(0).toUpperCase() + moduleName.slice(1) %>Req) *errors.Error
18
+ Page<%= moduleName.charAt(0).toUpperCase() + moduleName.slice(1) %>(ctx *gin.Context, pageReq *load.Page, filter *req.<%= moduleName.charAt(0).toUpperCase() + moduleName.slice(1) %>Req) (*load.PageResp, *errors.Error)
19
+ List<%= moduleName.charAt(0).toUpperCase() + moduleName.slice(1) %>(ctx *gin.Context, filter *req.<%= moduleName.charAt(0).toUpperCase() + moduleName.slice(1) %>Req) ([]*req.<%= moduleName.charAt(0).toUpperCase() + moduleName.slice(1) %>Resp, *errors.Error)
20
+ Get<%= moduleName.charAt(0).toUpperCase() + moduleName.slice(1) %>(ctx *gin.Context, id int64) (*req.<%= moduleName.charAt(0).toUpperCase() + moduleName.slice(1) %>Resp, *errors.Error)
21
+ Delete<%= moduleName.charAt(0).toUpperCase() + moduleName.slice(1) %>(ctx *gin.Context, id int64) *errors.Error
22
+ }
package/yarn-error.log ADDED
@@ -0,0 +1,208 @@
1
+ Arguments:
2
+ /usr/local/bin/node /opt/homebrew/Cellar/yarn/1.22.19/libexec/bin/yarn.js publish
3
+
4
+ PATH:
5
+ /Users/doz/.docker/bin:/Users/doz/.rbenv/shims:/Users/doz/.rbenv/shims:/Users/doz/.rbenv/shims:/Users/doz/.rbenv/bin:/Users/doz/.docker/bin:/Users/doz/.local/share/solana/install/active_release/bin:/Users/doz/.rbenv/shims:/Users/doz/.rbenv/bin:/Users/doz/.docker/bin:/Users/doz/Library/Java/JavaVirtualMachines/corretto-1.8.0_352/Contents/Home/bin:/Users/doz/.local/share/solana/install/active_release/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Users/doz/.docker/bin:/Users/doz/.rbenv/shims:/Users/doz/.rbenv/bin:/Users/doz/.local/share/solana/install/active_release/bin:/Users/doz/Library/Java/JavaVirtualMachines/corretto-1.8.0_352/Contents/Home/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/doz/.cargo/bin:.:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/bin:/Users/doz/Library/Android/sdk/tools:/Users/doz/Library/Android/sdk/platform-tools:.:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/bin:/Users/doz/Library/Android/sdk/tools:/Users/doz/Library/Android/sdk/platform-tools
6
+
7
+ Yarn version:
8
+ 1.22.19
9
+
10
+ Node version:
11
+ 21.1.0
12
+
13
+ Platform:
14
+ darwin arm64
15
+
16
+ Trace:
17
+ Error: https://mirrors.huaweicloud.com/repository/npm/-/user/org.couchdb.user:jom-io: Incorrect username or password!
18
+ at params.callback [as _callback] (/opt/homebrew/Cellar/yarn/1.22.19/libexec/lib/cli.js:66145:18)
19
+ at self.callback (/opt/homebrew/Cellar/yarn/1.22.19/libexec/lib/cli.js:140890:22)
20
+ at Request.emit (node:events:515:28)
21
+ at Request.<anonymous> (/opt/homebrew/Cellar/yarn/1.22.19/libexec/lib/cli.js:141862:10)
22
+ at Request.emit (node:events:515:28)
23
+ at IncomingMessage.<anonymous> (/opt/homebrew/Cellar/yarn/1.22.19/libexec/lib/cli.js:141784:12)
24
+ at Object.onceWrapper (node:events:629:28)
25
+ at IncomingMessage.emit (node:events:527:35)
26
+ at endReadableNT (node:internal/streams/readable:1589:12)
27
+ at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
28
+
29
+ npm manifest:
30
+ {
31
+ "name": "gorig-cli",
32
+ "version": "1.0.0",
33
+ "type": "module",
34
+ "description": "gorig构建工具",
35
+ "main": "bin/cli.js",
36
+ "bin": {
37
+ "gorig-cli": "./bin/cli.js"
38
+ },
39
+ "scripts": {
40
+ "start": "node bin/cli.js"
41
+ },
42
+ "keywords": [
43
+ "go",
44
+ "cli",
45
+ "gorig"
46
+ ],
47
+ "author": "jom",
48
+ "license": "MIT",
49
+ "dependencies": {
50
+ "chalk": "^5.3.0",
51
+ "commander": "^12.1.0",
52
+ "ejs": "^3.1.10",
53
+ "fs-extra": "^11.2.0"
54
+ }
55
+ }
56
+
57
+ yarn manifest:
58
+ No manifest
59
+
60
+ Lockfile:
61
+ # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
62
+ # yarn lockfile v1
63
+
64
+
65
+ ansi-styles@^4.1.0:
66
+ version "4.3.0"
67
+ resolved "https://mirrors.huaweicloud.com/repository/npm/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937"
68
+ integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==
69
+ dependencies:
70
+ color-convert "^2.0.1"
71
+
72
+ async@^3.2.3:
73
+ version "3.2.6"
74
+ resolved "https://mirrors.huaweicloud.com/repository/npm/async/-/async-3.2.6.tgz#1b0728e14929d51b85b449b7f06e27c1145e38ce"
75
+ integrity sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==
76
+
77
+ balanced-match@^1.0.0:
78
+ version "1.0.2"
79
+ resolved "https://mirrors.huaweicloud.com/repository/npm/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
80
+ integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
81
+
82
+ brace-expansion@^1.1.7:
83
+ version "1.1.11"
84
+ resolved "https://mirrors.huaweicloud.com/repository/npm/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
85
+ integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
86
+ dependencies:
87
+ balanced-match "^1.0.0"
88
+ concat-map "0.0.1"
89
+
90
+ brace-expansion@^2.0.1:
91
+ version "2.0.1"
92
+ resolved "https://mirrors.huaweicloud.com/repository/npm/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae"
93
+ integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==
94
+ dependencies:
95
+ balanced-match "^1.0.0"
96
+
97
+ chalk@^4.0.2:
98
+ version "4.1.2"
99
+ resolved "https://mirrors.huaweicloud.com/repository/npm/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
100
+ integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
101
+ dependencies:
102
+ ansi-styles "^4.1.0"
103
+ supports-color "^7.1.0"
104
+
105
+ chalk@^5.3.0:
106
+ version "5.3.0"
107
+ resolved "https://mirrors.huaweicloud.com/repository/npm/chalk/-/chalk-5.3.0.tgz#67c20a7ebef70e7f3970a01f90fa210cb6860385"
108
+ integrity sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==
109
+
110
+ color-convert@^2.0.1:
111
+ version "2.0.1"
112
+ resolved "https://mirrors.huaweicloud.com/repository/npm/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3"
113
+ integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==
114
+ dependencies:
115
+ color-name "~1.1.4"
116
+
117
+ color-name@~1.1.4:
118
+ version "1.1.4"
119
+ resolved "https://mirrors.huaweicloud.com/repository/npm/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
120
+ integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
121
+
122
+ commander@^12.1.0:
123
+ version "12.1.0"
124
+ resolved "https://mirrors.huaweicloud.com/repository/npm/commander/-/commander-12.1.0.tgz#01423b36f501259fdaac4d0e4d60c96c991585d3"
125
+ integrity sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==
126
+
127
+ concat-map@0.0.1:
128
+ version "0.0.1"
129
+ resolved "https://mirrors.huaweicloud.com/repository/npm/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
130
+ integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==
131
+
132
+ ejs@^3.1.10:
133
+ version "3.1.10"
134
+ resolved "https://mirrors.huaweicloud.com/repository/npm/ejs/-/ejs-3.1.10.tgz#69ab8358b14e896f80cc39e62087b88500c3ac3b"
135
+ integrity sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==
136
+ dependencies:
137
+ jake "^10.8.5"
138
+
139
+ filelist@^1.0.4:
140
+ version "1.0.4"
141
+ resolved "https://mirrors.huaweicloud.com/repository/npm/filelist/-/filelist-1.0.4.tgz#f78978a1e944775ff9e62e744424f215e58352b5"
142
+ integrity sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==
143
+ dependencies:
144
+ minimatch "^5.0.1"
145
+
146
+ fs-extra@^11.2.0:
147
+ version "11.2.0"
148
+ resolved "https://mirrors.huaweicloud.com/repository/npm/fs-extra/-/fs-extra-11.2.0.tgz#e70e17dfad64232287d01929399e0ea7c86b0e5b"
149
+ integrity sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==
150
+ dependencies:
151
+ graceful-fs "^4.2.0"
152
+ jsonfile "^6.0.1"
153
+ universalify "^2.0.0"
154
+
155
+ graceful-fs@^4.1.6, graceful-fs@^4.2.0:
156
+ version "4.2.11"
157
+ resolved "https://mirrors.huaweicloud.com/repository/npm/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3"
158
+ integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==
159
+
160
+ has-flag@^4.0.0:
161
+ version "4.0.0"
162
+ resolved "https://mirrors.huaweicloud.com/repository/npm/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
163
+ integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==
164
+
165
+ jake@^10.8.5:
166
+ version "10.9.2"
167
+ resolved "https://mirrors.huaweicloud.com/repository/npm/jake/-/jake-10.9.2.tgz#6ae487e6a69afec3a5e167628996b59f35ae2b7f"
168
+ integrity sha512-2P4SQ0HrLQ+fw6llpLnOaGAvN2Zu6778SJMrCUwns4fOoG9ayrTiZk3VV8sCPkVZF8ab0zksVpS8FDY5pRCNBA==
169
+ dependencies:
170
+ async "^3.2.3"
171
+ chalk "^4.0.2"
172
+ filelist "^1.0.4"
173
+ minimatch "^3.1.2"
174
+
175
+ jsonfile@^6.0.1:
176
+ version "6.1.0"
177
+ resolved "https://mirrors.huaweicloud.com/repository/npm/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae"
178
+ integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==
179
+ dependencies:
180
+ universalify "^2.0.0"
181
+ optionalDependencies:
182
+ graceful-fs "^4.1.6"
183
+
184
+ minimatch@^3.1.2:
185
+ version "3.1.2"
186
+ resolved "https://mirrors.huaweicloud.com/repository/npm/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
187
+ integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==
188
+ dependencies:
189
+ brace-expansion "^1.1.7"
190
+
191
+ minimatch@^5.0.1:
192
+ version "5.1.6"
193
+ resolved "https://mirrors.huaweicloud.com/repository/npm/minimatch/-/minimatch-5.1.6.tgz#1cfcb8cf5522ea69952cd2af95ae09477f122a96"
194
+ integrity sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==
195
+ dependencies:
196
+ brace-expansion "^2.0.1"
197
+
198
+ supports-color@^7.1.0:
199
+ version "7.2.0"
200
+ resolved "https://mirrors.huaweicloud.com/repository/npm/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da"
201
+ integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==
202
+ dependencies:
203
+ has-flag "^4.0.0"
204
+
205
+ universalify@^2.0.0:
206
+ version "2.0.1"
207
+ resolved "https://mirrors.huaweicloud.com/repository/npm/universalify/-/universalify-2.0.1.tgz#168efc2180964e6386d061e094df61afe239b18d"
208
+ integrity sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==