3 Commits

Author SHA1 Message Date
ZHANGZENGNING e44e002291 zzn4.29后端代码第一次提交 3 weeks ago
ZHANGZENGNING b16d36d4dd 投票系统 4.29 3 weeks ago
ZHANGZENGNING 04b7e67c11 初始化 3 weeks ago
  1. 1
      .gitattributes
  2. 19
      .gitignore
  3. 4
      .idea/material_theme_project_new.xml
  4. 7
      Makefile
  5. 4
      README.MD
  6. 18
      api/v1/vote/vote.go
  7. 45
      go.mod
  8. 94
      go.sum
  9. 16
      hack/config.yaml
  10. 20
      hack/hack-cli.mk
  11. 75
      hack/hack.mk
  12. 34
      internal/cmd/cmd.go
  13. 1
      internal/consts/consts.go
  14. 76
      internal/controller/vote.go
  15. 0
      internal/dao/.gitkeep
  16. 27
      internal/dao/float_window.go
  17. 91
      internal/dao/internal/float_window.go
  18. 89
      internal/dao/internal/member_info.go
  19. 83
      internal/dao/internal/vote_records.go
  20. 27
      internal/dao/member_info.go
  21. 27
      internal/dao/vote_records.go
  22. 0
      internal/logic/.gitkeep
  23. 124
      internal/logic/vote.go
  24. 0
      internal/model/.gitkeep
  25. 0
      internal/model/do/.gitkeep
  26. 25
      internal/model/do/float_window.go
  27. 23
      internal/model/do/member_info.go
  28. 21
      internal/model/do/vote_records.go
  29. 80
      internal/model/dto/Result.go
  30. 13
      internal/model/dto/activityDto.go
  31. 12
      internal/model/dto/voteDto.go
  32. 0
      internal/model/entity/.gitkeep
  33. 23
      internal/model/entity/float_window.go
  34. 18
      internal/model/entity/member_info.go
  35. 19
      internal/model/entity/vote_records.go
  36. 1
      internal/packed/packed.go
  37. 0
      internal/service/.gitkeep
  38. 34
      internal/service/vote.go
  39. 16
      main.go
  40. 21
      manifest/deploy/kustomize/base/deployment.yaml
  41. 8
      manifest/deploy/kustomize/base/kustomization.yaml
  42. 12
      manifest/deploy/kustomize/base/service.yaml
  43. 14
      manifest/deploy/kustomize/overlays/develop/configmap.yaml
  44. 10
      manifest/deploy/kustomize/overlays/develop/deployment.yaml
  45. 14
      manifest/deploy/kustomize/overlays/develop/kustomization.yaml
  46. 16
      manifest/docker/Dockerfile
  47. 8
      manifest/docker/docker.sh
  48. 0
      manifest/i18n/.gitkeep
  49. 0
      manifest/protobuf/.keep-if-necessary
  50. 0
      resource/public/html/.gitkeep
  51. 0
      resource/public/plugin/.gitkeep
  52. 0
      resource/public/resource/css/.gitkeep
  53. 0
      resource/public/resource/image/.gitkeep
  54. 0
      resource/public/resource/js/.gitkeep
  55. 0
      resource/template/.gitkeep
  56. 0
      utility/.gitkeep

1
.gitattributes

@ -0,0 +1 @@
* linguist-language=GO

19
.gitignore

@ -0,0 +1,19 @@
.buildpath
.hgignore.swp
.project
.orig
.swp
.idea/
.settings/
.vscode/
bin/
**/.DS_Store
gf
main
main.exe
output/
manifest/output/
temp/
temp.yaml
bin
**/config/config.yaml

4
.idea/material_theme_project_new.xml

@ -3,7 +3,9 @@
<component name="MaterialThemeProjectNewConfig">
<option name="metadata">
<MTProjectMetadataState>
<option name="userId" value="-7a328c97:19665a4d1f8:-7e83" />
<option name="migrated" value="true" />
<option name="pristineConfig" value="false" />
<option name="userId" value="-7a63e17c:19622cf3528:-7ffe" />
</MTProjectMetadataState>
</option>
</component>

7
Makefile

@ -0,0 +1,7 @@
ROOT_DIR = $(shell pwd)
NAMESPACE = "default"
DEPLOY_NAME = "template-single"
DOCKER_NAME = "template-single"
include ./hack/hack-cli.mk
include ./hack/hack.mk

4
README.MD

@ -0,0 +1,4 @@
# GoFrame Template For SingleRepo
Quick Start:
- https://goframe.org/quick

18
api/v1/vote/vote.go

