Merge branch 'test'
# Conflicts: # pkg/infrastructure/pg/init.go
正在显示
59 个修改的文件
包含
1345 行增加
和
247 行删除
1 | FROM golang:latest | 1 | FROM golang:latest |
2 | #FROM 192.168.0.243:5000/mmm/digital-platform:20220831 | 2 | #FROM 192.168.0.243:5000/mmm/digital-platform:20220831 |
3 | -ENV APP_DIR $GOPATH/src/digital-platform | 3 | +ENV APP_DIR $GOPATH/src/performance |
4 | RUN mkdir -p $APP_DIR | 4 | RUN mkdir -p $APP_DIR |
5 | WORKDIR $APP_DIR/ | 5 | WORKDIR $APP_DIR/ |
6 | COPY ./pkg pkg | 6 | COPY ./pkg pkg |
@@ -13,5 +13,5 @@ ENV GO111MODULE on | @@ -13,5 +13,5 @@ ENV GO111MODULE on | ||
13 | ENV GOPROXY https://goproxy.io | 13 | ENV GOPROXY https://goproxy.io |
14 | RUN ["go","mod","tidy"] | 14 | RUN ["go","mod","tidy"] |
15 | RUN ["ls"] | 15 | RUN ["ls"] |
16 | -RUN ["go","build","-o","digital-platform"] | ||
17 | -ENTRYPOINT ["./digital-platform"] | ||
16 | +RUN ["go","build","-o","performance"] | ||
17 | +ENTRYPOINT ["./performance"] |
debug.log
0 → 100644
1 | +2022/11/10 09:28:21.494 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "company" ("id" bigserial, "logo" text, "name" text, "charge_user_ids" jsonb, "status" bigint, "update_at" timestamptz, "create_at" timestamptz, "delete_at" timestamptz, PRIMARY KEY ("id")) null | ||
2 | +2022/11/10 09:28:21.521 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "department" ("id" bigserial, "company_id" bigint, "level" bigint, "name" text, "parent_id" bigint, "charge_user_ids" jsonb, "path" text, "create_at" timestamptz, "update_at" timestamptz, "delete_at" timestamptz, PRIMARY KEY ("id")) null | ||
3 | +2022/11/10 09:28:21.548 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "user" ("id" bigserial, "account" text, "avatar_url" text, "company_id" bigint, "admin_type" bigint, "name" text, "email" text, "status" bigint, "department_id" jsonb, "update_at" timestamptz, "create_at" timestamptz, "delete_at" timestamptz, PRIMARY KEY ("id")) null | ||
4 | +2022/11/10 09:28:21.575 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "received_message" ("message_id" bigserial, "message_type" text, "message_body" text, "occurred_on" timestamptz, "create_at" timestamptz, PRIMARY KEY ("message_id")) null | ||
5 | +2022/11/10 09:28:21.602 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "role" ("id" bigserial, "name" text, "type" bigint, "description" text, "company_id" bigint, "created_at" timestamptz, "updated_at" timestamptz, "deleted_at" timestamptz, PRIMARY KEY ("id")) null | ||
6 | +2022/11/10 09:28:21.630 [D] [hook.go:130] performance COMMENT ON TABLE public."role" IS '角色'; null | ||
7 | +2022/11/10 09:28:21.659 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".id IS 'ID'; null | ||
8 | +2022/11/10 09:28:21.688 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".name IS '角色名称'; null | ||
9 | +2022/11/10 09:28:21.716 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".type IS '角色类型(0角色可删、1系统预置角色不可删)'; null | ||
10 | +2022/11/10 09:28:21.743 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".description IS '角色描述'; null | ||
11 | +2022/11/10 09:28:21.771 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".company_id IS '公司ID'; null | ||
12 | +2022/11/10 09:28:21.799 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".created_at IS '创建时间'; null | ||
13 | +2022/11/10 09:28:21.828 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".updated_at IS '更新时间'; null | ||
14 | +2022/11/10 09:28:21.856 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".deleted_at IS '删除时间'; null | ||
15 | +2022/11/10 09:28:21.883 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "role_user" ("id" bigserial, "role_id" bigint, "user_id" bigint, "company_id" bigint, "created_at" timestamptz, "updated_at" timestamptz, "deleted_at" timestamptz, PRIMARY KEY ("id")) null | ||
16 | +2022/11/10 09:28:21.911 [D] [hook.go:130] performance COMMENT ON TABLE public."role_user" IS '角色用户关系'; null | ||
17 | +2022/11/10 09:28:21.937 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".id IS 'ID'; null | ||
18 | +2022/11/10 09:28:21.964 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".role_id IS '角色ID'; null | ||
19 | +2022/11/10 09:28:21.993 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".user_id IS '用户ID'; null | ||
20 | +2022/11/10 09:28:22.020 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".company_id IS '公司ID'; null | ||
21 | +2022/11/10 09:28:22.047 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".created_at IS '创建时间'; null | ||
22 | +2022/11/10 09:28:22.075 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".updated_at IS '更新时间'; null | ||
23 | +2022/11/10 09:28:22.102 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".deleted_at IS '删除时间'; null | ||
24 | +2022/11/10 09:28:22.116 [I] [???:0] performance http server Running on http://:8082 | ||
25 | +2022/11/10 09:28:22.860 [E] [asm_amd64.s:1594] performance kafka: client has run out of available brokers to talk to (Is your cluster reachable?) [] | ||
26 | +2022/11/10 09:29:54.845 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "company" ("id" bigserial, "logo" text, "name" text, "charge_user_ids" jsonb, "status" bigint, "update_at" timestamptz, "create_at" timestamptz, "delete_at" timestamptz, PRIMARY KEY ("id")) null | ||
27 | +2022/11/10 09:29:54.873 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "department" ("id" bigserial, "company_id" bigint, "level" bigint, "name" text, "parent_id" bigint, "charge_user_ids" jsonb, "path" text, "create_at" timestamptz, "update_at" timestamptz, "delete_at" timestamptz, PRIMARY KEY ("id")) null | ||
28 | +2022/11/10 09:29:54.899 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "user" ("id" bigserial, "account" text, "avatar_url" text, "company_id" bigint, "admin_type" bigint, "name" text, "email" text, "status" bigint, "department_id" jsonb, "update_at" timestamptz, "create_at" timestamptz, "delete_at" timestamptz, PRIMARY KEY ("id")) null | ||
29 | +2022/11/10 09:29:54.926 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "received_message" ("message_id" bigserial, "message_type" text, "message_body" text, "occurred_on" timestamptz, "create_at" timestamptz, PRIMARY KEY ("message_id")) null | ||
30 | +2022/11/10 09:29:54.953 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "role" ("id" bigserial, "name" text, "type" bigint, "description" text, "company_id" bigint, "created_at" timestamptz, "updated_at" timestamptz, "deleted_at" timestamptz, PRIMARY KEY ("id")) null | ||
31 | +2022/11/10 09:29:54.981 [D] [hook.go:130] performance COMMENT ON TABLE public."role" IS '角色'; null | ||
32 | +2022/11/10 09:29:55.009 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".id IS 'ID'; null | ||
33 | +2022/11/10 09:29:55.037 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".name IS '角色名称'; null | ||
34 | +2022/11/10 09:29:55.068 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".type IS '角色类型(0角色可删、1系统预置角色不可删)'; null | ||
35 | +2022/11/10 09:29:55.094 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".description IS '角色描述'; null | ||
36 | +2022/11/10 09:29:55.121 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".company_id IS '公司ID'; null | ||
37 | +2022/11/10 09:29:55.149 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".created_at IS '创建时间'; null | ||
38 | +2022/11/10 09:29:55.183 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".updated_at IS '更新时间'; null | ||
39 | +2022/11/10 09:29:55.212 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".deleted_at IS '删除时间'; null | ||
40 | +2022/11/10 09:29:55.243 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "role_user" ("id" bigserial, "role_id" bigint, "user_id" bigint, "company_id" bigint, "created_at" timestamptz, "updated_at" timestamptz, "deleted_at" timestamptz, PRIMARY KEY ("id")) null | ||
41 | +2022/11/10 09:29:55.270 [D] [hook.go:130] performance COMMENT ON TABLE public."role_user" IS '角色用户关系'; null | ||
42 | +2022/11/10 09:29:55.297 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".id IS 'ID'; null | ||
43 | +2022/11/10 09:29:55.324 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".role_id IS '角色ID'; null | ||
44 | +2022/11/10 09:29:55.351 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".user_id IS '用户ID'; null | ||
45 | +2022/11/10 09:29:55.377 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".company_id IS '公司ID'; null | ||
46 | +2022/11/10 09:29:55.403 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".created_at IS '创建时间'; null | ||
47 | +2022/11/10 09:29:55.430 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".updated_at IS '更新时间'; null | ||
48 | +2022/11/10 09:29:55.456 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".deleted_at IS '删除时间'; null | ||
49 | +2022/11/10 09:29:55.466 [I] [???:0] performance http server Running on http://:8082 | ||
50 | +2022/11/10 09:29:56.217 [E] [asm_amd64.s:1594] performance kafka: client has run out of available brokers to talk to (Is your cluster reachable?) [] | ||
51 | +2022/11/10 09:30:15.476 [D] [router.go:977] performance | 127.0.0.1|[97;42m 200 [0m| 364.534µs| match|[97;44m GET [0m /log r:/log | ||
52 | +2022/11/10 09:30:15.546 [D] [router.go:977] performance | 127.0.0.1|[97;43m 404 [0m| 959.763µs| nomatch|[97;44m GET [0m /favicon.ico | ||
53 | +2022/11/10 15:07:19.528 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "company" ("id" bigserial, "logo" text, "name" text, "charge_user_ids" jsonb, "status" bigint, "update_at" timestamptz, "create_at" timestamptz, "delete_at" timestamptz, PRIMARY KEY ("id")) null | ||
54 | +2022/11/10 15:07:19.556 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "department" ("id" bigserial, "company_id" bigint, "level" bigint, "name" text, "parent_id" bigint, "charge_user_ids" jsonb, "path" text, "create_at" timestamptz, "update_at" timestamptz, "delete_at" timestamptz, PRIMARY KEY ("id")) null | ||
55 | +2022/11/10 15:07:19.583 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "user" ("id" bigserial, "account" text, "avatar_url" text, "company_id" bigint, "admin_type" bigint, "name" text, "email" text, "status" bigint, "department_id" jsonb, "update_at" timestamptz, "create_at" timestamptz, "delete_at" timestamptz, PRIMARY KEY ("id")) null | ||
56 | +2022/11/10 15:07:19.611 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "received_message" ("message_id" bigserial, "message_type" text, "message_body" text, "occurred_on" timestamptz, "create_at" timestamptz, PRIMARY KEY ("message_id")) null | ||
57 | +2022/11/10 15:07:19.638 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "role" ("id" bigserial, "name" text, "type" bigint, "description" text, "company_id" bigint, "created_at" timestamptz, "updated_at" timestamptz, "deleted_at" timestamptz, PRIMARY KEY ("id")) null | ||
58 | +2022/11/10 15:07:19.666 [D] [hook.go:130] performance COMMENT ON TABLE public."role" IS '角色'; null | ||
59 | +2022/11/10 15:07:19.695 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".id IS 'ID'; null | ||
60 | +2022/11/10 15:07:19.723 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".name IS '角色名称'; null | ||
61 | +2022/11/10 15:07:19.750 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".type IS '角色类型(0角色可删、1系统预置角色不可删)'; null | ||
62 | +2022/11/10 15:07:19.777 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".description IS '角色描述'; null | ||
63 | +2022/11/10 15:07:19.805 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".company_id IS '公司ID'; null | ||
64 | +2022/11/10 15:07:19.834 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".created_at IS '创建时间'; null | ||
65 | +2022/11/10 15:07:19.861 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".updated_at IS '更新时间'; null | ||
66 | +2022/11/10 15:07:19.889 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".deleted_at IS '删除时间'; null | ||
67 | +2022/11/10 15:07:19.916 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "role_user" ("id" bigserial, "role_id" bigint, "user_id" bigint, "company_id" bigint, "created_at" timestamptz, "updated_at" timestamptz, "deleted_at" timestamptz, PRIMARY KEY ("id")) null | ||
68 | +2022/11/10 15:07:19.944 [D] [hook.go:130] performance COMMENT ON TABLE public."role_user" IS '角色用户关系'; null | ||
69 | +2022/11/10 15:07:19.971 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".id IS 'ID'; null | ||
70 | +2022/11/10 15:07:19.998 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".role_id IS '角色ID'; null | ||
71 | +2022/11/10 15:07:20.026 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".user_id IS '用户ID'; null | ||
72 | +2022/11/10 15:07:20.054 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".company_id IS '公司ID'; null | ||
73 | +2022/11/10 15:07:20.081 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".created_at IS '创建时间'; null | ||
74 | +2022/11/10 15:07:20.109 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".updated_at IS '更新时间'; null | ||
75 | +2022/11/10 15:07:20.136 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".deleted_at IS '删除时间'; null | ||
76 | +2022/11/10 15:07:20.221 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "positions" ("id" bigserial, "company_id" bigint, "name" text, "parent_id" bigint, "path" text, "level" bigint, "remarks" text, "created_at" timestamptz, "updated_at" timestamptz, "deleted_at" timestamptz, PRIMARY KEY ("id")) null | ||
77 | +2022/11/10 15:07:20.257 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "user_positions" ("id" bigserial, "company_id" bigint, "position_id" bigint, "user_id" bigint, "created_at" timestamptz, "updated_at" timestamptz, "deleted_at" timestamptz, PRIMARY KEY ("id")) null | ||
78 | +2022/11/10 15:07:20.272 [I] [???:0] performance http server Running on http://:8082 | ||
79 | +2022/11/10 15:07:21.024 [E] [asm_amd64.s:1594] performance kafka: client has run out of available brokers to talk to (Is your cluster reachable?) [] | ||
80 | +2022/11/10 15:58:14.817 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "company" ("id" bigserial, "logo" text, "name" text, "charge_user_ids" jsonb, "status" bigint, "update_at" timestamptz, "create_at" timestamptz, "delete_at" timestamptz, PRIMARY KEY ("id")) null | ||
81 | +2022/11/10 15:58:14.843 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "department" ("id" bigserial, "company_id" bigint, "level" bigint, "name" text, "parent_id" bigint, "charge_user_ids" jsonb, "path" text, "create_at" timestamptz, "update_at" timestamptz, "delete_at" timestamptz, PRIMARY KEY ("id")) null | ||
82 | +2022/11/10 15:58:14.870 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "user" ("id" bigserial, "account" text, "avatar_url" text, "company_id" bigint, "admin_type" bigint, "name" text, "email" text, "status" bigint, "department_id" jsonb, "position_id" jsonb, "update_at" timestamptz, "create_at" timestamptz, "delete_at" timestamptz, PRIMARY KEY ("id")) null | ||
83 | +2022/11/10 15:58:14.897 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "received_message" ("message_id" bigserial, "message_type" text, "message_body" text, "occurred_on" timestamptz, "create_at" timestamptz, PRIMARY KEY ("message_id")) null | ||
84 | +2022/11/10 15:58:14.924 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "role" ("id" bigserial, "name" text, "type" bigint, "description" text, "company_id" bigint, "created_at" timestamptz, "updated_at" timestamptz, "deleted_at" timestamptz, PRIMARY KEY ("id")) null | ||
85 | +2022/11/10 15:58:14.952 [D] [hook.go:130] performance COMMENT ON TABLE public."role" IS '角色'; null | ||
86 | +2022/11/10 15:58:14.979 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".id IS 'ID'; null | ||
87 | +2022/11/10 15:58:15.006 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".name IS '角色名称'; null | ||
88 | +2022/11/10 15:58:15.033 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".type IS '角色类型(0角色可删、1系统预置角色不可删)'; null | ||
89 | +2022/11/10 15:58:15.060 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".description IS '角色描述'; null | ||
90 | +2022/11/10 15:58:15.087 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".company_id IS '公司ID'; null | ||
91 | +2022/11/10 15:58:15.114 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".created_at IS '创建时间'; null | ||
92 | +2022/11/10 15:58:15.141 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".updated_at IS '更新时间'; null | ||
93 | +2022/11/10 15:58:15.168 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".deleted_at IS '删除时间'; null | ||
94 | +2022/11/10 15:58:15.194 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "role_user" ("id" bigserial, "role_id" bigint, "user_id" bigint, "company_id" bigint, "created_at" timestamptz, "updated_at" timestamptz, "deleted_at" timestamptz, PRIMARY KEY ("id")) null | ||
95 | +2022/11/10 15:58:15.222 [D] [hook.go:130] performance COMMENT ON TABLE public."role_user" IS '角色用户关系'; null | ||
96 | +2022/11/10 15:58:15.249 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".id IS 'ID'; null | ||
97 | +2022/11/10 15:58:15.275 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".role_id IS '角色ID'; null | ||
98 | +2022/11/10 15:58:15.302 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".user_id IS '用户ID'; null | ||
99 | +2022/11/10 15:58:15.329 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".company_id IS '公司ID'; null | ||
100 | +2022/11/10 15:58:15.356 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".created_at IS '创建时间'; null | ||
101 | +2022/11/10 15:58:15.383 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".updated_at IS '更新时间'; null | ||
102 | +2022/11/10 15:58:15.409 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".deleted_at IS '删除时间'; null | ||
103 | +2022/11/10 15:58:15.435 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "positions" ("id" bigserial, "company_id" bigint, "name" text, "parent_id" bigint, "path" text, "level" bigint, "remarks" text, "created_at" timestamptz, "updated_at" timestamptz, "deleted_at" timestamptz, PRIMARY KEY ("id")) null | ||
104 | +2022/11/10 15:58:15.450 [I] [???:0] performance http server Running on http://:8082 | ||
105 | +2022/11/10 15:58:16.194 [E] [asm_amd64.s:1594] performance kafka: client has run out of available brokers to talk to (Is your cluster reachable?) [] | ||
106 | +2022/11/10 16:16:09.220 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "company" ("id" bigserial, "logo" text, "name" text, "charge_user_ids" jsonb, "status" bigint, "update_at" timestamptz, "create_at" timestamptz, "delete_at" timestamptz, PRIMARY KEY ("id")) null | ||
107 | +2022/11/10 16:16:09.247 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "department" ("id" bigserial, "company_id" bigint, "level" bigint, "name" text, "parent_id" bigint, "charge_user_ids" jsonb, "path" text, "create_at" timestamptz, "update_at" timestamptz, "delete_at" timestamptz, PRIMARY KEY ("id")) null | ||
108 | +2022/11/10 16:16:09.274 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "user" ("id" bigserial, "account" text, "avatar_url" text, "company_id" bigint, "admin_type" bigint, "name" text, "email" text, "status" bigint, "department_id" jsonb, "position_id" jsonb, "update_at" timestamptz, "create_at" timestamptz, "delete_at" timestamptz, PRIMARY KEY ("id")) null | ||
109 | +2022/11/10 16:16:09.302 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "received_message" ("message_id" bigserial, "message_type" text, "message_body" text, "occurred_on" timestamptz, "create_at" timestamptz, PRIMARY KEY ("message_id")) null | ||
110 | +2022/11/10 16:16:09.330 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "role" ("id" bigserial, "name" text, "type" bigint, "description" text, "company_id" bigint, "created_at" timestamptz, "updated_at" timestamptz, "deleted_at" timestamptz, PRIMARY KEY ("id")) null | ||
111 | +2022/11/10 16:16:09.359 [D] [hook.go:130] performance COMMENT ON TABLE public."role" IS '角色'; null | ||
112 | +2022/11/10 16:16:09.386 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".id IS 'ID'; null | ||
113 | +2022/11/10 16:16:09.415 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".name IS '角色名称'; null | ||
114 | +2022/11/10 16:16:09.442 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".type IS '角色类型(0角色可删、1系统预置角色不可删)'; null | ||
115 | +2022/11/10 16:16:09.470 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".description IS '角色描述'; null | ||
116 | +2022/11/10 16:16:09.497 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".company_id IS '公司ID'; null | ||
117 | +2022/11/10 16:16:09.524 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".created_at IS '创建时间'; null | ||
118 | +2022/11/10 16:16:09.553 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".updated_at IS '更新时间'; null | ||
119 | +2022/11/10 16:16:09.580 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".deleted_at IS '删除时间'; null | ||
120 | +2022/11/10 16:16:09.606 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "role_user" ("id" bigserial, "role_id" bigint, "user_id" bigint, "company_id" bigint, "created_at" timestamptz, "updated_at" timestamptz, "deleted_at" timestamptz, PRIMARY KEY ("id")) null | ||
121 | +2022/11/10 16:16:09.633 [D] [hook.go:130] performance COMMENT ON TABLE public."role_user" IS '角色用户关系'; null | ||
122 | +2022/11/10 16:16:09.660 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".id IS 'ID'; null | ||
123 | +2022/11/10 16:16:09.687 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".role_id IS '角色ID'; null | ||
124 | +2022/11/10 16:16:09.714 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".user_id IS '用户ID'; null | ||
125 | +2022/11/10 16:16:09.750 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".company_id IS '公司ID'; null | ||
126 | +2022/11/10 16:16:09.776 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".created_at IS '创建时间'; null | ||
127 | +2022/11/10 16:16:09.803 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".updated_at IS '更新时间'; null | ||
128 | +2022/11/10 16:16:09.831 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".deleted_at IS '删除时间'; null | ||
129 | +2022/11/10 16:16:09.857 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "positions" ("id" bigserial, "company_id" bigint, "name" text, "parent_id" bigint, "path" text, "level" bigint, "remarks" text, "created_at" timestamptz, "updated_at" timestamptz, "deleted_at" timestamptz, PRIMARY KEY ("id")) null | ||
130 | +2022/11/10 16:16:09.873 [I] [???:0] performance http server Running on http://:8082 | ||
131 | +2022/11/10 16:16:10.621 [E] [asm_amd64.s:1594] performance kafka: client has run out of available brokers to talk to (Is your cluster reachable?) [] |
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | export PATH=/root/local/bin:$PATH | 2 | export PATH=/root/local/bin:$PATH |
3 | -kubectl -n mmm-suplus-dev get pods | grep -q sg-local-storage | 3 | +kubectl -n mmm-suplus-test get pods | grep -q performance-back |
4 | if [ "$?" == "1" ];then | 4 | if [ "$?" == "1" ];then |
5 | - kubectl create -f /tmp/local/sg-local-storage/sg-storage.yaml --record | ||
6 | - kubectl -n mmm-suplus-dev get svc | grep -q sg-local-storage | 5 | + kubectl create -f /tmp/test/performance-back/performance-back.yaml --record |
6 | + kubectl -n mmm-suplus-test get svc | grep -q performance-back | ||
7 | if [ "$?" == "0" ];then | 7 | if [ "$?" == "0" ];then |
8 | - echo "sg-local-storage service install success!" | 8 | + echo "performance-back service install success!" |
9 | else | 9 | else |
10 | - echo "sg-local-storage service install fail!" | 10 | + echo "performance-back service install fail!" |
11 | fi | 11 | fi |
12 | - kubectl -n mmm-suplus-dev get pods | grep -q sg-local-storage | 12 | + kubectl -n mmm-suplus-test get pods | grep -q performance-back |
13 | if [ "$?" == "0" ];then | 13 | if [ "$?" == "0" ];then |
14 | - echo "sg-local-storage deployment install success!" | 14 | + echo "performance-back deployment install success!" |
15 | else | 15 | else |
16 | - echo "sg-local-storage deployment install fail!" | 16 | + echo "performance-back deployment install fail!" |
17 | fi | 17 | fi |
18 | else | 18 | else |
19 | - kubectl delete -f /tmp/local/sg-local-storage/sg-storage.yaml | ||
20 | - kubectl -n mmm-suplus-dev get svc | grep -q sg-local-storage | 19 | + kubectl delete -f /tmp/test/performance-back/performance-back.yaml |
20 | + kubectl -n mmm-suplus-test get svc | grep -q performance-back | ||
21 | while [ "$?" == "0" ] | 21 | while [ "$?" == "0" ] |
22 | do | 22 | do |
23 | - kubectl -n mmm-suplus-dev get svc | grep -q sg-local-storage | 23 | + kubectl -n mmm-suplus-test get svc | grep -q performance-back |
24 | done | 24 | done |
25 | - kubectl -n mmm-suplus-dev get pods | grep -q sg-local-storage | 25 | + kubectl -n mmm-suplus-test get pods | grep -q performance-back |
26 | while [ "$?" == "0" ] | 26 | while [ "$?" == "0" ] |
27 | do | 27 | do |
28 | - kubectl -n mmm-suplus-dev get pods | grep -q sg-local-storage | 28 | + kubectl -n mmm-suplus-test get pods | grep -q performance-back |
29 | done | 29 | done |
30 | - kubectl create -f /tmp/local/sg-local-storage/sg-storage.yaml --record | ||
31 | - kubectl -n mmm-suplus-dev get svc | grep -q sg-local-storage | 30 | + kubectl create -f /tmp/test/performance-back/performance-back.yaml --record |
31 | + kubectl -n mmm-suplus-test get svc | grep -q performance-back | ||
32 | if [ "$?" == "0" ];then | 32 | if [ "$?" == "0" ];then |
33 | - echo "sg-local-storage service update success!" | 33 | + echo "performance-back service update success!" |
34 | else | 34 | else |
35 | - echo "sg-local-storage service update fail!" | 35 | + echo "performance-back service update fail!" |
36 | fi | 36 | fi |
37 | - kubectl -n mmm-suplus-dev get pods | grep -q sg-local-storage | 37 | + kubectl -n mmm-suplus-test get pods | grep -q performance-back |
38 | if [ "$?" == "0" ];then | 38 | if [ "$?" == "0" ];then |
39 | - echo "sg-local-storage deployment update success!" | 39 | + echo "performance-back deployment update success!" |
40 | else | 40 | else |
41 | - echo "sg-local-storage deployment update fail!" | 41 | + echo "performance-back deployment update fail!" |
42 | fi | 42 | fi |
43 | fi | 43 | fi |
1 | apiVersion: v1 | 1 | apiVersion: v1 |
2 | kind: Service | 2 | kind: Service |
3 | metadata: | 3 | metadata: |
4 | - name: sg-local-storage | ||
5 | - namespace: mmm-suplus-dev | 4 | + name: performance-back |
5 | + namespace: mmm-suplus-test | ||
6 | labels: | 6 | labels: |
7 | - k8s-app: sg-local-storage | 7 | + k8s-app: performance-back |
8 | spec: | 8 | spec: |
9 | ports: | 9 | ports: |
10 | - name: "http" | 10 | - name: "http" |
11 | port: 80 | 11 | port: 80 |
12 | - targetPort: 8080 | 12 | + targetPort: 8082 |
13 | - name: "https" | 13 | - name: "https" |
14 | port: 443 | 14 | port: 443 |
15 | targetPort: 443 | 15 | targetPort: 443 |
16 | selector: | 16 | selector: |
17 | - k8s-app: sg-local-storage | 17 | + k8s-app: performance-back |
18 | --- | 18 | --- |
19 | apiVersion: extensions/v1beta1 | 19 | apiVersion: extensions/v1beta1 |
20 | kind: Deployment | 20 | kind: Deployment |
21 | metadata: | 21 | metadata: |
22 | - name: sg-local-storage | ||
23 | - namespace: mmm-suplus-dev | 22 | + name: performance-back |
23 | + namespace: mmm-suplus-test | ||
24 | labels: | 24 | labels: |
25 | - k8s-app: sg-local-storage | 25 | + k8s-app: performance-back |
26 | spec: | 26 | spec: |
27 | replicas: 1 | 27 | replicas: 1 |
28 | template: | 28 | template: |
29 | metadata: | 29 | metadata: |
30 | labels: | 30 | labels: |
31 | - k8s-app: sg-local-storage | 31 | + k8s-app: performance-back |
32 | spec: | 32 | spec: |
33 | affinity: | 33 | affinity: |
34 | nodeAffinity: | 34 | nodeAffinity: |
@@ -46,17 +46,15 @@ spec: | @@ -46,17 +46,15 @@ spec: | ||
46 | - cn-hangzhou.i-bp1euf5u1ph9kbhtndhb | 46 | - cn-hangzhou.i-bp1euf5u1ph9kbhtndhb |
47 | - cn-hangzhou.i-bp1hyp5oips9cdwxxgxy | 47 | - cn-hangzhou.i-bp1hyp5oips9cdwxxgxy |
48 | containers: | 48 | containers: |
49 | - - name: sg-local-storage | ||
50 | - image: 192.168.0.243:5000/mmm/sg-storage:local | 49 | + - name: performance-back |
50 | + image: 192.168.0.243:5000/mmm/performance-back:dev | ||
51 | imagePullPolicy: Always | 51 | imagePullPolicy: Always |
52 | ports: | 52 | ports: |
53 | - - containerPort: 8080 | 53 | + - containerPort: 8082 |
54 | - containerPort: 443 | 54 | - containerPort: 443 |
55 | volumeMounts: | 55 | volumeMounts: |
56 | - mountPath: /opt/logs | 56 | - mountPath: /opt/logs |
57 | name: accesslogs | 57 | name: accesslogs |
58 | - - mountPath: /go/src/sg-storage/uploads | ||
59 | - name: sgstorage-pvc1 | ||
60 | env: | 58 | env: |
61 | - name: LOG_LEVEL | 59 | - name: LOG_LEVEL |
62 | value: "debug" | 60 | value: "debug" |
@@ -67,7 +65,7 @@ spec: | @@ -67,7 +65,7 @@ spec: | ||
67 | - name: ERROR_BASE_CODE_MULTIPLE | 65 | - name: ERROR_BASE_CODE_MULTIPLE |
68 | value: "1000" | 66 | value: "1000" |
69 | - name: POSTGRESQL_DB_NAME | 67 | - name: POSTGRESQL_DB_NAME |
70 | - value: "sg_storage_local" | 68 | + value: "performance_test" |
71 | - name: ENABLE_HTTPS | 69 | - name: ENABLE_HTTPS |
72 | value: "true" | 70 | value: "true" |
73 | - name: POSTGRESQL_USER | 71 | - name: POSTGRESQL_USER |
@@ -100,9 +98,23 @@ spec: | @@ -100,9 +98,23 @@ spec: | ||
100 | configMapKeyRef: | 98 | configMapKeyRef: |
101 | name: suplus-config | 99 | name: suplus-config |
102 | key: redis.port | 100 | key: redis.port |
101 | + - name: KAFKA_HOSTS | ||
102 | + valueFrom: | ||
103 | + configMapKeyRef: | ||
104 | + name: suplus-config | ||
105 | + key: kafka.host | ||
106 | + - name: KAFKA_PERFORMANCE_ID | ||
107 | + valueFrom: | ||
108 | + configMapKeyRef: | ||
109 | + name: suplus-config | ||
110 | + key: kafkaperformance.id | ||
111 | + - name: KAFKA_BUSINESS_TOPIC | ||
112 | + value: "mmm_business_test" | ||
113 | + - name: UCENTER_SERVICE_HOST | ||
114 | + value: "https://suplus-ucenter-test.fjmaimaimai.com" | ||
115 | + - name: BUSINESS_ADMIN_SERVICE_HOST | ||
116 | + value: "https://suplus-business-admin-test.fjmaimaimai.com" | ||
103 | volumes: | 117 | volumes: |
104 | - name: accesslogs | 118 | - name: accesslogs |
105 | emptyDir: {} | 119 | emptyDir: {} |
106 | - - name: sgstorage-pvc1 | ||
107 | - persistentVolumeClaim: | ||
108 | - claimName: sgstorage-pvc | ||
120 | + |
@@ -6,6 +6,7 @@ require ( | @@ -6,6 +6,7 @@ require ( | ||
6 | github.com/Shopify/sarama v1.25.0 | 6 | github.com/Shopify/sarama v1.25.0 |
7 | github.com/beego/beego/v2 v2.0.5 | 7 | github.com/beego/beego/v2 v2.0.5 |
8 | github.com/bwmarrin/snowflake v0.3.0 | 8 | github.com/bwmarrin/snowflake v0.3.0 |
9 | + github.com/dgrijalva/jwt-go v3.2.0+incompatible | ||
9 | github.com/go-pg/pg/v10 v10.10.7 | 10 | github.com/go-pg/pg/v10 v10.10.7 |
10 | github.com/linmadan/egglib-go v0.0.0-20210827085852-177fa745932d | 11 | github.com/linmadan/egglib-go v0.0.0-20210827085852-177fa745932d |
11 | ) | 12 | ) |
@@ -111,6 +111,7 @@ github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGii | @@ -111,6 +111,7 @@ github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGii | ||
111 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | 111 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
112 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | 112 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= |
113 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | 113 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
114 | +github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= | ||
114 | github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= | 115 | github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= |
115 | github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= | 116 | github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= |
116 | github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= | 117 | github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= |
go_build_main_go
0 → 100755
不能预览此文件类型
pkg/application/auth/command/login.go
0 → 100644
pkg/application/auth/service/auth.go
0 → 100644
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/auth/command" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
8 | +) | ||
9 | + | ||
10 | +type AuthService struct { | ||
11 | +} | ||
12 | + | ||
13 | +// Login PC端登录 | ||
14 | +func (service *AuthService) Login(loginCommand *command.LoginCommand) (interface{}, error) { | ||
15 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
16 | + if err != nil { | ||
17 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
18 | + } | ||
19 | + if errStart := transactionContext.StartTransaction(); errStart != nil { | ||
20 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, errStart.Error()) | ||
21 | + } | ||
22 | + defer func() { | ||
23 | + _ = transactionContext.RollbackTransaction() | ||
24 | + }() | ||
25 | + //统一用户中心登录 | ||
26 | + authCodeReply, err := factory.UCenterApi().AuthCode(loginCommand.Code) | ||
27 | + if err != nil || !authCodeReply.IsOk() { | ||
28 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统一用户中心认证失败") | ||
29 | + } | ||
30 | + //用户权限校验 | ||
31 | + userAuthReply, err := factory.BusinessAdminApi().GetUserAuth(authCodeReply.Data.MUid, loginCommand.PlatformId) | ||
32 | + if err != nil { | ||
33 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户鉴权失败") | ||
34 | + } | ||
35 | + if !userAuthReply.IsOk() { | ||
36 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, userAuthReply.Message()) | ||
37 | + } | ||
38 | + //获取公司数据 | ||
39 | + companyRepository := factory.CreateCompanyRepository(map[string]interface{}{ | ||
40 | + "transactionContext": transactionContext, | ||
41 | + }) | ||
42 | + company, err := companyRepository.FindOne(map[string]interface{}{ | ||
43 | + "id": authCodeReply.Data.CompanyId, | ||
44 | + }) | ||
45 | + if err != nil { | ||
46 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取公司数据失败") | ||
47 | + } | ||
48 | + userRepository := factory.CreateUserRepository(map[string]interface{}{ | ||
49 | + "transactionContext": transactionContext, | ||
50 | + }) | ||
51 | + user, err := userRepository.FindOne(map[string]interface{}{ | ||
52 | + "id": authCodeReply.Data.MUid, | ||
53 | + "companyId": company.Id, | ||
54 | + }) | ||
55 | + if err != nil { | ||
56 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取公司数据失败") | ||
57 | + } | ||
58 | + if user.Status != domain.UserStatusEnable { | ||
59 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户被禁用") | ||
60 | + } | ||
61 | + userAuth := &domain.UserAuth{ | ||
62 | + UserId: user.Id, | ||
63 | + CompanyId: user.CompanyId, | ||
64 | + Phone: user.Account, | ||
65 | + PlatformId: loginCommand.PlatformId, | ||
66 | + Name: user.Name, | ||
67 | + AdminType: user.AdminType, | ||
68 | + } | ||
69 | + accessToken, err := userAuth.CreateAccessToken() | ||
70 | + if err != nil { | ||
71 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
72 | + } | ||
73 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
74 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
75 | + } | ||
76 | + return map[string]interface{}{ | ||
77 | + "access": map[string]interface{}{ | ||
78 | + "accessToken": accessToken, | ||
79 | + "expiresIn": domain.JWTExpiresSecond, | ||
80 | + }, | ||
81 | + }, nil | ||
82 | +} |
pkg/application/auth/service/auth_test.go
0 → 100644
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
6 | + "testing" | ||
7 | +) | ||
8 | + | ||
9 | +func TestAdminToken(t *testing.T) { | ||
10 | + domain.JWTExpiresSecond = 3600 * 24 * 365 | ||
11 | + userAuth := &domain.UserAuth{ | ||
12 | + UserId: 3325567738895360, | ||
13 | + CompanyId: 507, | ||
14 | + Phone: "18559023318", | ||
15 | + PlatformId: 28, | ||
16 | + Name: "庄敏学", | ||
17 | + AdminType: 2, | ||
18 | + } | ||
19 | + fmt.Println(userAuth.CreateAccessToken()) | ||
20 | +} | ||
21 | + | ||
22 | +func TestFontToken(t *testing.T) { | ||
23 | + domain.JWTExpiresSecond = 3600 * 24 * 365 | ||
24 | + userAuth := &domain.UserAuth{ | ||
25 | + UserId: 3325567738895360, | ||
26 | + CompanyId: 507, | ||
27 | + Phone: "18559023318", | ||
28 | + PlatformId: 29, | ||
29 | + Name: "庄敏学", | ||
30 | + AdminType: 2, | ||
31 | + } | ||
32 | + fmt.Println(userAuth.CreateAccessToken()) | ||
33 | +} |
1 | package command | 1 | package command |
2 | 2 | ||
3 | -//AddCompanyCommand 数据来源 企业平台 推送的消息 | ||
4 | -//新建公司 | 3 | +// AddCompanyCommand 数据来源 企业平台 推送的消息 |
4 | +// 新建公司 | ||
5 | type SaveCompanyCommand struct { | 5 | type SaveCompanyCommand struct { |
6 | //新添加的公司 | 6 | //新添加的公司 |
7 | - Comapany struct { | 7 | + Company struct { |
8 | Id int64 `json:"id" ` | 8 | Id int64 `json:"id" ` |
9 | Logo string `json:"logo"` // 公司logo | 9 | Logo string `json:"logo"` // 公司logo |
10 | Name string `json:"name"` // 公司名称 | 10 | Name string `json:"name"` // 公司名称 |
@@ -20,38 +20,38 @@ type SyncDataCompanyService struct { | @@ -20,38 +20,38 @@ type SyncDataCompanyService struct { | ||
20 | // // add:添加,edit:编辑,setCompanyCharge:更改公司主管,changeAdmin换管理员 | 20 | // // add:添加,edit:编辑,setCompanyCharge:更改公司主管,changeAdmin换管理员 |
21 | // Action string `json:"action"` | 21 | // Action string `json:"action"` |
22 | // // 具体的对象JSON数据 | 22 | // // 具体的对象JSON数据 |
23 | -// Datas json.RawMessage `json:"data"` | 23 | +// Data json.RawMessage `json:"data"` |
24 | // } | 24 | // } |
25 | 25 | ||
26 | -//从BusinessAdmins 接收消息,变更公司数据 | 26 | +// 从BusinessAdmins 接收消息,变更公司数据 |
27 | func (c SyncDataCompanyService) FromBusinessAdmin(param *domain.MessageBody) error { | 27 | func (c SyncDataCompanyService) FromBusinessAdmin(param *domain.MessageBody) error { |
28 | action := param.Module + "/" + param.Action | 28 | action := param.Module + "/" + param.Action |
29 | var err error | 29 | var err error |
30 | switch action { | 30 | switch action { |
31 | case "company/add": | 31 | case "company/add": |
32 | var param1 command.SaveCompanyCommand | 32 | var param1 command.SaveCompanyCommand |
33 | - err = json.Unmarshal(param.Datas, ¶m1) | 33 | + err = json.Unmarshal(param.Data, ¶m1) |
34 | if err != nil { | 34 | if err != nil { |
35 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 35 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
36 | } | 36 | } |
37 | err = c.addCompany(¶m1) | 37 | err = c.addCompany(¶m1) |
38 | case "company/edit": | 38 | case "company/edit": |
39 | var param2 command.SaveCompanyCommand | 39 | var param2 command.SaveCompanyCommand |
40 | - err = json.Unmarshal(param.Datas, ¶m2) | 40 | + err = json.Unmarshal(param.Data, ¶m2) |
41 | if err != nil { | 41 | if err != nil { |
42 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 42 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
43 | } | 43 | } |
44 | err = c.editCompany(¶m2) | 44 | err = c.editCompany(¶m2) |
45 | case "company/setCompanyCharge": | 45 | case "company/setCompanyCharge": |
46 | var param3 command.SetCompanyCharge | 46 | var param3 command.SetCompanyCharge |
47 | - err = json.Unmarshal(param.Datas, ¶m3) | 47 | + err = json.Unmarshal(param.Data, ¶m3) |
48 | if err != nil { | 48 | if err != nil { |
49 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 49 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
50 | } | 50 | } |
51 | err = c.setCompanyCharge(¶m3) | 51 | err = c.setCompanyCharge(¶m3) |
52 | case "company/changeAdmin": | 52 | case "company/changeAdmin": |
53 | var param3 command.ChangeAdminCommand | 53 | var param3 command.ChangeAdminCommand |
54 | - err = json.Unmarshal(param.Datas, ¶m3) | 54 | + err = json.Unmarshal(param.Data, ¶m3) |
55 | if err != nil { | 55 | if err != nil { |
56 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 56 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
57 | } | 57 | } |
@@ -63,9 +63,9 @@ func (c SyncDataCompanyService) FromBusinessAdmin(param *domain.MessageBody) err | @@ -63,9 +63,9 @@ func (c SyncDataCompanyService) FromBusinessAdmin(param *domain.MessageBody) err | ||
63 | return err | 63 | return err |
64 | } | 64 | } |
65 | 65 | ||
66 | -//addCompany | ||
67 | -//从BusinessAdmins 接收消息 添加公司 | ||
68 | -//module="company" action="add" | 66 | +// addCompany |
67 | +// 从BusinessAdmins 接收消息 添加公司 | ||
68 | +// module="company" action="add" | ||
69 | func (c SyncDataCompanyService) addCompany(param *command.SaveCompanyCommand) error { | 69 | func (c SyncDataCompanyService) addCompany(param *command.SaveCompanyCommand) error { |
70 | transactionContext, err := factory.CreateTransactionContext(nil) | 70 | transactionContext, err := factory.CreateTransactionContext(nil) |
71 | if err != nil { | 71 | if err != nil { |
@@ -79,14 +79,14 @@ func (c SyncDataCompanyService) addCompany(param *command.SaveCompanyCommand) er | @@ -79,14 +79,14 @@ func (c SyncDataCompanyService) addCompany(param *command.SaveCompanyCommand) er | ||
79 | }() | 79 | }() |
80 | nowTime := time.Now() | 80 | nowTime := time.Now() |
81 | newCompany := domain.Company{ | 81 | newCompany := domain.Company{ |
82 | - Id: param.Comapany.Id, | ||
83 | - Logo: param.Comapany.Logo, | ||
84 | - Name: param.Comapany.Name, | ||
85 | - Status: param.Comapany.Status, | ||
86 | - UpdateAt: nowTime, | ||
87 | - CreateAt: nowTime, | 82 | + Id: param.Company.Id, |
83 | + Logo: param.Company.Logo, | ||
84 | + Name: param.Company.Name, | ||
85 | + Status: param.Company.Status, | ||
86 | + UpdatedAt: nowTime, | ||
87 | + CreatedAt: nowTime, | ||
88 | ChargeUserIds: []int64{}, | 88 | ChargeUserIds: []int64{}, |
89 | - DeleteAt: nil, | 89 | + DeletedAt: nil, |
90 | } | 90 | } |
91 | 91 | ||
92 | newUser := domain.User{ | 92 | newUser := domain.User{ |
@@ -97,9 +97,9 @@ func (c SyncDataCompanyService) addCompany(param *command.SaveCompanyCommand) er | @@ -97,9 +97,9 @@ func (c SyncDataCompanyService) addCompany(param *command.SaveCompanyCommand) er | ||
97 | AdminType: param.User.AdminType, | 97 | AdminType: param.User.AdminType, |
98 | Name: param.User.Name, | 98 | Name: param.User.Name, |
99 | Status: param.User.Status, | 99 | Status: param.User.Status, |
100 | - UpdateAt: nowTime, | ||
101 | - DeleteAt: nil, | ||
102 | - CreateAt: nowTime, | 100 | + UpdatedAt: nowTime, |
101 | + DeletedAt: nil, | ||
102 | + CreatedAt: nowTime, | ||
103 | } | 103 | } |
104 | companyRepo := factory.CreateCompanyRepository(map[string]interface{}{ | 104 | companyRepo := factory.CreateCompanyRepository(map[string]interface{}{ |
105 | "transactionContext": transactionContext, | 105 | "transactionContext": transactionContext, |
@@ -121,9 +121,9 @@ func (c SyncDataCompanyService) addCompany(param *command.SaveCompanyCommand) er | @@ -121,9 +121,9 @@ func (c SyncDataCompanyService) addCompany(param *command.SaveCompanyCommand) er | ||
121 | return nil | 121 | return nil |
122 | } | 122 | } |
123 | 123 | ||
124 | -//editCompany | ||
125 | -//从BusinessAdmins 接收消息 更新公司 | ||
126 | -//module="company" action="edit" | 124 | +// editCompany |
125 | +// 从BusinessAdmins 接收消息 更新公司 | ||
126 | +// module="company" action="edit" | ||
127 | func (c SyncDataCompanyService) editCompany(param *command.SaveCompanyCommand) error { | 127 | func (c SyncDataCompanyService) editCompany(param *command.SaveCompanyCommand) error { |
128 | transactionContext, err := factory.CreateTransactionContext(nil) | 128 | transactionContext, err := factory.CreateTransactionContext(nil) |
129 | if err != nil { | 129 | if err != nil { |
@@ -144,7 +144,7 @@ func (c SyncDataCompanyService) editCompany(param *command.SaveCompanyCommand) e | @@ -144,7 +144,7 @@ func (c SyncDataCompanyService) editCompany(param *command.SaveCompanyCommand) e | ||
144 | 144 | ||
145 | _, companyList, err := companyRepo.Find(map[string]interface{}{ | 145 | _, companyList, err := companyRepo.Find(map[string]interface{}{ |
146 | "limit": 1, | 146 | "limit": 1, |
147 | - "id": param.Comapany.Id, | 147 | + "id": param.Company.Id, |
148 | }) | 148 | }) |
149 | if err != nil { | 149 | if err != nil { |
150 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 150 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -165,22 +165,22 @@ func (c SyncDataCompanyService) editCompany(param *command.SaveCompanyCommand) e | @@ -165,22 +165,22 @@ func (c SyncDataCompanyService) editCompany(param *command.SaveCompanyCommand) e | ||
165 | newCompany = companyList[0] | 165 | newCompany = companyList[0] |
166 | } else { | 166 | } else { |
167 | newCompany = &domain.Company{ | 167 | newCompany = &domain.Company{ |
168 | - CreateAt: nowTime, | 168 | + CreatedAt: nowTime, |
169 | } | 169 | } |
170 | } | 170 | } |
171 | if len(userList) > 0 { | 171 | if len(userList) > 0 { |
172 | newUser = userList[0] | 172 | newUser = userList[0] |
173 | } else { | 173 | } else { |
174 | newUser = &domain.User{ | 174 | newUser = &domain.User{ |
175 | - CreateAt: nowTime, | 175 | + CreatedAt: nowTime, |
176 | } | 176 | } |
177 | } | 177 | } |
178 | 178 | ||
179 | - newCompany.Id = param.Comapany.Id | ||
180 | - newCompany.Logo = param.Comapany.Logo | ||
181 | - newCompany.Name = param.Comapany.Name | ||
182 | - newCompany.Status = param.Comapany.Status | ||
183 | - newCompany.UpdateAt = nowTime | 179 | + newCompany.Id = param.Company.Id |
180 | + newCompany.Logo = param.Company.Logo | ||
181 | + newCompany.Name = param.Company.Name | ||
182 | + newCompany.Status = param.Company.Status | ||
183 | + newCompany.UpdatedAt = nowTime | ||
184 | 184 | ||
185 | newUser.Id = param.User.Id | 185 | newUser.Id = param.User.Id |
186 | newUser.Account = param.User.Phone | 186 | newUser.Account = param.User.Phone |
@@ -189,7 +189,7 @@ func (c SyncDataCompanyService) editCompany(param *command.SaveCompanyCommand) e | @@ -189,7 +189,7 @@ func (c SyncDataCompanyService) editCompany(param *command.SaveCompanyCommand) e | ||
189 | newUser.AdminType = param.User.AdminType | 189 | newUser.AdminType = param.User.AdminType |
190 | newUser.Name = param.User.Name | 190 | newUser.Name = param.User.Name |
191 | newUser.Status = param.User.Status | 191 | newUser.Status = param.User.Status |
192 | - newUser.UpdateAt = nowTime | 192 | + newUser.UpdatedAt = nowTime |
193 | if len(companyList) > 0 { | 193 | if len(companyList) > 0 { |
194 | _, err = companyRepo.Update(newCompany) | 194 | _, err = companyRepo.Update(newCompany) |
195 | if err != nil { | 195 | if err != nil { |
@@ -218,7 +218,7 @@ func (c SyncDataCompanyService) editCompany(param *command.SaveCompanyCommand) e | @@ -218,7 +218,7 @@ func (c SyncDataCompanyService) editCompany(param *command.SaveCompanyCommand) e | ||
218 | return nil | 218 | return nil |
219 | } | 219 | } |
220 | 220 | ||
221 | -//module="company" action="setCompanyCharge" | 221 | +// module="company" action="setCompanyCharge" |
222 | func (srv SyncDataCompanyService) setCompanyCharge(param *command.SetCompanyCharge) error { | 222 | func (srv SyncDataCompanyService) setCompanyCharge(param *command.SetCompanyCharge) error { |
223 | transactionContext, err := factory.CreateTransactionContext(nil) | 223 | transactionContext, err := factory.CreateTransactionContext(nil) |
224 | if err != nil { | 224 | if err != nil { |
@@ -245,7 +245,7 @@ func (srv SyncDataCompanyService) setCompanyCharge(param *command.SetCompanyChar | @@ -245,7 +245,7 @@ func (srv SyncDataCompanyService) setCompanyCharge(param *command.SetCompanyChar | ||
245 | } | 245 | } |
246 | for i := range companyList { | 246 | for i := range companyList { |
247 | companyList[i].ChargeUserIds = param.ChargeUserIds | 247 | companyList[i].ChargeUserIds = param.ChargeUserIds |
248 | - companyList[i].UpdateAt = time.Now() | 248 | + companyList[i].UpdatedAt = time.Now() |
249 | _, err = companyRepo.Update(companyList[i]) | 249 | _, err = companyRepo.Update(companyList[i]) |
250 | if err != nil { | 250 | if err != nil { |
251 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 251 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -257,9 +257,9 @@ func (srv SyncDataCompanyService) setCompanyCharge(param *command.SetCompanyChar | @@ -257,9 +257,9 @@ func (srv SyncDataCompanyService) setCompanyCharge(param *command.SetCompanyChar | ||
257 | return nil | 257 | return nil |
258 | } | 258 | } |
259 | 259 | ||
260 | -//changeAdmin | ||
261 | -//从BusinessAdmins 接收消息 变更主管 | ||
262 | -//module="company" action="changeAdmin" | 260 | +// changeAdmin |
261 | +// 从BusinessAdmins 接收消息 变更主管 | ||
262 | +// module="company" action="changeAdmin" | ||
263 | func (srv SyncDataCompanyService) changeAdmin(param *command.ChangeAdminCommand) error { | 263 | func (srv SyncDataCompanyService) changeAdmin(param *command.ChangeAdminCommand) error { |
264 | transactionContext, err := factory.CreateTransactionContext(nil) | 264 | transactionContext, err := factory.CreateTransactionContext(nil) |
265 | if err != nil { | 265 | if err != nil { |
@@ -287,7 +287,7 @@ func (srv SyncDataCompanyService) changeAdmin(param *command.ChangeAdminCommand) | @@ -287,7 +287,7 @@ func (srv SyncDataCompanyService) changeAdmin(param *command.ChangeAdminCommand) | ||
287 | //修改旧管理员 为普通用户 | 287 | //修改旧管理员 为普通用户 |
288 | for i := range userList { | 288 | for i := range userList { |
289 | userList[i].AdminType = domain.UserTypeCommon | 289 | userList[i].AdminType = domain.UserTypeCommon |
290 | - userList[i].UpdateAt = time.Now() | 290 | + userList[i].UpdatedAt = time.Now() |
291 | _, err := userRepo.Update(userList[i]) | 291 | _, err := userRepo.Update(userList[i]) |
292 | if err != nil { | 292 | if err != nil { |
293 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 293 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -305,7 +305,7 @@ func (srv SyncDataCompanyService) changeAdmin(param *command.ChangeAdminCommand) | @@ -305,7 +305,7 @@ func (srv SyncDataCompanyService) changeAdmin(param *command.ChangeAdminCommand) | ||
305 | //修改为管理员用户 | 305 | //修改为管理员用户 |
306 | for i := range userList2 { | 306 | for i := range userList2 { |
307 | userList[i].AdminType = domain.UserTypeManager | 307 | userList[i].AdminType = domain.UserTypeManager |
308 | - userList[i].UpdateAt = time.Now() | 308 | + userList[i].UpdatedAt = time.Now() |
309 | _, err := userRepo.Update(userList[i]) | 309 | _, err := userRepo.Update(userList[i]) |
310 | if err != nil { | 310 | if err != nil { |
311 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 311 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -18,7 +18,7 @@ type SyncDataDepartmentService struct{} | @@ -18,7 +18,7 @@ type SyncDataDepartmentService struct{} | ||
18 | // // add:添加,edit:编辑,batchDelete:批量删除,import:导入部门 | 18 | // // add:添加,edit:编辑,batchDelete:批量删除,import:导入部门 |
19 | // Action string `json:"action"` | 19 | // Action string `json:"action"` |
20 | // // 具体的对象JSON数据 | 20 | // // 具体的对象JSON数据 |
21 | -// Datas json.RawMessage `json:"data"` | 21 | +// Data json.RawMessage `json:"data"` |
22 | // } | 22 | // } |
23 | 23 | ||
24 | func (srv SyncDataDepartmentService) FromBusinessAdmin(param *domain.MessageBody) error { | 24 | func (srv SyncDataDepartmentService) FromBusinessAdmin(param *domain.MessageBody) error { |
@@ -27,28 +27,28 @@ func (srv SyncDataDepartmentService) FromBusinessAdmin(param *domain.MessageBody | @@ -27,28 +27,28 @@ func (srv SyncDataDepartmentService) FromBusinessAdmin(param *domain.MessageBody | ||
27 | switch action { | 27 | switch action { |
28 | case "department/add": | 28 | case "department/add": |
29 | var param1 command.AddDepartmentCommand | 29 | var param1 command.AddDepartmentCommand |
30 | - err = json.Unmarshal(param.Datas, ¶m1) | 30 | + err = json.Unmarshal(param.Data, ¶m1) |
31 | if err != nil { | 31 | if err != nil { |
32 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 32 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
33 | } | 33 | } |
34 | err = srv.addDepartment(¶m1) | 34 | err = srv.addDepartment(¶m1) |
35 | case "department/edit": | 35 | case "department/edit": |
36 | var param1 command.EditDepartmentCommand | 36 | var param1 command.EditDepartmentCommand |
37 | - err = json.Unmarshal(param.Datas, ¶m1) | 37 | + err = json.Unmarshal(param.Data, ¶m1) |
38 | if err != nil { | 38 | if err != nil { |
39 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 39 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
40 | } | 40 | } |
41 | err = srv.editDepartment(¶m1) | 41 | err = srv.editDepartment(¶m1) |
42 | case "department/batchDelete": | 42 | case "department/batchDelete": |
43 | var param1 command.BatchDeleteCommand | 43 | var param1 command.BatchDeleteCommand |
44 | - err = json.Unmarshal(param.Datas, ¶m1) | 44 | + err = json.Unmarshal(param.Data, ¶m1) |
45 | if err != nil { | 45 | if err != nil { |
46 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 46 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
47 | } | 47 | } |
48 | err = srv.batchDeleteDepartment(¶m1) | 48 | err = srv.batchDeleteDepartment(¶m1) |
49 | case "department/import": | 49 | case "department/import": |
50 | var param1 []command.ImportDepartmentCommand | 50 | var param1 []command.ImportDepartmentCommand |
51 | - err = json.Unmarshal(param.Datas, ¶m1) | 51 | + err = json.Unmarshal(param.Data, ¶m1) |
52 | if err != nil { | 52 | if err != nil { |
53 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 53 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
54 | } | 54 | } |
@@ -57,9 +57,9 @@ func (srv SyncDataDepartmentService) FromBusinessAdmin(param *domain.MessageBody | @@ -57,9 +57,9 @@ func (srv SyncDataDepartmentService) FromBusinessAdmin(param *domain.MessageBody | ||
57 | return err | 57 | return err |
58 | } | 58 | } |
59 | 59 | ||
60 | -//AddDepartment | ||
61 | -//从BusinessAdmins 接收消息 添加部门 | ||
62 | -//module="department" action="add" | 60 | +// AddDepartment |
61 | +// 从BusinessAdmins 接收消息 添加部门 | ||
62 | +// module="department" action="add" | ||
63 | func (srv SyncDataDepartmentService) addDepartment(param *command.AddDepartmentCommand) error { | 63 | func (srv SyncDataDepartmentService) addDepartment(param *command.AddDepartmentCommand) error { |
64 | transactionContext, err := factory.CreateTransactionContext(nil) | 64 | transactionContext, err := factory.CreateTransactionContext(nil) |
65 | if err != nil { | 65 | if err != nil { |
@@ -81,9 +81,9 @@ func (srv SyncDataDepartmentService) addDepartment(param *command.AddDepartmentC | @@ -81,9 +81,9 @@ func (srv SyncDataDepartmentService) addDepartment(param *command.AddDepartmentC | ||
81 | ParentId: param.ParentId, | 81 | ParentId: param.ParentId, |
82 | ChargeUserIds: param.ChargeUserIds, | 82 | ChargeUserIds: param.ChargeUserIds, |
83 | Path: param.Path, | 83 | Path: param.Path, |
84 | - CreateAt: nowTime, | ||
85 | - UpdateAt: nowTime, | ||
86 | - DeleteAt: nil, | 84 | + CreatedAt: nowTime, |
85 | + UpdatedAt: nowTime, | ||
86 | + DeletedAt: nil, | ||
87 | } | 87 | } |
88 | 88 | ||
89 | departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{ | 89 | departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{ |
@@ -99,9 +99,9 @@ func (srv SyncDataDepartmentService) addDepartment(param *command.AddDepartmentC | @@ -99,9 +99,9 @@ func (srv SyncDataDepartmentService) addDepartment(param *command.AddDepartmentC | ||
99 | return nil | 99 | return nil |
100 | } | 100 | } |
101 | 101 | ||
102 | -//EditDepartment | ||
103 | -//从BusinessAdmins 接收消息 编辑部门 | ||
104 | -//module="department" action="edit" | 102 | +// EditDepartment |
103 | +// 从BusinessAdmins 接收消息 编辑部门 | ||
104 | +// module="department" action="edit" | ||
105 | func (srv SyncDataDepartmentService) editDepartment(param *command.EditDepartmentCommand) error { | 105 | func (srv SyncDataDepartmentService) editDepartment(param *command.EditDepartmentCommand) error { |
106 | transactionContext, err := factory.CreateTransactionContext(nil) | 106 | transactionContext, err := factory.CreateTransactionContext(nil) |
107 | if err != nil { | 107 | if err != nil { |
@@ -130,11 +130,19 @@ func (srv SyncDataDepartmentService) editDepartment(param *command.EditDepartmen | @@ -130,11 +130,19 @@ func (srv SyncDataDepartmentService) editDepartment(param *command.EditDepartmen | ||
130 | for i := range departmentList { | 130 | for i := range departmentList { |
131 | if departmentList[i].Id == param.Id { | 131 | if departmentList[i].Id == param.Id { |
132 | departmentList[i].CompanyId = param.CompanyId | 132 | departmentList[i].CompanyId = param.CompanyId |
133 | - departmentList[i].Name = param.Name | ||
134 | - departmentList[i].Name = param.Path | ||
135 | - departmentList[i].ChargeUserIds = param.ChargeUserIds | ||
136 | - departmentList[i].Level = param.Level | ||
137 | departmentList[i].ParentId = param.ParentId | 133 | departmentList[i].ParentId = param.ParentId |
134 | + if param.Name != "" { | ||
135 | + departmentList[i].Name = param.Name | ||
136 | + } | ||
137 | + if param.Path != "" { | ||
138 | + departmentList[i].Path = param.Path | ||
139 | + } | ||
140 | + if param.Level > 0 { | ||
141 | + departmentList[i].Level = param.Level | ||
142 | + } | ||
143 | + if len(param.ChargeUserIds) > 0 { | ||
144 | + departmentList[i].ChargeUserIds = param.ChargeUserIds | ||
145 | + } | ||
138 | continue | 146 | continue |
139 | } | 147 | } |
140 | 148 | ||
@@ -158,9 +166,9 @@ func (srv SyncDataDepartmentService) editDepartment(param *command.EditDepartmen | @@ -158,9 +166,9 @@ func (srv SyncDataDepartmentService) editDepartment(param *command.EditDepartmen | ||
158 | return nil | 166 | return nil |
159 | } | 167 | } |
160 | 168 | ||
161 | -//batchDelete | ||
162 | -//从BusinessAdmins 接收消息 删除部门 | ||
163 | -//module="department" action="batchDelete" | 169 | +// batchDelete |
170 | +// 从BusinessAdmins 接收消息 删除部门 | ||
171 | +// module="department" action="batchDelete" | ||
164 | func (srv SyncDataDepartmentService) batchDeleteDepartment(param *command.BatchDeleteCommand) error { | 172 | func (srv SyncDataDepartmentService) batchDeleteDepartment(param *command.BatchDeleteCommand) error { |
165 | if len(param.Ids) == 0 { | 173 | if len(param.Ids) == 0 { |
166 | return nil | 174 | return nil |
@@ -188,9 +196,9 @@ func (srv SyncDataDepartmentService) batchDeleteDepartment(param *command.BatchD | @@ -188,9 +196,9 @@ func (srv SyncDataDepartmentService) batchDeleteDepartment(param *command.BatchD | ||
188 | return nil | 196 | return nil |
189 | } | 197 | } |
190 | 198 | ||
191 | -//importDepartment | ||
192 | -//从BusinessAdmins 接收消息 导入部门数据 | ||
193 | -//module="department" action="import" | 199 | +// importDepartment |
200 | +// 从BusinessAdmins 接收消息 导入部门数据 | ||
201 | +// module="department" action="import" | ||
194 | func (srv SyncDataDepartmentService) importDepartment(param []command.ImportDepartmentCommand) error { | 202 | func (srv SyncDataDepartmentService) importDepartment(param []command.ImportDepartmentCommand) error { |
195 | transactionContext, err := factory.CreateTransactionContext(nil) | 203 | transactionContext, err := factory.CreateTransactionContext(nil) |
196 | if err != nil { | 204 | if err != nil { |
@@ -215,9 +223,9 @@ func (srv SyncDataDepartmentService) importDepartment(param []command.ImportDepa | @@ -215,9 +223,9 @@ func (srv SyncDataDepartmentService) importDepartment(param []command.ImportDepa | ||
215 | ParentId: param[i].ParentId, | 223 | ParentId: param[i].ParentId, |
216 | ChargeUserIds: []int64{}, | 224 | ChargeUserIds: []int64{}, |
217 | Path: param[i].Path, | 225 | Path: param[i].Path, |
218 | - CreateAt: nowTime, | ||
219 | - UpdateAt: nowTime, | ||
220 | - DeleteAt: nil, | 226 | + CreatedAt: nowTime, |
227 | + UpdatedAt: nowTime, | ||
228 | + DeletedAt: nil, | ||
221 | } | 229 | } |
222 | _, err = departmentRepo.Insert(&newDepartment) | 230 | _, err = departmentRepo.Insert(&newDepartment) |
223 | if err != nil { | 231 | if err != nil { |
pkg/application/factory/api.go
0 → 100644
1 | +package factory | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/serviceGateway" | ||
6 | +) | ||
7 | + | ||
8 | +func UCenterApi() domain.UCenterApi { | ||
9 | + return serviceGateway.NewHttpLibUCenterApiServiceGateway() | ||
10 | +} | ||
11 | + | ||
12 | +func BusinessAdminApi() domain.BusinessAdminApi { | ||
13 | + return serviceGateway.NewHttpLibBusinessAdminServiceGateway() | ||
14 | +} |
@@ -57,6 +57,14 @@ func CreateDepartmentRepository(options map[string]interface{}) domain.Departmen | @@ -57,6 +57,14 @@ func CreateDepartmentRepository(options map[string]interface{}) domain.Departmen | ||
57 | return repository.NewDepartmentRepository(transactionContext) | 57 | return repository.NewDepartmentRepository(transactionContext) |
58 | } | 58 | } |
59 | 59 | ||
60 | +func CreatePositionRepository(options map[string]interface{}) domain.PositionRepository { | ||
61 | + var transactionContext *pg.TransactionContext | ||
62 | + if value, ok := options["transactionContext"]; ok { | ||
63 | + transactionContext = value.(*pg.TransactionContext) | ||
64 | + } | ||
65 | + return repository.NewPositionRepository(transactionContext) | ||
66 | +} | ||
67 | + | ||
60 | func CreateRoleRepository(options map[string]interface{}) domain.RoleRepository { | 68 | func CreateRoleRepository(options map[string]interface{}) domain.RoleRepository { |
61 | var transactionContext *pg.TransactionContext | 69 | var transactionContext *pg.TransactionContext |
62 | if value, ok := options["transactionContext"]; ok { | 70 | if value, ok := options["transactionContext"]; ok { |
1 | +package command | ||
2 | + | ||
3 | +type SavePositionCommand struct { | ||
4 | + //职位ID | ||
5 | + Id int64 `json:"id"` | ||
6 | + //公司ID | ||
7 | + CompanyId int64 `json:"company_id"` | ||
8 | + //职位名称 | ||
9 | + Name string `json:"name"` | ||
10 | + //父级职位ID | ||
11 | + ParentId int64 `json:"parent_id"` | ||
12 | + //职位路径 | ||
13 | + Path string `json:"path"` | ||
14 | + //职位层级 | ||
15 | + Level int `json:"level"` | ||
16 | +} |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "encoding/json" | ||
5 | + "github.com/linmadan/egglib-go/core/application" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/position/command" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
9 | +) | ||
10 | + | ||
11 | +type SyncDataPositionService struct{} | ||
12 | + | ||
13 | +func (service SyncDataPositionService) FromBusinessAdmin(param *domain.MessageBody) error { | ||
14 | + var err error | ||
15 | + switch param.Action { | ||
16 | + //新增-编辑职位 | ||
17 | + case "add", "edit": | ||
18 | + createPositionCommand := &command.SavePositionCommand{} | ||
19 | + err = json.Unmarshal(param.Data, createPositionCommand) | ||
20 | + if err != nil { | ||
21 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
22 | + } | ||
23 | + err = service.CreateOrUpdatePosition(createPositionCommand) | ||
24 | + //批量删除职位 | ||
25 | + case "batchDelete": | ||
26 | + batchDeletePositionCommand := &command.BatchDeletePositionCommand{} | ||
27 | + err = json.Unmarshal(param.Data, batchDeletePositionCommand) | ||
28 | + if err != nil { | ||
29 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
30 | + } | ||
31 | + err = service.BatchDeletePosition(batchDeletePositionCommand) | ||
32 | + } | ||
33 | + return err | ||
34 | +} | ||
35 | + | ||
36 | +// CreateOrUpdatePosition 新增职位 | ||
37 | +func (service SyncDataPositionService) CreateOrUpdatePosition(positionCommand *command.SavePositionCommand) error { | ||
38 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
39 | + if err != nil { | ||
40 | + return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
41 | + } | ||
42 | + if err := transactionContext.StartTransaction(); err != nil { | ||
43 | + return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
44 | + } | ||
45 | + defer func() { | ||
46 | + _ = transactionContext.RollbackTransaction() | ||
47 | + }() | ||
48 | + positionRepository := factory.CreatePositionRepository(map[string]interface{}{ | ||
49 | + "transactionContext": transactionContext, | ||
50 | + }) | ||
51 | + position := &domain.Position{ | ||
52 | + Id: positionCommand.Id, | ||
53 | + CompanyId: positionCommand.CompanyId, | ||
54 | + Name: positionCommand.Name, | ||
55 | + ParentId: positionCommand.ParentId, | ||
56 | + Path: positionCommand.Path, | ||
57 | + Level: positionCommand.Level, | ||
58 | + } | ||
59 | + pdm, _ := positionRepository.FindOne(map[string]interface{}{"id": position.Id}) | ||
60 | + if pdm != nil && pdm.Id > 0 { | ||
61 | + _, err = positionRepository.Update(position) | ||
62 | + } else { | ||
63 | + _, err = positionRepository.Insert(position) | ||
64 | + } | ||
65 | + if err != nil { | ||
66 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
67 | + } | ||
68 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
69 | + return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
70 | + } | ||
71 | + return nil | ||
72 | +} | ||
73 | + | ||
74 | +// BatchDeletePosition 批量删除职位 | ||
75 | +func (service SyncDataPositionService) BatchDeletePosition(batchDeletePositionCommand *command.BatchDeletePositionCommand) error { | ||
76 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
77 | + if err != nil { | ||
78 | + return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
79 | + } | ||
80 | + if err := transactionContext.StartTransaction(); err != nil { | ||
81 | + return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
82 | + } | ||
83 | + defer func() { | ||
84 | + _ = transactionContext.RollbackTransaction() | ||
85 | + }() | ||
86 | + positionRepository := factory.CreatePositionRepository(map[string]interface{}{ | ||
87 | + "transactionContext": transactionContext, | ||
88 | + }) | ||
89 | + err = positionRepository.Remove(batchDeletePositionCommand.Ids) | ||
90 | + if err != nil { | ||
91 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
92 | + } | ||
93 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
94 | + return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
95 | + } | ||
96 | + return nil | ||
97 | +} |
@@ -8,7 +8,29 @@ type SaveUserCommand struct { | @@ -8,7 +8,29 @@ type SaveUserCommand struct { | ||
8 | AdminType int `json:"admin_type"` // 1普通员工 2 主管理员 | 8 | AdminType int `json:"admin_type"` // 1普通员工 2 主管理员 |
9 | Name string `json:"name"` // 用户姓名 | 9 | Name string `json:"name"` // 用户姓名 |
10 | Status int `json:"status"` // 用户状态(1正常 2禁用) | 10 | Status int `json:"status"` // 用户状态(1正常 2禁用) |
11 | + Email string `json:"email"` // 邮箱 | ||
11 | UserDepartments []struct { | 12 | UserDepartments []struct { |
12 | DepartmentId int `json:"department_id" ` | 13 | DepartmentId int `json:"department_id" ` |
13 | } `json:"user_departments"` //用户的组织ids | 14 | } `json:"user_departments"` //用户的组织ids |
15 | + UserPositions []struct { | ||
16 | + PositionId int `json:"position_id"` | ||
17 | + CompanyId int64 `json:"company_id"` | ||
18 | + UserId int64 `json:"user_id"` | ||
19 | + } `json:"user_positions"` | ||
20 | +} | ||
21 | + | ||
22 | +func (saveUserCommand *SaveUserCommand) DepartmentIds() []int { | ||
23 | + ids := make([]int, 0) | ||
24 | + for _, v := range saveUserCommand.UserDepartments { | ||
25 | + ids = append(ids, v.DepartmentId) | ||
26 | + } | ||
27 | + return ids | ||
28 | +} | ||
29 | + | ||
30 | +func (saveUserCommand *SaveUserCommand) PositionIds() []int { | ||
31 | + ids := make([]int, 0) | ||
32 | + for _, v := range saveUserCommand.UserPositions { | ||
33 | + ids = append(ids, v.PositionId) | ||
34 | + } | ||
35 | + return ids | ||
14 | } | 36 | } |
@@ -20,7 +20,7 @@ type SyncDataUserService struct{} | @@ -20,7 +20,7 @@ type SyncDataUserService struct{} | ||
20 | // // add:添加,edit:编辑,batchDelete:批量删除,batchForbid:批量禁用用户,batchRemove:批量更改用户部门,import:导入用户 | 20 | // // add:添加,edit:编辑,batchDelete:批量删除,batchForbid:批量禁用用户,batchRemove:批量更改用户部门,import:导入用户 |
21 | // Action string `json:"action"` | 21 | // Action string `json:"action"` |
22 | // // 具体的对象JSON数据 | 22 | // // 具体的对象JSON数据 |
23 | -// Datas json.RawMessage `json:"data"` | 23 | +// Data json.RawMessage `json:"data"` |
24 | // } | 24 | // } |
25 | 25 | ||
26 | func (srv SyncDataUserService) FromBusinessAdmin(param *domain.MessageBody) error { | 26 | func (srv SyncDataUserService) FromBusinessAdmin(param *domain.MessageBody) error { |
@@ -29,35 +29,35 @@ func (srv SyncDataUserService) FromBusinessAdmin(param *domain.MessageBody) erro | @@ -29,35 +29,35 @@ func (srv SyncDataUserService) FromBusinessAdmin(param *domain.MessageBody) erro | ||
29 | switch action { | 29 | switch action { |
30 | case "employee/add": | 30 | case "employee/add": |
31 | var param1 command.SaveUserCommand | 31 | var param1 command.SaveUserCommand |
32 | - err = json.Unmarshal(param.Datas, ¶m1) | 32 | + err = json.Unmarshal(param.Data, ¶m1) |
33 | if err != nil { | 33 | if err != nil { |
34 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 34 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
35 | } | 35 | } |
36 | err = srv.AddUser(¶m1) | 36 | err = srv.AddUser(¶m1) |
37 | case "employee/edit": | 37 | case "employee/edit": |
38 | var param2 command.SaveUserCommand | 38 | var param2 command.SaveUserCommand |
39 | - err = json.Unmarshal(param.Datas, ¶m2) | 39 | + err = json.Unmarshal(param.Data, ¶m2) |
40 | if err != nil { | 40 | if err != nil { |
41 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 41 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
42 | } | 42 | } |
43 | err = srv.UpdateUser(¶m2) | 43 | err = srv.UpdateUser(¶m2) |
44 | case "employee/batchDelete": | 44 | case "employee/batchDelete": |
45 | var param3 command.BatchDeleteCommand | 45 | var param3 command.BatchDeleteCommand |
46 | - err = json.Unmarshal(param.Datas, ¶m3) | 46 | + err = json.Unmarshal(param.Data, ¶m3) |
47 | if err != nil { | 47 | if err != nil { |
48 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 48 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
49 | } | 49 | } |
50 | err = srv.batchDelete(¶m3) | 50 | err = srv.batchDelete(¶m3) |
51 | - case "company/batchForbid": | 51 | + case "employee/batchForbid": |
52 | var param4 command.BatchForbidCommand | 52 | var param4 command.BatchForbidCommand |
53 | - err = json.Unmarshal(param.Datas, ¶m4) | 53 | + err = json.Unmarshal(param.Data, ¶m4) |
54 | if err != nil { | 54 | if err != nil { |
55 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 55 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
56 | } | 56 | } |
57 | err = srv.batchForbid(¶m4) | 57 | err = srv.batchForbid(¶m4) |
58 | - case "company/import": | 58 | + case "employee/import": |
59 | var param4 command.ImportUserCommand | 59 | var param4 command.ImportUserCommand |
60 | - err = json.Unmarshal(param.Datas, ¶m4) | 60 | + err = json.Unmarshal(param.Data, ¶m4) |
61 | if err != nil { | 61 | if err != nil { |
62 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 62 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
63 | } | 63 | } |
@@ -69,9 +69,9 @@ func (srv SyncDataUserService) FromBusinessAdmin(param *domain.MessageBody) erro | @@ -69,9 +69,9 @@ func (srv SyncDataUserService) FromBusinessAdmin(param *domain.MessageBody) erro | ||
69 | return err | 69 | return err |
70 | } | 70 | } |
71 | 71 | ||
72 | -//AddUser | ||
73 | -//从BusinessAdmins 接收消息 添加用户 | ||
74 | -//module="employee" action="add" | 72 | +// AddUser |
73 | +// 从BusinessAdmins 接收消息 添加用户 | ||
74 | +// module="employee" action="add" | ||
75 | func (srv SyncDataUserService) AddUser(param *command.SaveUserCommand) error { | 75 | func (srv SyncDataUserService) AddUser(param *command.SaveUserCommand) error { |
76 | transactionContext, err := factory.CreateTransactionContext(nil) | 76 | transactionContext, err := factory.CreateTransactionContext(nil) |
77 | if err != nil { | 77 | if err != nil { |
@@ -83,10 +83,6 @@ func (srv SyncDataUserService) AddUser(param *command.SaveUserCommand) error { | @@ -83,10 +83,6 @@ func (srv SyncDataUserService) AddUser(param *command.SaveUserCommand) error { | ||
83 | defer func() { | 83 | defer func() { |
84 | _ = transactionContext.RollbackTransaction() | 84 | _ = transactionContext.RollbackTransaction() |
85 | }() | 85 | }() |
86 | - var departmentIds []int | ||
87 | - for _, v := range param.UserDepartments { | ||
88 | - departmentIds = append(departmentIds, v.DepartmentId) | ||
89 | - } | ||
90 | nowTime := time.Now() | 86 | nowTime := time.Now() |
91 | newUser := domain.User{ | 87 | newUser := domain.User{ |
92 | Id: param.Id, | 88 | Id: param.Id, |
@@ -94,12 +90,13 @@ func (srv SyncDataUserService) AddUser(param *command.SaveUserCommand) error { | @@ -94,12 +90,13 @@ func (srv SyncDataUserService) AddUser(param *command.SaveUserCommand) error { | ||
94 | AvatarUrl: param.Avatar, | 90 | AvatarUrl: param.Avatar, |
95 | CompanyId: param.CompanyId, | 91 | CompanyId: param.CompanyId, |
96 | AdminType: param.AdminType, | 92 | AdminType: param.AdminType, |
97 | - DepartmentId: departmentIds, | 93 | + DepartmentId: param.DepartmentIds(), |
94 | + PositionId: param.PositionIds(), | ||
98 | Name: param.Name, | 95 | Name: param.Name, |
96 | + Email: param.Email, | ||
99 | Status: param.Status, | 97 | Status: param.Status, |
100 | - UpdateAt: nowTime, | ||
101 | - DeleteAt: nil, | ||
102 | - CreateAt: nowTime, | 98 | + UpdatedAt: nowTime, |
99 | + CreatedAt: nowTime, | ||
103 | } | 100 | } |
104 | userRepo := factory.CreateUserRepository(map[string]interface{}{ | 101 | userRepo := factory.CreateUserRepository(map[string]interface{}{ |
105 | "transactionContext": transactionContext, | 102 | "transactionContext": transactionContext, |
@@ -114,9 +111,9 @@ func (srv SyncDataUserService) AddUser(param *command.SaveUserCommand) error { | @@ -114,9 +111,9 @@ func (srv SyncDataUserService) AddUser(param *command.SaveUserCommand) error { | ||
114 | return nil | 111 | return nil |
115 | } | 112 | } |
116 | 113 | ||
117 | -//UpdateUser | ||
118 | -//从BusinessAdmins 接收消息 更新用户 | ||
119 | -//module="employee" action="edit" | 114 | +// UpdateUser |
115 | +// 从BusinessAdmins 接收消息 更新用户 | ||
116 | +// module="employee" action="edit" | ||
120 | func (srv SyncDataUserService) UpdateUser(param *command.SaveUserCommand) error { | 117 | func (srv SyncDataUserService) UpdateUser(param *command.SaveUserCommand) error { |
121 | transactionContext, err := factory.CreateTransactionContext(nil) | 118 | transactionContext, err := factory.CreateTransactionContext(nil) |
122 | if err != nil { | 119 | if err != nil { |
@@ -146,7 +143,7 @@ func (srv SyncDataUserService) UpdateUser(param *command.SaveUserCommand) error | @@ -146,7 +143,7 @@ func (srv SyncDataUserService) UpdateUser(param *command.SaveUserCommand) error | ||
146 | newUser = userList[0] | 143 | newUser = userList[0] |
147 | } else { | 144 | } else { |
148 | newUser = &domain.User{ | 145 | newUser = &domain.User{ |
149 | - CreateAt: nowTime, | 146 | + CreatedAt: nowTime, |
150 | } | 147 | } |
151 | } | 148 | } |
152 | newUser.Id = param.Id | 149 | newUser.Id = param.Id |
@@ -156,7 +153,10 @@ func (srv SyncDataUserService) UpdateUser(param *command.SaveUserCommand) error | @@ -156,7 +153,10 @@ func (srv SyncDataUserService) UpdateUser(param *command.SaveUserCommand) error | ||
156 | newUser.AdminType = param.AdminType | 153 | newUser.AdminType = param.AdminType |
157 | newUser.Name = param.Name | 154 | newUser.Name = param.Name |
158 | newUser.Status = param.Status | 155 | newUser.Status = param.Status |
159 | - newUser.UpdateAt = nowTime | 156 | + newUser.PositionId = param.PositionIds() |
157 | + newUser.DepartmentId = param.DepartmentIds() | ||
158 | + | ||
159 | + newUser.UpdatedAt = nowTime | ||
160 | if len(userList) > 0 { | 160 | if len(userList) > 0 { |
161 | _, err = userRepo.Update(newUser) | 161 | _, err = userRepo.Update(newUser) |
162 | if err != nil { | 162 | if err != nil { |
@@ -174,9 +174,9 @@ func (srv SyncDataUserService) UpdateUser(param *command.SaveUserCommand) error | @@ -174,9 +174,9 @@ func (srv SyncDataUserService) UpdateUser(param *command.SaveUserCommand) error | ||
174 | return nil | 174 | return nil |
175 | } | 175 | } |
176 | 176 | ||
177 | -//batchDelete | ||
178 | -//从BusinessAdmins 接收消息 删除用户 | ||
179 | -//module="employee" action="batchDelete" | 177 | +// batchDelete |
178 | +// 从BusinessAdmins 接收消息 删除用户 | ||
179 | +// module="employee" action="batchDelete" | ||
180 | func (srv SyncDataUserService) batchDelete(param *command.BatchDeleteCommand) error { | 180 | func (srv SyncDataUserService) batchDelete(param *command.BatchDeleteCommand) error { |
181 | if len(param.Uids) == 0 { | 181 | if len(param.Uids) == 0 { |
182 | return nil | 182 | return nil |
@@ -205,9 +205,9 @@ func (srv SyncDataUserService) batchDelete(param *command.BatchDeleteCommand) er | @@ -205,9 +205,9 @@ func (srv SyncDataUserService) batchDelete(param *command.BatchDeleteCommand) er | ||
205 | return nil | 205 | return nil |
206 | } | 206 | } |
207 | 207 | ||
208 | -//batchForbid | ||
209 | -//从BusinessAdmins 接收消息 禁用,启用用户 | ||
210 | -//module="employee" action="batchForbid" | 208 | +// batchForbid |
209 | +// 从BusinessAdmins 接收消息 禁用,启用用户 | ||
210 | +// module="employee" action="batchForbid" | ||
211 | func (srv SyncDataUserService) batchForbid(param *command.BatchForbidCommand) error { | 211 | func (srv SyncDataUserService) batchForbid(param *command.BatchForbidCommand) error { |
212 | if len(param.Uids) == 0 { | 212 | if len(param.Uids) == 0 { |
213 | return nil | 213 | return nil |
@@ -245,9 +245,9 @@ func (srv SyncDataUserService) batchForbid(param *command.BatchForbidCommand) er | @@ -245,9 +245,9 @@ func (srv SyncDataUserService) batchForbid(param *command.BatchForbidCommand) er | ||
245 | return nil | 245 | return nil |
246 | } | 246 | } |
247 | 247 | ||
248 | -//importUser | ||
249 | -//从BusinessAdmins 接收消息 导入用户数据 | ||
250 | -//module="employee" action="import" | 248 | +// importUser |
249 | +// 从BusinessAdmins 接收消息 导入用户数据 | ||
250 | +// module="employee" action="import" | ||
251 | func (srv SyncDataUserService) importUser(param *command.ImportUserCommand) error { | 251 | func (srv SyncDataUserService) importUser(param *command.ImportUserCommand) error { |
252 | transactionContext, err := factory.CreateTransactionContext(nil) | 252 | transactionContext, err := factory.CreateTransactionContext(nil) |
253 | if err != nil { | 253 | if err != nil { |
@@ -287,7 +287,7 @@ func (srv SyncDataUserService) importUser(param *command.ImportUserCommand) erro | @@ -287,7 +287,7 @@ func (srv SyncDataUserService) importUser(param *command.ImportUserCommand) erro | ||
287 | editUserList[i].Name = mVal.Name | 287 | editUserList[i].Name = mVal.Name |
288 | editUserList[i].Status = mVal.Status | 288 | editUserList[i].Status = mVal.Status |
289 | editUserList[i].CompanyId = mVal.CompanyId | 289 | editUserList[i].CompanyId = mVal.CompanyId |
290 | - editUserList[i].UpdateAt = nowTime | 290 | + editUserList[i].UpdatedAt = nowTime |
291 | _, err = userRepo.Update(editUserList[i]) | 291 | _, err = userRepo.Update(editUserList[i]) |
292 | if err != nil { | 292 | if err != nil { |
293 | return err | 293 | return err |
@@ -305,9 +305,9 @@ func (srv SyncDataUserService) importUser(param *command.ImportUserCommand) erro | @@ -305,9 +305,9 @@ func (srv SyncDataUserService) importUser(param *command.ImportUserCommand) erro | ||
305 | AdminType: param.AddUsers[i].AdminType, | 305 | AdminType: param.AddUsers[i].AdminType, |
306 | Name: param.AddUsers[i].Name, | 306 | Name: param.AddUsers[i].Name, |
307 | Status: param.AddUsers[i].Status, | 307 | Status: param.AddUsers[i].Status, |
308 | - UpdateAt: nowTime, | ||
309 | - DeleteAt: nil, | ||
310 | - CreateAt: nowTime, | 308 | + UpdatedAt: nowTime, |
309 | + DeletedAt: nil, | ||
310 | + CreatedAt: nowTime, | ||
311 | } | 311 | } |
312 | _, err := userRepo.Insert(&tempUser) | 312 | _, err := userRepo.Insert(&tempUser) |
313 | if err != nil { | 313 | if err != nil { |
pkg/constant/business_admin.go
0 → 100644
1 | +package constant | ||
2 | + | ||
3 | +import "os" | ||
4 | + | ||
5 | +// 用户中心地址 | ||
6 | +var UCENTER_SERVICE_HOST = "http://suplus-ucenter-test.fjmaimaimai.com" | ||
7 | + | ||
8 | +// var UCENTER_HOST = "https://suplus-ucenter-dev.fjmaimaimai.com" //统一用户中心地址 | ||
9 | +var UCENTER_SECRET = "cykbjnfqgctn" | ||
10 | +var UCENTER_APP_KEY = "39aefef9e22744a3b2d2d3791824ae7b" | ||
11 | +var UCENTER_CHECK_ALT = "rsF0pL!6DwjBO735" | ||
12 | + | ||
13 | +// 企业平台地址 | ||
14 | +var BUSINESS_ADMIN_SERVICE_HOST = "http://suplus-business-admin-test.fjmaimaimai.com" | ||
15 | + | ||
16 | +// 绩效管理平台ID | ||
17 | +var PLATFORM_ADMIN_ID = 28 | ||
18 | + | ||
19 | +// 员工绩效平台ID | ||
20 | +var PLATFORM_FONT_ID = 29 | ||
21 | + | ||
22 | +func init() { | ||
23 | + if os.Getenv("UCENTER_SERVICE_HOST") != "" { | ||
24 | + UCENTER_SERVICE_HOST = os.Getenv("UCENTER_SERVICE_HOST") | ||
25 | + } | ||
26 | + if os.Getenv("BUSINESS_ADMIN_SERVICE_HOST") != "" { | ||
27 | + BUSINESS_ADMIN_SERVICE_HOST = os.Getenv("BUSINESS_ADMIN_SERVICE_HOST") | ||
28 | + } | ||
29 | +} |
1 | //go:build !local | 1 | //go:build !local |
2 | +// +build !local | ||
2 | 3 | ||
3 | package constant | 4 | package constant |
4 | 5 | ||
@@ -8,14 +9,14 @@ var KAFKA_HOSTS = "127.0.0.1:9092" // 1.116.151.79:9092 | @@ -8,14 +9,14 @@ var KAFKA_HOSTS = "127.0.0.1:9092" // 1.116.151.79:9092 | ||
8 | 9 | ||
9 | var KAFKA_GROUP_ID = "performance_dev" | 10 | var KAFKA_GROUP_ID = "performance_dev" |
10 | 11 | ||
11 | -var KAFKA_BUSINESS_ADMIN_TOPIC = "mmm-business-admin-dev" | 12 | +var KAFKA_BUSINESS_TOPIC = "mmm-business-admin-dev" |
12 | 13 | ||
13 | func init() { | 14 | func init() { |
14 | if os.Getenv("KAFKA_HOSTS") != "" { | 15 | if os.Getenv("KAFKA_HOSTS") != "" { |
15 | KAFKA_HOSTS = os.Getenv("KAFKA_HOSTS") | 16 | KAFKA_HOSTS = os.Getenv("KAFKA_HOSTS") |
16 | } | 17 | } |
17 | - if os.Getenv("KAFKA_BUSINESS_ADMIN_TOPIC") != "" { | ||
18 | - KAFKA_BUSINESS_ADMIN_TOPIC = os.Getenv("KAFKA_BUSINESS_ADMIN_TOPIC") | 18 | + if os.Getenv("KAFKA_BUSINESS_TOPIC") != "" { |
19 | + KAFKA_BUSINESS_TOPIC = os.Getenv("KAFKA_BUSINESS_TOPIC") | ||
19 | } | 20 | } |
20 | if os.Getenv("KAFKA_GROUP_ID") != "" { | 21 | if os.Getenv("KAFKA_GROUP_ID") != "" { |
21 | KAFKA_GROUP_ID = os.Getenv("KAFKA_GROUP_ID") | 22 | KAFKA_GROUP_ID = os.Getenv("KAFKA_GROUP_ID") |
@@ -2,7 +2,7 @@ package constant | @@ -2,7 +2,7 @@ package constant | ||
2 | 2 | ||
3 | import "os" | 3 | import "os" |
4 | 4 | ||
5 | -var POSTGRESQL_DB_NAME = "performance_dev" | 5 | +var POSTGRESQL_DB_NAME = "performance_test" |
6 | var POSTGRESQL_USER = "postgres" | 6 | var POSTGRESQL_USER = "postgres" |
7 | var POSTGRESQL_PASSWORD = "eagle1010" | 7 | var POSTGRESQL_PASSWORD = "eagle1010" |
8 | var POSTGRESQL_HOST = "114.55.200.59" | 8 | var POSTGRESQL_HOST = "114.55.200.59" |
pkg/domain/business_admin.go
0 → 100644
1 | +package domain | ||
2 | + | ||
3 | +import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/serviceGateway/reply" | ||
4 | + | ||
5 | +// UCenterApi 统一用户中心 | ||
6 | +type UCenterApi interface { | ||
7 | + AuthCode(code string) (*reply.UCenterAuthCode, error) | ||
8 | +} | ||
9 | + | ||
10 | +// BusinessAdminApi 企业平台 | ||
11 | +type BusinessAdminApi interface { | ||
12 | + GetUserAuth(userId int64, platformId int) (*reply.BusinessAdminUserAuth, error) | ||
13 | +} |
@@ -3,14 +3,14 @@ package domain | @@ -3,14 +3,14 @@ package domain | ||
3 | import "time" | 3 | import "time" |
4 | 4 | ||
5 | type Company struct { | 5 | type Company struct { |
6 | - Id int64 //公司编号 | ||
7 | - Logo string //公司logo | ||
8 | - Name string //公司名称 | ||
9 | - ChargeUserIds []int64 //公司级别的部门主管uids | ||
10 | - Status int //公司状态,1正常 2禁用 | ||
11 | - UpdateAt time.Time //更新时间 | ||
12 | - CreateAt time.Time //创建时间 | ||
13 | - DeleteAt *time.Time | 6 | + Id int64 //公司编号 |
7 | + Logo string //公司logo | ||
8 | + Name string //公司名称 | ||
9 | + ChargeUserIds []int64 //公司级别的部门主管uids | ||
10 | + Status int //公司状态,1正常 2禁用 | ||
11 | + UpdatedAt time.Time //更新时间 | ||
12 | + CreatedAt time.Time //创建时间 | ||
13 | + DeletedAt *time.Time //删除时间 | ||
14 | } | 14 | } |
15 | 15 | ||
16 | type CompanyRepository interface { | 16 | type CompanyRepository interface { |
@@ -10,10 +10,11 @@ type Department struct { | @@ -10,10 +10,11 @@ type Department struct { | ||
10 | ParentId int64 // 组织父级id | 10 | ParentId int64 // 组织父级id |
11 | ChargeUserIds []int64 // 主管uids | 11 | ChargeUserIds []int64 // 主管uids |
12 | Path string // 组织路径 | 12 | Path string // 组织路径 |
13 | - CreateAt time.Time // 创建时间 | ||
14 | - UpdateAt time.Time // 更新时间 | ||
15 | - DeleteAt *time.Time // 删除时间 | 13 | + CreatedAt time.Time // 创建时间 |
14 | + UpdatedAt time.Time // 更新时间 | ||
15 | + DeletedAt *time.Time // 删除时间 | ||
16 | } | 16 | } |
17 | + | ||
17 | type DepartmentRepository interface { | 18 | type DepartmentRepository interface { |
18 | Insert(param *Department) (*Department, error) | 19 | Insert(param *Department) (*Department, error) |
19 | Update(param *Department) (*Department, error) | 20 | Update(param *Department) (*Department, error) |
pkg/domain/position.go
0 → 100644
1 | +package domain | ||
2 | + | ||
3 | +type Position struct { | ||
4 | + //职位ID | ||
5 | + Id int64 `json:"id"` | ||
6 | + //公司ID | ||
7 | + CompanyId int64 `json:"companyId"` | ||
8 | + //职位名称 | ||
9 | + Name string `json:"name"` | ||
10 | + //父级职位ID | ||
11 | + ParentId int64 `json:"parentId"` | ||
12 | + //职位路径 | ||
13 | + Path string `json:"path"` | ||
14 | + //职位层级 | ||
15 | + Level int `json:"level"` | ||
16 | +} | ||
17 | + | ||
18 | +type PositionRepository interface { | ||
19 | + Insert(position *Position) (*Position, error) | ||
20 | + Update(position *Position) (*Position, error) | ||
21 | + Remove(ids []int64) error | ||
22 | + FindOne(queryOption map[string]interface{}) (*Position, error) | ||
23 | +} |
@@ -10,13 +10,13 @@ type ReceivedMessage struct { | @@ -10,13 +10,13 @@ type ReceivedMessage struct { | ||
10 | MessageType string `json:"MessageType"` | 10 | MessageType string `json:"MessageType"` |
11 | MessageBody string `json:"MessageBody"` | 11 | MessageBody string `json:"MessageBody"` |
12 | OccurredOn time.Time `json:"OccurredOn"` | 12 | OccurredOn time.Time `json:"OccurredOn"` |
13 | - CreateAt time.Time `json:"-"` | 13 | + CreatedAt time.Time `json:"-"` |
14 | } | 14 | } |
15 | 15 | ||
16 | type MessageBody struct { | 16 | type MessageBody struct { |
17 | Module string `json:"module"` | 17 | Module string `json:"module"` |
18 | Action string `json:"action"` | 18 | Action string `json:"action"` |
19 | - Datas json.RawMessage `json:"datas"` // 具体的对象JSON数据 | 19 | + Data json.RawMessage `json:"data"` // 具体的对象JSON数据 |
20 | } | 20 | } |
21 | 21 | ||
22 | type ReceivedMessageRepository interface { | 22 | type ReceivedMessageRepository interface { |
@@ -12,15 +12,18 @@ type User struct { | @@ -12,15 +12,18 @@ type User struct { | ||
12 | Email string // 邮箱 | 12 | Email string // 邮箱 |
13 | Status int // 用户状态(1正常 2禁用) | 13 | Status int // 用户状态(1正常 2禁用) |
14 | DepartmentId []int // 用户归属的部门 | 14 | DepartmentId []int // 用户归属的部门 |
15 | - UpdateAt time.Time // 更新时间 | ||
16 | - DeleteAt *time.Time | ||
17 | - CreateAt time.Time | 15 | + PositionId []int //用户职位 |
16 | + UpdatedAt time.Time // 更新时间 | ||
17 | + DeletedAt *time.Time | ||
18 | + CreatedAt time.Time | ||
18 | } | 19 | } |
19 | 20 | ||
20 | -//1普通员工 2 主管理员 | 21 | +// 1普通员工 2 主管理员 |
21 | const ( | 22 | const ( |
22 | UserTypeCommon int = 1 | 23 | UserTypeCommon int = 1 |
23 | UserTypeManager int = 2 | 24 | UserTypeManager int = 2 |
25 | + | ||
26 | + UserStatusEnable int = 1 | ||
24 | ) | 27 | ) |
25 | 28 | ||
26 | type UserRepository interface { | 29 | type UserRepository interface { |
pkg/domain/user_auth.go
0 → 100644
1 | +package domain | ||
2 | + | ||
3 | +import ( | ||
4 | + "errors" | ||
5 | + "github.com/dgrijalva/jwt-go" | ||
6 | + "time" | ||
7 | +) | ||
8 | + | ||
9 | +type UserAuth struct { | ||
10 | + jwt.StandardClaims `json:"-"` | ||
11 | + UserId int64 `json:"userId"` | ||
12 | + CompanyId int64 `json:"companyId"` | ||
13 | + Phone string `json:"phone"` | ||
14 | + PlatformId int `json:"platformId"` | ||
15 | + Name string `json:"name"` | ||
16 | + AdminType int `json:"adminType"` | ||
17 | +} | ||
18 | + | ||
19 | +var issuer = "performance" | ||
20 | + | ||
21 | +var secretKey = "Ma9HXITeliSYS43Z" | ||
22 | + | ||
23 | +var JWTExpiresSecond = 3600 * 24 | ||
24 | + | ||
25 | +// CreateAccessToken 生成token | ||
26 | +func (userAuth *UserAuth) CreateAccessToken() (string, error) { | ||
27 | + userAuth.StandardClaims = jwt.StandardClaims{ | ||
28 | + ExpiresAt: time.Now().Add(time.Duration(JWTExpiresSecond) * time.Second).Unix(), | ||
29 | + Issuer: issuer, | ||
30 | + } | ||
31 | + token := jwt.NewWithClaims(jwt.SigningMethodHS256, userAuth) | ||
32 | + return token.SignedString([]byte(secretKey)) | ||
33 | +} | ||
34 | + | ||
35 | +// ParseAccessToken 解析token | ||
36 | +func (userAuth *UserAuth) ParseAccessToken(token string) (*UserAuth, error) { | ||
37 | + user := &UserAuth{} | ||
38 | + tokenClaims, err := jwt.ParseWithClaims(token, user, func(token *jwt.Token) (interface{}, error) { | ||
39 | + return []byte(secretKey), nil | ||
40 | + }) | ||
41 | + if err != nil || tokenClaims == nil { | ||
42 | + return nil, errors.New("解析token失败") | ||
43 | + } | ||
44 | + if claim, ok := tokenClaims.Claims.(*UserAuth); ok && tokenClaims.Valid { | ||
45 | + user.UserId = claim.UserId | ||
46 | + user.CompanyId = claim.CompanyId | ||
47 | + user.Phone = claim.Phone | ||
48 | + user.PlatformId = claim.PlatformId | ||
49 | + user.Name = claim.Name | ||
50 | + user.AdminType = claim.AdminType | ||
51 | + return user, nil | ||
52 | + } | ||
53 | + return user, errors.New("解析token失败") | ||
54 | +} |
@@ -33,6 +33,7 @@ func init() { | @@ -33,6 +33,7 @@ func init() { | ||
33 | &models.ReceivedMessage{}, | 33 | &models.ReceivedMessage{}, |
34 | &models.Role{}, | 34 | &models.Role{}, |
35 | &models.RoleUser{}, | 35 | &models.RoleUser{}, |
36 | + &models.Position{}, | ||
36 | &models.EvaluationRule{}, | 37 | &models.EvaluationRule{}, |
37 | &models.EvaluationTemplate{}, | 38 | &models.EvaluationTemplate{}, |
38 | &models.EvaluationCycle{}, | 39 | &models.EvaluationCycle{}, |
@@ -9,7 +9,7 @@ type Company struct { | @@ -9,7 +9,7 @@ type Company struct { | ||
9 | Name string //公司名称 | 9 | Name string //公司名称 |
10 | ChargeUserIds []int64 //公司级别的部门主管uids | 10 | ChargeUserIds []int64 //公司级别的部门主管uids |
11 | Status int //公司状态,1正常 2禁用 | 11 | Status int //公司状态,1正常 2禁用 |
12 | - UpdateAt time.Time //更新时间 | ||
13 | - CreateAt time.Time //创建时间 | ||
14 | - DeleteAt *time.Time //删除时间 | 12 | + CreatedAt time.Time //创建时间 |
13 | + UpdatedAt time.Time //更新时间 | ||
14 | + DeletedAt *time.Time `pg:",soft_delete"` //删除时间 | ||
15 | } | 15 | } |
@@ -8,12 +8,12 @@ type Department struct { | @@ -8,12 +8,12 @@ type Department struct { | ||
8 | tableName struct{} `pg:"department"` | 8 | tableName struct{} `pg:"department"` |
9 | Id int64 `pg:"pk:id"` // 组织id | 9 | Id int64 `pg:"pk:id"` // 组织id |
10 | CompanyId int64 // 公司编号 | 10 | CompanyId int64 // 公司编号 |
11 | - Level int // 组织级别 | 11 | + Level int `pg:",use_zero"` // 组织级别 |
12 | Name string // 组织名称 | 12 | Name string // 组织名称 |
13 | - ParentId int64 // 组织父级id | 13 | + ParentId int64 `pg:",use_zero"` // 组织父级id |
14 | ChargeUserIds []int64 // 主管uids | 14 | ChargeUserIds []int64 // 主管uids |
15 | Path string // 组织路径 | 15 | Path string // 组织路径 |
16 | - CreateAt time.Time // 创建时间 | ||
17 | - UpdateAt time.Time // 更新时间 | ||
18 | - DeleteAt *time.Time // 删除时间 | 16 | + CreatedAt time.Time // 创建时间 |
17 | + UpdatedAt time.Time // 更新时间 | ||
18 | + DeletedAt *time.Time `pg:",soft_delete"` // 删除时间 | ||
19 | } | 19 | } |
@@ -8,5 +8,7 @@ type ReceivedMessage struct { | @@ -8,5 +8,7 @@ type ReceivedMessage struct { | ||
8 | MessageType string | 8 | MessageType string |
9 | MessageBody string | 9 | MessageBody string |
10 | OccurredOn time.Time | 10 | OccurredOn time.Time |
11 | - CreateAt time.Time | 11 | + CreatedAt time.Time `pg:"default:now()"` |
12 | + UpdatedAt time.Time `pg:"default:now()"` | ||
13 | + DeletedAt *time.Time `pg:",soft_delete"` | ||
12 | } | 14 | } |
pkg/infrastructure/pg/models/position.go
0 → 100644
1 | +package models | ||
2 | + | ||
3 | +import "time" | ||
4 | + | ||
5 | +type Position struct { | ||
6 | + tableName struct{} `pg:"position"` | ||
7 | + //职位ID | ||
8 | + Id int64 `pg:",pk"` | ||
9 | + //公司ID | ||
10 | + CompanyId int64 `comment:"公司ID"` | ||
11 | + //职位名称 | ||
12 | + Name string `comment:"职位名称"` | ||
13 | + //父级职位ID | ||
14 | + ParentId int64 `comment:"父级职位ID" pg:",use_zero"` | ||
15 | + //职位路径 | ||
16 | + Path string `comment:"职位路径"` | ||
17 | + //职位层级 | ||
18 | + Level int `comment:"职位层级" pg:",use_zero"` | ||
19 | + //创建时间 | ||
20 | + CreatedAt time.Time `comment:"创建时间" pg:"default:now()"` | ||
21 | + //更新时间 | ||
22 | + UpdatedAt time.Time `comment:"更新时间" pg:"default:now()"` | ||
23 | + //删除时间 | ||
24 | + DeletedAt *time.Time `comment:"删除时间" pg:",soft_delete"` | ||
25 | +} |
@@ -11,5 +11,5 @@ type Role struct { | @@ -11,5 +11,5 @@ type Role struct { | ||
11 | CompanyId int64 `comment:"公司ID"` | 11 | CompanyId int64 `comment:"公司ID"` |
12 | CreatedAt time.Time `comment:"创建时间"` | 12 | CreatedAt time.Time `comment:"创建时间"` |
13 | UpdatedAt time.Time `comment:"更新时间"` | 13 | UpdatedAt time.Time `comment:"更新时间"` |
14 | - DeletedAt *time.Time `comment:"删除时间"` | 14 | + DeletedAt *time.Time `comment:"删除时间" pg:",soft_delete"` |
15 | } | 15 | } |
@@ -10,5 +10,5 @@ type RoleUser struct { | @@ -10,5 +10,5 @@ type RoleUser struct { | ||
10 | CompanyId int64 `comment:"公司ID"` | 10 | CompanyId int64 `comment:"公司ID"` |
11 | CreatedAt time.Time `comment:"创建时间"` | 11 | CreatedAt time.Time `comment:"创建时间"` |
12 | UpdatedAt time.Time `comment:"更新时间"` | 12 | UpdatedAt time.Time `comment:"更新时间"` |
13 | - DeletedAt *time.Time `comment:"删除时间"` | 13 | + DeletedAt *time.Time `comment:"删除时间" pg:",soft_delete"` |
14 | } | 14 | } |
@@ -13,7 +13,8 @@ type User struct { | @@ -13,7 +13,8 @@ type User struct { | ||
13 | Email string // 邮箱 | 13 | Email string // 邮箱 |
14 | Status int // 用户状态(1正常 2禁用) | 14 | Status int // 用户状态(1正常 2禁用) |
15 | DepartmentId []int // 用户归属的部门 | 15 | DepartmentId []int // 用户归属的部门 |
16 | - UpdateAt time.Time // 更新时间 | ||
17 | - CreateAt time.Time // 创建时间 | ||
18 | - DeleteAt *time.Time // 删除时间 | 16 | + PositionId []int // 用户职位 |
17 | + CreatedAt time.Time // 创建时间 | ||
18 | + UpdatedAt time.Time // 更新时间 | ||
19 | + DeletedAt *time.Time `pg:",soft_delete"` // 删除时间 | ||
19 | } | 20 | } |
@@ -28,9 +28,9 @@ func (repo *CompanyRepository) Insert(u *domain.Company) (*domain.Company, error | @@ -28,9 +28,9 @@ func (repo *CompanyRepository) Insert(u *domain.Company) (*domain.Company, error | ||
28 | Name: u.Name, | 28 | Name: u.Name, |
29 | Status: u.Status, | 29 | Status: u.Status, |
30 | ChargeUserIds: u.ChargeUserIds, | 30 | ChargeUserIds: u.ChargeUserIds, |
31 | - UpdateAt: u.UpdateAt, | ||
32 | - CreateAt: u.CreateAt, | ||
33 | - DeleteAt: u.DeleteAt, | 31 | + UpdatedAt: u.UpdatedAt, |
32 | + CreatedAt: u.CreatedAt, | ||
33 | + DeletedAt: u.DeletedAt, | ||
34 | } | 34 | } |
35 | tx := repo.transactionContext.PgTx | 35 | tx := repo.transactionContext.PgTx |
36 | _, err := tx.Model(&companyModel).Insert() | 36 | _, err := tx.Model(&companyModel).Insert() |
@@ -48,9 +48,9 @@ func (repo *CompanyRepository) Update(u *domain.Company) (*domain.Company, error | @@ -48,9 +48,9 @@ func (repo *CompanyRepository) Update(u *domain.Company) (*domain.Company, error | ||
48 | Name: u.Name, | 48 | Name: u.Name, |
49 | Status: u.Status, | 49 | Status: u.Status, |
50 | ChargeUserIds: u.ChargeUserIds, | 50 | ChargeUserIds: u.ChargeUserIds, |
51 | - UpdateAt: u.UpdateAt, | ||
52 | - CreateAt: u.CreateAt, | ||
53 | - DeleteAt: u.DeleteAt, | 51 | + UpdatedAt: u.UpdatedAt, |
52 | + CreatedAt: u.CreatedAt, | ||
53 | + DeletedAt: u.DeletedAt, | ||
54 | } | 54 | } |
55 | tx := repo.transactionContext.PgTx | 55 | tx := repo.transactionContext.PgTx |
56 | _, err := tx.Model(&companyModel).WherePK().Update() | 56 | _, err := tx.Model(&companyModel).WherePK().Update() |
@@ -62,7 +62,7 @@ func (repo *CompanyRepository) Update(u *domain.Company) (*domain.Company, error | @@ -62,7 +62,7 @@ func (repo *CompanyRepository) Update(u *domain.Company) (*domain.Company, error | ||
62 | 62 | ||
63 | func (repo *CompanyRepository) Remove(u *domain.Company) (*domain.Company, error) { | 63 | func (repo *CompanyRepository) Remove(u *domain.Company) (*domain.Company, error) { |
64 | nowTime := time.Now() | 64 | nowTime := time.Now() |
65 | - u.DeleteAt = &nowTime | 65 | + u.DeletedAt = &nowTime |
66 | _, err := repo.Update(u) | 66 | _, err := repo.Update(u) |
67 | return u, err | 67 | return u, err |
68 | } | 68 | } |
@@ -113,12 +113,12 @@ func (repo *CompanyRepository) Find(queryOptions map[string]interface{}) (int, [ | @@ -113,12 +113,12 @@ func (repo *CompanyRepository) Find(queryOptions map[string]interface{}) (int, [ | ||
113 | 113 | ||
114 | func (repo *CompanyRepository) TransformToCompanyDomain(m *models.Company) *domain.Company { | 114 | func (repo *CompanyRepository) TransformToCompanyDomain(m *models.Company) *domain.Company { |
115 | return &domain.Company{ | 115 | return &domain.Company{ |
116 | - Id: m.Id, | ||
117 | - Logo: m.Logo, | ||
118 | - Name: m.Name, | ||
119 | - Status: m.Status, | ||
120 | - UpdateAt: m.UpdateAt, | ||
121 | - CreateAt: m.CreateAt, | ||
122 | - DeleteAt: m.DeleteAt, | 116 | + Id: m.Id, |
117 | + Logo: m.Logo, | ||
118 | + Name: m.Name, | ||
119 | + Status: m.Status, | ||
120 | + UpdatedAt: m.UpdatedAt, | ||
121 | + CreatedAt: m.CreatedAt, | ||
122 | + DeletedAt: m.DeletedAt, | ||
123 | } | 123 | } |
124 | } | 124 | } |
1 | package repository | 1 | package repository |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | - "time" | ||
5 | - | ||
6 | "github.com/go-pg/pg/v10" | 4 | "github.com/go-pg/pg/v10" |
7 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | 5 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" |
8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
@@ -30,9 +28,9 @@ func (repo *DepartmentRepository) Insert(u *domain.Department) (*domain.Departme | @@ -30,9 +28,9 @@ func (repo *DepartmentRepository) Insert(u *domain.Department) (*domain.Departme | ||
30 | ParentId: u.ParentId, | 28 | ParentId: u.ParentId, |
31 | ChargeUserIds: u.ChargeUserIds, | 29 | ChargeUserIds: u.ChargeUserIds, |
32 | Path: u.Path, | 30 | Path: u.Path, |
33 | - CreateAt: u.CreateAt, | ||
34 | - UpdateAt: u.UpdateAt, | ||
35 | - DeleteAt: nil, | 31 | + CreatedAt: u.CreatedAt, |
32 | + UpdatedAt: u.UpdatedAt, | ||
33 | + DeletedAt: nil, | ||
36 | } | 34 | } |
37 | tx := repo.transactionContext.PgTx | 35 | tx := repo.transactionContext.PgTx |
38 | _, err := tx.Model(&departmentModel).Insert() | 36 | _, err := tx.Model(&departmentModel).Insert() |
@@ -52,9 +50,9 @@ func (repo *DepartmentRepository) Update(u *domain.Department) (*domain.Departme | @@ -52,9 +50,9 @@ func (repo *DepartmentRepository) Update(u *domain.Department) (*domain.Departme | ||
52 | ParentId: u.ParentId, | 50 | ParentId: u.ParentId, |
53 | ChargeUserIds: u.ChargeUserIds, | 51 | ChargeUserIds: u.ChargeUserIds, |
54 | Path: u.Path, | 52 | Path: u.Path, |
55 | - CreateAt: u.CreateAt, | ||
56 | - UpdateAt: u.UpdateAt, | ||
57 | - DeleteAt: u.DeleteAt, | 53 | + CreatedAt: u.CreatedAt, |
54 | + UpdatedAt: u.UpdatedAt, | ||
55 | + DeletedAt: u.DeletedAt, | ||
58 | } | 56 | } |
59 | tx := repo.transactionContext.PgTx | 57 | tx := repo.transactionContext.PgTx |
60 | _, err := tx.Model(&departmentModel).WherePK().Update() | 58 | _, err := tx.Model(&departmentModel).WherePK().Update() |
@@ -65,13 +63,11 @@ func (repo *DepartmentRepository) Update(u *domain.Department) (*domain.Departme | @@ -65,13 +63,11 @@ func (repo *DepartmentRepository) Update(u *domain.Department) (*domain.Departme | ||
65 | } | 63 | } |
66 | 64 | ||
67 | func (repo *DepartmentRepository) Remove(ids []int64) error { | 65 | func (repo *DepartmentRepository) Remove(ids []int64) error { |
68 | - nowTime := time.Now() | ||
69 | tx := repo.transactionContext.PgTx | 66 | tx := repo.transactionContext.PgTx |
70 | uModel := models.Department{} | 67 | uModel := models.Department{} |
71 | _, err := tx.Model(&uModel). | 68 | _, err := tx.Model(&uModel). |
72 | - Set("delete_at", nowTime). | ||
73 | Where("id in (?)", pg.In(ids)). | 69 | Where("id in (?)", pg.In(ids)). |
74 | - Update() | 70 | + Delete() |
75 | return err | 71 | return err |
76 | } | 72 | } |
77 | 73 | ||
@@ -95,14 +91,14 @@ func (repo *DepartmentRepository) FindOne(queryOptions map[string]interface{}) ( | @@ -95,14 +91,14 @@ func (repo *DepartmentRepository) FindOne(queryOptions map[string]interface{}) ( | ||
95 | 91 | ||
96 | func (repo *DepartmentRepository) Find(queryOptions map[string]interface{}) (int, []*domain.Department, error) { | 92 | func (repo *DepartmentRepository) Find(queryOptions map[string]interface{}) (int, []*domain.Department, error) { |
97 | tx := repo.transactionContext.PgTx | 93 | tx := repo.transactionContext.PgTx |
98 | - dparmentModel := []models.Department{} | 94 | + var dparmentModel []models.Department |
99 | query := tx.Model(&dparmentModel). | 95 | query := tx.Model(&dparmentModel). |
100 | Limit(20) | 96 | Limit(20) |
101 | if v, ok := queryOptions["id"]; ok { | 97 | if v, ok := queryOptions["id"]; ok { |
102 | query.Where("id=?", v) | 98 | query.Where("id=?", v) |
103 | } | 99 | } |
104 | if v, ok := queryOptions["ids"]; ok { | 100 | if v, ok := queryOptions["ids"]; ok { |
105 | - query.Where("id in(?)", pg.In(v)) | 101 | + query.Where("id in (?)", pg.In(v)) |
106 | } | 102 | } |
107 | if v, ok := queryOptions["limit"]; ok { | 103 | if v, ok := queryOptions["limit"]; ok { |
108 | query.Limit(v.(int)) | 104 | query.Limit(v.(int)) |
@@ -131,8 +127,8 @@ func (repo *DepartmentRepository) TransformToCompanyDomain(u *models.Department) | @@ -131,8 +127,8 @@ func (repo *DepartmentRepository) TransformToCompanyDomain(u *models.Department) | ||
131 | ParentId: u.ParentId, | 127 | ParentId: u.ParentId, |
132 | ChargeUserIds: u.ChargeUserIds, | 128 | ChargeUserIds: u.ChargeUserIds, |
133 | Path: u.Path, | 129 | Path: u.Path, |
134 | - CreateAt: u.CreateAt, | ||
135 | - UpdateAt: u.UpdateAt, | ||
136 | - DeleteAt: u.DeleteAt, | 130 | + CreatedAt: u.CreatedAt, |
131 | + UpdatedAt: u.UpdatedAt, | ||
132 | + DeletedAt: u.DeletedAt, | ||
137 | } | 133 | } |
138 | } | 134 | } |
1 | +package repository | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/go-pg/pg/v10" | ||
5 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models" | ||
8 | + "time" | ||
9 | +) | ||
10 | + | ||
11 | +type PositionRepository struct { | ||
12 | + transactionContext *pgTransaction.TransactionContext | ||
13 | +} | ||
14 | + | ||
15 | +func NewPositionRepository(tx *pgTransaction.TransactionContext) *PositionRepository { | ||
16 | + return &PositionRepository{ | ||
17 | + transactionContext: tx, | ||
18 | + } | ||
19 | +} | ||
20 | + | ||
21 | +// Insert 新增职位 | ||
22 | +func (repository *PositionRepository) Insert(position *domain.Position) (*domain.Position, error) { | ||
23 | + model := &models.Position{ | ||
24 | + Id: position.Id, | ||
25 | + CompanyId: position.CompanyId, | ||
26 | + Name: position.Name, | ||
27 | + ParentId: position.ParentId, | ||
28 | + Path: position.Path, | ||
29 | + Level: position.Level, | ||
30 | + } | ||
31 | + _, err := repository.transactionContext.PgTx.Model(model).Insert() | ||
32 | + return position, err | ||
33 | +} | ||
34 | + | ||
35 | +// Update 更新 | ||
36 | +func (repository *PositionRepository) Update(position *domain.Position) (*domain.Position, error) { | ||
37 | + model := &models.Position{ | ||
38 | + Id: position.Id, | ||
39 | + CompanyId: position.CompanyId, | ||
40 | + Name: position.Name, | ||
41 | + ParentId: position.ParentId, | ||
42 | + Path: position.Path, | ||
43 | + Level: position.Level, | ||
44 | + UpdatedAt: time.Now(), | ||
45 | + } | ||
46 | + _, err := repository.transactionContext.PgTx.Model(model).WherePK().Update() | ||
47 | + return position, err | ||
48 | +} | ||
49 | + | ||
50 | +// Remove 删除 | ||
51 | +func (repository *PositionRepository) Remove(ids []int64) error { | ||
52 | + _, err := repository.transactionContext.PgTx.Model(&models.Position{}).Where("id in (?)", pg.In(ids)).Delete() | ||
53 | + return err | ||
54 | +} | ||
55 | + | ||
56 | +func (repository *PositionRepository) FindOne(queryOption map[string]interface{}) (*domain.Position, error) { | ||
57 | + position := &models.Position{} | ||
58 | + query := repository.transactionContext.PgTx.Model(position) | ||
59 | + if id, ok := queryOption["id"]; ok { | ||
60 | + query.Where("id = ?", id) | ||
61 | + } | ||
62 | + err := query.First() | ||
63 | + if err != nil { | ||
64 | + return nil, err | ||
65 | + } | ||
66 | + return repository.transferToDomain(position), nil | ||
67 | +} | ||
68 | + | ||
69 | +func (repository *PositionRepository) transferToDomain(model *models.Position) *domain.Position { | ||
70 | + return &domain.Position{ | ||
71 | + Id: model.Id, | ||
72 | + CompanyId: model.CompanyId, | ||
73 | + Name: model.Name, | ||
74 | + ParentId: model.ParentId, | ||
75 | + Path: model.Path, | ||
76 | + Level: model.Level, | ||
77 | + } | ||
78 | +} |
@@ -27,7 +27,7 @@ func (repo *ReceivedMessageRepository) SaveMessage(param *domain.ReceivedMessage | @@ -27,7 +27,7 @@ func (repo *ReceivedMessageRepository) SaveMessage(param *domain.ReceivedMessage | ||
27 | MessageType: param.MessageType, | 27 | MessageType: param.MessageType, |
28 | MessageBody: param.MessageBody, | 28 | MessageBody: param.MessageBody, |
29 | OccurredOn: param.OccurredOn, | 29 | OccurredOn: param.OccurredOn, |
30 | - CreateAt: time.Now(), | 30 | + CreatedAt: time.Now(), |
31 | } | 31 | } |
32 | tx := repo.transactionContext.PgTx | 32 | tx := repo.transactionContext.PgTx |
33 | _, err := tx.Model(message). | 33 | _, err := tx.Model(message). |
@@ -50,7 +50,7 @@ func (repo *ReceivedMessageRepository) FindMessage(messageId int64) (*domain.Rec | @@ -50,7 +50,7 @@ func (repo *ReceivedMessageRepository) FindMessage(messageId int64) (*domain.Rec | ||
50 | MessageType: receivedMessageModel.MessageType, | 50 | MessageType: receivedMessageModel.MessageType, |
51 | MessageBody: receivedMessageModel.MessageBody, | 51 | MessageBody: receivedMessageModel.MessageBody, |
52 | OccurredOn: receivedMessageModel.OccurredOn, | 52 | OccurredOn: receivedMessageModel.OccurredOn, |
53 | - CreateAt: receivedMessageModel.CreateAt, | 53 | + CreatedAt: receivedMessageModel.CreatedAt, |
54 | } | 54 | } |
55 | return message, nil | 55 | return message, nil |
56 | 56 |
1 | package repository | 1 | package repository |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | - "time" | ||
5 | - | ||
6 | "github.com/go-pg/pg/v10" | 4 | "github.com/go-pg/pg/v10" |
7 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | 5 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" |
8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
@@ -30,9 +28,9 @@ func (repo *UserRepository) Insert(user *domain.User) (*domain.User, error) { | @@ -30,9 +28,9 @@ func (repo *UserRepository) Insert(user *domain.User) (*domain.User, error) { | ||
30 | AdminType: user.AdminType, | 28 | AdminType: user.AdminType, |
31 | Name: user.Name, | 29 | Name: user.Name, |
32 | Status: user.Status, | 30 | Status: user.Status, |
33 | - UpdateAt: user.UpdateAt, | ||
34 | - CreateAt: user.CreateAt, | ||
35 | - DeleteAt: user.DeleteAt, | 31 | + UpdatedAt: user.UpdatedAt, |
32 | + CreatedAt: user.CreatedAt, | ||
33 | + DeletedAt: user.DeletedAt, | ||
36 | } | 34 | } |
37 | tx := repo.transactionContext.PgTx | 35 | tx := repo.transactionContext.PgTx |
38 | _, err := tx.Model(&userModel).Insert() | 36 | _, err := tx.Model(&userModel).Insert() |
@@ -53,9 +51,9 @@ func (repo *UserRepository) Update(user *domain.User) (*domain.User, error) { | @@ -53,9 +51,9 @@ func (repo *UserRepository) Update(user *domain.User) (*domain.User, error) { | ||
53 | Name: user.Name, | 51 | Name: user.Name, |
54 | Email: user.Email, | 52 | Email: user.Email, |
55 | Status: user.Status, | 53 | Status: user.Status, |
56 | - UpdateAt: user.UpdateAt, | ||
57 | - CreateAt: user.CreateAt, | ||
58 | - DeleteAt: user.DeleteAt, | 54 | + UpdatedAt: user.UpdatedAt, |
55 | + CreatedAt: user.CreatedAt, | ||
56 | + DeletedAt: user.DeletedAt, | ||
59 | } | 57 | } |
60 | tx := repo.transactionContext.PgTx | 58 | tx := repo.transactionContext.PgTx |
61 | _, err := tx.Model(&userModel).WherePK().Update() | 59 | _, err := tx.Model(&userModel).WherePK().Update() |
@@ -66,13 +64,9 @@ func (repo *UserRepository) Update(user *domain.User) (*domain.User, error) { | @@ -66,13 +64,9 @@ func (repo *UserRepository) Update(user *domain.User) (*domain.User, error) { | ||
66 | } | 64 | } |
67 | 65 | ||
68 | func (repo *UserRepository) Remove(userId []int64) error { | 66 | func (repo *UserRepository) Remove(userId []int64) error { |
69 | - nowTime := time.Now() | ||
70 | tx := repo.transactionContext.PgTx | 67 | tx := repo.transactionContext.PgTx |
71 | uModel := models.User{} | 68 | uModel := models.User{} |
72 | - _, err := tx.Model(&uModel). | ||
73 | - Set("delete_at", nowTime). | ||
74 | - Where("id in (?)", pg.In(userId)). | ||
75 | - Update() | 69 | + _, err := tx.Model(&uModel).Where("id in (?)", pg.In(userId)).Delete() |
76 | return err | 70 | return err |
77 | } | 71 | } |
78 | 72 | ||
@@ -83,6 +77,9 @@ func (repo *UserRepository) FindOne(queryOptions map[string]interface{}) (*domai | @@ -83,6 +77,9 @@ func (repo *UserRepository) FindOne(queryOptions map[string]interface{}) (*domai | ||
83 | if v, ok := queryOptions["id"]; ok { | 77 | if v, ok := queryOptions["id"]; ok { |
84 | query.Where("id=?", v) | 78 | query.Where("id=?", v) |
85 | } | 79 | } |
80 | + if v, ok := queryOptions["companyId"]; ok { | ||
81 | + query.Where("company_id = ?", v) | ||
82 | + } | ||
86 | err := query.First() | 83 | err := query.First() |
87 | if err == pg.ErrNoRows { | 84 | if err == pg.ErrNoRows { |
88 | return nil, ErrNoRows | 85 | return nil, ErrNoRows |
@@ -97,8 +94,7 @@ func (repo *UserRepository) FindOne(queryOptions map[string]interface{}) (*domai | @@ -97,8 +94,7 @@ func (repo *UserRepository) FindOne(queryOptions map[string]interface{}) (*domai | ||
97 | func (repo *UserRepository) Find(queryOptions map[string]interface{}) (int, []*domain.User, error) { | 94 | func (repo *UserRepository) Find(queryOptions map[string]interface{}) (int, []*domain.User, error) { |
98 | tx := repo.transactionContext.PgTx | 95 | tx := repo.transactionContext.PgTx |
99 | userModel := []models.User{} | 96 | userModel := []models.User{} |
100 | - query := tx.Model(&userModel).Where("delete_at isnull"). | ||
101 | - Limit(20) | 97 | + query := tx.Model(&userModel).Limit(20) |
102 | if v, ok := queryOptions["id"]; ok { | 98 | if v, ok := queryOptions["id"]; ok { |
103 | query.Where("id=?", v) | 99 | query.Where("id=?", v) |
104 | } | 100 | } |
@@ -142,8 +138,8 @@ func (repo *UserRepository) TransformToUserDomain(user *models.User) *domain.Use | @@ -142,8 +138,8 @@ func (repo *UserRepository) TransformToUserDomain(user *models.User) *domain.Use | ||
142 | Name: user.Name, | 138 | Name: user.Name, |
143 | Email: user.Email, | 139 | Email: user.Email, |
144 | Status: user.Status, | 140 | Status: user.Status, |
145 | - UpdateAt: user.UpdateAt, | ||
146 | - CreateAt: user.CreateAt, | ||
147 | - DeleteAt: user.DeleteAt, | 141 | + UpdatedAt: user.UpdatedAt, |
142 | + CreatedAt: user.CreatedAt, | ||
143 | + DeletedAt: user.DeletedAt, | ||
148 | } | 144 | } |
149 | } | 145 | } |
1 | +package serviceGateway | ||
2 | + | ||
3 | +import ( | ||
4 | + "crypto/tls" | ||
5 | + "encoding/json" | ||
6 | + "github.com/beego/beego/v2/client/httplib" | ||
7 | + "github.com/linmadan/egglib-go/utils/tool_funs" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" | ||
9 | + "io/ioutil" | ||
10 | + "net/http" | ||
11 | + "reflect" | ||
12 | + "strings" | ||
13 | + "time" | ||
14 | +) | ||
15 | + | ||
16 | +type httpLibBaseServiceGateway struct { | ||
17 | + baseURL string | ||
18 | + connectTimeout time.Duration | ||
19 | + readWriteTimeout time.Duration | ||
20 | + request *httplib.BeegoHTTPRequest | ||
21 | + params map[string]interface{} | ||
22 | + body string | ||
23 | +} | ||
24 | + | ||
25 | +func (client *httpLibBaseServiceGateway) CreateRequest(method, url string) { | ||
26 | + client.request = httplib.NewBeegoRequest(client.baseURL+url, strings.ToUpper(method)) | ||
27 | + client.request.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}) | ||
28 | +} | ||
29 | + | ||
30 | +// 设置请求参数 | ||
31 | +func (client *httpLibBaseServiceGateway) SetParams(params map[string]string) { | ||
32 | + if len(params) > 0 { | ||
33 | + for key, value := range params { | ||
34 | + client.request.Param(key, value) | ||
35 | + client.params[key] = value | ||
36 | + } | ||
37 | + } | ||
38 | +} | ||
39 | + | ||
40 | +// 设置请求参数 | ||
41 | +func (client *httpLibBaseServiceGateway) SetParam(key, value string) { | ||
42 | + client.request.Param(key, value) | ||
43 | + client.params[key] = value | ||
44 | +} | ||
45 | + | ||
46 | +// 设置body | ||
47 | +func (client *httpLibBaseServiceGateway) SetBody(body interface{}) { | ||
48 | + //判断是否为string | ||
49 | + ty := reflect.TypeOf(body) | ||
50 | + if ty.Name() == "string" { | ||
51 | + client.request.Body(body) | ||
52 | + client.body = body.(string) | ||
53 | + } else { | ||
54 | + mBytes, _ := json.Marshal(body) | ||
55 | + client.request.Body(mBytes) | ||
56 | + client.body = string(mBytes) | ||
57 | + } | ||
58 | + client.request.Header("Content-Type", "application/json") | ||
59 | + client.request.Header("Accept", "application/json") | ||
60 | +} | ||
61 | + | ||
62 | +// 设置头信息 | ||
63 | +func (client *httpLibBaseServiceGateway) SetHeader(key, value string) { | ||
64 | + client.request.Header(key, value) | ||
65 | +} | ||
66 | + | ||
67 | +// 设置多个头部信息 | ||
68 | +func (client *httpLibBaseServiceGateway) SetHeaders(headers map[string]string) { | ||
69 | + if len(headers) > 0 { | ||
70 | + for key, value := range headers { | ||
71 | + client.request.Header(key, value) | ||
72 | + } | ||
73 | + } | ||
74 | +} | ||
75 | + | ||
76 | +// 设置超时时间 | ||
77 | +func (client *httpLibBaseServiceGateway) SetTimeout(connectTimeout, readWriteTimeout time.Duration) { | ||
78 | + client.request.SetTimeout(connectTimeout, readWriteTimeout) | ||
79 | +} | ||
80 | + | ||
81 | +// 设置cookie | ||
82 | +func (client *httpLibBaseServiceGateway) SetCookie(cookie *http.Cookie) { | ||
83 | + client.request.SetCookie(cookie) | ||
84 | +} | ||
85 | + | ||
86 | +// 设置UserAgent | ||
87 | +func (client *httpLibBaseServiceGateway) SetUserAgent(userAgent string) { | ||
88 | + client.request.SetUserAgent(userAgent) | ||
89 | +} | ||
90 | + | ||
91 | +// 请求结果返回结构体 | ||
92 | +func (client *httpLibBaseServiceGateway) ToJson(result interface{}) error { | ||
93 | + response, err := client.request.Response() | ||
94 | + if err != nil { | ||
95 | + return err | ||
96 | + } | ||
97 | + client.addOptionLog(response) | ||
98 | + mBytes, err := ioutil.ReadAll(response.Body) | ||
99 | + if err != nil { | ||
100 | + return err | ||
101 | + } | ||
102 | + err = json.Unmarshal(mBytes, result) | ||
103 | + //增加返回数据日志 | ||
104 | + log.Logger.Debug(response.Request.Method+" "+response.Request.URL.String()+"----response----", tool_funs.SimpleStructToMap(result)) | ||
105 | + return err | ||
106 | +} | ||
107 | + | ||
108 | +// 请求结果返回string | ||
109 | +func (client *httpLibBaseServiceGateway) ToString() (string, error) { | ||
110 | + response, err := client.request.Response() | ||
111 | + if err != nil { | ||
112 | + return "", err | ||
113 | + } | ||
114 | + client.addOptionLog(response) | ||
115 | + mBytes, err := ioutil.ReadAll(response.Body) | ||
116 | + //增加返回数据日志 | ||
117 | + log.Logger.Debug(response.Request.Method + " " + response.Request.URL.String() + "----response----" + string(mBytes)) | ||
118 | + return string(mBytes), err | ||
119 | +} | ||
120 | + | ||
121 | +// 请求结果返回bytes | ||
122 | +func (client *httpLibBaseServiceGateway) ToBytes() ([]byte, error) { | ||
123 | + response, err := client.request.Response() | ||
124 | + if err != nil { | ||
125 | + return nil, err | ||
126 | + } | ||
127 | + client.addOptionLog(response) | ||
128 | + mBytes, _ := ioutil.ReadAll(response.Body) | ||
129 | + //增加返回数据日志 | ||
130 | + log.Logger.Debug(response.Request.Method + " " + response.Request.URL.String() + "----response----" + string(mBytes)) | ||
131 | + return mBytes, nil | ||
132 | +} | ||
133 | + | ||
134 | +// 添加options日志 | ||
135 | +func (client *httpLibBaseServiceGateway) addOptionLog(response *http.Response) { | ||
136 | + logTxt := response.Request.Method + " " + response.Request.URL.String() | ||
137 | + if response.Request.Method != http.MethodGet { | ||
138 | + contentType := client.request.GetRequest().Header.Get("Content-Type") | ||
139 | + if strings.Contains(strings.ToLower(contentType), "json") { | ||
140 | + log.Logger.Debug(logTxt+" ----options----", map[string]interface{}{"body": client.body}) | ||
141 | + } else { | ||
142 | + log.Logger.Debug(logTxt+" ----options----", map[string]interface{}{"params": client.params}) | ||
143 | + } | ||
144 | + } | ||
145 | +} |
1 | +package serviceGateway | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/serviceGateway/reply" | ||
6 | + "net/http" | ||
7 | +) | ||
8 | + | ||
9 | +type HttpLibBusinessAdminServiceGateway struct { | ||
10 | + httpLibBaseServiceGateway | ||
11 | +} | ||
12 | + | ||
13 | +// GetUserAuth 请求企业平台确认用户是否可以使用 | ||
14 | +func (serviceGateway *HttpLibBusinessAdminServiceGateway) GetUserAuth(userId int64, platformId int) (*reply.BusinessAdminUserAuth, error) { | ||
15 | + businessAdminUserAuth := &reply.BusinessAdminUserAuth{} | ||
16 | + serviceGateway.CreateRequest(http.MethodPost, "/auth/get-user-auth") | ||
17 | + serviceGateway.SetBody(map[string]interface{}{ | ||
18 | + "userId": userId, | ||
19 | + "platformId": platformId, | ||
20 | + }) | ||
21 | + err := serviceGateway.ToJson(businessAdminUserAuth) | ||
22 | + return businessAdminUserAuth, err | ||
23 | +} | ||
24 | + | ||
25 | +func NewHttpLibBusinessAdminServiceGateway() *HttpLibBusinessAdminServiceGateway { | ||
26 | + return &HttpLibBusinessAdminServiceGateway{ | ||
27 | + httpLibBaseServiceGateway{ | ||
28 | + baseURL: constant.BUSINESS_ADMIN_SERVICE_HOST, | ||
29 | + }, | ||
30 | + } | ||
31 | +} |
1 | +package serviceGateway | ||
2 | + | ||
3 | +import ( | ||
4 | + "crypto/sha1" | ||
5 | + "fmt" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/serviceGateway/reply" | ||
8 | + "net/http" | ||
9 | + "net/url" | ||
10 | + "time" | ||
11 | +) | ||
12 | + | ||
13 | +type HttpLibUCenterApiServiceGateway struct { | ||
14 | + httpLibBaseServiceGateway | ||
15 | +} | ||
16 | + | ||
17 | +func (serviceGateway *HttpLibUCenterApiServiceGateway) buildHeaders() map[string]string { | ||
18 | + nowTime := fmt.Sprint(time.Now().Unix()) | ||
19 | + str := fmt.Sprintf("%s%s%s", nowTime, constant.UCENTER_SECRET, constant.UCENTER_CHECK_ALT) | ||
20 | + bt := sha1.Sum([]byte(str)) | ||
21 | + checksum := fmt.Sprintf("%x", bt) | ||
22 | + return map[string]string{ | ||
23 | + "appKey": constant.UCENTER_APP_KEY, | ||
24 | + "nonce": "", | ||
25 | + "curTime": nowTime, | ||
26 | + "checkSum": checksum, | ||
27 | + } | ||
28 | +} | ||
29 | + | ||
30 | +// AuthCode PC端登录 | ||
31 | +func (serviceGateway *HttpLibUCenterApiServiceGateway) AuthCode(code string) (*reply.UCenterAuthCode, error) { | ||
32 | + authCodeReply := &reply.UCenterAuthCode{} | ||
33 | + serviceGateway.CreateRequest(http.MethodPost, "/auth/serverLogin") | ||
34 | + serviceGateway.SetBody(map[string]interface{}{ | ||
35 | + "type": 3, | ||
36 | + "secret": url.QueryEscape(code), | ||
37 | + }) | ||
38 | + serviceGateway.SetHeaders(serviceGateway.buildHeaders()) | ||
39 | + err := serviceGateway.ToJson(authCodeReply) | ||
40 | + return authCodeReply, err | ||
41 | +} | ||
42 | + | ||
43 | +func NewHttpLibUCenterApiServiceGateway() *HttpLibUCenterApiServiceGateway { | ||
44 | + return &HttpLibUCenterApiServiceGateway{ | ||
45 | + httpLibBaseServiceGateway{baseURL: constant.UCENTER_SERVICE_HOST}, | ||
46 | + } | ||
47 | +} |
1 | +package reply | ||
2 | + | ||
3 | +type BusinessAdminUserAuth struct { | ||
4 | + BaseReply | ||
5 | + Data struct { | ||
6 | + UserAuth bool `json:"userAuth"` | ||
7 | + } `json:"data"` | ||
8 | +} | ||
9 | + | ||
10 | +func (businessAdminUserAuth *BusinessAdminUserAuth) Message() string { | ||
11 | + if businessAdminUserAuth.Code == 10001 { | ||
12 | + return "用户不存在" | ||
13 | + } | ||
14 | + if businessAdminUserAuth.Code == 10002 { | ||
15 | + return "登录凭证已过期,请重新登陆" | ||
16 | + } | ||
17 | + if businessAdminUserAuth.Code == 10003 { | ||
18 | + return "验证码不能为空" | ||
19 | + } | ||
20 | + if businessAdminUserAuth.Code == 10004 { | ||
21 | + return "登录凭证不能为空" | ||
22 | + } | ||
23 | + if businessAdminUserAuth.Code == 10005 { | ||
24 | + return "密码不能为空" | ||
25 | + } | ||
26 | + if businessAdminUserAuth.Code == 10006 { | ||
27 | + return "当前账号已被禁用" | ||
28 | + } | ||
29 | + if businessAdminUserAuth.Code == 10007 { | ||
30 | + return "该企业已被禁用,无法正常访问!重新选择其他企业进入,或退出登录。" | ||
31 | + } | ||
32 | + if businessAdminUserAuth.Code == 10008 { | ||
33 | + return "抱歉,企业管理员未帮您开通权限。如需访问,请联系企业管理员" | ||
34 | + } | ||
35 | + if businessAdminUserAuth.Code == 10009 { | ||
36 | + return "密码错误" | ||
37 | + } | ||
38 | + if businessAdminUserAuth.Code == 10010 { | ||
39 | + return "验证码错误" | ||
40 | + } | ||
41 | + return "你没有权限进入系统,请联系管理员" | ||
42 | +} |
1 | +package reply | ||
2 | + | ||
3 | +type UCenterAuthCode struct { | ||
4 | + BaseReply | ||
5 | + Data struct { | ||
6 | + Id int64 `json:"id"` //统一用户中心的id,对应本系统中users表的open_id | ||
7 | + Phone string `json:"phone"` //手机号 ,账号 | ||
8 | + NickName string `json:"nickname"` //昵称 | ||
9 | + Avatar string `json:"avatar"` //头像 | ||
10 | + ImToken string `json:"imtoken"` //网易云imtoken | ||
11 | + AccId int64 `json:"accid"` //网易云id | ||
12 | + CustomerAccount int64 `json:"customerAccount"` //客服id | ||
13 | + CompanyId int64 `json:"companyId"` //总后台的公司id ,对应company表中的admin_company_id | ||
14 | + MUid int64 `json:"muid"` //企业平台的用户id,对应本系统中users表的id | ||
15 | + } `json:"data"` | ||
16 | +} |
1 | +package controllers | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/web/beego" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/auth/command" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/auth/service" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
8 | +) | ||
9 | + | ||
10 | +type AuthController struct { | ||
11 | + beego.BaseController | ||
12 | +} | ||
13 | + | ||
14 | +// Login PC端登录 | ||
15 | +func (controller *AuthController) Login() { | ||
16 | + authService := &service.AuthService{} | ||
17 | + loginCommand := &command.LoginCommand{} | ||
18 | + _ = controller.Unmarshal(loginCommand) | ||
19 | + resp, err := authService.Login(loginCommand) | ||
20 | + controller.Response(resp, err) | ||
21 | +} | ||
22 | + | ||
23 | +func (controller *AuthController) User() { | ||
24 | + | ||
25 | + userAuth := controller.Ctx.Input.GetData(domain.UserAuth{}).(*domain.UserAuth) | ||
26 | + controller.Response(map[string]interface{}{ | ||
27 | + "user": userAuth, | ||
28 | + }, nil) | ||
29 | +} |
1 | +package controllers | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/beego/beego/v2/server/web" | ||
5 | + "os" | ||
6 | +) | ||
7 | + | ||
8 | +type LoggerController struct { | ||
9 | + web.Controller | ||
10 | +} | ||
11 | + | ||
12 | +func (controller *LoggerController) Output() { | ||
13 | + bytes, _ := os.ReadFile("./debug.log") | ||
14 | + controller.Ctx.WriteString(string(bytes)) | ||
15 | +} |
1 | +package middlewares | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/beego/beego/v2/server/web/context" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
7 | +) | ||
8 | + | ||
9 | +func CheckAdminToken() func(ctx *context.Context) { | ||
10 | + return func(ctx *context.Context) { | ||
11 | + adminToken := ctx.Input.Header("x-admin-token") | ||
12 | + userAuth, err := (&domain.UserAuth{}).ParseAccessToken(adminToken) | ||
13 | + if err != nil || userAuth.UserId <= 0 { | ||
14 | + forbidden(ctx) | ||
15 | + return | ||
16 | + } | ||
17 | + if userAuth.PlatformId != constant.PLATFORM_ADMIN_ID { | ||
18 | + forbidden(ctx) | ||
19 | + return | ||
20 | + } | ||
21 | + ctx.Input.SetData(domain.UserAuth{}, userAuth) | ||
22 | + } | ||
23 | +} | ||
24 | + | ||
25 | +func forbidden(ctx *context.Context) { | ||
26 | + resp := map[string]interface{}{ | ||
27 | + "code": 902, | ||
28 | + "msg": "Authorization过期或无效,需要进行重新获取令牌", | ||
29 | + } | ||
30 | + _ = ctx.Output.JSON(resp, false, false) | ||
31 | +} |
1 | +package middlewares | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/beego/beego/v2/server/web/context" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
7 | +) | ||
8 | + | ||
9 | +func CheckFontToken() func(ctx *context.Context) { | ||
10 | + return func(ctx *context.Context) { | ||
11 | + adminToken := ctx.Input.Header("x-font-token") | ||
12 | + userAuth, err := (&domain.UserAuth{}).ParseAccessToken(adminToken) | ||
13 | + if err != nil || userAuth.UserId <= 0 { | ||
14 | + forbidden(ctx) | ||
15 | + return | ||
16 | + } | ||
17 | + if userAuth.PlatformId != constant.PLATFORM_FONT_ID { | ||
18 | + forbidden(ctx) | ||
19 | + return | ||
20 | + } | ||
21 | + ctx.Input.SetData(domain.UserAuth{}, userAuth) | ||
22 | + } | ||
23 | +} |
pkg/port/beego/routers/auth.go
0 → 100644
1 | +package routers | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/beego/beego/v2/server/web" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares" | ||
7 | +) | ||
8 | + | ||
9 | +func init() { | ||
10 | + web.Router("/login", &controllers.AuthController{}, "Post:Login") | ||
11 | + | ||
12 | + web.InsertFilter("/auth/admin/*", web.BeforeExec, middlewares.CheckAdminToken()) | ||
13 | + web.Router("/auth/admin/user", &controllers.AuthController{}, "Get:User") | ||
14 | + | ||
15 | + web.InsertFilter("/auth/font/*", web.BeforeExec, middlewares.CheckFontToken()) | ||
16 | + web.Router("/auth/font/user", &controllers.AuthController{}, "Get:User") | ||
17 | +} |
pkg/port/beego/routers/logger.go
0 → 100644
@@ -2,6 +2,7 @@ package handle | @@ -2,6 +2,7 @@ package handle | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "encoding/json" | 4 | "encoding/json" |
5 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/position/service" | ||
5 | "strconv" | 6 | "strconv" |
6 | 7 | ||
7 | "github.com/Shopify/sarama" | 8 | "github.com/Shopify/sarama" |
@@ -15,13 +16,12 @@ import ( | @@ -15,13 +16,12 @@ import ( | ||
15 | 16 | ||
16 | func SyncDataBusinessAdmin(msgData *sarama.ConsumerMessage) error { | 17 | func SyncDataBusinessAdmin(msgData *sarama.ConsumerMessage) error { |
17 | var receivedMsg domain.ReceivedMessage | 18 | var receivedMsg domain.ReceivedMessage |
18 | - | ||
19 | - log.Logger.Debug(string(msgData.Value)) | ||
20 | err := json.Unmarshal(msgData.Value, &receivedMsg) | 19 | err := json.Unmarshal(msgData.Value, &receivedMsg) |
21 | if err != nil { | 20 | if err != nil { |
22 | log.Logger.Error("解析ReceivedMessage 失败" + err.Error()) | 21 | log.Logger.Error("解析ReceivedMessage 失败" + err.Error()) |
23 | return err | 22 | return err |
24 | } | 23 | } |
24 | + log.Logger.Debug("解析message:", map[string]interface{}{"data": receivedMsg}) | ||
25 | transactionContext, err := factory.CreateTransactionContext(nil) | 25 | transactionContext, err := factory.CreateTransactionContext(nil) |
26 | if err != nil { | 26 | if err != nil { |
27 | return err | 27 | return err |
@@ -60,7 +60,9 @@ func SyncDataBusinessAdmin(msgData *sarama.ConsumerMessage) error { | @@ -60,7 +60,9 @@ func SyncDataBusinessAdmin(msgData *sarama.ConsumerMessage) error { | ||
60 | err = companySrv.FromBusinessAdmin(&msgBody) | 60 | err = companySrv.FromBusinessAdmin(&msgBody) |
61 | if err != nil { | 61 | if err != nil { |
62 | log.Logger.Error("处理company消息失败"+err.Error(), map[string]interface{}{ | 62 | log.Logger.Error("处理company消息失败"+err.Error(), map[string]interface{}{ |
63 | - "data": msgBody, | 63 | + "module": msgBody.Module, |
64 | + "action": msgBody.Action, | ||
65 | + "data": string(msgBody.Data), | ||
64 | }) | 66 | }) |
65 | return err | 67 | return err |
66 | } | 68 | } |
@@ -69,7 +71,9 @@ func SyncDataBusinessAdmin(msgData *sarama.ConsumerMessage) error { | @@ -69,7 +71,9 @@ func SyncDataBusinessAdmin(msgData *sarama.ConsumerMessage) error { | ||
69 | err = departmentSrv.FromBusinessAdmin(&msgBody) | 71 | err = departmentSrv.FromBusinessAdmin(&msgBody) |
70 | if err != nil { | 72 | if err != nil { |
71 | log.Logger.Error("处理department消息失败"+err.Error(), map[string]interface{}{ | 73 | log.Logger.Error("处理department消息失败"+err.Error(), map[string]interface{}{ |
72 | - "data": msgBody, | 74 | + "module": msgBody.Module, |
75 | + "action": msgBody.Action, | ||
76 | + "data": string(msgBody.Data), | ||
73 | }) | 77 | }) |
74 | return err | 78 | return err |
75 | } | 79 | } |
@@ -78,7 +82,20 @@ func SyncDataBusinessAdmin(msgData *sarama.ConsumerMessage) error { | @@ -78,7 +82,20 @@ func SyncDataBusinessAdmin(msgData *sarama.ConsumerMessage) error { | ||
78 | err = employeeSrv.FromBusinessAdmin(&msgBody) | 82 | err = employeeSrv.FromBusinessAdmin(&msgBody) |
79 | if err != nil { | 83 | if err != nil { |
80 | log.Logger.Error("处理employee消息失败"+err.Error(), map[string]interface{}{ | 84 | log.Logger.Error("处理employee消息失败"+err.Error(), map[string]interface{}{ |
81 | - "data": msgBody, | 85 | + "module": msgBody.Module, |
86 | + "action": msgBody.Action, | ||
87 | + "data": string(msgBody.Data), | ||
88 | + }) | ||
89 | + return err | ||
90 | + } | ||
91 | + case "position": | ||
92 | + positionSrv := service.SyncDataPositionService{} | ||
93 | + err = positionSrv.FromBusinessAdmin(&msgBody) | ||
94 | + if err != nil { | ||
95 | + log.Logger.Error("处理position消息失败"+err.Error(), map[string]interface{}{ | ||
96 | + "module": msgBody.Module, | ||
97 | + "action": msgBody.Action, | ||
98 | + "data": string(msgBody.Data), | ||
82 | }) | 99 | }) |
83 | return err | 100 | return err |
84 | } | 101 | } |
@@ -6,20 +6,20 @@ import ( | @@ -6,20 +6,20 @@ import ( | ||
6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant" | 6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant" |
7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" | 7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" |
8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/consumer/handle" | 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/consumer/handle" |
9 | + "strings" | ||
9 | ) | 10 | ) |
10 | 11 | ||
11 | func Run() { | 12 | func Run() { |
12 | messageHandlerMap := make(map[string]func(message *sarama.ConsumerMessage) error) | 13 | messageHandlerMap := make(map[string]func(message *sarama.ConsumerMessage) error) |
13 | - messageHandlerMap["demo-v1"] = Demo | 14 | + //messageHandlerMap["demo-v1"] = Demo |
14 | //"指定topic" => 对应的处理方法 | 15 | //"指定topic" => 对应的处理方法 |
15 | - messageHandlerMap["mmm-business-admin-dev"] = handle.SyncDataBusinessAdmin | ||
16 | - err := saramaConsumer.StartConsume(constant.KAFKA_HOSTS, constant.SERVICE_NAME, messageHandlerMap, log.Logger) | 16 | + messageHandlerMap[constant.KAFKA_BUSINESS_TOPIC] = handle.SyncDataBusinessAdmin |
17 | + hosts := strings.Split(constant.KAFKA_HOSTS, ",") | ||
18 | + var host string | ||
19 | + if len(hosts) > 0 { | ||
20 | + host = hosts[0] | ||
21 | + } | ||
22 | + log.Logger.Debug("kafka host: " + host + " topic:" + constant.KAFKA_BUSINESS_TOPIC + " group id:" + constant.KAFKA_GROUP_ID) | ||
23 | + err := saramaConsumer.StartConsume(host, constant.KAFKA_GROUP_ID, messageHandlerMap, log.Logger) | ||
17 | log.Logger.Error(err.Error()) | 24 | log.Logger.Error(err.Error()) |
18 | } | 25 | } |
19 | - | ||
20 | -func Demo(message *sarama.ConsumerMessage) error { | ||
21 | - k := string(message.Key) | ||
22 | - v := string(message.Value) | ||
23 | - log.Logger.Debug("message===>" + k + ":" + v) | ||
24 | - return nil | ||
25 | -} |
-
请 注册 或 登录 后发表评论