正在显示
12 个修改的文件
包含
36 行增加
和
22 行删除
allied-creation-basic.exe
已删除
100644 → 0
不能预览此文件类型
| @@ -2,6 +2,7 @@ package main | @@ -2,6 +2,7 @@ package main | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "github.com/beego/beego/v2/server/web" | 4 | "github.com/beego/beego/v2/server/web" |
| 5 | + _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/port/beego/routers" | ||
| 5 | ) | 6 | ) |
| 6 | 7 | ||
| 7 | func main() { | 8 | func main() { |
| @@ -4,6 +4,7 @@ import ( | @@ -4,6 +4,7 @@ import ( | ||
| 4 | "fmt" | 4 | "fmt" |
| 5 | 5 | ||
| 6 | "github.com/beego/beego/v2/core/validation" | 6 | "github.com/beego/beego/v2/core/validation" |
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/domain" | ||
| 7 | ) | 8 | ) |
| 8 | 9 | ||
| 9 | type CreateDictionaryCommand struct { | 10 | type CreateDictionaryCommand struct { |
| @@ -18,7 +19,7 @@ type CreateDictionaryCommand struct { | @@ -18,7 +19,7 @@ type CreateDictionaryCommand struct { | ||
| 18 | // 是否可见【1:不可以】【2:可以】 | 19 | // 是否可见【1:不可以】【2:可以】 |
| 19 | IsShow int `json:"isShow,omitempty"` | 20 | IsShow int `json:"isShow,omitempty"` |
| 20 | // 字典值列表 | 21 | // 字典值列表 |
| 21 | - DictItems []*DictionaryItem `json:"dictItems,omitempty"` | 22 | + DictItems []*domain.DictionaryItem `json:"dictItems,omitempty"` |
| 22 | } | 23 | } |
| 23 | 24 | ||
| 24 | func (createDictionaryCommand *CreateDictionaryCommand) Valid(validation *validation.Validation) { | 25 | func (createDictionaryCommand *CreateDictionaryCommand) Valid(validation *validation.Validation) { |
| @@ -4,11 +4,12 @@ import ( | @@ -4,11 +4,12 @@ import ( | ||
| 4 | "fmt" | 4 | "fmt" |
| 5 | 5 | ||
| 6 | "github.com/beego/beego/v2/core/validation" | 6 | "github.com/beego/beego/v2/core/validation" |
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/domain" | ||
| 7 | ) | 8 | ) |
| 8 | 9 | ||
| 9 | type UpdateDictionaryCommand struct { | 10 | type UpdateDictionaryCommand struct { |
| 10 | // 字典编号 主键 | 11 | // 字典编号 主键 |
| 11 | - DictionaryId int `json:"dictionaryId,omitempty"` | 12 | + DictionaryId int64 `json:"dictionaryId,omitempty"` |
| 12 | // 字典编码 | 13 | // 字典编码 |
| 13 | DictCode string `json:"dictCode,omitempty"` | 14 | DictCode string `json:"dictCode,omitempty"` |
| 14 | // 字典名称 | 15 | // 字典名称 |
| @@ -18,7 +19,7 @@ type UpdateDictionaryCommand struct { | @@ -18,7 +19,7 @@ type UpdateDictionaryCommand struct { | ||
| 18 | // 是否可见【1:不可以】【2:可以】 | 19 | // 是否可见【1:不可以】【2:可以】 |
| 19 | IsShow int `json:"isShow,omitempty"` | 20 | IsShow int `json:"isShow,omitempty"` |
| 20 | // 字典值列表 | 21 | // 字典值列表 |
| 21 | - DictItems []*DictionaryItem `json:"dictItems,omitempty"` | 22 | + DictItems []*domain.DictionaryItem `json:"dictItems,omitempty"` |
| 22 | } | 23 | } |
| 23 | 24 | ||
| 24 | func (updateDictionaryCommand *UpdateDictionaryCommand) Valid(validation *validation.Validation) { | 25 | func (updateDictionaryCommand *UpdateDictionaryCommand) Valid(validation *validation.Validation) { |
| @@ -8,6 +8,7 @@ import ( | @@ -8,6 +8,7 @@ import ( | ||
| 8 | 8 | ||
| 9 | type GetDictionaryQuery struct { | 9 | type GetDictionaryQuery struct { |
| 10 | // 字典编码 | 10 | // 字典编码 |
| 11 | + DictionaryId int64 `json:"dictionaryId"` | ||
| 11 | DictCode string `json:"dictCode,omitempty"` | 12 | DictCode string `json:"dictCode,omitempty"` |
| 12 | } | 13 | } |
| 13 | 14 |
| 1 | package service | 1 | package service |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | + "fmt" | ||
| 5 | + | ||
| 4 | "github.com/linmadan/egglib-go/core/application" | 6 | "github.com/linmadan/egglib-go/core/application" |
| 5 | "github.com/linmadan/egglib-go/utils/tool_funs" | 7 | "github.com/linmadan/egglib-go/utils/tool_funs" |
| 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/dictionary/command" | 8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/dictionary/command" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/dictionary/query" | 9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/dictionary/query" |
| 8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/factory" | 10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/factory" |
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/domain" | ||
| 9 | ) | 12 | ) |
| 10 | 13 | ||
| 11 | // 数据字典设置 | 14 | // 数据字典设置 |
| @@ -27,10 +30,8 @@ func (dictionaryService *DictionaryService) CreateDictionary(createDictionaryCom | @@ -27,10 +30,8 @@ func (dictionaryService *DictionaryService) CreateDictionary(createDictionaryCom | ||
| 27 | defer func() { | 30 | defer func() { |
| 28 | transactionContext.RollbackTransaction() | 31 | transactionContext.RollbackTransaction() |
| 29 | }() | 32 | }() |
| 30 | - newDictionary := &dictionary.Dictionary{ | ||
| 31 | - Dictionary: createDictionaryCommand.Dictionary, | ||
| 32 | - } | ||
| 33 | - var dictionaryRepository dictionary.DictionaryRepository | 33 | + newDictionary := &domain.Dictionary{} //TODO |
| 34 | + var dictionaryRepository domain.DictionaryRepository | ||
| 34 | if value, err := factory.CreateDictionaryRepository(map[string]interface{}{ | 35 | if value, err := factory.CreateDictionaryRepository(map[string]interface{}{ |
| 35 | "transactionContext": transactionContext, | 36 | "transactionContext": transactionContext, |
| 36 | }); err != nil { | 37 | }); err != nil { |
| @@ -63,7 +64,7 @@ func (dictionaryService *DictionaryService) GetDictionary(getDictionaryQuery *qu | @@ -63,7 +64,7 @@ func (dictionaryService *DictionaryService) GetDictionary(getDictionaryQuery *qu | ||
| 63 | defer func() { | 64 | defer func() { |
| 64 | transactionContext.RollbackTransaction() | 65 | transactionContext.RollbackTransaction() |
| 65 | }() | 66 | }() |
| 66 | - var dictionaryRepository dictionary.DictionaryRepository | 67 | + var dictionaryRepository domain.DictionaryRepository |
| 67 | if value, err := factory.CreateDictionaryRepository(map[string]interface{}{ | 68 | if value, err := factory.CreateDictionaryRepository(map[string]interface{}{ |
| 68 | "transactionContext": transactionContext, | 69 | "transactionContext": transactionContext, |
| 69 | }); err != nil { | 70 | }); err != nil { |
| @@ -71,12 +72,12 @@ func (dictionaryService *DictionaryService) GetDictionary(getDictionaryQuery *qu | @@ -71,12 +72,12 @@ func (dictionaryService *DictionaryService) GetDictionary(getDictionaryQuery *qu | ||
| 71 | } else { | 72 | } else { |
| 72 | dictionaryRepository = value | 73 | dictionaryRepository = value |
| 73 | } | 74 | } |
| 74 | - dictionary, err := dictionaryRepository.FindOne(map[string]interface{}{"dictionaryId": getDictionaryQuery.DictionaryId}) | 75 | + dictionary, err := dictionaryRepository.FindOne(map[string]interface{}{"dictionaryId": getDictionaryQuery.DictCode}) |
| 75 | if err != nil { | 76 | if err != nil { |
| 76 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 77 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 77 | } | 78 | } |
| 78 | if dictionary == nil { | 79 | if dictionary == nil { |
| 79 | - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getDictionaryQuery.DictionaryId))) | 80 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getDictionaryQuery.DictCode))) |
| 80 | } else { | 81 | } else { |
| 81 | if err := transactionContext.CommitTransaction(); err != nil { | 82 | if err := transactionContext.CommitTransaction(); err != nil { |
| 82 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 83 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| @@ -100,7 +101,7 @@ func (dictionaryService *DictionaryService) ListDictionary(listDictionaryQuery * | @@ -100,7 +101,7 @@ func (dictionaryService *DictionaryService) ListDictionary(listDictionaryQuery * | ||
| 100 | defer func() { | 101 | defer func() { |
| 101 | transactionContext.RollbackTransaction() | 102 | transactionContext.RollbackTransaction() |
| 102 | }() | 103 | }() |
| 103 | - var dictionaryRepository dictionary.DictionaryRepository | 104 | + var dictionaryRepository domain.DictionaryRepository |
| 104 | if value, err := factory.CreateDictionaryRepository(map[string]interface{}{ | 105 | if value, err := factory.CreateDictionaryRepository(map[string]interface{}{ |
| 105 | "transactionContext": transactionContext, | 106 | "transactionContext": transactionContext, |
| 106 | }); err != nil { | 107 | }); err != nil { |
| @@ -136,7 +137,7 @@ func (dictionaryService *DictionaryService) RemoveDictionary(removeDictionaryCom | @@ -136,7 +137,7 @@ func (dictionaryService *DictionaryService) RemoveDictionary(removeDictionaryCom | ||
| 136 | defer func() { | 137 | defer func() { |
| 137 | transactionContext.RollbackTransaction() | 138 | transactionContext.RollbackTransaction() |
| 138 | }() | 139 | }() |
| 139 | - var dictionaryRepository dictionary.DictionaryRepository | 140 | + var dictionaryRepository domain.DictionaryRepository |
| 140 | if value, err := factory.CreateDictionaryRepository(map[string]interface{}{ | 141 | if value, err := factory.CreateDictionaryRepository(map[string]interface{}{ |
| 141 | "transactionContext": transactionContext, | 142 | "transactionContext": transactionContext, |
| 142 | }); err != nil { | 143 | }); err != nil { |
| @@ -176,7 +177,7 @@ func (dictionaryService *DictionaryService) UpdateDictionary(updateDictionaryCom | @@ -176,7 +177,7 @@ func (dictionaryService *DictionaryService) UpdateDictionary(updateDictionaryCom | ||
| 176 | defer func() { | 177 | defer func() { |
| 177 | transactionContext.RollbackTransaction() | 178 | transactionContext.RollbackTransaction() |
| 178 | }() | 179 | }() |
| 179 | - var dictionaryRepository dictionary.DictionaryRepository | 180 | + var dictionaryRepository domain.DictionaryRepository |
| 180 | if value, err := factory.CreateDictionaryRepository(map[string]interface{}{ | 181 | if value, err := factory.CreateDictionaryRepository(map[string]interface{}{ |
| 181 | "transactionContext": transactionContext, | 182 | "transactionContext": transactionContext, |
| 182 | }); err != nil { | 183 | }); err != nil { |
| @@ -3,7 +3,7 @@ package domain | @@ -3,7 +3,7 @@ package domain | ||
| 3 | // 字典 | 3 | // 字典 |
| 4 | type Dictionary struct { | 4 | type Dictionary struct { |
| 5 | // 字典编号 主键 | 5 | // 字典编号 主键 |
| 6 | - DictionaryId int `json:"dictionaryId"` | 6 | + DictionaryId int64 `json:"dictionaryId"` |
| 7 | // 字典编码 | 7 | // 字典编码 |
| 8 | DictCode string `json:"dictCode"` | 8 | DictCode string `json:"dictCode"` |
| 9 | // 字典名称 | 9 | // 字典名称 |
| @@ -32,7 +32,7 @@ func (dictionary *Dictionary) Identify() interface{} { | @@ -32,7 +32,7 @@ func (dictionary *Dictionary) Identify() interface{} { | ||
| 32 | 32 | ||
| 33 | func (dictionary *Dictionary) Update(data map[string]interface{}) error { | 33 | func (dictionary *Dictionary) Update(data map[string]interface{}) error { |
| 34 | if dictionaryId, ok := data["dictionaryId"]; ok { | 34 | if dictionaryId, ok := data["dictionaryId"]; ok { |
| 35 | - dictionary.DictionaryId = dictionaryId.(int) | 35 | + dictionary.DictionaryId = dictionaryId.(int64) |
| 36 | } | 36 | } |
| 37 | if dictCode, ok := data["dictCode"]; ok { | 37 | if dictCode, ok := data["dictCode"]; ok { |
| 38 | dictionary.DictCode = dictCode.(string) | 38 | dictionary.DictCode = dictCode.(string) |
| 1 | package models | 1 | package models |
| 2 | 2 | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/domain" | ||
| 5 | +) | ||
| 6 | + | ||
| 3 | type Dictionary struct { | 7 | type Dictionary struct { |
| 4 | tableName string `pg:"dictionarys,alias:dictionary"` | 8 | tableName string `pg:"dictionarys,alias:dictionary"` |
| 5 | // 字典编号 主键 | 9 | // 字典编号 主键 |
| 6 | - DictionaryId int | 10 | + DictionaryId int64 `pg:",pk"` |
| 7 | // 字典编码 | 11 | // 字典编码 |
| 8 | DictCode string | 12 | DictCode string |
| 9 | // 字典名称 | 13 | // 字典名称 |
| @@ -13,5 +17,5 @@ type Dictionary struct { | @@ -13,5 +17,5 @@ type Dictionary struct { | ||
| 13 | // 是否可见【1:不可以】【2:可以】 | 17 | // 是否可见【1:不可以】【2:可以】 |
| 14 | IsShow int | 18 | IsShow int |
| 15 | // 字典值列表 | 19 | // 字典值列表 |
| 16 | - DictItems []*DictionaryItem `pg:",array"` | 20 | + DictItems []*domain.DictionaryItem `pg:",array"` |
| 17 | } | 21 | } |
| @@ -3,6 +3,7 @@ package repository | @@ -3,6 +3,7 @@ package repository | ||
| 3 | import ( | 3 | import ( |
| 4 | "fmt" | 4 | "fmt" |
| 5 | 5 | ||
| 6 | + "github.com/go-pg/pg/v10" | ||
| 6 | "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" | 7 | "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" |
| 7 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | 8 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" |
| 8 | "github.com/linmadan/egglib-go/utils/snowflake" | 9 | "github.com/linmadan/egglib-go/utils/snowflake" |
| 1 | package beego | 1 | package beego |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | + "os" | ||
| 5 | + "strconv" | ||
| 6 | + | ||
| 4 | "github.com/beego/beego/v2/server/web" | 7 | "github.com/beego/beego/v2/server/web" |
| 5 | "github.com/linmadan/egglib-go/web/beego/filters" | 8 | "github.com/linmadan/egglib-go/web/beego/filters" |
| 6 | 9 | ||
| 7 | //_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/port/beego/routers" | 10 | //_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/port/beego/routers" |
| 8 | - . "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/log" | 11 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/log" |
| 9 | ) | 12 | ) |
| 10 | 13 | ||
| 11 | func init() { | 14 | func init() { |
| @@ -25,6 +28,6 @@ func init() { | @@ -25,6 +28,6 @@ func init() { | ||
| 25 | } | 28 | } |
| 26 | } | 29 | } |
| 27 | web.InsertFilter("/*", web.BeforeExec, filters.AllowCors()) | 30 | web.InsertFilter("/*", web.BeforeExec, filters.AllowCors()) |
| 28 | - web.InsertFilter("/*", web.BeforeExec, filters.CreateRequstLogFilter(Logger)) | ||
| 29 | - web.InsertFilter("/*", web.AfterExec, filters.CreateResponseLogFilter(Logger), web.WithReturnOnOutput(false)) | 31 | + web.InsertFilter("/*", web.BeforeExec, filters.CreateRequstLogFilter(log.Logger)) |
| 32 | + web.InsertFilter("/*", web.AfterExec, filters.CreateResponseLogFilter(log.Logger), web.WithReturnOnOutput(false)) | ||
| 30 | } | 33 | } |
| @@ -23,7 +23,7 @@ func (controller *DictionaryController) UpdateDictionary() { | @@ -23,7 +23,7 @@ func (controller *DictionaryController) UpdateDictionary() { | ||
| 23 | dictionaryService := service.NewDictionaryService(nil) | 23 | dictionaryService := service.NewDictionaryService(nil) |
| 24 | updateDictionaryCommand := &command.UpdateDictionaryCommand{} | 24 | updateDictionaryCommand := &command.UpdateDictionaryCommand{} |
| 25 | controller.Unmarshal(updateDictionaryCommand) | 25 | controller.Unmarshal(updateDictionaryCommand) |
| 26 | - dictionaryId, _ := controller.GetString(":dictionaryId") | 26 | + dictionaryId, _ := controller.GetInt64(":dictionaryId") |
| 27 | updateDictionaryCommand.DictionaryId = dictionaryId | 27 | updateDictionaryCommand.DictionaryId = dictionaryId |
| 28 | data, err := dictionaryService.UpdateDictionary(updateDictionaryCommand) | 28 | data, err := dictionaryService.UpdateDictionary(updateDictionaryCommand) |
| 29 | controller.Response(data, err) | 29 | controller.Response(data, err) |
| @@ -32,7 +32,7 @@ func (controller *DictionaryController) UpdateDictionary() { | @@ -32,7 +32,7 @@ func (controller *DictionaryController) UpdateDictionary() { | ||
| 32 | func (controller *DictionaryController) GetDictionary() { | 32 | func (controller *DictionaryController) GetDictionary() { |
| 33 | dictionaryService := service.NewDictionaryService(nil) | 33 | dictionaryService := service.NewDictionaryService(nil) |
| 34 | getDictionaryQuery := &query.GetDictionaryQuery{} | 34 | getDictionaryQuery := &query.GetDictionaryQuery{} |
| 35 | - dictionaryId, _ := controller.GetString(":dictionaryId") | 35 | + dictionaryId, _ := controller.GetInt64(":dictionaryId") |
| 36 | getDictionaryQuery.DictionaryId = dictionaryId | 36 | getDictionaryQuery.DictionaryId = dictionaryId |
| 37 | data, err := dictionaryService.GetDictionary(getDictionaryQuery) | 37 | data, err := dictionaryService.GetDictionary(getDictionaryQuery) |
| 38 | controller.Response(data, err) | 38 | controller.Response(data, err) |
-
请 注册 或 登录 后发表评论