Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dt_analysis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haoyanbin
dt_analysis
Commits
7970f4d3
Commit
7970f4d3
authored
Sep 08, 2023
by
haoyanbin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
ebfe0db7
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
52 additions
and
20 deletions
+52
-20
survey.go
api/mobile/survey.go
+17
-14
user.go
api/mobile/user.go
+23
-6
survey.go
model/request/survey.go
+1
-0
sys_user.go
model/request/sys_user.go
+2
-0
survey.go
model/survey.go
+3
-0
survey.go
router/survey.go
+1
-0
survey.go
service/survey.go
+5
-0
No files found.
api/mobile/survey.go
View file @
7970f4d3
...
...
@@ -57,31 +57,34 @@ func CreateSurveyUser(c *gin.Context) {
var
req
request
.
CreateSurveyUserReq
_
=
c
.
ShouldBindJSON
(
&
req
)
ipData
,
_
:=
service
.
GetIpaddr
(
c
.
ClientIP
())
SurveyUser
:=
model
.
SurveyUser
{
SurveyId
:
1
,
UserId
:
req
.
UserId
,
MocId
:
req
.
MocId
,
Id
:
req
.
Id
,
Contacts
:
req
.
Contacts
,
ContactsMobile
:
req
.
ContactsMobile
,
Reference
:
req
.
Reference
,
ReferenceMobile
:
req
.
ReferenceMobile
,
CreateTime
:
utils
.
NowTime
(),
Country
:
ipData
.
Country
,
Area
:
ipData
.
Area
,
Region
:
ipData
.
Region
,
City
:
ipData
.
City
,
Status
:
1
,
}
_
,
surveyUserId
:=
service
.
CreateSurveyUser
(
SurveyUser
)
service
.
UpdateSurveyUser
(
SurveyUser
)
//for _, v := range req.Data {
// v.SurveyUserId = surveyUserId
// service.CreateSurveyUserData(v)
//}
response
.
OkWithMessage
(
"修改成功"
,
c
)
return
}
func
CreateSurveyUserData
(
c
*
gin
.
Context
)
{
var
req
request
.
CreateSurveyUserReq
_
=
c
.
ShouldBindJSON
(
&
req
)
for
_
,
v
:=
range
req
.
Data
{
v
.
SurveyUserId
=
surveyUser
Id
v
.
SurveyUserId
=
req
.
Id
service
.
CreateSurveyUserData
(
v
)
}
response
.
OkWithMessage
(
"创建成功"
,
c
)
response
.
OkWithMessage
(
"修改成功"
,
c
)
return
}
...
...
api/mobile/user.go
View file @
7970f4d3
...
...
@@ -44,17 +44,34 @@ func SendCode(c *gin.Context) {
}
func
CheckCode
(
c
*
gin
.
Context
)
{
var
r
request
.
CheckCodeReq
_
=
c
.
ShouldBindJSON
(
&
r
)
var
r
eq
request
.
CheckCodeReq
_
=
c
.
ShouldBindJSON
(
&
r
eq
)
data
:=
service
.
GetMobileCode
(
r
.
Mobile
)
data
:=
service
.
GetMobileCode
(
r
eq
.
Mobile
)
if
data
.
Code
==
r
.
Code
||
r
.
Code
=
=
"999888"
{
response
.
OkWithMessage
(
"验证成功
"
,
c
)
if
data
.
Code
!=
req
.
Code
&&
req
.
Code
!
=
"999888"
{
response
.
FailWithMessage
(
"验证码不正确
"
,
c
)
return
}
response
.
FailWithMessage
(
"验证失败"
,
c
)
ipData
,
_
:=
service
.
GetIpaddr
(
c
.
ClientIP
())
SurveyUser
:=
model
.
SurveyUser
{
SurveyId
:
1
,
UserId
:
req
.
UserId
,
MocId
:
req
.
MocId
,
CodeMobile
:
req
.
Mobile
,
Code
:
req
.
Code
,
CreateTime
:
utils
.
NowTime
(),
Country
:
ipData
.
Country
,
Area
:
ipData
.
Area
,
Region
:
ipData
.
Region
,
City
:
ipData
.
City
,
}
_
,
surveyUserId
:=
service
.
CreateSurveyUser
(
SurveyUser
)
response
.
OkWithData
(
map
[
string
]
int
{
"id"
:
surveyUserId
},
c
)
return
}
...
...
model/request/survey.go
View file @
7970f4d3
...
...
@@ -4,6 +4,7 @@ import "gin-vue-admin/model"
type
CreateSurveyUserReq
struct
{
Data
[]
model
.
SurveyUserData
`json:"data"`
Id
int
`gorm:"type:int(255)" json:"id"`
SurveyId
int
`gorm:"type:int(255)" json:"survey_id"`
UserId
int
`gorm:"type:int(255)" json:"user_id"`
MocId
int
`gorm:"type:int(255)" json:"moc_id"`
...
...
model/request/sys_user.go
View file @
7970f4d3
...
...
@@ -10,6 +10,8 @@ type SendCodeReq struct {
}
type
CheckCodeReq
struct
{
UserId
int
`gorm:"type:int(255)" json:"user_id"`
MocId
int
`gorm:"type:int(255)" json:"moc_id"`
Mobile
string
`json:"mobile"`
Code
string
`json:"code"`
}
...
...
model/survey.go
View file @
7970f4d3
...
...
@@ -6,6 +6,8 @@ type SurveyUser struct {
SurveyId
int
`gorm:"type:int(255)" json:"survey_id"`
UserId
int
`gorm:"type:int(255)" json:"user_id"`
MocId
int
`gorm:"type:int(255)" json:"moc_id"`
CodeMobile
string
`gorm:"type:string(255)" json:"code_mobile"`
Code
string
`gorm:"type:string(255)" json:"code"`
Contacts
string
`gorm:"type:string(255)" json:"contacts"`
ContactsMobile
string
`gorm:"type:string(255)" json:"contacts_mobile"`
Reference
string
`gorm:"type:string(255)" json:"reference"`
...
...
@@ -15,6 +17,7 @@ type SurveyUser struct {
Area
string
`gorm:"type:string(255)" json:"area"`
Region
string
`gorm:"type:string(255)" json:"region"`
City
string
`gorm:"type:string(255)" json:"city"`
Status
int
`gorm:"type:int(255)" json:"status"`
}
type
SurveyUserData
struct
{
...
...
router/survey.go
View file @
7970f4d3
...
...
@@ -18,6 +18,7 @@ func InitSurveyPublicRouter(Router *gin.RouterGroup) {
DataVipCommentRouter
:=
Router
.
Group
(
"survey"
)
.
Use
(
middleware
.
OperationRecord
())
{
DataVipCommentRouter
.
POST
(
"create"
,
mobile
.
CreateSurveyUser
)
DataVipCommentRouter
.
POST
(
"createData"
,
mobile
.
CreateSurveyUserData
)
DataVipCommentRouter
.
POST
(
"createLog"
,
mobile
.
CreateSurveyLog
)
DataVipCommentRouter
.
GET
(
"exportSurveyUserExcel"
,
mobile
.
ExportSurveyUserExcel
)
}
...
...
service/survey.go
View file @
7970f4d3
...
...
@@ -12,6 +12,11 @@ func CreateSurveyUser(req model.SurveyUser) (error, int) {
return
err
,
req
.
Id
}
func
UpdateSurveyUser
(
req
model
.
SurveyUser
)
(
error
,
int
)
{
err
:=
global
.
GVA_DB
.
Table
(
"survey_user"
)
.
Where
(
"id=?"
,
req
.
Id
)
.
Updates
(
&
req
)
.
Error
return
err
,
req
.
Id
}
func
CreateSurveyUserData
(
req
model
.
SurveyUserData
)
error
{
err
:=
global
.
GVA_DB
.
Table
(
"survey_user_data"
)
.
Create
(
&
req
)
.
Error
return
err
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment