正在显示
100 个修改的文件
包含
2470 行增加
和
0 行删除
.gitignore
0 → 100644
1 | +# Compiled Object codefiles, Static and Dynamic libs (Shared Objects) | ||
2 | +*.o | ||
3 | +*.a | ||
4 | +*.so | ||
5 | + | ||
6 | +# Folders | ||
7 | +_obj | ||
8 | +_test | ||
9 | + | ||
10 | +# Architecture specific extensions/prefixes | ||
11 | +*.[568vq] | ||
12 | +[568vq].out | ||
13 | + | ||
14 | +*.cgo1.go | ||
15 | +*.cgo2.c | ||
16 | +_cgo_defun.c | ||
17 | +_cgo_gotypes.go | ||
18 | +_cgo_export.* | ||
19 | + | ||
20 | +_testmain.go | ||
21 | + | ||
22 | +*.exe | ||
23 | +*.test | ||
24 | +.log | ||
25 | +.idea | ||
26 | + | ||
27 | +app.log | ||
28 | +go.sum | ||
29 | +lastupdate.tmp |
Dockerfile
0 → 100644
1 | +FROM golang:latest | ||
2 | +ENV APP_DIR $GOPATH/src/character-library-metadata-bastion | ||
3 | +RUN mkdir -p $APP_DIR | ||
4 | +WORKDIR $APP_DIR/ | ||
5 | +COPY ./pkg pkg | ||
6 | +COPY ./conf conf | ||
7 | +COPY ./go.mod go.mod | ||
8 | +COPY ./go.sum go.sum | ||
9 | +COPY ./main.go main.go | ||
10 | +RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"] | ||
11 | +ENV GO111MODULE on | ||
12 | +ENV GOPROXY https://goproxy.io | ||
13 | +RUN ["go","mod","tidy"] | ||
14 | +RUN ["ls"] | ||
15 | +RUN ["go","build"] | ||
16 | +ENTRYPOINT ["./character-library-metadata-bastion"] |
README.md
0 → 100644
config/app.conf
0 → 100644
1 | +POSTGRESQL_DB_NAME = allied_creation_dev | ||
2 | +POSTGRESQL_HOST = 114.55.200.59 | ||
3 | +POSTGRESQL_PORT = 31543 | ||
4 | +POSTGRESQL_USER = postgres | ||
5 | +POSTGRESQL_PASSWORD = eagle1010 | ||
6 | +DISABLE_SQL_GENERATE_COMMENT = false | ||
7 | +SERVICE_ENV = test | ||
8 | +HTTP_PORT = 8081 | ||
9 | +ENABLE_KAFKA_LOG11 = true | ||
10 | +HTTPS_PORT = 8143 | ||
11 | +ALLIED_CREATION_USER_HOST = http://allied-creation-user-dev.fjmaimaimai.com |
config/app_test.conf
0 → 100644
1 | +POSTGRESQL_DB_NAME = allied_creation_test | ||
2 | +POSTGRESQL_HOST = 114.55.200.59 | ||
3 | +POSTGRESQL_PORT = 31543 | ||
4 | +POSTGRESQL_USER = postgres | ||
5 | +POSTGRESQL_PASSWORD = eagle1010 | ||
6 | +DISABLE_SQL_GENERATE_COMMENT = false | ||
7 | +SERVICE_ENV = test | ||
8 | +HTTP_PORT = 8081 | ||
9 | +ENABLE_KAFKA_LOG11 = true | ||
10 | +HTTPS_PORT = 8143 | ||
11 | +ALLIED_CREATION_USER_HOST = http://allied-creation-user-test.fjmaimaimai.com | ||
12 | +MANUFACTURE_DEFAULT_COMPANYID = 23 | ||
13 | +MANUFACTURE_DEFAULT_ORGID = 487 | ||
14 | +MANUFACTURE_DEFAULT_WORKSHOPID = 28 |
config/fjmaimaimai.com.key
0 → 100644
1 | +-----BEGIN RSA PRIVATE KEY----- | ||
2 | +MIIEpAIBAAKCAQEA45R02HLq/QHraf7VBf6QO4ca1StnmvztF5BLVU7txhKe9FD4 | ||
3 | +CLUhwharlUlPPjYFdqm9pFxynUqt15djEPhGVUEFeBpf931pVuPugNmZ/AVj0p8y | ||
4 | +06eTNLphkrzCdBzISUN5E3PKglz3efIzq6ZK8vbns/XSQA9NRzAPTboe0KC0Flj4 | ||
5 | +YPP1X69aJiBOGClsAjG1EXQ6gxepBiL1Fq3GtpKHrQPFHffUXEkPZJz09x6RxpuU | ||
6 | +CrtxUKdO6eKg89COo3xLXVpOZu94+csBAgvXqmADp/XCQELZRMTTEA4OIyz7yXoK | ||
7 | +nmqceoHaeSv4nzDDMwzITFvWmZHDPHLuZwNSZwIDAQABAoIBAQDGPKf3b0rQLt7g | ||
8 | +irEGsrLyl4JBE7kA4bao4vEsEz+9XLUHfoxAEX+hcFvwA1a6ixYBQmRGCp1v9AAw | ||
9 | +HteVjZ6+XpAkCV102NJsdMlphaLDS/KjIjeE9KCeuoeJ6VC9EeFJKDQMRL2vBsov | ||
10 | +eFGYAJeiwn4cXVHSqUGYc/2wqCJ1eRHJkvprDqIeZU8ND3uQ5Gz/5azezf8hBu2P | ||
11 | +MUDseX1PzdvvElidxpHR1KsZTvGVFMMFWRcSDfQYSIB8EevMKQS2YwU9kmiCI3s3 | ||
12 | +qDEAc/Usj64oRLh3Wwh9V0H26zpn/XyQ5pzYmWtCGUpifGuAAQeFKc1jPN6fJy6a | ||
13 | +WwLprqV5AoGBAP0k7btOXE5+hmMGcuiu3vWg0X3EOQf7MtMlsrMbqrzS4HbaaMqP | ||
14 | +BW4hrQOLl8zB9vOYt0TuK0/+ONLlCgYiodqA8FkC7TUHcTyHUEIE3+QTrI23CY6z | ||
15 | +AbJgnHew4jKhRvbLFHkrrIMWgRIDlIwk7HFwHLpU9tw2SsHMz6hWQjY1AoGBAOYl | ||
16 | +suq/hyYHlI6ggbzkFjchlRxBFEOm8GOa6LLjuP0sxbaFXXfFUtw4YhO0WL8X9JSm | ||
17 | +Qtsb4HVQPZMGlrY5rale4FOXBnSovt0LuPR3gX9OaK9T9x4X+gabQrlGIlcS2QRM | ||
18 | +AvwPGlWptLLmQOgWdcZ5xOGEWdXDhIFrAK6khEmrAoGBAJDRM39YEM6G63JzGgGr | ||
19 | +KLn0SmRcgRPjzOumQVjdlwt2yBq2UASxVTXv5f6FOU5WGGS7FP1GE1kr4m4jwVxJ | ||
20 | +K7bI1LbXScRwgYNTFcLu7vaXmrtn3vvXxDy7sEd41a6JPQOqoge/yG0lzqjzi2Ox | ||
21 | +K+KpdIXUXXUVSicceB+hWTeRAoGAIVuXejT2hsmUe7PB+jnpCmagsS6xnDinIRjD | ||
22 | +36HoHzINGi5sZL7CCs9VT9vU/SWguqb6i72XpAlUU2oiEBl+FU1+ID+EnQYUW/+l | ||
23 | ++DEWIPihbcAy0jbRc4GvgyEqOwqtT9UgnZ4myAHIAiIjiEAxI+pkYfeH+dbT7tou | ||
24 | +iCGqVu8CgYBOF/1Ek3ex23CryLuMHg8wp0VHSSuksnurMWkg/H8qBT7NjWhVNRCi | ||
25 | +mrjy2oCSI6TKPwVZQo15LeOuhXkfYFig667sBvo59Nz+QBQhh6NGwrSiZuYlf3F/ | ||
26 | +8mgDIjspJm4R9kFRAZZcsuHH6hHAge5Lik/yRyztxI9Vlpok6e1bEw== | ||
27 | +-----END RSA PRIVATE KEY----- |
config/fjmaimaimai.com_bundle.crt
0 → 100644
1 | +-----BEGIN CERTIFICATE----- | ||
2 | +MIIGeTCCBWGgAwIBAgIRAI8zZs95ViIzW/6yB+17fngwDQYJKoZIhvcNAQELBQAw | ||
3 | +XDELMAkGA1UEBhMCQ04xGjAYBgNVBAoTEVdvVHJ1cyBDQSBMaW1pdGVkMTEwLwYD | ||
4 | +VQQDDChXb1RydXMgT1YgU2VydmVyIENBICBbUnVuIGJ5IHRoZSBJc3N1ZXJdMB4X | ||
5 | +DTIyMDIxMDAwMDAwMFoXDTIzMDMxMjIzNTk1OVowZjELMAkGA1UEBhMCQ04xEjAQ | ||
6 | +BgNVBAgMCeemj+W7uuecgTEnMCUGA1UECgwe5aSp6IGU5L+h5oGv56eR5oqA5pyJ | ||
7 | +6ZmQ5YWs5Y+4MRowGAYDVQQDDBEqLmZqbWFpbWFpbWFpLmNvbTCCASIwDQYJKoZI | ||
8 | +hvcNAQEBBQADggEPADCCAQoCggEBAOOUdNhy6v0B62n+1QX+kDuHGtUrZ5r87ReQ | ||
9 | +S1VO7cYSnvRQ+Ai1IcIWq5VJTz42BXapvaRccp1KrdeXYxD4RlVBBXgaX/d9aVbj | ||
10 | +7oDZmfwFY9KfMtOnkzS6YZK8wnQcyElDeRNzyoJc93nyM6umSvL257P10kAPTUcw | ||
11 | +D026HtCgtBZY+GDz9V+vWiYgThgpbAIxtRF0OoMXqQYi9RatxraSh60DxR331FxJ | ||
12 | +D2Sc9PcekcablAq7cVCnTunioPPQjqN8S11aTmbvePnLAQIL16pgA6f1wkBC2UTE | ||
13 | +0xAODiMs+8l6Cp5qnHqB2nkr+J8wwzMMyExb1pmRwzxy7mcDUmcCAwEAAaOCAyow | ||
14 | +ggMmMB8GA1UdIwQYMBaAFA1JjxUze8BPtvs6OAn8NBXaYN0UMB0GA1UdDgQWBBSd | ||
15 | +7Jpt75ZS1gDF9uvt6jq/wsM6pTAOBgNVHQ8BAf8EBAMCBaAwDAYDVR0TAQH/BAIw | ||
16 | +ADAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwSQYDVR0gBEIwQDA0Bgsr | ||
17 | +BgEEAbIxAQICFjAlMCMGCCsGAQUFBwIBFhdodHRwczovL3NlY3RpZ28uY29tL0NQ | ||
18 | +UzAIBgZngQwBAgIwPQYDVR0fBDYwNDAyoDCgLoYsaHR0cDovL2NybC5jcmxvY3Nw | ||
19 | +LmNuL1dvVHJ1c09WU2VydmVyQ0FfMi5jcmwwbAYIKwYBBQUHAQEEYDBeMDgGCCsG | ||
20 | +AQUFBzAChixodHRwOi8vYWlhLmNybG9jc3AuY24vV29UcnVzT1ZTZXJ2ZXJDQV8y | ||
21 | +LmNydDAiBggrBgEFBQcwAYYWaHR0cDovL29jc3AuY3Jsb2NzcC5jbjCCAX4GCisG | ||
22 | +AQQB1nkCBAIEggFuBIIBagFoAHYArfe++nz/EMiLnT2cHj4YarRnKV3PsQwkyoWG | ||
23 | +NOvcgooAAAF+4S03XgAABAMARzBFAiEAqR1sq52hM4f5aS3cvFX0eMSDkBy0Ezbf | ||
24 | +8O6DPg7404sCIC+acfUKRvt4A89tcgvdK8TiAvFb1zaaN5608wtyLUcRAHcAejKM | ||
25 | +VNi3LbYg6jjgUh7phBZwMhOFTTvSK8E6V6NS61IAAAF+4S03HAAABAMASDBGAiEA | ||
26 | +7OiNg/IGkzMm3/NDw+oZuqDAYgigaq9Bsh67gyRDw9oCIQCexK1Oo74f6IMRebPU | ||
27 | +Z2/U6DyiOh6bUu/qJJyyhjBHrgB1AOg+0No+9QY1MudXKLyJa8kD08vREWvs62nh | ||
28 | +d31tBr1uAAABfuEtNwMAAAQDAEYwRAIgWcr/D/Ygi5WOeoRdpg93smwz6snU9vxL | ||
29 | +I0CLiufIfKECIAFvFv9PMrHTyC05TIGfWfkVHqGZoPjPKRUtZyoWlMGaMC0GA1Ud | ||
30 | +EQQmMCSCESouZmptYWltYWltYWkuY29tgg9mam1haW1haW1haS5jb20wDQYJKoZI | ||
31 | +hvcNAQELBQADggEBAHhfZLmBvIDl9kQvKZf2IrFUNbd9/yLWnrCoKOaQejVVOGkZ | ||
32 | +BmFpn2ZXGCfuCZUqhZQLc9xL49fkmBACQJa358pLUcrMRweZPPRPW53uGWH6N3IA | ||
33 | +cAShUscFU9LBZ7ynbK9OG58E1O9/taJVQGd7YmjhEyA7A3oTtxjedk1ZPz1Hue/w | ||
34 | +au5wfAg9Tl4ds8/rPTCACSYTd1HXhR9OuqDcinTdtwJrzKp3NKWpQjPvgpNcaJPA | ||
35 | +j8JHnggP3GDe4xGNyt6CmNuZpWVm23CT7pFYwqQYTLqKB5yFRK4PUZ3PPKz49gQv | ||
36 | +hkln6/8l93Jt5oRolk4kq6A/D64jwlNwa7EPlz8= | ||
37 | +-----END CERTIFICATE----- | ||
38 | +-----BEGIN CERTIFICATE----- | ||
39 | +MIIF4TCCA8mgAwIBAgIQHQgpVDhMv3SvabmRFpvwLTANBgkqhkiG9w0BAQwFADCB | ||
40 | +iDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0pl | ||
41 | +cnNleSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNV | ||
42 | +BAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMjAw | ||
43 | +MTA4MDAwMDAwWhcNMzAwMTA3MjM1OTU5WjBcMQswCQYDVQQGEwJDTjEaMBgGA1UE | ||
44 | +ChMRV29UcnVzIENBIExpbWl0ZWQxMTAvBgNVBAMMKFdvVHJ1cyBPViBTZXJ2ZXIg | ||
45 | +Q0EgIFtSdW4gYnkgdGhlIElzc3Vlcl0wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw | ||
46 | +ggEKAoIBAQCARFLq6kqQRZ4SdFMPdd3XJTcOdVVT5bvZZx0VVDrkw3TmSAloQVFf | ||
47 | +RhqDOSXg4CsIaa64qFSrC3a5sc8LgRhx7AUdvoUdfvdxIY1uoyxRWpoWO8oTUkSn | ||
48 | +EXjEPf+zrcU5cWTOi32xWL9vklYds7iOQwgsKAHDzt4an8MLGvcLxAHciyiKcDEh | ||
49 | +HZOGUHO5bKaCq+kP2rJCfVSlNvdyl1B8q+aGWXoi0gXGVL7WX4pcWj+DGuITbLB2 | ||
50 | +MzMytse4MjLJ84zaXh0UD4STlyD8tu/fakdxIwQ7K3/pP3RoGj1R9CvMWXUU+fZm | ||
51 | +KNLW5565hd9Bh3Wkz8b4ApgMD9o3RUjTAgMBAAGjggFwMIIBbDAfBgNVHSMEGDAW | ||
52 | +gBRTeb9aqitKz1SA4dibwJ3ysgNmyzAdBgNVHQ4EFgQUDUmPFTN7wE+2+zo4Cfw0 | ||
53 | +Fdpg3RQwDgYDVR0PAQH/BAQDAgGGMBIGA1UdEwEB/wQIMAYBAf8CAQAwHQYDVR0l | ||
54 | +BBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMCIGA1UdIAQbMBkwDQYLKwYBBAGyMQEC | ||
55 | +AhYwCAYGZ4EMAQICMFAGA1UdHwRJMEcwRaBDoEGGP2h0dHA6Ly9jcmwudXNlcnRy | ||
56 | +dXN0LmNvbS9VU0VSVHJ1c3RSU0FDZXJ0aWZpY2F0aW9uQXV0aG9yaXR5LmNybDBx | ||
57 | +BggrBgEFBQcBAQRlMGMwOgYIKwYBBQUHMAKGLmh0dHA6Ly9jcnQudXNlcnRydXN0 | ||
58 | +LmNvbS9VU0VSVHJ1c3RSU0FBQUFDQS5jcnQwJQYIKwYBBQUHMAGGGWh0dHA6Ly9v | ||
59 | +Y3NwLnVzZXJ0cnVzdC5jb20wDQYJKoZIhvcNAQEMBQADggIBAA5G7XA+fNKyj7Fy | ||
60 | +uotoII38/32eZ4UrC1vGFPEtDyd0yzOrr7SvQUoO2GLxFzIQ0SsgMNXJ4UAhMkTD | ||
61 | +yz1OA0tx0g0GjOQXBGA/yfRR7SgitRJAdbqkPfppMn+dtKXCHHx35ohTL0PklRdb | ||
62 | +mXacvR7rXUIiJMdsvZZqYwc+DpGJ+Zv0sRJZEL7pm1oZv6EV+UzjAlOnLe6yrnyD | ||
63 | +c99Kk1H/RFPUzduUWjiVR2aMDT1oMiwYeB2Zq60Sb201jqZPNQj5E+TkDD5BPFVc | ||
64 | +kLeRi3LyXBUuBvXPsdLtBNlr+LExtCDd66kjeUe2/YbTHF4ai5PZPraQxgbOJJyc | ||
65 | +gizGl/JOgrIQPUOLSQvXlxpKEqS+0z6KqV52bco2PNrC0f8ILKuw0nsfhgcGy46d | ||
66 | +Su8fmU9+FT6e61i2nteKvt8qkkSkAJKQxRUWYduN24mG/OOIkoeOPdYHi+qEfbyI | ||
67 | +qxiiqcH9cZgLK9AVuJoKtt7vg21OyrWi7S5T/WbTfTz9XL7QGe8ZODZZx6d50uo/ | ||
68 | +lDOmXm3p/kdGApvUF1UrL+og22jBLi0Ns6xzCfzrI3SpC9abvU8E9EnxQABuu/gM | ||
69 | +/B63dbaZzSsMVFxeECD9nMWv7IH+/rqyGmjqEJzgKdPGvXhqpebQ1HhWrV+j+ipc | ||
70 | +jplXB1j3GCozDFsninXG102N6wC8 | ||
71 | +-----END CERTIFICATE----- | ||
72 | +-----BEGIN CERTIFICATE----- | ||
73 | +MIIFgTCCBGmgAwIBAgIQOXJEOvkit1HX02wQ3TE1lTANBgkqhkiG9w0BAQwFADB7 | ||
74 | +MQswCQYDVQQGEwJHQjEbMBkGA1UECAwSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYD | ||
75 | +VQQHDAdTYWxmb3JkMRowGAYDVQQKDBFDb21vZG8gQ0EgTGltaXRlZDEhMB8GA1UE | ||
76 | +AwwYQUFBIENlcnRpZmljYXRlIFNlcnZpY2VzMB4XDTE5MDMxMjAwMDAwMFoXDTI4 | ||
77 | +MTIzMTIzNTk1OVowgYgxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpOZXcgSmVyc2V5 | ||
78 | +MRQwEgYDVQQHEwtKZXJzZXkgQ2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBO | ||
79 | +ZXR3b3JrMS4wLAYDVQQDEyVVU0VSVHJ1c3QgUlNBIENlcnRpZmljYXRpb24gQXV0 | ||
80 | +aG9yaXR5MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAgBJlFzYOw9sI | ||
81 | +s9CsVw127c0n00ytUINh4qogTQktZAnczomfzD2p7PbPwdzx07HWezcoEStH2jnG | ||
82 | +vDoZtF+mvX2do2NCtnbyqTsrkfjib9DsFiCQCT7i6HTJGLSR1GJk23+jBvGIGGqQ | ||
83 | +Ijy8/hPwhxR79uQfjtTkUcYRZ0YIUcuGFFQ/vDP+fmyc/xadGL1RjjWmp2bIcmfb | ||
84 | +IWax1Jt4A8BQOujM8Ny8nkz+rwWWNR9XWrf/zvk9tyy29lTdyOcSOk2uTIq3XJq0 | ||
85 | +tyA9yn8iNK5+O2hmAUTnAU5GU5szYPeUvlM3kHND8zLDU+/bqv50TmnHa4xgk97E | ||
86 | +xwzf4TKuzJM7UXiVZ4vuPVb+DNBpDxsP8yUmazNt925H+nND5X4OpWaxKXwyhGNV | ||
87 | +icQNwZNUMBkTrNN9N6frXTpsNVzbQdcS2qlJC9/YgIoJk2KOtWbPJYjNhLixP6Q5 | ||
88 | +D9kCnusSTJV882sFqV4Wg8y4Z+LoE53MW4LTTLPtW//e5XOsIzstAL81VXQJSdhJ | ||
89 | +WBp/kjbmUZIO8yZ9HE0XvMnsQybQv0FfQKlERPSZ51eHnlAfV1SoPv10Yy+xUGUJ | ||
90 | +5lhCLkMaTLTwJUdZ+gQek9QmRkpQgbLevni3/GcV4clXhB4PY9bpYrrWX1Uu6lzG | ||
91 | +KAgEJTm4Diup8kyXHAc/DVL17e8vgg8CAwEAAaOB8jCB7zAfBgNVHSMEGDAWgBSg | ||
92 | +EQojPpbxB+zirynvgqV/0DCktDAdBgNVHQ4EFgQUU3m/WqorSs9UgOHYm8Cd8rID | ||
93 | +ZsswDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMBAf8wEQYDVR0gBAowCDAG | ||
94 | +BgRVHSAAMEMGA1UdHwQ8MDowOKA2oDSGMmh0dHA6Ly9jcmwuY29tb2RvY2EuY29t | ||
95 | +L0FBQUNlcnRpZmljYXRlU2VydmljZXMuY3JsMDQGCCsGAQUFBwEBBCgwJjAkBggr | ||
96 | +BgEFBQcwAYYYaHR0cDovL29jc3AuY29tb2RvY2EuY29tMA0GCSqGSIb3DQEBDAUA | ||
97 | +A4IBAQAYh1HcdCE9nIrgJ7cz0C7M7PDmy14R3iJvm3WOnnL+5Nb+qh+cli3vA0p+ | ||
98 | +rvSNb3I8QzvAP+u431yqqcau8vzY7qN7Q/aGNnwU4M309z/+3ri0ivCRlv79Q2R+ | ||
99 | +/czSAaF9ffgZGclCKxO/WIu6pKJmBHaIkU4MiRTOok3JMrO66BQavHHxW/BBC5gA | ||
100 | +CiIDEOUMsfnNkjcZ7Tvx5Dq2+UUTJnWvu6rvP3t3O9LEApE9GQDTF1w52z97GA1F | ||
101 | +zZOFli9d31kWTz9RvdVFGD/tSo7oBmF0Ixa1DVBzJ0RHfxBdiSprhTEUxOipakyA | ||
102 | +vGp4z7h/jnZymQyd/teRCBaho1+V | ||
103 | +-----END CERTIFICATE----- |
1 | +apiVersion: v1 | ||
2 | +kind: Service | ||
3 | +metadata: | ||
4 | + name: character-library-metadata-bastion | ||
5 | + namespace: <replace-your-k8s-namespace> | ||
6 | + labels: | ||
7 | + k8s-app: character-library-metadata-bastion | ||
8 | +spec: | ||
9 | + ports: | ||
10 | + - name: "http" | ||
11 | + port: 80 | ||
12 | + targetPort: 8082 | ||
13 | + selector: | ||
14 | + k8s-app: character-library-metadata-bastion | ||
15 | +--- | ||
16 | +apiVersion: extensions/v1beta1 | ||
17 | +kind: Deployment | ||
18 | +metadata: | ||
19 | + name: character-library-metadata-bastion | ||
20 | + namespace: <replace-your-k8s-namespace> | ||
21 | + labels: | ||
22 | + k8s-app: character-library-metadata-bastion | ||
23 | +spec: | ||
24 | + replicas: 1 | ||
25 | + template: | ||
26 | + metadata: | ||
27 | + labels: | ||
28 | + k8s-app: character-library-metadata-bastion | ||
29 | + spec: | ||
30 | + affinity: | ||
31 | + nodeAffinity: | ||
32 | + preferredDuringSchedulingIgnoredDuringExecution: | ||
33 | + - preference: {} | ||
34 | + weight: 100 | ||
35 | + requiredDuringSchedulingIgnoredDuringExecution: | ||
36 | + nodeSelectorTerms: | ||
37 | + - matchExpressions: | ||
38 | + - key: kubernetes.io/hostname | ||
39 | + operator: In | ||
40 | + values: | ||
41 | + - cn-hangzhou.i-bp1djh1xn7taumbue1ze | ||
42 | + - cn-hangzhou.i-bp1djh1xn7taumbue1zd | ||
43 | + - cn-hangzhou.i-bp1euf5u1ph9kbhtndhb | ||
44 | + - cn-hangzhou.i-bp1hyp5oips9cdwxxgxy | ||
45 | + containers: | ||
46 | + - name: character-library-metadata-bastion | ||
47 | + image: 192.168.0.243:5000/mmm/character-library-metadata-bastion:dev | ||
48 | + imagePullPolicy: Always | ||
49 | + ports: | ||
50 | + - containerPort: 8082 | ||
51 | + volumeMounts: | ||
52 | + - mountPath: /opt/logs | ||
53 | + name: accesslogs | ||
54 | + env: | ||
55 | + - name: LOG_LEVEL | ||
56 | + value: "debug" | ||
57 | + - name: ERROR_BASE_CODE | ||
58 | + value: "1" | ||
59 | + - name: ERROR_BASE_CODE_MULTIPLE | ||
60 | + value: "1000" | ||
61 | + volumes: | ||
62 | + - name: accesslogs | ||
63 | + emptyDir: {} |
deploy/k8s/dev/install.sh
0 → 100644
1 | +#!/bin/bash | ||
2 | +export PATH=/root/local/bin:$PATH | ||
3 | +kubectl -n <replace-your-k8s-namespace> get pods | grep -q character-library-metadata-bastion | ||
4 | +if [ "$?" == "1" ];then | ||
5 | + kubectl create -f /tmp/dev/character-library-metadata-bastion/character-library-metadata-bastion.yaml --record | ||
6 | + kubectl -n <replace-your-k8s-namespace> get svc | grep -q character-library-metadata-bastion | ||
7 | + if [ "$?" == "0" ];then | ||
8 | + echo "character-library-metadata-bastion service install success!" | ||
9 | + else | ||
10 | + echo "character-library-metadata-bastion service install fail!" | ||
11 | + fi | ||
12 | + kubectl -n <replace-your-k8s-namespace> get pods | grep -q character-library-metadata-bastion | ||
13 | + if [ "$?" == "0" ];then | ||
14 | + echo "character-library-metadata-bastion deployment install success!" | ||
15 | + else | ||
16 | + echo "character-library-metadata-bastion deployment install fail!" | ||
17 | + fi | ||
18 | +else | ||
19 | + kubectl delete -f /tmp/dev/character-library-metadata-bastion/character-library-metadata-bastion.yaml | ||
20 | + kubectl -n <replace-your-k8s-namespace> get svc | grep -q character-library-metadata-bastion | ||
21 | + while [ "$?" == "0" ] | ||
22 | + do | ||
23 | + kubectl -n <replace-your-k8s-namespace> get svc | grep -q character-library-metadata-bastion | ||
24 | + done | ||
25 | + kubectl -n <replace-your-k8s-namespace> get pods | grep -q character-library-metadata-bastion | ||
26 | + while [ "$?" == "0" ] | ||
27 | + do | ||
28 | + kubectl -n <replace-your-k8s-namespace> get pods | grep -q character-library-metadata-bastion | ||
29 | + done | ||
30 | + kubectl create -f /tmp/dev/character-library-metadata-bastion/character-library-metadata-bastion.yaml --record | ||
31 | + kubectl -n <replace-your-k8s-namespace> get svc | grep -q character-library-metadata-bastion | ||
32 | + if [ "$?" == "0" ];then | ||
33 | + echo "character-library-metadata-bastion service update success!" | ||
34 | + else | ||
35 | + echo "character-library-metadata-bastion service update fail!" | ||
36 | + fi | ||
37 | + kubectl -n <replace-your-k8s-namespace> get pods | grep -q character-library-metadata-bastion | ||
38 | + if [ "$?" == "0" ];then | ||
39 | + echo "character-library-metadata-bastion deployment update success!" | ||
40 | + else | ||
41 | + echo "character-library-metadata-bastion deployment update fail!" | ||
42 | + fi | ||
43 | +fi |
1 | +version: v1 | ||
2 | +kind: HttpApi | ||
3 | +metadata: | ||
4 | + service: file | ||
5 | + path: /files | ||
6 | + endpoints: | ||
7 | + - method: createFile | ||
8 | + route: | ||
9 | + post: / | ||
10 | + - method: updateFile | ||
11 | + route: | ||
12 | + put: /{fileId} | ||
13 | + - method: getFile | ||
14 | + route: | ||
15 | + get: /{fileId} | ||
16 | + - method: removeFile | ||
17 | + route: | ||
18 | + delete: /{fileId} | ||
19 | + - method: listFile | ||
20 | + route: | ||
21 | + get: / | ||
22 | + params: | ||
23 | + - name: offset | ||
24 | + - name: limit | ||
25 | + - method: loadDataTable | ||
26 | + route: | ||
27 | + post: /files/load-data-table | ||
28 | + - method: editDataTable | ||
29 | + route: | ||
30 | + post: /files/edit-data-table | ||
31 | + - method: flushDataTable | ||
32 | + route: | ||
33 | + post: /files/flush-data-table | ||
34 | + - method: generateMainTable | ||
35 | + route: | ||
36 | + post: /files/generate-main-table |
1 | +version: v1 | ||
2 | +kind: Schema | ||
3 | +metadata: | ||
4 | + name: field | ||
5 | + description: 字段 | ||
6 | + attributes: | ||
7 | + - ref: fieldId | ||
8 | + required: true | ||
9 | + - ref: index | ||
10 | + required: true | ||
11 | + - ref: name | ||
12 | + required: true | ||
13 | + - ref: SQLName | ||
14 | + required: true | ||
15 | + - ref: SQLType | ||
16 | + required: true | ||
17 | + - ref: description | ||
18 | + required: true | ||
19 | + - ref: flag | ||
20 | + required: true |
1 | +version: v1 | ||
2 | +kind: Schema | ||
3 | +metadata: | ||
4 | + name: file | ||
5 | + description: 文件 | ||
6 | + attributes: | ||
7 | + - ref: fileId | ||
8 | + required: true | ||
9 | + - ref: fileType | ||
10 | + required: true | ||
11 | + - ref: fileInfo | ||
12 | + required: true | ||
13 | + - ref: sourceFileId | ||
14 | + required: true | ||
15 | + - ref: operator | ||
16 | + required: true | ||
17 | + - ref: createdAt | ||
18 | + required: true | ||
19 | + - ref: updatedAt | ||
20 | + required: true | ||
21 | + - ref: deletedAt | ||
22 | + required: true | ||
23 | + - ref: version | ||
24 | + required: true |
1 | +version: v1 | ||
2 | +kind: Schema | ||
3 | +metadata: | ||
4 | + name: logEntry | ||
5 | + description: 日志内容 | ||
6 | + attributes: | ||
7 | + - ref: objectName | ||
8 | + required: true | ||
9 | + - ref: objectType | ||
10 | + required: true | ||
11 | + - ref: operationType | ||
12 | + required: true | ||
13 | + - ref: content | ||
14 | + required: true | ||
15 | + - ref: operatorName | ||
16 | + required: true |
1 | +version: v1 | ||
2 | +kind: Schema | ||
3 | +metadata: | ||
4 | + name: table | ||
5 | + description: 表 | ||
6 | + attributes: | ||
7 | + - ref: tableId | ||
8 | + required: true | ||
9 | + - ref: tableType | ||
10 | + required: true | ||
11 | + - ref: name | ||
12 | + required: true | ||
13 | + - ref: SQLName | ||
14 | + required: true | ||
15 | + - ref: parentId | ||
16 | + required: true | ||
17 | + - ref: dataFieldIndex | ||
18 | + required: true | ||
19 | + - ref: PK | ||
20 | + required: true | ||
21 | + - ref: dataFields | ||
22 | + required: true | ||
23 | + - ref: manualFields | ||
24 | + required: true | ||
25 | + - ref: createdAt | ||
26 | + required: true | ||
27 | + - ref: updatedAt | ||
28 | + required: true | ||
29 | + - ref: deletedAt | ||
30 | + required: true | ||
31 | + - ref: version | ||
32 | + required: true |
1 | +version: v1 | ||
2 | +kind: Method | ||
3 | +metadata: | ||
4 | + name: createFile | ||
5 | + type: command | ||
6 | + description: 创建文件服务 | ||
7 | + payload: | ||
8 | + - ref: name | ||
9 | + required: true | ||
10 | + - ref: url | ||
11 | + required: true | ||
12 | + - ref: fileSize | ||
13 | + required: true | ||
14 | + result: | ||
15 | + - name: file | ||
16 | + type: | ||
17 | + schema: file | ||
18 | + required: true |
1 | +version: v1 | ||
2 | +kind: Method | ||
3 | +metadata: | ||
4 | + name: listFile | ||
5 | + type: query | ||
6 | + description: 返回文件服务列表 | ||
7 | + payload: | ||
8 | + - ref: offset | ||
9 | + required: true | ||
10 | + - ref: limit | ||
11 | + required: true | ||
12 | + result: | ||
13 | + - ref: count | ||
14 | + required: true | ||
15 | + - name: files | ||
16 | + type: | ||
17 | + array: file | ||
18 | + required: true |
document/openapi/swagger.yaml
0 → 100644
1 | +swagger: "2.0" | ||
2 | +info: | ||
3 | + title: "" | ||
4 | + description: 字库元数据堡垒 | ||
5 | + contact: | ||
6 | + name: ttt | ||
7 | + email: "" | ||
8 | + home: "" | ||
9 | + version: 0.0.1 | ||
10 | +consumes: | ||
11 | +- application/json | ||
12 | +- application/xml | ||
13 | +produces: | ||
14 | +- application/json | ||
15 | +- application/xml | ||
16 | +paths: | ||
17 | + /files: | ||
18 | + get: | ||
19 | + tags: | ||
20 | + - file | ||
21 | + summary: 返回文件服务列表 | ||
22 | + description: 返回文件服务列表 | ||
23 | + operationId: file#listFile | ||
24 | + parameters: | ||
25 | + - name: offset | ||
26 | + in: query | ||
27 | + description: 查询偏离量 | ||
28 | + required: false | ||
29 | + type: integer | ||
30 | + - name: limit | ||
31 | + in: query | ||
32 | + description: 查询限制 | ||
33 | + required: false | ||
34 | + type: integer | ||
35 | + responses: | ||
36 | + "200": | ||
37 | + description: OK response. | ||
38 | + schema: | ||
39 | + $ref: '#/definitions/FileListFileResponseBody' | ||
40 | + schemes: | ||
41 | + - http | ||
42 | + post: | ||
43 | + tags: | ||
44 | + - file | ||
45 | + summary: 创建文件服务 | ||
46 | + description: 创建文件服务 | ||
47 | + operationId: file#createFile | ||
48 | + parameters: | ||
49 | + - name: CreateFileRequestBody | ||
50 | + in: body | ||
51 | + required: true | ||
52 | + schema: | ||
53 | + $ref: '#/definitions/FileCreateFileRequestBody' | ||
54 | + responses: | ||
55 | + "200": | ||
56 | + description: OK response. | ||
57 | + schema: | ||
58 | + $ref: '#/definitions/FileCreateFileResponseBody' | ||
59 | + schemes: | ||
60 | + - http | ||
61 | + /files/{fileId}: | ||
62 | + get: | ||
63 | + tags: | ||
64 | + - file | ||
65 | + summary: 返回文件服务 | ||
66 | + description: 返回文件服务 | ||
67 | + operationId: file#getFile | ||
68 | + parameters: | ||
69 | + - name: fileId | ||
70 | + in: path | ||
71 | + description: 文件ID | ||
72 | + required: true | ||
73 | + type: integer | ||
74 | + responses: | ||
75 | + "200": | ||
76 | + description: OK response. | ||
77 | + schema: | ||
78 | + $ref: '#/definitions/FileGetFileResponseBody' | ||
79 | + schemes: | ||
80 | + - http | ||
81 | + put: | ||
82 | + tags: | ||
83 | + - file | ||
84 | + summary: 更新文件服务 | ||
85 | + description: 更新文件服务 | ||
86 | + operationId: file#updateFile | ||
87 | + parameters: | ||
88 | + - name: fileId | ||
89 | + in: path | ||
90 | + description: 文件ID | ||
91 | + required: true | ||
92 | + type: integer | ||
93 | + responses: | ||
94 | + "200": | ||
95 | + description: OK response. | ||
96 | + schema: | ||
97 | + $ref: '#/definitions/FileUpdateFileResponseBody' | ||
98 | + schemes: | ||
99 | + - http | ||
100 | + delete: | ||
101 | + tags: | ||
102 | + - file | ||
103 | + summary: 移除文件服务 | ||
104 | + description: 移除文件服务 | ||
105 | + operationId: file#removeFile | ||
106 | + parameters: | ||
107 | + - name: fileId | ||
108 | + in: path | ||
109 | + description: 文件ID | ||
110 | + required: true | ||
111 | + type: integer | ||
112 | + responses: | ||
113 | + "200": | ||
114 | + description: OK response. | ||
115 | + schema: | ||
116 | + $ref: '#/definitions/FileRemoveFileResponseBody' | ||
117 | + schemes: | ||
118 | + - http | ||
119 | + /files/files/edit-data-table: | ||
120 | + post: | ||
121 | + tags: | ||
122 | + - file | ||
123 | + summary: 编辑表格数据 | ||
124 | + description: 编辑表格数据 | ||
125 | + operationId: file#editDataTable | ||
126 | + parameters: | ||
127 | + - name: EditDataTableRequestBody | ||
128 | + in: body | ||
129 | + required: true | ||
130 | + schema: | ||
131 | + $ref: '#/definitions/FileEditDataTableRequestBody' | ||
132 | + responses: | ||
133 | + "200": | ||
134 | + description: OK response. | ||
135 | + schema: | ||
136 | + $ref: '#/definitions/FileEditDataTableResponseBody' | ||
137 | + schemes: | ||
138 | + - http | ||
139 | + /files/files/flush-data-table: | ||
140 | + post: | ||
141 | + tags: | ||
142 | + - file | ||
143 | + summary: 持久化表格数据 | ||
144 | + description: 持久化表格数据 | ||
145 | + operationId: file#flushDataTable | ||
146 | + parameters: | ||
147 | + - name: FlushDataTableRequestBody | ||
148 | + in: body | ||
149 | + required: true | ||
150 | + schema: | ||
151 | + $ref: '#/definitions/FileFlushDataTableRequestBody' | ||
152 | + responses: | ||
153 | + "200": | ||
154 | + description: OK response. | ||
155 | + schema: | ||
156 | + $ref: '#/definitions/FileFlushDataTableResponseBody' | ||
157 | + schemes: | ||
158 | + - http | ||
159 | + /files/files/generate-main-table: | ||
160 | + post: | ||
161 | + tags: | ||
162 | + - file | ||
163 | + summary: 生成主表 | ||
164 | + description: 生成主表 | ||
165 | + operationId: file#generateMainTable | ||
166 | + parameters: | ||
167 | + - name: GenerateMainTableRequestBody | ||
168 | + in: body | ||
169 | + required: true | ||
170 | + schema: | ||
171 | + $ref: '#/definitions/FileGenerateMainTableRequestBody' | ||
172 | + responses: | ||
173 | + "200": | ||
174 | + description: OK response. | ||
175 | + schema: | ||
176 | + $ref: '#/definitions/FileGenerateMainTableResponseBody' | ||
177 | + schemes: | ||
178 | + - http | ||
179 | + /files/files/load-data-table: | ||
180 | + post: | ||
181 | + tags: | ||
182 | + - file | ||
183 | + summary: 加载表格数据 | ||
184 | + description: 加载表格数据 | ||
185 | + operationId: file#loadDataTable | ||
186 | + parameters: | ||
187 | + - name: LoadDataTableRequestBody | ||
188 | + in: body | ||
189 | + required: true | ||
190 | + schema: | ||
191 | + $ref: '#/definitions/FileLoadDataTableRequestBody' | ||
192 | + responses: | ||
193 | + "200": | ||
194 | + description: OK response. | ||
195 | + schema: | ||
196 | + $ref: '#/definitions/FileLoadDataTableResponseBody' | ||
197 | + schemes: | ||
198 | + - http | ||
199 | +definitions: | ||
200 | + FileCreateFileRequestBody: | ||
201 | + title: FileCreateFileRequestBody | ||
202 | + type: object | ||
203 | + properties: | ||
204 | + fileSize: | ||
205 | + type: integer | ||
206 | + description: 文件大小 | ||
207 | + required: | ||
208 | + - fileSize | ||
209 | + name: | ||
210 | + type: string | ||
211 | + description: 名称 | ||
212 | + required: | ||
213 | + - name | ||
214 | + url: | ||
215 | + type: string | ||
216 | + description: 文件地址 | ||
217 | + required: | ||
218 | + - url | ||
219 | + FileCreateFileResponseBody: | ||
220 | + title: 'Mediatype identifier: FileCreateFileResponseBody' | ||
221 | + type: object | ||
222 | + properties: | ||
223 | + file: | ||
224 | + $ref: '#/definitions/fileResponseBody' | ||
225 | + FileEditDataTableRequestBody: | ||
226 | + title: FileEditDataTableRequestBody | ||
227 | + type: object | ||
228 | + properties: | ||
229 | + fileId: | ||
230 | + type: integer | ||
231 | + description: 文件ID | ||
232 | + required: | ||
233 | + - fileId | ||
234 | + FileEditDataTableResponseBody: | ||
235 | + title: 'Mediatype identifier: FileEditDataTableResponseBody' | ||
236 | + type: object | ||
237 | + properties: | ||
238 | + file: | ||
239 | + $ref: '#/definitions/fileResponseBody' | ||
240 | + FileFlushDataTableRequestBody: | ||
241 | + title: FileFlushDataTableRequestBody | ||
242 | + type: object | ||
243 | + properties: | ||
244 | + fileId: | ||
245 | + type: integer | ||
246 | + description: 文件ID | ||
247 | + required: | ||
248 | + - fileId | ||
249 | + FileFlushDataTableResponseBody: | ||
250 | + title: 'Mediatype identifier: FileFlushDataTableResponseBody' | ||
251 | + type: object | ||
252 | + properties: | ||
253 | + file: | ||
254 | + $ref: '#/definitions/fileResponseBody' | ||
255 | + FileGenerateMainTableRequestBody: | ||
256 | + title: FileGenerateMainTableRequestBody | ||
257 | + type: object | ||
258 | + properties: | ||
259 | + fileId: | ||
260 | + type: integer | ||
261 | + description: 文件ID | ||
262 | + required: | ||
263 | + - fileId | ||
264 | + FileGenerateMainTableResponseBody: | ||
265 | + title: 'Mediatype identifier: FileGenerateMainTableResponseBody' | ||
266 | + type: object | ||
267 | + properties: | ||
268 | + file: | ||
269 | + $ref: '#/definitions/fileResponseBody' | ||
270 | + FileGetFileResponseBody: | ||
271 | + title: 'Mediatype identifier: FileGetFileResponseBody' | ||
272 | + type: object | ||
273 | + properties: | ||
274 | + file: | ||
275 | + $ref: '#/definitions/fileResponseBody' | ||
276 | + FileListFileResponseBody: | ||
277 | + title: 'Mediatype identifier: FileListFileResponseBody' | ||
278 | + type: object | ||
279 | + properties: | ||
280 | + count: | ||
281 | + type: integer | ||
282 | + description: 匹配数目 | ||
283 | + required: | ||
284 | + - count | ||
285 | + files: | ||
286 | + type: array | ||
287 | + items: | ||
288 | + $ref: '#/definitions/fileResponseBody' | ||
289 | + required: | ||
290 | + - files | ||
291 | + FileLoadDataTableRequestBody: | ||
292 | + title: FileLoadDataTableRequestBody | ||
293 | + type: object | ||
294 | + properties: | ||
295 | + fileId: | ||
296 | + type: integer | ||
297 | + description: 文件ID | ||
298 | + required: | ||
299 | + - fileId | ||
300 | + FileLoadDataTableResponseBody: | ||
301 | + title: 'Mediatype identifier: FileLoadDataTableResponseBody' | ||
302 | + type: object | ||
303 | + properties: | ||
304 | + file: | ||
305 | + $ref: '#/definitions/fileResponseBody' | ||
306 | + FileRemoveFileResponseBody: | ||
307 | + title: 'Mediatype identifier: FileRemoveFileResponseBody' | ||
308 | + type: object | ||
309 | + properties: | ||
310 | + file: | ||
311 | + $ref: '#/definitions/fileResponseBody' | ||
312 | + FileUpdateFileResponseBody: | ||
313 | + title: 'Mediatype identifier: FileUpdateFileResponseBody' | ||
314 | + type: object | ||
315 | + properties: | ||
316 | + file: | ||
317 | + $ref: '#/definitions/fileResponseBody' | ||
318 | + fileResponseBody: | ||
319 | + title: fileResponseBody | ||
320 | + type: object | ||
321 | + properties: | ||
322 | + createdAt: | ||
323 | + type: string | ||
324 | + description: 创建时间 | ||
325 | + required: | ||
326 | + - createdAt | ||
327 | + deletedAt: | ||
328 | + type: string | ||
329 | + description: 删除时间 | ||
330 | + required: | ||
331 | + - deletedAt | ||
332 | + fileId: | ||
333 | + type: integer | ||
334 | + description: 文件ID | ||
335 | + required: | ||
336 | + - fileId | ||
337 | + fileInfo: | ||
338 | + type: string | ||
339 | + description: 文件信息 | ||
340 | + required: | ||
341 | + - fileInfo | ||
342 | + fileType: | ||
343 | + type: string | ||
344 | + description: 文件类型 | ||
345 | + required: | ||
346 | + - fileType | ||
347 | + operator: | ||
348 | + type: string | ||
349 | + description: 操作人 | ||
350 | + required: | ||
351 | + - operator | ||
352 | + sourceFileId: | ||
353 | + type: string | ||
354 | + description: 源文件Id(FileType为TemporaryFile或VerifiedFile时有值) | ||
355 | + required: | ||
356 | + - sourceFileId | ||
357 | + updatedAt: | ||
358 | + type: string | ||
359 | + description: 更新时间 | ||
360 | + required: | ||
361 | + - updatedAt | ||
362 | + version: | ||
363 | + type: integer | ||
364 | + description: 版本 | ||
365 | + required: | ||
366 | + - version | ||
367 | + description: 文件 |
go.mod
0 → 100644
1 | +module gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion | ||
2 | + | ||
3 | +go 1.16 | ||
4 | + | ||
5 | +require ( | ||
6 | + github.com/Shopify/sarama v1.25.0 | ||
7 | + github.com/ajg/form v1.5.1 // indirect | ||
8 | + github.com/beego/beego/v2 v2.0.1 | ||
9 | + github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect | ||
10 | + github.com/fatih/structs v1.1.0 // indirect | ||
11 | + github.com/gavv/httpexpect v2.0.0+incompatible | ||
12 | + github.com/go-pg/pg/v10 v10.9.0 | ||
13 | + github.com/go-redis/redis v6.15.9+incompatible // indirect | ||
14 | + github.com/go-redis/redis/v7 v7.4.1 // indirect | ||
15 | + github.com/golang/snappy v0.0.3 // indirect | ||
16 | + github.com/google/go-cmp v0.5.6 // indirect | ||
17 | + github.com/google/go-querystring v1.1.0 // indirect | ||
18 | + github.com/google/uuid v1.3.0 // indirect | ||
19 | + github.com/imkira/go-interpol v1.1.0 // indirect | ||
20 | + github.com/linmadan/egglib-go v0.0.0-20210313060205-8b5e456b11f7 | ||
21 | + github.com/moul/http2curl v1.0.0 // indirect | ||
22 | + github.com/onsi/ginkgo v1.15.2 | ||
23 | + github.com/onsi/gomega v1.11.0 | ||
24 | + github.com/sergi/go-diff v1.2.0 // indirect | ||
25 | + github.com/smartystreets/goconvey v1.7.2 // indirect | ||
26 | + github.com/valyala/fasthttp v1.38.0 // indirect | ||
27 | + github.com/xeipuuv/gojsonschema v1.2.0 // indirect | ||
28 | + github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect | ||
29 | + github.com/yudai/gojsondiff v1.0.0 // indirect | ||
30 | + github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect | ||
31 | + github.com/yudai/pp v2.0.1+incompatible // indirect | ||
32 | +) | ||
33 | + | ||
34 | +replace github.com/linmadan/egglib-go v0.0.0-20210313060205-8b5e456b11f7 => github.com/tiptok/egglib-go v0.0.0-20220421085958-9682d0ac42c1 |
main.go
0 → 100644
1 | +package main | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/beego/beego/v2/server/web" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/constant" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/redis" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/log" | ||
9 | + "time" | ||
10 | + | ||
11 | + _ "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/constant" | ||
12 | + _ "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/pg" | ||
13 | + _ "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/redis" | ||
14 | + _ "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/log" | ||
15 | + _ "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/port/beego" | ||
16 | +) | ||
17 | + | ||
18 | +func main() { | ||
19 | + defer func() { | ||
20 | + if r := recover(); r != nil { | ||
21 | + log.Logger.Error(fmt.Sprintf("%v", r)) | ||
22 | + } | ||
23 | + }() | ||
24 | + | ||
25 | + log.InitLogHook(constant.ENABLE_KAFKA_LOG, true) | ||
26 | + redis.InitRedis() | ||
27 | + | ||
28 | + time.Sleep(time.Second) | ||
29 | + log.Logger.Info("server start!") | ||
30 | + web.Run() | ||
31 | + log.Logger.Info("server stop!") | ||
32 | +} |
pkg/application/factory/domain_service.go
0 → 100644
1 | +package factory |
pkg/application/factory/repository.go
0 → 100644
1 | +package factory | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/transaction/pg" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/repository" | ||
7 | +) | ||
8 | + | ||
9 | +func CreateTableRepository(options map[string]interface{}) (domain.TableRepository, error) { | ||
10 | + var transactionContext *pg.TransactionContext | ||
11 | + if value, ok := options["transactionContext"]; ok { | ||
12 | + transactionContext = value.(*pg.TransactionContext) | ||
13 | + } | ||
14 | + return repository.NewTableRepository(transactionContext) | ||
15 | +} | ||
16 | + | ||
17 | +func CreateLogRepository(options map[string]interface{}) (domain.LogRepository, error) { | ||
18 | + var transactionContext *pg.TransactionContext | ||
19 | + if value, ok := options["transactionContext"]; ok { | ||
20 | + transactionContext = value.(*pg.TransactionContext) | ||
21 | + } | ||
22 | + return repository.NewLogRepository(transactionContext) | ||
23 | +} | ||
24 | + | ||
25 | +func CreateFileRepository(options map[string]interface{}) (domain.FileRepository, error) { | ||
26 | + var transactionContext *pg.TransactionContext | ||
27 | + if value, ok := options["transactionContext"]; ok { | ||
28 | + transactionContext = value.(*pg.TransactionContext) | ||
29 | + } | ||
30 | + return repository.NewFileRepository(transactionContext) | ||
31 | +} |
pkg/application/factory/transaction.go
0 → 100644
1 | +package factory | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | + pG "github.com/linmadan/egglib-go/transaction/pg" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/pg" | ||
7 | +) | ||
8 | + | ||
9 | +func CreateTransactionContext(options map[string]interface{}) (application.TransactionContext, error) { | ||
10 | + return pG.NewPGTransactionContext(pg.DB), nil | ||
11 | +} |
pkg/application/file/command/create_file.go
0 → 100644
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type CreateFileCommand struct { | ||
12 | + // 名称 | ||
13 | + Name string `cname:"名称" json:"name" valid:"Required"` | ||
14 | + // 文件地址 | ||
15 | + Url string `cname:"文件地址" json:"url" valid:"Required"` | ||
16 | + // 文件大小 | ||
17 | + FileSize int `cname:"文件大小" json:"fileSize" valid:"Required"` | ||
18 | +} | ||
19 | + | ||
20 | +func (createFileCommand *CreateFileCommand) Valid(validation *validation.Validation) { | ||
21 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
22 | +} | ||
23 | + | ||
24 | +func (createFileCommand *CreateFileCommand) ValidateCommand() error { | ||
25 | + valid := validation.Validation{} | ||
26 | + b, err := valid.Valid(createFileCommand) | ||
27 | + if err != nil { | ||
28 | + return err | ||
29 | + } | ||
30 | + if !b { | ||
31 | + elem := reflect.TypeOf(createFileCommand).Elem() | ||
32 | + for _, validErr := range valid.Errors { | ||
33 | + field, isExist := elem.FieldByName(validErr.Field) | ||
34 | + if isExist { | ||
35 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
36 | + } else { | ||
37 | + return fmt.Errorf(validErr.Message) | ||
38 | + } | ||
39 | + } | ||
40 | + } | ||
41 | + return nil | ||
42 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type EditDataTableCommand struct { | ||
12 | + // 文件ID | ||
13 | + FileId int `cname:"文件ID" json:"fileId" valid:"Required"` | ||
14 | +} | ||
15 | + | ||
16 | +func (editDataTableCommand *EditDataTableCommand) Valid(validation *validation.Validation) { | ||
17 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
18 | +} | ||
19 | + | ||
20 | +func (editDataTableCommand *EditDataTableCommand) ValidateCommand() error { | ||
21 | + valid := validation.Validation{} | ||
22 | + b, err := valid.Valid(editDataTableCommand) | ||
23 | + if err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + if !b { | ||
27 | + elem := reflect.TypeOf(editDataTableCommand).Elem() | ||
28 | + for _, validErr := range valid.Errors { | ||
29 | + field, isExist := elem.FieldByName(validErr.Field) | ||
30 | + if isExist { | ||
31 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
32 | + } else { | ||
33 | + return fmt.Errorf(validErr.Message) | ||
34 | + } | ||
35 | + } | ||
36 | + } | ||
37 | + return nil | ||
38 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type FlushDataTableCommand struct { | ||
12 | + // 文件ID | ||
13 | + FileId int `cname:"文件ID" json:"fileId" valid:"Required"` | ||
14 | +} | ||
15 | + | ||
16 | +func (flushDataTableCommand *FlushDataTableCommand) Valid(validation *validation.Validation) { | ||
17 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
18 | +} | ||
19 | + | ||
20 | +func (flushDataTableCommand *FlushDataTableCommand) ValidateCommand() error { | ||
21 | + valid := validation.Validation{} | ||
22 | + b, err := valid.Valid(flushDataTableCommand) | ||
23 | + if err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + if !b { | ||
27 | + elem := reflect.TypeOf(flushDataTableCommand).Elem() | ||
28 | + for _, validErr := range valid.Errors { | ||
29 | + field, isExist := elem.FieldByName(validErr.Field) | ||
30 | + if isExist { | ||
31 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
32 | + } else { | ||
33 | + return fmt.Errorf(validErr.Message) | ||
34 | + } | ||
35 | + } | ||
36 | + } | ||
37 | + return nil | ||
38 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type GenerateMainTableCommand struct { | ||
12 | + // 文件ID | ||
13 | + FileId int `cname:"文件ID" json:"fileId" valid:"Required"` | ||
14 | +} | ||
15 | + | ||
16 | +func (generateMainTableCommand *GenerateMainTableCommand) Valid(validation *validation.Validation) { | ||
17 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
18 | +} | ||
19 | + | ||
20 | +func (generateMainTableCommand *GenerateMainTableCommand) ValidateCommand() error { | ||
21 | + valid := validation.Validation{} | ||
22 | + b, err := valid.Valid(generateMainTableCommand) | ||
23 | + if err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + if !b { | ||
27 | + elem := reflect.TypeOf(generateMainTableCommand).Elem() | ||
28 | + for _, validErr := range valid.Errors { | ||
29 | + field, isExist := elem.FieldByName(validErr.Field) | ||
30 | + if isExist { | ||
31 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
32 | + } else { | ||
33 | + return fmt.Errorf(validErr.Message) | ||
34 | + } | ||
35 | + } | ||
36 | + } | ||
37 | + return nil | ||
38 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type LoadDataTableCommand struct { | ||
12 | + // 文件ID | ||
13 | + FileId int `cname:"文件ID" json:"fileId" valid:"Required"` | ||
14 | +} | ||
15 | + | ||
16 | +func (loadDataTableCommand *LoadDataTableCommand) Valid(validation *validation.Validation) { | ||
17 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
18 | +} | ||
19 | + | ||
20 | +func (loadDataTableCommand *LoadDataTableCommand) ValidateCommand() error { | ||
21 | + valid := validation.Validation{} | ||
22 | + b, err := valid.Valid(loadDataTableCommand) | ||
23 | + if err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + if !b { | ||
27 | + elem := reflect.TypeOf(loadDataTableCommand).Elem() | ||
28 | + for _, validErr := range valid.Errors { | ||
29 | + field, isExist := elem.FieldByName(validErr.Field) | ||
30 | + if isExist { | ||
31 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
32 | + } else { | ||
33 | + return fmt.Errorf(validErr.Message) | ||
34 | + } | ||
35 | + } | ||
36 | + } | ||
37 | + return nil | ||
38 | +} |
pkg/application/file/command/remove_file.go
0 → 100644
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type RemoveFileCommand struct { | ||
12 | + // 文件ID | ||
13 | + FileId int `cname:"文件ID" json:"fileId" valid:"Required"` | ||
14 | +} | ||
15 | + | ||
16 | +func (removeFileCommand *RemoveFileCommand) Valid(validation *validation.Validation) { | ||
17 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
18 | +} | ||
19 | + | ||
20 | +func (removeFileCommand *RemoveFileCommand) ValidateCommand() error { | ||
21 | + valid := validation.Validation{} | ||
22 | + b, err := valid.Valid(removeFileCommand) | ||
23 | + if err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + if !b { | ||
27 | + elem := reflect.TypeOf(removeFileCommand).Elem() | ||
28 | + for _, validErr := range valid.Errors { | ||
29 | + field, isExist := elem.FieldByName(validErr.Field) | ||
30 | + if isExist { | ||
31 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
32 | + } else { | ||
33 | + return fmt.Errorf(validErr.Message) | ||
34 | + } | ||
35 | + } | ||
36 | + } | ||
37 | + return nil | ||
38 | +} |
pkg/application/file/command/update_file.go
0 → 100644
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type UpdateFileCommand struct { | ||
12 | + // 文件ID | ||
13 | + FileId int `cname:"文件ID" json:"fileId" valid:"Required"` | ||
14 | +} | ||
15 | + | ||
16 | +func (updateFileCommand *UpdateFileCommand) Valid(validation *validation.Validation) { | ||
17 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
18 | +} | ||
19 | + | ||
20 | +func (updateFileCommand *UpdateFileCommand) ValidateCommand() error { | ||
21 | + valid := validation.Validation{} | ||
22 | + b, err := valid.Valid(updateFileCommand) | ||
23 | + if err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + if !b { | ||
27 | + elem := reflect.TypeOf(updateFileCommand).Elem() | ||
28 | + for _, validErr := range valid.Errors { | ||
29 | + field, isExist := elem.FieldByName(validErr.Field) | ||
30 | + if isExist { | ||
31 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
32 | + } else { | ||
33 | + return fmt.Errorf(validErr.Message) | ||
34 | + } | ||
35 | + } | ||
36 | + } | ||
37 | + return nil | ||
38 | +} |
pkg/application/file/query/get_file.go
0 → 100644
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type GetFileQuery struct { | ||
12 | + // 文件ID | ||
13 | + FileId int `cname:"文件ID" json:"fileId" valid:"Required"` | ||
14 | +} | ||
15 | + | ||
16 | +func (getFileQuery *GetFileQuery) Valid(validation *validation.Validation) { | ||
17 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
18 | +} | ||
19 | + | ||
20 | +func (getFileQuery *GetFileQuery) ValidateQuery() error { | ||
21 | + valid := validation.Validation{} | ||
22 | + b, err := valid.Valid(getFileQuery) | ||
23 | + if err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + if !b { | ||
27 | + elem := reflect.TypeOf(getFileQuery).Elem() | ||
28 | + for _, validErr := range valid.Errors { | ||
29 | + field, isExist := elem.FieldByName(validErr.Field) | ||
30 | + if isExist { | ||
31 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
32 | + } else { | ||
33 | + return fmt.Errorf(validErr.Message) | ||
34 | + } | ||
35 | + } | ||
36 | + } | ||
37 | + return nil | ||
38 | +} |
pkg/application/file/query/list_file.go
0 → 100644
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type ListFileQuery struct { | ||
12 | + // 查询偏离量 | ||
13 | + Offset int `cname:"查询偏离量" json:"offset" valid:"Required"` | ||
14 | + // 查询限制 | ||
15 | + Limit int `cname:"查询限制" json:"limit" valid:"Required"` | ||
16 | +} | ||
17 | + | ||
18 | +func (listFileQuery *ListFileQuery) Valid(validation *validation.Validation) { | ||
19 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
20 | +} | ||
21 | + | ||
22 | +func (listFileQuery *ListFileQuery) ValidateQuery() error { | ||
23 | + valid := validation.Validation{} | ||
24 | + b, err := valid.Valid(listFileQuery) | ||
25 | + if err != nil { | ||
26 | + return err | ||
27 | + } | ||
28 | + if !b { | ||
29 | + elem := reflect.TypeOf(listFileQuery).Elem() | ||
30 | + for _, validErr := range valid.Errors { | ||
31 | + field, isExist := elem.FieldByName(validErr.Field) | ||
32 | + if isExist { | ||
33 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
34 | + } else { | ||
35 | + return fmt.Errorf(validErr.Message) | ||
36 | + } | ||
37 | + } | ||
38 | + } | ||
39 | + return nil | ||
40 | +} |
pkg/application/file/service/file.go
0 → 100644
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/linmadan/egglib-go/core/application" | ||
6 | + "github.com/linmadan/egglib-go/utils/tool_funs" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/factory" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/file/command" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/file/query" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain" | ||
11 | +) | ||
12 | + | ||
13 | +// 文件服务 | ||
14 | +type FileService struct { | ||
15 | +} | ||
16 | + | ||
17 | +// 创建文件服务 | ||
18 | +func (fileService *FileService) CreateFile(createFileCommand *command.CreateFileCommand) (interface{}, error) { | ||
19 | + if err := createFileCommand.ValidateCommand(); err != nil { | ||
20 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
21 | + } | ||
22 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
23 | + if err != nil { | ||
24 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
25 | + } | ||
26 | + if err := transactionContext.StartTransaction(); err != nil { | ||
27 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
28 | + } | ||
29 | + defer func() { | ||
30 | + transactionContext.RollbackTransaction() | ||
31 | + }() | ||
32 | + newFile := &domain.File{ | ||
33 | + //Name: createFileCommand.Name, | ||
34 | + //Url: createFileCommand.Url, | ||
35 | + //FileSize: createFileCommand.FileSize, | ||
36 | + } | ||
37 | + var fileRepository domain.FileRepository | ||
38 | + if value, err := factory.CreateFileRepository(map[string]interface{}{ | ||
39 | + "transactionContext": transactionContext, | ||
40 | + }); err != nil { | ||
41 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
42 | + } else { | ||
43 | + fileRepository = value | ||
44 | + } | ||
45 | + if file, err := fileRepository.Save(newFile); err != nil { | ||
46 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
47 | + } else { | ||
48 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
49 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
50 | + } | ||
51 | + return file, nil | ||
52 | + } | ||
53 | +} | ||
54 | + | ||
55 | +// 编辑表格数据 | ||
56 | +func (fileService *FileService) EditDataTable(editDataTableCommand *command.EditDataTableCommand) (interface{}, error) { | ||
57 | + if err := editDataTableCommand.ValidateCommand(); err != nil { | ||
58 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
59 | + } | ||
60 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
61 | + if err != nil { | ||
62 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
63 | + } | ||
64 | + if err := transactionContext.StartTransaction(); err != nil { | ||
65 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
66 | + } | ||
67 | + defer func() { | ||
68 | + transactionContext.RollbackTransaction() | ||
69 | + }() | ||
70 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
71 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
72 | + } | ||
73 | + return nil, nil | ||
74 | +} | ||
75 | + | ||
76 | +// 持久化表格数据 | ||
77 | +func (fileService *FileService) FlushDataTable(flushDataTableCommand *command.FlushDataTableCommand) (interface{}, error) { | ||
78 | + if err := flushDataTableCommand.ValidateCommand(); err != nil { | ||
79 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
80 | + } | ||
81 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
82 | + if err != nil { | ||
83 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
84 | + } | ||
85 | + if err := transactionContext.StartTransaction(); err != nil { | ||
86 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
87 | + } | ||
88 | + defer func() { | ||
89 | + transactionContext.RollbackTransaction() | ||
90 | + }() | ||
91 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
92 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
93 | + } | ||
94 | + return nil, nil | ||
95 | +} | ||
96 | + | ||
97 | +// 生成主表 | ||
98 | +func (fileService *FileService) GenerateMainTable(generateMainTableCommand *command.GenerateMainTableCommand) (interface{}, error) { | ||
99 | + if err := generateMainTableCommand.ValidateCommand(); err != nil { | ||
100 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
101 | + } | ||
102 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
103 | + if err != nil { | ||
104 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
105 | + } | ||
106 | + if err := transactionContext.StartTransaction(); err != nil { | ||
107 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
108 | + } | ||
109 | + defer func() { | ||
110 | + transactionContext.RollbackTransaction() | ||
111 | + }() | ||
112 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
113 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
114 | + } | ||
115 | + return nil, nil | ||
116 | +} | ||
117 | + | ||
118 | +// 返回文件服务 | ||
119 | +func (fileService *FileService) GetFile(getFileQuery *query.GetFileQuery) (interface{}, error) { | ||
120 | + if err := getFileQuery.ValidateQuery(); err != nil { | ||
121 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
122 | + } | ||
123 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
124 | + if err != nil { | ||
125 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
126 | + } | ||
127 | + if err := transactionContext.StartTransaction(); err != nil { | ||
128 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
129 | + } | ||
130 | + defer func() { | ||
131 | + transactionContext.RollbackTransaction() | ||
132 | + }() | ||
133 | + var fileRepository domain.FileRepository | ||
134 | + if value, err := factory.CreateFileRepository(map[string]interface{}{ | ||
135 | + "transactionContext": transactionContext, | ||
136 | + }); err != nil { | ||
137 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
138 | + } else { | ||
139 | + fileRepository = value | ||
140 | + } | ||
141 | + file, err := fileRepository.FindOne(map[string]interface{}{"fileId": getFileQuery.FileId}) | ||
142 | + if err != nil { | ||
143 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
144 | + } | ||
145 | + if file == nil { | ||
146 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getFileQuery.FileId))) | ||
147 | + } else { | ||
148 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
149 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
150 | + } | ||
151 | + return file, nil | ||
152 | + } | ||
153 | +} | ||
154 | + | ||
155 | +// 返回文件服务列表 | ||
156 | +func (fileService *FileService) ListFile(listFileQuery *query.ListFileQuery) (interface{}, error) { | ||
157 | + if err := listFileQuery.ValidateQuery(); err != nil { | ||
158 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
159 | + } | ||
160 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
161 | + if err != nil { | ||
162 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
163 | + } | ||
164 | + if err := transactionContext.StartTransaction(); err != nil { | ||
165 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
166 | + } | ||
167 | + defer func() { | ||
168 | + transactionContext.RollbackTransaction() | ||
169 | + }() | ||
170 | + var fileRepository domain.FileRepository | ||
171 | + if value, err := factory.CreateFileRepository(map[string]interface{}{ | ||
172 | + "transactionContext": transactionContext, | ||
173 | + }); err != nil { | ||
174 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
175 | + } else { | ||
176 | + fileRepository = value | ||
177 | + } | ||
178 | + if count, files, err := fileRepository.Find(tool_funs.SimpleStructToMap(listFileQuery)); err != nil { | ||
179 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
180 | + } else { | ||
181 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
182 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
183 | + } | ||
184 | + return map[string]interface{}{ | ||
185 | + "count": count, | ||
186 | + "files": files, | ||
187 | + }, nil | ||
188 | + } | ||
189 | +} | ||
190 | + | ||
191 | +// 加载表格数据 | ||
192 | +func (fileService *FileService) LoadDataTable(loadDataTableCommand *command.LoadDataTableCommand) (interface{}, error) { | ||
193 | + if err := loadDataTableCommand.ValidateCommand(); err != nil { | ||
194 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
195 | + } | ||
196 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
197 | + if err != nil { | ||
198 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
199 | + } | ||
200 | + if err := transactionContext.StartTransaction(); err != nil { | ||
201 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
202 | + } | ||
203 | + defer func() { | ||
204 | + transactionContext.RollbackTransaction() | ||
205 | + }() | ||
206 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
207 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
208 | + } | ||
209 | + return nil, nil | ||
210 | +} | ||
211 | + | ||
212 | +// 移除文件服务 | ||
213 | +func (fileService *FileService) RemoveFile(removeFileCommand *command.RemoveFileCommand) (interface{}, error) { | ||
214 | + if err := removeFileCommand.ValidateCommand(); err != nil { | ||
215 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
216 | + } | ||
217 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
218 | + if err != nil { | ||
219 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
220 | + } | ||
221 | + if err := transactionContext.StartTransaction(); err != nil { | ||
222 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
223 | + } | ||
224 | + defer func() { | ||
225 | + transactionContext.RollbackTransaction() | ||
226 | + }() | ||
227 | + var fileRepository domain.FileRepository | ||
228 | + if value, err := factory.CreateFileRepository(map[string]interface{}{ | ||
229 | + "transactionContext": transactionContext, | ||
230 | + }); err != nil { | ||
231 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
232 | + } else { | ||
233 | + fileRepository = value | ||
234 | + } | ||
235 | + file, err := fileRepository.FindOne(map[string]interface{}{"fileId": removeFileCommand.FileId}) | ||
236 | + if err != nil { | ||
237 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
238 | + } | ||
239 | + if file == nil { | ||
240 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeFileCommand.FileId))) | ||
241 | + } | ||
242 | + if file, err := fileRepository.Remove(file); err != nil { | ||
243 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
244 | + } else { | ||
245 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
246 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
247 | + } | ||
248 | + return file, nil | ||
249 | + } | ||
250 | +} | ||
251 | + | ||
252 | +// 更新文件服务 | ||
253 | +func (fileService *FileService) UpdateFile(updateFileCommand *command.UpdateFileCommand) (interface{}, error) { | ||
254 | + if err := updateFileCommand.ValidateCommand(); err != nil { | ||
255 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
256 | + } | ||
257 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
258 | + if err != nil { | ||
259 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
260 | + } | ||
261 | + if err := transactionContext.StartTransaction(); err != nil { | ||
262 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
263 | + } | ||
264 | + defer func() { | ||
265 | + transactionContext.RollbackTransaction() | ||
266 | + }() | ||
267 | + var fileRepository domain.FileRepository | ||
268 | + if value, err := factory.CreateFileRepository(map[string]interface{}{ | ||
269 | + "transactionContext": transactionContext, | ||
270 | + }); err != nil { | ||
271 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
272 | + } else { | ||
273 | + fileRepository = value | ||
274 | + } | ||
275 | + file, err := fileRepository.FindOne(map[string]interface{}{"fileId": updateFileCommand.FileId}) | ||
276 | + if err != nil { | ||
277 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
278 | + } | ||
279 | + if file == nil { | ||
280 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateFileCommand.FileId))) | ||
281 | + } | ||
282 | + if err := file.Update(tool_funs.SimpleStructToMap(updateFileCommand)); err != nil { | ||
283 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
284 | + } | ||
285 | + if file, err := fileRepository.Save(file); err != nil { | ||
286 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
287 | + } else { | ||
288 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
289 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
290 | + } | ||
291 | + return file, nil | ||
292 | + } | ||
293 | +} | ||
294 | + | ||
295 | +func NewFileService(options map[string]interface{}) *FileService { | ||
296 | + newFileService := &FileService{} | ||
297 | + return newFileService | ||
298 | +} |
pkg/application/init.go
0 → 100644
pkg/constant/common.go
0 → 100644
1 | +package constant | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | +) | ||
6 | + | ||
7 | +var SERVICE_NAME = "character-library-metadata-bastion" | ||
8 | +var SERVICE_ENV = "dev" | ||
9 | +var HTTP_PORT int = 8081 | ||
10 | +var CACHE_PREFIX = "character-library-metadata-bastion-dev" | ||
11 | +var LOG_LEVEL = "debug" | ||
12 | +var LOG_FILE = "app.log" | ||
13 | +var PPROF_ON = true | ||
14 | + | ||
15 | +//天联共创基础模块 | ||
16 | +//var ALLIED_CREATION_BASIC_HOST = "http://localhost:8080" //"http://allied-creation-basic-dev.fjmaimaimai.com" | ||
17 | + | ||
18 | +//天联共创用户模块 | ||
19 | +var ALLIED_CREATION_USER_HOST = "http://localhost:8081" //"http://allied-creation-user-dev.fjmaimaimai.com" | ||
20 | + | ||
21 | +//天联共创业务模块 | ||
22 | +//var ALLIED_CREATION_COOPERATION_HOST = "http://localhost:8082" // "http://allied-creation-cooperation-dev.fjmaimaimai.com" | ||
23 | + | ||
24 | +var MMM_BYTE_BANK_HOST = "http://220.250.41.79:8301" | ||
25 | + | ||
26 | +//var CUSTOMER_ACCOUNT = []int64{3129687560814592, 3129687690100739, 3492238958608384} | ||
27 | + | ||
28 | +//const CUSTOMER_ACCOUNT_DELIMITER = "," | ||
29 | + | ||
30 | +/***** 1.数据传输 *****/ | ||
31 | +//const HeaderCompanyId = "companyId" | ||
32 | +//const HeaderUserId = "userId" | ||
33 | +//const HeaderOrgId = "orgId" | ||
34 | +//const HeaderOrgIds = "orgIds" | ||
35 | + | ||
36 | +func init() { | ||
37 | + LOG_LEVEL = Configurator.DefaultString("LOG_LEVEL", LOG_LEVEL) | ||
38 | + //ALLIED_CREATION_BASIC_HOST = Configurator.DefaultString("ALLIED_CREATION_BASIC_HOST", ALLIED_CREATION_BASIC_HOST) | ||
39 | + ALLIED_CREATION_USER_HOST = Configurator.DefaultString("ALLIED_CREATION_USER_HOST", ALLIED_CREATION_USER_HOST) | ||
40 | + //ALLIED_CREATION_COOPERATION_HOST = Configurator.DefaultString("ALLIED_CREATION_COOPERATION_HOST", ALLIED_CREATION_COOPERATION_HOST) | ||
41 | + MMM_BYTE_BANK_HOST = Configurator.DefaultString("MMM_BYTE_BANK_HOST", MMM_BYTE_BANK_HOST) | ||
42 | + SERVICE_ENV = Configurator.DefaultString("SERVICE_ENV", SERVICE_ENV) | ||
43 | + HTTP_PORT = Configurator.DefaultInt("HTTP_PORT", HTTP_PORT) | ||
44 | + SERVICE_NAME = fmt.Sprintf("%v-%v", SERVICE_NAME, SERVICE_ENV) | ||
45 | + PPROF_ON = Configurator.DefaultBool("PPROF_ON", PPROF_ON) | ||
46 | + CACHE_PREFIX = SERVICE_NAME | ||
47 | +} |
pkg/constant/constant_conf.go
0 → 100644
pkg/constant/constant_env.go
0 → 100644
pkg/constant/kafka.go
0 → 100644
1 | +package constant | ||
2 | + | ||
3 | +var ( | ||
4 | + // kafka 地址 | ||
5 | + KAFKA_HOST = "192.168.0.250:9092,192.168.0.251:9092,192.168.0.252:9092" //"106.75.231.90:9092" | ||
6 | + // kafka topic log stash | ||
7 | + TOPIC_LOG_STASH = "go_stash_dev" //"pushMessage" | ||
8 | + // kafka topic up_block_chain | ||
9 | + TOPIC_UP_BLOCK_CHAIN = "allied_creation_message" | ||
10 | + // 是否启用日志收集 (本地不启用) | ||
11 | + ENABLE_KAFKA_LOG = false | ||
12 | +) | ||
13 | + | ||
14 | +func init() { | ||
15 | + KAFKA_HOST = Configurator.DefaultString("KAFKA_HOST", KAFKA_HOST) | ||
16 | + ENABLE_KAFKA_LOG = Configurator.DefaultBool("ENABLE_KAFKA_LOG", ENABLE_KAFKA_LOG) | ||
17 | +} |
pkg/constant/postgresql.go
0 → 100644
1 | +package constant | ||
2 | + | ||
3 | +var POSTGRESQL_DB_NAME = "terms" | ||
4 | +var POSTGRESQL_USER = "postgres" | ||
5 | +var POSTGRESQL_PASSWORD = "123456" | ||
6 | +var POSTGRESQL_HOST = "127.0.0.1" | ||
7 | +var POSTGRESQL_PORT = "5432" | ||
8 | +var DISABLE_CREATE_TABLE = false | ||
9 | +var DISABLE_SQL_GENERATE_PRINT = false | ||
10 | +var DISABLE_SQL_GENERATE_COMMENT = true | ||
11 | + | ||
12 | +func init() { | ||
13 | + POSTGRESQL_HOST = Configurator.DefaultString("POSTGRESQL_HOST", POSTGRESQL_HOST) | ||
14 | + POSTGRESQL_PORT = Configurator.DefaultString("POSTGRESQL_PORT", POSTGRESQL_PORT) | ||
15 | + POSTGRESQL_DB_NAME = Configurator.DefaultString("POSTGRESQL_DB_NAME", POSTGRESQL_DB_NAME) | ||
16 | + POSTGRESQL_USER = Configurator.DefaultString("POSTGRESQL_USER", POSTGRESQL_USER) | ||
17 | + POSTGRESQL_PASSWORD = Configurator.DefaultString("POSTGRESQL_PASSWORD", POSTGRESQL_PASSWORD) | ||
18 | + | ||
19 | + DISABLE_CREATE_TABLE = Configurator.DefaultBool("DISABLE_CREATE_TABLE", DISABLE_CREATE_TABLE) | ||
20 | + DISABLE_SQL_GENERATE_PRINT = Configurator.DefaultBool("DISABLE_SQL_GENERATE_PRINT", DISABLE_SQL_GENERATE_PRINT) | ||
21 | +} |
pkg/constant/redis.go
0 → 100644
1 | +package constant | ||
2 | + | ||
3 | +var ( | ||
4 | + REDIS_HOST = "127.0.0.1" | ||
5 | + REDIS_PORT = "6379" | ||
6 | + REDIS_AUTH = "" | ||
7 | + REDIS_ADDRESS = "" | ||
8 | + | ||
9 | + // 是否关闭仓储层缓存 | ||
10 | + ENABLE_REPOSITORY_CACHE = true | ||
11 | + // 缓存过期时间 单位秒 | ||
12 | + REPOSITORY_CACHE_EXPIRE = 30 * 60 | ||
13 | + // redis 考勤机打卡消息队列 | ||
14 | + REDIS_ZKTECO_KEY = "allied-creation-zkteco" | ||
15 | + // redis 车间数据消息队列 | ||
16 | + REDIS_WORKSHOP_KEY = "allied-creation-workshop" | ||
17 | +) | ||
18 | + | ||
19 | +func init() { | ||
20 | + REDIS_HOST = Configurator.DefaultString("REDIS_HOST", REDIS_HOST) | ||
21 | + REDIS_PORT = Configurator.DefaultString("REDIS_PORT", REDIS_PORT) | ||
22 | + REDIS_AUTH = Configurator.DefaultString("REDIS_AUTH", REDIS_AUTH) | ||
23 | + ENABLE_REPOSITORY_CACHE = Configurator.DefaultBool("ENABLE_REPOSITORY_CACHE", ENABLE_REPOSITORY_CACHE) | ||
24 | + REDIS_ADDRESS = REDIS_HOST + ":" + REDIS_PORT | ||
25 | +} |
pkg/domain/field.go
0 → 100644
1 | +package domain | ||
2 | + | ||
3 | +// Field 字段 | ||
4 | +type Field struct { | ||
5 | + // 字段Id | ||
6 | + FieldId int `json:"fieldId"` | ||
7 | + // 索引序号 | ||
8 | + Index int `json:"index"` | ||
9 | + // 名称 | ||
10 | + Name string `json:"name"` | ||
11 | + // 对应数据库名称 | ||
12 | + SQLName string `json:"sqlName"` | ||
13 | + // 对应数据库类型 | ||
14 | + SQLType string `json:"sqlType"` | ||
15 | + // 描述 | ||
16 | + Description string `json:"description"` | ||
17 | + // 标识 1:主表字段 2:手动添加 | ||
18 | + Flag int `json:"flag"` | ||
19 | +} |
pkg/domain/file.go
0 → 100644
1 | +package domain | ||
2 | + | ||
3 | +import "time" | ||
4 | + | ||
5 | +// File 文件 | ||
6 | +type File struct { | ||
7 | + // 文件ID | ||
8 | + FileId int `json:"fileId"` | ||
9 | + // 文件类型 | ||
10 | + FileType string `json:"fileType"` | ||
11 | + // 文件信息 | ||
12 | + FileInfo *FileInfo `json:"fileInfo"` | ||
13 | + // 源文件Id(FileType为TemporaryFile或VerifiedFile时有值) | ||
14 | + SourceFileId string `json:"sourceFileId"` | ||
15 | + // 操作人 | ||
16 | + Operator string `json:"operator"` | ||
17 | + // 创建时间 | ||
18 | + CreatedAt time.Time `json:"createdAt"` | ||
19 | + // 更新时间 | ||
20 | + UpdatedAt time.Time `json:"updatedAt"` | ||
21 | + // 删除时间 | ||
22 | + DeletedAt time.Time `json:"deletedAt"` | ||
23 | + // 版本 | ||
24 | + Version int `json:"version"` | ||
25 | +} | ||
26 | + | ||
27 | +type FileRepository interface { | ||
28 | + Save(file *File) (*File, error) | ||
29 | + Remove(file *File) (*File, error) | ||
30 | + FindOne(queryOptions map[string]interface{}) (*File, error) | ||
31 | + Find(queryOptions map[string]interface{}) (int64, []*File, error) | ||
32 | +} | ||
33 | + | ||
34 | +func (file *File) Identify() interface{} { | ||
35 | + if file.FileId == 0 { | ||
36 | + return nil | ||
37 | + } | ||
38 | + return file.FileId | ||
39 | +} | ||
40 | + | ||
41 | +func (file *File) Update(data map[string]interface{}) error { | ||
42 | + return nil | ||
43 | +} |
pkg/domain/file_info.go
0 → 100644
pkg/domain/log.go
0 → 100644
1 | +package domain | ||
2 | + | ||
3 | +import "time" | ||
4 | + | ||
5 | +// Log 日志 | ||
6 | +type Log struct { | ||
7 | + // 日志ID | ||
8 | + LogId int `json:"logId"` | ||
9 | + // 日志类型 1.校验步骤 2.常规日志 | ||
10 | + LogType int `json:"logType"` | ||
11 | + // 源数据ID | ||
12 | + SourceId int `json:"sourceId"` | ||
13 | + // 日志内容 | ||
14 | + Entry *LogEntry `json:"entry"` | ||
15 | + // 创建时间 | ||
16 | + CreatedAt time.Time `json:"createdAt"` | ||
17 | +} | ||
18 | + | ||
19 | +type LogRepository interface { | ||
20 | + Save(log *Log) (*Log, error) | ||
21 | + Remove(log *Log) (*Log, error) | ||
22 | + FindOne(queryOptions map[string]interface{}) (*Log, error) | ||
23 | + Find(queryOptions map[string]interface{}) (int64, []*Log, error) | ||
24 | +} | ||
25 | + | ||
26 | +func (log *Log) Identify() interface{} { | ||
27 | + if log.LogId == 0 { | ||
28 | + return nil | ||
29 | + } | ||
30 | + return log.LogId | ||
31 | +} | ||
32 | + | ||
33 | +func (log *Log) Update(data map[string]interface{}) error { | ||
34 | + | ||
35 | + return nil | ||
36 | +} |
pkg/domain/log_entry.go
0 → 100644
1 | +package domain | ||
2 | + | ||
3 | +// LogEntry 日志内容 | ||
4 | +type LogEntry struct { | ||
5 | + // 对象名称 数据表名 / 文件名 | ||
6 | + ObjectName string `json:"objectName"` | ||
7 | + // 对象类型 1.主表 2.分表 3.副表 4.源文件 5.校验文件 | ||
8 | + ObjectType string `json:"objectType"` | ||
9 | + // 操作类型 1.主表生成 2.主表拆分 3.数据导入 4.分表生成 5.表复制 6.编辑记录 7.文件上传 8.文件校验 | ||
10 | + OperationType string `json:"operationType"` | ||
11 | + // 日志内容 | ||
12 | + Content string `json:"content"` | ||
13 | + // 操作人名称 | ||
14 | + OperatorName string `json:"operatorName"` | ||
15 | +} |
pkg/domain/table.go
0 → 100644
1 | +package domain | ||
2 | + | ||
3 | +import "time" | ||
4 | + | ||
5 | +// Table 表 | ||
6 | +type Table struct { | ||
7 | + // 表Id | ||
8 | + TableId int `json:"tableId"` | ||
9 | + // 表类型 MainTable:主表 SideTable:副表 SubTable:分表 ExcelTable:Excel表 | ||
10 | + TableType string `json:"tableType"` | ||
11 | + // 名称 | ||
12 | + Name string `json:"name"` | ||
13 | + // 对应数据库名称 | ||
14 | + SQLName string `json:"sQLName"` | ||
15 | + // 父级ID | ||
16 | + ParentId int64 `json:"parentId,string"` | ||
17 | + // 数据字段序号 | ||
18 | + DataFieldIndex int `json:"dataFieldIndex"` | ||
19 | + // 主键字段 | ||
20 | + PK string `json:"pK"` | ||
21 | + // 数据列 | ||
22 | + DataFields string `json:"dataFields"` | ||
23 | + // 手动添加的列 | ||
24 | + ManualFields string `json:"manualFields"` | ||
25 | + // 创建时间 | ||
26 | + CreatedAt time.Time `json:"createdAt"` | ||
27 | + // 更新时间 | ||
28 | + UpdatedAt time.Time `json:"updatedAt"` | ||
29 | + // 删除时间 | ||
30 | + DeletedAt time.Time `json:"deletedAt"` | ||
31 | + // 版本 | ||
32 | + Version int `json:"version"` | ||
33 | +} | ||
34 | + | ||
35 | +type TableRepository interface { | ||
36 | + Save(table *Table) (*Table, error) | ||
37 | + Remove(table *Table) (*Table, error) | ||
38 | + FindOne(queryOptions map[string]interface{}) (*Table, error) | ||
39 | + Find(queryOptions map[string]interface{}) (int64, []*Table, error) | ||
40 | +} | ||
41 | + | ||
42 | +func (table *Table) Identify() interface{} { | ||
43 | + if table.TableId == 0 { | ||
44 | + return nil | ||
45 | + } | ||
46 | + return table.TableId | ||
47 | +} | ||
48 | + | ||
49 | +func (table *Table) Update(data map[string]interface{}) error { | ||
50 | + return nil | ||
51 | +} |
pkg/infrastructure/pg/init.go
0 → 100644
1 | +package pg | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/go-pg/pg/v10" | ||
6 | + "github.com/go-pg/pg/v10/orm" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/constant" | ||
8 | + | ||
9 | + //_ "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/pg/models" | ||
10 | + "github.com/linmadan/egglib-go/persistent/pg/comment" | ||
11 | + "github.com/linmadan/egglib-go/persistent/pg/hooks" | ||
12 | +) | ||
13 | + | ||
14 | +var DB *pg.DB | ||
15 | + | ||
16 | +func init() { | ||
17 | + DB = pg.Connect(&pg.Options{ | ||
18 | + User: constant.POSTGRESQL_USER, | ||
19 | + Password: constant.POSTGRESQL_PASSWORD, | ||
20 | + Database: constant.POSTGRESQL_DB_NAME, | ||
21 | + Addr: fmt.Sprintf("%s:%s", constant.POSTGRESQL_HOST, constant.POSTGRESQL_PORT), | ||
22 | + }) | ||
23 | + if !constant.DISABLE_SQL_GENERATE_PRINT { | ||
24 | + DB.AddQueryHook(hooks.SqlGeneratePrintHook{}) | ||
25 | + } | ||
26 | + if !constant.DISABLE_CREATE_TABLE { | ||
27 | + for _, model := range []interface{}{} { | ||
28 | + err := DB.Model(model).CreateTable(&orm.CreateTableOptions{ | ||
29 | + Temp: false, | ||
30 | + IfNotExists: true, | ||
31 | + FKConstraints: true, | ||
32 | + }) | ||
33 | + if err != nil { | ||
34 | + panic(err) | ||
35 | + } | ||
36 | + comment.AddComments(DB, model) | ||
37 | + } | ||
38 | + } | ||
39 | +} |
pkg/infrastructure/pg/models/file.go
0 → 100644
1 | +package models | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain" | ||
5 | + "time" | ||
6 | +) | ||
7 | + | ||
8 | +type File struct { | ||
9 | + tableName string `comment:"文件" pg:"metadata.files,alias:file"` | ||
10 | + // 文件ID | ||
11 | + FileId int `comment:"文件ID" pg:"pk:file_id"` | ||
12 | + // 文件类型 | ||
13 | + FileType string `comment:"文件类型"` | ||
14 | + // 文件信息 | ||
15 | + FileInfo *domain.FileInfo `comment:"文件信息"` | ||
16 | + // 源文件Id(FileType为TemporaryFile或VerifiedFile时有值) | ||
17 | + SourceFileId string `comment:"源文件Id(FileType为TemporaryFile或VerifiedFile时有值)"` | ||
18 | + // 操作人 | ||
19 | + Operator string `comment:"操作人"` | ||
20 | + // 创建时间 | ||
21 | + CreatedAt time.Time `comment:"创建时间"` | ||
22 | + // 更新时间 | ||
23 | + UpdatedAt time.Time `comment:"更新时间"` | ||
24 | + // 删除时间 | ||
25 | + DeletedAt time.Time `comment:"删除时间"` | ||
26 | + // 版本 | ||
27 | + Version int `comment:"版本"` | ||
28 | +} |
pkg/infrastructure/pg/models/log.go
0 → 100644
1 | +package models | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain" | ||
5 | + "time" | ||
6 | +) | ||
7 | + | ||
8 | +type Log struct { | ||
9 | + tableName string `comment:"日志" pg:"metadata.logs,alias:log"` | ||
10 | + // 日志ID | ||
11 | + LogId int `comment:"日志ID" pg:"pk:log_id"` | ||
12 | + // 日志类型 1.校验步骤 2.常规日志 | ||
13 | + LogType int `comment:"日志类型 1.校验步骤 2.常规日志"` | ||
14 | + // 源数据ID | ||
15 | + SourceId int `comment:"源数据ID"` | ||
16 | + // 日志内容 | ||
17 | + Entry *domain.LogEntry `comment:"日志内容"` | ||
18 | + // 创建时间 | ||
19 | + CreatedAt time.Time `comment:"创建时间"` | ||
20 | +} |
pkg/infrastructure/pg/models/table.go
0 → 100644
1 | +package models | ||
2 | + | ||
3 | +import "time" | ||
4 | + | ||
5 | +type Table struct { | ||
6 | + tableName string `comment:"表" pg:"metadata.tables,alias:table"` | ||
7 | + // 表Id | ||
8 | + TableId int `comment:"表Id" pg:"pk:table_id"` | ||
9 | + // 表类型 MainTable:主表 SideTable:副表 SubTable:分表 ExcelTable:Excel表 | ||
10 | + TableType string `comment:"表类型 MainTable:主表 SideTable:副表 SubTable:分表 ExcelTable:Excel表"` | ||
11 | + // 名称 | ||
12 | + Name string `comment:"名称"` | ||
13 | + // 对应数据库名称 | ||
14 | + SQLName string `comment:"对应数据库名称"` | ||
15 | + // 父级ID | ||
16 | + ParentId int64 `comment:"父级ID"` | ||
17 | + // 数据字段序号 | ||
18 | + DataFieldIndex int `comment:"数据字段序号"` | ||
19 | + // 主键字段 | ||
20 | + PK string `comment:"主键字段"` | ||
21 | + // 数据列 | ||
22 | + DataFields string `comment:"数据列"` | ||
23 | + // 手动添加的列 | ||
24 | + ManualFields string `comment:"手动添加的列"` | ||
25 | + // 创建时间 | ||
26 | + CreatedAt time.Time `comment:"创建时间"` | ||
27 | + // 更新时间 | ||
28 | + UpdatedAt time.Time `comment:"更新时间"` | ||
29 | + // 删除时间 | ||
30 | + DeletedAt time.Time `comment:"删除时间"` | ||
31 | + // 版本 | ||
32 | + Version int `comment:"版本"` | ||
33 | +} |
pkg/infrastructure/pg/transform/file.go
0 → 100644
1 | +package transform | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/pg/models" | ||
6 | +) | ||
7 | + | ||
8 | +func TransformToFileDomainModelFromPgModels(fileModel *models.File) (*domain.File, error) { | ||
9 | + return &domain.File{ | ||
10 | + FileId: fileModel.FileId, | ||
11 | + FileType: fileModel.FileType, | ||
12 | + FileInfo: fileModel.FileInfo, | ||
13 | + SourceFileId: fileModel.SourceFileId, | ||
14 | + Operator: fileModel.Operator, | ||
15 | + CreatedAt: fileModel.CreatedAt, | ||
16 | + UpdatedAt: fileModel.UpdatedAt, | ||
17 | + DeletedAt: fileModel.DeletedAt, | ||
18 | + Version: fileModel.Version, | ||
19 | + }, nil | ||
20 | +} |
-
请 注册 或 登录 后发表评论