@ -0,0 +1,18 @@
package vote
// 条件筛选
type GetVoteDetailListReq struct {
PageNo int `v:"required" json:"pageNo" dc:"页码" d:"1"`
PageSize int `v:"required" json:"pageSize" dc:"页面大小" d:"10"`
ActivityId int `v:"required" json:"activityId" dc:"活动id"`
Jwcode string `json:"jwcode" dc:"查询条件中的精网号"`
Dept string `json:"dept" dc:"查询条件中的部门"`
StartDate string `json:"startDate" dc:"开始时间"`
EndDate string `json:"endDate" dc:"结束时间"`
//StartTime *gtime.Time `json:"startTime" dc:"开始时间"`
// EndTime *gtime.Time `json:"endTime" dc:"结束时间"`
}
type GetActivityListReq struct {
PageNo int `v:"required" json:"pageNo" dc:"页码" d:"1"`
PageSize int `v:"required" json:"pageSize" dc:"页面大小" d:"24"`
}

45
go.mod

@ -0,0 +1,45 @@
module VoteManage_Go
go 1.22
toolchain go1.23.8
require (
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.9.0
github.com/gogf/gf/v2 v2.9.0
github.com/xuri/excelize/v2 v2.9.0
)
require (
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/clbanning/mxj/v2 v2.7.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-sql-driver/mysql v1.7.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/grokify/html-strip-tags-go v0.1.0 // indirect
github.com/magiconair/properties v1.8.9 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/richardlehane/mscfb v1.0.4 // indirect
github.com/richardlehane/msoleps v1.0.4 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/xuri/efp v0.0.0-20240408161823-9ad904a10d6d // indirect
github.com/xuri/nfp v0.0.0-20240318013403-ab9948c2c4a7 // indirect
go.opentelemetry.io/otel v1.32.0 // indirect
go.opentelemetry.io/otel/metric v1.32.0 // indirect
go.opentelemetry.io/otel/sdk v1.32.0 // indirect
go.opentelemetry.io/otel/trace v1.32.0 // indirect
golang.org/x/crypto v0.30.0 // indirect
golang.org/x/net v0.32.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

94
go.sum

@ -0,0 +1,94 @@
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME=
github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.9.0 h1:1f7EeD0lfPHoXfaJDSL7cxRcSRelbsAKgF3MGXY+Uyo=
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.9.0/go.mod h1:tToO1PjGkLIR+9DbJ0wrKicYma0H/EUHXOpwel6Dw+0=
github.com/gogf/gf/v2 v2.9.0 h1:semN5Q5qGjDQEv4620VzxcJzJlSD07gmyJ9Sy9zfbHk=
github.com/gogf/gf/v2 v2.9.0/go.mod h1:sWGQw+pLILtuHmbOxoe0D+0DdaXxbleT57axOLH2vKI=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4=
github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/magiconair/properties v1.8.9 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM=
github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/richardlehane/mscfb v1.0.4 h1:WULscsljNPConisD5hR0+OyZjwK46Pfyr6mPu5ZawpM=
github.com/richardlehane/mscfb v1.0.4/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk=
github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
github.com/richardlehane/msoleps v1.0.4 h1:WuESlvhX3gH2IHcd8UqyCuFY5yiq/GR/yqaSM/9/g00=
github.com/richardlehane/msoleps v1.0.4/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/xuri/efp v0.0.0-20240408161823-9ad904a10d6d h1:llb0neMWDQe87IzJLS4Ci7psK/lVsjIS2otl+1WyRyY=
github.com/xuri/efp v0.0.0-20240408161823-9ad904a10d6d/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
github.com/xuri/excelize/v2 v2.9.0 h1:1tgOaEq92IOEumR1/JfYS/eR0KHOCsRv/rYXXh6YJQE=
github.com/xuri/excelize/v2 v2.9.0/go.mod h1:uqey4QBZ9gdMeWApPLdhm9x+9o2lq4iVmjiLfBS5hdE=
github.com/xuri/nfp v0.0.0-20240318013403-ab9948c2c4a7 h1:hPVCafDV85blFTabnqKgNhDCkJX25eik94Si9cTER4A=
github.com/xuri/nfp v0.0.0-20240318013403-ab9948c2c4a7/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ=
go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U=
go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg=
go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M=
go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8=
go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5lEG4=
go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU=
go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM=
go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8=
golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY=
golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ=
golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E=
golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI=
golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

16
hack/config.yaml

@ -0,0 +1,16 @@
# CLI tool, only in development environment.
# https://goframe.org/docs/cli
gfcli:
gen:
dao:
- link: "mysql:shequ:7bMDPChJSdLMAwNR@tcp(121.89.234.155:3306)/shequ"
descriptionTag: true
tables: "member_info,vote_records"
- link: "mysql:live:p4jMAMShNM8HTrbX@tcp(39.101.133.168:3306)/live"
descriptionTag: true
tables: "float_window"
docker:
build: "-a amd64 -s linux -p temp -ew"
tagPrefixes:
- my.image.pub/my-app

20
hack/hack-cli.mk

@ -0,0 +1,20 @@
# Install/Update to the latest CLI tool.
.PHONY: cli
cli:
@set -e; \
wget -O gf \
https://github.com/gogf/gf/releases/latest/download/gf_$(shell go env GOOS)_$(shell go env GOARCH) && \
chmod +x gf && \
./gf install -y && \
rm ./gf
# Check and install CLI tool.
.PHONY: cli.install
cli.install:
@set -e; \
gf -v > /dev/null 2>&1 || if [[ "$?" -ne "0" ]]; then \
echo "GoFame CLI is not installed, start proceeding auto installation..."; \
make cli; \
fi;

75
hack/hack.mk

@ -0,0 +1,75 @@
.DEFAULT_GOAL := build
# Update GoFrame and its CLI to latest stable version.
.PHONY: up
up: cli.install
@gf up -a
# Build binary using configuration from hack/config.yaml.
.PHONY: build
build: cli.install
@gf build -ew
# Parse api and generate controller/sdk.
.PHONY: ctrl
ctrl: cli.install
@gf gen ctrl
# Generate Go files for DAO/DO/Entity.
.PHONY: dao
dao: cli.install
@gf gen dao
# Parse current project go files and generate enums go file.
.PHONY: enums
enums: cli.install
@gf gen enums
# Generate Go files for Service.
.PHONY: service
service: cli.install
@gf gen service
# Build docker image.
.PHONY: image
image: cli.install
$(eval _TAG = $(shell git rev-parse --short HEAD))
ifneq (, $(shell git status --porcelain 2>/dev/null))
$(eval _TAG = $(_TAG).dirty)
endif
$(eval _TAG = $(if ${TAG}, ${TAG}, $(_TAG)))
$(eval _PUSH = $(if ${PUSH}, ${PUSH}, ))
@gf docker ${_PUSH} -tn $(DOCKER_NAME):${_TAG};
# Build docker image and automatically push to docker repo.
.PHONY: image.push
image.push: cli.install
@make image PUSH=-p;
# Deploy image and yaml to current kubectl environment.
.PHONY: deploy
deploy: cli.install
$(eval _TAG = $(if ${TAG}, ${TAG}, develop))
@set -e; \
mkdir -p $(ROOT_DIR)/temp/kustomize;\
cd $(ROOT_DIR)/manifest/deploy/kustomize/overlays/${_ENV};\
kustomize build > $(ROOT_DIR)/temp/kustomize.yaml;\
kubectl apply -f $(ROOT_DIR)/temp/kustomize.yaml; \
if [ $(DEPLOY_NAME) != "" ]; then \
kubectl patch -n $(NAMESPACE) deployment/$(DEPLOY_NAME) -p "{\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"date\":\"$(shell date +%s)\"}}}}}"; \
fi;
# Parsing protobuf files and generating go files.
.PHONY: pb
pb: cli.install
@gf gen pb
# Generate protobuf files for database tables.
.PHONY: pbentity
pbentity: cli.install
@gf gen pbentity

34
internal/cmd/cmd.go

@ -0,0 +1,34 @@
package cmd
import (
"VoteManage_Go/internal/controller"
"context"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
"github.com/gogf/gf/v2/os/gcmd"
)
func MiddlewareCORS(r *ghttp.Request) {
r.Response.CORSDefault()
r.Middleware.Next()
}
var (
Main = gcmd.Command{
Name: "main",
Usage: "main",
Brief: "start http server",
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
s := g.Server()
s.Group("/api", func(group *ghttp.RouterGroup) {
group.Middleware(MiddlewareCORS)
group.POST("/vote", controller.Vote().GetVoteDetailList)
group.POST("/export", controller.Vote().ExportVote)
group.POST("/activity", controller.Vote().GetActivityList)
})
s.Run()
return nil
},
}
)

