正在显示
11 个修改的文件
包含
465 行增加
和
2 行删除
| 1 | +package command | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_basic" | ||
| 6 | +) | ||
| 7 | + | ||
| 8 | +type CreateDictionaryCommand struct { | ||
| 9 | + //操作人 | ||
| 10 | + Operator domain.Operator `json:"-"` | ||
| 11 | + allied_creation_basic.ReqDictionaryAdd | ||
| 12 | +} |
| 1 | +package command | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_basic" | ||
| 6 | +) | ||
| 7 | + | ||
| 8 | +type UpdateDictionaryCommand struct { | ||
| 9 | + //操作人 | ||
| 10 | + Operator domain.Operator `json:"-"` | ||
| 11 | + allied_creation_basic.ReqDictionaryUpdate | ||
| 12 | +} |
| 1 | +package service | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/linmadan/egglib-go/core/application" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/dictionary/command" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/dictionary/query" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_basic" | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +// 字典服务 | ||
| 11 | +type DictionayService struct { | ||
| 12 | +} | ||
| 13 | + | ||
| 14 | +func NewDictionayService(options map[string]interface{}) *DictionayService { | ||
| 15 | + return &DictionayService{} | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +// 创建字典 | ||
| 19 | +func (dictionaryService *DictionayService) CreateDictionay(createCommand *command.CreateDictionaryCommand) (interface{}, error) { | ||
| 20 | + creationBasicGateway := allied_creation_basic.NewHttplibAlliedCreationBasic( | ||
| 21 | + createCommand.Operator) | ||
| 22 | + result, err := creationBasicGateway.DictionaryAdd(allied_creation_basic.ReqDictionaryAdd{ | ||
| 23 | + DictCode: createCommand.DictCode, | ||
| 24 | + DictName: createCommand.DictName, | ||
| 25 | + Describe: createCommand.Describe, | ||
| 26 | + DictItems: createCommand.DictItems, | ||
| 27 | + }) | ||
| 28 | + if err != nil { | ||
| 29 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
| 30 | + } | ||
| 31 | + return result, nil | ||
| 32 | +} | ||
| 33 | + | ||
| 34 | +// 更新字典 | ||
| 35 | +func (dictionaryService *DictionayService) UpdateDictionay(updateCommand *command.UpdateDictionaryCommand) (interface{}, error) { | ||
| 36 | + creationBasicGateway := allied_creation_basic.NewHttplibAlliedCreationBasic( | ||
| 37 | + updateCommand.Operator) | ||
| 38 | + result, err := creationBasicGateway.DictionaryUpdate(allied_creation_basic.ReqDictionaryUpdate{ | ||
| 39 | + DictionaryId: updateCommand.DictionaryId, | ||
| 40 | + DictCode: updateCommand.DictCode, | ||
| 41 | + DictName: updateCommand.DictName, | ||
| 42 | + Describe: updateCommand.Describe, | ||
| 43 | + DictItems: updateCommand.DictItems, | ||
| 44 | + }) | ||
| 45 | + if err != nil { | ||
| 46 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
| 47 | + } | ||
| 48 | + return result, nil | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | +//获取字典 | ||
| 52 | +func (dictionaryService *DictionayService) GetDictionay(getQuery *query.GetDictionaryQuery) (interface{}, error) { | ||
| 53 | + creationBasicGateway := allied_creation_basic.NewHttplibAlliedCreationBasic( | ||
| 54 | + getQuery.Operator) | ||
| 55 | + result, err := creationBasicGateway.DictionaryGet(allied_creation_basic.ReqDictionaryGet{ | ||
| 56 | + DictionaryId: getQuery.DictionaryId, | ||
| 57 | + }) | ||
| 58 | + if err != nil { | ||
| 59 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
| 60 | + } | ||
| 61 | + return result, nil | ||
| 62 | +} | ||
| 63 | + | ||
| 64 | +//获取字典 | ||
| 65 | +func (dictionaryService *DictionayService) RemoveDictionay(removeCommand *command.RemoveDictionaryCommand) (interface{}, error) { | ||
| 66 | + creationBasicGateway := allied_creation_basic.NewHttplibAlliedCreationBasic( | ||
| 67 | + removeCommand.Operator) | ||
| 68 | + result, err := creationBasicGateway.DictionaryGet(allied_creation_basic.ReqDictionaryGet{ | ||
| 69 | + DictionaryId: removeCommand.DictionaryId, | ||
| 70 | + }) | ||
| 71 | + if err != nil { | ||
| 72 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
| 73 | + } | ||
| 74 | + return result, nil | ||
| 75 | +} | ||
| 76 | + | ||
| 77 | +//获取字典 | ||
| 78 | +func (dictionaryService *DictionayService) ListDictionay(searchQuery *query.ListDictionaryQuery) (interface{}, error) { | ||
| 79 | + creationBasicGateway := allied_creation_basic.NewHttplibAlliedCreationBasic( | ||
| 80 | + searchQuery.Operator) | ||
| 81 | + result, err := creationBasicGateway.DictionarySearch(allied_creation_basic.ReqDictionarySearch{ | ||
| 82 | + Pageindex: searchQuery.Pageindex, | ||
| 83 | + PageSize: searchQuery.PageSize, | ||
| 84 | + }) | ||
| 85 | + if err != nil { | ||
| 86 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
| 87 | + } | ||
| 88 | + return result, nil | ||
| 89 | +} |
| @@ -3,6 +3,7 @@ package allied_creation_basic | @@ -3,6 +3,7 @@ package allied_creation_basic | ||
| 3 | import ( | 3 | import ( |
| 4 | "encoding/json" | 4 | "encoding/json" |
| 5 | "fmt" | 5 | "fmt" |
| 6 | + "strconv" | ||
| 6 | 7 | ||
| 7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log" | 8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log" |
| 8 | 9 | ||
| @@ -40,3 +41,163 @@ func (gateway HttplibAlliedCreationBasic) GetDictionarysByCode(param ReqGetDicti | @@ -40,3 +41,163 @@ func (gateway HttplibAlliedCreationBasic) GetDictionarysByCode(param ReqGetDicti | ||
| 40 | err = gateway.GetResponseData(result, &data) | 41 | err = gateway.GetResponseData(result, &data) |
| 41 | return &data, err | 42 | return &data, err |
| 42 | } | 43 | } |
| 44 | + | ||
| 45 | +//DictionaryAdd 添加字典 | ||
| 46 | +func (gateway HttplibAlliedCreationBasic) DictionaryAdd(param ReqDictionaryAdd) (*DataDictionaryAdd, error) { | ||
| 47 | + url := gateway.baseUrL + "/dictionarys" | ||
| 48 | + method := "post" | ||
| 49 | + req := gateway.CreateRequest(url, method) | ||
| 50 | + //TODO traceID | ||
| 51 | + log.Logger.Debug("向基础模块请求数据:添加字典。", map[string]interface{}{ | ||
| 52 | + "api": method + ":" + url, | ||
| 53 | + "param": param, | ||
| 54 | + }) | ||
| 55 | + req, err := req.JSONBody(param) | ||
| 56 | + if err != nil { | ||
| 57 | + return nil, fmt.Errorf("请求添加字典失败:%w", err) | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + byteResult, err := req.Bytes() | ||
| 61 | + if err != nil { | ||
| 62 | + return nil, fmt.Errorf("获取添加字典数据失败:%w", err) | ||
| 63 | + } | ||
| 64 | + log.Logger.Debug("获取基础模块响应数据:添加字典数据。", map[string]interface{}{ | ||
| 65 | + "result": string(byteResult), | ||
| 66 | + }) | ||
| 67 | + var result service_gateway.GatewayResponse | ||
| 68 | + err = json.Unmarshal(byteResult, &result) | ||
| 69 | + if err != nil { | ||
| 70 | + return nil, fmt.Errorf("解析添加字典数据失败:%w", err) | ||
| 71 | + } | ||
| 72 | + var data DataDictionaryAdd | ||
| 73 | + err = gateway.GetResponseData(result, &data) | ||
| 74 | + return &data, err | ||
| 75 | +} | ||
| 76 | + | ||
| 77 | +//DictionaryUpdate 更新字典 | ||
| 78 | +func (gateway HttplibAlliedCreationBasic) DictionaryUpdate(param ReqDictionaryUpdate) (*DataDictionaryUpdate, error) { | ||
| 79 | + url := gateway.baseUrL + "/dictionarys/" + strconv.Itoa(int(param.DictionaryId)) | ||
| 80 | + method := "PUT" | ||
| 81 | + req := gateway.CreateRequest(url, method) | ||
| 82 | + //TODO traceID | ||
| 83 | + log.Logger.Debug("向基础模块请求数据:更新字典。", map[string]interface{}{ | ||
| 84 | + "api": method + ":" + url, | ||
| 85 | + "param": param, | ||
| 86 | + }) | ||
| 87 | + req, err := req.JSONBody(param) | ||
| 88 | + if err != nil { | ||
| 89 | + return nil, fmt.Errorf("请求更新字典失败:%w", err) | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + byteResult, err := req.Bytes() | ||
| 93 | + if err != nil { | ||
| 94 | + return nil, fmt.Errorf("获取更新字典数据失败:%w", err) | ||
| 95 | + } | ||
| 96 | + log.Logger.Debug("获取基础模块响应数据:更新字典数据。", map[string]interface{}{ | ||
| 97 | + "result": string(byteResult), | ||
| 98 | + }) | ||
| 99 | + var result service_gateway.GatewayResponse | ||
| 100 | + err = json.Unmarshal(byteResult, &result) | ||
| 101 | + if err != nil { | ||
| 102 | + return nil, fmt.Errorf("解析更新字典数据失败:%w", err) | ||
| 103 | + } | ||
| 104 | + var data DataDictionaryUpdate | ||
| 105 | + err = gateway.GetResponseData(result, &data) | ||
| 106 | + return &data, err | ||
| 107 | +} | ||
| 108 | + | ||
| 109 | +//DictionaryGet 获取字典 | ||
| 110 | +func (gateway HttplibAlliedCreationBasic) DictionaryGet(param ReqDictionaryGet) (*DataDictionaryGet, error) { | ||
| 111 | + url := gateway.baseUrL + "/dictionarys/" + strconv.Itoa(int(param.DictionaryId)) | ||
| 112 | + method := "GET" | ||
| 113 | + req := gateway.CreateRequest(url, method) | ||
| 114 | + //TODO traceID | ||
| 115 | + log.Logger.Debug("向基础模块请求数据:获取字典。", map[string]interface{}{ | ||
| 116 | + "api": method + ":" + url, | ||
| 117 | + "param": param, | ||
| 118 | + }) | ||
| 119 | + req, err := req.JSONBody(param) | ||
| 120 | + if err != nil { | ||
| 121 | + return nil, fmt.Errorf("请求获取字典失败:%w", err) | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + byteResult, err := req.Bytes() | ||
| 125 | + if err != nil { | ||
| 126 | + return nil, fmt.Errorf("获取字典数据失败:%w", err) | ||
| 127 | + } | ||
| 128 | + log.Logger.Debug("获取基础模块响应数据:获取字典数据。", map[string]interface{}{ | ||
| 129 | + "result": string(byteResult), | ||
| 130 | + }) | ||
| 131 | + var result service_gateway.GatewayResponse | ||
| 132 | + err = json.Unmarshal(byteResult, &result) | ||
| 133 | + if err != nil { | ||
| 134 | + return nil, fmt.Errorf("解析获取字典数据失败:%w", err) | ||
| 135 | + } | ||
| 136 | + var data DataDictionaryGet | ||
| 137 | + err = gateway.GetResponseData(result, &data) | ||
| 138 | + return &data, err | ||
| 139 | +} | ||
| 140 | + | ||
| 141 | +//DictionaryRemove 删除字典 | ||
| 142 | +func (gateway HttplibAlliedCreationBasic) DictionaryRemove(param ReqDictionaryRemove) (*DataDictionaryRemove, error) { | ||
| 143 | + url := gateway.baseUrL + "/dictionarys/" + strconv.Itoa(int(param.DictionaryId)) | ||
| 144 | + method := "DELETE" | ||
| 145 | + req := gateway.CreateRequest(url, method) | ||
| 146 | + //TODO traceID | ||
| 147 | + log.Logger.Debug("向基础模块请求数据:删除字典。", map[string]interface{}{ | ||
| 148 | + "api": method + ":" + url, | ||
| 149 | + "param": param, | ||
| 150 | + }) | ||
| 151 | + req, err := req.JSONBody(param) | ||
| 152 | + if err != nil { | ||
| 153 | + return nil, fmt.Errorf("请求删除字典失败:%w", err) | ||
| 154 | + } | ||
| 155 | + | ||
| 156 | + byteResult, err := req.Bytes() | ||
| 157 | + if err != nil { | ||
| 158 | + return nil, fmt.Errorf("获取删除字典失败:%w", err) | ||
| 159 | + } | ||
| 160 | + log.Logger.Debug("获取基础模块响应数据:删除字典。", map[string]interface{}{ | ||
| 161 | + "result": string(byteResult), | ||
| 162 | + }) | ||
| 163 | + var result service_gateway.GatewayResponse | ||
| 164 | + err = json.Unmarshal(byteResult, &result) | ||
| 165 | + if err != nil { | ||
| 166 | + return nil, fmt.Errorf("解析删除字典数据失败:%w", err) | ||
| 167 | + } | ||
| 168 | + var data DataDictionaryRemove | ||
| 169 | + err = gateway.GetResponseData(result, &data) | ||
| 170 | + return &data, err | ||
| 171 | +} | ||
| 172 | + | ||
| 173 | +//DictionarySearch 查询字典 | ||
| 174 | +func (gateway HttplibAlliedCreationBasic) DictionarySearch(param ReqDictionarySearch) (*DataDictionarySearch, error) { | ||
| 175 | + url := gateway.baseUrL + "/dictionarys/search" | ||
| 176 | + method := "POST" | ||
| 177 | + req := gateway.CreateRequest(url, method) | ||
| 178 | + //TODO traceID | ||
| 179 | + log.Logger.Debug("向基础模块请求数据:查询字典。", map[string]interface{}{ | ||
| 180 | + "api": method + ":" + url, | ||
| 181 | + "param": param, | ||
| 182 | + }) | ||
| 183 | + req, err := req.JSONBody(param) | ||
| 184 | + if err != nil { | ||
| 185 | + return nil, fmt.Errorf("请求查询字典失败:%w", err) | ||
| 186 | + } | ||
| 187 | + | ||
| 188 | + byteResult, err := req.Bytes() | ||
| 189 | + if err != nil { | ||
| 190 | + return nil, fmt.Errorf("获取查询字典失败:%w", err) | ||
| 191 | + } | ||
| 192 | + log.Logger.Debug("获取基础模块响应数据:查询字典。", map[string]interface{}{ | ||
| 193 | + "result": string(byteResult), | ||
| 194 | + }) | ||
| 195 | + var result service_gateway.GatewayResponse | ||
| 196 | + err = json.Unmarshal(byteResult, &result) | ||
| 197 | + if err != nil { | ||
| 198 | + return nil, fmt.Errorf("解析查询字典失败:%w", err) | ||
| 199 | + } | ||
| 200 | + var data DataDictionarySearch | ||
| 201 | + err = gateway.GetResponseData(result, &data) | ||
| 202 | + return &data, err | ||
| 203 | +} |
| @@ -31,3 +31,77 @@ type DataGetDictionaryByCode struct { | @@ -31,3 +31,77 @@ type DataGetDictionaryByCode struct { | ||
| 31 | } `json:"dictItems"` | 31 | } `json:"dictItems"` |
| 32 | } `json:"dictionarys"` | 32 | } `json:"dictionarys"` |
| 33 | } | 33 | } |
| 34 | + | ||
| 35 | +type Dictionary struct { | ||
| 36 | + DictionaryId int64 `json:"dictionaryId,string"` // 字典编号 主键 | ||
| 37 | + DictCode string `json:"dictCode"` // 字典编码 | ||
| 38 | + DictName string `json:"dictName"` // 字典名称 | ||
| 39 | + Describe string `json:"describe"` // 备注信息 | ||
| 40 | + DictItems []DictionaryItem `json:"dictItems"` // 字典值列表 | ||
| 41 | +} | ||
| 42 | + | ||
| 43 | +// 字典明细项 | ||
| 44 | +type DictionaryItem struct { | ||
| 45 | + ItemCode string `json:"itemCode"` // 项编码 | ||
| 46 | + ItemLabel string `json:"itemLabel"` // 项标签 | ||
| 47 | + ItemValue string `json:"itemValue"` // 值 | ||
| 48 | + IsShow int `json:"isShow"` // 是否可见【1:不可以】【2:可以】 | ||
| 49 | + Sort int `json:"sort"` // 显示序号 | ||
| 50 | +} | ||
| 51 | + | ||
| 52 | +type ( | ||
| 53 | + ReqDictionarySearch struct { | ||
| 54 | + Pageindex int `json:"pageIndex"` // 查询页码 | ||
| 55 | + PageSize int `json:"pageSize"` // 查询限制 | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + DataDictionarySearch struct { | ||
| 59 | + Grid struct { | ||
| 60 | + Total int `json:"total"` | ||
| 61 | + PageNumber int `json:"pageNumber"` | ||
| 62 | + List []Dictionary `json:"list"` // 字典值列表 | ||
| 63 | + } `json:"grid"` | ||
| 64 | + } | ||
| 65 | +) | ||
| 66 | + | ||
| 67 | +type ( | ||
| 68 | + ReqDictionaryAdd struct { | ||
| 69 | + DictCode string `json:"dictCode"` // 字典编码 | ||
| 70 | + DictName string `json:"dictName"` // 字典名称 | ||
| 71 | + Describe string `json:"describe"` // 备注信息 | ||
| 72 | + DictItems []DictionaryItem `json:"dictItems"` // 字典值列表 | ||
| 73 | + } | ||
| 74 | + DataDictionaryAdd struct { | ||
| 75 | + Dictionary | ||
| 76 | + } | ||
| 77 | +) | ||
| 78 | + | ||
| 79 | +type ( | ||
| 80 | + ReqDictionaryUpdate struct { | ||
| 81 | + DictionaryId int64 `json:"dictionaryId"` // 字典编号 主键 | ||
| 82 | + DictCode string `json:"dictCode"` // 字典编码 | ||
| 83 | + DictName string `json:"dictName"` // 字典名称 | ||
| 84 | + Describe string `json:"describe"` // 备注信息 | ||
| 85 | + DictItems []DictionaryItem `json:"dictItems"` // 字典值列表 | ||
| 86 | + } | ||
| 87 | + DataDictionaryUpdate struct { | ||
| 88 | + Dictionary | ||
| 89 | + } | ||
| 90 | +) | ||
| 91 | + | ||
| 92 | +type ( | ||
| 93 | + ReqDictionaryGet struct { | ||
| 94 | + DictionaryId int `json:"dictionaryId"` | ||
| 95 | + } | ||
| 96 | + DataDictionaryGet struct { | ||
| 97 | + Dictionary | ||
| 98 | + } | ||
| 99 | +) | ||
| 100 | + | ||
| 101 | +type ( | ||
| 102 | + ReqDictionaryRemove struct { | ||
| 103 | + DictionaryId int `json:"dictionaryId"` | ||
| 104 | + } | ||
| 105 | + DataDictionaryRemove struct { | ||
| 106 | + } | ||
| 107 | +) |
| @@ -90,8 +90,8 @@ type ( | @@ -90,8 +90,8 @@ type ( | ||
| 90 | 90 | ||
| 91 | DataNoticeSettingProfile struct { | 91 | DataNoticeSettingProfile struct { |
| 92 | ModuleList []struct { | 92 | ModuleList []struct { |
| 93 | - ModuleCode string `json:"Code"` | ||
| 94 | - Name string `json:"name"` | 93 | + ModuleCode string `json:"moduleCode"` |
| 94 | + ModuleName string `json:"moduleName"` | ||
| 95 | } `json:"moduleList"` | 95 | } `json:"moduleList"` |
| 96 | ModuleActionList []struct { | 96 | ModuleActionList []struct { |
| 97 | ModuleCode string `json:"moduleCode"` | 97 | ModuleCode string `json:"moduleCode"` |
| 1 | +package backgroud_client | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log" | ||
| 5 | + | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/dictionary/command" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/dictionary/query" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/dictionary/service" | ||
| 9 | +) | ||
| 10 | + | ||
| 11 | +type DictionaryController struct { | ||
| 12 | + baseController | ||
| 13 | +} | ||
| 14 | + | ||
| 15 | +func (controller *DictionaryController) CreateDictionary() { | ||
| 16 | + dictionaryService := service.NewDictionayService(nil) | ||
| 17 | + createCommand := &command.CreateDictionaryCommand{} | ||
| 18 | + err := controller.Unmarshal(createCommand) | ||
| 19 | + if err != nil { | ||
| 20 | + log.Logger.Debug("json err:" + err.Error()) | ||
| 21 | + } | ||
| 22 | + createCommand.Operator = controller.GetOperator() | ||
| 23 | + data, err := dictionaryService.CreateDictionay(createCommand) | ||
| 24 | + controller.Response(data, err) | ||
| 25 | +} | ||
| 26 | + | ||
| 27 | +func (controller *DictionaryController) UpdateDictionary() { | ||
| 28 | + dictionaryService := service.NewDictionayService(nil) | ||
| 29 | + updateCommand := &command.UpdateDictionaryCommand{} | ||
| 30 | + err := controller.Unmarshal(updateCommand) | ||
| 31 | + if err != nil { | ||
| 32 | + log.Logger.Debug("json err:" + err.Error()) | ||
| 33 | + } | ||
| 34 | + updateCommand.Operator = controller.GetOperator() | ||
| 35 | + data, err := dictionaryService.UpdateDictionay(updateCommand) | ||
| 36 | + controller.Response(data, err) | ||
| 37 | +} | ||
| 38 | + | ||
| 39 | +func (controller *DictionaryController) RemoveDictionary() { | ||
| 40 | + dictionaryService := service.NewDictionayService(nil) | ||
| 41 | + removeCommand := &command.RemoveDictionaryCommand{} | ||
| 42 | + err := controller.Unmarshal(removeCommand) | ||
| 43 | + if err != nil { | ||
| 44 | + log.Logger.Debug("json err:" + err.Error()) | ||
| 45 | + } | ||
| 46 | + removeCommand.Operator = controller.GetOperator() | ||
| 47 | + data, err := dictionaryService.RemoveDictionay(removeCommand) | ||
| 48 | + controller.Response(data, err) | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | +func (controller *DictionaryController) GetDictionary() { | ||
| 52 | + dictionaryService := service.NewDictionayService(nil) | ||
| 53 | + getQuery := &query.GetDictionaryQuery{} | ||
| 54 | + err := controller.Unmarshal(getQuery) | ||
| 55 | + if err != nil { | ||
| 56 | + log.Logger.Debug("json err:" + err.Error()) | ||
| 57 | + } | ||
| 58 | + getQuery.Operator = controller.GetOperator() | ||
| 59 | + data, err := dictionaryService.GetDictionay(getQuery) | ||
| 60 | + controller.Response(data, err) | ||
| 61 | +} | ||
| 62 | + | ||
| 63 | +func (controller *DictionaryController) ListDictionary() { | ||
| 64 | + dictionaryService := service.NewDictionayService(nil) | ||
| 65 | + listQuery := &query.ListDictionaryQuery{} | ||
| 66 | + err := controller.Unmarshal(listQuery) | ||
| 67 | + if err != nil { | ||
| 68 | + log.Logger.Debug("json err:" + err.Error()) | ||
| 69 | + } | ||
| 70 | + listQuery.Operator = controller.GetOperator() | ||
| 71 | + data, err := dictionaryService.ListDictionay(listQuery) | ||
| 72 | + controller.Response(data, err) | ||
| 73 | +} |
| 1 | +package routers | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/beego/beego/v2/server/web" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/backgroud_client" | ||
| 6 | +) | ||
| 7 | + | ||
| 8 | +func init() { | ||
| 9 | + web.Router("/v1/background/dictionary/", &backgroud_client.DictionaryController{}, "Post:CreateDictionary") | ||
| 10 | + web.Router("/v1/background/dictionary/:dictionaryId", &backgroud_client.DictionaryController{}, "Put:UpdateDictionary") | ||
| 11 | + web.Router("/v1/background/dictionary/:dictionaryId", &backgroud_client.DictionaryController{}, "Get:GetDictionary") | ||
| 12 | + web.Router("/v1/background/dictionary/search", &backgroud_client.DictionaryController{}, "Post:ListDictionary") | ||
| 13 | + web.Router("/v1/background/dictionary/remove", &backgroud_client.DictionaryController{}, "Post:RemoveDictionary") | ||
| 14 | +} |
-
请 注册 或 登录 后发表评论