作者 Administrator

合并分支 'test' 到 'master'

Test



查看合并请求 !1
正在显示 100 个修改的文件 包含 2524 行增加1091 行删除

要显示太多修改。

为保证性能只显示 100 of 100+ 个文件。

@@ -24,3 +24,6 @@ _testmain.go @@ -24,3 +24,6 @@ _testmain.go
24 .log 24 .log
25 .idea 25 .idea
26 *.tmp 26 *.tmp
  27 +
  28 +swagger.json
  29 +swagger.yaml
1 -FROM golang:latest  
2 -MAINTAINER <>  
3 -ENV APP_DIR $GOPATH/src/project 1 +FROM 192.168.0.243:5000/mmm/allied-creation-user:20210809
  2 +ENV APP_DIR $GOPATH/src/project-20210906
4 RUN mkdir -p $APP_DIR 3 RUN mkdir -p $APP_DIR
5 WORKDIR $APP_DIR/ 4 WORKDIR $APP_DIR/
6 COPY ./pkg pkg 5 COPY ./pkg pkg
7 -COPY ./conf conf 6 +COPY ./config config
8 COPY ./go.mod go.mod 7 COPY ./go.mod go.mod
9 COPY ./go.sum go.sum 8 COPY ./go.sum go.sum
10 COPY ./main.go main.go 9 COPY ./main.go main.go
@@ -12,6 +11,6 @@ RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"] @@ -12,6 +11,6 @@ RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"]
12 ENV GO111MODULE on 11 ENV GO111MODULE on
13 ENV GOPROXY https://goproxy.io 12 ENV GOPROXY https://goproxy.io
14 RUN ["go","mod","tidy"] 13 RUN ["go","mod","tidy"]
15 -RUN ["ls"]  
16 RUN ["go","build"] 14 RUN ["go","build"]
17 -ENTRYPOINT ["./project"]  
  15 +RUN ["ls"]
  16 +ENTRYPOINT ["./allied-creation-user"]
  1 +-----BEGIN RSA PRIVATE KEY-----
  2 +MIIEpQIBAAKCAQEAy0OxRf+NheQG9epxbrudwnrzqVgqK5zCuRAkLUgaSMATVXEA
  3 +iDzJN39om+Q49MmtEk4pXGzKUyzkFJG96PA8tJq0E+bSDtSK3n+2mjZb6pChmgHw
  4 +KEX7T8ZVLqJBSrfrI4Z2BJDNEC+3wvVW3zpog1RlfKgft6NYUzNLUqE5Mxzq7lpD
  5 +eRsq+FhzM1sOeEb2dAmUlDDs+7HcR3Kj0ttKeg+hKqIottQ/H6Tq4c8deEQGnO0+
  6 +RN3CygyETbYmLuWttI/sUltulWJALIuU81Yr6uCOq5MSt2WsU8CTuhRwGXSvcQCO
  7 +FLYppYktoMDOGIBQffmJc/DdT1d35fvdpKbm+QIDAQABAoIBAQC8X7+qX2uI6gqJ
  8 +XPxC4x0RX2DxUAPE50KOv6bHUEsLoPZJ+K/Fko/oHuuTja47Lax3inhKb4gSDUhS
  9 +x754YivgNH8u8ns5wz/vc+yGflowyFj7oVAwAqslA2luDnD0Df6crcAx+wAQQCjN
  10 +RRF9T2QMUeq73BOI3Ji+gosLyN55vms2KadrwpPQwYN7qhdrerE7vPqCZeswzs1/
  11 +A5M9PVGBG+simNea5kv+tVJUdLi6ckGAB5KabyhpG779ckwzV/aZy3wIj4SvUvCd
  12 +bewH0xPHx5TqnMOXtzHgktClmL7hIYxy9sL14Dn0KVHbyolQ7IqmJtjXYqG84Fmx
  13 +AfyDfeABAoGBAPP820tKElrfTuZ+Z19kJBTp6I5iax2Ph10glUHLlLqJ82clI/Gl
  14 +CbMtnGmD72HfnJei82xqoVLsUkN9Sp+TSNJALh4N8rHkAtwq5kWToiAWZydwxVsp
  15 +x5OWEN3+QFIdjVW6fhg6jZSK5HHIqMdZOVvbfKP+Cv9fWWzlS7/WVTlJAoGBANVF
  16 +kol+KojM4DEASrw0s1mfPr0XvUFvKJ2TgVGR3HxAk4r0e0WwJdSfwGiB/ePcc6g5
  17 +D5dxBe8W5g3+V0DaC0f1DDNXg2MjYWoByWrurbm14FRnpMnx/UfZLo7rq8T9YrUT
  18 +Bd/y0/JasndN27bIfd60n233IYMqhV2+wBwqD3AxAoGAE2/wdHYJMk4Z9gjZ6WKL
  19 +8VKVIUq759X4XbXrzhsO1TGKP4xY6bZRKIIYtNs65dwvmHD13Yw9H+MNxqyjlkTg
  20 +h0dvpRtNW1ij1bBhOefCAbZnL2AviMyyRpKs81J/A0uxZ8P8qad4gf3ypxHqSD9W
  21 +b3fz3QivDZsl/6Pgvf6wOWkCgYEA1Cv9x5lj2WrxEu62axyG3P9nHBm055cdsf5g
  22 +JfVVg6t+3TuyM7c1O52efpnsKrdTvKTf1QrVG3INdxh0V4lUtcac16sVhBhbvml+
  23 +p0pCPMIrJe1ibKG5F7SB9B+TaEuo2nnNW2mp367JY5VqoyI8zsWk4nJ8vZAc1BGD
  24 +78EMUNECgYEAtV0pta3GuHKOLX1HMRsUsYuWjLqAbahnciF6MnjNWSonEK3VjMhI
  25 +g+krP/9sWoC3cFOG+4s96ubjDTWImvQvCrPaENdvlNwgp035bn51eFRv00QchM2H
  26 +VCS9Nhoqj5BIHl1G7Q13+tYTzjUWtteG902nWDVhgSlNLJf1rbTn34g=
  27 +-----END RSA PRIVATE KEY-----
  1 +-----BEGIN CERTIFICATE-----
  2 +MIIGazCCBVOgAwIBAgIQZBwijHoFToh2kjGwQ1E6bjANBgkqhkiG9w0BAQsFADBc
  3 +MQswCQYDVQQGEwJDTjEaMBgGA1UEChMRV29UcnVzIENBIExpbWl0ZWQxMTAvBgNV
  4 +BAMMKFdvVHJ1cyBPViBTZXJ2ZXIgQ0EgIFtSdW4gYnkgdGhlIElzc3Vlcl0wHhcN
  5 +MjEwMjA0MDAwMDAwWhcNMjIwMzA2MjM1OTU5WjCB0TELMAkGA1UEBhMCQ04xDzAN
  6 +BgNVBBETBjM1MDAxNTESMBAGA1UEBwwJ56aP5bee5biCMU8wTQYDVQQJDEbpqazl
  7 +sL7ljLrmuZbph4zot68yN+WPtzEj5qW85LqU5qW8NTEw44CBNTEx5a6k77yI6Ieq
  8 +6LS46K+V6aqM5Yy65YaF77yJMTAwLgYDVQQKDCfnpo/lu7rkubDkubDkubDkv6Hm
  9 +ga/np5HmioDmnInpmZDlhazlj7gxGjAYBgNVBAMMESouZmptYWltYWltYWkuY29t
  10 +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAy0OxRf+NheQG9epxbrud
  11 +wnrzqVgqK5zCuRAkLUgaSMATVXEAiDzJN39om+Q49MmtEk4pXGzKUyzkFJG96PA8
  12 +tJq0E+bSDtSK3n+2mjZb6pChmgHwKEX7T8ZVLqJBSrfrI4Z2BJDNEC+3wvVW3zpo
  13 +g1RlfKgft6NYUzNLUqE5Mxzq7lpDeRsq+FhzM1sOeEb2dAmUlDDs+7HcR3Kj0ttK
  14 +eg+hKqIottQ/H6Tq4c8deEQGnO0+RN3CygyETbYmLuWttI/sUltulWJALIuU81Yr
  15 +6uCOq5MSt2WsU8CTuhRwGXSvcQCOFLYppYktoMDOGIBQffmJc/DdT1d35fvdpKbm
  16 ++QIDAQABo4ICsTCCAq0wHwYDVR0jBBgwFoAUDUmPFTN7wE+2+zo4Cfw0Fdpg3RQw
  17 +HQYDVR0OBBYEFMGZEgzwtp+UhpTAS9nmSxlo9tIlMA4GA1UdDwEB/wQEAwIFoDAM
  18 +BgNVHRMBAf8EAjAAMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjBJBgNV
  19 +HSAEQjBAMDQGCysGAQQBsjEBAgIWMCUwIwYIKwYBBQUHAgEWF2h0dHBzOi8vc2Vj
  20 +dGlnby5jb20vQ1BTMAgGBmeBDAECAjA9BgNVHR8ENjA0MDKgMKAuhixodHRwOi8v
  21 +Y3JsLmNybG9jc3AuY24vV29UcnVzT1ZTZXJ2ZXJDQV8yLmNybDBsBggrBgEFBQcB
  22 +AQRgMF4wOAYIKwYBBQUHMAKGLGh0dHA6Ly9haWEuY3Jsb2NzcC5jbi9Xb1RydXNP
  23 +VlNlcnZlckNBXzIuY3J0MCIGCCsGAQUFBzABhhZodHRwOi8vb2NzcC5jcmxvY3Nw
  24 +LmNuMIIBBQYKKwYBBAHWeQIEAgSB9gSB8wDxAHcARqVV63X6kSAwtaKJafTzfREs
  25 +QXS+/Um4havy/HD+bUcAAAF3brV9qAAABAMASDBGAiEAjrXS+1JJW9jag/XfW+kY
  26 +oL4sGGDNvcZgV35E0EcGQVACIQCjQh8k5oSFtqo7Qrbx2k3OISjfPSYRXNNsG4Ba
  27 +MyDmRwB2AN+lXqtogk8fbK3uuF9OPlrqzaISpGpejjsSwCBEXCpzAAABd261fdAA
  28 +AAQDAEcwRQIgcPQQJ3rkCFaQPKwT3rtfQkr0taPzw0KW7yqu+MtmBH0CIQChKeMk
  29 +v7Xs0z7J47lM6HTPOU+xXL2riC69LC1KCOS6GTAtBgNVHREEJjAkghEqLmZqbWFp
  30 +bWFpbWFpLmNvbYIPZmptYWltYWltYWkuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQBn
  31 ++jDy7sZS0gZzwMR4hnZHWqFYcJR3wnk77xr+5Yu2ifhlxaLHE3rEY3xTR9LsPwfW
  32 +pdg2McinPCI6vs009NYIpeTiHzVDPzKu2BaUfKj+EHLwZQGfXkNhp3cpqZMiTkr/
  33 +YNqf25GXsBa+spwzyHh9MBXXCfWRfdHX7JlH5zyoLNztTp8unxaRYldjghHDA3Q7
  34 +8Fyz6OncY3I4U4KKBSq2/TTxveDW6NxTTuJTPOg3/qSIkwdOBLuIzuhxmF4D9wpl
  35 +LMHmne2CilVeg73/GAzQt/w7FzmdvaHPAOVYWzdaTNALiXJxbi7EyO8q/uNK0GqY
  36 +hljMsnA1hApG+/2sOP/P
  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: allied-creation-user
  5 + namespace: mmm-suplus-dev
  6 + labels:
  7 + k8s-app: allied-creation-user
  8 +spec:
  9 + ports:
  10 + - name: "http"
  11 + port: 80
  12 + targetPort: 8082
  13 + selector:
  14 + k8s-app: allied-creation-user
  15 +---
  16 +apiVersion: extensions/v1beta1
  17 +kind: Deployment
  18 +metadata:
  19 + name: allied-creation-user
  20 + namespace: mmm-suplus-dev
  21 + labels:
  22 + k8s-app: allied-creation-user
  23 +spec:
  24 + replicas: 1
  25 + template:
  26 + metadata:
  27 + labels:
  28 + k8s-app: allied-creation-user
  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: allied-creation-user
  47 + image: 192.168.0.243:5000/mmm/allied-creation-user:dev
  48 + imagePullPolicy: Always
  49 + ports:
  50 + - containerPort: 8082
  51 + volumeMounts:
  52 + - mountPath: /opt/logs
  53 + name: accesslogs
  54 + env:
  55 + - name: POSTGRESQL_DB_NAME
  56 + valueFrom:
  57 + configMapKeyRef:
  58 + name: suplus-config
  59 + key: postgresqlalliedcreation.dbname
  60 + - name: POSTGRESQL_USER
  61 + valueFrom:
  62 + configMapKeyRef:
  63 + name: suplus-config
  64 + key: postgresql.user
  65 + - name: POSTGRESQL_PASSWORD
  66 + valueFrom:
  67 + configMapKeyRef:
  68 + name: suplus-config
  69 + key: postgresql.password
  70 + - name: POSTGRESQL_HOST
  71 + valueFrom:
  72 + configMapKeyRef:
  73 + name: suplus-config
  74 + key: postgresql.host
  75 + - name: POSTGRESQL_PORT
  76 + valueFrom:
  77 + configMapKeyRef:
  78 + name: suplus-config
  79 + key: postgresql.port
  80 + - name: REDIS_HOST
  81 + valueFrom:
  82 + configMapKeyRef:
  83 + name: suplus-config
  84 + key: redis.ip
  85 + - name: REDIS_PORT
  86 + valueFrom:
  87 + configMapKeyRef:
  88 + name: suplus-config
  89 + key: redis.port
  90 + - name: REDIS_AUTH
  91 + value: ""
  92 + - name: LOG_LEVEL
  93 + value: "debug"
  94 + - name: ERROR_BASE_CODE
  95 + value: "1"
  96 + - name: ERROR_BASE_CODE_MULTIPLE
  97 + value: "1000"
  98 + - name: ENABLE_KAFKA_LOG
  99 + value: "true"
  100 + - name: HTTP_PORT
  101 + value: "8082"
  102 + - name: SERVICE_ENV
  103 + value: "dev"
  104 + - name: REDIS_HOST
  105 + valueFrom:
  106 + configMapKeyRef:
  107 + name: suplus-config
  108 + key: redis.ip
  109 + - name: REDIS_PORT
  110 + valueFrom:
  111 + configMapKeyRef:
  112 + name: suplus-config
  113 + key: redis.port
  114 + volumes:
  115 + - name: accesslogs
  116 + emptyDir: {}
1 #!/bin/bash 1 #!/bin/bash
2 export PATH=/root/local/bin:$PATH 2 export PATH=/root/local/bin:$PATH
3 -kubectl -n <replace-your-k8s-namespace> get pods | grep -q project 3 +kubectl -n mmm-suplus-dev get pods | grep -q allied-creation-user
4 if [ "$?" == "1" ];then 4 if [ "$?" == "1" ];then
5 - kubectl create -f /tmp/dev/project/project.yaml --record  
6 - kubectl -n <replace-your-k8s-namespace> get svc | grep -q project 5 + kubectl create -f /tmp/dev/allied-creation-user/allied-creation-user.yaml --record
  6 + kubectl -n mmm-suplus-dev get svc | grep -q allied-creation-user