1
internal/consts/consts.go

@ -0,0 +1 @@
package consts

76
internal/controller/vote.go

@ -0,0 +1,76 @@
package controller
import (
"VoteManage_Go/api/v1/vote"
"VoteManage_Go/internal/model/dto"
"VoteManage_Go/internal/service"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
)
type cVote struct{}
func Vote() *cVote {
return &cVote{}
}
func (c cVote) GetVoteDetailList(r *ghttp.Request) {
var req *vote.GetVoteDetailListReq
if err := r.Parse(&req); err != nil {
r.Response.WriteJsonExit(dto.Result{
Code: 400,
Message: err.Error(),
})
}
res, total, err := service.Vote().GetVoteByCondition(r.Context(), req)
if err != nil {
r.Response.WriteJsonExit(dto.Result{
Code: 400,
Message: err.Error(),
})
}
r.Response.WriteJsonExit(dto.Result{
Code: 200,
Message: "success",
Data: g.Map{
"list": res,
"total": total,
},
})
}
func (c *cVote) ExportVote(r *ghttp.Request) {
var req *vote.GetVoteDetailListReq
// 解析请求参数
if err := r.Parse(&req); err != nil {
r.Response.WriteJsonExit(dto.Error(err.Error()))
}
//查询数据,创建excel文件,设置表头,写入数据,设置文件名,保存到缓冲区并返回,设置响应头,指定内容类型为excel文件,指定文件名为fileName,将buffer中的内容写入响应
service.Vote().ExportVote(r, req)
}
func (c *cVote) GetActivityList(r *ghttp.Request) {
var req *vote.GetActivityListReq
if err := r.Parse(&req); err != nil {
r.Response.WriteJsonExit(dto.Result{
Code: 400,
Message: err.Error(),
})
}
res, total, err := service.Vote().GetActivityList(r.Context(), req)
if err != nil {
r.Response.WriteJsonExit(dto.Result{
Code: 400,
Message: err.Error(),
})
}
r.Response.WriteJsonExit(dto.Result{
Code: 200,
Message: "success",
Data: g.Map{
"list": res,
"total": total,
},
})
}

