作者 yangfu

大屏互动初始化

正在显示 49 个修改的文件 包含 3332 行增加79 行删除
@@ -8,7 +8,7 @@ bsi-api: @@ -8,7 +8,7 @@ bsi-api:
8 8
9 .PHONY: bsi-swagger 9 .PHONY: bsi-swagger
10 bsi-swagger: 10 bsi-swagger:
11 - goctl api plugin -plugin goctl-swagger="swagger -filename core.json" -api .\cmd\bsi\api\dsl\core.api -dir .\cmd\discuss\api\dsl 11 + goctl api plugin -plugin goctl-swagger="swagger -filename core.json" -api .\cmd\bsi\api\dsl\core.api -dir .\cmd\bsi\api\dsl
12 12
13 .PHONY: bsi-build 13 .PHONY: bsi-build
14 bsi-build: 14 bsi-build:
  1 +{
  2 + "swagger": "2.0",
  3 + "info": {
  4 + "title": "",
  5 + "version": ""
  6 + },
  7 + "schemes": [
  8 + "http",
  9 + "https"
  10 + ],
  11 + "consumes": [
  12 + "application/json"
  13 + ],
  14 + "produces": [
  15 + "application/json"
  16 + ],
  17 + "paths": {
  18 + "v1/clear": {
  19 + "get": {
  20 + "summary": "清理缓存",
  21 + "operationId": "commonGetClearCache",
  22 + "responses": {
  23 + "200": {
  24 + "description": "A successful response.",
  25 + "schema": {}
  26 + }
  27 + },
  28 + "requestBody": {},
  29 + "tags": [
  30 + "common"
  31 + ]
  32 + }
  33 + },
  34 + "v1/common/sms/code": {
  35 + "post": {
  36 + "summary": "短信验证码",
  37 + "operationId": "commonSmsCode",
  38 + "responses": {
  39 + "200": {
  40 + "description": "A successful response.",
  41 + "schema": {
  42 + "$ref": "#/definitions/CommonSmsCodeResposne"
  43 + }
  44 + }
  45 + },
  46 + "parameters": [
  47 + {
  48 + "name": "body",
  49 + "in": "body",
  50 + "required": true,
  51 + "schema": {
  52 + "$ref": "#/definitions/CommonSmsCodeRequest"
  53 + }
  54 + }
  55 + ],
  56 + "requestBody": {},
  57 + "tags": [
  58 + "common"
  59 + ]
  60 + }
  61 + },
  62 + "v1/h5/activity/pull-submission": {
  63 + "post": {
  64 + "summary": "活动问卷拉取",
  65 + "operationId": "h5ActivityQuestionnairePullSubmission",
  66 + "responses": {
  67 + "200": {
  68 + "description": "A successful response.",
  69 + "schema": {
  70 + "$ref": "#/definitions/PullSubmissionResponse"
  71 + }
  72 + }
  73 + },
  74 + "parameters": [
  75 + {
  76 + "name": "body",
  77 + "in": "body",
  78 + "required": true,
  79 + "schema": {
  80 + "$ref": "#/definitions/PullSubmissionRequest"
  81 + }
  82 + }
  83 + ],
  84 + "requestBody": {},
  85 + "tags": [
  86 + "activity"
  87 + ]
  88 + }
  89 + },
  90 + "v1/h5/activity/questionnaire-Submit": {
  91 + "post": {
  92 + "summary": "活动问卷提交",
  93 + "operationId": "h5ActivityQuestionnaireSubmit",
  94 + "responses": {
  95 + "200": {
  96 + "description": "A successful response.",
  97 + "schema": {
  98 + "$ref": "#/definitions/QuestionnaireSubmitResponse"
  99 + }
  100 + }
  101 + },
  102 + "parameters": [
  103 + {
  104 + "name": "body",
  105 + "in": "body",
  106 + "required": true,
  107 + "schema": {
  108 + "$ref": "#/definitions/QuestionnaireSubmitRequest"
  109 + }
  110 + }
  111 + ],
  112 + "requestBody": {},
  113 + "tags": [
  114 + "activity"
  115 + ]
  116 + }
  117 + },
  118 + "v1/h5/activity/{id}": {
  119 + "get": {
  120 + "summary": "活动详情",
  121 + "operationId": "h5ActivityGet",
  122 + "responses": {
  123 + "200": {
  124 + "description": "A successful response.",
  125 + "schema": {}
  126 + }
  127 + },
  128 + "parameters": [
  129 + {
  130 + "name": "id",
  131 + "in": "path",
  132 + "required": true,
  133 + "type": "string"
  134 + }
  135 + ],
  136 + "requestBody": {},
  137 + "tags": [
  138 + "activity"
  139 + ]
  140 + }
  141 + },
  142 + "v1/log/{module}": {
  143 + "get": {
  144 + "summary": "日志查询",
  145 + "operationId": "commonGetLog",
  146 + "responses": {
  147 + "200": {
  148 + "description": "A successful response.",
  149 + "schema": {}
  150 + }
  151 + },
  152 + "parameters": [
  153 + {
  154 + "name": "module",
  155 + "in": "path",
  156 + "required": true,
  157 + "type": "string"
  158 + }
  159 + ],
  160 + "requestBody": {},
  161 + "tags": [
  162 + "common"
  163 + ]
  164 + }
  165 + },
  166 + "v1/mini/qrcode": {
  167 + "post": {
  168 + "summary": "微信二维码",
  169 + "operationId": "miniQrcodeInvite",
  170 + "responses": {
  171 + "200": {
  172 + "description": "A successful response.",
  173 + "schema": {}
  174 + }
  175 + },
  176 + "parameters": [
  177 + {
  178 + "name": "body",
  179 + "in": "body",
  180 + "required": true,
  181 + "schema": {
  182 + "$ref": "#/definitions/MiniQrCodeRequest"
  183 + }
  184 + }
  185 + ],
  186 + "requestBody": {},
  187 + "tags": [
  188 + "common"
  189 + ]
  190 + }
  191 + },
  192 + "v1/system/activity": {
  193 + "post": {
  194 + "summary": "活动保存",
  195 + "operationId": "systemActivitySave",
  196 + "responses": {
  197 + "200": {
  198 + "description": "A successful response.",
  199 + "schema": {}
  200 + }
  201 + },
  202 + "requestBody": {},
  203 + "tags": [
  204 + "activity"
  205 + ]
  206 + }
  207 + },
  208 + "v1/system/activity/close": {
  209 + "post": {
  210 + "summary": "活动关闭",
  211 + "operationId": "systemActivityClose",
  212 + "responses": {
  213 + "200": {
  214 + "description": "A successful response.",
  215 + "schema": {
  216 + "$ref": "#/definitions/ActivityCloseResponse"
  217 + }
  218 + }
  219 + },
  220 + "parameters": [
  221 + {
  222 + "name": "body",
  223 + "in": "body",
  224 + "required": true,
  225 + "schema": {
  226 + "$ref": "#/definitions/ActivityCloseRequest"
  227 + }
  228 + }
  229 + ],
  230 + "requestBody": {},
  231 + "tags": [
  232 + "activity"
  233 + ]
  234 + }
  235 + },
  236 + "v1/system/activity/open": {
  237 + "post": {
  238 + "summary": "活动开启",
  239 + "operationId": "systemActivityOpen",
  240 + "responses": {
  241 + "200": {
  242 + "description": "A successful response.",
  243 + "schema": {
  244 + "$ref": "#/definitions/ActivityOpenResponse"
  245 + }
  246 + }
  247 + },
  248 + "parameters": [
  249 + {
  250 + "name": "body",
  251 + "in": "body",
  252 + "required": true,
  253 + "schema": {
  254 + "$ref": "#/definitions/ActivityOpenRequest"
  255 + }
  256 + }
  257 + ],
  258 + "requestBody": {},
  259 + "tags": [
  260 + "activity"
  261 + ]
  262 + }
  263 + },
  264 + "v1/system/activity/search": {
  265 + "post": {
  266 + "summary": "活动搜索",
  267 + "operationId": "systemActivitySearch",
  268 + "responses": {
  269 + "200": {
  270 + "description": "A successful response.",
  271 + "schema": {}
  272 + }
  273 + },
  274 + "requestBody": {},
  275 + "tags": [
  276 + "activity"
  277 + ]
  278 + }
  279 + },
  280 + "v1/system/activity/submition-data-export": {
  281 + "post": {
  282 + "summary": "活动问卷数据导出",
  283 + "operationId": "systemActivitySubmissionDataExport",
  284 + "responses": {
  285 + "200": {
  286 + "description": "A successful response.",
  287 + "schema": {
  288 + "$ref": "#/definitions/SubmissionDataSearchResponse"
  289 + }
  290 + }
  291 + },
  292 + "parameters": [
  293 + {
  294 + "name": "body",
  295 + "in": "body",
  296 + "required": true,
  297 + "schema": {
  298 + "$ref": "#/definitions/SubmissionDataSearchRequest"
  299 + }
  300 + }
  301 + ],
  302 + "requestBody": {},
  303 + "tags": [
  304 + "activity"
  305 + ]
  306 + }
  307 + },
  308 + "v1/system/activity/submition-data-search": {
  309 + "post": {
  310 + "summary": "活动问卷数据搜索",
  311 + "operationId": "systemActivitySubmissionDataSearch",
  312 + "responses": {
  313 + "200": {
  314 + "description": "A successful response.",
  315 + "schema": {
  316 + "$ref": "#/definitions/SubmissionDataSearchResponse"
  317 + }
  318 + }
  319 + },
  320 + "parameters": [
  321 + {
  322 + "name": "body",
  323 + "in": "body",
  324 + "required": true,
  325 + "schema": {
  326 + "$ref": "#/definitions/SubmissionDataSearchRequest"
  327 + }
  328 + }
  329 + ],
  330 + "requestBody": {},
  331 + "tags": [
  332 + "activity"
  333 + ]
  334 + }
  335 + },
  336 + "v1/system/activity/{id}": {
  337 + "get": {
  338 + "summary": "活动详情",
  339 + "operationId": "systemActivityGet",
  340 + "responses": {
  341 + "200": {
  342 + "description": "A successful response.",
  343 + "schema": {}
  344 + }
  345 + },
  346 + "parameters": [
  347 + {
  348 + "name": "id",
  349 + "in": "path",
  350 + "required": true,
  351 + "type": "string"
  352 + }
  353 + ],
  354 + "requestBody": {},
  355 + "tags": [
  356 + "activity"
  357 + ]
  358 + },
  359 + "delete": {
  360 + "summary": "活动删除",
  361 + "operationId": "systemActivityDelete",
  362 + "responses": {
  363 + "200": {
  364 + "description": "A successful response.",
  365 + "schema": {}
  366 + }
  367 + },
  368 + "parameters": [
  369 + {
  370 + "name": "id",
  371 + "in": "path",
  372 + "required": true,
  373 + "type": "string"
  374 + }
  375 + ],
  376 + "requestBody": {},
  377 + "tags": [
  378 + "activity"
  379 + ]
  380 + },
  381 + "put": {
  382 + "summary": "活动更新",
  383 + "operationId": "systemActivityUpdate",
  384 + "responses": {
  385 + "200": {
  386 + "description": "A successful response.",
  387 + "schema": {}
  388 + }
  389 + },
  390 + "parameters": [
  391 + {
  392 + "name": "id",
  393 + "in": "path",
  394 + "required": true,
  395 + "type": "string"
  396 + }
  397 + ],
  398 + "requestBody": {},
  399 + "tags": [
  400 + "activity"
  401 + ]
  402 + }
  403 + }
  404 + },
  405 + "definitions": {
  406 + "ActivityCloseRequest": {
  407 + "type": "object",
  408 + "properties": {
  409 + "id": {
  410 + "type": "integer",
  411 + "format": "int64",
  412 + "description": " 唯一标识"
  413 + }
  414 + },
  415 + "title": "ActivityCloseRequest",
  416 + "required": [
  417 + "id"
  418 + ]
  419 + },
  420 + "ActivityCloseResponse": {
  421 + "type": "object",
  422 + "title": "ActivityCloseResponse"
  423 + },
  424 + "ActivityOpenRequest": {
  425 + "type": "object",
  426 + "properties": {
  427 + "id": {
  428 + "type": "integer",
  429 + "format": "int64",
  430 + "description": " 唯一标识"
  431 + }
  432 + },
  433 + "title": "ActivityOpenRequest",
  434 + "required": [
  435 + "id"
  436 + ]
  437 + },
  438 + "ActivityOpenResponse": {
  439 + "type": "object",
  440 + "title": "ActivityOpenResponse"
  441 + },
  442 + "CommonSmsCodeRequest": {
  443 + "type": "object",
  444 + "properties": {
  445 + "phone": {
  446 + "type": "string"
  447 + }
  448 + },
  449 + "title": "CommonSmsCodeRequest",
  450 + "required": [
  451 + "phone"
  452 + ]
  453 + },
  454 + "CommonSmsCodeResposne": {
  455 + "type": "object",
  456 + "title": "CommonSmsCodeResposne"
  457 + },
  458 + "MiniQrCodeRequest": {
  459 + "type": "object",
  460 + "properties": {
  461 + "page": {
  462 + "type": "string",
  463 + "description": " 微信页面入口"
  464 + },
  465 + "scene": {
  466 + "type": "string",
  467 + "description": " 参数"
  468 + }
  469 + },
  470 + "title": "MiniQrCodeRequest",
  471 + "required": [
  472 + "page",
  473 + "scene"
  474 + ]
  475 + },
  476 + "PullSubmissionRequest": {
  477 + "type": "object",
  478 + "properties": {
  479 + "id": {
  480 + "type": "integer",
  481 + "format": "int64",
  482 + "description": " 活动ID"
  483 + },
  484 + "timestamp": {
  485 + "type": "integer",
  486 + "format": "int64",
  487 + "description": " 最后一次拉取时间戳,首次为当前时间"
  488 + }
  489 + },
  490 + "title": "PullSubmissionRequest",
  491 + "required": [
  492 + "id",
  493 + "timestamp"
  494 + ]
  495 + },
  496 + "PullSubmissionResponse": {
  497 + "type": "object",
  498 + "properties": {
  499 + "totalParticipants": {
  500 + "type": "integer",
  501 + "format": "int64",
  502 + "description": " 累计参与人次"
  503 + },
  504 + "list": {
  505 + "type": "array",
  506 + "items": {
  507 + "$ref": "#/definitions/SubmissionItem"
  508 + }
  509 + }
  510 + },
  511 + "title": "PullSubmissionResponse",
  512 + "required": [
  513 + "totalParticipants",
  514 + "list"
  515 + ]
  516 + },
  517 + "QuestionItem": {
  518 + "type": "object",
  519 + "properties": {
  520 + "label": {
  521 + "type": "string",
  522 + "description": " 字段名称"
  523 + },
  524 + "product": {
  525 + "type": "string",
  526 + "description": " 商品(非必填)"
  527 + },
  528 + "value": {
  529 + "type": "string",
  530 + "description": " 值"
  531 + }
  532 + },
  533 + "title": "QuestionItem",
  534 + "required": [
  535 + "label",
  536 + "product",
  537 + "value"
  538 + ]
  539 + },
  540 + "QuestionnaireSubmitRequest": {
  541 + "type": "object",
  542 + "properties": {
  543 + "id": {
  544 + "type": "integer",
  545 + "format": "int64",
  546 + "description": " 活动ID"
  547 + },
  548 + "formList": {
  549 + "type": "array",
  550 + "items": {
  551 + "$ref": "#/definitions/QuestionItem"
  552 + },
  553 + "description": " 表单列表"
  554 + }
  555 + },
  556 + "title": "QuestionnaireSubmitRequest",
  557 + "required": [
  558 + "id",
  559 + "formList"
  560 + ]
  561 + },
  562 + "QuestionnaireSubmitResponse": {
  563 + "type": "object",
  564 + "title": "QuestionnaireSubmitResponse"
  565 + },
  566 + "SubmissionDataSearchRequest": {
  567 + "type": "object",
  568 + "properties": {
  569 + "page": {
  570 + "type": "integer",
  571 + "format": "int32"
  572 + },
  573 + "size": {
  574 + "type": "integer",
  575 + "format": "int32"
  576 + },
  577 + "activityId": {
  578 + "type": "integer",
  579 + "format": "int64"
  580 + },
  581 + "name": {
  582 + "type": "string"
  583 + },
  584 + "product": {
  585 + "type": "string"
  586 + },
  587 + "isRepeat": {
  588 + "$ref": "#/definitions/bool",
  589 + "description": " true:重复的 false:正常"
  590 + },
  591 + "amountFrom": {
  592 + "type": "number",
  593 + "format": "double",
  594 + "description": " 金额 从多少开始"
  595 + },
  596 + "amountTo": {
  597 + "type": "number",
  598 + "format": "double",
  599 + "description": " 金额 从多少截至"
  600 + },
  601 + "selectIdList": {
  602 + "type": "array",
  603 + "items": {
  604 + "type": "integer",
  605 + "format": "int64"
  606 + },
  607 + "description": " 选择的数据项"
  608 + }
  609 + },
  610 + "title": "SubmissionDataSearchRequest",
  611 + "required": [
  612 + "page",
  613 + "size",
  614 + "amountFrom",
  615 + "amountTo",
  616 + "selectIdList"
  617 + ]
  618 + },
  619 + "SubmissionDataSearchResponse": {
  620 + "type": "object",
  621 + "properties": {
  622 + "list": {
  623 + "type": "array",
  624 + "items": {
  625 + "$ref": "#/definitions/SubmissionItem"
  626 + }
  627 + },
  628 + "total": {
  629 + "type": "integer",
  630 + "format": "int64"
  631 + }
  632 + },
  633 + "title": "SubmissionDataSearchResponse",
  634 + "required": [
  635 + "list",
  636 + "total"
  637 + ]
  638 + },
  639 + "SubmissionItem": {
  640 + "type": "object",
  641 + "properties": {
  642 + "name": {
  643 + "type": "string",
  644 + "description": " 投资人姓名"
  645 + },
  646 + "title": {
  647 + "type": "string",
  648 + "description": " 称谓"
  649 + },
  650 + "avatar": {
  651 + "type": "string",
  652 + "description": " 头像"
  653 + },
  654 + "product": {
  655 + "type": "string",
  656 + "description": " 产品"
  657 + },
  658 + "amount": {
  659 + "type": "number",
  660 + "format": "double",
  661 + "description": " 金额"
  662 + },
  663 + "greeting": {
  664 + "type": "string",
  665 + "description": " 祝福"
  666 + },
  667 + "time": {
  668 + "type": "integer",
  669 + "format": "int64",
  670 + "description": "提报时间"
  671 + },
  672 + "isRepeat": {
  673 + "type": "boolean",
  674 + "format": "boolean",
  675 + "description": " 是否重复"
  676 + }
  677 + },
  678 + "title": "SubmissionItem",
  679 + "required": [
  680 + "name",
  681 + "title",
  682 + "avatar",
  683 + "product",
  684 + "amount",
  685 + "greeting",
  686 + "time",
  687 + "isRepeat"
  688 + ]
  689 + },
  690 + "TodoRequest": {
  691 + "type": "object",
  692 + "title": "TodoRequest"
  693 + },
  694 + "TodoResonse": {
  695 + "type": "object",
  696 + "title": "TodoResonse"
  697 + }
  698 + },
  699 + "securityDefinitions": {
  700 + "apiKey": {
  701 + "type": "apiKey",
  702 + "description": "Enter JWT Bearer token **_only_**",
  703 + "name": "Authorization",
  704 + "in": "header"
  705 + }
  706 + },
  707 + "security": [
  708 + {
  709 + "apiKey": []
  710 + }
  711 + ]
  712 +}
