作者 yangfu

init

正在显示 51 个修改的文件 包含 2521 行增加0 行删除
  1 +# Compiled Object codefiles, Static and Dynamic libs (Shared Objects)
  2 +*.o
  3 +*.a
  4 +*.so
  5 +
  6 +# Folders
  7 +_obj
  8 +_test
  9 +
  10 +# Architecture specific extensions/prefixes
  11 +*.[568vq]
  12 +[568vq].out
  13 +
  14 +*.cgo1.go
  15 +*.cgo2.c
  16 +_cgo_defun.c
  17 +_cgo_gotypes.go
  18 +_cgo_export.*
  19 +
  20 +_testmain.go
  21 +
  22 +*.exe
  23 +*.test
  24 +.log
  25 +.idea
  1 +FROM golang:latest
  2 +MAINTAINER tiptok <785409885@qq.com>
  3 +ENV APP_DIR $GOPATH/src/godevp
  4 +RUN mkdir -p $APP_DIR
  5 +WORKDIR $APP_DIR/
  6 +COPY ./pkg pkg
  7 +COPY ./conf conf
  8 +COPY ./go.mod go.mod
  9 +COPY ./go.sum go.sum
  10 +COPY ./main.go main.go
  11 +RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"]
  12 +ENV GO111MODULE on
  13 +ENV GOPROXY https://goproxy.io
  14 +RUN ["go","mod","tidy"]
  15 +RUN ["ls"]
  16 +RUN ["go","build"]
  17 +ENTRYPOINT ["./godevp"]
  1 +#godevp
  1 +appname = godevp
  2 +runmode = "${RUN_MODE||dev}"
  3 +httpport = "${HTTP_PORT||8080}"
  4 +
  5 +#开启监控
  6 +EnableAdmin = false
  7 +#开启JSON请求
  8 +copyrequestbody = true
  9 +#防止跨站请求伪造 未启用
  10 +enablexsrf = false
  11 +xsrfkey = asdfioerjlasdfmFADFOEJF2323SDFF
  12 +xsrfexpire = 3600
  13 +[lang]
  14 +types = en-US|zh-CN
  15 +names = English|简体中文
  1 +apiVersion: v1
  2 +kind: Service
  3 +metadata:
  4 + name: godevp
  5 + namespace: <replace-your-k8s-namespace>
  6 + labels:
  7 + k8s-app: godevp
  8 +spec:
  9 + ports:
  10 + - name: "http"
  11 + port: 80
  12 + targetPort: 8082
  13 + selector:
  14 + k8s-app: godevp
  15 +---
  16 +apiVersion: extensions/v1beta1
  17 +kind: Deployment
  18 +metadata:
  19 + name: godevp
  20 + namespace: <replace-your-k8s-namespace>
  21 + labels:
  22 + k8s-app: godevp
  23 +spec:
  24 + replicas: 1
  25 + template:
  26 + metadata:
  27 + labels:
  28 + k8s-app: godevp
  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: godevp
  47 + image: 192.168.0.243:5000/mmm/godevp:dev
  48 + imagePullPolicy: Always
  49 + ports:
  50 + - containerPort: 8082
  51 + volumeMounts:
  52 + - mountPath: /opt/logs
  53 + name: accesslogs
  54 + env:
  55 + - name: LOG_LEVEL
  56 + value: "debug"
  57 + - name: ERROR_BASE_CODE
  58 + value: "1"
  59 + - name: ERROR_BASE_CODE_MULTIPLE
  60 + value: "1000"
  61 + volumes:
  62 + - name: accesslogs
  63 + emptyDir: {}
  1 +#!/bin/bash
  2 +export PATH=/root/local/bin:$PATH
  3 +kubectl -n <replace-your-k8s-namespace> get pods | grep -q godevp
  4 +if [ "$?" == "1" ];then
  5 + kubectl create -f /tmp/dev/godevp/godevp.yaml --record
  6 + kubectl -n <replace-your-k8s-namespace> get svc | grep -q godevp
  7 + if [ "$?" == "0" ];then
  8 + echo "godevp service install success!"
  9 + else
  10 + echo "godevp service install fail!"
  11 + fi
  12 + kubectl -n <replace-your-k8s-namespace> get pods | grep -q godevp
  13 + if [ "$?" == "0" ];then
  14 + echo "godevp deployment install success!"
  15 + else
  16 + echo "godevp deployment install fail!"
  17 + fi
  18 +else
  19 + kubectl delete -f /tmp/dev/godevp/godevp.yaml
  20 + kubectl -n <replace-your-k8s-namespace> get svc | grep -q godevp
  21 + while [ "$?" == "0" ]
  22 + do
  23 + kubectl -n <replace-your-k8s-namespace> get svc | grep -q godevp
  24 + done
  25 + kubectl -n <replace-your-k8s-namespace> get pods | grep -q godevp
  26 + while [ "$?" == "0" ]
  27 + do
  28 + kubectl -n <replace-your-k8s-namespace> get pods | grep -q godevp
  29 + done
  30 + kubectl create -f /tmp/dev/godevp/godevp.yaml --record
  31 + kubectl -n <replace-your-k8s-namespace> get svc | grep -q godevp
  32 + if [ "$?" == "0" ];then
  33 + echo "godevp service update success!"
  34 + else
  35 + echo "godevp service update fail!"
  36 + fi
  37 + kubectl -n <replace-your-k8s-namespace> get pods | grep -q godevp
  38 + if [ "$?" == "0" ];then
  39 + echo "godevp deployment update success!"
  40 + else
  41 + echo "godevp deployment update fail!"
  42 + fi
  43 +fi
  1 +module github.com/tiptok/godevp
  2 +
  3 +go 1.15
  4 +
  5 +require (
  6 + github.com/ajg/form v1.5.1 // indirect
  7 + github.com/astaxie/beego v1.12.3
  8 + github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect
  9 + github.com/fatih/structs v1.1.0 // indirect
  10 + github.com/gavv/httpexpect v2.0.0+incompatible
  11 + github.com/go-pg/pg v8.0.6+incompatible
  12 + github.com/google/go-querystring v1.0.0 // indirect
  13 + github.com/gorilla/websocket v1.4.2 // indirect
  14 + github.com/imkira/go-interpol v1.1.0 // indirect
  15 + github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect
  16 + github.com/linmadan/egglib-go v0.0.0-20201125083542-25358a549edb
  17 + github.com/mattn/go-colorable v0.1.8 // indirect
  18 + github.com/moul/http2curl v1.0.0 // indirect
  19 + github.com/onsi/ginkgo v1.14.2
  20 + github.com/onsi/gomega v1.10.4
  21 + github.com/sergi/go-diff v1.1.0 // indirect
  22 + github.com/smartystreets/goconvey v1.6.4 // indirect
  23 + github.com/valyala/fasthttp v1.18.0 // indirect
  24 + github.com/xeipuuv/gojsonschema v1.2.0 // indirect
  25 + github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect
  26 + github.com/yudai/gojsondiff v1.0.0 // indirect
  27 + github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
  28 + github.com/yudai/pp v2.0.1+incompatible // indirect
  29 +)
  1 +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
  2 +github.com/DataDog/zstd v1.3.6-0.20190409195224-796139022798/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
  3 +github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
  4 +github.com/OwnLocal/goes v1.0.0/go.mod h1:8rIFjBGTue3lCU0wplczcUgt9Gxgrkkrw7etMIcn8TM=
  5 +github.com/Shopify/sarama v1.23.1/go.mod h1:XLH1GYJnLVE0XCr6KdJGVJRTwY30moWNJ4sERjXX6fs=
  6 +github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
  7 +github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
  8 +github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
  9 +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
  10 +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
  11 +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
  12 +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
  13 +github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
  14 +github.com/alicebob/miniredis v2.5.0+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+DxYx+6BMjkBbe5ONFIF1MXffk=
  15 +github.com/andybalholm/brotli v1.0.0 h1:7UCwP93aiSfvWpapti8g88vVVGp2qqtGyePsSuDafo4=
  16 +github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
  17 +github.com/astaxie/beego v1.12.0/go.mod h1:fysx+LZNZKnvh4GED/xND7jWtjCR6HzydR2Hh2Im57o=
  18 +github.com/astaxie/beego v1.12.3 h1:SAQkdD2ePye+v8Gn1r4X6IKZM1wd28EyUOVQ3PDSOOQ=
  19 +github.com/astaxie/beego v1.12.3/go.mod h1:p3qIm0Ryx7zeBHLljmd7omloyca1s4yu1a8kM1FkpIA=
  20 +github.com/beego/goyaml2 v0.0.0-20130207012346-5545475820dd/go.mod h1:1b+Y/CofkYwXMUU0OhQqGvsY2Bvgr4j6jfT699wyZKQ=
  21 +github.com/beego/x2j v0.0.0-20131220205130-a0352aadc542/go.mod h1:kSeGC/p1AbBiEp5kat81+DSQrZenVBZXklMLaELspWU=
  22 +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
  23 +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
  24 +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
  25 +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
  26 +github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60=
  27 +github.com/casbin/casbin v1.7.0/go.mod h1:c67qKN6Oum3UF5Q1+BByfFxkwKvhwW57ITjqwtzR1KE=
  28 +github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
  29 +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
  30 +github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80=
  31 +github.com/couchbase/go-couchbase v0.0.0-20181122212707-3e9b6e1258bb/go.mod h1:TWI8EKQMs5u5jLKW/tsb9VwauIrMIxQG1r5fMsswK5U=
  32 +github.com/couchbase/go-couchbase v0.0.0-20200519150804-63f3cdb75e0d/go.mod h1:TWI8EKQMs5u5jLKW/tsb9VwauIrMIxQG1r5fMsswK5U=
  33 +github.com/couchbase/gomemcached v0.0.0-20181122193126-5125a94a666c/go.mod h1:srVSlQLB8iXBVXHgnqemxUXqN6FCvClgCMPCsjBDR7c=
  34 +github.com/couchbase/gomemcached v0.0.0-20200526233749-ec430f949808/go.mod h1:srVSlQLB8iXBVXHgnqemxUXqN6FCvClgCMPCsjBDR7c=
  35 +github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs=
  36 +github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGiisLwp9rITslkFNpZD5rz43tf41QFkTWY=
  37 +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
  38 +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
  39 +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
  40 +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
  41 +github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
  42 +github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
  43 +github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
  44 +github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
  45 +github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox93HoX8utj1kxD9aFUcI=
  46 +github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk=
  47 +github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
  48 +github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 h1:DddqAaWDpywytcG8w/qoQ5sAN8X12d3Z3koB0C3Rxsc=
  49 +github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8=
  50 +github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
  51 +github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
  52 +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
  53 +github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
  54 +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
  55 +github.com/gavv/httpexpect v2.0.0+incompatible h1:1X9kcRshkSKEjNJJxX9Y9mQ5BRfbxU5kORdjhlA1yX8=
  56 +github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc=
  57 +github.com/glendc/gopher-json v0.0.0-20170414221815-dc4743023d0c/go.mod h1:Gja1A+xZ9BoviGJNA2E9vFkPjjsl+CoJxSXiQM1UXtw=
  58 +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
  59 +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
  60 +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
  61 +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
  62 +github.com/go-pg/pg v8.0.6+incompatible h1:Hi7yUJ2zwmHFq1Mar5XqhCe3NJ7j9r+BaiNmd+vqf+A=
  63 +github.com/go-pg/pg v8.0.6+incompatible/go.mod h1:a2oXow+aFOrvwcKs3eIA0lNFmMilrxK2sOkB5NWe0vA=
  64 +github.com/go-pg/pg v8.0.7+incompatible h1:ty/sXL1OZLo+47KK9N8llRcmbA9tZasqbQ/OO4ld53g=
  65 +github.com/go-pg/pg v8.0.7+incompatible/go.mod h1:a2oXow+aFOrvwcKs3eIA0lNFmMilrxK2sOkB5NWe0vA=
  66 +github.com/go-redis/redis v6.14.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
  67 +github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
  68 +github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
  69 +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
  70 +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
  71 +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
  72 +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
  73 +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
  74 +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
  75 +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
  76 +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
  77 +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
  78 +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
  79 +github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
  80 +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
  81 +github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
  82 +github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
  83 +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
  84 +github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
  85 +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
  86 +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
  87 +github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
  88 +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
  89 +github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
  90 +github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
  91 +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
  92 +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
  93 +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
  94 +github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
  95 +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
  96 +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
  97 +github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
  98 +github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
  99 +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
  100 +github.com/imkira/go-interpol v1.1.0 h1:KIiKr0VSG2CUW1hl1jpiyuzuJeKUUpC8iM1AIE7N1Vk=
  101 +github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA=
  102 +github.com/jcmturner/gofork v0.0.0-20190328161633-dc7c13fece03/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o=
  103 +github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
  104 +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
  105 +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
  106 +github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
  107 +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
  108 +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
  109 +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
  110 +github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 h1:uC1QfSlInpQF+M0ao65imhwqKnz3Q2z/d8PWZRMQvDM=
  111 +github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k=
  112 +github.com/klauspost/compress v1.10.7 h1:7rix8v8GpI3ZBb0nSozFRgbtXKv+hOe+qfEpZqybrAg=
  113 +github.com/klauspost/compress v1.10.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
  114 +github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
  115 +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
  116 +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
  117 +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
  118 +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
  119 +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
  120 +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
  121 +github.com/ledisdb/ledisdb v0.0.0-20200510135210-d35789ec47e6/go.mod h1:n931TsDuKuq+uX4v1fulaMbA/7ZLLhjc85h7chZGBCQ=
  122 +github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
  123 +github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9 h1:zJZsqJ1wFMYb2yrja5S3OZ+oASx4irRksZ8+emFs56M=
  124 +github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9/go.mod h1:S1zYn9bb6h+Qzu1aOO8raFhHniewOBaif3YvA9qA6lk=
  125 +github.com/linmadan/egglib-go v0.0.0-20201125083542-25358a549edb h1:Ocxw5BWyRrRkTHSsTmQx0UnGsAYZDOwa3K9oGlXF8Jo=
  126 +github.com/linmadan/egglib-go v0.0.0-20201125083542-25358a549edb/go.mod h1:S1zYn9bb6h+Qzu1aOO8raFhHniewOBaif3YvA9qA6lk=
  127 +github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
  128 +github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
  129 +github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
  130 +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
  131 +github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
  132 +github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
  133 +github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
  134 +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
  135 +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
  136 +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
  137 +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
  138 +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
  139 +github.com/moul/http2curl v1.0.0 h1:dRMWoAtb+ePxMlLkrCbAqh4TlPHXvoGUSQ323/9Zahs=
  140 +github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ=
  141 +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
  142 +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
  143 +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
  144 +github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
  145 +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
  146 +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
  147 +github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
  148 +github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg=
  149 +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
  150 +github.com/onsi/ginkgo v1.14.2 h1:8mVmC9kjFFmA8H4pKMUhcblgifdkOIXPvbhN1T36q1M=
  151 +github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
  152 +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
  153 +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
  154 +github.com/onsi/gomega v1.10.4 h1:NiTx7EEvBzu9sFOD1zORteLSt3o8gnlvZZwSE9TnY9U=
  155 +github.com/onsi/gomega v1.10.4/go.mod h1:g/HbgYopi++010VEqkFgJHKC09uJiW9UkXvMUuKHUCQ=
  156 +github.com/pelletier/go-toml v1.0.1/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
  157 +github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
  158 +github.com/peterh/liner v1.0.1-0.20171122030339-3681c2a91233/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc=
  159 +github.com/pierrec/lz4 v0.0.0-20190327172049-315a67e90e41/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
  160 +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
  161 +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
  162 +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
  163 +github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
  164 +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
  165 +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
  166 +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
  167 +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
  168 +github.com/prometheus/client_golang v1.7.0 h1:wCi7urQOGBsYcQROHqpUUX4ct84xp40t9R9JX0FuA/U=
  169 +github.com/prometheus/client_golang v1.7.0/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
  170 +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
  171 +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
  172 +github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
  173 +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
  174 +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
  175 +github.com/prometheus/common v0.10.0 h1:RyRA7RzGXQZiW+tGMr7sxa85G1z0yOpM1qq5c8lNawc=
  176 +github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
  177 +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
  178 +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
  179 +github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8=
  180 +github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
  181 +github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
  182 +github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
  183 +github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
  184 +github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI+b2qND5gpH8YhURn0k8OCaeRnkINo=
  185 +github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg=
  186 +github.com/siddontang/go v0.0.0-20170517070808-cb568a3e5cc0/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
  187 +github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
  188 +github.com/siddontang/goredis v0.0.0-20150324035039-760763f78400/go.mod h1:DDcKzU3qCuvj/tPnimWSsZZzvk9qvkvrIL5naVBPh5s=
  189 +github.com/siddontang/ledisdb v0.0.0-20181029004158-becf5f38d373/go.mod h1:mF1DpOSOUiJRMR+FDqaqu3EBqrybQtrDDszLUZ6oxPg=
  190 +github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA=
  191 +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
  192 +github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
  193 +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
  194 +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
  195 +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
  196 +github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
  197 +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
  198 +github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE=
  199 +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
  200 +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
  201 +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
  202 +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
  203 +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
  204 +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
  205 +github.com/syndtr/goleveldb v0.0.0-20160425020131-cfa635847112/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
  206 +github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
  207 +github.com/ugorji/go v0.0.0-20171122102828-84cb69a8af83/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ=
  208 +github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
  209 +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
  210 +github.com/valyala/fasthttp v1.18.0 h1:IV0DdMlatq9QO1Cr6wGJPVW1sV1Q8HvZXAIcjorylyM=
  211 +github.com/valyala/fasthttp v1.18.0/go.mod h1:jjraHZVbKOXftJfsOYoAjaeygpj5hr8ermTRJNroD7A=
  212 +github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
  213 +github.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc=
  214 +github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I=
  215 +github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=
  216 +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c=
  217 +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
  218 +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
  219 +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
  220 +github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
  221 +github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
  222 +github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 h1:6fRhSjgLCkTD3JnJxvaJ4Sj+TYblw757bqYgZaOq5ZY=
  223 +github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI=
  224 +github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA=
  225 +github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg=
  226 +github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M=
  227 +github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM=
  228 +github.com/yudai/pp v2.0.1+incompatible h1:Q4//iY4pNF6yPLZIigmvcl7k/bPgrcTPIFIcmawg5bI=
  229 +github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc=
  230 +github.com/yuin/gopher-lua v0.0.0-20171031051903-609c9cd26973/go.mod h1:aEV29XrmTYFr3CiRxZeGHpkvbwq+prZduBqMaascyCU=
  231 +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
  232 +golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
  233 +golang.org/x/crypto v0.0.0-20181127143415-eb0de9b17e85/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
  234 +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
  235 +golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
  236 +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
  237 +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
  238 +golang.org/x/crypto v0.0.0-20191029031824-8986dd9e96cf/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
  239 +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
  240 +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
  241 +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
  242 +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
  243 +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
  244 +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
  245 +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
  246 +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
  247 +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
  248 +golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
  249 +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
  250 +golang.org/x/net v0.0.0-20201016165138-7b1cca2348c0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
  251 +golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb h1:eBmm0M9fYhWpKZLjQUUKka/LtIxf46G4fxeEz5KJr9U=
  252 +golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
  253 +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
  254 +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
  255 +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
  256 +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
  257 +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
  258 +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
  259 +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
  260 +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
  261 +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
  262 +golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
  263 +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
  264 +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
  265 +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
  266 +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
  267 +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
  268 +golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
  269 +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
  270 +golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
  271 +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
  272 +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
  273 +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
  274 +golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
  275 +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
  276 +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA=
  277 +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
  278 +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
  279 +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
  280 +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
  281 +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
  282 +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
  283 +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
  284 +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
  285 +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
  286 +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
  287 +google.golang.org/appengine v1.6.2/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
  288 +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
  289 +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
  290 +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
  291 +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
  292 +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
  293 +google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
  294 +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
  295 +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
  296 +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
  297 +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
  298 +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
  299 +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
  300 +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
  301 +gopkg.in/jcmturner/aescts.v1 v1.0.1/go.mod h1:nsR8qBOg+OucoIW+WMhB3GspUQXq9XorLnQb9XtvcOo=
  302 +gopkg.in/jcmturner/dnsutils.v1 v1.0.1/go.mod h1:m3v+5svpVOhtFAP/wSz+yzh4Mc0Fg7eRhxkJMWSIz9Q=
  303 +gopkg.in/jcmturner/goidentity.v3 v3.0.0/go.mod h1:oG2kH0IvSYNIu80dVAyu/yoefjq1mNfM5bm88whjWx4=
  304 +gopkg.in/jcmturner/gokrb5.v7 v7.2.3/go.mod h1:l8VISx+WGYp+Fp7KRbsiUuXTTOnxIc3Tuvyavf11/WM=
  305 +gopkg.in/jcmturner/rpc.v1 v1.1.0/go.mod h1:YIdkC4XfD6GXbzje11McwsDuOlZQSb9W4vfLvuNnlv8=
  306 +gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
  307 +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
  308 +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
  309 +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
  310 +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
  311 +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
  312 +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
  313 +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
  314 +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
  315 +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
  316 +mellium.im/sasl v0.2.1 h1:nspKSRg7/SyO0cRGY71OkfHab8tf9kCts6a6oTDut0w=
  317 +mellium.im/sasl v0.2.1/go.mod h1:ROaEDLQNuf9vjKqE1SrAfnsobm2YKXT1gnN1uDp1PjQ=
  1 +package main
  2 +
  3 +import (
  4 + "github.com/astaxie/beego"
  5 + _ "github.com/tiptok/godevp/pkg/infrastructure/pg"
  6 + _ "github.com/tiptok/godevp/pkg/port/beego"
  7 +)
  8 +
  9 +func main() {
  10 + beego.Run()
  11 +}
  1 +package factory
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/transaction/pg"
  5 + "github.com/tiptok/godevp/pkg/domain/role"
  6 + "github.com/tiptok/godevp/pkg/domain/users"
  7 + "github.com/tiptok/godevp/pkg/infrastructure/repository"
  8 +)
  9 +
  10 +func CreateUsersRepository(options map[string]interface{}) (users.UsersRepository, error) {
  11 + var transactionContext *pg.TransactionContext
  12 + if value, ok := options["transactionContext"]; ok {
  13 + transactionContext = value.(*pg.TransactionContext)
  14 + }
  15 + return repository.NewUsersRepository(transactionContext)
  16 +}
  17 +
  18 +func CreateRoleRepository(options map[string]interface{}) (role.RoleRepository, error) {
  19 + var transactionContext *pg.TransactionContext
  20 + if value, ok := options["transactionContext"]; ok {
  21 + transactionContext = value.(*pg.TransactionContext)
  22 + }
  23 + return repository.NewRoleRepository(transactionContext)
  24 +}
  1 +package factory
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/core/application"
  5 + pG "github.com/linmadan/egglib-go/transaction/pg"
  6 + "github.com/tiptok/godevp/pkg/infrastructure/pg"
  7 +)
  8 +
  9 +func CreateTransactionContext(options map[string]interface{}) (application.TransactionContext, error) {
  10 + return pG.NewPGTransactionContext(pg.DB), nil
  11 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/astaxie/beego/validation"
  7 +)
  8 +
  9 +type CreateRoleCommand struct {
  10 + // 角色id
  11 + Id int64 `json:"id" valid:"Required"`
  12 + // 角色名称
  13 + RoleName string `json:"roleName,omitempty"`
  14 +}
  15 +
  16 +func (createRoleCommand *CreateRoleCommand) Valid(validation *validation.Validation) {
  17 + validation.SetError("CustomValid", "未实现的自定义认证")
  18 +}
  19 +
  20 +func (createRoleCommand *CreateRoleCommand) ValidateCommand() error {
  21 + valid := validation.Validation{}
  22 + b, err := valid.Valid(createRoleCommand)
  23 + if err != nil {
  24 + return err
  25 + }
  26 + if !b {
  27 + for _, validErr := range valid.Errors {
  28 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  29 + }
  30 + }
  31 + return nil
  32 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/astaxie/beego/validation"
  7 +)
  8 +
  9 +type RemoveRoleCommand struct {
  10 + // 角色id
  11 + RoleId int64 `json:"roleId" valid:"Required"`
  12 +}
  13 +
  14 +func (removeRoleCommand *RemoveRoleCommand) Valid(validation *validation.Validation) {
  15 + validation.SetError("CustomValid", "未实现的自定义认证")
  16 +}
  17 +
  18 +func (removeRoleCommand *RemoveRoleCommand) ValidateCommand() error {
  19 + valid := validation.Validation{}
  20 + b, err := valid.Valid(removeRoleCommand)
  21 + if err != nil {
  22 + return err
  23 + }
  24 + if !b {
  25 + for _, validErr := range valid.Errors {
  26 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  27 + }
  28 + }
  29 + return nil
  30 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/astaxie/beego/validation"
  7 +)
  8 +
  9 +type UpdateRoleCommand struct {
  10 + // 角色id
  11 + RoleId int64 `json:"roleId" valid:"Required"`
  12 +}
  13 +
  14 +func (updateRoleCommand *UpdateRoleCommand) Valid(validation *validation.Validation) {
  15 + validation.SetError("CustomValid", "未实现的自定义认证")
  16 +}
  17 +
  18 +func (updateRoleCommand *UpdateRoleCommand) ValidateCommand() error {
  19 + valid := validation.Validation{}
  20 + b, err := valid.Valid(updateRoleCommand)
  21 + if err != nil {
  22 + return err
  23 + }
  24 + if !b {
  25 + for _, validErr := range valid.Errors {
  26 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  27 + }
  28 + }
  29 + return nil
  30 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/astaxie/beego/validation"
  7 +)
  8 +
  9 +type GetRoleQuery struct {
  10 + // 角色id
  11 + RoleId int64 `json:"roleId" valid:"Required"`
  12 +}
  13 +
  14 +func (getRoleQuery *GetRoleQuery) Valid(validation *validation.Validation) {
  15 + //validation.SetError("CustomValid", "未实现的自定义认证")
  16 +}
  17 +
  18 +func (getRoleQuery *GetRoleQuery) ValidateQuery() error {
  19 + valid := validation.Validation{}
  20 + b, err := valid.Valid(getRoleQuery)
  21 + if err != nil {
  22 + return err
  23 + }
  24 + if !b {
  25 + for _, validErr := range valid.Errors {
  26 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  27 + }
  28 + }
  29 + return nil
  30 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/astaxie/beego/validation"
  7 +)
  8 +
  9 +type ListRoleQuery struct {
  10 + // 查询偏离量
  11 + Offset int `json:"offset" ` //valid:"Required"
  12 + // 查询限制
  13 + Limit int `json:"limit"` // valid:"Required"
  14 +}
  15 +
  16 +func (listRoleQuery *ListRoleQuery) Valid(validation *validation.Validation) {
  17 + //validation.SetError("CustomValid", "未实现的自定义认证")
  18 +}
  19 +
  20 +func (listRoleQuery *ListRoleQuery) ValidateQuery() error {
  21 + valid := validation.Validation{}
  22 + b, err := valid.Valid(listRoleQuery)
  23 + if err != nil {
  24 + return err
  25 + }
  26 + if !b {
  27 + for _, validErr := range valid.Errors {
  28 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  29 + }
  30 + }
  31 + return nil
  32 +}
  1 +package service
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/linmadan/egglib-go/core/application"
  6 + "github.com/linmadan/egglib-go/utils/tool_funs"
  7 + "github.com/tiptok/godevp/pkg/application/factory"
  8 + "github.com/tiptok/godevp/pkg/application/role/command"
  9 + "github.com/tiptok/godevp/pkg/application/role/query"
  10 + "github.com/tiptok/godevp/pkg/domain/role"
  11 +)
  12 +
  13 +// 角色名称
  14 +type RoleService struct {
  15 +}
  16 +
  17 +// 创建
  18 +func (roleService *RoleService) CreateRole(createRoleCommand *command.CreateRoleCommand) (interface{}, error) {
  19 + if err := createRoleCommand.ValidateCommand(); err != nil {
  20 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  21 + }
  22 + transactionContext, err := factory.CreateTransactionContext(nil)
  23 + if err != nil {
  24 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  25 + }
  26 + if err := transactionContext.StartTransaction(); err != nil {
  27 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  28 + }
  29 + defer func() {
  30 + transactionContext.RollbackTransaction()
  31 + }()
  32 + newRole := &role.Role{
  33 + Id: createRoleCommand.Id,
  34 + RoleName: createRoleCommand.RoleName,
  35 + }
  36 + var roleRepository role.RoleRepository
  37 + if value, err := factory.CreateRoleRepository(map[string]interface{}{
  38 + "transactionContext": transactionContext,
  39 + }); err != nil {
  40 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  41 + } else {
  42 + roleRepository = value
  43 + }
  44 + if role, err := roleRepository.Save(newRole); err != nil {
  45 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  46 + } else {
  47 + if err := transactionContext.CommitTransaction(); err != nil {
  48 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  49 + }
  50 + return role, nil
  51 + }
  52 +}
  53 +
  54 +// 返回
  55 +func (roleService *RoleService) GetRole(getRoleQuery *query.GetRoleQuery) (interface{}, error) {
  56 + if err := getRoleQuery.ValidateQuery(); err != nil {
  57 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  58 + }
  59 + transactionContext, err := factory.CreateTransactionContext(nil)
  60 + if err != nil {
  61 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  62 + }
  63 + if err := transactionContext.StartTransaction(); err != nil {
  64 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  65 + }
  66 + defer func() {
  67 + transactionContext.RollbackTransaction()
  68 + }()
  69 + var roleRepository role.RoleRepository
  70 + if value, err := factory.CreateRoleRepository(map[string]interface{}{
  71 + "transactionContext": transactionContext,
  72 + }); err != nil {
  73 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  74 + } else {
  75 + roleRepository = value
  76 + }
  77 + role, err := roleRepository.FindOne(map[string]interface{}{"roleId": getRoleQuery.RoleId})
  78 + if err != nil {
  79 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  80 + }
  81 + if role == nil {
  82 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getRoleQuery.RoleId)))
  83 + } else {
  84 + if err := transactionContext.CommitTransaction(); err != nil {
  85 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  86 + }
  87 + return role, nil
  88 + }
  89 +}
  90 +
  91 +// 返回列表
  92 +func (roleService *RoleService) ListRole(listRoleQuery *query.ListRoleQuery) (interface{}, error) {
  93 + if err := listRoleQuery.ValidateQuery(); err != nil {
  94 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  95 + }
  96 + transactionContext, err := factory.CreateTransactionContext(nil)
  97 + if err != nil {
  98 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  99 + }
  100 + if err := transactionContext.StartTransaction(); err != nil {
  101 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  102 + }
  103 + defer func() {
  104 + transactionContext.RollbackTransaction()
  105 + }()
  106 + var roleRepository role.RoleRepository
  107 + if value, err := factory.CreateRoleRepository(map[string]interface{}{
  108 + "transactionContext": transactionContext,
  109 + }); err != nil {
  110 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  111 + } else {
  112 + roleRepository = value
  113 + }
  114 + if count, roles, err := roleRepository.Find(tool_funs.SimpleStructToMap(listRoleQuery)); err != nil {
  115 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  116 + } else {
  117 + if err := transactionContext.CommitTransaction(); err != nil {
  118 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  119 + }
  120 + return map[string]interface{}{
  121 + "count": count,
  122 + "roles": roles,
  123 + }, nil
  124 + }
  125 +}
  126 +
  127 +// 移除
  128 +func (roleService *RoleService) RemoveRole(removeRoleCommand *command.RemoveRoleCommand) (interface{}, error) {
  129 + if err := removeRoleCommand.ValidateCommand(); err != nil {
  130 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  131 + }
  132 + transactionContext, err := factory.CreateTransactionContext(nil)
  133 + if err != nil {
  134 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  135 + }
  136 + if err := transactionContext.StartTransaction(); err != nil {
  137 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  138 + }
  139 + defer func() {
  140 + transactionContext.RollbackTransaction()
  141 + }()
  142 + var roleRepository role.RoleRepository
  143 + if value, err := factory.CreateRoleRepository(map[string]interface{}{
  144 + "transactionContext": transactionContext,
  145 + }); err != nil {
  146 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  147 + } else {
  148 + roleRepository = value
  149 + }
  150 + role, err := roleRepository.FindOne(map[string]interface{}{"roleId": removeRoleCommand.RoleId})
  151 + if err != nil {
  152 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  153 + }
  154 + if role == nil {
  155 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeRoleCommand.RoleId)))
  156 + }
  157 + if role, err := roleRepository.Remove(role); err != nil {
  158 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  159 + } else {
  160 + if err := transactionContext.CommitTransaction(); err != nil {
  161 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  162 + }
  163 + return role, nil
  164 + }
  165 +}
  166 +
  167 +// 更新
  168 +func (roleService *RoleService) UpdateRole(updateRoleCommand *command.UpdateRoleCommand) (interface{}, error) {
  169 + if err := updateRoleCommand.ValidateCommand(); err != nil {
  170 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  171 + }
  172 + transactionContext, err := factory.CreateTransactionContext(nil)
  173 + if err != nil {
  174 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  175 + }
  176 + if err := transactionContext.StartTransaction(); err != nil {
  177 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  178 + }
  179 + defer func() {
  180 + transactionContext.RollbackTransaction()
  181 + }()
  182 + var roleRepository role.RoleRepository
  183 + if value, err := factory.CreateRoleRepository(map[string]interface{}{
  184 + "transactionContext": transactionContext,
  185 + }); err != nil {
  186 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  187 + } else {
  188 + roleRepository = value
  189 + }
  190 + role, err := roleRepository.FindOne(map[string]interface{}{"roleId": updateRoleCommand.RoleId})
  191 + if err != nil {
  192 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  193 + }
  194 + if role == nil {
  195 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateRoleCommand.RoleId)))
  196 + }
  197 + if err := role.Update(tool_funs.SimpleStructToMap(updateRoleCommand)); err != nil {
  198 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  199 + }
  200 + if role, err := roleRepository.Save(role); err != nil {
  201 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  202 + } else {
  203 + if err := transactionContext.CommitTransaction(); err != nil {
  204 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  205 + }
  206 + return role, nil
  207 + }
  208 +}
  209 +
  210 +func NewRoleService(options map[string]interface{}) *RoleService {
  211 + newRoleService := &RoleService{}
  212 + return newRoleService
  213 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/astaxie/beego/validation"
  7 +)
  8 +
  9 +type CreateUsersCommand struct {
  10 + Name string `json:"name" valid:"Required"`
  11 + Phone string `json:"phone" valid:"Required"`
  12 +}
  13 +
  14 +func (createUsersCommand *CreateUsersCommand) Valid(validation *validation.Validation) {
  15 + //validation.SetError("CustomValid", "未实现的自定义认证")
  16 +}
  17 +
  18 +func (createUsersCommand *CreateUsersCommand) ValidateCommand() error {
  19 + valid := validation.Validation{}
  20 + b, err := valid.Valid(createUsersCommand)
  21 + if err != nil {
  22 + return err
  23 + }
  24 + if !b {
  25 + for _, validErr := range valid.Errors {
  26 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  27 + }
  28 + }
  29 + return nil
  30 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/astaxie/beego/validation"
  7 +)
  8 +
  9 +type RemoveUsersCommand struct {
  10 + // user - id
  11 + UsersId int64 `json:"usersId" valid:"Required"`
  12 +}
  13 +
  14 +func (removeUsersCommand *RemoveUsersCommand) Valid(validation *validation.Validation) {
  15 + //validation.SetError("CustomValid", "未实现的自定义认证")
  16 +}
  17 +
  18 +func (removeUsersCommand *RemoveUsersCommand) ValidateCommand() error {
  19 + valid := validation.Validation{}
  20 + b, err := valid.Valid(removeUsersCommand)
  21 + if err != nil {
  22 + return err
  23 + }
  24 + if !b {
  25 + for _, validErr := range valid.Errors {
  26 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  27 + }
  28 + }
  29 + return nil
  30 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/astaxie/beego/validation"
  7 +)
  8 +
  9 +type UpdateUsersCommand struct {
  10 + // user - id
  11 + UsersId int64 `json:"usersId" valid:"Required"`
  12 +}
  13 +
  14 +func (updateUsersCommand *UpdateUsersCommand) Valid(validation *validation.Validation) {
  15 + validation.SetError("CustomValid", "未实现的自定义认证")
  16 +}
  17 +
  18 +func (updateUsersCommand *UpdateUsersCommand) ValidateCommand() error {
  19 + valid := validation.Validation{}
  20 + b, err := valid.Valid(updateUsersCommand)
  21 + if err != nil {
  22 + return err
  23 + }
  24 + if !b {
  25 + for _, validErr := range valid.Errors {
  26 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  27 + }
  28 + }
  29 + return nil
  30 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/astaxie/beego/validation"
  7 +)
  8 +
  9 +type GetUsersQuery struct {
  10 + // user - id
  11 + UsersId int64 `json:"usersId" valid:"Required"`
  12 +}
  13 +
  14 +func (getUsersQuery *GetUsersQuery) Valid(validation *validation.Validation) {
  15 + //validation.SetError("CustomValid", "未实现的自定义认证")
  16 +}
  17 +
  18 +func (getUsersQuery *GetUsersQuery) ValidateQuery() error {
  19 + valid := validation.Validation{}
  20 + b, err := valid.Valid(getUsersQuery)
  21 + if err != nil {
  22 + return err
  23 + }
  24 + if !b {
  25 + for _, validErr := range valid.Errors {
  26 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  27 + }
  28 + }
  29 + return nil
  30 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/astaxie/beego/validation"
  7 +)
  8 +
  9 +type ListUsersQuery struct {
  10 + // 查询偏离量
  11 + Offset int `json:"offset"` //`json:"offset" valid:"Required"`
  12 + // 查询限制
  13 + Limit int `json:"limit"` //`json:"limit" valid:"Required"`
  14 +}
  15 +
  16 +func (listUsersQuery *ListUsersQuery) Valid(validation *validation.Validation) {
  17 + //validation.SetError("CustomValid", "未实现的自定义认证")
  18 +}
  19 +
  20 +func (listUsersQuery *ListUsersQuery) ValidateQuery() error {
  21 + valid := validation.Validation{}
  22 + b, err := valid.Valid(listUsersQuery)
  23 + if err != nil {
  24 + return err
  25 + }
  26 + if !b {
  27 + for _, validErr := range valid.Errors {
  28 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  29 + }
  30 + }
  31 + return nil
  32 +}
  1 +package service
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/linmadan/egglib-go/core/application"
  6 + "github.com/linmadan/egglib-go/utils/tool_funs"
  7 + "github.com/tiptok/godevp/pkg/application/factory"
  8 + "github.com/tiptok/godevp/pkg/application/users/command"
  9 + "github.com/tiptok/godevp/pkg/application/users/query"
  10 + "github.com/tiptok/godevp/pkg/domain/users"
  11 +)
  12 +
  13 +type UsersService struct {
  14 +}
  15 +
  16 +// 创建
  17 +func (usersService *UsersService) CreateUsers(createUsersCommand *command.CreateUsersCommand) (interface{}, error) {
  18 + if err := createUsersCommand.ValidateCommand(); err != nil {
  19 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  20 + }
  21 + transactionContext, err := factory.CreateTransactionContext(nil)
  22 + if err != nil {
  23 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  24 + }
  25 + if err := transactionContext.StartTransaction(); err != nil {
  26 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  27 + }
  28 + defer func() {
  29 + transactionContext.RollbackTransaction()
  30 + }()
  31 + newUsers := &users.Users{
  32 + Name: createUsersCommand.Name,
  33 + Phone: createUsersCommand.Phone,
  34 + }
  35 + var usersRepository users.UsersRepository
  36 + if value, err := factory.CreateUsersRepository(map[string]interface{}{
  37 + "transactionContext": transactionContext,
  38 + }); err != nil {
  39 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  40 + } else {
  41 + usersRepository = value
  42 + }
  43 + if users, err := usersRepository.Save(newUsers); err != nil {
  44 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  45 + } else {
  46 + if err := transactionContext.CommitTransaction(); err != nil {
  47 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  48 + }
  49 + return users, nil
  50 + }
  51 +}
  52 +
  53 +// 返回
  54 +func (usersService *UsersService) GetUsers(getUsersQuery *query.GetUsersQuery) (interface{}, error) {
  55 + if err := getUsersQuery.ValidateQuery(); err != nil {
  56 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  57 + }
  58 + transactionContext, err := factory.CreateTransactionContext(nil)
  59 + if err != nil {
  60 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  61 + }
  62 + if err := transactionContext.StartTransaction(); err != nil {
  63 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  64 + }
  65 + defer func() {
  66 + transactionContext.RollbackTransaction()
  67 + }()
  68 + var usersRepository users.UsersRepository
  69 + if value, err := factory.CreateUsersRepository(map[string]interface{}{
  70 + "transactionContext": transactionContext,
  71 + }); err != nil {
  72 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  73 + } else {
  74 + usersRepository = value
  75 + }
  76 + users, err := usersRepository.FindOne(map[string]interface{}{"usersId": getUsersQuery.UsersId})
  77 + if err != nil {
  78 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  79 + }
  80 + if users == nil {
  81 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getUsersQuery.UsersId)))
  82 + } else {
  83 + if err := transactionContext.CommitTransaction(); err != nil {
  84 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  85 + }
  86 + return users, nil
  87 + }
  88 +}
  89 +
  90 +// 返回列表
  91 +func (usersService *UsersService) ListUsers(listUsersQuery *query.ListUsersQuery) (interface{}, error) {
  92 + if err := listUsersQuery.ValidateQuery(); err != nil {
  93 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  94 + }
  95 + transactionContext, err := factory.CreateTransactionContext(nil)
  96 + if err != nil {
  97 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  98 + }
  99 + if err := transactionContext.StartTransaction(); err != nil {
  100 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  101 + }
  102 + defer func() {
  103 + transactionContext.RollbackTransaction()
  104 + }()
  105 + var usersRepository users.UsersRepository
  106 + if value, err := factory.CreateUsersRepository(map[string]interface{}{
  107 + "transactionContext": transactionContext,
  108 + }); err != nil {
  109 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  110 + } else {
  111 + usersRepository = value
  112 + }
  113 + if count, userss, err := usersRepository.Find(tool_funs.SimpleStructToMap(listUsersQuery)); err != nil {
  114 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  115 + } else {
  116 + if err := transactionContext.CommitTransaction(); err != nil {
  117 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  118 + }
  119 + return map[string]interface{}{
  120 + "count": count,
  121 + "users": userss,
  122 + }, nil
  123 + }
  124 +}
  125 +
  126 +// 移除
  127 +func (usersService *UsersService) RemoveUsers(removeUsersCommand *command.RemoveUsersCommand) (interface{}, error) {
  128 + if err := removeUsersCommand.ValidateCommand(); err != nil {
  129 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  130 + }
  131 + transactionContext, err := factory.CreateTransactionContext(nil)
  132 + if err != nil {
  133 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  134 + }
  135 + if err := transactionContext.StartTransaction(); err != nil {
  136 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  137 + }
  138 + defer func() {
  139 + transactionContext.RollbackTransaction()
  140 + }()
  141 + var usersRepository users.UsersRepository
  142 + if value, err := factory.CreateUsersRepository(map[string]interface{}{
  143 + "transactionContext": transactionContext,
  144 + }); err != nil {
  145 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  146 + } else {
  147 + usersRepository = value
  148 + }
  149 + users, err := usersRepository.FindOne(map[string]interface{}{"usersId": removeUsersCommand.UsersId})
  150 + if err != nil {
  151 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  152 + }
  153 + if users == nil {
  154 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeUsersCommand.UsersId)))
  155 + }
  156 + if users, err := usersRepository.Remove(users); err != nil {
  157 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  158 + } else {
  159 + if err := transactionContext.CommitTransaction(); err != nil {
  160 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  161 + }
  162 + return users, nil
  163 + }
  164 +}
  165 +
  166 +// 更新
  167 +func (usersService *UsersService) UpdateUsers(updateUsersCommand *command.UpdateUsersCommand) (interface{}, error) {
  168 + if err := updateUsersCommand.ValidateCommand(); err != nil {
  169 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  170 + }
  171 + transactionContext, err := factory.CreateTransactionContext(nil)
  172 + if err != nil {
  173 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  174 + }
  175 + if err := transactionContext.StartTransaction(); err != nil {
  176 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  177 + }
  178 + defer func() {
  179 + transactionContext.RollbackTransaction()
  180 + }()
  181 + var usersRepository users.UsersRepository
  182 + if value, err := factory.CreateUsersRepository(map[string]interface{}{
  183 + "transactionContext": transactionContext,
  184 + }); err != nil {
  185 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  186 + } else {
  187 + usersRepository = value
  188 + }
  189 + users, err := usersRepository.FindOne(map[string]interface{}{"usersId": updateUsersCommand.UsersId})
  190 + if err != nil {
  191 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  192 + }
  193 + if users == nil {
  194 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateUsersCommand.UsersId)))
  195 + }
  196 + if err := users.Update(tool_funs.SimpleStructToMap(updateUsersCommand)); err != nil {
  197 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  198 + }
  199 + if users, err := usersRepository.Save(users); err != nil {
  200 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  201 + } else {
  202 + if err := transactionContext.CommitTransaction(); err != nil {
  203 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  204 + }
  205 + return users, nil
  206 + }
  207 +}
  208 +
  209 +func NewUsersService(options map[string]interface{}) *UsersService {
  210 + newUsersService := &UsersService{}
  211 + return newUsersService
  212 +}
  1 +package constant
  2 +
  3 +import "os"
  4 +
  5 +const SERVICE_NAME = "godevp"
  6 +
  7 +var LOG_LEVEL = "debug"
  8 +
  9 +func init() {
  10 + if os.Getenv("LOG_LEVEL") != "" {
  11 + LOG_LEVEL = os.Getenv("LOG_LEVEL")
  12 + }
  13 +}
  1 +package constant
  2 +
  3 +import "os"
  4 +
  5 +var POSTGRESQL_DB_NAME = "godevp_dev"
  6 +var POSTGRESQL_USER = "postgres"
  7 +var POSTGRESQL_PASSWORD = "eagle1010"
  8 +var POSTGRESQL_HOST = "114.55.200.59"
  9 +var POSTGRESQL_PORT = "31543"
  10 +var DISABLE_CREATE_TABLE = true
  11 +var DISABLE_SQL_GENERATE_PRINT = false
  12 +
  13 +func init() {
  14 + if os.Getenv("POSTGRESQL_DB_NAME") != "" {
  15 + POSTGRESQL_DB_NAME = os.Getenv("POSTGRESQL_DB_NAME")
  16 + }
  17 + if os.Getenv("POSTGRESQL_USER") != "" {
  18 + POSTGRESQL_USER = os.Getenv("POSTGRESQL_USER")
  19 + }
  20 + if os.Getenv("POSTGRESQL_PASSWORD") != "" {
  21 + POSTGRESQL_PASSWORD = os.Getenv("POSTGRESQL_PASSWORD")
  22 + }
  23 + if os.Getenv("POSTGRESQL_HOST") != "" {
  24 + POSTGRESQL_HOST = os.Getenv("POSTGRESQL_HOST")
  25 + }
  26 + if os.Getenv("POSTGRESQL_PORT") != "" {
  27 + POSTGRESQL_PORT = os.Getenv("POSTGRESQL_PORT")
  28 + }
  29 + if os.Getenv("DISABLE_CREATE_TABLE") != "" {
  30 + DISABLE_CREATE_TABLE = true
  31 + }
  32 + if os.Getenv("DISABLE_SQL_GENERATE_PRINT") != "" {
  33 + DISABLE_SQL_GENERATE_PRINT = true
  34 + }
  35 +}
  1 +package role
  2 +
  3 +import "time"
  4 +
  5 +// 角色实体
  6 +type Role struct {
  7 + // dcc
  8 + Id int64 `json:"id"`
  9 + // 角色名称
  10 + RoleName string `json:"roleName"`
  11 + // 父级Id
  12 + ParentId int64 `json:"parentId"`
  13 + // 创建时间
  14 + CreateTime time.Time `json:"createTime"`
  15 + // 更新时间
  16 + UpdateTime time.Time `json:"updateTime"`
  17 +}
  18 +
  19 +type RoleRepository interface {
  20 + Save(role *Role) (*Role, error)
  21 + Remove(role *Role) (*Role, error)
  22 + FindOne(queryOptions map[string]interface{}) (*Role, error)
  23 + Find(queryOptions map[string]interface{}) (int64, []*Role, error)
  24 +}
  25 +
  26 +func (role *Role) Identify() interface{} {
  27 + if role.Id == 0 {
  28 + return nil
  29 + }
  30 + return role.Id
  31 +}
  32 +
  33 +func (role *Role) Update(data map[string]interface{}) error {
  34 + if Id, ok := data["Id"]; ok {
  35 + role.Id = Id.(int64)
  36 + }
  37 + if RoleName, ok := data["RoleName"]; ok {
  38 + role.RoleName = RoleName.(string)
  39 + }
  40 + if ParentId, ok := data["ParentId"]; ok {
  41 + role.ParentId = ParentId.(int64)
  42 + }
  43 + if CreateTime, ok := data["CreateTime"]; ok {
  44 + role.CreateTime = CreateTime.(time.Time)
  45 + }
  46 + if UpdateTime, ok := data["UpdateTime"]; ok {
  47 + role.UpdateTime = UpdateTime.(time.Time)
  48 + }
  49 + return nil
  50 +}
  1 +package users
  2 +
  3 +import "time"
  4 +
  5 +// 用户实体
  6 +type Users struct {
  7 + // dcc
  8 + Id int64 `json:"id"`
  9 + // 名称
  10 + Name string `json:"name"`
  11 + // 手机号
  12 + Phone string `json:"phone"`
  13 + // 密码
  14 + Passwd string `json:"passwd"`
  15 + // 用户角色
  16 + Roles []int64 `json:"roles"`
  17 + // 状态 1-启用 0-禁用
  18 + Status int `json:"status"`
  19 + // 1:管理员 2:普通员工
  20 + AdminType int `json:"adminType"`
  21 + // 创建时间
  22 + CreateTime time.Time `json:"createTime"`
  23 + // 更新时间
  24 + UpdateTime time.Time `json:"updateTime"`
  25 +}
  26 +
  27 +type UsersRepository interface {
  28 + Save(users *Users) (*Users, error)
  29 + Remove(users *Users) (*Users, error)
  30 + FindOne(queryOptions map[string]interface{}) (*Users, error)
  31 + Find(queryOptions map[string]interface{}) (int64, []*Users, error)
  32 +}
  33 +
  34 +func (users *Users) Identify() interface{} {
  35 + if users.Id == 0 {
  36 + return nil
  37 + }
  38 + return users.Id
  39 +}
  40 +
  41 +func (users *Users) Update(data map[string]interface{}) error {
  42 + if Id, ok := data["Id"]; ok {
  43 + users.Id = Id.(int64)
  44 + }
  45 + if Name, ok := data["Name"]; ok {
  46 + users.Name = Name.(string)
  47 + }
  48 + if Phone, ok := data["Phone"]; ok {
  49 + users.Phone = Phone.(string)
  50 + }
  51 + if Passwd, ok := data["Passwd"]; ok {
  52 + users.Passwd = Passwd.(string)
  53 + }
  54 + if Roles, ok := data["Roles"]; ok {
  55 + users.Roles = Roles.([]int64)
  56 + }
  57 + if Status, ok := data["Status"]; ok {
  58 + users.Status = Status.(int)
  59 + }
  60 + if AdminType, ok := data["AdminType"]; ok {
  61 + users.AdminType = AdminType.(int)
  62 + }
  63 + if CreateTime, ok := data["CreateTime"]; ok {
  64 + users.CreateTime = CreateTime.(time.Time)
  65 + }
  66 + if UpdateTime, ok := data["UpdateTime"]; ok {
  67 + users.UpdateTime = UpdateTime.(time.Time)
  68 + }
  69 + return nil
  70 +}
  1 +package pg
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/go-pg/pg"
  6 + "github.com/go-pg/pg/orm"
  7 + "github.com/tiptok/godevp/pkg/constant"
  8 +
  9 + //_ "github.com/tiptok/godevp/pkg/infrastructure/pg/models"
  10 + "github.com/linmadan/egglib-go/persistent/pg/hooks"
  11 +)
  12 +
  13 +var DB *pg.DB
  14 +
  15 +func init() {
  16 + DB = pg.Connect(&pg.Options{
  17 + User: constant.POSTGRESQL_USER,
  18 + Password: constant.POSTGRESQL_PASSWORD,
  19 + Database: constant.POSTGRESQL_DB_NAME,
  20 + Addr: fmt.Sprintf("%s:%s", constant.POSTGRESQL_HOST, constant.POSTGRESQL_PORT),
  21 + })
  22 + if !constant.DISABLE_SQL_GENERATE_PRINT {
  23 + DB.AddQueryHook(hooks.SqlGeneratePrintHook{})
  24 + }
  25 + if !constant.DISABLE_CREATE_TABLE {
  26 + for _, model := range []interface{}{} {
  27 + err := DB.CreateTable(model, &orm.CreateTableOptions{
  28 + Temp: false,
  29 + IfNotExists: true,
  30 + FKConstraints: true,
  31 + })
  32 + if err != nil {
  33 + panic(err)
  34 + }
  35 + }
  36 + }
  37 +}
  1 +package models
  2 +
  3 +import "time"
  4 +
  5 +type Role struct {
  6 + TableName struct{} `sql:"role,alias:role"`
  7 + // dcc
  8 + Id int64
  9 + // 角色名称
  10 + RoleName string
  11 + // 父级Id
  12 + ParentId int64
  13 + // 创建时间
  14 + CreateTime time.Time
  15 + // 更新时间
  16 + UpdateTime time.Time
  17 +}
  1 +package models
  2 +
  3 +import "time"
  4 +
  5 +type Users struct {
  6 + TableName string `pg:"users,alias:users"`
  7 + // dcc
  8 + Id int64 `pg:",pk"`
  9 + // 名称
  10 + Name string
  11 + // 手机号
  12 + Phone string
  13 + // 密码
  14 + Passwd string
  15 + // 用户角色
  16 + Roles []int64 //`pg:",array"`
  17 + // 状态 1-启用 0-禁用
  18 + Status int
  19 + // 1:管理员 2:普通员工
  20 + AdminType int
  21 + // 创建时间
  22 + CreateTime time.Time
  23 + // 更新时间
  24 + UpdateTime time.Time
  25 +}
  1 +package repository
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/go-pg/pg"
  7 + pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  8 + "github.com/tiptok/godevp/pkg/domain/role"
  9 + domain "github.com/tiptok/godevp/pkg/domain/role"
  10 + "github.com/tiptok/godevp/pkg/infrastructure/pg/models"
  11 +)
  12 +
  13 +type RoleRepository struct {
  14 + transactionContext *pgTransaction.TransactionContext
  15 +}
  16 +
  17 +func (repository *RoleRepository) nextIdentify() (int64, error) {
  18 + return 0, nil
  19 +}
  20 +func (repository *RoleRepository) Save(role *role.Role) (*role.Role, error) {
  21 + tx := repository.transactionContext.PgTx
  22 + if role.Identify() == nil {
  23 + _, err := repository.nextIdentify()
  24 + if err != nil {
  25 + return role, err
  26 + }
  27 + if _, err := tx.QueryOne(
  28 + pg.Scan(&role.Id, &role.RoleName, &role.ParentId, &role.CreateTime, &role.UpdateTime),
  29 + "INSERT INTO roles (id, role_name, parent_id, create_time, update_time) VALUES (?, ?, ?, ?, ?) RETURNING id, role_name, parent_id, create_time, update_time",
  30 + role.Id, role.RoleName, role.ParentId, role.CreateTime, role.UpdateTime); err != nil {
  31 + return role, err
  32 + }
  33 + } else {
  34 + if _, err := tx.QueryOne(
  35 + pg.Scan(&role.Id, &role.RoleName, &role.ParentId, &role.CreateTime, &role.UpdateTime),
  36 + "UPDATE roles SET id=?, role_name=?, parent_id=?, create_time=?, update_time=? WHERE id=? RETURNING id, role_name, parent_id, create_time, update_time",
  37 + role.Id, role.RoleName, role.ParentId, role.CreateTime, role.UpdateTime, role.Identify()); err != nil {
  38 + return role, err
  39 + }
  40 + }
  41 + return role, nil
  42 +}
  43 +func (repository *RoleRepository) Remove(role *role.Role) (*role.Role, error) {
  44 + tx := repository.transactionContext.PgTx
  45 + roleModel := new(models.Role)
  46 + roleModel.Id = role.Identify().(int64)
  47 + if _, err := tx.Model(roleModel).WherePK().Delete(); err != nil {
  48 + return role, err
  49 + }
  50 + return role, nil
  51 +}
  52 +func (repository *RoleRepository) FindOne(queryOptions map[string]interface{}) (*role.Role, error) {
  53 + tx := repository.transactionContext.PgTx
  54 + roleModel := new(models.Role)
  55 + query := tx.Model(roleModel)
  56 + if roleId, ok := queryOptions["roleId"]; ok {
  57 + query = query.Where("role.id = ?", roleId)
  58 + }
  59 + if err := query.First(); err != nil {
  60 + if err.Error() == "pg: no rows in result set" {
  61 + return nil, fmt.Errorf("没有此资源")
  62 + } else {
  63 + return nil, err
  64 + }
  65 + }
  66 + if roleModel.Id == 0 {
  67 + return nil, nil
  68 + } else {
  69 + return repository.transformPgModelToDomainModel(roleModel)
  70 + }
  71 +}
  72 +func (repository *RoleRepository) Find(queryOptions map[string]interface{}) (int64, []*role.Role, error) {
  73 + tx := repository.transactionContext.PgTx
  74 + var roleModels []*models.Role
  75 + roles := make([]*role.Role, 0)
  76 + query := tx.Model(&roleModels)
  77 + if offset, ok := queryOptions["offset"]; ok {
  78 + offset := offset.(int)
  79 + if offset > -1 {
  80 + query = query.Offset(offset)
  81 + }
  82 + } else {
  83 + query = query.Offset(0)
  84 + }
  85 + if limit, ok := queryOptions["limit"]; ok {
  86 + limit := limit.(int)
  87 + if limit > -1 {
  88 + query = query.Limit(limit)
  89 + }
  90 + } else {
  91 + query = query.Limit(20)
  92 + }
  93 + if count, err := query.Order("id DESC").SelectAndCount(); err != nil {
  94 + return 0, roles, err
  95 + } else {
  96 + for _, roleModel := range roleModels {
  97 + if role, err := repository.transformPgModelToDomainModel(roleModel); err != nil {
  98 + return 0, roles, err
  99 + } else {
  100 + roles = append(roles, role)
  101 + }
  102 + }
  103 + return int64(count), roles, nil
  104 + }
  105 +}
  106 +func (repository *RoleRepository) transformPgModelToDomainModel(roleModel *models.Role) (*domain.Role, error) {
  107 + return &role.Role{
  108 + Id: roleModel.Id,
  109 + RoleName: roleModel.RoleName,
  110 + ParentId: roleModel.ParentId,
  111 + CreateTime: roleModel.CreateTime,
  112 + UpdateTime: roleModel.UpdateTime,
  113 + }, nil
  114 +}
  115 +func NewRoleRepository(transactionContext *pgTransaction.TransactionContext) (*RoleRepository, error) {
  116 + if transactionContext == nil {
  117 + return nil, fmt.Errorf("transactionContext参数不能为nil")
  118 + } else {
  119 + return &RoleRepository{
  120 + transactionContext: transactionContext,
  121 + }, nil
  122 + }
  123 +}
  1 +package repository
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/go-pg/pg"
  7 + pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  8 + "github.com/tiptok/godevp/pkg/domain/users"
  9 + domain "github.com/tiptok/godevp/pkg/domain/users"
  10 + "github.com/tiptok/godevp/pkg/infrastructure/pg/models"
  11 +)
  12 +
  13 +type UsersRepository struct {
  14 + transactionContext *pgTransaction.TransactionContext
  15 +}
  16 +
  17 +func (repository *UsersRepository) nextIdentify() (int64, error) {
  18 + return 0, nil
  19 +}
  20 +func (repository *UsersRepository) Save(users *users.Users) (*users.Users, error) {
  21 + tx := repository.transactionContext.PgTx
  22 + if users.Identify() == nil {
  23 + _, err := repository.nextIdentify()
  24 + if err != nil {
  25 + return users, err
  26 + }
  27 + if _, err := tx.QueryOne(
  28 + pg.Scan(&users.Id, &users.Name, &users.Phone, &users.Passwd, pg.Array(&users.Roles), &users.Status, &users.AdminType, &users.CreateTime, &users.UpdateTime),
  29 + "INSERT INTO users (name, phone, passwd, roles, status, admin_type, create_time, update_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING id, name, phone, passwd, roles, status, admin_type, create_time, update_time",
  30 + users.Name, users.Phone, users.Passwd, pg.Array(users.Roles), users.Status, users.AdminType, users.CreateTime, users.UpdateTime); err != nil {
  31 + return users, err
  32 + }
  33 + } else {
  34 + if _, err := tx.QueryOne(
  35 + pg.Scan(&users.Id, &users.Name, &users.Phone, &users.Passwd, pg.Array(&users.Roles), &users.Status, &users.AdminType, &users.CreateTime, &users.UpdateTime),
  36 + "UPDATE users SET name=?, phone=?, passwd=?, roles=?, status=?, admin_type=?, create_time=?, update_time=? WHERE id=? RETURNING id, name, phone, passwd, roles, status, admin_type, create_time, update_time",
  37 + users.Name, users.Phone, users.Passwd, pg.Array(users.Roles), users.Status, users.AdminType, users.CreateTime, users.UpdateTime, users.Identify()); err != nil {
  38 + return users, err
  39 + }
  40 + }
  41 + return users, nil
  42 +}
  43 +func (repository *UsersRepository) Remove(users *users.Users) (*users.Users, error) {
  44 + tx := repository.transactionContext.PgTx
  45 + usersModel := new(models.Users)
  46 + usersModel.Id = users.Identify().(int64)
  47 + if _, err := tx.Model(usersModel).WherePK().Delete(); err != nil {
  48 + return users, err
  49 + }
  50 + return users, nil
  51 +}
  52 +func (repository *UsersRepository) FindOne(queryOptions map[string]interface{}) (*users.Users, error) {
  53 + tx := repository.transactionContext.PgTx
  54 + usersModel := new(models.Users)
  55 + query := tx.Model(usersModel)
  56 + if usersId, ok := queryOptions["usersId"]; ok {
  57 + query = query.Where("users.id = ?", usersId)
  58 + }
  59 + if err := query.First(); err != nil {
  60 + if err.Error() == "pg: no rows in result set" {
  61 + return nil, fmt.Errorf("没有此资源")
  62 + } else {
  63 + return nil, err
  64 + }
  65 + }
  66 + if usersModel.Id == 0 {
  67 + return nil, nil
  68 + } else {
  69 + return repository.transformPgModelToDomainModel(usersModel)
  70 + }
  71 +}
  72 +func (repository *UsersRepository) Find(queryOptions map[string]interface{}) (int64, []*users.Users, error) {
  73 + tx := repository.transactionContext.PgTx
  74 + var usersModels []*models.Users
  75 + userss := make([]*users.Users, 0)
  76 + query := tx.Model(&usersModels)
  77 + if offset, ok := queryOptions["offset"]; ok {
  78 + offset := offset.(int)
  79 + if offset > -1 {
  80 + query = query.Offset(offset)
  81 + }
  82 + } else {
  83 + query = query.Offset(0)
  84 + }
  85 + if limit, ok := queryOptions["limit"]; ok {
  86 + limit := limit.(int)
  87 + if limit > -1 {
  88 + query = query.Limit(limit)
  89 + }
  90 + } else {
  91 + query = query.Limit(20)
  92 + }
  93 + if count, err := query.Order("id DESC").SelectAndCount(); err != nil {
  94 + return 0, userss, err
  95 + } else {
  96 + for _, usersModel := range usersModels {
  97 + if users, err := repository.transformPgModelToDomainModel(usersModel); err != nil {
  98 + return 0, userss, err
  99 + } else {
  100 + userss = append(userss, users)
  101 + }
  102 + }
  103 + return int64(count), userss, nil
  104 + }
  105 +}
  106 +func (repository *UsersRepository) transformPgModelToDomainModel(usersModel *models.Users) (*domain.Users, error) {
  107 + return &users.Users{
  108 + Id: usersModel.Id,
  109 + Name: usersModel.Name,
  110 + Phone: usersModel.Phone,
  111 + Passwd: usersModel.Passwd,
  112 + Roles: usersModel.Roles,
  113 + Status: usersModel.Status,
  114 + AdminType: usersModel.AdminType,
  115 + CreateTime: usersModel.CreateTime,
  116 + UpdateTime: usersModel.UpdateTime,
  117 + }, nil
  118 +}
  119 +func NewUsersRepository(transactionContext *pgTransaction.TransactionContext) (*UsersRepository, error) {
  120 + if transactionContext == nil {
  121 + return nil, fmt.Errorf("transactionContext参数不能为nil")
  122 + } else {
  123 + return &UsersRepository{
  124 + transactionContext: transactionContext,
  125 + }, nil
  126 + }
  127 +}
  1 +package constant
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/log"
  5 + "github.com/linmadan/egglib-go/log/logrus"
  6 + "github.com/tiptok/godevp/pkg/constant"
  7 +)
  8 +
  9 +var Logger log.Logger
  10 +
  11 +func init() {
  12 + Logger = logrus.NewLogrusLogger()
  13 + Logger.SetServiceName(constant.SERVICE_NAME)
  14 + Logger.SetLevel(constant.LOG_LEVEL)
  15 +}
  1 +package beego
  2 +
  3 +import (
  4 + "github.com/astaxie/beego"
  5 + "github.com/linmadan/egglib-go/web/beego/filters"
  6 +
  7 + . "github.com/tiptok/godevp/pkg/log"
  8 + _ "github.com/tiptok/godevp/pkg/port/beego/routers"
  9 +)
  10 +
  11 +func init() {
  12 + beego.InsertFilter("/*", beego.BeforeExec, filters.CreateRequestBodyFilter())
  13 + beego.InsertFilter("/*", beego.BeforeExec, filters.CreateRequstLogFilter(Logger))
  14 + beego.InsertFilter("/*", beego.AfterExec, filters.CreateResponseLogFilter(Logger), false)
  15 +}
  1 +package controllers
  2 +
  3 +import (
  4 + "encoding/json"
  5 +
  6 + "github.com/astaxie/beego"
  7 + "github.com/linmadan/egglib-go/web/beego/utils"
  8 + "github.com/tiptok/godevp/pkg/application/role/command"
  9 + "github.com/tiptok/godevp/pkg/application/role/query"
  10 + "github.com/tiptok/godevp/pkg/application/role/service"
  11 +)
  12 +
  13 +type RoleController struct {
  14 + beego.Controller
  15 +}
  16 +
  17 +func (controller *RoleController) CreateRole() {
  18 + roleService := service.NewRoleService(nil)
  19 + createRoleCommand := &command.CreateRoleCommand{}
  20 + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), createRoleCommand)
  21 + data, err := roleService.CreateRole(createRoleCommand)
  22 + var response utils.JsonResponse
  23 + if err != nil {
  24 + response = utils.ResponseError(controller.Ctx, err)
  25 + } else {
  26 + response = utils.ResponseData(controller.Ctx, data)
  27 + }
  28 + controller.Data["json"] = response
  29 + controller.ServeJSON()
  30 +}
  31 +
  32 +func (controller *RoleController) UpdateRole() {
  33 + roleService := service.NewRoleService(nil)
  34 + updateRoleCommand := &command.UpdateRoleCommand{}
  35 + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), updateRoleCommand)
  36 + Id, _ := controller.GetInt64(":Id")
  37 + updateRoleCommand.RoleId = Id
  38 + data, err := roleService.UpdateRole(updateRoleCommand)
  39 + var response utils.JsonResponse
  40 + if err != nil {
  41 + response = utils.ResponseError(controller.Ctx, err)
  42 + } else {
  43 + response = utils.ResponseData(controller.Ctx, data)
  44 + }
  45 + controller.Data["json"] = response
  46 + controller.ServeJSON()
  47 +}
  48 +
  49 +func (controller *RoleController) GetRole() {
  50 + roleService := service.NewRoleService(nil)
  51 + getRoleQuery := &query.GetRoleQuery{}
  52 + Id, _ := controller.GetInt64(":Id")
  53 + getRoleQuery.RoleId = Id
  54 + data, err := roleService.GetRole(getRoleQuery)
  55 + var response utils.JsonResponse
  56 + if err != nil {
  57 + response = utils.ResponseError(controller.Ctx, err)
  58 + } else {
  59 + response = utils.ResponseData(controller.Ctx, data)
  60 + }
  61 + controller.Data["json"] = response
  62 + controller.ServeJSON()
  63 +}
  64 +
  65 +func (controller *RoleController) RemoveRole() {
  66 + roleService := service.NewRoleService(nil)
  67 + removeRoleCommand := &command.RemoveRoleCommand{}
  68 + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), removeRoleCommand)
  69 + Id, _ := controller.GetInt64(":Id")
  70 + removeRoleCommand.RoleId = Id
  71 + data, err := roleService.RemoveRole(removeRoleCommand)
  72 + var response utils.JsonResponse
  73 + if err != nil {
  74 + response = utils.ResponseError(controller.Ctx, err)
  75 + } else {
  76 + response = utils.ResponseData(controller.Ctx, data)
  77 + }
  78 + controller.Data["json"] = response
  79 + controller.ServeJSON()
  80 +}
  81 +
  82 +func (controller *RoleController) ListRole() {
  83 + roleService := service.NewRoleService(nil)
  84 + listRoleQuery := &query.ListRoleQuery{}
  85 + offset, _ := controller.GetInt("offset")
  86 + listRoleQuery.Offset = offset
  87 + limit, _ := controller.GetInt("limit")
  88 + listRoleQuery.Limit = limit
  89 + data, err := roleService.ListRole(listRoleQuery)
  90 + var response utils.JsonResponse
  91 + if err != nil {
  92 + response = utils.ResponseError(controller.Ctx, err)
  93 + } else {
  94 + response = utils.ResponseData(controller.Ctx, data)
  95 + }
  96 + controller.Data["json"] = response
  97 + controller.ServeJSON()
  98 +}
  1 +package controllers
  2 +
  3 +import (
  4 + "encoding/json"
  5 +
  6 + "github.com/astaxie/beego"
  7 + "github.com/linmadan/egglib-go/web/beego/utils"
  8 + "github.com/tiptok/godevp/pkg/application/users/command"
  9 + "github.com/tiptok/godevp/pkg/application/users/query"
  10 + "github.com/tiptok/godevp/pkg/application/users/service"
  11 +)
  12 +
  13 +type UsersController struct {
  14 + beego.Controller
  15 +}
  16 +
  17 +func (controller *UsersController) CreateUsers() {
  18 + usersService := service.NewUsersService(nil)
  19 + createUsersCommand := &command.CreateUsersCommand{}
  20 + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), createUsersCommand)
  21 + data, err := usersService.CreateUsers(createUsersCommand)
  22 + var response utils.JsonResponse
  23 + if err != nil {
  24 + response = utils.ResponseError(controller.Ctx, err)
  25 + } else {
  26 + response = utils.ResponseData(controller.Ctx, data)
  27 + }
  28 + controller.Data["json"] = response
  29 + controller.ServeJSON()
  30 +}
  31 +
  32 +func (controller *UsersController) UpdateUsers() {
  33 + usersService := service.NewUsersService(nil)
  34 + updateUsersCommand := &command.UpdateUsersCommand{}
  35 + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), updateUsersCommand)
  36 + Id, _ := controller.GetInt64(":Id")
  37 + updateUsersCommand.UsersId = Id
  38 + data, err := usersService.UpdateUsers(updateUsersCommand)
  39 + var response utils.JsonResponse
  40 + if err != nil {
  41 + response = utils.ResponseError(controller.Ctx, err)
  42 + } else {
  43 + response = utils.ResponseData(controller.Ctx, data)
  44 + }
  45 + controller.Data["json"] = response
  46 + controller.ServeJSON()
  47 +}
  48 +
  49 +func (controller *UsersController) GetUsers() {
  50 + usersService := service.NewUsersService(nil)
  51 + getUsersQuery := &query.GetUsersQuery{}
  52 + Id, _ := controller.GetInt64(":Id")
  53 + getUsersQuery.UsersId = Id
  54 + data, err := usersService.GetUsers(getUsersQuery)
  55 + var response utils.JsonResponse
  56 + if err != nil {
  57 + response = utils.ResponseError(controller.Ctx, err)
  58 + } else {
  59 + response = utils.ResponseData(controller.Ctx, data)
  60 + }
  61 + controller.Data["json"] = response
  62 + controller.ServeJSON()
  63 +}
  64 +
  65 +func (controller *UsersController) RemoveUsers() {
  66 + usersService := service.NewUsersService(nil)
  67 + removeUsersCommand := &command.RemoveUsersCommand{}
  68 + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), removeUsersCommand)
  69 + Id, _ := controller.GetInt64(":Id")
  70 + removeUsersCommand.UsersId = Id
  71 + data, err := usersService.RemoveUsers(removeUsersCommand)
  72 + var response utils.JsonResponse
  73 + if err != nil {
  74 + response = utils.ResponseError(controller.Ctx, err)
  75 + } else {
  76 + response = utils.ResponseData(controller.Ctx, data)
  77 + }
  78 + controller.Data["json"] = response
  79 + controller.ServeJSON()
  80 +}
  81 +
  82 +func (controller *UsersController) ListUsers() {
  83 + usersService := service.NewUsersService(nil)
  84 + listUsersQuery := &query.ListUsersQuery{}
  85 + offset, _ := controller.GetInt("offset")
  86 + listUsersQuery.Offset = offset
  87 + limit, _ := controller.GetInt("limit")
  88 + listUsersQuery.Limit = limit
  89 + data, err := usersService.ListUsers(listUsersQuery)
  90 + var response utils.JsonResponse
  91 + if err != nil {
  92 + response = utils.ResponseError(controller.Ctx, err)
  93 + } else {
  94 + response = utils.ResponseData(controller.Ctx, data)
  95 + }
  96 + controller.Data["json"] = response
  97 + controller.ServeJSON()
  98 +}
  1 +package routers
  2 +
  3 +import (
  4 + "github.com/astaxie/beego"
  5 + "github.com/tiptok/godevp/pkg/port/beego/controllers"
  6 +)
  7 +
  8 +func init() {
  9 + beego.Router("/v1/role/", &controllers.RoleController{}, "Post:CreateRole")
  10 + beego.Router("/v1/role/:Id", &controllers.RoleController{}, "Put:UpdateRole")
  11 + beego.Router("/v1/role/:Id", &controllers.RoleController{}, "Get:GetRole")
  12 + beego.Router("/v1/role/:Id", &controllers.RoleController{}, "Delete:RemoveRole")
  13 + beego.Router("/v1/role/", &controllers.RoleController{}, "Get:ListRole")
  14 +}
  1 +package routers
  2 +
  3 +import (
  4 + "github.com/astaxie/beego"
  5 + "github.com/tiptok/godevp/pkg/port/beego/controllers"
  6 +)
  7 +
  8 +func init() {
  9 + beego.Router("/v1/user/", &controllers.UsersController{}, "Post:CreateUsers")
  10 + beego.Router("/v1/user/:Id", &controllers.UsersController{}, "Put:UpdateUsers")
  11 + beego.Router("/v1/user/:Id", &controllers.UsersController{}, "Get:GetUsers")
  12 + beego.Router("/v1/user/:Id", &controllers.UsersController{}, "Delete:RemoveUsers")
  13 + beego.Router("/v1/user/", &controllers.UsersController{}, "Get:ListUsers")
  14 +}
  1 +package role
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/gavv/httpexpect"
  7 + . "github.com/onsi/ginkgo"
  8 + . "github.com/onsi/gomega"
  9 + pG "github.com/tiptok/godevp/pkg/infrastructure/pg"
  10 +)
  11 +
  12 +var _ = Describe("创建", func() {
  13 + Describe("提交数据创建", func() {
  14 + Context("提交正确的新角色实体数据", func() {
  15 + It("返回角色实体数据", func() {
  16 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  17 + body := map[string]interface{}{
  18 + "Id": "int64",
  19 + "RoleName": "string",
  20 + }
  21 + httpExpect.POST("/roles/").
  22 + WithJSON(body).
  23 + Expect().
  24 + Status(http.StatusOK).
  25 + JSON().
  26 + Object().
  27 + ContainsKey("code").ValueEqual("code", 0).
  28 + ContainsKey("msg").ValueEqual("msg", "ok").
  29 + ContainsKey("data").Value("data").Object().
  30 + ContainsKey("id").ValueNotEqual("id", BeZero())
  31 + })
  32 + })
  33 + })
  34 + AfterEach(func() {
  35 + _, err := pG.DB.Exec("DELETE FROM roles WHERE true")
  36 + Expect(err).NotTo(HaveOccurred())
  37 + })
  38 +})
  1 +package role
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/gavv/httpexpect"
  7 + "github.com/go-pg/pg"
  8 + . "github.com/onsi/ginkgo"
  9 + . "github.com/onsi/gomega"
  10 + pG "github.com/tiptok/godevp/pkg/infrastructure/pg"
  11 +)
  12 +
  13 +var _ = Describe("返回", func() {
  14 + var roleId int64
  15 + BeforeEach(func() {
  16 + _, err := pG.DB.QueryOne(
  17 + pg.Scan(&roleId),
  18 + "INSERT INTO roles (id, role_name, parent_id, create_time, update_time) VALUES (?, ?, ?, ?, ?) RETURNING id",
  19 + "testId", "testRoleName", "testParentId", "testCreateTime", "testUpdateTime")
  20 + Expect(err).NotTo(HaveOccurred())
  21 + })
  22 + Describe("根据roleId参数返回角色实体", func() {
  23 + Context("传入有效的roleId", func() {
  24 + It("返回角色实体数据", func() {
  25 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  26 + httpExpect.GET("/roles/{Id}").
  27 + Expect().
  28 + Status(http.StatusOK).
  29 + JSON().
  30 + Object().
  31 + ContainsKey("code").ValueEqual("code", 0).
  32 + ContainsKey("msg").ValueEqual("msg", "ok").
  33 + ContainsKey("data").Value("data").Object()
  34 + })
  35 + })
  36 + })
  37 + AfterEach(func() {
  38 + _, err := pG.DB.Exec("DELETE FROM roles WHERE true")
  39 + Expect(err).NotTo(HaveOccurred())
  40 + })
  41 +})
  1 +package role
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/gavv/httpexpect"
  7 + "github.com/go-pg/pg"
  8 + . "github.com/onsi/ginkgo"
  9 + . "github.com/onsi/gomega"
  10 + pG "github.com/tiptok/godevp/pkg/infrastructure/pg"
  11 +)
  12 +
  13 +var _ = Describe("返回列表", func() {
  14 + var roleId int64
  15 + BeforeEach(func() {
  16 + _, err := pG.DB.QueryOne(
  17 + pg.Scan(&roleId),
  18 + "INSERT INTO roles (id, role_name, parent_id, create_time, update_time) VALUES (?, ?, ?, ?, ?) RETURNING id",
  19 + "testId", "testRoleName", "testParentId", "testCreateTime", "testUpdateTime")
  20 + Expect(err).NotTo(HaveOccurred())
  21 + })
  22 + Describe("根据参数返回角色实体列表", func() {
  23 + Context("传入有效的参数", func() {
  24 + It("返回角色实体数据列表", func() {
  25 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  26 + httpExpect.GET("/roles/").
  27 + WithQuery("offset", "int").
  28 + WithQuery("limit", "int").
  29 + Expect().
  30 + Status(http.StatusOK).
  31 + JSON().
  32 + Object().
  33 + ContainsKey("code").ValueEqual("code", 0).
  34 + ContainsKey("msg").ValueEqual("msg", "ok").
  35 + ContainsKey("data").Value("data").Object().
  36 + ContainsKey("count").ValueEqual("count", 1).
  37 + ContainsKey("roles").Value("roles").Array()
  38 + })
  39 + })
  40 + })
  41 + AfterEach(func() {
  42 + _, err := pG.DB.Exec("DELETE FROM roles WHERE true")
  43 + Expect(err).NotTo(HaveOccurred())
  44 + })
  45 +})
  1 +package role
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/gavv/httpexpect"
  7 + "github.com/go-pg/pg"
  8 + . "github.com/onsi/ginkgo"
  9 + . "github.com/onsi/gomega"
  10 + pG "github.com/tiptok/godevp/pkg/infrastructure/pg"
  11 +)
  12 +
  13 +var _ = Describe("移除", func() {
  14 + var roleId int64
  15 + BeforeEach(func() {
  16 + _, err := pG.DB.QueryOne(
  17 + pg.Scan(&roleId),
  18 + "INSERT INTO roles (id, role_name, parent_id, create_time, update_time) VALUES (?, ?, ?, ?, ?) RETURNING id",
  19 + "testId", "testRoleName", "testParentId", "testCreateTime", "testUpdateTime")
  20 + Expect(err).NotTo(HaveOccurred())
  21 + })
  22 + Describe("根据参数移除", func() {
  23 + Context("传入有效的roleId", func() {
  24 + It("返回被移除角色实体的数据", func() {
  25 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  26 + httpExpect.DELETE("/roles/{Id}").
  27 + Expect().
  28 + Status(http.StatusOK).
  29 + JSON().
  30 + Object().
  31 + ContainsKey("code").ValueEqual("code", 0).
  32 + ContainsKey("msg").ValueEqual("msg", "ok").
  33 + ContainsKey("data").Value("data").Object()
  34 + })
  35 + })
  36 + })
  37 + AfterEach(func() {
  38 + _, err := pG.DB.Exec("DELETE FROM roles WHERE true")
  39 + Expect(err).NotTo(HaveOccurred())
  40 + })
  41 +})
  1 +package role
  2 +
  3 +import (
  4 + "net/http"
  5 + "net/http/httptest"
  6 + "testing"
  7 +
  8 + "github.com/astaxie/beego"
  9 + . "github.com/onsi/ginkgo"
  10 + . "github.com/onsi/gomega"
  11 + _ "github.com/tiptok/godevp/pkg/infrastructure/pg"
  12 + _ "github.com/tiptok/godevp/pkg/port/beego"
  13 +)
  14 +
  15 +func TestRole(t *testing.T) {
  16 + RegisterFailHandler(Fail)
  17 + RunSpecs(t, "Beego Port Role Correlations Test Case Suite")
  18 +}
  19 +
  20 +var handler http.Handler
  21 +var server *httptest.Server
  22 +
  23 +var _ = BeforeSuite(func() {
  24 + handler = beego.BeeApp.Handlers
  25 + server = httptest.NewServer(handler)
  26 +})
  27 +
  28 +var _ = AfterSuite(func() {
  29 + server.Close()
  30 +})
  1 +package role
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/gavv/httpexpect"
  7 + "github.com/go-pg/pg"
  8 + . "github.com/onsi/ginkgo"
  9 + . "github.com/onsi/gomega"
  10 + pG "github.com/tiptok/godevp/pkg/infrastructure/pg"
  11 +)
  12 +
  13 +var _ = Describe("更新", func() {
  14 + var roleId int64
  15 + BeforeEach(func() {
  16 + _, err := pG.DB.QueryOne(
  17 + pg.Scan(&roleId),
  18 + "INSERT INTO roles (id, role_name, parent_id, create_time, update_time) VALUES (?, ?, ?, ?, ?) RETURNING id",
  19 + "testId", "testRoleName", "testParentId", "testCreateTime", "testUpdateTime")
  20 + Expect(err).NotTo(HaveOccurred())
  21 + })
  22 + Describe("提交数据更新", func() {
  23 + Context("提交正确的角色实体数据", func() {
  24 + It("返回更新后的角色实体数据", func() {
  25 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  26 + body := map[string]interface{}{
  27 + "RoleId": "int64",
  28 + }
  29 + httpExpect.PUT("/roles/{Id}").
  30 + WithJSON(body).
  31 + Expect().
  32 + Status(http.StatusOK).
  33 + JSON().
  34 + Object().
  35 + ContainsKey("code").ValueEqual("code", 0).
  36 + ContainsKey("msg").ValueEqual("msg", "ok").
  37 + ContainsKey("data").Value("data").Object().
  38 + ContainsKey("id").ValueEqual("id", roleId)
  39 + })
  40 + })
  41 + })
  42 + AfterEach(func() {
  43 + _, err := pG.DB.Exec("DELETE FROM roles WHERE true")
  44 + Expect(err).NotTo(HaveOccurred())
  45 + })
  46 +})
  1 +package users
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/gavv/httpexpect"
  7 + . "github.com/onsi/ginkgo"
  8 + . "github.com/onsi/gomega"
  9 + pG "github.com/tiptok/godevp/pkg/infrastructure/pg"
  10 +)
  11 +
  12 +var _ = Describe("创建", func() {
  13 + Describe("提交数据创建", func() {
  14 + Context("提交正确的新用户实体数据", func() {
  15 + It("返回用户实体数据", func() {
  16 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  17 + body := map[string]interface{}{
  18 + "name": "string",
  19 + "phone": "string",
  20 + }
  21 + httpExpect.POST("/userss/").
  22 + WithJSON(body).
  23 + Expect().
  24 + Status(http.StatusOK).
  25 + JSON().
  26 + Object().
  27 + ContainsKey("code").ValueEqual("code", 0).
  28 + ContainsKey("msg").ValueEqual("msg", "ok").
  29 + ContainsKey("data").Value("data").Object().
  30 + ContainsKey("id").ValueNotEqual("id", BeZero())
  31 + })
  32 + })
  33 + })
  34 + AfterEach(func() {
  35 + _, err := pG.DB.Exec("DELETE FROM userss WHERE true")
  36 + Expect(err).NotTo(HaveOccurred())
  37 + })
  38 +})
  1 +package users
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/gavv/httpexpect"
  7 + "github.com/go-pg/pg"
  8 + . "github.com/onsi/ginkgo"
  9 + . "github.com/onsi/gomega"
  10 + pG "github.com/tiptok/godevp/pkg/infrastructure/pg"
  11 +)
  12 +
  13 +var _ = Describe("返回", func() {
  14 + var usersId int64
  15 + BeforeEach(func() {
  16 + _, err := pG.DB.QueryOne(
  17 + pg.Scan(&usersId),
  18 + "INSERT INTO userss (id, name, phone, passwd, roles, status, admin_type, create_time, update_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id",
  19 + "testId", "testName", "testPhone", "testPasswd", "testRoles", "testStatus", "testAdminType", "testCreateTime", "testUpdateTime")
  20 + Expect(err).NotTo(HaveOccurred())
  21 + })
  22 + Describe("根据usersId参数返回用户实体", func() {
  23 + Context("传入有效的usersId", func() {
  24 + It("返回用户实体数据", func() {
  25 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  26 + httpExpect.GET("/userss/{Id}").
  27 + Expect().
  28 + Status(http.StatusOK).
  29 + JSON().
  30 + Object().
  31 + ContainsKey("code").ValueEqual("code", 0).
  32 + ContainsKey("msg").ValueEqual("msg", "ok").
  33 + ContainsKey("data").Value("data").Object()
  34 + })
  35 + })
  36 + })
  37 + AfterEach(func() {
  38 + _, err := pG.DB.Exec("DELETE FROM userss WHERE true")
  39 + Expect(err).NotTo(HaveOccurred())
  40 + })
  41 +})
  1 +package users
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/gavv/httpexpect"
  7 + "github.com/go-pg/pg"
  8 + . "github.com/onsi/ginkgo"
  9 + . "github.com/onsi/gomega"
  10 + pG "github.com/tiptok/godevp/pkg/infrastructure/pg"
  11 +)
  12 +
  13 +var _ = Describe("返回列表", func() {
  14 + var usersId int64
  15 + BeforeEach(func() {
  16 + _, err := pG.DB.QueryOne(
  17 + pg.Scan(&usersId),
  18 + "INSERT INTO userss (id, name, phone, passwd, roles, status, admin_type, create_time, update_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id",
  19 + "testId", "testName", "testPhone", "testPasswd", "testRoles", "testStatus", "testAdminType", "testCreateTime", "testUpdateTime")
  20 + Expect(err).NotTo(HaveOccurred())
  21 + })
  22 + Describe("根据参数返回用户实体列表", func() {
  23 + Context("传入有效的参数", func() {
  24 + It("返回用户实体数据列表", func() {
  25 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  26 + httpExpect.GET("/userss/").
  27 + WithQuery("offset", "int").
  28 + WithQuery("limit", "int").
  29 + Expect().
  30 + Status(http.StatusOK).
  31 + JSON().
  32 + Object().
  33 + ContainsKey("code").ValueEqual("code", 0).
  34 + ContainsKey("msg").ValueEqual("msg", "ok").
  35 + ContainsKey("data").Value("data").Object().
  36 + ContainsKey("count").ValueEqual("count", 1).
  37 + ContainsKey("userss").Value("userss").Array()
  38 + })
  39 + })
  40 + })
  41 + AfterEach(func() {
  42 + _, err := pG.DB.Exec("DELETE FROM userss WHERE true")
  43 + Expect(err).NotTo(HaveOccurred())
  44 + })
  45 +})
  1 +package users
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/gavv/httpexpect"
  7 + "github.com/go-pg/pg"
  8 + . "github.com/onsi/ginkgo"
  9 + . "github.com/onsi/gomega"
  10 + pG "github.com/tiptok/godevp/pkg/infrastructure/pg"
  11 +)
  12 +
  13 +var _ = Describe("移除", func() {
  14 + var usersId int64
  15 + BeforeEach(func() {
  16 + _, err := pG.DB.QueryOne(
  17 + pg.Scan(&usersId),
  18 + "INSERT INTO userss (id, name, phone, passwd, roles, status, admin_type, create_time, update_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id",
  19 + "testId", "testName", "testPhone", "testPasswd", "testRoles", "testStatus", "testAdminType", "testCreateTime", "testUpdateTime")
  20 + Expect(err).NotTo(HaveOccurred())
  21 + })
  22 + Describe("根据参数移除", func() {
  23 + Context("传入有效的usersId", func() {
  24 + It("返回被移除用户实体的数据", func() {
  25 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  26 + httpExpect.DELETE("/userss/{Id}").
  27 + Expect().
  28 + Status(http.StatusOK).
  29 + JSON().
  30 + Object().
  31 + ContainsKey("code").ValueEqual("code", 0).
  32 + ContainsKey("msg").ValueEqual("msg", "ok").
  33 + ContainsKey("data").Value("data").Object()
  34 + })
  35 + })
  36 + })
  37 + AfterEach(func() {
  38 + _, err := pG.DB.Exec("DELETE FROM userss WHERE true")
  39 + Expect(err).NotTo(HaveOccurred())
  40 + })
  41 +})
  1 +package users
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/gavv/httpexpect"
  7 + "github.com/go-pg/pg"
  8 + . "github.com/onsi/ginkgo"
  9 + . "github.com/onsi/gomega"
  10 + pG "github.com/tiptok/godevp/pkg/infrastructure/pg"
  11 +)
  12 +
  13 +var _ = Describe("更新", func() {
  14 + var usersId int64
  15 + BeforeEach(func() {
  16 + _, err := pG.DB.QueryOne(
  17 + pg.Scan(&usersId),
  18 + "INSERT INTO userss (id, name, phone, passwd, roles, status, admin_type, create_time, update_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id",
  19 + "testId", "testName", "testPhone", "testPasswd", "testRoles", "testStatus", "testAdminType", "testCreateTime", "testUpdateTime")
  20 + Expect(err).NotTo(HaveOccurred())
  21 + })
  22 + Describe("提交数据更新", func() {
  23 + Context("提交正确的用户实体数据", func() {
  24 + It("返回更新后的用户实体数据", func() {
  25 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  26 + body := map[string]interface{}{
  27 + "usersId": "int64",
  28 + }
  29 + httpExpect.PUT("/userss/{Id}").
  30 + WithJSON(body).
  31 + Expect().
  32 + Status(http.StatusOK).
  33 + JSON().
  34 + Object().
  35 + ContainsKey("code").ValueEqual("code", 0).
  36 + ContainsKey("msg").ValueEqual("msg", "ok").
  37 + ContainsKey("data").Value("data").Object().
  38 + ContainsKey("id").ValueEqual("id", usersId)
  39 + })
  40 + })
  41 + })
  42 + AfterEach(func() {
  43 + _, err := pG.DB.Exec("DELETE FROM userss WHERE true")
  44 + Expect(err).NotTo(HaveOccurred())
  45 + })
  46 +})
  1 +package users
  2 +
  3 +import (
  4 + "net/http"
  5 + "net/http/httptest"
  6 + "testing"
  7 +
  8 + "github.com/astaxie/beego"
  9 + . "github.com/onsi/ginkgo"
  10 + . "github.com/onsi/gomega"
  11 + _ "github.com/tiptok/godevp/pkg/infrastructure/pg"
  12 + _ "github.com/tiptok/godevp/pkg/port/beego"
  13 +)
  14 +
  15 +func TestUsers(t *testing.T) {
  16 + RegisterFailHandler(Fail)
  17 + RunSpecs(t, "Beego Port Users Correlations Test Case Suite")
  18 +}
  19 +
  20 +var handler http.Handler
  21 +var server *httptest.Server
  22 +
  23 +var _ = BeforeSuite(func() {
  24 + handler = beego.BeeApp.Handlers
  25 + server = httptest.NewServer(handler)
  26 +})
  27 +
  28 +var _ = AfterSuite(func() {
  29 + server.Close()
  30 +})