0
internal/dao/.gitkeep

27
internal/dao/float_window.go

@ -0,0 +1,27 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package dao
import (
"VoteManage_Go/internal/dao/internal"
)
// internalFloatWindowDao is internal type for wrapping internal DAO implements.
type internalFloatWindowDao = *internal.FloatWindowDao
// floatWindowDao is the data access object for table float_window.
// You can define custom methods on it to extend its functionality as you wish.
type floatWindowDao struct {
internalFloatWindowDao
}
var (
// FloatWindow is globally public accessible object for table float_window operations.
FloatWindow = floatWindowDao{
internal.NewFloatWindowDao(),
}
)
// Fill with you ideas below.

91
internal/dao/internal/float_window.go

@ -0,0 +1,91 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// FloatWindowDao is the data access object for table float_window.
type FloatWindowDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of current DAO.
columns FloatWindowColumns // columns contains all the column names of Table for convenient usage.
}
// FloatWindowColumns defines and stores column names for table float_window.
type FloatWindowColumns struct {
Id string // 自增id
Title string // 标题
Icon string // 图标
Start string // 开始日期
End string // 结束日期
Url string // 活动地址
Markets string // 市场 my,sg,th,vi,can,hk
MemberLimit string // 用户权限 1:非网 2:半年版 3:终免
CreatedAt string //
UpdatedAt string //
}
// floatWindowColumns holds the columns for table float_window.
var floatWindowColumns = FloatWindowColumns{
Id: "id",
Title: "title",
Icon: "icon",
Start: "start",
End: "end",
Url: "url",
Markets: "markets",
MemberLimit: "member_limit",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
}
// NewFloatWindowDao creates and returns a new DAO object for table data access.
func NewFloatWindowDao() *FloatWindowDao {
return &FloatWindowDao{
group: "default",
table: "float_window",
columns: floatWindowColumns,
}
}
// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *FloatWindowDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of current dao.
func (dao *FloatWindowDao) Table() string {
return dao.table
}
// Columns returns all column names of current dao.
func (dao *FloatWindowDao) Columns() FloatWindowColumns {
return dao.columns
}
// Group returns the configuration group name of database of current dao.
func (dao *FloatWindowDao) Group() string {
return dao.group
}
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *FloatWindowDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *FloatWindowDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

89
internal/dao/internal/member_info.go

@ -0,0 +1,89 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// MemberInfoDao is the data access object for table member_info.
type MemberInfoDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of current DAO.
columns MemberInfoColumns // columns contains all the column names of Table for convenient usage.
}
// MemberInfoColumns defines and stores column names for table member_info.
type MemberInfoColumns struct {
Id string //
Jwcode string //
Nickname string //
Img string //
Medal string // 体验官勋章url
LocMarket string //
Dept string //
Shop string //
BoguMember string // 1:博股会员,0:不是
}
// memberInfoColumns holds the columns for table member_info.
var memberInfoColumns = MemberInfoColumns{
Id: "id",
Jwcode: "jwcode",
Nickname: "nickname",
Img: "img",
Medal: "medal",
LocMarket: "loc_market",
Dept: "dept",
Shop: "shop",
BoguMember: "bogu_member",
}
// NewMemberInfoDao creates and returns a new DAO object for table data access.
func NewMemberInfoDao() *MemberInfoDao {
return &MemberInfoDao{
group: "default",
table: "member_info",
columns: memberInfoColumns,
}
}
// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *MemberInfoDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of current dao.
func (dao *MemberInfoDao) Table() string {
return dao.table
}
// Columns returns all column names of current dao.
func (dao *MemberInfoDao) Columns() MemberInfoColumns {
return dao.columns
}
// Group returns the configuration group name of database of current dao.
func (dao *MemberInfoDao) Group() string {
return dao.group
}
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *MemberInfoDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *MemberInfoDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

