正在显示
10 个修改的文件
包含
347 行增加
和
4 行删除
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + | ||
6 | + "github.com/beego/beego/v2/core/validation" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | ||
8 | +) | ||
9 | + | ||
10 | +type SettingUpdateCommand struct { | ||
11 | + //操作人 | ||
12 | + Operator domain.Operator `json:"-"` | ||
13 | + SettingCode string `json:"settingCode" valid:"Required"` | ||
14 | + // 设定的值 | ||
15 | + Value string `json:"value" valid:"Required"` | ||
16 | +} | ||
17 | + | ||
18 | +func (settingUpdate *SettingUpdateCommand) Valid(validation *validation.Validation) { | ||
19 | + | ||
20 | +} | ||
21 | + | ||
22 | +func (settingUpdate *SettingUpdateCommand) ValidateCommand() error { | ||
23 | + valid := validation.Validation{} | ||
24 | + b, err := valid.Valid(settingUpdate) | ||
25 | + if err != nil { | ||
26 | + return err | ||
27 | + } | ||
28 | + if !b { | ||
29 | + for _, validErr := range valid.Errors { | ||
30 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
31 | + } | ||
32 | + } | ||
33 | + return nil | ||
34 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + | ||
6 | + "github.com/beego/beego/v2/core/validation" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | ||
8 | +) | ||
9 | + | ||
10 | +type SettingGetQuery struct { | ||
11 | + //操作人 | ||
12 | + Operator domain.Operator `json:"-"` | ||
13 | + SettingCode string `json:"settingCode"` | ||
14 | +} | ||
15 | + | ||
16 | +func (settingGetQuery *SettingGetQuery) Valid(validation *validation.Validation) { | ||
17 | + | ||
18 | +} | ||
19 | + | ||
20 | +func (settingGetQuery *SettingGetQuery) ValidateCommand() error { | ||
21 | + valid := validation.Validation{} | ||
22 | + b, err := valid.Valid(settingGetQuery) | ||
23 | + if err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + if !b { | ||
27 | + for _, validErr := range valid.Errors { | ||
28 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
29 | + } | ||
30 | + } | ||
31 | + return nil | ||
32 | +} |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/systemsetting/command" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/systemsetting/query" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_basic" | ||
7 | +) | ||
8 | + | ||
9 | +// 用户信息 | ||
10 | +type SystemSettingService struct { | ||
11 | +} | ||
12 | + | ||
13 | +func NewSystemSettingService(options map[string]interface{}) *SystemSettingService { | ||
14 | + newUsersService := &SystemSettingService{} | ||
15 | + return newUsersService | ||
16 | +} | ||
17 | + | ||
18 | +func (srv SystemSettingService) GetSystemSettingList(systemSettingListQuery *query.SettingListQuery) (interface{}, error) { | ||
19 | + creationBasicGateway := allied_creation_basic.NewHttplibAlliedCreationBasic( | ||
20 | + systemSettingListQuery.Operator, | ||
21 | + ) | ||
22 | + result, err := creationBasicGateway.SystemSettingSearch(allied_creation_basic.ReqSystemSettingSearch{}) | ||
23 | + return result, err | ||
24 | +} | ||
25 | + | ||
26 | +func (srv SystemSettingService) GetSystemSetting(systemSettingGetQuery *query.SettingGetQuery) (interface{}, error) { | ||
27 | + creationBasicGateway := allied_creation_basic.NewHttplibAlliedCreationBasic( | ||
28 | + systemSettingGetQuery.Operator, | ||
29 | + ) | ||
30 | + result, err := creationBasicGateway.SystemSettingGet(allied_creation_basic.ReqSystemSettingGet{ | ||
31 | + SettingCode: systemSettingGetQuery.SettingCode, | ||
32 | + }) | ||
33 | + return result, err | ||
34 | +} | ||
35 | + | ||
36 | +func (srv SystemSettingService) SystemSettingUpdate(systemSettingUpdate *command.SettingUpdateCommand) (interface{}, error) { | ||
37 | + creationBasicGateway := allied_creation_basic.NewHttplibAlliedCreationBasic( | ||
38 | + systemSettingUpdate.Operator, | ||
39 | + ) | ||
40 | + result, err := creationBasicGateway.SystemSettingUpdate(allied_creation_basic.ReqSystemSettingUpdate{ | ||
41 | + SettingCode: systemSettingUpdate.SettingCode, | ||
42 | + Value: systemSettingUpdate.Value, | ||
43 | + CompanyId: systemSettingUpdate.Operator.CompanyId, | ||
44 | + }) | ||
45 | + return result, err | ||
46 | +} |
1 | +package allied_creation_basic | ||
2 | + | ||
3 | +import ( | ||
4 | + "encoding/json" | ||
5 | + "fmt" | ||
6 | + | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log" | ||
9 | +) | ||
10 | + | ||
11 | +// SystemSetting 更新系统设置 | ||
12 | +func (gateway HttplibAlliedCreationBasic) SystemSettingUpdate(param ReqSystemSettingUpdate) (*DataSystemSettingUpdate, error) { | ||
13 | + url := gateway.baseUrL + "/system-setting" | ||
14 | + method := "PUT" | ||
15 | + req := gateway.CreateRequest(url, method) | ||
16 | + log.Logger.Debug("向基础模块请求数据:更新系统设置。", map[string]interface{}{ | ||
17 | + "api": method + ":" + url, | ||
18 | + "param": param, | ||
19 | + }) | ||
20 | + req, err := req.JSONBody(param) | ||
21 | + if err != nil { | ||
22 | + return nil, fmt.Errorf("请求更新系统设置失败:%w", err) | ||
23 | + } | ||
24 | + | ||
25 | + byteResult, err := req.Bytes() | ||
26 | + if err != nil { | ||
27 | + return nil, fmt.Errorf("获取更新系统设置失败:%w", err) | ||
28 | + } | ||
29 | + log.Logger.Debug("获取基础模块请求数据:更新系统设置。", map[string]interface{}{ | ||
30 | + "result": string(byteResult), | ||
31 | + }) | ||
32 | + var result service_gateway.GatewayResponse | ||
33 | + err = json.Unmarshal(byteResult, &result) | ||
34 | + if err != nil { | ||
35 | + return nil, fmt.Errorf("解析更新系统设置:%w", err) | ||
36 | + } | ||
37 | + var data DataSystemSettingUpdate | ||
38 | + err = gateway.GetResponseData(result, &data) | ||
39 | + return &data, err | ||
40 | +} | ||
41 | + | ||
42 | +// System-settingSearch 获取企业的系统设置列表 | ||
43 | +func (gateway HttplibAlliedCreationBasic) SystemSettingSearch(param ReqSystemSettingSearch) (*DataSystemSettingSearch, error) { | ||
44 | + url := gateway.baseUrL + "/system-setting/search" | ||
45 | + method := "POST" | ||
46 | + req := gateway.CreateRequest(url, method) | ||
47 | + log.Logger.Debug("向基础模块请求数据:获取企业的系统设置列表。", map[string]interface{}{ | ||
48 | + "api": method + ":" + url, | ||
49 | + "param": param, | ||
50 | + }) | ||
51 | + req, err := req.JSONBody(param) | ||
52 | + if err != nil { | ||
53 | + return nil, fmt.Errorf("请求获取企业的系统设置列表失败:%w", err) | ||
54 | + } | ||
55 | + | ||
56 | + byteResult, err := req.Bytes() | ||
57 | + if err != nil { | ||
58 | + return nil, fmt.Errorf("获取获取企业的系统设置列表失败:%w", err) | ||
59 | + } | ||
60 | + log.Logger.Debug("获取基础模块请求数据:获取企业的系统设置列表。", map[string]interface{}{ | ||
61 | + "result": string(byteResult), | ||
62 | + }) | ||
63 | + var result service_gateway.GatewayResponse | ||
64 | + err = json.Unmarshal(byteResult, &result) | ||
65 | + if err != nil { | ||
66 | + return nil, fmt.Errorf("解析获取企业的系统设置列表:%w", err) | ||
67 | + } | ||
68 | + var data DataSystemSettingSearch | ||
69 | + err = gateway.GetResponseData(result, &data) | ||
70 | + return &data, err | ||
71 | +} | ||
72 | + | ||
73 | +// SystemSettingGet 获取企业的系统设置项 | ||
74 | +func (gateway HttplibAlliedCreationBasic) SystemSettingGet(param ReqSystemSettingGet) (*DataSystemSettingGet, error) { | ||
75 | + url := gateway.baseUrL + "/system-setting/get" | ||
76 | + method := "POST" | ||
77 | + req := gateway.CreateRequest(url, method) | ||
78 | + log.Logger.Debug("向基础模块请求数据:获取企业的系统设置项。", map[string]interface{}{ | ||
79 | + "api": method + ":" + url, | ||
80 | + "param": param, | ||
81 | + }) | ||
82 | + req, err := req.JSONBody(param) | ||
83 | + if err != nil { | ||
84 | + return nil, fmt.Errorf("请求获取企业的系统设置项失败:%w", err) | ||
85 | + } | ||
86 | + | ||
87 | + byteResult, err := req.Bytes() | ||
88 | + if err != nil { | ||
89 | + return nil, fmt.Errorf("获取获取企业的系统设置项失败:%w", err) | ||
90 | + } | ||
91 | + log.Logger.Debug("获取基础模块请求数据:获取企业的系统设置项。", map[string]interface{}{ | ||
92 | + "result": string(byteResult), | ||
93 | + }) | ||
94 | + var result service_gateway.GatewayResponse | ||
95 | + err = json.Unmarshal(byteResult, &result) | ||
96 | + if err != nil { | ||
97 | + return nil, fmt.Errorf("解析获取企业的系统设置项:%w", err) | ||
98 | + } | ||
99 | + var data DataSystemSettingGet | ||
100 | + err = gateway.GetResponseData(result, &data) | ||
101 | + return &data, err | ||
102 | +} |
@@ -90,15 +90,15 @@ type ( | @@ -90,15 +90,15 @@ type ( | ||
90 | } | 90 | } |
91 | 91 | ||
92 | DataNoticeSettingProfile struct { | 92 | DataNoticeSettingProfile struct { |
93 | - Module []struct { | 93 | + ModuleList []struct { |
94 | ModuleCode string `json:"Code"` | 94 | ModuleCode string `json:"Code"` |
95 | Name string `json:"name"` | 95 | Name string `json:"name"` |
96 | - } `json:"module"` | ||
97 | - ModuleAction []struct { | 96 | + } `json:"moduleList"` |
97 | + ModuleActionList []struct { | ||
98 | ModuleCode string `json:"module_code"` | 98 | ModuleCode string `json:"module_code"` |
99 | ActionCode string `json:"action_Code"` | 99 | ActionCode string `json:"action_Code"` |
100 | Name string `json:"name"` | 100 | Name string `json:"name"` |
101 | - } `json:"moduleAction"` | 101 | + } `json:"moduleActionList"` |
102 | ParamList []struct { | 102 | ParamList []struct { |
103 | // 变量的代码标识 | 103 | // 变量的代码标识 |
104 | ParamCode string `json:"paramCode"` | 104 | ParamCode string `json:"paramCode"` |
1 | +package allied_creation_basic | ||
2 | + | ||
3 | +//更新系统设置 | ||
4 | +type ( | ||
5 | + ReqSystemSettingUpdate struct { | ||
6 | + // 公司id | ||
7 | + CompanyId int64 `json:"companyId"` | ||
8 | + // 设定的值 | ||
9 | + Value string `json:"value"` | ||
10 | + // 设置对应的编码 | ||
11 | + SettingCode string `json:"settingCode"` | ||
12 | + } | ||
13 | + | ||
14 | + DataSystemSettingUpdate struct { | ||
15 | + } | ||
16 | +) | ||
17 | + | ||
18 | +//获取企业的系统设置列表 | ||
19 | +type ( | ||
20 | + ReqSystemSettingSearch struct { | ||
21 | + } | ||
22 | + | ||
23 | + DataSystemSettingSearch struct { | ||
24 | + SystemSetting []struct { | ||
25 | + // 公司id | ||
26 | + CompanyId int64 `json:"companyId"` | ||
27 | + // 管控层级 | ||
28 | + ControlLevel string `json:"controlLevel"` | ||
29 | + // 描述 | ||
30 | + Description string `json:"description"` | ||
31 | + // 设置对应的编码 | ||
32 | + SettingCode string `json:"settingCode"` | ||
33 | + // 设置对应的名称 | ||
34 | + SettingName string `json:"settingName"` | ||
35 | + // 数据id | ||
36 | + SystemSettingId int64 `json:"systemSettingId"` | ||
37 | + // 设定的值 | ||
38 | + Value string `json:"value"` | ||
39 | + // 值类型 | ||
40 | + ValueType string `json:"valueType"` | ||
41 | + } | ||
42 | + } | ||
43 | +) | ||
44 | + | ||
45 | +//获取企业的系统设置项 | ||
46 | +type ( | ||
47 | + ReqSystemSettingGet struct { | ||
48 | + SettingCode string `json:"settingCode"` | ||
49 | + } | ||
50 | + | ||
51 | + DataSystemSettingGet struct { | ||
52 | + // 公司id | ||
53 | + CompanyId int64 `json:"companyId"` | ||
54 | + // 管控层级 | ||
55 | + ControlLevel string `json:"controlLevel"` | ||
56 | + // 描述 | ||
57 | + Description string `json:"description"` | ||
58 | + // 设置对应的编码 | ||
59 | + SettingCode string `json:"settingCode"` | ||
60 | + // 设置对应的名称 | ||
61 | + SettingName string `json:"settingName"` | ||
62 | + // 数据id | ||
63 | + SystemSettingId int64 `json:"systemSettingId"` | ||
64 | + // 设定的值 | ||
65 | + Value string `json:"value"` | ||
66 | + // 值类型 | ||
67 | + ValueType string `json:"valueType"` | ||
68 | + } | ||
69 | +) |
@@ -48,6 +48,7 @@ func (gateway BaseServiceGateway) CreateRequest(url string, method string) *http | @@ -48,6 +48,7 @@ func (gateway BaseServiceGateway) CreateRequest(url string, method string) *http | ||
48 | request.Header("companyId", strconv.FormatInt(gateway.CompanyId, 10)) | 48 | request.Header("companyId", strconv.FormatInt(gateway.CompanyId, 10)) |
49 | request.Header("orgId", strconv.FormatInt(gateway.OrgId, 10)) | 49 | request.Header("orgId", strconv.FormatInt(gateway.OrgId, 10)) |
50 | request.Header("userId", strconv.FormatInt(gateway.UserId, 10)) | 50 | request.Header("userId", strconv.FormatInt(gateway.UserId, 10)) |
51 | + request.Header("userBaseId", strconv.FormatInt(gateway.UserBaseId, 10)) | ||
51 | return request.SetTimeout(gateway.ConnectTimeout, gateway.ReadWriteTimeout) | 52 | return request.SetTimeout(gateway.ConnectTimeout, gateway.ReadWriteTimeout) |
52 | } | 53 | } |
53 | 54 |
1 | +package web_client | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/systemsetting/command" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/systemsetting/query" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/systemsetting/service" | ||
7 | +) | ||
8 | + | ||
9 | +type SystemSettingController struct { | ||
10 | + baseController | ||
11 | +} | ||
12 | + | ||
13 | +func (controller SystemSettingController) SystemSettingSearch() { | ||
14 | + systemSettingService := service.NewSystemSettingService(nil) | ||
15 | + q := &query.SettingListQuery{ | ||
16 | + Operator: controller.GetOperator(), | ||
17 | + } | ||
18 | + data, err := systemSettingService.GetSystemSettingList(q) | ||
19 | + controller.Response(data, err) | ||
20 | +} | ||
21 | + | ||
22 | +func (controller SystemSettingController) SystemSettingGet() { | ||
23 | + systemSettingService := service.NewSystemSettingService(nil) | ||
24 | + q := &query.SettingGetQuery{} | ||
25 | + controller.Unmarshal(q) | ||
26 | + q.Operator = controller.GetOperator() | ||
27 | + data, err := systemSettingService.GetSystemSetting(q) | ||
28 | + controller.Response(data, err) | ||
29 | + | ||
30 | +} | ||
31 | + | ||
32 | +func (controller SystemSettingController) SystemSettingUpdate() { | ||
33 | + systemSettingService := service.NewSystemSettingService(nil) | ||
34 | + q := &command.SettingUpdateCommand{} | ||
35 | + controller.Unmarshal(q) | ||
36 | + q.Operator = controller.GetOperator() | ||
37 | + data, err := systemSettingService.SystemSettingUpdate(q) | ||
38 | + controller.Response(data, err) | ||
39 | +} |
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/web_client" | ||
6 | +) | ||
7 | + | ||
8 | +func init() { | ||
9 | + web.Router("/v1/web/system-setting/search", &web_client.SystemSettingController{}, "Post:SystemSettingSearch") | ||
10 | + web.Router("/v1/web/syetem-setting/:settingId", &web_client.SystemSettingController{}, "Get:SystemSettingGet") | ||
11 | + web.Router("/v1/web/syetem-setting", &web_client.SystemSettingController{}, "Put:SystemSettingUpdate") | ||
12 | +} |
-
请 注册 或 登录 后发表评论