@@ -2,32 +2,129 @@ syntax = "v1" @@ -2,32 +2,129 @@ syntax = "v1"
2 2
3 info( 3 info(
4 title: "易数家显示大屏互动服务" 4 title: "易数家显示大屏互动服务"
5 - desc: "易数家显示大屏互动服务 BSI(Big screen interaction)"  
6 - author: "bsi"  
7 - email: "bsi@gmail.com" 5 + desc: "易数家显示大屏互动服务 (Big screen interaction)"
  6 + author: ""
  7 + email: "@gmail.com"
8 version: "v1" 8 version: "v1"
9 ) 9 )
10 10
11 -// H5接口 11 +// 后台接口
  12 +@server(
  13 + prefix: v1/system
  14 + group: activity
  15 + middleware: LoginStatusCheck,LogRequest
  16 + jwt: SystemAuth
  17 +)
  18 +
  19 +service Core {
  20 + @doc "活动详情"
  21 + @handler systemActivityGet
  22 + get /activity/:id //(ActivityGetRequest) returns (ActivityGetResponse)
  23 + @doc "活动保存"
  24 + @handler systemActivitySave
  25 + post /activity //(ActivitySaveRequest) returns (ActivitySaveResponse)
  26 + @doc "活动删除"
  27 + @handler systemActivityDelete
  28 + delete /activity/:id //(ActivityDeleteRequest) returns (ActivityDeleteResponse)
  29 + @doc "活动更新"
  30 + @handler systemActivityUpdate
  31 + put /activity/:id //(ActivityUpdateRequest) returns (ActivityUpdateResponse)
  32 + @doc "活动搜索"
  33 + @handler systemActivitySearch
  34 + post /activity/search //(ActivitySearchRequest) returns (ActivitySearchResponse)
  35 + @doc "活动开启"
  36 + @handler systemActivityOpen
  37 + post /activity/open (ActivityOpenRequest) returns (ActivityOpenResponse)
  38 + @doc "活动关闭"
  39 + @handler systemActivityClose
  40 + post /activity/close (ActivityCloseRequest) returns (ActivityCloseResponse)
  41 + @doc "活动问卷数据搜索"
  42 + @handler systemActivitySubmissionDataSearch
  43 + post /activity/submition-data-search (SubmissionDataSearchRequest) returns(SubmissionDataSearchResponse)
  44 + @doc "活动问卷数据导出"
  45 + @handler systemActivitySubmissionDataExport
  46 + post /activity/submition-data-export (SubmissionDataSearchRequest) returns(SubmissionDataSearchResponse)
  47 +}
  48 +
12 @server( 49 @server(
13 prefix: v1/h5 50 prefix: v1/h5
14 - group: todo 51 + group: activity
15 middleware: LogRequest 52 middleware: LogRequest
16 - //jwt: MiniAuth  
17 ) 53 )
  54 +
18 service Core { 55 service Core {
19 - @doc ""  
20 - @handler H5Todo  
21 - get /todo  
22 - @doc ""  
23 - @handler H5TodoErrorCommon  
24 - get /todo/err1 returns(TodoResonse)  
25 - @doc ""  
26 - @handler H5TodoErrorInternal  
27 - get /todo/err2 returns(TodoResonse)  
28 - @doc ""  
29 - @handler H5TodoErrorGrpc  
30 - get /todo/err3 returns(TodoResonse) 56 + @doc "活动详情"
  57 + @handler h5ActivityGet
  58 + get /activity/:id //(ActivityGetRequest) returns (ActivityGetResponse)
  59 + @doc "活动问卷提交"
  60 + @handler h5ActivityQuestionnaireSubmit
  61 + post /activity/questionnaire-Submit (QuestionnaireSubmitRequest) returns (QuestionnaireSubmitResponse)
  62 + @doc "活动问卷拉取"
  63 + @handler h5ActivityQuestionnairePullSubmission
  64 + post /activity/pull-submission (PullSubmissionRequest) returns(PullSubmissionResponse)
  65 +}
  66 +
  67 +type(
  68 + ActivityOpenRequest struct{
  69 + Id int64 `json:"id"` // 唯一标识
  70 + }
  71 + ActivityOpenResponse struct{
  72 +
  73 + }
  74 + ActivityCloseRequest struct{
  75 + Id int64 `json:"id"` // 唯一标识
  76 + }
  77 + ActivityCloseResponse struct{
  78 +
  79 + }
  80 +)
  81 +
  82 +type(
  83 + QuestionnaireSubmitRequest struct{
  84 + Id int64 `json:"id"` // 活动ID
  85 + FormList []QuestionItem `json:"formList"` // 表单列表
  86 + }
  87 + QuestionnaireSubmitResponse{}
  88 +
  89 + SubmissionDataSearchRequest struct{
  90 + Page int `json:"page"`
  91 + Size int `json:"size"`
  92 + ActivityId int64 `json:"activityId,optional"`
  93 + Name string `json:"name,optional"`
  94 + Product string `json:"product,optional"`
  95 + IsRepeat *bool `json:"isRepeat,optional"` // true:重复的 false:正常
  96 + AmountFrom float64 `json:"amountFrom"` // 金额 从多少开始
  97 + AmountTo float64 `json:"amountTo"` // 金额 从多少截至
  98 + SelectIdList []int64 `json:"selectIdList"` // 选择的数据项
  99 + }
  100 + SubmissionDataSearchResponse struct{
  101 + List []SubmissionItem `json:"list"`
  102 + Total int64 `json:"total"`
  103 + }
  104 + PullSubmissionRequest{
  105 + Id int64 `json:"id"` // 活动ID
  106 + Timestamp int64 `json:"timestamp"` // 最后一次拉取时间戳,首次为当前时间
  107 + }
  108 + PullSubmissionResponse{
  109 + TotalParticipants int64 `json:"totalParticipants"` // 累计参与人次
  110 + List []SubmissionItem `json:"list"`
  111 + }
  112 + SubmissionItem{
  113 + Name string `json:"name"` // 投资人姓名
  114 + Title string `json:"title"` // 称谓
  115 + Avatar string `json:"avatar"` // 头像
  116 + Product string `json:"product"`// 产品
  117 + Amount float64 `json:"amount"`// 金额
  118 + Greeting string `json:"greeting"` // 祝福
  119 + Time int64 `json:"time"` //提报时间
  120 + IsRepeat bool `json:"isRepeat"` // 是否重复
  121 + }
  122 +)
  123 +
  124 +type QuestionItem struct {
  125 + Label string `json:"label"` // 字段名称
  126 + Product string `json:"product"` // 商品(非必填)
  127 + Value string `json:"value"` // 值
31 } 128 }
32 129
33 type ( 130 type (
1 Name: Core 1 Name: Core
2 Host: 0.0.0.0 2 Host: 0.0.0.0
3 -Port: 8080 3 +Port: 8081
4 4
5 Verbose: false 5 Verbose: false
6 Migrate: true 6 Migrate: true
  1 +package activity
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/types"
  5 + "net/http"
  6 +
  7 + "github.com/zeromicro/go-zero/rest/httpx"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/logic/activity"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc"
  10 +)
  11 +
  12 +func H5ActivityGetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.ActivityGetRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := activity.NewSystemActivityGetLogic(r.Context(), svcCtx)
  21 + resp, err := l.SystemActivityGet(&req)
  22 + if err != nil {
  23 + httpx.ErrorCtx(r.Context(), w, err)
  24 + } else {
  25 + httpx.OkJsonCtx(r.Context(), w, resp)
  26 + }
  27 + }
  28 +}
  1 +package activity
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/logic/activity"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/types"
  10 +)
  11 +
  12 +func H5ActivityQuestionnairePullSubmissionHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.PullSubmissionRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := activity.NewH5ActivityQuestionnairePullSubmissionLogic(r.Context(), svcCtx)
  21 + resp, err := l.H5ActivityQuestionnairePullSubmission(&req)
  22 + if err != nil {
  23 + httpx.ErrorCtx(r.Context(), w, err)
  24 + } else {
  25 + httpx.OkJsonCtx(r.Context(), w, resp)
  26 + }
  27 + }
  28 +}
  1 +package activity
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/logic/activity"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/types"
  10 +)
  11 +
  12 +func H5ActivityQuestionnaireSubmitHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.QuestionnaireSubmitRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := activity.NewH5ActivityQuestionnaireSubmitLogic(r.Context(), svcCtx)
  21 + resp, err := l.H5ActivityQuestionnaireSubmit(&req)
  22 + if err != nil {
  23 + httpx.ErrorCtx(r.Context(), w, err)
  24 + } else {
  25 + httpx.OkJsonCtx(r.Context(), w, resp)
  26 + }
  27 + }
  28 +}
  1 +package activity
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/logic/activity"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/types"
  10 +)
  11 +
  12 +func SystemActivityCloseHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.ActivityCloseRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := activity.NewSystemActivityCloseLogic(r.Context(), svcCtx)
  21 + resp, err := l.SystemActivityClose(&req)
  22 + if err != nil {
  23 + httpx.ErrorCtx(r.Context(), w, err)
  24 + } else {
  25 + httpx.OkJsonCtx(r.Context(), w, resp)
  26 + }
  27 + }
  28 +}
  1 +package activity
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/logic/activity"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/types"
  10 +)
  11 +
  12 +func SystemActivityDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.ActivityDeleteRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := activity.NewSystemActivityDeleteLogic(r.Context(), svcCtx)
  21 + resp, err := l.SystemActivityDelete(&req)
  22 + if err != nil {
  23 + httpx.ErrorCtx(r.Context(), w, err)
  24 + } else {
  25 + httpx.OkJsonCtx(r.Context(), w, resp)
  26 + }
  27 + }
  28 +}
  1 +package activity
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/logic/activity"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/types"
  10 +)
  11 +
  12 +func SystemActivityGetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.ActivityGetRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := activity.NewSystemActivityGetLogic(r.Context(), svcCtx)
  21 + resp, err := l.SystemActivityGet(&req)
  22 + if err != nil {
  23 + httpx.ErrorCtx(r.Context(), w, err)
  24 + } else {
  25 + httpx.OkJsonCtx(r.Context(), w, resp)
  26 + }
  27 + }
  28 +}
  1 +package activity
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/logic/activity"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/types"
  10 +)
  11 +
  12 +func SystemActivityOpenHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.ActivityOpenRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := activity.NewSystemActivityOpenLogic(r.Context(), svcCtx)
  21 + resp, err := l.SystemActivityOpen(&req)
  22 + if err != nil {
  23 + httpx.ErrorCtx(r.Context(), w, err)
  24 + } else {
  25 + httpx.OkJsonCtx(r.Context(), w, resp)
  26 + }
  27 + }
  28 +}
  1 +package activity
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/logic/activity"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/types"
  10 +)
  11 +
  12 +func SystemActivitySaveHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.ActivitySaveRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := activity.NewSystemActivitySaveLogic(r.Context(), svcCtx)
  21 + resp, err := l.SystemActivitySave(&req)
  22 + if err != nil {
  23 + httpx.ErrorCtx(r.Context(), w, err)
  24 + } else {
  25 + httpx.OkJsonCtx(r.Context(), w, resp)
  26 + }
  27 + }
  28 +}
  1 +package activity
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/logic/activity"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/types"
  10 +)
  11 +
  12 +func SystemActivitySearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.ActivitySearchRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := activity.NewSystemActivitySearchLogic(r.Context(), svcCtx)
  21 + resp, err := l.SystemActivitySearch(&req)
  22 + if err != nil {
  23 + httpx.ErrorCtx(r.Context(), w, err)
  24 + } else {
  25 + httpx.OkJsonCtx(r.Context(), w, resp)
  26 + }
  27 + }
  28 +}
  1 +package activity
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/tiptok/tab"
  6 + "net/http"
  7 + "time"
  8 +
  9 + "github.com/zeromicro/go-zero/rest/httpx"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/logic/activity"
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc"
  12 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/types"
  13 +)
  14 +
  15 +func SystemActivitySubmissionDataExportHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  16 + return func(w http.ResponseWriter, r *http.Request) {
  17 + var req types.SubmissionDataSearchRequest
  18 + if err := httpx.Parse(r, &req); err != nil {
  19 + httpx.ErrorCtx(r.Context(), w, err)
  20 + return
  21 + }
  22 +
  23 + l := activity.NewSystemActivitySubmissionDataSearchLogic(r.Context(), svcCtx)
  24 + resp, err := l.SystemActivitySubmissionDataSearch(&req)
  25 + if err != nil {
  26 + httpx.ErrorCtx(r.Context(), w, err)
  27 + }
  28 +
  29 + title := []string{"人员姓名", "产品名称", "投资金额", "提报时间"}
  30 + data := make([][]string, 0)
  31 + for _, item := range resp.List {
  32 + row := make([]string, 0)
  33 + row = append(row,
  34 + item.Name,
  35 + item.Product,
  36 + fmt.Sprintf("%0.2f", item.Amount),
  37 + time.Unix(item.Time, 0).Format("2006-01-02 15:04:05"),
  38 + )
  39 + data = append(data, row)
  40 + }
  41 +
  42 + w.Header().Set("Content-Disposition", "attachment; filename="+"提报数据.xlsx")
  43 + w.Header().Set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=GBK") //"application/octet-stream")
  44 + writerTo := tab.NewXLXSWriterTo(title, data)
  45 + writerTo.WriteTo(w)
  46 + }
  47 +}
  1 +package activity
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/logic/activity"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/types"
  10 +)
  11 +
  12 +func SystemActivitySubmissionDataSearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.SubmissionDataSearchRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := activity.NewSystemActivitySubmissionDataSearchLogic(r.Context(), svcCtx)
  21 + resp, err := l.SystemActivitySubmissionDataSearch(&req)
  22 + if err != nil {
  23 + httpx.ErrorCtx(r.Context(), w, err)
  24 + } else {
  25 + httpx.OkJsonCtx(r.Context(), w, resp)
  26 + }
  27 + }
  28 +}
  1 +package activity
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/logic/activity"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/types"
  10 +)
  11 +
  12 +func SystemActivityUpdateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.ActivityUpdateRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := activity.NewSystemActivityUpdateLogic(r.Context(), svcCtx)
  21 + resp, err := l.SystemActivityUpdate(&req)
  22 + if err != nil {
  23 + httpx.ErrorCtx(r.Context(), w, err)
  24 + } else {
  25 + httpx.OkJsonCtx(r.Context(), w, resp)
  26 + }
  27 + }
  28 +}