83
internal/dao/internal/vote_records.go

@ -0,0 +1,83 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// VoteRecordsDao is the data access object for table vote_records.
type VoteRecordsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of current DAO.
columns VoteRecordsColumns // columns contains all the column names of Table for convenient usage.
}
// VoteRecordsColumns defines and stores column names for table vote_records.
type VoteRecordsColumns struct {
Id string //
Jwcode string //
VoteDate string //
Time string //
OptionsTitle string //
ActivityId string // 活动id
}
// voteRecordsColumns holds the columns for table vote_records.
var voteRecordsColumns = VoteRecordsColumns{
Id: "id",
Jwcode: "jwcode",
VoteDate: "vote_date",
Time: "time",
OptionsTitle: "options_title",
ActivityId: "activity_id",
}
// NewVoteRecordsDao creates and returns a new DAO object for table data access.
func NewVoteRecordsDao() *VoteRecordsDao {
return &VoteRecordsDao{
group: "default",
table: "vote_records",
columns: voteRecordsColumns,
}
}
// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *VoteRecordsDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of current dao.
func (dao *VoteRecordsDao) Table() string {
return dao.table
}
// Columns returns all column names of current dao.
func (dao *VoteRecordsDao) Columns() VoteRecordsColumns {
return dao.columns
}
// Group returns the configuration group name of database of current dao.
func (dao *VoteRecordsDao) Group() string {
return dao.group
}
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *VoteRecordsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *VoteRecordsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

27
internal/dao/member_info.go

@ -0,0 +1,27 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package dao
import (
"VoteManage_Go/internal/dao/internal"
)
// internalMemberInfoDao is internal type for wrapping internal DAO implements.
type internalMemberInfoDao = *internal.MemberInfoDao
// memberInfoDao is the data access object for table member_info.
// You can define custom methods on it to extend its functionality as you wish.
type memberInfoDao struct {
internalMemberInfoDao
}
var (
// MemberInfo is globally public accessible object for table member_info operations.
MemberInfo = memberInfoDao{
internal.NewMemberInfoDao(),
}
)
// Fill with you ideas below.

27
internal/dao/vote_records.go

@ -0,0 +1,27 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package dao
import (
"VoteManage_Go/internal/dao/internal"
)
// internalVoteRecordsDao is internal type for wrapping internal DAO implements.
type internalVoteRecordsDao = *internal.VoteRecordsDao
// voteRecordsDao is the data access object for table vote_records.
// You can define custom methods on it to extend its functionality as you wish.
type voteRecordsDao struct {
internalVoteRecordsDao
}
var (
// VoteRecords is globally public accessible object for table vote_records operations.
VoteRecords = voteRecordsDao{
internal.NewVoteRecordsDao(),
}
)
// Fill with you ideas below.

0
internal/logic/.gitkeep

124
internal/logic/vote.go