7 if [ "$?" == "0" ];then 7 if [ "$?" == "0" ];then
8 - echo "project service install success!" 8 + echo "allied-creation-user service install success!"
9 else 9 else
10 - echo "project service install fail!" 10 + echo "allied-creation-user service install fail!"
11 fi 11 fi
12 - kubectl -n <replace-your-k8s-namespace> get pods | grep -q project 12 + kubectl -n mmm-suplus-dev get pods | grep -q allied-creation-user
13 if [ "$?" == "0" ];then 13 if [ "$?" == "0" ];then
14 - echo "project deployment install success!" 14 + echo "allied-creation-user deployment install success!"
15 else 15 else
16 - echo "project deployment install fail!" 16 + echo "allied-creation-user deployment install fail!"
17 fi 17 fi
18 else 18 else
19 - kubectl delete -f /tmp/dev/project/project.yaml  
20 - kubectl -n <replace-your-k8s-namespace> get svc | grep -q project 19 + kubectl delete -f /tmp/dev/allied-creation-user/allied-creation-user.yaml
  20 + kubectl -n mmm-suplus-dev get svc | grep -q allied-creation-user
21 while [ "$?" == "0" ] 21 while [ "$?" == "0" ]
22 do 22 do
23 - kubectl -n <replace-your-k8s-namespace> get svc | grep -q project 23 + kubectl -n mmm-suplus-dev get svc | grep -q allied-creation-user
24 done 24 done
25 - kubectl -n <replace-your-k8s-namespace> get pods | grep -q project 25 + kubectl -n mmm-suplus-dev get pods | grep -q allied-creation-user
26 while [ "$?" == "0" ] 26 while [ "$?" == "0" ]
27 do 27 do
28 - kubectl -n <replace-your-k8s-namespace> get pods | grep -q project 28 + kubectl -n mmm-suplus-dev get pods | grep -q allied-creation-user
29 done 29 done
30 - kubectl create -f /tmp/dev/project/project.yaml --record  
31 - kubectl -n <replace-your-k8s-namespace> get svc | grep -q project 30 + kubectl create -f /tmp/dev/allied-creation-user/allied-creation-user.yaml --record
  31 + kubectl -n mmm-suplus-dev get svc | grep -q allied-creation-user
32 if [ "$?" == "0" ];then 32 if [ "$?" == "0" ];then
33 - echo "project service update success!" 33 + echo "allied-creation-user service update success!"
34 else 34 else
35 - echo "project service update fail!" 35 + echo "allied-creation-user service update fail!"
36 fi 36 fi
37 - kubectl -n <replace-your-k8s-namespace> get pods | grep -q project 37 + kubectl -n mmm-suplus-dev get pods | grep -q allied-creation-user
38 if [ "$?" == "0" ];then 38 if [ "$?" == "0" ];then
39 - echo "project deployment update success!" 39 + echo "allied-creation-user deployment update success!"
40 else 40 else
41 - echo "project deployment update fail!" 41 + echo "allied-creation-user 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: project  
5 - namespace: <replace-your-k8s-namespace> 4 + name: allied-creation-user
  5 + namespace: mmm-suplus-dev
6 labels: 6 labels:
7 - k8s-app: project 7 + k8s-app: allied-creation-user
8 spec: 8 spec:
9 ports: 9 ports:
10 - name: "http" 10 - name: "http"
11 port: 80 11 port: 80
12 targetPort: 8082 12 targetPort: 8082
13 selector: 13 selector:
14 - k8s-app: project 14 + k8s-app: allied-creation-user
15 --- 15 ---
16 apiVersion: extensions/v1beta1 16 apiVersion: extensions/v1beta1
17 kind: Deployment 17 kind: Deployment
18 metadata: 18 metadata:
19 - name: project  
20 - namespace: <replace-your-k8s-namespace> 19 + name: allied-creation-user
  20 + namespace: mmm-suplus-dev
21 labels: 21 labels:
22 - k8s-app: project 22 + k8s-app: allied-creation-user
23 spec: 23 spec:
24 replicas: 1 24 replicas: 1
25 template: 25 template:
26 metadata: 26 metadata:
27 labels: 27 labels:
28 - k8s-app: project 28 + k8s-app: allied-creation-user
29 spec: 29 spec:
30 affinity: 30 affinity:
31 nodeAffinity: 31 nodeAffinity:
@@ -43,8 +43,8 @@ spec: @@ -43,8 +43,8 @@ spec:
43 - cn-hangzhou.i-bp1euf5u1ph9kbhtndhb 43 - cn-hangzhou.i-bp1euf5u1ph9kbhtndhb
44 - cn-hangzhou.i-bp1hyp5oips9cdwxxgxy 44 - cn-hangzhou.i-bp1hyp5oips9cdwxxgxy
45 containers: 45 containers:
46 - - name: project  
47 - image: 192.168.0.243:5000/mmm/project:dev 46 + - name: allied-creation-user
  47 + image: 192.168.0.243:5000/mmm/allied-creation-user:dev
48 imagePullPolicy: Always 48 imagePullPolicy: Always
49 ports: 49 ports:
50 - containerPort: 8082 50 - containerPort: 8082
  1 +apiVersion: v1
  2 +kind: Service
  3 +metadata:
  4 + name: allied-creation-user
  5 + namespace: mmm-suplus-preonline
  6 + labels:
  7 + k8s-app: allied-creation-user
  8 +spec:
  9 + ports:
  10 + - name: "http"
  11 + port: 80
  12 + targetPort: 8082
  13 + selector:
  14 + k8s-app: allied-creation-user
  15 +---
  16 +apiVersion: extensions/v1beta1
  17 +kind: Deployment
  18 +metadata:
  19 + name: allied-creation-user
  20 + namespace: mmm-suplus-preonline
  21 + labels:
  22 + k8s-app: allied-creation-user
  23 +spec:
  24 + replicas: 1
  25 + template:
  26 + metadata:
  27 + labels:
  28 + k8s-app: allied-creation-user
  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: allied-creation-user
  47 + image: 192.168.0.243:5000/mmm/allied-creation-user:preonline
  48 + imagePullPolicy: Always
  49 + ports:
  50 + - containerPort: 8082
  51 + volumeMounts:
  52 + - mountPath: /opt/logs
  53 + name: accesslogs
  54 + env:
  55 + - name: POSTGRESQL_DB_NAME
  56 + valueFrom:
  57 + configMapKeyRef:
  58 + name: suplus-config
  59 + key: postgresqlalliedcreation.dbname
  60 + - name: POSTGRESQL_USER
  61 + valueFrom:
  62 + configMapKeyRef:
  63 + name: suplus-config
  64 + key: postgresql.user
  65 + - name: POSTGRESQL_PASSWORD
  66 + valueFrom:
  67 + configMapKeyRef:
  68 + name: suplus-config
  69 + key: postgresql.password
  70 + - name: POSTGRESQL_HOST
  71 + valueFrom:
  72 + configMapKeyRef:
  73 + name: suplus-config
  74 + key: postgresql.host
  75 + - name: POSTGRESQL_PORT
  76 + valueFrom:
  77 + configMapKeyRef:
  78 + name: suplus-config
  79 + key: postgresql.port
  80 + - name: REDIS_HOST
  81 + valueFrom:
  82 + configMapKeyRef:
  83 + name: suplus-config
  84 + key: redis.ip
  85 + - name: REDIS_PORT
  86 + valueFrom:
  87 + configMapKeyRef:
  88 + name: suplus-config
  89 + key: redis.port
  90 + - name: REDIS_AUTH
  91 + value: ""
  92 + - name: LOG_LEVEL
  93 + value: "debug"
  94 + - name: ERROR_BASE_CODE
  95 + value: "1"
  96 + - name: ERROR_BASE_CODE_MULTIPLE
  97 + value: "1000"
  98 + - name: ENABLE_KAFKA_LOG
  99 + value: "true"
  100 + - name: HTTP_PORT
  101 + value: "8082"
  102 + - name: REDIS_HOST
  103 + valueFrom:
  104 + configMapKeyRef:
  105 + name: suplus-config
  106 + key: redis.ip
  107 + - name: REDIS_PORT
  108 + valueFrom:
  109 + configMapKeyRef:
  110 + name: suplus-config
  111 + key: redis.port
  112 + - name: SERVICE_ENV
  113 + value: "pre"
  114 + volumes:
  115 + - name: accesslogs
  116 + emptyDir: {}
  1 +#!/bin/bash
  2 +export PATH=/root/local/bin:$PATH
  3 +kubectl -n mmm-suplus-preonline get pods | grep -q allied-creation-user
  4 +if [ "$?" == "1" ];then
  5 + kubectl create -f /tmp/preonline/allied-creation-user/allied-creation-user.yaml --record
  6 + kubectl -n mmm-suplus-preonline get svc | grep -q allied-creation-user
  7 + if [ "$?" == "0" ];then
  8 + echo "allied-creation-user service install success!"
  9 + else
  10 + echo "allied-creation-user service install fail!"
  11 + fi
  12 + kubectl -n mmm-suplus-preonline get pods | grep -q allied-creation-user
  13 + if [ "$?" == "0" ];then
  14 + echo "allied-creation-user deployment install success!"
  15 + else
  16 + echo "allied-creation-user deployment install fail!"
  17 + fi
  18 +else
  19 + kubectl delete -f /tmp/preonline/allied-creation-user/allied-creation-user.yaml
  20 + kubectl -n mmm-suplus-preonline get svc | grep -q allied-creation-user
  21 + while [ "$?" == "0" ]
  22 + do
  23 + kubectl -n mmm-suplus-preonline get svc | grep -q allied-creation-user
  24 + done
  25 + kubectl -n mmm-suplus-preonline get pods | grep -q allied-creation-user
  26 + while [ "$?" == "0" ]
  27 + do
  28 + kubectl -n mmm-suplus-preonline get pods | grep -q allied-creation-user
  29 + done
  30 + kubectl create -f /tmp/preonline/allied-creation-user/allied-creation-user.yaml --record
  31 + kubectl -n mmm-suplus-preonline get svc | grep -q allied-creation-user
  32 + if [ "$?" == "0" ];then
  33 + echo "allied-creation-user service update success!"
  34 + else
  35 + echo "allied-creation-user service update fail!"
  36 + fi
  37 + kubectl -n mmm-suplus-preonline get pods | grep -q allied-creation-user
  38 + if [ "$?" == "0" ];then
  39 + echo "allied-creation-user deployment update success!"
  40 + else
  41 + echo "allied-creation-user deployment update fail!"
  42 + fi
  43 +fi
  1 +apiVersion: v1
  2 +kind: Service
  3 +metadata:
  4 + name: allied-creation-user
  5 + namespace: mmm-suplus-test
  6 + labels:
  7 + k8s-app: allied-creation-user
  8 +spec:
  9 + ports:
  10 + - name: "http"
  11 + port: 80
  12 + targetPort: 8082
  13 + - name: "https"
  14 + port: 443
  15 + targetPort: 443
  16 + selector:
  17 + k8s-app: allied-creation-user
  18 +---
  19 +apiVersion: extensions/v1beta1
  20 +kind: Deployment
  21 +metadata:
  22 + name: allied-creation-user
  23 + namespace: mmm-suplus-test
  24 + labels:
  25 + k8s-app: allied-creation-user
  26 +spec:
  27 + replicas: 1
  28 + template:
  29 + metadata:
  30 + labels:
  31 + k8s-app: allied-creation-user
  32 + spec:
  33 + affinity:
  34 + nodeAffinity:
  35 + preferredDuringSchedulingIgnoredDuringExecution:
  36 + - preference: {}
  37 + weight: 100
  38 + requiredDuringSchedulingIgnoredDuringExecution:
  39 + nodeSelectorTerms:
  40 + - matchExpressions:
  41 + - key: kubernetes.io/hostname
  42 + operator: In
  43 + values:
  44 + - cn-hangzhou.i-bp1djh1xn7taumbue1ze
  45 + - cn-hangzhou.i-bp1djh1xn7taumbue1zd
  46 + - cn-hangzhou.i-bp1euf5u1ph9kbhtndhb
  47 + - cn-hangzhou.i-bp1hyp5oips9cdwxxgxy
  48 + containers:
  49 + - name: allied-creation-user
  50 + image: 192.168.0.243:5000/mmm/allied-creation-user:dev
  51 + imagePullPolicy: Always
  52 + ports:
  53 + - containerPort: 8082
  54 + - containerPort: 443
  55 + volumeMounts:
  56 + - mountPath: /opt/logs
  57 + name: accesslogs
  58 + env:
  59 + - name: POSTGRESQL_DB_NAME
  60 + valueFrom:
  61 + configMapKeyRef:
  62 + name: suplus-config
  63 + key: postgresqlalliedcreation.dbname
  64 + - name: POSTGRESQL_USER
  65 + valueFrom:
  66 + configMapKeyRef:
  67 + name: suplus-config
  68 + key: postgresql.user
  69 + - name: POSTGRESQL_PASSWORD
  70 + valueFrom:
  71 + configMapKeyRef:
  72 + name: suplus-config
  73 + key: postgresql.password
  74 + - name: POSTGRESQL_HOST
  75 + valueFrom:
  76 + configMapKeyRef:
  77 + name: suplus-config
  78 + key: postgresql.host
  79 + - name: POSTGRESQL_PORT
  80 + valueFrom:
  81 + configMapKeyRef:
  82 + name: suplus-config
  83 + key: postgresql.port
  84 + - name: REDIS_HOST
  85 + valueFrom:
  86 + configMapKeyRef:
  87 + name: suplus-config
  88 + key: redis.ip
  89 + - name: REDIS_PORT
  90 + valueFrom:
  91 + configMapKeyRef:
  92 + name: suplus-config
  93 + key: redis.port
  94 + - name: REDIS_AUTH
  95 + value: ""
  96 + - name: LOG_LEVEL
  97 + value: "debug"
  98 + - name: ERROR_BASE_CODE
  99 + value: "1"
  100 + - name: ERROR_BASE_CODE_MULTIPLE
  101 + value: "1000"
  102 + - name: ENABLE_KAFKA_LOG
  103 + value: "true"
  104 + - name: HTTP_PORT
  105 + value: "8082"
  106 + - name: SERVICE_ENV
  107 + value: "test"
  108 + - name: REDIS_HOST
  109 + valueFrom:
  110 + configMapKeyRef:
  111 + name: suplus-config
  112 + key: redis.ip
  113 + - name: REDIS_PORT
  114 + valueFrom:
  115 + configMapKeyRef:
  116 + name: suplus-config
  117 + key: redis.port
  118 + volumes:
  119 + - name: accesslogs
  120 + emptyDir: {}
  1 +#!/bin/bash
  2 +export PATH=/root/local/bin:$PATH
  3 +kubectl -n mmm-suplus-test get pods | grep -q allied-creation-user
  4 +if [ "$?" == "1" ];then
  5 + kubectl create -f /tmp/test/allied-creation-user/allied-creation-user.yaml --record
  6 + kubectl -n mmm-suplus-test get svc | grep -q allied-creation-user
  7 + if [ "$?" == "0" ];then
  8 + echo "allied-creation-user service install success!"
  9 + else
  10 + echo "allied-creation-user service install fail!"
  11 + fi
  12 + kubectl -n mmm-suplus-test get pods | grep -q allied-creation-user
  13 + if [ "$?" == "0" ];then
  14 + echo "allied-creation-user deployment install success!"
  15 + else
  16 + echo "allied-creation-user deployment install fail!"
  17 + fi
  18 +else
  19 + kubectl delete -f /tmp/test/allied-creation-user/allied-creation-user.yaml
  20 + kubectl -n mmm-suplus-test get svc | grep -q allied-creation-user
  21 + while [ "$?" == "0" ]
  22 + do
  23 + kubectl -n mmm-suplus-test get svc | grep -q allied-creation-user
  24 + done
  25 + kubectl -n mmm-suplus-test get pods | grep -q allied-creation-user
  26 + while [ "$?" == "0" ]
  27 + do
  28 + kubectl -n mmm-suplus-test get pods | grep -q allied-creation-user
  29 + done
  30 + kubectl create -f /tmp/test/allied-creation-user/allied-creation-user.yaml --record
  31 + kubectl -n mmm-suplus-test get svc | grep -q allied-creation-user
  32 + if [ "$?" == "0" ];then
  33 + echo "allied-creation-user service update success!"
  34 + else
  35 + echo "allied-creation-user service update fail!"
  36 + fi
  37 + kubectl -n mmm-suplus-test get pods | grep -q allied-creation-user
  38 + if [ "$?" == "0" ];then
  39 + echo "allied-creation-user deployment update success!"
  40 + else
  41 + echo "allied-creation-user deployment update fail!"
  42 + fi
  43 +fi