@@ -4,8 +4,8 @@ package handler @@ -4,8 +4,8 @@ package handler
4 import ( 4 import (
5 "net/http" 5 "net/http"
6 6
  7 + activity "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/handler/activity"
7 common "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/handler/common" 8 common "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/handler/common"
8 - todo "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/handler/todo"  
9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc" 9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc"
10 10
11 "github.com/zeromicro/go-zero/rest" 11 "github.com/zeromicro/go-zero/rest"
@@ -49,27 +49,77 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { @@ -49,27 +49,77 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
49 49
50 server.AddRoutes( 50 server.AddRoutes(
51 rest.WithMiddlewares( 51 rest.WithMiddlewares(
52 - []rest.Middleware{serverCtx.LogRequest}, 52 + []rest.Middleware{serverCtx.LoginStatusCheck, serverCtx.LogRequest},
53 []rest.Route{ 53 []rest.Route{
54 { 54 {
55 Method: http.MethodGet, 55 Method: http.MethodGet,
56 - Path: "/todo",  
57 - Handler: todo.H5TodoHandler(serverCtx), 56 + Path: "/activity/:id",
  57 + Handler: activity.SystemActivityGetHandler(serverCtx),
58 }, 58 },
59 { 59 {
60 - Method: http.MethodGet,  
61 - Path: "/todo/err1",  
62 - Handler: todo.H5TodoErrorCommonHandler(serverCtx), 60 + Method: http.MethodPost,
  61 + Path: "/activity",
  62 + Handler: activity.SystemActivitySaveHandler(serverCtx),
63 }, 63 },
64 { 64 {
65 - Method: http.MethodGet,  
66 - Path: "/todo/err2",  
67 - Handler: todo.H5TodoErrorInternalHandler(serverCtx), 65 + Method: http.MethodDelete,
  66 + Path: "/activity/:id",
  67 + Handler: activity.SystemActivityDeleteHandler(serverCtx),
  68 + },
  69 + {
  70 + Method: http.MethodPut,
  71 + Path: "/activity/:id",
  72 + Handler: activity.SystemActivityUpdateHandler(serverCtx),
  73 + },
  74 + {
  75 + Method: http.MethodPost,
  76 + Path: "/activity/search",
  77 + Handler: activity.SystemActivitySearchHandler(serverCtx),
  78 + },
  79 + {
  80 + Method: http.MethodPost,
  81 + Path: "/activity/open",
  82 + Handler: activity.SystemActivityOpenHandler(serverCtx),
  83 + },
  84 + {
  85 + Method: http.MethodPost,
  86 + Path: "/activity/close",
  87 + Handler: activity.SystemActivityCloseHandler(serverCtx),
  88 + },
  89 + {
  90 + Method: http.MethodPost,
  91 + Path: "/activity/submition-data-search",
  92 + Handler: activity.SystemActivitySubmissionDataSearchHandler(serverCtx),
68 }, 93 },
69 { 94 {
  95 + Method: http.MethodPost,
  96 + Path: "/activity/submition-data-export",
  97 + Handler: activity.SystemActivitySubmissionDataExportHandler(serverCtx),
  98 + },
  99 + }...,
  100 + ),
  101 + rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
  102 + rest.WithPrefix("/v1/system"),
  103 + )
  104 +
  105 + server.AddRoutes(
  106 + rest.WithMiddlewares(
  107 + []rest.Middleware{serverCtx.LogRequest},
  108 + []rest.Route{
  109 + {
70 Method: http.MethodGet, 110 Method: http.MethodGet,
71 - Path: "/todo/err3",  
72 - Handler: todo.H5TodoErrorGrpcHandler(serverCtx), 111 + Path: "/activity/:id",
  112 + Handler: activity.H5ActivityGetHandler(serverCtx),
  113 + },
  114 + {
  115 + Method: http.MethodPost,
  116 + Path: "/activity/questionnaire-Submit",
  117 + Handler: activity.H5ActivityQuestionnaireSubmitHandler(serverCtx),
  118 + },
  119 + {
  120 + Method: http.MethodPost,
  121 + Path: "/activity/pull-submission",
  122 + Handler: activity.H5ActivityQuestionnairePullSubmissionHandler(serverCtx),
73 }, 123 },
74 }..., 124 }...,
75 ), 125 ),
  1 +package activity
  2 +
  3 +import (
  4 + "context"
  5 +
  6 + "github.com/zeromicro/go-zero/core/logx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc"
  8 +)
  9 +
  10 +type H5ActivityGetLogic struct {
  11 + logx.Logger
  12 + ctx context.Context
  13 + svcCtx *svc.ServiceContext
  14 +}
  15 +
  16 +func NewH5ActivityGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *H5ActivityGetLogic {
  17 + return &H5ActivityGetLogic{
  18 + Logger: logx.WithContext(ctx),
  19 + ctx: ctx,
  20 + svcCtx: svcCtx,
  21 + }
  22 +}
  23 +
  24 +func (l *H5ActivityGetLogic) H5ActivityGet() error {
  25 + // todo: add your logic here and delete this line
  26 +
  27 + return nil
  28 +}
  1 +package activity
  2 +
  3 +import (
  4 + "context"
  5 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/interanl/pkg/domain"
  6 +
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/types"
  9 +
  10 + "github.com/zeromicro/go-zero/core/logx"
  11 +)
  12 +
  13 +type H5ActivityQuestionnairePullSubmissionLogic struct {
  14 + logx.Logger
  15 + ctx context.Context
  16 + svcCtx *svc.ServiceContext
  17 +}
  18 +
  19 +func NewH5ActivityQuestionnairePullSubmissionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *H5ActivityQuestionnairePullSubmissionLogic {
  20 + return &H5ActivityQuestionnairePullSubmissionLogic{
  21 + Logger: logx.WithContext(ctx),
  22 + ctx: ctx,
  23 + svcCtx: svcCtx,
  24 + }
  25 +}
  26 +
  27 +func (l *H5ActivityQuestionnairePullSubmissionLogic) H5ActivityQuestionnairePullSubmission(req *types.PullSubmissionRequest) (resp *types.PullSubmissionResponse, err error) {
  28 + var (
  29 + conn = l.svcCtx.DefaultDBConn()
  30 + dms []*domain.BsiActivityQuestionnaireSubmitRecord
  31 + total int64
  32 + )
  33 +
  34 + queryOptions := domain.NewQueryOptions().WithFindOnly().
  35 + MustWithKV("activityId", req.Id).
  36 + WithKV("timestamp", req.Timestamp)
  37 +
  38 + _, dms, err = l.svcCtx.BsiActivityQuestionnaireSubmitRecordRepository.Find(l.ctx, conn, queryOptions)
  39 + list := make([]types.SubmissionItem, 0)
  40 + for i := range dms {
  41 + item := NewTypesSubmissionItem(dms[i])
  42 + list = append(list, item)
  43 + }
  44 + // 累计参与人次
  45 + queryOptions = domain.NewQueryOptions().WithCountOnly().MustWithKV("activityId", req.Id)
  46 + total, _, _ = l.svcCtx.BsiActivityQuestionnaireSubmitRecordRepository.Find(l.ctx, conn, queryOptions)
  47 +
  48 + resp = &types.PullSubmissionResponse{
  49 + List: list,
  50 + TotalParticipants: total,
  51 + }
  52 + return
  53 +}
  1 +package activity
  2 +
  3 +import (
  4 + "context"
  5 + "fmt"
  6 + "github.com/samber/lo"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/interanl/pkg/domain"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/transaction"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/xerr"
  10 + "strconv"
  11 + "strings"
  12 +
  13 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc"
  14 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/types"
  15 +
  16 + "github.com/zeromicro/go-zero/core/logx"
  17 +)
  18 +
  19 +type H5ActivityQuestionnaireSubmitLogic struct {
  20 + logx.Logger
  21 + ctx context.Context
  22 + svcCtx *svc.ServiceContext
  23 +}
  24 +
  25 +func NewH5ActivityQuestionnaireSubmitLogic(ctx context.Context, svcCtx *svc.ServiceContext) *H5ActivityQuestionnaireSubmitLogic {
  26 + return &H5ActivityQuestionnaireSubmitLogic{
  27 + Logger: logx.WithContext(ctx),
  28 + ctx: ctx,
  29 + svcCtx: svcCtx,
  30 + }
  31 +}
  32 +
  33 +func (l *H5ActivityQuestionnaireSubmitLogic) H5ActivityQuestionnaireSubmit(req *types.QuestionnaireSubmitRequest) (resp *types.QuestionnaireSubmitResponse, err error) {
  34 + var (
  35 + conn = l.svcCtx.DefaultDBConn()
  36 + userName string
  37 + activity *domain.BsiActivity
  38 + defaultNameForm = "姓名"
  39 + userInfo domain.UserInfo
  40 + )
  41 + if !lo.ContainsBy(req.FormList, func(item types.QuestionItem) bool {
  42 + result := item.Label == defaultNameForm
  43 + if result {
  44 + userName = item.Value
  45 + }
  46 + return result
  47 + }) {
  48 + return nil, xerr.NewErrMsgErr("用户姓名不能为空", nil)
  49 + }
  50 + if activity, err = l.svcCtx.BsiActivityRepository.FindOne(l.ctx, conn, req.Id); err != nil {
  51 + return nil, xerr.NewErrMsgErr("活动不存在", err)
  52 + }
  53 +
  54 + // 从预设置人员里面查找
  55 + if v, ok := lo.Find(activity.ActivityConfig.DefaultUsers, func(item domain.UserInfo) bool {
  56 + return item.Name == userName
  57 + }); ok {
  58 + userInfo = v
  59 + } else {
  60 + userInfo = domain.UserInfo{
  61 + Name: userName,
  62 + }
  63 + }
  64 + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
  65 + for _, form := range req.FormList {
  66 + if form.Label == defaultNameForm {
  67 + continue
  68 + }
  69 + amount, _ := strconv.ParseFloat(strings.TrimRight(form.Value, "元"), 64)
  70 + if amount == 0 {
  71 + return fmt.Errorf("金额不能为0")
  72 + }
  73 + record := &domain.BsiActivityQuestionnaireSubmitRecord{
  74 + CompanyId: activity.CompanyId,
  75 + ActivityId: activity.Id,
  76 + Name: userInfo.Name,
  77 + Product: form.Product,
  78 + Amount: amount,
  79 + User: userInfo,
  80 + Greeting: activity.RandomGreeting(),
  81 + }
  82 + if record, err = l.svcCtx.BsiActivityQuestionnaireSubmitRecordRepository.Insert(l.ctx, conn, record); err != nil {
  83 + logx.Error(err)
  84 + return fmt.Errorf("保存失败")
  85 + }
  86 + }
  87 + return err
  88 + }, true); err != nil {
  89 + return nil, xerr.NewErrMsgErr(err.Error(), err)
  90 + }
  91 + return
  92 +}
  1 +package activity
  2 +
  3 +import (
  4 + "context"
  5 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/interanl/pkg/domain"
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/transaction"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/xerr"
  8 +
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/types"
  11 +
  12 + "github.com/zeromicro/go-zero/core/logx"
  13 +)
  14 +
  15 +type SystemActivityCloseLogic struct {
  16 + logx.Logger
  17 + ctx context.Context
  18 + svcCtx *svc.ServiceContext
  19 +}
  20 +
  21 +func NewSystemActivityCloseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemActivityCloseLogic {
  22 + return &SystemActivityCloseLogic{
  23 + Logger: logx.WithContext(ctx),
  24 + ctx: ctx,
  25 + svcCtx: svcCtx,
  26 + }
  27 +}
  28 +
  29 +func (l *SystemActivityCloseLogic) SystemActivityClose(req *types.ActivityCloseRequest) (resp *types.ActivityCloseResponse, err error) {
  30 + var (
  31 + conn = l.svcCtx.DefaultDBConn()
  32 + dm *domain.BsiActivity
  33 + )
  34 + if dm, err = l.svcCtx.BsiActivityRepository.FindOne(l.ctx, conn, req.Id); err != nil {
  35 + return nil, xerr.NewErrMsgErr("不存在", err)
  36 + }
  37 + // 赋值
  38 + dm.Status = domain.ActivityClosed
  39 + // 更新
  40 + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
  41 + dm, err = l.svcCtx.BsiActivityRepository.UpdateWithVersion(l.ctx, conn, dm)
  42 + return err
  43 + }, true); err != nil {
  44 + return nil, xerr.NewErrMsg("更新失败")
  45 + }
  46 + resp = &types.ActivityCloseResponse{}
  47 + return
  48 +}
  1 +package activity
  2 +
  3 +import (
  4 + "context"
  5 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/interanl/pkg/domain"
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/transaction"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/xerr"
  8 +
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/types"
  11 +
  12 + "github.com/zeromicro/go-zero/core/logx"
  13 +)
  14 +
  15 +type SystemActivityDeleteLogic struct {
  16 + logx.Logger
  17 + ctx context.Context
  18 + svcCtx *svc.ServiceContext
  19 +}
  20 +
  21 +func NewSystemActivityDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemActivityDeleteLogic {
  22 + return &SystemActivityDeleteLogic{
  23 + Logger: logx.WithContext(ctx),
  24 + ctx: ctx,
  25 + svcCtx: svcCtx,
  26 + }
  27 +}
  28 +
  29 +func (l *SystemActivityDeleteLogic) SystemActivityDelete(req *types.ActivityDeleteRequest) (resp *types.ActivityDeleteResponse, err error) {
  30 + var (
  31 + conn = l.svcCtx.DefaultDBConn()
  32 + dm *domain.BsiActivity
  33 + )
  34 + if dm, err = l.svcCtx.BsiActivityRepository.FindOne(l.ctx, conn, req.Id); err != nil {
  35 + return nil, xerr.NewErrMsgErr("不存在", err)
  36 + }
  37 + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
  38 + if dm, err = l.svcCtx.BsiActivityRepository.Delete(l.ctx, conn, dm); err != nil {
  39 + return err
  40 + }
  41 + return nil
  42 + }, true); err != nil {
  43 + return nil, xerr.NewErrMsgErr("移除失败", err)
  44 + }
  45 + return
  46 +}
  1 +package activity
  2 +
  3 +import (
  4 + "context"
  5 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/interanl/pkg/domain"
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/xerr"
  7 +
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/types"
  10 +
  11 + "github.com/zeromicro/go-zero/core/logx"
  12 +)
  13 +
  14 +type SystemActivityGetLogic struct {
  15 + logx.Logger
  16 + ctx context.Context
  17 + svcCtx *svc.ServiceContext
  18 +}
  19 +
  20 +func NewSystemActivityGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemActivityGetLogic {
  21 + return &SystemActivityGetLogic{
  22 + Logger: logx.WithContext(ctx),
  23 + ctx: ctx,
  24 + svcCtx: svcCtx,
  25 + }
  26 +}
  27 +
  28 +func (l *SystemActivityGetLogic) SystemActivityGet(req *types.ActivityGetRequest) (resp *types.ActivityGetResponse, err error) {
  29 + var (
  30 + conn = l.svcCtx.DefaultDBConn()
  31 + dm *domain.BsiActivity
  32 + )
  33 + // 货号唯一
  34 + if dm, err = l.svcCtx.BsiActivityRepository.FindOne(l.ctx, conn, req.Id); err != nil {
  35 + return nil, xerr.NewErrMsgErr("不存在", err)
  36 + }
  37 + resp = &types.ActivityGetResponse{
  38 + Activity: NewTypesBsiActivity(dm),
  39 + }
  40 + return
  41 +}
  1 +package activity
  2 +
  3 +import (
  4 + "context"
  5 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/interanl/pkg/domain"
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/transaction"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/xerr"
  8 +
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/types"
  11 +
  12 + "github.com/zeromicro/go-zero/core/logx"
  13 +)
  14 +
  15 +type SystemActivityOpenLogic struct {
  16 + logx.Logger
  17 + ctx context.Context
  18 + svcCtx *svc.ServiceContext
  19 +}
  20 +
  21 +func NewSystemActivityOpenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemActivityOpenLogic {
  22 + return &SystemActivityOpenLogic{
  23 + Logger: logx.WithContext(ctx),
  24 + ctx: ctx,
  25 + svcCtx: svcCtx,
  26 + }
  27 +}
  28 +
  29 +func (l *SystemActivityOpenLogic) SystemActivityOpen(req *types.ActivityOpenRequest) (resp *types.ActivityOpenResponse, err error) {
  30 + var (
  31 + conn = l.svcCtx.DefaultDBConn()
  32 + dm *domain.BsiActivity
  33 + )
  34 + if dm, err = l.svcCtx.BsiActivityRepository.FindOne(l.ctx, conn, req.Id); err != nil {
  35 + return nil, xerr.NewErrMsgErr("不存在", err)
  36 + }
  37 + // 赋值
  38 + dm.Status = domain.ActivityOpening
  39 + // 更新
  40 + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
  41 + dm, err = l.svcCtx.BsiActivityRepository.UpdateWithVersion(l.ctx, conn, dm)
  42 + return err
  43 + }, true); err != nil {
  44 + return nil, xerr.NewErrMsg("更新失败")
  45 + }
  46 + resp = &types.ActivityOpenResponse{}
  47 + return
  48 +}
  1 +package activity
  2 +
  3 +import (
  4 + "context"
  5 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/interanl/pkg/domain"
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/contextdata"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/transaction"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/xerr"
  9 +
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc"
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/types"
  12 +
  13 + "github.com/zeromicro/go-zero/core/logx"
  14 +)
  15 +
  16 +type SystemActivitySaveLogic struct {
  17 + logx.Logger
  18 + ctx context.Context
  19 + svcCtx *svc.ServiceContext
  20 +}
  21 +
  22 +func NewSystemActivitySaveLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemActivitySaveLogic {
  23 + return &SystemActivitySaveLogic{
  24 + Logger: logx.WithContext(ctx),
  25 + ctx: ctx,
  26 + svcCtx: svcCtx,
  27 + }
  28 +}
  29 +
  30 +func (l *SystemActivitySaveLogic) SystemActivitySave(req *types.ActivitySaveRequest) (resp *types.ActivitySaveResponse, err error) {
  31 + var (
  32 + dm *domain.BsiActivity
  33 + userToken = contextdata.GetUserTokenFromCtx(l.ctx)
  34 + )
  35 + if err = req.Activity.Valid(); err != nil {
  36 + return nil, xerr.NewErrMsg(err.Error())
  37 + }
  38 + // 唯一判断
  39 + dm = NewDomainBsiActivity(userToken.CompanyId, req.Activity)
  40 + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
  41 + dm, err = l.svcCtx.BsiActivityRepository.Insert(l.ctx, conn, dm)
  42 + return err
  43 + }, true); err != nil {
  44 + return nil, xerr.NewErrMsg("保存失败")
  45 + }
  46 + resp = &types.ActivitySaveResponse{}
  47 + return
  48 +}
  49 +
  50 +func NewDomainBsiActivity(companyId int64, item types.ActivityItem) *domain.BsiActivity {
  51 + return &domain.BsiActivity{
  52 + CompanyId: companyId,
  53 + Issue: item.Issue,
  54 + Remark: item.Remark,
  55 + ActivateType: item.ActivateType,
  56 + BeginAt: item.BeginAt,
  57 + EndAt: item.EndAt,
  58 + ActivityConfig: item.ActivityConfig,
  59 + Status: domain.ActivityWaiting,
  60 + }
  61 +}
  62 +
  63 +func NewTypesBsiActivity(item *domain.BsiActivity) types.ActivityItem {
  64 + return types.ActivityItem{
  65 + Id: item.Id,
  66 + CompanyId: item.CompanyId,
  67 + Issue: item.Issue,
  68 + Remark: item.Remark,
  69 + ActivateType: item.ActivateType,
  70 + BeginAt: item.BeginAt,
  71 + EndAt: item.EndAt,
  72 + ActivityConfig: item.ActivityConfig,
  73 + Status: item.ResolveActivityStatus(),
  74 + }
  75 +}
  1 +package activity
  2 +
  3 +import (
  4 + "context"
  5 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc"
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/types"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/interanl/pkg/domain"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/contextdata"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/transaction"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/xerr"
  11 +
  12 + "github.com/zeromicro/go-zero/core/logx"
  13 +)
  14 +
  15 +type SystemActivitySearchLogic struct {
  16 + logx.Logger
  17 + ctx context.Context
  18 + svcCtx *svc.ServiceContext
  19 +}
  20 +
  21 +func NewSystemActivitySearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemActivitySearchLogic {
  22 + return &SystemActivitySearchLogic{
  23 + Logger: logx.WithContext(ctx),
  24 + ctx: ctx,
  25 + svcCtx: svcCtx,
  26 + }
  27 +}
  28 +
  29 +func (l *SystemActivitySearchLogic) SystemActivitySearch(req *types.ActivitySearchRequest) (resp *types.ActivitySearchResponse, err error) {
  30 + var (
  31 + conn = l.svcCtx.DefaultDBConn()
  32 + dms []*domain.BsiActivity
  33 + total int64
  34 + userToken = contextdata.GetUserTokenFromCtx(l.ctx)
  35 + )
  36 +
  37 + // 延迟更新状态
  38 + queryOptions := domain.NewQueryOptions().WithFindOnly().WithKV("inStatus", []int{domain.ActivityWaiting, domain.ActivityOpening})
  39 + total, dms, err = l.svcCtx.BsiActivityRepository.Find(l.ctx, conn, userToken.CompanyId, queryOptions)
  40 + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
  41 + for _, item := range dms {
  42 + if item.NeedClose() {
  43 + item.Status = domain.ActivityClosed
  44 + if item, err = l.svcCtx.BsiActivityRepository.UpdateWithVersion(l.ctx, conn, item); err != nil {
  45 + return err
  46 + }
  47 + }
  48 + }
  49 + return nil
  50 + }, true); err != nil {
  51 + return nil, xerr.NewErrMsg("保存失败")
  52 + }
  53 +
  54 + queryOptions = domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size)
  55 + if req.Page > 0 {
  56 + queryOptions.WithOffsetLimit(req.Page, req.Size)
  57 + }
  58 + if req.Status != nil {
  59 + queryOptions.WithKV("status", req.Status)
  60 + }
  61 +
  62 + total, dms, err = l.svcCtx.BsiActivityRepository.Find(l.ctx, conn, userToken.CompanyId, queryOptions)
  63 + list := make([]types.ActivityItem, 0)
  64 + for i := range dms {
  65 + item := NewTypesBsiActivity(dms[i])
  66 + item.ActivityConfig = domain.ActivityConfig{}
  67 + list = append(list, item)
  68 + }
  69 +
  70 + resp = &types.ActivitySearchResponse{
  71 + List: list,
  72 + Total: total,
  73 + }
  74 + return
  75 +}
  1 +package activity
  2 +
  3 +import (
  4 + "context"
  5 +
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/types"
  8 +
  9 + "github.com/zeromicro/go-zero/core/logx"
  10 +)
  11 +
  12 +type SystemActivitySubmissionDataExportLogic struct {
  13 + logx.Logger
  14 + ctx context.Context
  15 + svcCtx *svc.ServiceContext
  16 +}
  17 +
  18 +func NewSystemActivitySubmissionDataExportLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemActivitySubmissionDataExportLogic {
  19 + return &SystemActivitySubmissionDataExportLogic{
  20 + Logger: logx.WithContext(ctx),
  21 + ctx: ctx,
  22 + svcCtx: svcCtx,
  23 + }
  24 +}
  25 +
  26 +func (l *SystemActivitySubmissionDataExportLogic) SystemActivitySubmissionDataExport(req *types.SubmissionDataSearchRequest) (resp *types.SubmissionDataSearchResponse, err error) {
  27 + // todo: add your logic here and delete this line
  28 +
  29 + return
  30 +}
  1 +package activity
  2 +
  3 +import (
  4 + "context"
  5 + "fmt"
  6 + "github.com/samber/lo"
  7 + "github.com/zeromicro/go-zero/core/collection"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/interanl/pkg/domain"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/contextdata"
  10 +
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc"
  12 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/types"
  13 +
  14 + "github.com/zeromicro/go-zero/core/logx"
  15 +)
  16 +
  17 +type SystemActivitySubmissionDataSearchLogic struct {
  18 + logx.Logger
  19 + ctx context.Context
  20 + svcCtx *svc.ServiceContext
  21 +}
  22 +
  23 +func NewSystemActivitySubmissionDataSearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemActivitySubmissionDataSearchLogic {
  24 + return &SystemActivitySubmissionDataSearchLogic{
  25 + Logger: logx.WithContext(ctx),
  26 + ctx: ctx,
  27 + svcCtx: svcCtx,
  28 + }
  29 +}
  30 +
  31 +func (l *SystemActivitySubmissionDataSearchLogic) SystemActivitySubmissionDataSearch(req *types.SubmissionDataSearchRequest) (resp *types.SubmissionDataSearchResponse, err error) {
  32 + var (
  33 + conn = l.svcCtx.DefaultDBConn()
  34 + dms []*domain.BsiActivityQuestionnaireSubmitRecord
  35 + total int64
  36 + userToken = contextdata.GetUserTokenFromCtx(l.ctx)
  37 + )
  38 +
  39 + queryOptions := domain.NewQueryOptions().WithFindOnly().
  40 + MustWithKV("activityId", req.ActivityId).MustWithKV("companyId", userToken.CompanyId).
  41 + WithKV("name", req.Name).
  42 + WithKV("product", req.Product).
  43 + WithKV("amountFrom", req.AmountFrom).
  44 + WithKV("amountTo", req.AmountTo)
  45 +
  46 + total, dms, err = l.svcCtx.BsiActivityQuestionnaireSubmitRecordRepository.Find(l.ctx, conn, queryOptions)
  47 + list := make([]types.SubmissionItem, 0)
  48 + set := collection.NewSet()
  49 + for i := range dms {
  50 + item := NewTypesSubmissionItem(dms[i])
  51 + k := keySubmission(item)
  52 + if !set.Contains(k) {
  53 + set.Add(k)
  54 + } else {
  55 + item.IsRepeat = true
  56 + }
  57 + // 重复性条件过滤
  58 + if req.IsRepeat != nil && item.IsRepeat != *req.IsRepeat {
  59 + continue
  60 + }
  61 + // 目标ID过滤
  62 + if len(req.SelectIdList) > 0 {
  63 + if !lo.Contains(req.SelectIdList, dms[i].Id) {
  64 + continue
  65 + }
  66 + }
  67 + list = append(list, item)
  68 + }
  69 + resp = &types.SubmissionDataSearchResponse{
  70 + List: lo.Slice(list, req.Size*(req.Page-1), req.Page*req.Size),
  71 + Total: total,
  72 + }
  73 + return
  74 +}
  75 +
  76 +func keySubmission(item types.SubmissionItem) string {
  77 + return fmt.Sprintf("%v-%v", item.Name, item.Product)
  78 +}
  79 +
  80 +func NewTypesSubmissionItem(item *domain.BsiActivityQuestionnaireSubmitRecord) types.SubmissionItem {
  81 + return types.SubmissionItem{
  82 + Name: item.Name,
  83 + Title: item.User.Title,
  84 + Avatar: item.User.Avatar,
  85 + Product: item.Product,
  86 + Amount: item.Amount,
  87 + Greeting: item.Greeting,
  88 + Time: item.CreatedAt,
  89 + }
  90 +}
  1 +package activity
  2 +
  3 +import (
  4 + "context"
  5 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/interanl/pkg/domain"
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/transaction"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/xerr"
  8 +
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/svc"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/types"
  11 +
  12 + "github.com/zeromicro/go-zero/core/logx"
  13 +)
  14 +
  15 +type SystemActivityUpdateLogic struct {
  16 + logx.Logger
  17 + ctx context.Context
  18 + svcCtx *svc.ServiceContext
  19 +}
  20 +
  21 +func NewSystemActivityUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemActivityUpdateLogic {
  22 + return &SystemActivityUpdateLogic{
  23 + Logger: logx.WithContext(ctx),
  24 + ctx: ctx,
  25 + svcCtx: svcCtx,
  26 + }
  27 +}
  28 +
  29 +func (l *SystemActivityUpdateLogic) SystemActivityUpdate(req *types.ActivityUpdateRequest) (resp *types.ActivityUpdateResponse, err error) {
  30 + var (
  31 + conn = l.svcCtx.DefaultDBConn()
  32 + dm *domain.BsiActivity
  33 + )
  34 + if err = req.Activity.Valid(); err != nil {
  35 + return nil, xerr.NewErrMsg(err.Error())
  36 + }
  37 + if dm, err = l.svcCtx.BsiActivityRepository.FindOne(l.ctx, conn, req.Id); err != nil {
  38 + return nil, xerr.NewErrMsgErr("不存在", err)
  39 + }
  40 + // 不可编辑判断
  41 + if dm.IsOpen() {
  42 + return nil, xerr.NewErrMsg("活动已经开启不可编辑")
  43 + }
  44 + // 赋值
  45 + dm.Issue = req.Activity.Issue
  46 + dm.Remark = req.Activity.Remark
  47 + dm.ActivateType = req.Activity.ActivateType
  48 + dm.BeginAt = req.Activity.BeginAt
  49 + dm.EndAt = req.Activity.EndAt
  50 + dm.ActivityConfig = req.Activity.ActivityConfig
  51 + // 更新
  52 + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
  53 + dm, err = l.svcCtx.BsiActivityRepository.UpdateWithVersion(l.ctx, conn, dm)
  54 + return err
  55 + }, true); err != nil {
  56 + return nil, xerr.NewErrMsg("更新失败")
  57 + }
  58 + resp = &types.ActivityUpdateResponse{}
  59 + return
  60 +}