@ -0,0 +1,124 @@
package logic
import (
"VoteManage_Go/api/v1/vote"
"VoteManage_Go/internal/dao"
"VoteManage_Go/internal/model/dto"
"VoteManage_Go/internal/service"
"context"
"fmt"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
"github.com/gogf/gf/v2/os/gtime"
"github.com/xuri/excelize/v2"
"net/url"
"strconv"
"time"
)
type sVote struct{}
func init() {
service.RegisterVote(New())
}
func New() *sVote {
return &sVote{}
}
func (s *sVote) GetVoteByCondition(ctx context.Context, req *vote.GetVoteDetailListReq) (votes []*dto.VoteDto, total int, err error) {
query := g.Model("vote_records v").LeftJoin("member_info m", "v.jwcode = m.jwcode").
Fields("v.id, m.nickname, v.jwcode, m.dept, v.options_title, v.time").
Where("v.activity_id = ?", req.ActivityId)
// 条件1:jwcode输入(精确匹配)
if req.Jwcode != "" {
query = query.Where("v.jwcode = ?", req.Jwcode)
}
// 条件2:地区dept下拉框(精确匹配)dept是汉字
if req.Dept != "" {
query = query.Where("m.dept = ?", req.Dept)
}
// 条件3:投票日期范围(时间戳转换)
//if req.StartTime != nil && req.EndTime != nil {
// // 将前端日期字符串转为Unix时间戳(示例:2025.04.01 00:00:00 → 时间戳)
// query = query.Where("v.time BETWEEN ? AND ?", req.StartTime.Unix(), req.EndTime.Unix())
//}
if req.StartDate != "" && req.EndDate != "" {
start := gtime.New(req.StartDate + " 00:00:00").Unix()
end := gtime.New(req.EndDate + " 23:59:59").Unix()
query = query.Where("v.time BETWEEN ? AND ?", start, end)
}
// 条件4:分页
query.Page(req.PageNo, req.PageSize).ScanAndCount(&votes, &total, false)
return
}
func (s *sVote) ExportVote(r *ghttp.Request, req *vote.GetVoteDetailListReq) {
votes, _, err := s.GetVoteByCondition(r.Context(), req)
if err != nil {
r.Response.WriteJsonExit(dto.Error("查询失败:" + err.Error()))
return
}
if len(votes) == 0 {
r.Response.WriteJsonExit(dto.Error("查询结果为空"))
return
}
// 内存中创建Excel文件(不落盘)
excelFile := excelize.NewFile()
sheetName := "投票记录"
excelFile.SetSheetName("Sheet1", sheetName)
// 设置表头样式
headers := []string{"序号", "姓名", "精网号", "地区", "投票明细", "投票时间"}
for i, header := range headers {
col := string('A' + i)
excelFile.SetCellValue(sheetName, col+"1", header)
excelFile.SetColWidth(sheetName, col, col, 18) // 列宽调整
}
// 动态写入数据
for rowIdx, vote := range votes {
row := strconv.Itoa(rowIdx + 2)
excelFile.SetCellValue(sheetName, "A"+row, rowIdx+1)
excelFile.SetCellValue(sheetName, "B"+row, vote.Nickname)
excelFile.SetCellValue(sheetName, "C"+row, vote.Jwcode)
excelFile.SetCellValue(sheetName, "D"+row, vote.Dept)
excelFile.SetCellValue(sheetName, "E"+row, vote.OptionsTitle)
excelFile.SetCellValue(sheetName, "F"+row, vote.Time)
}
// 生成唯一文件名并响应流
fileName := fmt.Sprintf("投票记录_%s.xlsx",
time.Now().Format("20060102150405"),
)
r.Response.Header().Set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
r.Response.Header().Set("Content-Disposition", "attachment; filename*=UTF-8''"+url.QueryEscape(fileName))
// 直接写入HTTP响应流
if buffer, err := excelFile.WriteToBuffer(); err == nil {
r.Response.Write(buffer.Bytes())
} else {
r.Response.WriteJsonExit(dto.Error("文件生成失败:" + err.Error()))
}
}
func (s *sVote) GetActivityList(ctx context.Context, req *vote.GetActivityListReq) (activities []*dto.Activity, total int, err error) {
err = g.DB("live").Model("float_window").Fields("id, title, start, end, created_at").
OrderDesc("id").Page(req.PageNo, req.PageSize).ScanAndCount(&activities, &total, false)
for _, v := range activities {
v.VoteCount, _ = dao.VoteRecords.Ctx(ctx).Where("activity_id", v.Id).Fields("DISTINCT jwcode").Count()
//fmt.Printf(strconv.Itoa(v.VoteCount))
if gtime.Date() < v.Start {
v.Status = 1
} else if gtime.Date() > v.End {
v.Status = 3
} else {
v.Status = 2
}
}
return
}

0
internal/model/.gitkeep

0
internal/model/do/.gitkeep

25
internal/model/do/float_window.go

@ -0,0 +1,25 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// FloatWindow is the golang structure of table float_window for DAO operations like Where/Data.
type FloatWindow struct {
g.Meta `orm:"table:float_window, do:true"`
Id interface{} // 自增id
Title interface{} // 标题
Icon interface{} // 图标
Start *gtime.Time // 开始日期
End *gtime.Time // 结束日期
Url interface{} // 活动地址
Markets interface{} // 市场 my,sg,th,vi,can,hk
MemberLimit interface{} // 用户权限 1:非网 2:半年版 3:终免
CreatedAt *gtime.Time //
UpdatedAt *gtime.Time //
}

23
internal/model/do/member_info.go

@ -0,0 +1,23 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
)
// MemberInfo is the golang structure of table member_info for DAO operations like Where/Data.
type MemberInfo struct {
g.Meta `orm:"table:member_info, do:true"`
Id interface{} //
Jwcode interface{} //
Nickname interface{} //
Img interface{} //
Medal interface{} // 体验官勋章url
LocMarket interface{} //
Dept interface{} //
Shop interface{} //
BoguMember interface{} // 1:博股会员,0:不是
}

21
internal/model/do/vote_records.go