1 -version: v1  
2 -kind: HttpApi  
3 -metadata:  
4 - service: menu  
5 - path: /menus  
6 - endpoints:  
7 - - method: createMenu  
8 - route:  
9 - post: /  
10 - - method: updateMenu  
11 - route:  
12 - put: /{menuId}  
13 - - method: getMenu  
14 - route:  
15 - get: /{menuId}  
16 - - method: removeMenu  
17 - route:  
18 - delete: /{menuId}  
19 - - method: listMenu  
20 - route:  
21 - get: /  
22 - params:  
23 - - name: offset  
24 - - name: limit  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: count  
5 - description: 匹配数目  
6 - type:  
7 - primitive: int64  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: createAt  
5 - description: 创建时间  
6 - type:  
7 - primitive: datetime  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: deleteAt  
5 - description: 删除时间  
6 - type:  
7 - primitive: datetime  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: limit  
5 - description: 查询限制  
6 - type:  
7 - primitive: int  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: offset  
5 - description: 查询偏离量  
6 - type:  
7 - primitive: int  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: remark  
5 - description: 备注  
6 - type:  
7 - primitive: string  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: updateAt  
5 - description: 更新时间  
6 - type:  
7 - primitive: datetime  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: companyId  
5 - description: 企业id  
6 - type:  
7 - primitive: int64  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: companyName  
5 - description: 企业名称  
6 - type:  
7 - primitive: string  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: configCode  
5 - description: 参数编码  
6 - type:  
7 - primitive: string  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: configId  
5 - description: 系统配置id  
6 - type:  
7 - primitive: int64  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: configLevel  
5 - description: 参数管控层级 (1.平台级 2.系统级 3.功能级)  
6 - type:  
7 - primitive: int  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: configName  
5 - description: 参数名称  
6 - type:  
7 - primitive: string  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: desc  
5 - description: 参数描述  
6 - type:  
7 - primitive: string  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: value  
5 - description: 管控值  
6 - type:  
7 - primitive: string  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: valueType  
5 - description: 参数管控层级 (1.字符 2.数值 3.时间)  
6 - type:  
7 - primitive: int  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: menuId  
5 - description: 菜单编号  
6 - type:  
7 - primitive: int64  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: orgCode  
5 - description: 组织编码  
6 - type:  
7 - primitive: string  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: orgId  
5 - description: 组织ID  
6 - type:  
7 - primitive: int64  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: orgName  
5 - description: 组织名称  
6 - type:  
7 - primitive: string  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: roleId  
5 - description: 角色ID  
6 - type:  
7 - primitive: int64  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: roleName  
5 - description: 角色名称  
6 - type:  
7 - primitive: string  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: status  
5 - description: 用户状态  
6 - type:  
7 - primitive: int  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: usersCode  
5 - description: 用户编号  
6 - type:  
7 - primitive: string  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: usersCompanyId  
5 - description: 用户公司编号  
6 - type:  
7 - primitive: int64  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: usersId  
5 - description: 用户编号  
6 - type:  
7 - primitive: int64  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: usersName  
5 - description: 用户姓名  
6 - type:  
7 - primitive: string  
1 -version: v1  
2 -kind: Attribute  
3 -metadata:  
4 - name: usersType  
5 - description: 用户类型 : 1:普通用户 2:共创用户 1024:超级管理员  
6 - type:  
7 - primitive: int  
1 -version: v1  
2 -kind: Project  
3 -metadata:  
4 - name: project  
5 - description: 天联企业管理系统  
6 - version: 0.0.1  
7 - repository: gitlab.fjmaimaimai.com/allied-creation/allied-creation-user  
8 - contact:  
9 - name:  
10 - email:  
1 -version: v1  
2 -kind: Schema  
3 -metadata:  
4 - name: app  
5 - description: app项目管理  
6 - attributes:  
7 - - name: appId  
8 - description: appId  
9 - type:  
10 - primitive: int64  
11 - - name: project  
12 - description: 项目标识 ability  
13 - type:  
14 - primitive: string  
15 - - name: app  
16 - description: 应用标识 ability.boss.pad  
17 - type:  
18 - primitive: string  
19 - - name: icon  
20 - description: 图标地址  
21 - type:  
22 - primitive: string  
23 - - name: remark  
24 - description: 备注信息  
25 - type:  
26 - primitive: string  
27 - - ref: createAt  
28 - required: true  
29 - - ref: updateAt  
30 - required: true  
31 - - ref: deleteAt  
32 - required: true  
1 -version: v1  
2 -kind: Schema  
3 -metadata:  
4 - name: appVersion  
5 - description: App版本管理  
6 - attributes:  
7 - - name: appVersionId  
8 - description: app版本id  
9 - type:  
10 - primitive: int64  
11 - - name: app  
12 - description: 应用  
13 - type:  
14 - schema: app  
15 - - name: os  
16 - description: 设备类型 0:IOS 1:安卓  
17 - type:  
18 - primitive: int  
19 - - name: version  
20 - description: 版本信息  
21 - type:  
22 - schema: appVersionInfo  
23 - - name: remark  
24 - description: 备注信息  
25 - type:  
26 - primitive: string  
27 - - ref: createAt  
28 - required: true  
29 - - ref: updateAt  
30 - required: true  
31 - - ref: deleteAt  
32 - required: true  
1 -version: v1  
2 -kind: Schema  
3 -metadata:  
4 - name: appVersionInfo  
5 - description: app 版本信息  
6 - attributes:  
7 - - name: versionNo  
8 - description: 版本号  
9 - type:  
10 - primitive: string  
11 - - name: versionName  
12 - description: 版本名称  
13 - type:  
14 - primitive: string  
15 - - name: title  
16 - description: 标题  
17 - type:  
18 - primitive: string  
19 - - name: summary  
20 - description: 版本概要  
21 - type:  
22 - primitive: string  
23 - - name: content  
24 - description: 版本内容  
25 - type:  
26 - primitive: string  
27 - - name: deviceType  
28 - description: 设备类型 0:ios , 1:android  
29 - type:  
30 - primitive: int  
31 - - name: downloadPage  
32 - description: 下载页面  
33 - type:  
34 - primitive: string  
35 - - name: downloadFile  
36 - description: 文件下载地址  
37 - type:  
38 - primitive: string  
39 - - name: updateType  
40 - description: 更新类型 0不需要更新 1是引导更新 2是强制更新  
41 - type:  
42 - primitive: int  
43 - - name: channel  
44 - description: 更新的渠道 当前渠道 0_AppStore、1_fir平台、2_华为、3_小米、4_魅族、5_oppo、6_vivo、7_360、8_百度、9_应用宝、10_其他(使用应用宝地址)  
45 - type:  
46 - array: int  
1 -version: v1  
2 -kind: Schema  
3 -metadata:  
4 - name: company  
5 - description: 企业信息 (base)  
6 - attributes:  
7 - - ref: companyId  
8 - required: true  
9 - - name: companyConfig  
10 - description: 企业配置信息  
11 - type:  
12 - schema: companyConfig  
13 - - name: companyInfo  
14 - description: 企业基本信息  
15 - type:  
16 - schema: companyInfo  
17 - - name: status  
18 - description: 公司状态  
19 - type:  
20 - primitive: int  
21 - - ref: createAt  
22 - required: false  
23 - - ref: updateAt  
24 - required: false  
25 -  
1 -version: v1  
2 -kind: Schema  
3 -metadata:  
4 - name: companyConfig  
5 - description: 公司配置信息  
6 - attributes:  
7 - - name: systemName  
8 - description: 系统名称  
9 - type:  
10 - primitive: string  
11 - - name: theme  
12 - description: 主题  
13 - type:  
14 - primitive: string  
1 -version: v1  
2 -kind: Schema  
3 -metadata:  
4 - name: companyInfo  
5 - description: 公司信息  
6 - attributes:  
7 - - name: companyName  
8 - description: 公司名称  
9 - type:  
10 - primitive: string  
11 - - name: scale  
12 - description: 规模  
13 - type:  
14 - primitive: string  
15 - - name: logo  
16 - description: 公司Logo地址  
17 - type:  
18 - primitive: string  
19 - - name: address  
20 - description: 公司地址  
21 - type:  
22 - primitive: string  
23 - - name: taxpayerCode  
24 - description: 纳税人识别号  
25 - type:  
26 - primitive: string  
27 - - name: businessLicense  
28 - description: 营业执照  
29 - type:  
30 - primitive: string  
31 - - name: industryCategory  
32 - description: 所属行业  
33 - type:  
34 - primitive: string  
35 - - name: contacts  
36 - description: 联系人  
37 - type:  
38 - primitive: string  
39 - - name: registTime  
40 - description: 注册时间  
41 - type:  
42 - primitive: datetime  
43 - - name: registStatus  
44 - description: 注册状态  
45 - type:  
46 - primitive: int  
1 -version: v1  
2 -kind: Schema  
3 -metadata:  
4 - name: config  
5 - description: 系统参数配置  
6 - attributes:  
7 - - ref: configId  
8 - required: true  
9 - - ref: companyId  
10 - required: true  
11 - - ref: configCode  
12 - required: true  
13 - - ref: configName  
14 - required: true  
15 - - ref: configLevel  
16 - required: true  
17 - - ref: valueType  
18 - required: true  
19 - - ref: value  
20 - required: true  
21 - - ref: desc  
22 - required: true  
1 -version: v1  
2 -kind: Schema  
3 -metadata:  
4 - name: cooperationInfo  
5 - description: 共创信息  
6 - attributes:  
7 - - name: cooperationCompany  
8 - description: 共创公司  
9 - type:  
10 - primitive: string  
11 - - name: cooperationDeadline  
12 - description: 共创到期时间 (yyyy-MM-dd)  
13 - type:  
14 - primitive: datetime  
1 -version: v1  
2 -kind: Schema  
3 -metadata:  
4 - name: credentialAuth  
5 - description: 凭证认证 (base) (停用)  
6 - attributes:  
7 - - name: credential  
8 - description: 凭证  
9 - type:  
10 - primitive: string  
11 - - name: deviceType  
12 - description: 设备类型  
13 - type:  
14 - primitive: string  
15 - - name: expire  
16 - description: 过期时间蹉(unix)  
17 - type:  
18 - primitive: int64  
1 -version: v1  
2 -kind: Schema  
3 -metadata:  
4 - name: customizeMenus  
5 - description: 自定义菜单 (base)(菜单维护)  
6 - attributes:  
7 - - name: customizeMenusId  
8 - description: 自定义菜单id  
9 - type:  
10 - primitive: int64  
11 - - ref: companyId  
12 - required: true  
13 - - name: menuId  
14 - description: 菜单id  
15 - type:  
16 - primitive: int64  
17 - - name: menuName  
18 - description: 菜单名称  
19 - type:  
20 - primitive: string  
21 - - name: menuAlias  
22 - description: 菜单别名  
23 - type:  
24 - primitive: string  
25 - - name: sort  
26 - description: 排序  
27 - type:  
28 - primitive: int  
1 -version: v1  
2 -kind: Schema  
3 -metadata:  
4 - name: dataColumn  
5 - description: 数据列  
6 - attributes:  
7 - - name: dataIndex  
8 - description: 数据列字段代码名称  
9 - type:  
10 - primitive: string  
11 - - name: title  
12 - description: 数据列字段中文描述  
13 - type:  
14 - primitive: string  
15 - - name: sortBy  
16 - description: 默认的排序  
17 - type:  
18 - primitive: int64  
19 - - name: isDefault  
20 - description: 是否是默认配置字段  
21 - type:  
22 - primitive: int  
1 -version: v1  
2 -kind: Schema  
3 -metadata:  
4 - name: dataColumnPerson  
5 - description: 列表设置个人:页面列表数据的输出列的个人配置  
6 - attributes:  
7 - - name: dataColumnPersonId  
8 - description: 数据id  
9 - type:  
10 - primitive: int64  
11 - - name: resource  
12 - description: 资源 (列如表单 user)  
13 - type:  
14 - primitive: string  
15 - - name: columns  
16 - description: 配置的用户显示的字段,例 `["c1","c2"]``  
17 - type:  
18 - array: string  
19 - - name: usersId  
20 - description: 归属的用户id  
21 - type:  
22 - primitive: int64  
1 -version: v1  
2 -kind: Schema  
3 -metadata:  
4 - name: dataColumnSys  
5 - description: 列表设置系统:页面列表数据的输出列的系统全局配置  
6 - attributes:  
7 - - name: dataColumnSysId  
8 - description: 数据id  
9 - type:  
10 - primitive: int64  
11 - - name: resource  
12 - description: 资源 (列如表单 user)  
13 - type:  
14 - primitive: string  
15 - - name: columns  
16 - description: 数据列字段代码名称  
17 - type:  
18 - array: dataColumn  
1 -version: v1  
2 -kind: Schema  
3 -metadata:  
4 - name: dictionary  
5 - description: 字典  
6 - attributes:  
7 - - name: dictionaryId  
8 - description: 字典编号 主键  
9 - type:  
10 - primitive: int  
11 - - name: dictCode  
12 - description: 字典编码  
13 - type:  
14 - primitive: string  
15 - - name: dictName  
16 - description: 字典名称  
17 - type:  
18 - primitive: string  
19 - - name: enableStatus  
20 - description: 启用状态(启用:1 禁用:2)  
21 - type:  
22 - primitive: int  
23 - - name: desc  
24 - description: 备注信息  
25 - type:  
26 - primitive: string  
27 - - name: dictItems  
28 - description: 字典值列表  
29 - type:  
30 - array: dictionaryItem  
1 -version: v1  
2 -kind: Schema  
3 -metadata:  
4 - name: dictionaryItem  
5 - description: 字典明细项  
6 - attributes:  
7 - - name: itemCode  
8 - description: 项编码  
9 - type:  
10 - primitive: string  
11 - - name: itemLabel  
12 - description: 项标签  
13 - type:  
14 - primitive: string  
15 - - name: itemValue  
16 - description:  
17 - type:  
18 - primitive: string  
19 - - name: enableStatus  
20 - description: 启用状态(启用:1 禁用:2)  
21 - type:  
22 - primitive: string  
23 - - name: sort  
24 - description: 显示序号  
25 - type:  
26 - primitive: int  
1 -version: v1  
2 -kind: Schema  
3 -metadata:  
4 - name: ext  
5 - description: 冗余附加数据  
6 - attributes:  
7 - - ref: usersName  
8 - required: true  
9 - - ref: orgName  
10 - required: true  
11 - - name: phone  
12 - description: 手机号  
13 - type:  
14 - primitive: string  
15 - - name: depName  
16 - description: 部门名称  
17 - type:  
18 - primitive: string  
1 -version: v1  
2 -kind: Schema  
3 -metadata:  
4 - name: im  
5 - description: 冗余附加数据  
6 - attributes:  
7 - - name: accid  
8 - description: 网易云信ID  
9 - type:  
10 - primitive: string  
11 - - name: imToken  
12 - description: 网易云信Token  
13 - type:  
14 - primitive: string  
15 - - name: csAccountId  
16 - description: 系统分配客服ID  
17 - type:  
18 - primitive: string  
1 -version: v1  
2 -kind: Schema  
3 -metadata:  
4 - name: menu  
5 - description: 系统菜单  
6 - attributes:  
7 - - ref: menuId  
8 - required: true  
9 - - name: parentId  
10 - description: 父级id  
11 - type:  
12 - primitive: int64  
13 - - name: menuName  
14 - description: 菜单名称  
15 - type:  
16 - primitive: string  
17 - - name: code  
18 - description: 菜单编码 SYSTEM_USER_EDIT / 100101 (字符编码)  
19 - type:  
20 - primitive: string  
21 - - name: accessCode  
22 - description: 权限编码 users:edit  
23 - type:  
24 - primitive: string  
25 - - name: menuType  
26 - description: 菜单类型 (目录catalog、菜单menu、按钮button)  
27 - type:  
28 - primitive: string  
29 - - name: icon  
30 - description: 菜单图标  
31 - type:  
32 - primitive: string  
33 - - name: sort  
34 - description: 排序  
35 - type:  
36 - primitive: int  
37 - - name: remark  
38 - description: 菜单说明  
39 - type:  
40 - primitive: string  
41 - - name: category  
42 - description: 菜单类别 (web:1、app:2)  
43 - type:  
44 - primitive: string  
45 - - name: parentPath  
46 - description: 父级节点路径("0,11,12,")  
47 - type:  
48 - primitive: string  
49 - - name: isPublish  
50 - description: 菜单是否公开状态,[0:隐藏],[1:显示],默认显示  
51 - type:  
52 - primitive: int  
53 - - name: isSystem  
54 - description: 菜单是否是系统级,[0:否],[1:是],默认否  
55 - type:  
56 - primitive: int  
1 -version: v1  
2 -kind: Schema  
3 -metadata:  
4 - name: org  
5 - description: 组织 organization  
6 - attributes:  
7 - - ref: orgId  
8 - required: true  
9 - - ref: companyId  
10 - required: true  
11 - - ref: createAt  
12 - required: true  
13 - - ref: updateAt  
14 - required: true  
15 - - ref: deleteAt  
16 - required: true  
17 - - ref: orgCode  
18 - required: true  
19 - - ref: orgName  
20 - required: true  
21 - - name: isOrg  
22 - description: 是否是组织  
23 - type:  
24 - primitive: int  
25 - - name: parentId  
26 - description: 父级ID  
27 - type:  
28 - primitive: int64  
1 -version: v1  
2 -kind: Schema  
3 -metadata:  
4 - name: phoneAuth  
5 - description: 手机认证 (base)  
6 - attributes:  
7 - - name: phone  
8 - description: 手机号  
9 - type:  
10 - primitive: string  
11 - - name: password  
12 - description: 密码  
13 - type:  
14 - primitive: string  
1 -version: v1  
2 -kind: Schema  
3 -metadata:  
4 - name: role  
5 - description: 角色 (base)  
6 - attributes:  
7 - - ref: roleId  
8 - required: true  
9 - - ref: companyId  
10 - required: true  
11 - - ref: orgId  
12 - required: true  
13 - - ref: roleName  
14 - required: true  
15 - - name: menuAccess  
16 - description: 菜单权限列表  
17 - type:  
18 - array: int64  
19 - - name: desc  
20 - description: 角色描述  
21 - type:  
22 - primitive: string  
23 - - name: ext  
24 - description: 扩展数据  
25 - type:  
26 - schema: ext  
27 - - ref: createAt  
28 - required: true  
29 - - ref: updateAt  
30 - required: true  
1 -version: v1  
2 -kind: Schema  
3 -metadata:  
4 - name: users  
5 - description: 用户(base)  
6 - attributes:  
7 - - ref: usersId  
8 - required: true  
9 - - name: usersInfo  
10 - description: 用户信息  
11 - type:  
12 - schema: usersInfo  
13 - - name: phoneAuth  
14 - description: 手机认证  
15 - type:  
16 - schemal: phoneAuth  
17 - - name: im  
18 - description: IM信息  
19 - type:  
20 - schemal: im  
21 - - ref: createAt  
22 - required: true  
23 - - ref: updateAt  
24 - required: true  
1 -version: v1  
2 -kind: Schema  
3 -metadata:  
4 - name: usersCompany  
5 - description: 用户 (base)  
6 - attributes:  
7 - - ref: usersCompanyId  
8 - required: true  
9 - - ref: companyId  
10 - required: true  
11 - - ref: usersId  
12 - required: true  
13 - - ref: usersType  
14 - required: true  
15 - - ref: usersCode  
16 - required: true  
17 - - name: organization  
18 - description: 组织机构  
19 - type:  
20 - primitive: int64  
21 - - name: department  
22 - description: 所属部门  
23 - type:  
24 - primitive: int64  
25 - - name: usersOrg  
26 - description: 用户关联的组织  
27 - type:  
28 - array: int64  
29 - - name: usersRole  
30 - description: 用户关联的角色  
31 - type:  
32 - array: int64  
33 - - name: collectedMenus  
34 - description: 收藏的菜单(工作台)(菜单编码列表)  
35 - type:  
36 - array: string  
37 - - name: cooperationInfo  
38 - description: 共创信息 (共创用户有效)  
39 - type:  
40 - schema: cooperationInfo  
41 - - name: enableStatus  
42 - description: 启用状态(启用:1 禁用:2)  
43 - type:  
44 - primitive: int  
45 - - name: ext  
46 - description: 扩展数据  
47 - type:  
48 - schema: ext  
49 - - ref: createAt  
50 - required: true  
51 - - ref: updateAt  
52 - required: true  
1 -version: v1  
2 -kind: Schema  
3 -metadata:  
4 - name: usersInfo  
5 - description: 用户信息 (base)  
6 - attributes:  
7 - - ref: usersName  
8 - required: true  
9 - - name: phone  
10 - description: 手机号码  
11 - type:  
12 - primitive: string  
13 - - name: avator  
14 - description: 头像  
15 - type:  
16 - primitive: string  
17 - - name: email  
18 - description: 邮箱  
19 - type:  
20 - primitive: string  
1 -version: v1  
2 -kind: Method  
3 -metadata:  
4 - name: createMenu  
5 - type: command  
6 - description: 创建菜单服务  
7 - payload:  
8 - - name: parentId  
9 - description: 父级id  
10 - type:  
11 - primitive: int64  
12 - - name: menuName  
13 - description: 菜单名称  
14 - type:  
15 - primitive: string  
16 - required: true  
17 - - name: code  
18 - description: 菜单编码 SYSTEM_USER_EDIT / 100101 (字符编码)  
19 - type:  
20 - primitive: string  
21 - required: true  
22 - - name: accessCode  
23 - description: 权限编码 users:edit  
24 - type:  
25 - primitive: string  
26 - required: true  
27 - - name: menuType  
28 - description: 菜单类型 (目录catalog、菜单menu、按钮button)  
29 - type:  
30 - primitive: string  
31 - required: true  
32 - - name: icon  
33 - description: 菜单图标  
34 - type:  
35 - primitive: string  
36 - - name: sort  
37 - description: 排序  
38 - type:  
39 - primitive: int  
40 - required: true  
41 - - name: remark  
42 - description: 菜单说明  
43 - type:  
44 - primitive: string  
45 - - name: isPublish  
46 - description: 菜单是否公开状态,[0:隐藏],[1:显示],默认显示  
47 - type:  
48 - primitive: int  
49 - required: true  
50 - result:  
51 - - name: menu  
52 - type:  
53 - schema: menu  
54 - required: true  
1 -version: v1  
2 -kind: Method  
3 -metadata:  
4 - name: getMenu  
5 - type: query  
6 - description: 返回菜单服务  
7 - payload:  
8 - - ref: menuId  
9 - required: true  
10 - result:  
11 - - name: menu  
12 - type:  
13 - schema: menu  
14 - required: true  
1 -version: v1  
2 -kind: Method  
3 -metadata:  
4 - name: listMenu  
5 - type: query  
6 - description: 返回菜单服务列表  
7 - payload:  
8 - - name: menuCategory  
9 - description: 菜单类别 web app  
10 - required: false  
11 - type:  
12 - primitive: string  
13 - - name: parentId  
14 - description: 菜单父级id 0:查询所有 n:父级id为n的菜单列表  
15 - required: false  
16 - type:  
17 - primitive: int64  
18 - - name: menuName  
19 - description: 菜单名称过滤  
20 - required: false  
21 - type:  
22 - primitive: string  
23 - - ref: offset  
24 - required: true  
25 - - ref: limit  
26 - required: true  
27 - result:  
28 - - ref: count  
29 - required: true  
30 - - name: menus  
31 - type:  
32 - array: menu  
33 - required: true  
1 -version: v1  
2 -kind: Method  
3 -metadata:  
4 - name: removeMenu  
5 - type: command  
6 - description: 移除菜单服务  
7 - payload:  
8 - - ref: menuId  
9 - required: true  
10 - result:  
11 - - name: menu  
12 - type:  
13 - schema: menu  
14 - required: true  
1 -version: v1  
2 -kind: Method  
3 -metadata:  
4 - name: updateMenu  
5 - type: command  
6 - description: 更新菜单服务  
7 - payload:  
8 - - ref: menuId  
9 - required: true  
10 - - name: menuName  
11 - description: 菜单名称  
12 - type:  
13 - primitive: string  
14 - required: true  
15 - - name: code  
16 - description: 菜单编码 SYSTEM_USER_EDIT / 100101 (字符编码)  
17 - type:  
18 - primitive: string  
19 - required: true  
20 - - name: accessCode  
21 - description: 权限编码 users:edit  
22 - type:  
23 - primitive: string  
24 - - name: menuType  
25 - description: 菜单类型 (目录catalog、菜单menu、按钮button)  
26 - type:  
27 - primitive: string  
28 - required: true  
29 - - name: icon  
30 - description: 菜单图标  
31 - type:  
32 - primitive: string  
33 - - name: sort  
34 - description: 排序  
35 - type:  
36 - primitive: int  
37 - required: true  
38 - - name: remark  
39 - description: 菜单说明  
40 - type:  
41 - primitive: string  
42 - - name: isPublish  
43 - description: 菜单是否公开状态,[0:隐藏],[1:显示],默认显示  
44 - type:  
45 - primitive: int  
46 - result:  
47 - - name: menu  
48 - type:  
49 - schema: menu  
50 - required: true  
1 -version: v1  
2 -kind: Service  
3 -metadata:  
4 - name: menu  
5 - description: 菜单服务  
@@ -5,6 +5,7 @@ go 1.16 @@ -5,6 +5,7 @@ go 1.16
5 require ( 5 require (
6 github.com/ajg/form v1.5.1 // indirect 6 github.com/ajg/form v1.5.1 // indirect
7 github.com/beego/beego/v2 v2.0.1 7 github.com/beego/beego/v2 v2.0.1
  8 + github.com/emirpasic/gods v1.12.0
8 github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect 9 github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect
9 github.com/fatih/structs v1.1.0 // indirect 10 github.com/fatih/structs v1.1.0 // indirect
10 github.com/gavv/httpexpect v2.0.0+incompatible 11 github.com/gavv/httpexpect v2.0.0+incompatible
@@ -18,6 +19,7 @@ require ( @@ -18,6 +19,7 @@ require (
18 github.com/onsi/gomega v1.11.0 19 github.com/onsi/gomega v1.11.0
19 github.com/sergi/go-diff v1.2.0 // indirect 20 github.com/sergi/go-diff v1.2.0 // indirect
20 github.com/smartystreets/goconvey v1.6.4 // indirect 21 github.com/smartystreets/goconvey v1.6.4 // indirect
  22 + github.com/stretchr/testify v1.7.0
21 github.com/valyala/fasthttp v1.23.0 // indirect 23 github.com/valyala/fasthttp v1.23.0 // indirect
22 github.com/xeipuuv/gojsonschema v1.2.0 // indirect 24 github.com/xeipuuv/gojsonschema v1.2.0 // indirect
23 github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect 25 github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect
@@ -73,6 +73,8 @@ github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox @@ -73,6 +73,8 @@ github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox
73 github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk= 73 github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk=
74 github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= 74 github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
75 github.com/emicklei/proto v1.9.0/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A= 75 github.com/emicklei/proto v1.9.0/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A=
  76 +github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
  77 +github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
76 github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= 78 github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
77 github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= 79 github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
78 github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= 80 github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
1 package main 1 package main
2 2
3 import ( 3 import (
  4 + "fmt"
4 "github.com/beego/beego/v2/server/web" 5 "github.com/beego/beego/v2/server/web"
  6 + "github.com/linmadan/egglib-go/log/logrus"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/constant"
  8 + _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/constant"
5 _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/pg" 9 _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/pg"
6 _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/redis" 10 _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/redis"
  11 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/log"
  12 + _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/log"
7 _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/port/beego" 13 _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/port/beego"
8 ) 14 )
9 15
10 func main() { 16 func main() {
  17 + log.Logger.Info("server start ....")
  18 + log.Logger.Info(fmt.Sprintf("ENABLE_KAFKA_LOG:%v", constant.ENABLE_KAFKA_LOG))
  19 +
  20 + if constant.ENABLE_KAFKA_LOG {
  21 + w, _ := logrus.NewKafkaWriter(constant.KAFKA_HOST, constant.TOPIC_LOG_STASH, false)
  22 + log.Logger.AddHook(w)
  23 + }
  24 + log.Logger.Info("server start!")
11 web.Run() 25 web.Run()
12 } 26 }
  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 CompanySignUpCommand struct {
  12 + // 企业名称
  13 + CompanyName string `cname:"企业名称" json:"companyName" valid:"Required"`
  14 + // 联系人
  15 + Contacts string `cname:"联系人" json:"contacts" valid:"Required"`
  16 + // 手机号码
  17 + Phone string `cname:"手机号码" json:"phone" valid:"Required"`
  18 + // 规模
  19 + Scale string `cname:"规模" json:"scale" valid:"Required"`
  20 + // 所属行业
  21 + IndustryCategory string `cname:"所属行业" json:"industryCategory" valid:"Required"`
  22 + // 密码
  23 + Password string `cname:"密码" json:"password" valid:"Required"`
  24 +}
  25 +
  26 +func (companySignUpCommand *CompanySignUpCommand) Valid(validation *validation.Validation) {
  27 + //validation.SetError("CustomValid", "未实现的自定义认证")
  28 +}
  29 +
  30 +func (companySignUpCommand *CompanySignUpCommand) ValidateCommand() error {
  31 + valid := validation.Validation{}
  32 + b, err := valid.Valid(companySignUpCommand)
  33 + if err != nil {
  34 + return err
  35 + }
  36 + if !b {
  37 + elem := reflect.TypeOf(companySignUpCommand).Elem()
  38 + for _, validErr := range valid.Errors {
  39 + field, isExist := elem.FieldByName(validErr.Field)
  40 + if isExist {
  41 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  42 + } else {
  43 + return fmt.Errorf(validErr.Message)
  44 + }
  45 + }
  46 + }
  47 + return nil
  48 +}
  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 DestroyAccountCommand struct {
  12 + // 用户Id 用户唯一标识
  13 + Account string `cname:"账号" json:"account" valid:"Required"`
  14 +}
  15 +
  16 +func (destroyAccountCommand *DestroyAccountCommand) Valid(validation *validation.Validation) {
  17 +
  18 +}
  19 +
  20 +func (destroyAccountCommand *DestroyAccountCommand) ValidateCommand() error {
  21 + valid := validation.Validation{}
  22 + b, err := valid.Valid(destroyAccountCommand)
  23 + if err != nil {
  24 + return err
  25 + }
  26 + if !b {
  27 + elem := reflect.TypeOf(destroyAccountCommand).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 PhoneAuthChangePasswordCommand struct {
  12 + // 用户Id 用户唯一标识
  13 + UserId int64 `cname:"用户Id 用户唯一标识" json:"userId" valid:"Required"`
  14 + // 旧密码
  15 + OldPassword string `cname:"旧密码" json:"oldPassword" valid:"Required"`
  16 + // 新密码
  17 + NewPassword string `cname:"新密码" json:"newPassword" valid:"Required"`
  18 +}
  19 +
  20 +func (phoneAuthChangePasswordCommand *PhoneAuthChangePasswordCommand) Valid(validation *validation.Validation) {
  21 +
  22 +}
  23 +
  24 +func (phoneAuthChangePasswordCommand *PhoneAuthChangePasswordCommand) ValidateCommand() error {
  25 + valid := validation.Validation{}
  26 + b, err := valid.Valid(phoneAuthChangePasswordCommand)
  27 + if err != nil {
  28 + return err
  29 + }
  30 + if !b {
  31 + elem := reflect.TypeOf(phoneAuthChangePasswordCommand).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 PhoneAuthCheckCommand struct {
  12 + // 手机号码
  13 + Phone string `cname:"手机号码" json:"phone" valid:"Required"`
  14 + // 密码
  15 + Password string `cname:"密码" json:"password" valid:"Required"`
  16 +}
  17 +
  18 +func (phoneAuthCheckCommand *PhoneAuthCheckCommand) Valid(validation *validation.Validation) {
  19 +
  20 +}
  21 +
  22 +func (phoneAuthCheckCommand *PhoneAuthCheckCommand) ValidateCommand() error {
  23 + valid := validation.Validation{}
  24 + b, err := valid.Valid(phoneAuthCheckCommand)
  25 + if err != nil {
  26 + return err
  27 + }
  28 + if !b {
  29 + elem := reflect.TypeOf(phoneAuthCheckCommand).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 +}
  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 PhoneAuthResetPasswordCommand struct {
  12 + // 手机号码
  13 + Phone string `cname:"手机号码" json:"phone" valid:"Required"`
  14 + // 密码
  15 + Password string `cname:"密码" json:"password" valid:"Required"`
  16 +}
  17 +
  18 +func (phoneAuthResetPasswordCommand *PhoneAuthResetPasswordCommand) Valid(validation *validation.Validation) {
  19 +
  20 +}
  21 +
  22 +func (phoneAuthResetPasswordCommand *PhoneAuthResetPasswordCommand) ValidateCommand() error {
  23 + valid := validation.Validation{}
  24 + b, err := valid.Valid(phoneAuthResetPasswordCommand)
  25 + if err != nil {
  26 + return err
  27 + }
  28 + if !b {
  29 + elem := reflect.TypeOf(phoneAuthResetPasswordCommand).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 +}
  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 PhoneAuthResetPhoneCommand struct {
  12 + // 用户Id 用户唯一标识
  13 + UserId int64 `cname:"用户Id 用户唯一标识" json:"userId"`
  14 + OldPhone string `cname:"" json:"oldPhone" valid:"Required"`
  15 + NewPhone string `cname:"" json:"newPhone" valid:"Required"`
  16 +}
  17 +
  18 +func (phoneAuthResetPhoneCommand *PhoneAuthResetPhoneCommand) Valid(validation *validation.Validation) {
  19 +
  20 +}
  21 +
  22 +func (phoneAuthResetPhoneCommand *PhoneAuthResetPhoneCommand) ValidateCommand() error {
  23 + valid := validation.Validation{}
  24 + b, err := valid.Valid(phoneAuthResetPhoneCommand)
  25 + if err != nil {
  26 + return err
  27 + }
  28 + if !b {
  29 + elem := reflect.TypeOf(phoneAuthResetPhoneCommand).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 +}
  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 RefreshIMCommand struct {
  12 + // 手机号码
  13 + Phone string `cname:"手机号码" json:"phone" valid:"Required"`
  14 + // 刷新标识 0:刷新IM信息,并返回 1:使用旧的im信息
  15 + RefreshFlag int `cname:"刷新标识" json:"refreshFlag"`
  16 +}
  17 +
  18 +func (refreshIMCommand *RefreshIMCommand) Valid(validation *validation.Validation) {
  19 +
  20 +}
  21 +
  22 +func (refreshIMCommand *RefreshIMCommand) ValidateCommand() error {
  23 + valid := validation.Validation{}
  24 + b, err := valid.Valid(refreshIMCommand)
  25 + if err != nil {
  26 + return err
  27 + }
  28 + if !b {
  29 + elem := reflect.TypeOf(refreshIMCommand).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 +}
  1 +package dto
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
  5 +)
  6 +
  7 +type UserBaseDto struct {
  8 + // 用户基础数据id
  9 + UserBaseId int64 `json:"userBaseId,omitempty"`
  10 + UserType int `json:"userType"`
  11 + // 用户信息
  12 + UserInfo *domain.UserInfo `json:"userInfo,omitempty"`
  13 + // 手机号码
  14 + //Account string `json:"phone,omitempty"`
  15 + // 密码
  16 + //Password string `json:"password,omitempty"`
  17 + // IM信息
  18 + Im *domain.Im `json:"im,omitempty"`
  19 + // 关联的用户 (冗余)
  20 + //RelatedUsers []int64 `json:"relatedUsers,omitempty"`
  21 + // 账号状态 1:正常 2.禁用 3:注销
  22 + //Status int `json:"status,omitempty"`
  23 + // 创建时间
  24 + //CreatedAt time.Time `json:"createdAt,omitempty"`
  25 + // 更新时间
  26 + //UpdatedAt time.Time `json:"updatedAt,omitempty"`
  27 +}
  28 +
  29 +func (u *UserBaseDto) LoadDto(ub *domain.UserBase) {
  30 + u.UserBaseId = ub.UserBaseId
  31 + u.UserInfo = ub.UserInfo
  32 + u.UserType = domain.UserTypeVisitor
  33 + u.Im = ub.Im
  34 +}
  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 UserInfoQuery struct {
  12 + Account string `cname:"账号" json:"account"`
  13 + UserBaseId int64 `cname:"用户编号" json:"userBaseId"`
  14 +}
  15 +
  16 +func (userInfoQuery *UserInfoQuery) Valid(validation *validation.Validation) {
  17 + //validation.SetError("CustomValid", "未实现的自定义认证")
  18 + if len(userInfoQuery.Account) == 0 && userInfoQuery.UserBaseId <= 0 {
  19 + validation.SetError("CustomValid", "参数不能为空")
  20 + }
  21 +}
  22 +
  23 +func (userInfoQuery *UserInfoQuery) ValidateQuery() error {
  24 + valid := validation.Validation{}
  25 + b, err := valid.Valid(userInfoQuery)
  26 + if err != nil {
  27 + return err
  28 + }
  29 + if !b {
  30 + elem := reflect.TypeOf(userInfoQuery).Elem()
  31 + for _, validErr := range valid.Errors {
  32 + field, isExist := elem.FieldByName(validErr.Field)
  33 + if isExist {
  34 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  35 + } else {
  36 + return fmt.Errorf(validErr.Message)
  37 + }
  38 + }
  39 + }
  40 + return nil
  41 +}
  1 +package service
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/core/application"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/auth/command"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/auth/dto"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/auth/query"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/factory"
  9 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
  10 + "strconv"
  11 + "time"
  12 +)
  13 +
  14 +// 认证服务
  15 +type AuthService struct {
  16 +}
  17 +
  18 +// 企业注册
  19 +func (authService *AuthService) CompanySignUp(companySignUpCommand *command.CompanySignUpCommand) (interface{}, error) {
  20 + if err := companySignUpCommand.ValidateCommand(); err != nil {
  21 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  22 + }
  23 + transactionContext, err := factory.CreateTransactionContext(nil)
  24 + if err != nil {
  25 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  26 + }
  27 + if err := transactionContext.StartTransaction(); err != nil {
  28 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  29 + }
  30 + defer func() {
  31 + transactionContext.RollbackTransaction()
  32 + }()
  33 +
  34 + //var user *domain.User
  35 + signUpCompanyService, err := factory.CreateSignUpCompanyService(map[string]interface{}{
  36 + "transactionContext": transactionContext,
  37 + })
  38 + if err != nil {
  39 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  40 + }
  41 + companyInfo := &domain.CompanyInfo{
  42 + CompanyName: companySignUpCommand.CompanyName,
  43 + Scale: companySignUpCommand.Scale,
  44 + Logo: "",
  45 + Address: "",
  46 + IndustryCategory: companySignUpCommand.IndustryCategory,
  47 + RegisteredTime: time.Now(),
  48 + }
  49 + userInfo := &domain.UserInfo{
  50 + UserName: companySignUpCommand.Contacts,
  51 + Phone: companySignUpCommand.Phone,
  52 + }
  53 + if _, err = signUpCompanyService.SignUpCompany(companySignUpCommand.Phone, companySignUpCommand.Password, companyInfo, userInfo); err != nil {
  54 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  55 + }
  56 + if err := transactionContext.CommitTransaction(); err != nil {
  57 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  58 + }
  59 + return struct{}{}, nil
  60 +}
  61 +
  62 +// 注销账号 (添加用户时重新激活)
  63 +func (authService *AuthService) DestroyAccount(destroyAccountCommand *command.DestroyAccountCommand) (interface{}, error) {
  64 + if err := destroyAccountCommand.ValidateCommand(); err != nil {
  65 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  66 + }
  67 + transactionContext, err := factory.CreateTransactionContext(nil)
  68 + if err != nil {
  69 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  70 + }
  71 + if err := transactionContext.StartTransaction(); err != nil {
  72 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  73 + }
  74 + defer func() {
  75 + transactionContext.RollbackTransaction()
  76 + }()
  77 +
  78 + accountDestroyService, err := factory.CreatePgAuthAccountDestroyService(map[string]interface{}{
  79 + "transactionContext": transactionContext,
  80 + })
  81 + if err != nil {
  82 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  83 + }
  84 + if err := accountDestroyService.DestroyAccount(nil, destroyAccountCommand.Account); err != nil {
  85 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  86 + }
  87 +
  88 + if err := transactionContext.CommitTransaction(); err != nil {
  89 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  90 + }
  91 + return struct{}{}, nil
  92 +}
  93 +
  94 +// 修改密码
  95 +func (authService *AuthService) PhoneAuthChangePassword(phoneAuthChangePasswordCommand *command.PhoneAuthChangePasswordCommand) (interface{}, error) {
  96 + if err := phoneAuthChangePasswordCommand.ValidateCommand(); err != nil {
  97 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  98 + }
  99 + transactionContext, err := factory.CreateTransactionContext(nil)
  100 + if err != nil {
  101 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  102 + }
  103 + if err := transactionContext.StartTransaction(); err != nil {
  104 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  105 + }
  106 + defer func() {
  107 + transactionContext.RollbackTransaction()
  108 + }()
  109 + var userRepository domain.UserRepository
  110 + if value, err := factory.CreateUserRepository(map[string]interface{}{
  111 + "transactionContext": transactionContext,
  112 + }); err != nil {
  113 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  114 + } else {
  115 + userRepository = value
  116 + }
  117 + var userBaseId int64
  118 + if user, err := userRepository.FindOne(map[string]interface{}{"userId": phoneAuthChangePasswordCommand.UserId}); err != nil {
  119 + if err == domain.ErrorNotFound {
  120 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "该用户不存在")
  121 + }
  122 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  123 + } else {
  124 + userBaseId = user.UserBaseId
  125 + }
  126 +
  127 + var userBaseRepository domain.UserBaseRepository
  128 + if value, err := factory.CreateUserBaseRepository(map[string]interface{}{
  129 + "transactionContext": transactionContext,
  130 + }); err != nil {
  131 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  132 + } else {
  133 + userBaseRepository = value
  134 + }
  135 + userBase, err := userBaseRepository.FindOne(map[string]interface{}{"userBaseId": userBaseId})
  136 + if err != nil {
  137 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  138 + }
  139 + if err == domain.ErrorNotFound {
  140 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "该用户不存在")
  141 + }
  142 + if err := userBase.CheckAccountPassword(userBase.Account, phoneAuthChangePasswordCommand.OldPassword); err != nil {
  143 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  144 + }
  145 + if err := userBase.ResetPassword(userBase.Account, phoneAuthChangePasswordCommand.NewPassword); err != nil {
  146 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  147 + }
  148 + if _, err = userBaseRepository.Save(userBase); err != nil {
  149 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  150 + }
  151 +
  152 + if err := transactionContext.CommitTransaction(); err != nil {
  153 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  154 + }
  155 + return struct {
  156 + }{}, nil
  157 +}
  158 +
  159 +// 手机账号密码检查
  160 +func (authService *AuthService) PhoneAuthCheck(phoneAuthCheckCommand *command.PhoneAuthCheckCommand) (interface{}, error) {
  161 + if err := phoneAuthCheckCommand.ValidateCommand(); err != nil {
  162 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  163 + }
  164 + transactionContext, err := factory.CreateTransactionContext(nil)
  165 + if err != nil {
  166 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  167 + }
  168 + if err := transactionContext.StartTransaction(); err != nil {
  169 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  170 + }
  171 + defer func() {
  172 + transactionContext.RollbackTransaction()
  173 + }()
  174 +
  175 + var userBaseRepository domain.UserBaseRepository
  176 + if value, err := factory.CreateUserBaseRepository(map[string]interface{}{
  177 + "transactionContext": transactionContext,
  178 + }); err != nil {
  179 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  180 + } else {
  181 + userBaseRepository = value
  182 + }
  183 + userBase, err := userBaseRepository.FindOne(map[string]interface{}{"account": phoneAuthCheckCommand.Phone})
  184 + if err != nil {
  185 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  186 + }
  187 + if err == domain.ErrorNotFound {
  188 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "该用户不存在")
  189 + }
  190 + if err := userBase.CheckAccountPassword(phoneAuthCheckCommand.Phone, phoneAuthCheckCommand.Password); err != nil {
  191 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  192 + }
  193 +
  194 + if err := transactionContext.CommitTransaction(); err != nil {
  195 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  196 + }
  197 + return userBase, nil
  198 +}
  199 +
  200 +// 重置密码(忘记密码)
  201 +func (authService *AuthService) PhoneAuthResetPassword(phoneAuthResetPasswordCommand *command.PhoneAuthResetPasswordCommand) (interface{}, error) {
  202 + if err := phoneAuthResetPasswordCommand.ValidateCommand(); err != nil {
  203 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  204 + }
  205 + transactionContext, err := factory.CreateTransactionContext(nil)
  206 + if err != nil {
  207 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  208 + }
  209 + if err := transactionContext.StartTransaction(); err != nil {
  210 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  211 + }
  212 + defer func() {
  213 + transactionContext.RollbackTransaction()
  214 + }()
  215 +
  216 + var userBaseRepository domain.UserBaseRepository
  217 + if value, err := factory.CreateUserBaseRepository(map[string]interface{}{
  218 + "transactionContext": transactionContext,
  219 + }); err != nil {
  220 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  221 + } else {
  222 + userBaseRepository = value
  223 + }
  224 + userBase, err := userBaseRepository.FindOne(map[string]interface{}{"account": phoneAuthResetPasswordCommand.Phone})
  225 + if err != nil {
  226 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  227 + }
  228 + if err == domain.ErrorNotFound {
  229 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "该用户不存在")
  230 + }
  231 + if err := userBase.ResetPassword(phoneAuthResetPasswordCommand.Phone, phoneAuthResetPasswordCommand.Password); err != nil {
  232 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  233 + }
  234 +
  235 + if _, err = userBaseRepository.Save(userBase); err != nil {
  236 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  237 + }
  238 +
  239 + if err := transactionContext.CommitTransaction(); err != nil {
  240 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  241 + }
  242 + return struct{}{}, nil
  243 +}
  244 +
  245 +// 重置手机号
  246 +func (authService *AuthService) PhoneAuthResetPhone(phoneAuthResetPhoneCommand *command.PhoneAuthResetPhoneCommand) (interface{}, error) {
  247 + if err := phoneAuthResetPhoneCommand.ValidateCommand(); err != nil {
  248 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  249 + }
  250 + transactionContext, err := factory.CreateTransactionContext(nil)
  251 + if err != nil {
  252 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  253 + }
  254 + if err := transactionContext.StartTransaction(); err != nil {
  255 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  256 + }
  257 + defer func() {
  258 + transactionContext.RollbackTransaction()
  259 + }()
  260 +
  261 + resetPhoneService, err := factory.CreatePgAuthResetPhoneService(map[string]interface{}{
  262 + "transactionContext": transactionContext,
  263 + })
  264 + if err != nil {
  265 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  266 + }
  267 + if err := resetPhoneService.ResetPhone(nil, phoneAuthResetPhoneCommand.OldPhone, phoneAuthResetPhoneCommand.NewPhone); err != nil {
  268 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  269 + }
  270 + if err := transactionContext.CommitTransaction(); err != nil {
  271 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  272 + }
  273 + return struct{}{}, nil
  274 +}
  275 +
  276 +// 刷新IM信息
  277 +func (authService *AuthService) RefreshIM(refreshIMCommand *command.RefreshIMCommand) (interface{}, error) {
  278 + if err := refreshIMCommand.ValidateCommand(); err != nil {
  279 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  280 + }
  281 + transactionContext, err := factory.CreateTransactionContext(nil)
  282 + if err != nil {
  283 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  284 + }
  285 + if err := transactionContext.StartTransaction(); err != nil {
  286 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  287 + }
  288 + defer func() {
  289 + transactionContext.RollbackTransaction()
  290 + }()
  291 +
  292 + imService, _ := factory.CreatePgImService(map[string]interface{}{
  293 + "transactionContext": transactionContext,
  294 + })
  295 + userId, _ := strconv.Atoi(refreshIMCommand.Phone)
  296 + imInfo, err := imService.InitOrUpdateUserIMInfo(int64(userId), refreshIMCommand.RefreshFlag)
  297 + if err != nil {
  298 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  299 + }
  300 + if err := transactionContext.CommitTransaction(); err != nil {
  301 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  302 + }
  303 + return imInfo, nil
  304 +}
  305 +
  306 +// 用户信息
  307 +func (authService *AuthService) UserInfo(userInfoQuery *query.UserInfoQuery) (interface{}, error) {
  308 + if err := userInfoQuery.ValidateQuery(); err != nil {
  309 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  310 + }
  311 + transactionContext, err := factory.CreateTransactionContext(nil)
  312 + if err != nil {
  313 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  314 + }
  315 + if err := transactionContext.StartTransaction(); err != nil {
  316 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  317 + }
  318 + defer func() {
  319 + transactionContext.RollbackTransaction()
  320 + }()
  321 +
  322 + var userBase *domain.UserBase
  323 + userBaseRepository, _, _ := factory.FastPgUserBase(transactionContext, 0)
  324 + if len(userInfoQuery.Account) > 0 {
  325 + userBase, err = userBaseRepository.FindOne(map[string]interface{}{"account": userInfoQuery.Account})
  326 + } else if userInfoQuery.UserBaseId > 0 {
  327 + userBase, err = userBaseRepository.FindOne(map[string]interface{}{"userBaseId": userInfoQuery.UserBaseId})
  328 + }
  329 + if err != nil {
  330 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  331 + }
  332 + ubDto := &dto.UserBaseDto{}
  333 + ubDto.LoadDto(userBase)
  334 + if err := transactionContext.CommitTransaction(); err != nil {
  335 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  336 + }
  337 + return ubDto, nil
  338 +}
  339 +
  340 +func NewAuthService(options map[string]interface{}) *AuthService {
  341 + newAuthService := &AuthService{}
  342 + return newAuthService
  343 +}
  1 +package service
  2 +
  3 +type CommonService struct {
  4 +}
  5 +
  6 +// 创建菜单服务
  7 +func (commonService *CommonService) DictionarySearch(codes []string) (interface{}, error) {
  8 + type dictItem struct {
  9 + ItemCode string `json:"itemCode"`
  10 + ItemValue string `json:"itemValue"`
  11 + }
  12 + dictionaries := make([]interface{}, 0)
  13 + for i := range codes {
  14 + switch codes[i] {
  15 + case "MenuType":
  16 + dictionaries = append(dictionaries, map[string]interface{}{
  17 + "dictName": "菜单类型",
  18 + "dictItems": []dictItem{
  19 + {"目录", "catalog"},
  20 + {"菜单", "menu"},
  21 + {"按钮", "button"},
  22 + },
  23 + })
  24 + }
  25 + }
  26 + return map[string]interface{}{"dictionary": dictionaries}, nil
  27 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 + "time"
  8 +
  9 + "github.com/beego/beego/v2/core/validation"
  10 +)
  11 +
  12 +type CreateCompanyCommand struct {
  13 + // 企业名称
  14 + CompanyName string `cname:"企业名称" json:"companyName" valid:"Required"`
  15 + // 规模
  16 + Scale string `cname:"规模" json:"scale" valid:"Required"`
  17 + // 公司Logo地址
  18 + Logo string `cname:"公司Logo地址" json:"logo" valid:"Required"`
  19 + // 公司地址
  20 + Address string `cname:"公司地址" json:"address" valid:"Required"`
  21 + // 所属行业
  22 + IndustryCategory string `cname:"所属行业" json:"industryCategory" valid:"Required"`
  23 + // 联系人
  24 + Contacts string `cname:"联系人" json:"contacts" valid:"Required"`
  25 + // 注册时间
  26 + RegisteredTime time.Time `cname:"注册时间" json:"registeredTime,omitempty"`
  27 + // 注册状态 1:已注册 2:待认证 3:已认证
  28 + Status int `cname:"注册状态 1:已注册 2:待认证 3:已认证" json:"status,omitempty"`
  29 +}
  30 +
  31 +func (createCompanyCommand *CreateCompanyCommand) Valid(validation *validation.Validation) {
  32 + validation.SetError("CustomValid", "未实现的自定义认证")
  33 +}
  34 +
  35 +func (createCompanyCommand *CreateCompanyCommand) ValidateCommand() error {
  36 + valid := validation.Validation{}
  37 + b, err := valid.Valid(createCompanyCommand)
  38 + if err != nil {
  39 + return err
  40 + }
  41 + if !b {
  42 + elem := reflect.TypeOf(createCompanyCommand).Elem()
  43 + for _, validErr := range valid.Errors {
  44 + field, isExist := elem.FieldByName(validErr.Field)
  45 + if isExist {
  46 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  47 + } else {
  48 + return fmt.Errorf(validErr.Message)
  49 + }
  50 + }
  51 + }
  52 + return nil
  53 +}
  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 ListCompanyCustomizeMenusCommand struct {
  12 + // 企业id
  13 + CompanyId int64 `cname:"企业id" json:"companyId,string" valid:"Required"`
  14 + // 菜单类别 web app
  15 + MenuCategory string `cname:"菜单类别" json:"menuCategory,omitempty" valid:"Required"`
  16 +}
  17 +
  18 +func (listCompanyCustomizeMenusCommand *ListCompanyCustomizeMenusCommand) Valid(validation *validation.Validation) {
  19 +
  20 +}
  21 +
  22 +func (listCompanyCustomizeMenusCommand *ListCompanyCustomizeMenusCommand) ValidateCommand() error {
  23 + valid := validation.Validation{}
  24 + b, err := valid.Valid(listCompanyCustomizeMenusCommand)
  25 + if err != nil {
  26 + return err
  27 + }
  28 + if !b {
  29 + elem := reflect.TypeOf(listCompanyCustomizeMenusCommand).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 +}
  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 RemoveCompanyCommand struct {
  12 + // 企业id
  13 + CompanyId int64 `cname:"企业id" json:"companyId,string" valid:"Required"`
  14 +}
  15 +
  16 +func (removeCompanyCommand *RemoveCompanyCommand) Valid(validation *validation.Validation) {
  17 + validation.SetError("CustomValid", "未实现的自定义认证")
  18 +}
  19 +
  20 +func (removeCompanyCommand *RemoveCompanyCommand) ValidateCommand() error {
  21 + valid := validation.Validation{}
  22 + b, err := valid.Valid(removeCompanyCommand)
  23 + if err != nil {
  24 + return err
  25 + }
  26 + if !b {
  27 + elem := reflect.TypeOf(removeCompanyCommand).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 UpdateCompanyCommand struct {
  12 + // 企业id
  13 + CompanyId int64 `cname:"企业id" json:"companyId,string" valid:"Required"`
  14 + // 企业名称
  15 + CompanyName string `cname:"企业名称" json:"companyName" valid:"Required"`
  16 + // 公司地址
  17 + Address string `cname:"公司地址" json:"address" valid:"Required"`
  18 + // 系统名称
  19 + SystemName string `cname:"系统名称" json:"systemName" valid:"Required"`
  20 + // 公司Logo地址
  21 + Logo string `cname:"公司Logo地址" json:"logo" valid:"Required"`
  22 +}
  23 +
  24 +func (updateCompanyCommand *UpdateCompanyCommand) Valid(validation *validation.Validation) {
  25 + //validation.SetError("CustomValid", "未实现的自定义认证")
  26 +}
  27 +
  28 +func (updateCompanyCommand *UpdateCompanyCommand) ValidateCommand() error {
  29 + valid := validation.Validation{}
  30 + b, err := valid.Valid(updateCompanyCommand)
  31 + if err != nil {
  32 + return err
  33 + }
  34 + if !b {
  35 + elem := reflect.TypeOf(updateCompanyCommand).Elem()
  36 + for _, validErr := range valid.Errors {
  37 + field, isExist := elem.FieldByName(validErr.Field)
  38 + if isExist {
  39 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  40 + } else {
  41 + return fmt.Errorf(validErr.Message)
  42 + }
  43 + }
  44 + }
  45 + return nil
  46 +}
  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 UpdateCompanyCustomizeMenusCommand struct {
  12 + // 企业id
  13 + CompanyId int64 `cname:"企业id" json:"companyId" valid:"Required"`
  14 + // 菜单编号
  15 + MenuId int64 `cname:"菜单编号" json:"menuId" valid:"Required"`
  16 + // 菜单名称
  17 + //MenuName string `cname:"菜单名称" json:"menuName" valid:"Required"`
  18 + // 菜单别名
  19 + MenuAlias string `cname:"菜单别名" json:"menuAlias" valid:"Required"`
  20 + // 排序
  21 + Sort int `cname:"排序" json:"sort" valid:"Required"`
  22 +}
  23 +
  24 +func (updateCompanyCustomizeMenusCommand *UpdateCompanyCustomizeMenusCommand) Valid(validation *validation.Validation) {
  25 + //validation.SetError("CustomValid", "未实现的自定义认证")
  26 +}
  27 +
  28 +func (updateCompanyCustomizeMenusCommand *UpdateCompanyCustomizeMenusCommand) ValidateCommand() error {
  29 + valid := validation.Validation{}
  30 + b, err := valid.Valid(updateCompanyCustomizeMenusCommand)
  31 + if err != nil {
  32 + return err
  33 + }
  34 + if !b {
  35 + elem := reflect.TypeOf(updateCompanyCustomizeMenusCommand).Elem()
  36 + for _, validErr := range valid.Errors {
  37 + field, isExist := elem.FieldByName(validErr.Field)
  38 + if isExist {
  39 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  40 + } else {
  41 + return fmt.Errorf(validErr.Message)
  42 + }
  43 + }
  44 + }
  45 + return nil
  46 +}
  1 +package dto
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/utils"
  6 +)
  7 +
  8 +type CustomizeMenuDto struct {
  9 +}
  10 +
  11 +func (dto *CustomizeMenuDto) LoadDto(menus []*domain.Menu, customizeMenus []*domain.CustomizeMenu, rootMenu *domain.Menu) (interface{}, error) {
  12 + var ret []interface{}
  13 + ret = append(ret, rootMenu)
  14 + menusMap := make(map[int64]*domain.Menu)
  15 + menusMap[rootMenu.MenuId] = rootMenu
  16 + for i := range menus {
  17 + menusMap[menus[i].MenuId] = menus[i]
  18 + }
  19 +
  20 + for i := range customizeMenus {
  21 + m := customizeMenus[i]
  22 + if menu, ok := menusMap[m.MenuId]; ok {
  23 + menu.MenuAlias = m.MenuAlias
  24 + menu.Sort = m.Sort
  25 + }
  26 + }
  27 +
  28 + for i := range menus {
  29 + fieldMenu := utils.LoadCustomFieldToMap(menus[i], "MenuId", "ParentId", "MenuName", "Code", "Icon", "MenuAlias", "MenuType", "Remark", "Sort", "EnableStatus")
  30 + fieldMenu["parentMenuName"] = ""
  31 + if menu, ok := menusMap[menus[i].ParentId]; ok {
  32 + fieldMenu["parentMenuName"] = menu.MenuName
  33 + }
  34 + ret = append(ret, fieldMenu)
  35 + }
  36 + return ret, nil
  37 +}
  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 GetCompanyQuery struct {
  12 + // 企业id
  13 + CompanyId int64 `cname:"企业id" json:"companyId,string" valid:"Required"`
  14 +}
  15 +
  16 +func (getCompanyQuery *GetCompanyQuery) Valid(validation *validation.Validation) {
  17 + //validation.SetError("CustomValid", "未实现的自定义认证")
  18 +}
  19 +
  20 +func (getCompanyQuery *GetCompanyQuery) ValidateQuery() error {
  21 + valid := validation.Validation{}
  22 + b, err := valid.Valid(getCompanyQuery)
  23 + if err != nil {
  24 + return err
  25 + }
  26 + if !b {
  27 + elem := reflect.TypeOf(getCompanyQuery).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 query
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type ListCompanyQuery struct {
  12 + // 查询偏离量
  13 + Offset int `cname:"查询偏离量" json:"offset" valid:"Required"`
  14 + // 查询限制
  15 + Limit int `cname:"查询限制" json:"limit" valid:"Required"`
  16 +}
  17 +
  18 +func (listCompanyQuery *ListCompanyQuery) Valid(validation *validation.Validation) {
  19 + //validation.SetError("CustomValid", "未实现的自定义认证")
  20 +}
  21 +
  22 +func (listCompanyQuery *ListCompanyQuery) ValidateQuery() error {
  23 + valid := validation.Validation{}
  24 + b, err := valid.Valid(listCompanyQuery)
  25 + if err != nil {
  26 + return err
  27 + }
  28 + if !b {
  29 + elem := reflect.TypeOf(listCompanyQuery).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 +}
  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/allied-creation-user/pkg/application/company/command"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/company/dto"
  9 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/company/query"
  10 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/factory"
  11 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
  12 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/common"
  13 + "strconv"
  14 +)
  15 +
  16 +// 企业
  17 +type CompanyService struct {
  18 +}
  19 +
  20 +// 创建企业
  21 +func (companyService *CompanyService) CreateCompany(createCompanyCommand *command.CreateCompanyCommand) (interface{}, error) {
  22 + if err := createCompanyCommand.ValidateCommand(); err != nil {
  23 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  24 + }
  25 + transactionContext, err := factory.CreateTransactionContext(nil)
  26 + if err != nil {
  27 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  28 + }
  29 + if err := transactionContext.StartTransaction(); err != nil {
  30 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  31 + }
  32 + defer func() {
  33 + transactionContext.RollbackTransaction()
  34 + }()
  35 + newCompany := &domain.Company{
  36 + //CompanyInfo: createCompanyCommand.CompanyInfo,
  37 + }
  38 + var companyRepository domain.CompanyRepository
  39 + if value, err := factory.CreateCompanyRepository(map[string]interface{}{
  40 + "transactionContext": transactionContext,
  41 + }); err != nil {
  42 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  43 + } else {
  44 + companyRepository = value
  45 + }
  46 + if company, err := companyRepository.Save(newCompany); err != nil {
  47 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  48 + } else {
  49 + if err := transactionContext.CommitTransaction(); err != nil {
  50 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  51 + }
  52 + return company, nil
  53 + }
  54 +}
  55 +
  56 +// 返回企业
  57 +func (companyService *CompanyService) GetCompany(getCompanyQuery *query.GetCompanyQuery) (interface{}, error) {
  58 + if err := getCompanyQuery.ValidateQuery(); err != nil {
  59 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  60 + }
  61 + transactionContext, err := factory.CreateTransactionContext(nil)
  62 + if err != nil {
  63 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  64 + }
  65 + if err := transactionContext.StartTransaction(); err != nil {
  66 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  67 + }
  68 + defer func() {
  69 + transactionContext.RollbackTransaction()
  70 + }()
  71 + var companyRepository domain.CompanyRepository
  72 + if value, err := factory.CreateCompanyRepository(map[string]interface{}{
  73 + "transactionContext": transactionContext,
  74 + }); err != nil {
  75 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  76 + } else {
  77 + companyRepository = value
  78 + }
  79 + company, err := companyRepository.FindOne(map[string]interface{}{"companyId": getCompanyQuery.CompanyId})
  80 + if err != nil {
  81 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  82 + }
  83 + if company == nil {
  84 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getCompanyQuery.CompanyId)))
  85 + } else {
  86 + if err := transactionContext.CommitTransaction(); err != nil {
  87 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  88 + }
  89 + return company, nil
  90 + }
  91 +}
  92 +
  93 +// 返回企业列表
  94 +func (companyService *CompanyService) ListCompany(listCompanyQuery *query.ListCompanyQuery) (interface{}, error) {
  95 + if err := listCompanyQuery.ValidateQuery(); err != nil {
  96 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  97 + }
  98 + transactionContext, err := factory.CreateTransactionContext(nil)
  99 + if err != nil {
  100 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  101 + }
  102 + if err := transactionContext.StartTransaction(); err != nil {
  103 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  104 + }
  105 + defer func() {
  106 + transactionContext.RollbackTransaction()
  107 + }()
  108 + var companyRepository domain.CompanyRepository
  109 + if value, err := factory.CreateCompanyRepository(map[string]interface{}{
  110 + "transactionContext": transactionContext,
  111 + }); err != nil {
  112 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  113 + } else {
  114 + companyRepository = value
  115 + }
  116 + if count, companys, err := companyRepository.Find(tool_funs.SimpleStructToMap(listCompanyQuery)); err != nil {
  117 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  118 + } else {
  119 + if err := transactionContext.CommitTransaction(); err != nil {
  120 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  121 + }
  122 + return map[string]interface{}{
  123 + "count": count,
  124 + "companys": companys,
  125 + }, nil
  126 + }
  127 +}
  128 +
  129 +// 返回自定义菜单列表(匹配有设置的菜单)
  130 +func (companyService *CompanyService) ListCompanyCustomizeMenus(listCompanyCustomizeMenusCommand *command.ListCompanyCustomizeMenusCommand) (interface{}, error) {
  131 + if err := listCompanyCustomizeMenusCommand.ValidateCommand(); err != nil {
  132 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  133 + }
  134 + transactionContext, err := factory.CreateTransactionContext(nil)
  135 + if err != nil {
  136 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  137 + }
  138 + if err := transactionContext.StartTransaction(); err != nil {
  139 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  140 + }
  141 + defer func() {
  142 + transactionContext.RollbackTransaction()
  143 + }()
  144 +
  145 + var menuRepository domain.MenuRepository
  146 + if value, err := factory.CreateMenuRepository(map[string]interface{}{
  147 + "transactionContext": transactionContext,
  148 + }); err != nil {
  149 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  150 + } else {
  151 + menuRepository = value
  152 + }
  153 + queryOptions := common.SimpleStructToMap(listCompanyCustomizeMenusCommand)
  154 + var menuCategory *domain.Menu
  155 + if m, e := menuRepository.FindOne(map[string]interface{}{"code": listCompanyCustomizeMenusCommand.MenuCategory}); e == nil && m != nil {
  156 + queryOptions["category"] = strconv.Itoa(int(m.MenuId))
  157 + menuCategory = m
  158 + }
  159 + queryOptions["menuTypeIn"] = []string{"catalog", "menu"}
  160 + queryOptions["isPublish"] = domain.MenuPublic
  161 + _, menus, err := menuRepository.Find(queryOptions)
  162 + if err != nil {
  163 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  164 + }
  165 + var customizeMenuRepository domain.CustomizeMenuRepository
  166 + if value, err := factory.CreateCustomizeMenuRepository(map[string]interface{}{
  167 + "transactionContext": transactionContext,
  168 + }); err != nil {
  169 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  170 + } else {
  171 + customizeMenuRepository = value
  172 + }
  173 + _, customizeMenus, err := customizeMenuRepository.Find(queryOptions)
  174 + if err != nil {
  175 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  176 + }
  177 + customizeMenuDto := dto.CustomizeMenuDto{}
  178 + ret, _ := customizeMenuDto.LoadDto(menus, customizeMenus, menuCategory)
  179 +
  180 + if err := transactionContext.CommitTransaction(); err != nil {
  181 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  182 + }
  183 + return map[string]interface{}{"menus": ret}, nil
  184 +}
  185 +
  186 +// 移除企业
  187 +func (companyService *CompanyService) RemoveCompany(removeCompanyCommand *command.RemoveCompanyCommand) (interface{}, error) {
  188 + if err := removeCompanyCommand.ValidateCommand(); err != nil {
  189 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  190 + }
  191 + transactionContext, err := factory.CreateTransactionContext(nil)
  192 + if err != nil {
  193 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  194 + }
  195 + if err := transactionContext.StartTransaction(); err != nil {
  196 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  197 + }
  198 + defer func() {
  199 + transactionContext.RollbackTransaction()
  200 + }()
  201 + var companyRepository domain.CompanyRepository
  202 + if value, err := factory.CreateCompanyRepository(map[string]interface{}{
  203 + "transactionContext": transactionContext,
  204 + }); err != nil {
  205 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  206 + } else {
  207 + companyRepository = value
  208 + }
  209 + company, err := companyRepository.FindOne(map[string]interface{}{"companyId": removeCompanyCommand.CompanyId})
  210 + if err != nil {
  211 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  212 + }
  213 + if company == nil {
  214 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeCompanyCommand.CompanyId)))
  215 + }
  216 + if company, err := companyRepository.Remove(company); err != nil {
  217 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  218 + } else {
  219 + if err := transactionContext.CommitTransaction(); err != nil {
  220 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  221 + }
  222 + return company, nil
  223 + }
  224 +}
  225 +
  226 +// 更新企业
  227 +func (companyService *CompanyService) UpdateCompany(updateCompanyCommand *command.UpdateCompanyCommand) (interface{}, error) {
  228 + if err := updateCompanyCommand.ValidateCommand(); err != nil {
  229 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  230 + }
  231 + transactionContext, err := factory.CreateTransactionContext(nil)
  232 + if err != nil {
  233 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  234 + }
  235 + if err := transactionContext.StartTransaction(); err != nil {
  236 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  237 + }
  238 + defer func() {
  239 + transactionContext.RollbackTransaction()
  240 + }()
  241 + var companyRepository domain.CompanyRepository
  242 + if value, err := factory.CreateCompanyRepository(map[string]interface{}{
  243 + "transactionContext": transactionContext,
  244 + }); err != nil {
  245 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  246 + } else {
  247 + companyRepository = value
  248 + }
  249 + company, err := companyRepository.FindOne(map[string]interface{}{"companyId": updateCompanyCommand.CompanyId})
  250 + if err != nil {
  251 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  252 + }
  253 + if company == nil {
  254 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCompanyCommand.CompanyId)))
  255 + }
  256 + if err := company.Update(tool_funs.SimpleStructToMap(updateCompanyCommand)); err != nil {
  257 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  258 + }
  259 +
  260 + orgRepository, _, _ := factory.FastPgOrg(transactionContext, 0)
  261 + if org, err := orgRepository.FindOne(map[string]interface{}{"companyId": updateCompanyCommand.CompanyId, "parentId": 0}); err != nil {
  262 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  263 + } else {
  264 + if org.OrgName != company.CompanyInfo.CompanyName {
  265 + org.Update(map[string]interface{}{"orgName": company.CompanyInfo.CompanyName})
  266 + }
  267 + if _, err := orgRepository.Save(org); err != nil {
  268 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  269 + }
  270 + }
  271 +
  272 + if company, err := companyRepository.Save(company); err != nil {
  273 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  274 + } else {
  275 + if err := transactionContext.CommitTransaction(); err != nil {
  276 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  277 + }
  278 + return company, nil
  279 + }
  280 +}
  281 +
  282 +// 更新自定义菜单
  283 +func (companyService *CompanyService) UpdateCompanyCustomizeMenus(updateCompanyCustomizeMenusCommand *command.UpdateCompanyCustomizeMenusCommand) (interface{}, error) {
  284 + if err := updateCompanyCustomizeMenusCommand.ValidateCommand(); err != nil {
  285 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  286 + }
  287 + transactionContext, err := factory.CreateTransactionContext(nil)
  288 + if err != nil {
  289 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  290 + }
  291 + if err := transactionContext.StartTransaction(); err != nil {
  292 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  293 + }
  294 + defer func() {
  295 + transactionContext.RollbackTransaction()
  296 + }()
  297 +
  298 + var menuRepository domain.MenuRepository
  299 + if value, err := factory.CreateMenuRepository(map[string]interface{}{
  300 + "transactionContext": transactionContext,
  301 + }); err != nil {
  302 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  303 + } else {
  304 + menuRepository = value
  305 + }
  306 + var menuName string
  307 + if menu, err := menuRepository.FindOne(map[string]interface{}{"menuId": updateCompanyCustomizeMenusCommand.MenuId}); err != nil || (menu != nil && menu.IsPublish != domain.MenuPublic) {
  308 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "菜单不存在")
  309 + } else {
  310 + menuName = menu.MenuName
  311 + }
  312 +
  313 + var customizeMenuRepository domain.CustomizeMenuRepository
  314 + if value, err := factory.CreateCustomizeMenuRepository(map[string]interface{}{
  315 + "transactionContext": transactionContext,
  316 + }); err != nil {
  317 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  318 + } else {
  319 + customizeMenuRepository = value
  320 + }
  321 + customizeMenu, e := customizeMenuRepository.FindOne(map[string]interface{}{
  322 + "companyId": updateCompanyCustomizeMenusCommand.CompanyId,
  323 + "menuId": updateCompanyCustomizeMenusCommand.MenuId,
  324 + "isPublish": domain.MenuPublic,
  325 + })
  326 + if e == domain.ErrorNotFound {
  327 + customizeMenu = &domain.CustomizeMenu{
  328 + CompanyId: updateCompanyCustomizeMenusCommand.CompanyId,
  329 + MenuId: updateCompanyCustomizeMenusCommand.MenuId,
  330 + MenuName: menuName,
  331 + MenuAlias: updateCompanyCustomizeMenusCommand.MenuAlias,
  332 + Sort: updateCompanyCustomizeMenusCommand.Sort,
  333 + }
  334 + } else if customizeMenu != nil {
  335 + data := tool_funs.SimpleStructToMap(updateCompanyCustomizeMenusCommand)
  336 + data["menuName"] = menuName
  337 + if err := customizeMenu.Update(data); err != nil {
  338 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  339 + }
  340 + } else {
  341 + return nil, application.ThrowError(application.TRANSACTION_ERROR, e.Error())
  342 + }
  343 + if customizeMenu, err = customizeMenuRepository.Save(customizeMenu); err != nil {
  344 + return nil, application.ThrowError(application.TRANSACTION_ERROR, e.Error())
  345 + }
  346 + if err := transactionContext.CommitTransaction(); err != nil {
  347 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  348 + }
  349 + return customizeMenu, nil
  350 +}
  351 +
  352 +func NewCompanyService(options map[string]interface{}) *CompanyService {
  353 + newCompanyService := &CompanyService{}
  354 + return newCompanyService
  355 +}
1 package factory 1 package factory
  2 +
  3 +import (
  4 + pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain/service"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/domainService"
  8 +)
  9 +
  10 +func CreateSignUpCompanyService(options map[string]interface{}) (service.PgSignUpCompanyService, error) {
  11 + var transactionContext *pgTransaction.TransactionContext
  12 + if value, ok := options["transactionContext"]; ok {
  13 + transactionContext = value.(*pgTransaction.TransactionContext)
  14 + }
  15 + return domainService.NewPgSignUpCompanyServiceService(transactionContext)
  16 +}
  17 +
  18 +func CreatePgAuthResetPhoneService(options map[string]interface{}) (service.PgAuthResetPhoneService, error) {
  19 + var transactionContext *pgTransaction.TransactionContext
  20 + if value, ok := options["transactionContext"]; ok {
  21 + transactionContext = value.(*pgTransaction.TransactionContext)
  22 + }
  23 + return domainService.NewPgAuthResetPhoneService(transactionContext)
  24 +}
  25 +
  26 +func CreatePgAuthAccountDestroyService(options map[string]interface{}) (service.PgAuthAccountDestroyService, error) {
  27 + var transactionContext *pgTransaction.TransactionContext
  28 + if value, ok := options["transactionContext"]; ok {
  29 + transactionContext = value.(*pgTransaction.TransactionContext)
  30 + }
  31 + return domainService.NewPgAuthAccountDestroyService(transactionContext)
  32 +}
  33 +
  34 +func CreatePgCreateUserService(options map[string]interface{}) (service.PgCreateUserService, error) {
  35 + var transactionContext *pgTransaction.TransactionContext
  36 + if value, ok := options["transactionContext"]; ok {
  37 + transactionContext = value.(*pgTransaction.TransactionContext)
  38 + }
  39 + return domainService.NewPgCreateUserService(transactionContext)
  40 +}
  41 +
  42 +func CreatePgDataAuthService(options map[string]interface{}) (domain.DataAuthor, error) {
  43 + var transactionContext *pgTransaction.TransactionContext
  44 + if value, ok := options["transactionContext"]; ok {
  45 + transactionContext = value.(*pgTransaction.TransactionContext)
  46 + }
  47 + return domainService.NewPgDataAuthService(transactionContext)
  48 +}
  49 +
  50 +func CreatePgUpdateUserService(options map[string]interface{}) (service.PgUpdateUserService, error) {
  51 + var transactionContext *pgTransaction.TransactionContext
  52 + if value, ok := options["transactionContext"]; ok {
  53 + transactionContext = value.(*pgTransaction.TransactionContext)
  54 + }
  55 + return domainService.NewPgUpdateUserService(transactionContext)
  56 +}
  57 +
  58 +func CreatePgCreateRoleService(options map[string]interface{}) (service.PgCreateRoleService, error) {
  59 + var transactionContext *pgTransaction.TransactionContext
  60 + if value, ok := options["transactionContext"]; ok {
  61 + transactionContext = value.(*pgTransaction.TransactionContext)
  62 + }
  63 + return domainService.NewPgCreateRoleService(transactionContext)
  64 +}
  65 +
  66 +func CreatePgCreateOrgService(options map[string]interface{}) (service.PgCreateOrgService, error) {
  67 + var transactionContext *pgTransaction.TransactionContext
  68 + if value, ok := options["transactionContext"]; ok {
  69 + transactionContext = value.(*pgTransaction.TransactionContext)
  70 + }
  71 + return domainService.NewPgCreateOrgService(transactionContext)
  72 +}
  73 +
  74 +func CreatePgRoleAccessMenusService(options map[string]interface{}) (service.PgRoleAccessMenusService, error) {
  75 + var transactionContext *pgTransaction.TransactionContext
  76 + if value, ok := options["transactionContext"]; ok {
  77 + transactionContext = value.(*pgTransaction.TransactionContext)
  78 + }
  79 + return domainService.NewPgRoleAccessMenusService(transactionContext)
  80 +}
  81 +
  82 +func CreatePgImService(options map[string]interface{}) (service.PgImService, error) {
  83 + var transactionContext *pgTransaction.TransactionContext
  84 + if value, ok := options["transactionContext"]; ok {
  85 + transactionContext = value.(*pgTransaction.TransactionContext)
  86 + }
  87 + return domainService.NewPgImService(transactionContext)
  88 +}
  89 +
  90 +func CreateBatchAddUserService(options map[string]interface{}) (service.PgBatchAddUserService, error) {
  91 + var transactionContext *pgTransaction.TransactionContext
  92 + if value, ok := options["transactionContext"]; ok {
  93 + transactionContext = value.(*pgTransaction.TransactionContext)
  94 + }
  95 + return domainService.NewPgBatchAddUserService(transactionContext)
  96 +}
  97 +
  98 +func CreatePgBatchRemoveRoleService(options map[string]interface{}) (service.PgBatchRemoveRoleService, error) {
  99 + var transactionContext *pgTransaction.TransactionContext
  100 + if value, ok := options["transactionContext"]; ok {
  101 + transactionContext = value.(*pgTransaction.TransactionContext)
  102 + }
  103 + return domainService.NewPgBatchRemoveRoleService(transactionContext)
  104 +}
  105 +
  106 +func CreatePgBatchAddOrgService(options map[string]interface{}) (service.PgBatchAddOrgService, error) {
  107 + var transactionContext *pgTransaction.TransactionContext
  108 + if value, ok := options["transactionContext"]; ok {
  109 + transactionContext = value.(*pgTransaction.TransactionContext)
  110 + }
  111 + return domainService.NewPgBatchAddOrgService(transactionContext)
  112 +}
  1 +package factory
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/core/application"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
  6 +)
  7 +
  8 +/***** 1.快速模块 *****/
  9 +
  10 +// FastPgUser 快速返回领域用户
  11 +//
  12 +// transactionContext 事务
  13 +// userId 用户ID
  14 +func FastPgUser(transactionContext application.TransactionContext, userId int64, options ...option) (domain.UserRepository, *domain.User, error) {
  15 + var rep domain.UserRepository
  16 + var mod *domain.User
  17 + var err error
  18 + if value, err := CreateUserRepository(map[string]interface{}{
  19 + "transactionContext": transactionContext,
  20 + }); err != nil {
  21 + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  22 + } else {
  23 + rep = value
  24 + }
  25 + if userId > 0 {
  26 + if mod, err = rep.FindOne(map[string]interface{}{"userId": userId}); err != nil {
  27 + if err == domain.ErrorNotFound {
  28 + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该用户不存在")
  29 + }
  30 + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  31 + }
  32 + }
  33 + if err = fastPgDataAuth(transactionContext, mod, options...); err != nil {
  34 + return nil, nil, err
  35 + }
  36 + return rep, mod, err
  37 +}
  38 +
  39 +// FastPgUser 快速返回领域用户基础
  40 +//
  41 +// transactionContext 事务
  42 +// userBaseId 用户基础ID
  43 +func FastPgUserBase(transactionContext application.TransactionContext, userBaseId int64) (domain.UserBaseRepository, *domain.UserBase, error) {
  44 + var rep domain.UserBaseRepository
  45 + var mod *domain.UserBase
  46 + var err error
  47 + if value, err := CreateUserBaseRepository(map[string]interface{}{
  48 + "transactionContext": transactionContext,
  49 + }); err != nil {
  50 + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  51 + } else {
  52 + rep = value
  53 + }
  54 + if userBaseId > 0 {
  55 + if mod, err = rep.FindOne(map[string]interface{}{"userBaseId": userBaseId}); err != nil {
  56 + if err == domain.ErrorNotFound {
  57 + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "用户基础不存在")
  58 + }
  59 + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  60 + }
  61 + }
  62 + return rep, mod, err
  63 +}
  64 +
  65 +// FastPgRole 快速返回领域角色
  66 +//
  67 +// transactionContext 事务
  68 +// roleId 角色Id
  69 +func FastPgRole(transactionContext application.TransactionContext, roleId int64, options ...option) (domain.RoleRepository, *domain.Role, error) {
  70 + var rep domain.RoleRepository
  71 + var mod *domain.Role
  72 + var err error
  73 + if value, err := CreateRoleRepository(map[string]interface{}{
  74 + "transactionContext": transactionContext,
  75 + }); err != nil {
  76 + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  77 + } else {
  78 + rep = value
  79 + }
  80 + if roleId > 0 {
  81 + if mod, err = rep.FindOne(map[string]interface{}{"roleId": roleId}); err != nil {
  82 + if err == domain.ErrorNotFound {
  83 + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该角色不存在")
  84 + }
  85 + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  86 + }
  87 + }
  88 + if err = fastPgDataAuth(transactionContext, mod, options...); err != nil {
  89 + return nil, nil, err
  90 + }
  91 + return rep, mod, err
  92 +}
  93 +
  94 +// FastPgRole 快速返回领域组织
  95 +//
  96 +// transactionContext 事务
  97 +// orgId 组织Id
  98 +func FastPgOrg(transactionContext application.TransactionContext, orgId int64) (domain.OrgRepository, *domain.Org, error) {
  99 + var rep domain.OrgRepository
  100 + var mod *domain.Org
  101 + var err error
  102 + if value, err := CreateOrgRepository(map[string]interface{}{
  103 + "transactionContext": transactionContext,
  104 + }); err != nil {
  105 + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  106 + } else {
  107 + rep = value
  108 + }
  109 + if orgId > 0 {
  110 + if mod, err = rep.FindOne(map[string]interface{}{"orgId": orgId}); err != nil {
  111 + if err == domain.ErrorNotFound {
  112 + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该组织不存在")
  113 + }
  114 + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  115 + }
  116 + }
  117 + return rep, mod, err
  118 +}
  119 +
  120 +// FastPgCompany 快速返回领域公司
  121 +//
  122 +// transactionContext 事务
  123 +// companyId 公司Id
  124 +func FastPgCompany(transactionContext application.TransactionContext, companyId int64) (domain.CompanyRepository, *domain.Company, error) {
  125 + var rep domain.CompanyRepository
  126 + var mod *domain.Company
  127 + var err error
  128 + if value, err := CreateCompanyRepository(map[string]interface{}{
  129 + "transactionContext": transactionContext,
  130 + }); err != nil {
  131 + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  132 + } else {
  133 + rep = value
  134 + }
  135 + if companyId > 0 {
  136 + if mod, err = rep.FindOne(map[string]interface{}{"companyId": companyId}); err != nil {
  137 + if err == domain.ErrorNotFound {
  138 + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该企业不存在")
  139 + }
  140 + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  141 + }
  142 + }
  143 + return rep, mod, err
  144 +}
  145 +
  146 +// FastPgMenu 快速返回领域菜单
  147 +//
  148 +// transactionContext 事务
  149 +// menuId 菜单Id
  150 +func FastPgMenu(transactionContext application.TransactionContext, menuId int64) (domain.MenuRepository, *domain.Menu, error) {
  151 + var rep domain.MenuRepository
  152 + var mod *domain.Menu
  153 + var err error
  154 + if value, err := CreateMenuRepository(map[string]interface{}{
  155 + "transactionContext": transactionContext,
  156 + }); err != nil {
  157 + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  158 + } else {
  159 + rep = value
  160 + }
  161 + if menuId > 0 {
  162 + if mod, err = rep.FindOne(map[string]interface{}{"menuId": menuId}); err != nil {
  163 + if err == domain.ErrorNotFound {
  164 + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该菜单不存在")
  165 + }
  166 + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  167 + }
  168 + }
  169 + return rep, mod, err
  170 +}
  171 +
  172 +// FastPgCustomizeMenu 快速返回领域自定义菜单
  173 +//
  174 +// transactionContext 事务
  175 +// customizeMenuId 自定义菜单Id
  176 +func FastPgCustomizeMenu(transactionContext application.TransactionContext, customizeMenuId int64) (domain.CustomizeMenuRepository, *domain.CustomizeMenu, error) {
  177 + var rep domain.CustomizeMenuRepository
  178 + var mod *domain.CustomizeMenu
  179 + var err error
  180 + if value, err := CreateCustomizeMenuRepository(map[string]interface{}{
  181 + "transactionContext": transactionContext,
  182 + }); err != nil {
  183 + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  184 + } else {
  185 + rep = value
  186 + }
  187 + if customizeMenuId > 0 {
  188 + if mod, err = rep.FindOne(map[string]interface{}{"customizeMenuId": customizeMenuId}); err != nil {
  189 + if err == domain.ErrorNotFound {
  190 + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "自定义菜单不存在")
  191 + }
  192 + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  193 + }
  194 + }
  195 + return rep, mod, err
  196 +}
  197 +
  198 +// FastPgAccountDestroyRecord 快速返回领域账号注销记录
  199 +//
  200 +// transactionContext 事务
  201 +// accountDestroyRecordId 账号注销记录Id
  202 +func FastPgAccountDestroyRecord(transactionContext application.TransactionContext, accountDestroyRecordId int64) (domain.AccountDestroyRecordRepository, *domain.AccountDestroyRecord, error) {
  203 + var rep domain.AccountDestroyRecordRepository
  204 + var mod *domain.AccountDestroyRecord
  205 + var err error
  206 + if value, err := CreateAccountDestroyRecordRepository(map[string]interface{}{
  207 + "transactionContext": transactionContext,
  208 + }); err != nil {
  209 + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  210 + } else {
  211 + rep = value
  212 + }
  213 + if accountDestroyRecordId > 0 {
  214 + if mod, err = rep.FindOne(map[string]interface{}{"accountDestroyRecord": accountDestroyRecordId}); err != nil {
  215 + if err == domain.ErrorNotFound {
  216 + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "账号注销记录不存在")
  217 + }
  218 + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  219 + }
  220 + }
  221 + return rep, mod, err
  222 +}
  223 +
  224 +// fastPgDataAuth 快速数据权限验证
  225 +//
  226 +// data 待认证的数据
  227 +// options 配置项
  228 +func fastPgDataAuth(transactionContext application.TransactionContext, data domain.AuthedData, options ...option) error {
  229 + option := NewFastOptions(options...)
  230 + if option.DataAuthRequired && data != nil {
  231 + if data.BelongOrg() != option.OperateInfo.OrgId {
  232 + return application.ThrowError(application.BUSINESS_ERROR, "当前登录的组织机构与操作数据组织机构不一致")
  233 + }
  234 + }
  235 + return nil
  236 +}
  237 +
  238 +/***** 2.配置 *****/
  239 +
  240 +type FastOptions struct {
  241 + DataAuthRequired bool
  242 + OperateInfo *domain.OperateInfo
  243 +}
  244 +
  245 +func NewFastOptions(options ...option) *FastOptions {
  246 + o := &FastOptions{
  247 + DataAuthRequired: false,
  248 + }
  249 + for i := 0; i < len(options); i++ {
  250 + options[i](o)
  251 + }
  252 + return o
  253 +}
  254 +
  255 +type option func(options *FastOptions)
  256 +
  257 +// 需要数据权限
  258 +func WithDataAuthRequired() option {
  259 + return func(options *FastOptions) {
  260 + options.DataAuthRequired = true
  261 + }
  262 +}
  263 +
  264 +// WithOperator 操作人
  265 +func WithOperator(op *domain.OperateInfo) option {
  266 + return func(options *FastOptions) {
  267 + options.OperateInfo = op
  268 + }
  269 +}
@@ -13,3 +13,59 @@ func CreateMenuRepository(options map[string]interface{}) (domain.MenuRepository @@ -13,3 +13,59 @@ func CreateMenuRepository(options map[string]interface{}) (domain.MenuRepository
13 } 13 }
14 return repository.NewMenuRepository(transactionContext) 14 return repository.NewMenuRepository(transactionContext)
15 } 15 }
  16 +
  17 +func CreateOrgRepository(options map[string]interface{}) (domain.OrgRepository, error) {
  18 + var transactionContext *pg.TransactionContext
  19 + if value, ok := options["transactionContext"]; ok {
  20 + transactionContext = value.(*pg.TransactionContext)
  21 + }
  22 + return repository.NewOrgRepository(transactionContext)
  23 +}
  24 +
  25 +func CreateRoleRepository(options map[string]interface{}) (domain.RoleRepository, error) {
  26 + var transactionContext *pg.TransactionContext
  27 + if value, ok := options["transactionContext"]; ok {
  28 + transactionContext = value.(*pg.TransactionContext)
  29 + }
  30 + return repository.NewRoleRepository(transactionContext)
  31 +}
  32 +
  33 +func CreateUserBaseRepository(options map[string]interface{}) (domain.UserBaseRepository, error) {
  34 + var transactionContext *pg.TransactionContext
  35 + if value, ok := options["transactionContext"]; ok {
  36 + transactionContext = value.(*pg.TransactionContext)
  37 + }
  38 + return repository.NewUserBaseRepository(transactionContext)
  39 +}
  40 +
  41 +func CreateUserRepository(options map[string]interface{}) (domain.UserRepository, error) {
  42 + var transactionContext *pg.TransactionContext
  43 + if value, ok := options["transactionContext"]; ok {
  44 + transactionContext = value.(*pg.TransactionContext)
  45 + }
  46 + return repository.NewUserRepository(transactionContext)
  47 +}
  48 +
  49 +func CreateCompanyRepository(options map[string]interface{}) (domain.CompanyRepository, error) {
  50 + var transactionContext *pg.TransactionContext
  51 + if value, ok := options["transactionContext"]; ok {
  52 + transactionContext = value.(*pg.TransactionContext)
  53 + }
  54 + return repository.NewCompanyRepository(transactionContext)
  55 +}
  56 +
  57 +func CreateCustomizeMenuRepository(options map[string]interface{}) (domain.CustomizeMenuRepository, error) {
  58 + var transactionContext *pg.TransactionContext
  59 + if value, ok := options["transactionContext"]; ok {
  60 + transactionContext = value.(*pg.TransactionContext)
  61 + }
  62 + return repository.NewCustomizeMenuRepository(transactionContext)
  63 +}
  64 +
  65 +func CreateAccountDestroyRecordRepository(options map[string]interface{}) (domain.AccountDestroyRecordRepository, error) {
  66 + var transactionContext *pg.TransactionContext
  67 + if value, ok := options["transactionContext"]; ok {
  68 + transactionContext = value.(*pg.TransactionContext)
  69 + }
  70 + return repository.NewAccountDestroyRecordRepository(transactionContext)
  71 +}
  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 BatchDeleteMenuCommand struct {
  12 + // 菜单ID列表
  13 + MenuIds []int64 `cname:"菜单ID列表" json:"menuIds,omitempty"`
  14 +}
  15 +
  16 +func (batchDeleteMenuCommand *BatchDeleteMenuCommand) Valid(validation *validation.Validation) {
  17 + //validation.SetError("CustomValid", "未实现的自定义认证")
  18 +}
  19 +
  20 +func (batchDeleteMenuCommand *BatchDeleteMenuCommand) ValidateCommand() error {
  21 + valid := validation.Validation{}
  22 + b, err := valid.Valid(batchDeleteMenuCommand)
  23 + if err != nil {
  24 + return err
  25 + }
  26 + if !b {
  27 + elem := reflect.TypeOf(batchDeleteMenuCommand).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 +}