1 package middleware 1 package middleware
2 -  
3 -import "net/http"  
4 -  
5 -type LogRequestMiddleware struct {  
6 -}  
7 -  
8 -func NewLogRequestMiddleware() *LogRequestMiddleware {  
9 - return &LogRequestMiddleware{}  
10 -}  
11 -  
12 -func (m *LogRequestMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {  
13 - return func(w http.ResponseWriter, r *http.Request) {  
14 - // TODO generate middleware implement function, delete after code implementation  
15 -  
16 - // Passthrough to next handler if need  
17 - next(w, r)  
18 - }  
19 -}  
@@ -4,42 +4,53 @@ import ( @@ -4,42 +4,53 @@ import (
4 "github.com/zeromicro/go-zero/core/stores/redis" 4 "github.com/zeromicro/go-zero/core/stores/redis"
5 "github.com/zeromicro/go-zero/rest" 5 "github.com/zeromicro/go-zero/rest"
6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/config" 6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/api/internal/config"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/interanl/pkg/db/repository"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/interanl/pkg/domain"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/cache"
7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/database" 10 "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/database"
8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/gateway" 11 "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/gateway"
9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/gateway/authlib" 12 "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/gateway/authlib"
10 "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/gateway/openlib" 13 "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/gateway/openlib"
11 "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/gateway/smslib" 14 "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/gateway/smslib"
12 "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/middleware" 15 "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/middleware"
  16 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/transaction"
13 "gorm.io/gorm" 17 "gorm.io/gorm"
14 ) 18 )
15 19
16 type ServiceContext struct { 20 type ServiceContext struct {
17 - Config config.Config  
18 - DB *gorm.DB  
19 - Redis *redis.Redis  
20 -  
21 - LogRequest rest.Middleware  
22 - LoginStatusCheck rest.Middleware  
23 -  
24 - ApiAuthService authlib.ApiAuthService  
25 - SmsService smslib.SMSService  
26 - OpenApiService openlib.OpenApiService 21 + Config config.Config
  22 + DB *gorm.DB
  23 + Redis *redis.Redis
  24 + LogRequest rest.Middleware
  25 + LoginStatusCheck rest.Middleware
  26 + ApiAuthService authlib.ApiAuthService
  27 + SmsService smslib.SMSService
  28 + OpenApiService openlib.OpenApiService
  29 + BsiActivityRepository domain.BsiActivityRepository
  30 + BsiActivityQuestionnaireSubmitRecordRepository domain.BsiActivityQuestionnaireSubmitRecordRepository
27 } 31 }
28 32
29 func NewServiceContext(c config.Config) *ServiceContext { 33 func NewServiceContext(c config.Config) *ServiceContext {
30 db := database.OpenGormPGDB(c.DB.DataSource, c.Log.Mode) 34 db := database.OpenGormPGDB(c.DB.DataSource, c.Log.Mode)
31 35
32 - //mlCache := cache.NewMultiLevelCache([]string{c.Redis.Host}, c.Redis.Pass) 36 + mlCache := cache.NewMultiLevelCache([]string{c.Redis.Host}, c.Redis.Pass)
33 redis, _ := redis.NewRedis(redis.RedisConf{Host: c.Redis.Host, Pass: c.Redis.Pass, Type: "node"}) 37 redis, _ := redis.NewRedis(redis.RedisConf{Host: c.Redis.Host, Pass: c.Redis.Pass, Type: "node"})
34 apiAuth := authlib.ApiAuthService{ 38 apiAuth := authlib.ApiAuthService{
35 Service: gateway.NewService(c.ApiAuth.Name, c.ApiAuth.Host, c.ApiAuth.Timeout), 39 Service: gateway.NewService(c.ApiAuth.Name, c.ApiAuth.Host, c.ApiAuth.Timeout),
36 } 40 }
37 41
38 return &ServiceContext{ 42 return &ServiceContext{
39 - Config: c,  
40 - DB: db,  
41 - Redis: redis,  
42 - ApiAuthService: apiAuth,  
43 - LogRequest: middleware.NewLogRequestMiddleware(c.LogRequest).Handle, 43 + Config: c,
  44 + DB: db,
  45 + Redis: redis,
  46 + ApiAuthService: apiAuth,
  47 + LogRequest: middleware.NewLogRequestMiddleware(c.LogRequest).Handle,
  48 + LoginStatusCheck: middleware.NewLoginStatusCheckMiddleware(apiAuth).Handle,
  49 + BsiActivityRepository: repository.NewBsiActivityRepository(cache.NewCachedRepository(mlCache)),
  50 + BsiActivityQuestionnaireSubmitRecordRepository: repository.NewBsiActivityQuestionnaireSubmitRecordRepository(cache.NewCachedRepository(mlCache)),
44 } 51 }
45 } 52 }
  53 +
  54 +func (svc *ServiceContext) DefaultDBConn() transaction.Conn {
  55 + return transaction.NewTransactionContext(svc.DB)
  56 +}
@@ -13,6 +13,72 @@ type MiniQrCodeRequest struct { @@ -13,6 +13,72 @@ type MiniQrCodeRequest struct {
13 Scene string `json:"scene"` // 参数 13 Scene string `json:"scene"` // 参数
14 } 14 }
15 15
  16 +type ActivityOpenRequest struct {
  17 + Id int64 `json:"id"` // 唯一标识
  18 +}
  19 +
  20 +type ActivityOpenResponse struct {
  21 +}
  22 +
  23 +type ActivityCloseRequest struct {
  24 + Id int64 `json:"id"` // 唯一标识
  25 +}
  26 +
  27 +type ActivityCloseResponse struct {
  28 +}
  29 +
  30 +type QuestionnaireSubmitRequest struct {
  31 + Id int64 `json:"id"` // 活动ID
  32 + FormList []QuestionItem `json:"formList"` // 表单列表
  33 +}
  34 +
  35 +type QuestionnaireSubmitResponse struct {
  36 +}
  37 +
  38 +type SubmissionDataSearchRequest struct {
  39 + Page int `json:"page"`
  40 + Size int `json:"size"`
  41 + ActivityId int64 `json:"activityId,optional"`
  42 + Name string `json:"name,optional"`
  43 + Product string `json:"product,optional"`
  44 + IsRepeat *bool `json:"isRepeat,optional"` // true:重复的 false:正常
  45 + AmountFrom float64 `json:"amountFrom"` // 金额 从多少开始
  46 + AmountTo float64 `json:"amountTo"` // 金额 从多少截至
  47 + SelectIdList []int64 `json:"selectIdList"` // 选择的数据项
  48 +}
  49 +
  50 +type SubmissionDataSearchResponse struct {
  51 + List []SubmissionItem `json:"list"`
  52 + Total int64 `json:"total"`
  53 +}
  54 +
  55 +type PullSubmissionRequest struct {
  56 + Id int64 `json:"id"` // 活动ID
  57 + Timestamp int64 `json:"timestamp"` // 最后一次拉取时间戳,首次为当前时间
  58 +}
  59 +
  60 +type PullSubmissionResponse struct {
  61 + TotalParticipants int64 `json:"totalParticipants"` // 累计参与人次
  62 + List []SubmissionItem `json:"list"`
  63 +}
  64 +
  65 +type SubmissionItem struct {
  66 + Name string `json:"name"` // 投资人姓名
  67 + Title string `json:"title"` // 称谓
  68 + Avatar string `json:"avatar"` // 头像
  69 + Product string `json:"product"` // 产品
  70 + Amount float64 `json:"amount"` // 金额
  71 + Greeting string `json:"greeting"` // 祝福
  72 + Time int64 `json:"time"` //提报时间
  73 + IsRepeat bool `json:"isRepeat"` // 是否重复
  74 +}
  75 +
  76 +type QuestionItem struct {
  77 + Label string `json:"label"` // 字段名称
  78 + Product string `json:"product"` // 商品(非必填)
  79 + Value string `json:"value"` // 值
  80 +}
  81 +
16 type TodoRequest struct { 82 type TodoRequest struct {
17 } 83 }
18 84
  1 +package types
  2 +
  3 +import (
  4 + "fmt"
  5 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/interanl/pkg/domain"
  6 +)
  7 +
  8 +type ActivityGetRequest struct {
  9 + Id int64 `path:"id"`
  10 +}
  11 +
  12 +type ActivityGetResponse struct {
  13 + Activity ActivityItem `json:"activity"`
  14 +}
  15 +
  16 +type ActivitySaveRequest struct {
  17 + Activity ActivityItem `json:"activity"`
  18 +}
  19 +
  20 +type ActivitySaveResponse struct {
  21 +}
  22 +
  23 +type ActivityDeleteRequest struct {
  24 + Id int64 `path:"id"`
  25 +}
  26 +
  27 +type ActivityDeleteResponse struct {
  28 +}
  29 +
  30 +type ActivityUpdateRequest struct {
  31 + Id int64 `path:"id"`
  32 + Activity ActivityItem `json:"activity"`
  33 +}
  34 +
  35 +type ActivityUpdateResponse struct {
  36 +}
  37 +
  38 +type ActivitySearchRequest struct {
  39 + Page int `json:"page"`
  40 + Size int `json:"size"`
  41 + Status *int `json:"status,optional"` // 0:未开始 1:已开始 2:结束
  42 + CompanyId int64 `json:"companyId,optional"` // 公司ID
  43 +}
  44 +
  45 +type ActivitySearchResponse struct {
  46 + List []ActivityItem `json:"list"`
  47 + Total int64 `json:"total"`
  48 +}
  49 +
  50 +type ActivityItem struct {
  51 + Id int64 `json:"id,optional"` // 唯一标识
  52 + CompanyId int64 `json:"companyId,optional"` // 公司ID
  53 + Issue string `json:"issue"` // 活动主题
  54 + Remark string `json:"remark,optional"` // 活动备注
  55 + ActivateType int `json:"activateType"` // 激活类型 1:手动 2:指定日期
  56 + BeginAt int64 `json:"beginAt,optional"` // 活动开始时间(激活类型:2有效)
  57 + EndAt int64 `json:"endAt,optional"` // 活动结束时间(激活类型:2有效)
  58 + Status int `json:"status,optional"` // 活动状态 0:未开始 1:已开始 2:结束
  59 + ActivityConfig domain.ActivityConfig `json:"activityConfig,optional"` // 活动配置
  60 +}
  61 +
  62 +func (item ActivityItem) Valid() error {
  63 + if !(item.ActivateType == domain.OpenByManual || item.ActivateType == domain.OpenBySpecificTime) {
  64 + return fmt.Errorf("激活类型有误 1:手动 2:指定日期")
  65 + }
  66 + if item.ActivateType == domain.OpenBySpecificTime {
  67 + if item.BeginAt > item.EndAt {
  68 + return fmt.Errorf("开始时间不能大于结束时间")
  69 + }
  70 + if item.BeginAt == 0 {
  71 + return fmt.Errorf("开始时间不能为空")
  72 + }
  73 + if item.EndAt == 0 {
  74 + return fmt.Errorf("结束时间不能为空")
  75 + }
  76 + }
  77 + if err := item.ActivityConfig.Valid(); err != nil {
  78 + return err
  79 + }
  80 + return nil
  81 +}
  82 +
  83 +//
  84 +//type ActivityConfig struct {
  85 +// H5Config *H5Config `json:"h5Config"` // H5页面配置
  86 +// Products []Product `json:"products,optional"` // 产品列表
  87 +// QuestionnaireConfig *QuestionnaireConfig `json:"questionnaireConfig"` // 问卷配置
  88 +// ScreenConfig *ScreenConfig `json:"screenConfig"` // 大屏配置
  89 +// DefaultUsers []UserInfo `json:"defaultUsers"` // 预设用户(名字不允许重复)
  90 +//}
  91 +//
  92 +//type H5Config struct {
  93 +// WebPageTitle string `json:"webPageTitle"` // 网页标题配置
  94 +// Announcement string `json:"announcement,optional"` // 公告内容
  95 +//}
  96 +//
  97 +//type Product struct {
  98 +// Id string `json:"id,optional"` // 标识
  99 +// Name string `json:"name,optional"` // 产品名称
  100 +// Cover string `json:"cover,optional"` // 产品封面图片
  101 +// Desc string `json:"desc,optional"` // 产品简介
  102 +//}
  103 +//
  104 +//type QuestionnaireConfig struct {
  105 +// WebPageTitle string `json:"webPageTitle"` // 网页标题配置
  106 +// Announcement string `json:"announcement,optional"` // 公告内容
  107 +// Questions []QuestionItem `json:"questions,optional"` // 问题列表
  108 +//}
  109 +//
  110 +//type QuestionItem struct {
  111 +// Label string `json:"label"` // 字段名称
  112 +// Product string `json:"product,optional"` // 商品(非必填)
  113 +// Type int `json:"type"` // 0:文本 1:单选
  114 +// CheckList []CheckItem `json:"checkList"`
  115 +//}
  116 +//
  117 +//type CheckItem struct {
  118 +// Value string `json:"value"` // 值 例如:500
  119 +// ValueType int `json:"valueType,optional"` // 0.人民币
  120 +//}
  121 +//
  122 +//type ScreenConfig struct {
  123 +// Background string `json:"background"` // 背景图片
  124 +// IsShowInteractiveNum bool `json:"isShowInteractiveNum"` // 是否展示互动数 true:展示 false:不展示
  125 +// Greetings []string `json:"greetings"` // 祝福语
  126 +//}
  127 +//
  128 +//type UserInfo struct {
  129 +// Name string `json:"name"` // 名称
  130 +// Avatar string `json:"avatar,optional"` // 头像
  131 +// Title string `json:"title,optional"` // 称谓
  132 +//}
@@ -2,4 +2,16 @@ CREATE TABLE `todo` @@ -2,4 +2,16 @@ CREATE TABLE `todo`
2 ( 2 (
3 `id` int(0) NOT NULL COMMENT '唯一标识', 3 `id` int(0) NOT NULL COMMENT '唯一标识',
4 PRIMARY KEY (`id`) USING BTREE 4 PRIMARY KEY (`id`) USING BTREE
  5 +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
  6 +
  7 +CREATE TABLE `bsi_activity`
  8 +(
  9 + `id` int(0) NOT NULL COMMENT '唯一标识',
  10 + PRIMARY KEY (`id`) USING BTREE
  11 +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
  12 +
  13 +CREATE TABLE `bsi_activity_questionnaire_submit_record`
  14 +(
  15 + `id` int(0) NOT NULL COMMENT '唯一标识',
  16 + PRIMARY KEY (`id`) USING BTREE
5 ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; 17 ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
@@ -38,5 +38,5 @@ COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/S @@ -38,5 +38,5 @@ COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/S
38 COPY --from=builder /build/api/${PROJECT} ./ 38 COPY --from=builder /build/api/${PROJECT} ./
39 COPY --from=builder /build/cmd/${PROJECTCODE}/api/etc/${CONFIG_FILE} ./etc/ 39 COPY --from=builder /build/cmd/${PROJECTCODE}/api/etc/${CONFIG_FILE} ./etc/
40 40
41 -EXPOSE 8080 41 +EXPOSE 8081
42 ENTRYPOINT ./${PROJECT} -f etc/${CONFIG_FILE} 42 ENTRYPOINT ./${PROJECT} -f etc/${CONFIG_FILE}
  1 +
  2 +syntax = "v1"
  3 +
  4 +info(
  5 + title: "xx实例"
  6 + desc: "xx实例"
  7 + author: "author"
  8 + email: "email"
  9 + version: "v1"
  10 +)
  11 +
  12 +@server(
  13 + prefix: bsi_activity/v1
  14 + group: bsi_activity
  15 + jwt: JwtAuth
  16 +)
  17 +service Core {
  18 + @doc "详情"
  19 + @handler bsi_activityGet
  20 + get /bsi_activity/:id (BsiActivityGetRequest) returns (BsiActivityGetResponse)
  21 + @doc "保存"
  22 + @handler bsi_activitySave
  23 + post /bsi_activity (BsiActivitySaveRequest) returns (BsiActivitySaveResponse)
  24 + @doc "删除"
  25 + @handler bsi_activityDelete
  26 + delete /bsi_activity/:id (BsiActivityDeleteRequest) returns (BsiActivityDeleteResponse)
  27 + @doc "更新"
  28 + @handler bsi_activityUpdate
  29 + put /bsi_activity/:id (BsiActivityUpdateRequest) returns (BsiActivityUpdateResponse)
  30 + @doc "搜索"
  31 + @handler bsi_activitySearch
  32 + post /bsi_activity/search (BsiActivitySearchRequest) returns (BsiActivitySearchResponse)
  33 +}
  34 +
  35 +type (
  36 + BsiActivityGetRequest {
  37 + Id int64 `path:"id"`
  38 + }
  39 + BsiActivityGetResponse struct{
  40 + BsiActivity BsiActivityItem `json:"bsi_activity"`
  41 + }
  42 +
  43 + BsiActivitySaveRequest struct{
  44 + BsiActivity BsiActivityItem `json:"bsi_activity"`
  45 + }
  46 + BsiActivitySaveResponse struct{}
  47 +
  48 + BsiActivityDeleteRequest struct{
  49 + Id int64 `path:"id"`
  50 + }
  51 + BsiActivityDeleteResponse struct{}
  52 +
  53 + BsiActivityUpdateRequest struct{
  54 + Id int64 `path:"id"`
  55 + BsiActivity BsiActivityItem `json:"bsi_activity"`
  56 + }
  57 + BsiActivityUpdateResponse struct{}
  58 +
  59 + BsiActivitySearchRequest struct{
  60 + Page int `json:"page"`
  61 + Size int `json:"size"`
  62 + }
  63 + BsiActivitySearchResponse{
  64 + List []BsiActivityItem `json:"list"`
  65 + Total int64 `json:"total"`
  66 + }
  67 + BsiActivityItem struct{
  68 +
  69 + }
  70 +)
  71 +
  72 +// logic CRUD
  73 +// Save
  74 + //var (
  75 + // conn = l.svcCtx.DefaultDBConn()
  76 + // dm *domain.BsiActivity
  77 + //)
  78 + //// 唯一判断
  79 +
  80 + //dm = NewDomainBsiActivity(req.BsiActivity)
  81 + //if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
  82 + // dm, err = l.svcCtx.BsiActivityRepository.Insert(l.ctx, conn, dm)
  83 + // return err
  84 + //}, true); err != nil {
  85 + // return nil, xerr.NewErrMsg("保存失败")
  86 + //}
  87 + ////resp = &types.BsiActivitySaveResponse{}
  88 + //return
  89 +
  90 +//func NewDomainBsiActivity(item types.BsiActivityItem) *domain.BsiActivity {
  91 +// return &domain.BsiActivity{
  92 +
  93 +// }
  94 +//}
  95 +//
  96 +//func NewTypesBsiActivity(item *domain.BsiActivity) types.BsiActivityItem {
  97 +// return types.BsiActivityItem{
  98 +// Id: item.Id,
  99 +// }
  100 +//}
  101 +
  102 +// Get
  103 + //var (
  104 + // conn = l.svcCtx.DefaultDBConn()
  105 + // dm *domain.BsiActivity
  106 + //)
  107 + //// 货号唯一
  108 + //if dm, err = l.svcCtx.BsiActivityRepository.FindOne(l.ctx, conn, req.Id); err != nil {
  109 + // return nil, xerr.NewErrMsgErr("不存在", err)
  110 + //}
  111 + //resp = &types.BsiActivityGetResponse{
  112 + // BsiActivity: NewTypesBsiActivity(dm),
  113 + //}
  114 + //return
  115 +
  116 +// Delete
  117 + //var (
  118 + // conn = l.svcCtx.DefaultDBConn()
  119 + // dm *domain.BsiActivity
  120 + //)
  121 + //if dm, err = l.svcCtx.BsiActivityRepository.FindOne(l.ctx, conn, req.Id); err != nil {
  122 + // return nil, xerr.NewErrMsgErr("不存在", err)
  123 + //}
  124 + //if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
  125 + // if dm, err = l.svcCtx.BsiActivityRepository.Delete(l.ctx, conn, dm); err != nil {
  126 + // return err
  127 + // }
  128 + // return nil
  129 + //}, true); err != nil {
  130 + // return nil, xerr.NewErrMsgErr("移除失败", err)
  131 + //}
  132 + //return
  133 +
  134 +// Search
  135 + //var (
  136 + // conn = l.svcCtx.DefaultDBConn()
  137 + // dms []*domain.BsiActivity
  138 + // total int64
  139 + //)
  140 + //
  141 + //queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size).
  142 + // WithKV("", "")
  143 +
  144 + //total, dms, err = l.svcCtx.BsiActivityRepository.Find(l.ctx, conn, queryOptions)
  145 + //list := make([]types.BsiActivityItem, 0)
  146 + //for i := range dms {
  147 + // list = append(list, NewTypesBsiActivity(dms[i]))
  148 + //}
  149 + //resp = &types.BsiActivitySearchResponse{
  150 + // List: list,
  151 + // Total: total,
  152 + //}
  153 + //return
  154 +
  155 +// Update
  156 + //var (
  157 + // conn = l.svcCtx.DefaultDBConn()
  158 + // dm *domain.BsiActivity
  159 + //)
  160 + //if dm, err = l.svcCtx.BsiActivityRepository.FindOne(l.ctx, conn, req.Id); err != nil {
  161 + // return nil, xerr.NewErrMsgErr("不存在", err)
  162 + //}
  163 + //// 不可编辑判断
  164 +
  165 + //// 赋值
  166 +
  167 + //// 更新
  168 + //if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
  169 + // dm, err = l.svcCtx.BsiActivityRepository.UpdateWithVersion(l.ctx, conn, dm)
  170 + // return err
  171 + //}, true); err != nil {
  172 + // return nil, xerr.NewErrMsg("更新失败")
  173 + //}
  174 + //resp = &types.BsiActivityUpdateResponse{}
  175 + //return
  1 +
  2 +syntax = "v1"
  3 +
  4 +info(
  5 + title: "xx实例"
  6 + desc: "xx实例"
  7 + author: "author"
  8 + email: "email"
  9 + version: "v1"
  10 +)
  11 +
  12 +@server(
  13 + prefix: bsi_activity_questionnaire_submit_record/v1
  14 + group: bsi_activity_questionnaire_submit_record
  15 + jwt: JwtAuth
  16 +)
  17 +service Core {
  18 + @doc "详情"
  19 + @handler bsi_activity_questionnaire_submit_recordGet
  20 + get /bsi_activity_questionnaire_submit_record/:id (BsiActivityQuestionnaireSubmitRecordGetRequest) returns (BsiActivityQuestionnaireSubmitRecordGetResponse)
  21 + @doc "保存"
  22 + @handler bsi_activity_questionnaire_submit_recordSave
  23 + post /bsi_activity_questionnaire_submit_record (BsiActivityQuestionnaireSubmitRecordSaveRequest) returns (BsiActivityQuestionnaireSubmitRecordSaveResponse)
  24 + @doc "删除"
  25 + @handler bsi_activity_questionnaire_submit_recordDelete
  26 + delete /bsi_activity_questionnaire_submit_record/:id (BsiActivityQuestionnaireSubmitRecordDeleteRequest) returns (BsiActivityQuestionnaireSubmitRecordDeleteResponse)
  27 + @doc "更新"
  28 + @handler bsi_activity_questionnaire_submit_recordUpdate
  29 + put /bsi_activity_questionnaire_submit_record/:id (BsiActivityQuestionnaireSubmitRecordUpdateRequest) returns (BsiActivityQuestionnaireSubmitRecordUpdateResponse)
  30 + @doc "搜索"
  31 + @handler bsi_activity_questionnaire_submit_recordSearch
  32 + post /bsi_activity_questionnaire_submit_record/search (BsiActivityQuestionnaireSubmitRecordSearchRequest) returns (BsiActivityQuestionnaireSubmitRecordSearchResponse)
  33 +}
  34 +
  35 +type (
  36 + BsiActivityQuestionnaireSubmitRecordGetRequest {
  37 + Id int64 `path:"id"`
  38 + }
  39 + BsiActivityQuestionnaireSubmitRecordGetResponse struct{
  40 + BsiActivityQuestionnaireSubmitRecord BsiActivityQuestionnaireSubmitRecordItem `json:"bsi_activity_questionnaire_submit_record"`
  41 + }
  42 +
  43 + BsiActivityQuestionnaireSubmitRecordSaveRequest struct{
  44 + BsiActivityQuestionnaireSubmitRecord BsiActivityQuestionnaireSubmitRecordItem `json:"bsi_activity_questionnaire_submit_record"`
  45 + }
  46 + BsiActivityQuestionnaireSubmitRecordSaveResponse struct{}
  47 +
  48 + BsiActivityQuestionnaireSubmitRecordDeleteRequest struct{
  49 + Id int64 `path:"id"`
  50 + }
  51 + BsiActivityQuestionnaireSubmitRecordDeleteResponse struct{}
  52 +
  53 + BsiActivityQuestionnaireSubmitRecordUpdateRequest struct{
  54 + Id int64 `path:"id"`
  55 + BsiActivityQuestionnaireSubmitRecord BsiActivityQuestionnaireSubmitRecordItem `json:"bsi_activity_questionnaire_submit_record"`
  56 + }
  57 + BsiActivityQuestionnaireSubmitRecordUpdateResponse struct{}
  58 +
  59 + BsiActivityQuestionnaireSubmitRecordSearchRequest struct{
  60 + Page int `json:"page"`
  61 + Size int `json:"size"`
  62 + }
  63 + BsiActivityQuestionnaireSubmitRecordSearchResponse{
  64 + List []BsiActivityQuestionnaireSubmitRecordItem `json:"list"`
  65 + Total int64 `json:"total"`
  66 + }
  67 + BsiActivityQuestionnaireSubmitRecordItem struct{
  68 +
  69 + }
  70 +)
  71 +
  72 +// logic CRUD
  73 +// Save
  74 + //var (
  75 + // conn = l.svcCtx.DefaultDBConn()
  76 + // dm *domain.BsiActivityQuestionnaireSubmitRecord
  77 + //)
  78 + //// 唯一判断
  79 +
  80 + //dm = NewDomainBsiActivityQuestionnaireSubmitRecord(req.BsiActivityQuestionnaireSubmitRecord)
  81 + //if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
  82 + // dm, err = l.svcCtx.BsiActivityQuestionnaireSubmitRecordRepository.Insert(l.ctx, conn, dm)
  83 + // return err
  84 + //}, true); err != nil {
  85 + // return nil, xerr.NewErrMsg("保存失败")
  86 + //}
  87 + ////resp = &types.BsiActivityQuestionnaireSubmitRecordSaveResponse{}
  88 + //return
  89 +
  90 +//func NewDomainBsiActivityQuestionnaireSubmitRecord(item types.BsiActivityQuestionnaireSubmitRecordItem) *domain.BsiActivityQuestionnaireSubmitRecord {
  91 +// return &domain.BsiActivityQuestionnaireSubmitRecord{
  92 +
  93 +// }
  94 +//}
  95 +//
  96 +//func NewTypesBsiActivityQuestionnaireSubmitRecord(item *domain.BsiActivityQuestionnaireSubmitRecord) types.BsiActivityQuestionnaireSubmitRecordItem {
  97 +// return types.BsiActivityQuestionnaireSubmitRecordItem{
  98 +// Id: item.Id,
  99 +// }
  100 +//}
  101 +
  102 +// Get
  103 + //var (
  104 + // conn = l.svcCtx.DefaultDBConn()
  105 + // dm *domain.BsiActivityQuestionnaireSubmitRecord
  106 + //)
  107 + //// 货号唯一
  108 + //if dm, err = l.svcCtx.BsiActivityQuestionnaireSubmitRecordRepository.FindOne(l.ctx, conn, req.Id); err != nil {
  109 + // return nil, xerr.NewErrMsgErr("不存在", err)
  110 + //}
  111 + //resp = &types.BsiActivityQuestionnaireSubmitRecordGetResponse{
  112 + // BsiActivityQuestionnaireSubmitRecord: NewTypesBsiActivityQuestionnaireSubmitRecord(dm),
  113 + //}
  114 + //return
  115 +
  116 +// Delete
  117 + //var (
  118 + // conn = l.svcCtx.DefaultDBConn()
  119 + // dm *domain.BsiActivityQuestionnaireSubmitRecord
  120 + //)
  121 + //if dm, err = l.svcCtx.BsiActivityQuestionnaireSubmitRecordRepository.FindOne(l.ctx, conn, req.Id); err != nil {
  122 + // return nil, xerr.NewErrMsgErr("不存在", err)
  123 + //}
  124 + //if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
  125 + // if dm, err = l.svcCtx.BsiActivityQuestionnaireSubmitRecordRepository.Delete(l.ctx, conn, dm); err != nil {
  126 + // return err
  127 + // }
  128 + // return nil
  129 + //}, true); err != nil {
  130 + // return nil, xerr.NewErrMsgErr("移除失败", err)
  131 + //}
  132 + //return
  133 +
  134 +// Search
  135 + //var (
  136 + // conn = l.svcCtx.DefaultDBConn()
  137 + // dms []*domain.BsiActivityQuestionnaireSubmitRecord
  138 + // total int64
  139 + //)
  140 + //
  141 + //queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size).
  142 + // WithKV("", "")
  143 +
  144 + //total, dms, err = l.svcCtx.BsiActivityQuestionnaireSubmitRecordRepository.Find(l.ctx, conn, queryOptions)
  145 + //list := make([]types.BsiActivityQuestionnaireSubmitRecordItem, 0)
  146 + //for i := range dms {
  147 + // list = append(list, NewTypesBsiActivityQuestionnaireSubmitRecord(dms[i]))
  148 + //}
  149 + //resp = &types.BsiActivityQuestionnaireSubmitRecordSearchResponse{
  150 + // List: list,
  151 + // Total: total,
  152 + //}
  153 + //return
  154 +
  155 +// Update
  156 + //var (
  157 + // conn = l.svcCtx.DefaultDBConn()
  158 + // dm *domain.BsiActivityQuestionnaireSubmitRecord
  159 + //)
  160 + //if dm, err = l.svcCtx.BsiActivityQuestionnaireSubmitRecordRepository.FindOne(l.ctx, conn, req.Id); err != nil {
  161 + // return nil, xerr.NewErrMsgErr("不存在", err)
  162 + //}
  163 + //// 不可编辑判断
  164 +
  165 + //// 赋值
  166 +
  167 + //// 更新
  168 + //if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
  169 + // dm, err = l.svcCtx.BsiActivityQuestionnaireSubmitRecordRepository.UpdateWithVersion(l.ctx, conn, dm)
  170 + // return err
  171 + //}, true); err != nil {
  172 + // return nil, xerr.NewErrMsg("更新失败")
  173 + //}
  174 + //resp = &types.BsiActivityQuestionnaireSubmitRecordUpdateResponse{}
  175 + //return
  1 +
  2 +syntax = "proto3";
  3 +
  4 +option go_package ="./pb";
  5 +
  6 +package pb;
  7 +
  8 +message BsiActivityGetReq {
  9 + int64 Id = 1;
  10 +}
  11 +message BsiActivityGetResp{
  12 + BsiActivityItem User = 1;
  13 +}
  14 +
  15 +message BsiActivitySaveReq {
  16 +
  17 +}
  18 +message BsiActivitySaveResp{
  19 +
  20 +}
  21 +
  22 +message BsiActivityDeleteReq {
  23 + int64 Id = 1;
  24 +}
  25 +message BsiActivityDeleteResp{
  26 +
  27 +}
  28 +
  29 +message BsiActivityUpdateReq {
  30 + int64 Id = 1;
  31 +}
  32 +message BsiActivityUpdateResp{
  33 +
  34 +}
  35 +
  36 +message BsiActivitySearchReq {
  37 + int64 PageNumber = 1;
  38 + int64 PageSize = 2;
  39 +}
  40 +message BsiActivitySearchResp{
  41 + repeated BsiActivityItem List =1;
  42 + int64 Total =2;
  43 +}
  44 +message BsiActivityItem {
  45 +
  46 +}
  47 +
  48 +service BsiActivityService {
  49 + rpc BsiActivityGet(BsiActivityGetReq) returns(BsiActivityGetResp);
  50 + rpc BsiActivitySave(BsiActivitySaveReq) returns(BsiActivitySaveResp);
  51 + rpc BsiActivityDelete(BsiActivityDeleteReq) returns(BsiActivityDeleteResp);
  52 + rpc BsiActivityUpdate(BsiActivityUpdateReq) returns(BsiActivityUpdateResp);
  53 + rpc BsiActivitySearch(BsiActivitySearchReq) returns(BsiActivitySearchResp);
  54 +}
  1 +
  2 +syntax = "proto3";
  3 +
  4 +option go_package ="./pb";
  5 +
  6 +package pb;
  7 +
  8 +message BsiActivityQuestionnaireSubmitRecordGetReq {
  9 + int64 Id = 1;
  10 +}
  11 +message BsiActivityQuestionnaireSubmitRecordGetResp{
  12 + BsiActivityQuestionnaireSubmitRecordItem User = 1;
  13 +}
  14 +
  15 +message BsiActivityQuestionnaireSubmitRecordSaveReq {
  16 +
  17 +}
  18 +message BsiActivityQuestionnaireSubmitRecordSaveResp{
  19 +
  20 +}
  21 +
  22 +message BsiActivityQuestionnaireSubmitRecordDeleteReq {
  23 + int64 Id = 1;
  24 +}
  25 +message BsiActivityQuestionnaireSubmitRecordDeleteResp{
  26 +
  27 +}
  28 +
  29 +message BsiActivityQuestionnaireSubmitRecordUpdateReq {
  30 + int64 Id = 1;
  31 +}
  32 +message BsiActivityQuestionnaireSubmitRecordUpdateResp{
  33 +
  34 +}
  35 +
  36 +message BsiActivityQuestionnaireSubmitRecordSearchReq {
  37 + int64 PageNumber = 1;
  38 + int64 PageSize = 2;
  39 +}
  40 +message BsiActivityQuestionnaireSubmitRecordSearchResp{
  41 + repeated BsiActivityQuestionnaireSubmitRecordItem List =1;
  42 + int64 Total =2;
  43 +}
  44 +message BsiActivityQuestionnaireSubmitRecordItem {
  45 +
  46 +}
  47 +
  48 +service BsiActivityQuestionnaireSubmitRecordService {
  49 + rpc BsiActivityQuestionnaireSubmitRecordGet(BsiActivityQuestionnaireSubmitRecordGetReq) returns(BsiActivityQuestionnaireSubmitRecordGetResp);
  50 + rpc BsiActivityQuestionnaireSubmitRecordSave(BsiActivityQuestionnaireSubmitRecordSaveReq) returns(BsiActivityQuestionnaireSubmitRecordSaveResp);
  51 + rpc BsiActivityQuestionnaireSubmitRecordDelete(BsiActivityQuestionnaireSubmitRecordDeleteReq) returns(BsiActivityQuestionnaireSubmitRecordDeleteResp);
  52 + rpc BsiActivityQuestionnaireSubmitRecordUpdate(BsiActivityQuestionnaireSubmitRecordUpdateReq) returns(BsiActivityQuestionnaireSubmitRecordUpdateResp);
  53 + rpc BsiActivityQuestionnaireSubmitRecordSearch(BsiActivityQuestionnaireSubmitRecordSearchReq) returns(BsiActivityQuestionnaireSubmitRecordSearchResp);
  54 +}
1 package db 1 package db
2 2
3 import ( 3 import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/interanl/pkg/db/models"
4 "gorm.io/gorm" 5 "gorm.io/gorm"
5 ) 6 )
6 7
7 func Migrate(db *gorm.DB) { 8 func Migrate(db *gorm.DB) {
8 - db.AutoMigrate() 9 + db.AutoMigrate(&models.BsiActivity{}, &models.BsiActivityQuestionnaireSubmitRecord{})
9 } 10 }
  1 +package models
  2 +
  3 +import (
  4 + "fmt"
  5 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/interanl/pkg/domain"
  6 + "gorm.io/gorm"
  7 + "gorm.io/plugin/soft_delete"
  8 + "time"
  9 +)
  10 +
  11 +type BsiActivity struct {
  12 + Id int64 // 唯一标识
  13 + CompanyId int64 // 公司ID
  14 + Issue string // 活动主题
  15 + Remark string // 活动备注
  16 + ActivateType int // 激活类型 1:手动 2:指定日期
  17 + BeginAt int64 // 活动开始时间(激活类型:2有效)
  18 + EndAt int64 // 活动结束时间(激活类型:2有效)
  19 + Status int // 活动状态 0:未开始 1:已开始 2:结束
  20 + ActivityConfig domain.ActivityConfig `gorm:"type:jsonb;serializer:json"` // 活动配置
  21 + CreatedAt int64
  22 + UpdatedAt int64
  23 + IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
  24 + DeletedAt int64
  25 + Version int
  26 +}
  27 +
  28 +func (m *BsiActivity) TableName() string {
  29 + return "bsi_activity"
  30 +}
  31 +
  32 +func (m *BsiActivity) BeforeCreate(tx *gorm.DB) (err error) {
  33 + m.CreatedAt = time.Now().Unix()
  34 + m.UpdatedAt = time.Now().Unix()
  35 + return
  36 +}
  37 +
  38 +func (m *BsiActivity) BeforeUpdate(tx *gorm.DB) (err error) {
  39 + m.UpdatedAt = time.Now().Unix()
  40 + return
  41 +}
  42 +
  43 +func (m *BsiActivity) CacheKeyFunc() string {
  44 + if m.Id == 0 {
  45 + return ""
  46 + }
  47 + return fmt.Sprintf("%v:cache:%v:id:%v", domain.ProjectName, m.TableName(), m.Id)
  48 +}
  49 +
  50 +func (m *BsiActivity) CacheKeyFuncByObject(obj interface{}) string {
  51 + if v, ok := obj.(*BsiActivity); ok {
  52 + return v.CacheKeyFunc()
  53 + }
  54 + return ""
  55 +}
  56 +
  57 +func (m *BsiActivity) CachePrimaryKeyFunc() string {
  58 + if len("") == 0 {
  59 + return ""
  60 + }
  61 + return fmt.Sprintf("%v:cache:%v:primarykey:%v", domain.ProjectName, m.TableName(), "key")
  62 +}
  1 +package models
  2 +
  3 +import (
  4 + "fmt"
  5 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/interanl/pkg/domain"
  6 + "gorm.io/gorm"
  7 + "gorm.io/plugin/soft_delete"
  8 + "time"
  9 +)
  10 +
  11 +type BsiActivityQuestionnaireSubmitRecord struct {
  12 + Id int64 // 唯一标识
  13 + CompanyId int64 // 公司ID
  14 + ActivityId int64 // 活动ID
  15 + Name string // 提交人名字
  16 + Product string // 商品
  17 + Amount float64 // 金额
  18 + User domain.UserInfo `gorm:"type:jsonb;serializer:json"` // 提交人
  19 + Greeting string // 祝福
  20 +
  21 + CreatedAt int64
  22 + UpdatedAt int64
  23 + IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
  24 + DeletedAt int64
  25 + Version int
  26 +}
  27 +
  28 +func (m *BsiActivityQuestionnaireSubmitRecord) TableName() string {
  29 + return "bsi_activity_questionnaire_submit_record"
  30 +}
  31 +
  32 +func (m *BsiActivityQuestionnaireSubmitRecord) BeforeCreate(tx *gorm.DB) (err error) {
  33 + m.CreatedAt = time.Now().Unix()
  34 + m.UpdatedAt = time.Now().Unix()
  35 + return
  36 +}
  37 +
  38 +func (m *BsiActivityQuestionnaireSubmitRecord) BeforeUpdate(tx *gorm.DB) (err error) {
  39 + m.UpdatedAt = time.Now().Unix()
  40 + return
  41 +}
  42 +
  43 +func (m *BsiActivityQuestionnaireSubmitRecord) CacheKeyFunc() string {
  44 + return ""
  45 + //if m.Id == 0 {
  46 + // return ""
  47 + //}
  48 + //return fmt.Sprintf("%v:cache:%v:id:%v", domain.ProjectName, m.TableName(), m.Id)
  49 +}
  50 +
  51 +func (m *BsiActivityQuestionnaireSubmitRecord) CacheKeyFuncByObject(obj interface{}) string {
  52 + if v, ok := obj.(*BsiActivityQuestionnaireSubmitRecord); ok {
  53 + return v.CacheKeyFunc()
  54 + }
  55 + return ""
  56 +}
  57 +
  58 +func (m *BsiActivityQuestionnaireSubmitRecord) CachePrimaryKeyFunc() string {
  59 + if len("") == 0 {
  60 + return ""
  61 + }
  62 + return fmt.Sprintf("%v:cache:%v:primarykey:%v", domain.ProjectName, m.TableName(), "key")
  63 +}
  1 +package repository
  2 +
  3 +import (
  4 + "context"
  5 + "fmt"
  6 + "github.com/jinzhu/copier"
  7 + "github.com/pkg/errors"
  8 + "github.com/tiptok/gocomm/pkg/cache"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/interanl/pkg/db/models"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/interanl/pkg/domain"
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/transaction"
  12 + "gorm.io/gorm"
  13 +)
  14 +
  15 +type BsiActivityQuestionnaireSubmitRecordRepository struct {
  16 + *cache.CachedRepository
  17 +}
  18 +
  19 +func (repository *BsiActivityQuestionnaireSubmitRecordRepository) Insert(ctx context.Context, conn transaction.Conn, dm *domain.BsiActivityQuestionnaireSubmitRecord) (*domain.BsiActivityQuestionnaireSubmitRecord, error) {
  20 + var (
  21 + err error
  22 + m = &models.BsiActivityQuestionnaireSubmitRecord{}
  23 + tx = conn.DB()
  24 + )
  25 + if m, err = repository.DomainModelToModel(dm); err != nil {
  26 + return nil, err
  27 + }
  28 + if tx = tx.Model(m).Save(m); tx.Error != nil {
  29 + return nil, tx.Error
  30 + }
  31 + dm.Id = m.Id
  32 + return repository.ModelToDomainModel(m)
  33 +
  34 +}
  35 +
  36 +func (repository *BsiActivityQuestionnaireSubmitRecordRepository) Update(ctx context.Context, conn transaction.Conn, dm *domain.BsiActivityQuestionnaireSubmitRecord) (*domain.BsiActivityQuestionnaireSubmitRecord, error) {
  37 + var (
  38 + err error
  39 + m *models.BsiActivityQuestionnaireSubmitRecord
  40 + tx = conn.DB()
  41 + )
  42 + if m, err = repository.DomainModelToModel(dm); err != nil {
  43 + return nil, err
  44 + }
  45 + queryFunc := func() (interface{}, error) {
  46 + tx = tx.Model(m).Updates(m)
  47 + return nil, tx.Error
  48 + }
  49 + if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
  50 + return nil, err
  51 + }
  52 + return repository.ModelToDomainModel(m)
  53 +}
  54 +
  55 +func (repository *BsiActivityQuestionnaireSubmitRecordRepository) UpdateWithVersion(ctx context.Context, transaction transaction.Conn, dm *domain.BsiActivityQuestionnaireSubmitRecord) (*domain.BsiActivityQuestionnaireSubmitRecord, error) {
  56 + var (
  57 + err error
  58 + m *models.BsiActivityQuestionnaireSubmitRecord
  59 + tx = transaction.DB()
  60 + )
  61 + if m, err = repository.DomainModelToModel(dm); err != nil {
  62 + return nil, err
  63 + }
  64 + oldVersion := dm.Version
  65 + m.Version += 1
  66 + queryFunc := func() (interface{}, error) {
  67 + tx = tx.Model(m).Select("*").Where("id = ?", m.Id).Where("version = ?", oldVersion).Updates(m)
  68 + if tx.RowsAffected == 0 {
  69 + return nil, domain.ErrUpdateFail
  70 + }
  71 + return nil, tx.Error
  72 + }
  73 + if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
  74 + return nil, err
  75 + }
  76 + return repository.ModelToDomainModel(m)
  77 +}
  78 +
  79 +func (repository *BsiActivityQuestionnaireSubmitRecordRepository) Delete(ctx context.Context, conn transaction.Conn, dm *domain.BsiActivityQuestionnaireSubmitRecord) (*domain.BsiActivityQuestionnaireSubmitRecord, error) {
  80 + var (
  81 + tx = conn.DB()
  82 + m = &models.BsiActivityQuestionnaireSubmitRecord{Id: dm.Identify().(int64)}
  83 + )
  84 + queryFunc := func() (interface{}, error) {
  85 + tx = tx.Where("id = ?", m.Id).Delete(m)
  86 + return m, tx.Error
  87 + }
  88 + if _, err := repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
  89 + return dm, err
  90 + }
  91 + return repository.ModelToDomainModel(m)
  92 +}
  93 +
  94 +func (repository *BsiActivityQuestionnaireSubmitRecordRepository) FindOne(ctx context.Context, conn transaction.Conn, id int64) (*domain.BsiActivityQuestionnaireSubmitRecord, error) {
  95 + var (
  96 + err error
  97 + tx = conn.DB()
  98 + m = new(models.BsiActivityQuestionnaireSubmitRecord)
  99 + )
  100 + queryFunc := func() (interface{}, error) {
  101 + tx = tx.Model(m).Where("id = ?", id).First(m)
  102 + if errors.Is(tx.Error, gorm.ErrRecordNotFound) {
  103 + return nil, domain.ErrNotFound
  104 + }
  105 + return m, tx.Error
  106 + }
  107 + cacheModel := new(models.BsiActivityQuestionnaireSubmitRecord)
  108 + cacheModel.Id = id
  109 + if err = repository.QueryCache(cacheModel.CacheKeyFunc, m, queryFunc); err != nil {
  110 + return nil, err
  111 + }
  112 + return repository.ModelToDomainModel(m)
  113 +}
  114 +
  115 +func (repository *BsiActivityQuestionnaireSubmitRecordRepository) Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*domain.BsiActivityQuestionnaireSubmitRecord, error) {
  116 + var (
  117 + tx = conn.DB()
  118 + ms []*models.BsiActivityQuestionnaireSubmitRecord
  119 + dms = make([]*domain.BsiActivityQuestionnaireSubmitRecord, 0)
  120 + total int64
  121 + )
  122 + queryFunc := func() (interface{}, error) {
  123 + tx = tx.Model(&ms).Order("id desc")
  124 + if v, ok := queryOptions["activityId"]; ok {
  125 + tx.Where("activity_id = ? ", v)
  126 + }
  127 + // 列表查询条件
  128 + if v, ok := queryOptions["name"]; ok {
  129 + tx.Where("name like ? ", fmt.Sprintf("%%%v%%", v))
  130 + }
  131 + if v, ok := queryOptions["product"]; ok {
  132 + tx.Where("product like ? ", fmt.Sprintf("%%%v%%", v))
  133 + }
  134 + if v, ok := queryOptions["amountFrom"]; ok {
  135 + tx.Where("amount >= ? ", v)
  136 + }
  137 + if v, ok := queryOptions["amountTo"]; ok {
  138 + tx.Where("amount < ? ", v)
  139 + }
  140 + if v, ok := queryOptions["timestamp"]; ok {
  141 + tx.Where("created_at > ? ", v)
  142 + }
  143 + if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil {
  144 + return dms, tx.Error
  145 + }
  146 + return dms, nil
  147 + }
  148 +
  149 + if _, err := repository.Query(queryFunc); err != nil {
  150 + return 0, nil, err
  151 + }
  152 +
  153 + for _, item := range ms {
  154 + if dm, err := repository.ModelToDomainModel(item); err != nil {
  155 + return 0, dms, err
  156 + } else {
  157 + dms = append(dms, dm)
  158 + }
  159 + }
  160 + return total, dms, nil
  161 +}
  162 +
  163 +func (repository *BsiActivityQuestionnaireSubmitRecordRepository) ModelToDomainModel(from *models.BsiActivityQuestionnaireSubmitRecord) (*domain.BsiActivityQuestionnaireSubmitRecord, error) {
  164 + to := &domain.BsiActivityQuestionnaireSubmitRecord{}
  165 + err := copier.Copy(to, from)
  166 + return to, err
  167 +}
  168 +
  169 +func (repository *BsiActivityQuestionnaireSubmitRecordRepository) DomainModelToModel(from *domain.BsiActivityQuestionnaireSubmitRecord) (*models.BsiActivityQuestionnaireSubmitRecord, error) {
  170 + to := &models.BsiActivityQuestionnaireSubmitRecord{}
  171 + err := copier.Copy(to, from)
  172 + return to, err
  173 +}
  174 +
  175 +func NewBsiActivityQuestionnaireSubmitRecordRepository(cache *cache.CachedRepository) domain.BsiActivityQuestionnaireSubmitRecordRepository {
  176 + return &BsiActivityQuestionnaireSubmitRecordRepository{CachedRepository: cache}
  177 +}
  1 +package repository
  2 +
  3 +import (
  4 + "context"
  5 + "github.com/jinzhu/copier"
  6 + "github.com/pkg/errors"
  7 + "github.com/tiptok/gocomm/pkg/cache"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/interanl/pkg/db/models"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/cmd/bsi/interanl/pkg/domain"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/transaction"
  11 + "gorm.io/gorm"
  12 +)
  13 +
  14 +type BsiActivityRepository struct {
  15 + *cache.CachedRepository
  16 +}
  17 +
  18 +func (repository *BsiActivityRepository) Insert(ctx context.Context, conn transaction.Conn, dm *domain.BsiActivity) (*domain.BsiActivity, error) {
  19 + var (
  20 + err error
  21 + m = &models.BsiActivity{}
  22 + tx = conn.DB()
  23 + )
  24 + if m, err = repository.DomainModelToModel(dm); err != nil {
  25 + return nil, err
  26 + }
  27 + if tx = tx.Model(m).Save(m); tx.Error != nil {
  28 + return nil, tx.Error
  29 + }
  30 + dm.Id = m.Id
  31 + return repository.ModelToDomainModel(m)
  32 +
  33 +}
  34 +
  35 +func (repository *BsiActivityRepository) Update(ctx context.Context, conn transaction.Conn, dm *domain.BsiActivity) (*domain.BsiActivity, error) {
  36 + var (
  37 + err error
  38 + m *models.BsiActivity
  39 + tx = conn.DB()
  40 + )
  41 + if m, err = repository.DomainModelToModel(dm); err != nil {
  42 + return nil, err
  43 + }
  44 + queryFunc := func() (interface{}, error) {
  45 + tx = tx.Model(m).Updates(m)
  46 + return nil, tx.Error
  47 + }
  48 + if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
  49 + return nil, err
  50 + }
  51 + return repository.ModelToDomainModel(m)
  52 +}
  53 +
  54 +func (repository *BsiActivityRepository) UpdateWithVersion(ctx context.Context, transaction transaction.Conn, dm *domain.BsiActivity) (*domain.BsiActivity, error) {
  55 + var (
  56 + err error
  57 + m *models.BsiActivity
  58 + tx = transaction.DB()
  59 + )
  60 + if m, err = repository.DomainModelToModel(dm); err != nil {
  61 + return nil, err
  62 + }
  63 + oldVersion := dm.Version
  64 + m.Version += 1
  65 + queryFunc := func() (interface{}, error) {
  66 + tx = tx.Model(m).Select("*").Where("id = ?", m.Id).Where("version = ?", oldVersion).Updates(m)
  67 + if tx.RowsAffected == 0 {
  68 + return nil, domain.ErrUpdateFail
  69 + }
  70 + return nil, tx.Error
  71 + }
  72 + if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
  73 + return nil, err
  74 + }
  75 + return repository.ModelToDomainModel(m)
  76 +}
  77 +
  78 +func (repository *BsiActivityRepository) Delete(ctx context.Context, conn transaction.Conn, dm *domain.BsiActivity) (*domain.BsiActivity, error) {
  79 + var (
  80 + tx = conn.DB()
  81 + m = &models.BsiActivity{Id: dm.Identify().(int64)}
  82 + )
  83 + queryFunc := func() (interface{}, error) {
  84 + tx = tx.Where("id = ?", m.Id).Delete(m)
  85 + return m, tx.Error
  86 + }
  87 + if _, err := repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
  88 + return dm, err
  89 + }
  90 + return repository.ModelToDomainModel(m)
  91 +}
  92 +
  93 +func (repository *BsiActivityRepository) FindOne(ctx context.Context, conn transaction.Conn, id int64) (*domain.BsiActivity, error) {
  94 + var (
  95 + err error
  96 + tx = conn.DB()
  97 + m = new(models.BsiActivity)
  98 + )
  99 + queryFunc := func() (interface{}, error) {
  100 + tx = tx.Model(m).Where("id = ?", id).First(m)
  101 + if errors.Is(tx.Error, gorm.ErrRecordNotFound) {
  102 + return nil, domain.ErrNotFound
  103 + }
  104 + return m, tx.Error
  105 + }
  106 + cacheModel := new(models.BsiActivity)
  107 + cacheModel.Id = id
  108 + if err = repository.QueryCache(cacheModel.CacheKeyFunc, m, queryFunc); err != nil {
  109 + return nil, err
  110 + }
  111 + return repository.ModelToDomainModel(m)
  112 +}
  113 +
  114 +func (repository *BsiActivityRepository) Find(ctx context.Context, conn transaction.Conn, companyId int64, queryOptions map[string]interface{}) (int64, []*domain.BsiActivity, error) {
  115 + var (
  116 + tx = conn.DB()
  117 + ms []*models.BsiActivity
  118 + dms = make([]*domain.BsiActivity, 0)
  119 + total int64
  120 + )
  121 + queryFunc := func() (interface{}, error) {
  122 + tx = tx.Model(&ms).Order("id desc")
  123 + tx.Where("company_id = ?", companyId)
  124 + if v, ok := queryOptions["status"]; ok {
  125 + tx.Where("status = ?", v)
  126 + }
  127 + if v, ok := queryOptions["inStatus"]; ok {
  128 + tx.Where("status in (?)", v)
  129 + }
  130 + if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil {
  131 + return dms, tx.Error
  132 + }
  133 + return dms, nil
  134 + }
  135 +
  136 + if _, err := repository.Query(queryFunc); err != nil {
  137 + return 0, nil, err
  138 + }
  139 +
  140 + for _, item := range ms {
  141 + if dm, err := repository.ModelToDomainModel(item); err != nil {
  142 + return 0, dms, err
  143 + } else {
  144 + dms = append(dms, dm)
  145 + }
  146 + }
  147 + return total, dms, nil
  148 +}
  149 +
  150 +func (repository *BsiActivityRepository) ModelToDomainModel(from *models.BsiActivity) (*domain.BsiActivity, error) {
  151 + to := &domain.BsiActivity{}
  152 + err := copier.Copy(to, from)
  153 + return to, err
  154 +}
  155 +
  156 +func (repository *BsiActivityRepository) DomainModelToModel(from *domain.BsiActivity) (*models.BsiActivity, error) {
  157 + to := &models.BsiActivity{}
  158 + err := copier.Copy(to, from)
  159 + return to, err
  160 +}
  161 +
  162 +func NewBsiActivityRepository(cache *cache.CachedRepository) domain.BsiActivityRepository {
  163 + return &BsiActivityRepository{CachedRepository: cache}
  164 +}
  1 +package domain
  2 +
  3 +import (
  4 + "context"
  5 + "fmt"
  6 + "github.com/zeromicro/go-zero/core/collection"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/transaction"
  8 + "math/rand"
  9 + "time"
  10 +)
  11 +
  12 +type BsiActivity struct {
  13 + Id int64 `json:"id,optional"` // 唯一标识
  14 + CompanyId int64 `json:"companyId,optional"` // 公司ID
  15 + Issue string `json:"issue"` // 活动主题
  16 + Remark string `json:"remark,optional"` // 活动备注
  17 + ActivateType int `json:"activateType"` // 激活类型 1:手动 2:指定日期
  18 + BeginAt int64 `json:"beginAt,optional"` // 活动开始时间(激活类型:2有效)
  19 + EndAt int64 `json:"endAt,optional"` // 活动结束时间(激活类型:2有效)
  20 + Status int `json:"status,optional"` // 活动状态 0:未开始 1:已开始 2:结束
  21 + ActivityConfig ActivityConfig `json:"activityConfig,optional"` // 活动配置
  22 + CreatedAt int64
  23 + UpdatedAt int64
  24 + DeletedAt int64
  25 + Version int
  26 +}
  27 +
  28 +const (
  29 + ActivityWaiting = 0
  30 + ActivityOpening = 1
  31 + ActivityClosed = 2
  32 +)
  33 +
  34 +const (
  35 + OpenByManual = 1 // 手动开启
  36 + OpenBySpecificTime = 2 // 特定时间
  37 +)
  38 +
  39 +type BsiActivityRepository interface {
  40 + Insert(ctx context.Context, conn transaction.Conn, dm *BsiActivity) (*BsiActivity, error)
  41 + Update(ctx context.Context, conn transaction.Conn, dm *BsiActivity) (*BsiActivity, error)
  42 + UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *BsiActivity) (*BsiActivity, error)
  43 + Delete(ctx context.Context, conn transaction.Conn, dm *BsiActivity) (*BsiActivity, error)
  44 + FindOne(ctx context.Context, conn transaction.Conn, id int64) (*BsiActivity, error)
  45 + Find(ctx context.Context, conn transaction.Conn, companyId int64, queryOptions map[string]interface{}) (int64, []*BsiActivity, error)
  46 +}
  47 +
  48 +func (m *BsiActivity) Identify() interface{} {
  49 + if m.Id == 0 {
  50 + return nil
  51 + }
  52 + return m.Id
  53 +}
  54 +
  55 +func (m *BsiActivity) ResolveActivityStatus() int {
  56 + if m.Status == ActivityClosed {
  57 + return m.Status
  58 + }
  59 + if m.IsOpen() {
  60 + return ActivityOpening
  61 + }
  62 + if m.IsClosed() {
  63 + return ActivityClosed
  64 + }
  65 + return m.Status
  66 +}
  67 +
  68 +func (m *BsiActivity) IsOpen() bool {
  69 + if m.ActivateType == OpenByManual {
  70 + if m.Status == ActivityOpening {
  71 + return true
  72 + }
  73 + }
  74 + if m.ActivateType == OpenBySpecificTime {
  75 + if m.BeginAt <= time.Now().Unix() && m.EndAt > time.Now().Unix() {
  76 + return true
  77 + }
  78 + }
  79 + return false
  80 +}
  81 +
  82 +func (m *BsiActivity) IsClosed() bool {
  83 + if m.NeedClose() {
  84 + return true
  85 + }
  86 + if m.Status == ActivityClosed {
  87 + return false
  88 + }
  89 + return false
  90 +}
  91 +
  92 +func (m *BsiActivity) NeedClose() bool {
  93 + if m.Status == ActivityClosed {
  94 + return false
  95 + }
  96 + if m.ActivateType == OpenBySpecificTime {
  97 + if m.EndAt < time.Now().Unix() {
  98 + return true
  99 + }
  100 + }
  101 + return false
  102 +}
  103 +
  104 +func (m *BsiActivity) RandomGreeting() string {
  105 + if m.ActivityConfig.ScreenConfig == nil {
  106 + return ""
  107 + }
  108 + if len(m.ActivityConfig.ScreenConfig.Greetings) == 0 {
  109 + return ""
  110 + }
  111 + idx := rand.Intn(len(m.ActivityConfig.ScreenConfig.Greetings))
  112 + return m.ActivityConfig.ScreenConfig.Greetings[idx]
  113 +}
  114 +
  115 +type ActivityConfig struct {
  116 + H5Config *H5Config `json:"h5Config"` // H5页面配置
  117 + Products []Product `json:"products,optional"` // 产品列表
  118 + QuestionnaireConfig *QuestionnaireConfig `json:"questionnaireConfig"` // 问卷配置
  119 + ScreenConfig *ScreenConfig `json:"screenConfig"` // 大屏配置
  120 + DefaultUsers []UserInfo `json:"defaultUsers"` // 预设用户(名字不允许重复)
  121 +}
  122 +
  123 +func (item ActivityConfig) Valid() error {
  124 + usersDup := collection.NewSet()
  125 + for _, u := range item.DefaultUsers {
  126 + if !usersDup.Contains(u.Name) {
  127 + usersDup.Add(u.Name)
  128 + continue
  129 + }
  130 + return fmt.Errorf("预设用户名重复`%v`", u.Name)
  131 + }
  132 +
  133 + productDup := collection.NewSet()
  134 + for _, u := range item.Products {
  135 + if !productDup.Contains(u.Name) {
  136 + productDup.Add(u.Name)
  137 + continue
  138 + }
  139 + return fmt.Errorf("商品名重复`%v`", u.Name)
  140 + }
  141 + return nil
  142 +}
  143 +
  144 +type H5Config struct {
  145 + WebPageTitle string `json:"webPageTitle"` // 网页标题配置
  146 + Announcement string `json:"announcement,optional"` // 公告内容
  147 +}
  148 +
  149 +type Product struct {
  150 + // Id string `json:"id,optional"` // 标识
  151 + Name string `json:"name,optional"` // 产品名称
  152 + Cover string `json:"cover,optional"` // 产品封面图片
  153 + Desc string `json:"desc,optional"` // 产品简介
  154 +}
  155 +
  156 +type QuestionnaireConfig struct {
  157 + WebPageTitle string `json:"webPageTitle"` // 网页标题配置
  158 + Announcement string `json:"announcement,optional"` // 公告内容
  159 + Questions []QuestionItem `json:"questions,optional"` // 问题列表
  160 +}
  161 +
  162 +type QuestionItem struct {
  163 + Label string `json:"label"` // 字段名称
  164 + Product string `json:"product,optional"` // 商品(非必填)
  165 + Type int `json:"type"` // 0:文本 1:单选
  166 + CheckList []CheckItem `json:"checkList"`
  167 +}
  168 +
  169 +type CheckItem struct {
  170 + Value string `json:"value"` // 值 例如:500
  171 + ValueType int `json:"valueType,optional"` // 0.人民币
  172 +}
  173 +
  174 +type ScreenConfig struct {
  175 + Background string `json:"background"` // 背景图片
  176 + IsShowInteractiveNum bool `json:"isShowInteractiveNum"` // 是否展示互动数 true:展示 false:不展示
  177 + Greetings []string `json:"greetings"` // 祝福语
  178 +}
  179 +
  180 +type UserInfo struct {
  181 + Name string `json:"name"` // 名称
  182 + Avatar string `json:"avatar,optional"` // 头像
  183 + Title string `json:"title,optional"` // 称谓
  184 +}
  1 +package domain
  2 +
  3 +import (
  4 + "context"
  5 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc/pkg/transaction"
  6 +)
  7 +
  8 +type BsiActivityQuestionnaireSubmitRecord struct {
  9 + Id int64 // 唯一标识
  10 + CompanyId int64 // 公司ID
  11 + ActivityId int64 // 活动ID
  12 + Name string // 提交人名字
  13 + Product string // 商品
  14 + Amount float64 // 金额
  15 + User UserInfo // 提交人
  16 + Greeting string // 祝福
  17 + CreatedAt int64
  18 + UpdatedAt int64
  19 + DeletedAt int64
  20 + Version int
  21 +}
  22 +
  23 +type BsiActivityQuestionnaireSubmitRecordRepository interface {
  24 + Insert(ctx context.Context, conn transaction.Conn, dm *BsiActivityQuestionnaireSubmitRecord) (*BsiActivityQuestionnaireSubmitRecord, error)
  25 + Update(ctx context.Context, conn transaction.Conn, dm *BsiActivityQuestionnaireSubmitRecord) (*BsiActivityQuestionnaireSubmitRecord, error)
  26 + UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *BsiActivityQuestionnaireSubmitRecord) (*BsiActivityQuestionnaireSubmitRecord, error)
  27 + Delete(ctx context.Context, conn transaction.Conn, dm *BsiActivityQuestionnaireSubmitRecord) (*BsiActivityQuestionnaireSubmitRecord, error)
  28 + FindOne(ctx context.Context, conn transaction.Conn, id int64) (*BsiActivityQuestionnaireSubmitRecord, error)
  29 + Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*BsiActivityQuestionnaireSubmitRecord, error)
  30 +}
  31 +
  32 +func (m *BsiActivityQuestionnaireSubmitRecord) Identify() interface{} {
  33 + if m.Id == 0 {
  34 + return nil
  35 + }
  36 + return m.Id
  37 +}