@ -0,0 +1,21 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// VoteRecords is the golang structure of table vote_records for DAO operations like Where/Data.
type VoteRecords struct {
g.Meta `orm:"table:vote_records, do:true"`
Id interface{} //
Jwcode interface{} //
VoteDate *gtime.Time //
Time interface{} //
OptionsTitle interface{} //
ActivityId interface{} // 活动id
}

80
internal/model/dto/Result.go

@ -0,0 +1,80 @@
package dto
// 定义响应结构
type Result struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data"` // 修改为实体类型
}
/*成功,没有数据*/
func Success() *Result {
return &Result{
Code: 200,
Message: "success",
Data: nil,
}
}
/*成功,自定义相应信息*/
func SuccessWithMsg(msg string) *Result {
return &Result{
Code: 200,
Message: msg,
Data: nil,
}
}
/*成功,有数据*/
func SuccessWithData(data interface{}) *Result {
return &Result{
Code: 200,
Message: "success",
Data: data,
}
}
/*成功,自定义信息和数据*/
func SuccessWithMsgAndData(msg string, data interface{}) *Result {
return &Result{
Code: 200,
Message: msg,
Data: data,
}
}
/*错误,只有错误信息,错误码0*/
func Error(msg string) *Result {
return &Result{
Code: 400, // 错误码
Message: msg, // 错误信息
Data: nil,
}
}
/*错误,有错误信息,有错误码*/
func ErrorWithCode(code int, msg string) *Result {
return &Result{
Code: code, // 错误码
Message: msg, // 错误信息
Data: nil,
}
}
/*未授权,有错误信息,错误码为401*/
func Unauthorized(msg string) *Result {
return &Result{
Code: 401, // 错误码
Message: msg, // 错误信息
Data: nil,
}
}
/*未授权,有错误信息,允许自定义错误码*/
func UnauthorizedWithCode(code int, msg string) *Result {
return &Result{
Code: code, // 错误码
Message: msg, // 错误信息
Data: nil,
}
}

13
internal/model/dto/activityDto.go

@ -0,0 +1,13 @@
package dto
type Activity struct {
Id int `json:"id"`
Title string `json:"title"`
Detail string `json:"detail" dc:"活动详情" `
VisitCount int `json:"visit_count" dc:"访问人数"`
VoteCount int `json:"vote_count" dc:"投票人数"`
Start string `json:"start" dc:"开始时间"`
End string `json:"end" dc:"结束时间"`
CreatedAt string `json:"created_at" dc:"创建时间"`
Status int `json:"status" dc:"活动状态"`
}

12
internal/model/dto/voteDto.go

@ -0,0 +1,12 @@
package dto
import "github.com/gogf/gf/v2/os/gtime"
type VoteDto struct {
Id uint `json:"id"`
Jwcode string `json:"jwcode"`
Nickname string `json:"nickname"`
Dept string `json:"dept"`
OptionsTitle string `json:"options_title"`
Time *gtime.Time `json:"time"`
}

0
internal/model/entity/.gitkeep

23
internal/model/entity/float_window.go

@ -0,0 +1,23 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/os/gtime"
)
// FloatWindow is the golang structure for table float_window.
type FloatWindow struct {
Id int `json:"id" orm:"id" description:"自增id"` // 自增id
Title string `json:"title" orm:"title" description:"标题"` // 标题
Icon string `json:"icon" orm:"icon" description:"图标"` // 图标
Start *gtime.Time `json:"start" orm:"start" description:"开始日期"` // 开始日期
End *gtime.Time `json:"end" orm:"end" description:"结束日期"` // 结束日期
Url string `json:"url" orm:"url" description:"活动地址"` // 活动地址
Markets string `json:"markets" orm:"markets" description:"市场 my,sg,th,vi,can,hk"` // 市场 my,sg,th,vi,can,hk
MemberLimit string `json:"memberLimit" orm:"member_limit" description:"用户权限 1:非网 2:半年版 3:终免"` // 用户权限 1:非网 2:半年版 3:终免
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""` //
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""` //
}

18
internal/model/entity/member_info.go

@ -0,0 +1,18 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
// MemberInfo is the golang structure for table member_info.
type MemberInfo struct {
Id uint `json:"id" orm:"id" description:""` //
Jwcode int `json:"jwcode" orm:"jwcode" description:""` //
Nickname string `json:"nickname" orm:"nickname" description:""` //
Img string `json:"img" orm:"img" description:""` //
Medal string `json:"medal" orm:"medal" description:"体验官勋章url"` // 体验官勋章url
LocMarket string `json:"locMarket" orm:"loc_market" description:""` //
Dept string `json:"dept" orm:"dept" description:""` //
Shop string `json:"shop" orm:"shop" description:""` //
BoguMember int `json:"boguMember" orm:"bogu_member" description:"1:博股会员,0:不是"` // 1:博股会员,0:不是
}

19
internal/model/entity/vote_records.go

@ -0,0 +1,19 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/os/gtime"
)
// VoteRecords is the golang structure for table vote_records.
type VoteRecords struct {
Id uint `json:"id" orm:"id" description:""` //
Jwcode string `json:"jwcode" orm:"jwcode" description:""` //
VoteDate *gtime.Time `json:"voteDate" orm:"vote_date" description:""` //
Time int `json:"time" orm:"time" description:""` //
OptionsTitle string `json:"optionsTitle" orm:"options_title" description:""` //
ActivityId int `json:"activityId" orm:"activity_id" description:"活动id"` // 活动id
}

1
internal/packed/packed.go

@ -0,0 +1 @@
package packed

0
internal/service/.gitkeep

34
internal/service/vote.go

@ -0,0 +1,34 @@
package service
import (
"VoteManage_Go/api/v1/vote"
"VoteManage_Go/internal/model/dto"
"context"
"github.com/gogf/gf/v2/net/ghttp"
)
type (
IVote interface {
//条件筛选
GetVoteByCondition(ctx context.Context, req *vote.GetVoteDetailListReq) (votes []*dto.VoteDto, total int, err error)
// 导出拥有卡券的用户列表
ExportVote(r *ghttp.Request, req *vote.GetVoteDetailListReq)
// 投票活动列表
GetActivityList(ctx context.Context, req *vote.GetActivityListReq) (activityList []*dto.Activity, total int, err error)
}
)
var (
localVote IVote
)
func Vote() IVote {
if localVote == nil {
panic("implement not found for interface ICoupon, forgot register?")
}
return localVote
}
func RegisterVote(i IVote) {
localVote = i
}

16
main.go

@ -0,0 +1,16 @@
package main
import (
_ "VoteManage_Go/internal/packed"
_ "VoteManage_Go/internal/logic"
_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
"github.com/gogf/gf/v2/os/gctx"
"VoteManage_Go/internal/cmd"
)
func main() {
cmd.Main.Run(gctx.GetInitCtx())
}

21
manifest/deploy/kustomize/base/deployment.yaml

@ -0,0 +1,21 @@
apiVersion: apps/vote
kind: Deployment
metadata:
name: template-single
labels:
app: template-single
spec:
replicas: 1
selector:
matchLabels:
app: template-single
template:
metadata:
labels:
app: template-single
spec:
containers:
- name : main
image: template-single
imagePullPolicy: Always

8
manifest/deploy/kustomize/base/kustomization.yaml

@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml
- service.yaml

12
manifest/deploy/kustomize/base/service.yaml

@ -0,0 +1,12 @@
apiVersion: vote
kind: Service
metadata:
name: template-single
spec:
ports:
- port: 80
protocol: TCP
targetPort: 8000
selector:
app: template-single

14
manifest/deploy/kustomize/overlays/develop/configmap.yaml

@ -0,0 +1,14 @@
apiVersion: vote
kind: ConfigMap
metadata:
name: template-single-configmap
data:
config.yaml: |
server:
address: ":8000"
openapiPath: "/api.json"
swaggerPath: "/swagger"
logger:
level : "all"
stdout: true

10
manifest/deploy/kustomize/overlays/develop/deployment.yaml

@ -0,0 +1,10 @@
apiVersion: apps/vote
kind: Deployment
metadata:
name: template-single
spec:
template:
spec:
containers:
- name : main
image: template-single:develop

14
manifest/deploy/kustomize/overlays/develop/kustomization.yaml

@ -0,0 +1,14 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
- configmap.yaml
patchesStrategicMerge:
- deployment.yaml
namespace: default

16
manifest/docker/Dockerfile

@ -0,0 +1,16 @@
FROM loads/alpine:3.8
###############################################################################
# INSTALLATION
###############################################################################
ENV WORKDIR /app
ADD resource $WORKDIR/
ADD ./temp/linux_amd64/main $WORKDIR/main
RUN chmod +x $WORKDIR/main
###############################################################################
# START
###############################################################################
WORKDIR $WORKDIR
CMD ./main

8
manifest/docker/docker.sh

@ -0,0 +1,8 @@
#!/bin/bash
# This shell is executed before docker build.

0
manifest/i18n/.gitkeep

0
manifest/protobuf/.keep-if-necessary

0
resource/public/html/.gitkeep

0
resource/public/plugin/.gitkeep

0
resource/public/resource/css/.gitkeep

0
resource/public/resource/image/.gitkeep

0
resource/public/resource/js/.gitkeep

0
resource/template/.gitkeep

0
utility/.gitkeep

Loading…
Cancel
Save