@@ -30,6 +30,8 @@ require ( @@ -30,6 +30,8 @@ require (
30 github.com/eapache/go-resiliency v1.3.0 // indirect 30 github.com/eapache/go-resiliency v1.3.0 // indirect
31 github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect 31 github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
32 github.com/eapache/queue v1.1.0 // indirect 32 github.com/eapache/queue v1.1.0 // indirect
  33 + github.com/extrame/ole2 v0.0.0-20160812065207-d69429661ad7 // indirect
  34 + github.com/extrame/xls v0.0.1 // indirect
33 github.com/fatih/color v1.15.0 // indirect 35 github.com/fatih/color v1.15.0 // indirect
34 github.com/fsnotify/fsnotify v1.4.9 // indirect 36 github.com/fsnotify/fsnotify v1.4.9 // indirect
35 github.com/garyburd/redigo v1.6.3 // indirect 37 github.com/garyburd/redigo v1.6.3 // indirect
@@ -80,6 +82,9 @@ require ( @@ -80,6 +82,9 @@ require (
80 github.com/prometheus/common v0.42.0 // indirect 82 github.com/prometheus/common v0.42.0 // indirect
81 github.com/prometheus/procfs v0.10.1 // indirect 83 github.com/prometheus/procfs v0.10.1 // indirect
82 github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect 84 github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
  85 + github.com/richardlehane/mscfb v1.0.4 // indirect
  86 + github.com/richardlehane/msoleps v1.0.1 // indirect
  87 + github.com/samber/lo v1.39.0 // indirect
83 github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect 88 github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect
84 github.com/spaolacci/murmur3 v1.1.0 // indirect 89 github.com/spaolacci/murmur3 v1.1.0 // indirect
85 github.com/spf13/afero v1.2.2 // indirect 90 github.com/spf13/afero v1.2.2 // indirect
@@ -87,7 +92,11 @@ require ( @@ -87,7 +92,11 @@ require (
87 github.com/spf13/jwalterweatherman v1.0.0 // indirect 92 github.com/spf13/jwalterweatherman v1.0.0 // indirect
88 github.com/spf13/pflag v1.0.5 // indirect 93 github.com/spf13/pflag v1.0.5 // indirect
89 github.com/spf13/viper v1.4.0 // indirect 94 github.com/spf13/viper v1.4.0 // indirect
  95 + github.com/tiptok/tab v0.0.0-20220923060916-58c234e99dff // indirect
90 github.com/ugorji/go/codec v1.1.7 // indirect 96 github.com/ugorji/go/codec v1.1.7 // indirect
  97 + github.com/xuri/efp v0.0.0-20220407160117-ad0f7a785be8 // indirect
  98 + github.com/xuri/excelize/v2 v2.6.0 // indirect
  99 + github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 // indirect
91 go.opentelemetry.io/otel v1.14.0 // indirect 100 go.opentelemetry.io/otel v1.14.0 // indirect
92 go.opentelemetry.io/otel/exporters/jaeger v1.14.0 // indirect 101 go.opentelemetry.io/otel/exporters/jaeger v1.14.0 // indirect
93 go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.14.0 // indirect 102 go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.14.0 // indirect
@@ -101,6 +110,7 @@ require ( @@ -101,6 +110,7 @@ require (
101 go.opentelemetry.io/proto/otlp v0.19.0 // indirect 110 go.opentelemetry.io/proto/otlp v0.19.0 // indirect
102 go.uber.org/automaxprocs v1.5.3 // indirect 111 go.uber.org/automaxprocs v1.5.3 // indirect
103 golang.org/x/crypto v0.12.0 // indirect 112 golang.org/x/crypto v0.12.0 // indirect
  113 + golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect
104 golang.org/x/net v0.14.0 // indirect 114 golang.org/x/net v0.14.0 // indirect
105 golang.org/x/sys v0.11.0 // indirect 115 golang.org/x/sys v0.11.0 // indirect
106 golang.org/x/text v0.12.0 // indirect 116 golang.org/x/text v0.12.0 // indirect
@@ -2,8 +2,8 @@ package xerr @@ -2,8 +2,8 @@ package xerr
2 2
3 import ( 3 import (
4 "context" 4 "context"
  5 + "github.com/samber/lo"
5 "github.com/zeromicro/go-zero/core/logx" 6 "github.com/zeromicro/go-zero/core/logx"
6 - "google.golang.org/grpc/status"  
7 "net/http" 7 "net/http"
8 ) 8 )
9 9
@@ -11,22 +11,15 @@ func ErrorHandlerCtx(ctx context.Context, err error) (int, any) { @@ -11,22 +11,15 @@ func ErrorHandlerCtx(ctx context.Context, err error) (int, any) {
11 //错误返回 11 //错误返回
12 var ( 12 var (
13 errCode = ServerCommonError 13 errCode = ServerCommonError
  14 + errMsg = ""
14 ) 15 )
15 // 自定义错误类型 16 // 自定义错误类型
16 if codeError, ok := err.(*CodeError); ok { 17 if codeError, ok := err.(*CodeError); ok {
17 errCode = codeError.GetErrCode() 18 errCode = codeError.GetErrCode()
18 - } else {  
19 - // grpc err错误  
20 - var grpcStatus *status.Status  
21 - if grpcStatus, ok = status.FromError(err); ok {  
22 - grpcCode := int(grpcStatus.Code())  
23 - if IsCodeErr(grpcCode) {  
24 - errCode = grpcCode  
25 - }  
26 - } 19 + errMsg = codeError.GetErrMsg()
27 } 20 }
28 logx.WithContext(ctx).Errorf("【ERROR-HANDLER】 : %+v ", err) 21 logx.WithContext(ctx).Errorf("【ERROR-HANDLER】 : %+v ", err)
29 - response := Error(errCode, MapErrMsg(errCode)) 22 + response := Error(int(errCode), lo.Ternary(errMsg != "", errMsg, MapErrMsg(errCode)))
30 response.Error = err.Error() 23 response.Error = err.Error()
31 return http.StatusOK, response 24 return http.StatusOK, response
32 } 25 }